• R/O
  • SSH
  • HTTPS

haribote: Commit


Commit MetaInfo

Revision189 (tree)
Time2010-03-01 21:33:30
Authortatsupc

Log Message

add edorbfs's format function

Change Summary

Incremental Difference

--- haribote/trunk/orbspace/edorbfs/io_img.c (revision 188)
+++ haribote/trunk/orbspace/edorbfs/io_img.c (revision 189)
@@ -0,0 +1,20 @@
1+#include "io_img.h"
2+
3+FILE *imgfp;
4+
5+unsigned int io_init(unsigned char *name, unsigned char *mode)
6+{
7+ if ((imgfp = fopen(name, mode)) == 0) {
8+ return 2;
9+ }
10+ return 0;
11+}
12+
13+unsigned int io_write(unsigned char *buf, unsigned int addr, unsigned int size)
14+{
15+ fseek(imgfp, addr, SEEK_SET);
16+ if (fwrite(buf, size, 1, imgfp) == 0) {
17+ return 2;
18+ }
19+ return 0;
20+}
--- haribote/trunk/orbspace/edorbfs/edorbfs.c (revision 188)
+++ haribote/trunk/orbspace/edorbfs/edorbfs.c (revision 189)
@@ -1,7 +1,110 @@
11 #include "io_img.h"
22 #include "..\orbspace\orbfs.h"
3+#include <stdlib.h>
4+#include <string.h>
35
6+static unsigned char ptable[16] = {
7+ 0x80, 0x00, 0x00, 0x00, 0x0d, 0x00, 0x00, 0x00,
8+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
9+};
10+
11+unsigned int cmd_create(unsigned char **args)
12+{
13+ return 0;
14+}
15+
16+unsigned int cmd_delete(unsigned char **args)
17+{
18+ return 0;
19+}
20+
21+unsigned int cmd_format(unsigned char **args)
22+{
23+ FILE *fp;
24+ unsigned char *fbuf;
25+ unsigned int fsize, i;
26+
27+ fsize = atoi(args[1]) * 1024;
28+ if ((i = io_init(args[0], "wb")) != 0) {
29+ return i;
30+ }
31+ fbuf = (unsigned char *) malloc(fsize);
32+ memset(fbuf, 0, fsize);
33+ if ((fp = fopen(args[2], "rb")) == 0) {
34+ return 3;
35+ }
36+ fread(fbuf, 446, 1, fp);
37+ memcpy(fbuf + 446, ptable, 16);
38+ *((unsigned int *) (fbuf + 446 + 0x0c)) = (unsigned int) (fsize + 511) / 512;
39+ fbuf[510] = 0x55; fbuf[511] = 0xaa;
40+ if ((i = io_write(fbuf, 0, fsize)) != 0) {
41+ return i;
42+ }
43+ return 0;
44+}
45+
46+unsigned int cmd_list(unsigned char **args)
47+{
48+ return 0;
49+}
50+
51+struct cmdtype {
52+ unsigned char cmd;
53+ unsigned int argn;
54+ unsigned int (*func)(unsigned char **);
55+} cmdtypes[4] = {
56+ { 'c', 2, cmd_create },
57+ { 'd', 1, cmd_delete },
58+ { 'f', 4, cmd_format },
59+ { 'l', 1, cmd_list }
60+};
61+
62+static unsigned char *errmsg[] = {
63+ "command syntax error",
64+ "image file error",
65+ "IPL error"
66+};
67+
68+void print_usage(void)
69+{
70+ puts("usage>edorbfs -c (from:dir\file.ext) (to:/imgfile/dir/file.ext)");
71+ puts(" >edorbfs -d (:/imgfile/dir/file.ext)");
72+ puts(" >edorbfs -f (imgfile) (imgsize by KB) (ipl:dir\file.ext) (os:dir\file.ext)");
73+ puts(" >edorbfs -l (:/imgfile/dir)");
74+ return;
75+}
76+
77+void print_error(unsigned int no)
78+{
79+ if (no > 0) {
80+ printf("edorbfs:%s\n", errmsg[no - 1]);
81+ }
82+ exit(1);
83+}
84+
485 int main(int argc, char **argv)
586 {
87+ unsigned char *args[4];
88+ int i, j;
89+
90+ if (argc < 2 && argv[1][0] != '-') {
91+ print_usage();
92+ print_error(0);
93+ }
94+ for (i = 0; i < 4; i++) {
95+ if (argv[1][1] == cmdtypes[i].cmd) {
96+ if (argc != (cmdtypes[i].argn + 2)) {
97+ print_error(1);
98+ }
99+ for (j = 0; j < 4; j++) {
100+ args[j] = (cmdtypes[i].argn >= (j + 1)) ? argv[j + 2] : 0;
101+ }
102+ if ((i = cmdtypes[i].func(args))) {
103+ print_error(i);
104+ }
105+ return 0;
106+ }
107+ }
108+ print_error(0);
6109 return 0;
7110 }
--- haribote/trunk/orbspace/edorbfs/io_img.h (revision 188)
+++ haribote/trunk/orbspace/edorbfs/io_img.h (revision 189)
@@ -1 +1,4 @@
11 #include <stdio.h>
2+
3+unsigned int io_init(unsigned char *name, unsigned char *mode);
4+unsigned int io_write(unsigned char *buf, unsigned int addr, unsigned int size);
--- haribote/trunk/orbspace/orbspace.txt (revision 188)
+++ haribote/trunk/orbspace/orbspace.txt (revision 189)
@@ -1,3 +1,6 @@
1+
2+=== 注意:基本的に実現してしまい、必要の無くなったものは削除していきます。 ===
3+
14 orbspace - 球を利用した新しい3DUIを提供するOS
25
36 * orbspaceとは
@@ -34,12 +37,7 @@
3437 0x00098000- 汎用データ領域
3538
3639 ** edorbfs
37->edorbfs
38-usage>edorbfs -c (from:dir\file.ext) (to:/imgfile/dir/file.ext)
39- >edorbfs -d (:/imgfile/dir/file.ext)
40- >edorbfs -f (imgfile) (imgsize by KB) (ipl:dir\file.ext) (os:dir\file.ext)
41- >edorbfs -l [(:/imgfile/dir)]
42->edorbfs -f orbspace.img 253440 orbspace\ipl.bin orbspace\orbspace.sys
40+>edorbfs -f orbspace.img 131072 orbspace\ipl.bin orbspace\orbspace.sys
4341 >edorbfs -c sin\sin.orb /orbspace.img/sin.orb
4442 >edorbfs -c circle\circle.orb /orbspace.img/circle.orb
4543 >edorbfs -c orbspace\main.c /orbspace.img/src/orbspace/main.c
@@ -61,8 +59,6 @@
6159 2048 circle.orb
6260 <DIR> src
6361
64-=== 注意:edorbfs、I/O(USBやImageFileAPIとの操作部分)、orbfs(ファイルシステム部分)に完全に分離 ===
65-
6662 * メモリマップ
6763 0x00000000-0x00007bff:あき(0x7c00バイト、31KB)
6864 0x00007c00-0x0009fbff:USBメモリイメージ(BPB、orbSAT、OS部分)(0x98000バイト、608KB)
@@ -109,7 +105,3 @@
109105 === 注意:OSのコード(orbspace.sys)は必ずエントリの先頭にあることと、断片化していないこと ===
110106
111107 * USB制御
112-
113-* 公開形式
114- -sourceforge.jp内でのSVN公開
115- -haribote.orgの個人ページでの告知
--- haribote/trunk/orbspace/Makefile (revision 188)
+++ haribote/trunk/orbspace/Makefile (revision 189)
@@ -1,2 +1,9 @@
1+default:
2+ make -C orbspace
3+
14 config:
25 make -C edorbfs
6+
7+clean:
8+ make -C edorbfs clean
9+ make -C orbspace clean
--- haribote/trunk/orbspace/orbspace/Makefile (nonexistent)
+++ haribote/trunk/orbspace/orbspace/Makefile (revision 189)
@@ -0,0 +1,12 @@
1+TOOLPATH = ../../z_tools/
2+NASK = $(TOOLPATH)nask.exe
3+
4+default:
5+ make ipl.bin
6+
7+ipl.bin: ipl.nas Makefile
8+ $(NASK) ipl.nas ipl.bin ipl.lst
9+
10+clean:
11+ del ipl.bin
12+ del ipl.lst
Show on old repository browser