orbspace
@@ -12,29 +12,24 @@ | ||
12 | 12 | |
13 | 13 | |
14 | 14 | |
15 | -1.orbFS | |
15 | +[ orbFS ] | |
16 | 16 | |
17 | -1-1.全体の構造 | |
17 | +** 全体の構造 | |
18 | 18 | 0x00000000-0x000001ff BPB(IPL、パーティションテーブル、0xaa55) |
19 | 19 | 0x00000200-0x00001dff orbSAT |
20 | 20 | 0x00001e00- データ領域 |
21 | 21 | |
22 | -1-2.orbSAT:orb Sector Allocation Table | |
22 | +** orbSAT:orb Sector Allocation Table | |
23 | 23 | -連続していないセクタを管理するときに使用 |
24 | 24 | -例:0x00000800 0x00001000 0x0000fff1 0x00000000 |
25 | 25 | =>0x800番目の次が0x1000番目、0xfff1番目が最後(つまりディスクは32MB使われている) |
26 | 26 | -このテーブルはデータ領域を対象とする(0x00001e00-0x00001fffまでを1番目とする) |
27 | 27 | |
28 | -1-3.データ領域の構造 | |
28 | +** データ領域の構造 | |
29 | 29 | 0x0000-0x0003 サイズ |
30 | 30 | 0x0004-0x000f 名前 |
31 | 31 | 0x0010-0x01ff メタデータ |
32 | -0x0200- 512バイトにアラインされたデータ部分 | |
33 | - (整理ボールの場合はファイルアドレスの羅列) | |
34 | - | |
35 | -1-3-1.メタデータの構造 | |
36 | - -この部分は次のようなテキストデータである | |
37 | - (先頭の" + "は引用文であることを示しており、改行コードは0x0aのみ) | |
32 | + (以下のようなテキストデータの羅列、先頭の" + "は引用文のマーク) | |
38 | 33 | + Type=File |
39 | 34 | + CreateDate=2010/1/1 |
40 | 35 | + CreateTime=12:29:06 |
@@ -45,7 +40,10 @@ | ||
45 | 40 | + Author=tatsu |
46 | 41 | + Keyword=orbspace |
47 | 42 | |
48 | -1-4.mkorbfs:ディスクイメージツール | |
43 | +0x0200- 512バイトにアラインされたデータ部分 | |
44 | + (整理ボールの場合はファイルアドレスの羅列) | |
45 | + | |
46 | +** mkorbfs:ディスクイメージツール | |
49 | 47 | >mkorbfs orbspace.img 131072 orbspace\ipl.bin \ |
50 | 48 | +File orbspace\orbspace.sys \ |
51 | 49 | +Ball orbspace Color=0xff0000 \ |
@@ -57,9 +55,9 @@ | ||
57 | 55 | |
58 | 56 | |
59 | 57 | |
60 | -2.orbScript | |
58 | +[ orbScript ] | |
61 | 59 | |
62 | -2-1.検索ボール(search.orb)の作成例 | |
60 | +** 検索ボール(search.orb)の作成例 | |
63 | 61 | + keyword = input(1) # 展開した後再入力可能、入力データをkeywordへ格納 |
64 | 62 | + collect(keyword, 1) # keywordに一致するものをボールの中へ集める、 |
65 | 63 | + ボールから離れても中身を維持し続ける |
@@ -66,9 +64,9 @@ | ||
66 | 64 | |
67 | 65 | |
68 | 66 | |
69 | -3.メモリマップ | |
67 | +[ メモリマップ ] | |
70 | 68 | 0x00000000-0x00007bff あき(31KB) |
71 | -0x00007c00-0x00096bff USBメモリの先頭部分(572KB) | |
69 | +0x00007c00-0x00096bff USBメモリの先頭部分(572KB、必要ないデータは0クリアされる) | |
72 | 70 | 0x00096c00-0x000fffff あき(421KB) |
73 | 71 | 0x00100000-0x001007ff IDT(2KB) |
74 | 72 | 0x00100800-0x001107ff GDT(64KB) |
@@ -77,14 +75,17 @@ | ||
77 | 75 | |
78 | 76 | |
79 | 77 | |
80 | -4.USBメモリ | |
78 | +[ USBメモリ ] | |
81 | 79 | |
82 | -4-1.IPLでのブート処理 | |
83 | - 1.BIOSを用いてUSBメモリの先頭から571.5KB読み込む | |
84 | - 2.BIOSを用いて画面モードの変更、キーボードランプの取得 | |
80 | +** IPLでのブート処理 | |
81 | + 1.拡張int13hを用いてUSBメモリの先頭から571.5KB読み込む | |
82 | + 2.BIOSを用いて画面モード(1024x768x32bit)の変更、キーボードランプの取得 | |
85 | 83 | 3.割り込みの禁止とA20GATEの有効化 |
86 | - 4.GDT/IDTの設定 | |
84 | + 4.GDT/IDT/PICの設定 | |
87 | 85 | 5.32bitプロテクトモード(ページング禁止)へ移行 |
88 | 86 | 6.OS(ほぼC記述)へ処理を移す |
89 | 87 | |
90 | -0xffff 0x0000 0x9200 0x00cf 0xd000 0x9c00 0x9a00 0x0048 | |
88 | +** OSでの初期化処理 | |
89 | + 1.メモリ/FIFOの初期化 | |
90 | + 2.キーボードの初期化 | |
91 | + 3.割り込みの受付 |
@@ -0,0 +1 @@ | ||
1 | +..\..\z_tools\make.exe %1 %2 %3 %4 %5 %6 %7 %8 %9 | |
\ No newline at end of file |
@@ -0,0 +1,10 @@ | ||
1 | +TARGET = bim2orb | |
2 | +MODE = exe | |
3 | +OBJS = $(TARGET).obj | |
4 | +STACKSIZE = 0x1000000 # 16MB (default) | |
5 | + | |
6 | +INCPATH = ../../z_tools/win32/ | |
7 | +CC1OPT = -Dmain=main0 | |
8 | +include ../com_mak.txt | |
9 | + | |
10 | +# tolset08対応Makefile |
@@ -0,0 +1,176 @@ | ||
1 | +#include <stdio.h> | |
2 | +#include <stdlib.h> | |
3 | + | |
4 | +typedef unsigned char UCHAR; | |
5 | +int getnum(const UCHAR *p); | |
6 | +int get32(const UCHAR *p); | |
7 | +void put32(UCHAR *p, int i); | |
8 | + | |
9 | +#define MAXSIZ 4 * 1024 * 1024 | |
10 | + | |
11 | +int main(int argc, UCHAR **argv) | |
12 | +{ | |
13 | + UCHAR *fbuf = malloc(MAXSIZ); | |
14 | + int heap_siz, mmarea, fsiz, dsize, dofs, stksiz, wrksiz, entry, bsssiz; | |
15 | + int heap_adr, i; | |
16 | + FILE *fp; | |
17 | + static UCHAR sign[3] = "Orb"; | |
18 | + | |
19 | + /* パラメータの取得 */ | |
20 | + if (argc < 4) { | |
21 | + puts("usage>bim2orb appname.bim appname.hrb heap-size [mmarea-size]"); | |
22 | + return 1; | |
23 | + } | |
24 | + heap_siz = getnum(argv[3]); | |
25 | + mmarea = 0; | |
26 | + if (argc >= 5) | |
27 | + mmarea = getnum(argv[4]); | |
28 | + | |
29 | + /* ファイル読み込み */ | |
30 | + fp = fopen(argv[1], "rb"); | |
31 | + if (fp == NULL) { | |
32 | +err_bim: | |
33 | + puts("bim file read error"); | |
34 | + return 1; | |
35 | + } | |
36 | + fsiz = fread(fbuf, 1, MAXSIZ, fp); | |
37 | + fclose(fp); | |
38 | + if (fsiz >= MAXSIZ || fsiz < 0) | |
39 | + goto err_bim; | |
40 | + | |
41 | + /* ヘッダ確認 */ | |
42 | + if (get32(&fbuf[4]) != 0x24) { /* ファイル中の.textスタートアドレス */ | |
43 | +err_form: | |
44 | + puts("bim file format error"); | |
45 | + return 1; | |
46 | + } | |
47 | + if (get32(&fbuf[8]) != 0x24) /* メモリロード時の.textスタートアドレス */ | |
48 | + goto err_form; | |
49 | + dsize = get32(&fbuf[12]); /* .dataセクションサイズ */ | |
50 | + dofs = get32(&fbuf[16]); /* ファイルのどこに.dataセクションがあるか */ | |
51 | + stksiz = get32(&fbuf[20]); /* スタックサイズ */ | |
52 | + entry = get32(&fbuf[24]); /* エントリポイント */ | |
53 | + bsssiz = get32(&fbuf[28]); /* bssサイズ */ | |
54 | + | |
55 | + /* ヘッダ生成 */ | |
56 | + heap_adr = stksiz + dsize + bsssiz; | |
57 | + heap_adr = (heap_adr + 0xf) & 0xfffffff0; /* 16バイト単位に切り上げ */ | |
58 | + wrksiz = heap_adr + heap_siz; | |
59 | + wrksiz = (wrksiz + 0xfff) & 0xfffff000; /* 4KB単位に切り上げ */ | |
60 | + put32(&fbuf[ 0], wrksiz); | |
61 | + fbuf[ 4]= 0xe9; | |
62 | + put32(&fbuf[ 5], entry - 0x09); | |
63 | + for (i = 0; i < 3; i++) | |
64 | + fbuf[9 + i] = sign[i]; | |
65 | + put32(&fbuf[12], stksiz); | |
66 | + put32(&fbuf[16], dsize); | |
67 | + put32(&fbuf[20], dofs); | |
68 | + | |
69 | + /* ファイル書き込み */ | |
70 | + fp = fopen(argv[2], "wb"); | |
71 | + if (fp == NULL) { | |
72 | +err_hrb: | |
73 | + puts("orb file write error"); | |
74 | + return 1; | |
75 | + } | |
76 | + i = fwrite(fbuf, 1, fsiz, fp); | |
77 | + fclose(fp); | |
78 | + if (fsiz != i) | |
79 | + goto err_hrb; | |
80 | + | |
81 | + return 0; | |
82 | +} | |
83 | + | |
84 | +int getnum(const UCHAR *p) | |
85 | +{ | |
86 | + int i = 0, base = 10, sign = 1; | |
87 | + UCHAR c; | |
88 | + if (*p == '-') { | |
89 | + p++; | |
90 | + sign = -1; | |
91 | + } | |
92 | + if (*p == '0') { | |
93 | + p++; | |
94 | + base = 8; | |
95 | + c = *p; | |
96 | + if (c >= 'a') | |
97 | + c -= 'a' - 'A'; | |
98 | + if (c == 'X') { | |
99 | + p++; | |
100 | + base = 16; | |
101 | + } | |
102 | + if (c == 'O') { | |
103 | + p++; | |
104 | + base = 8; | |
105 | + } | |
106 | + if (c == 'B') { | |
107 | + p++; | |
108 | + base = 2; | |
109 | + } | |
110 | + } | |
111 | + for (;;) { | |
112 | + c = *p++; | |
113 | + if ('0' <= c && c <= '9') | |
114 | + c -= '0'; | |
115 | + else if ('A' <= c && c <= 'F') | |
116 | + c -= 'A' - 10; | |
117 | + else if ('a' <= c && c <= 'f') | |
118 | + c -= 'a' - 10; | |
119 | + else | |
120 | + break; | |
121 | + if (c >= base) | |
122 | + break; | |
123 | + i = i * base + c; | |
124 | + } | |
125 | + if (c >= 'a') | |
126 | + c -= 'a' - 'A'; | |
127 | + if (c == 'K') | |
128 | + i <<= 10; | |
129 | + if (c == 'M') | |
130 | + i <<= 20; | |
131 | + if (c == 'G') | |
132 | + i <<= 30; | |
133 | + return i * sign; | |
134 | +} | |
135 | + | |
136 | +int get32(const UCHAR *p) | |
137 | +{ | |
138 | + return p[0] | p[1] << 8 | p[2] << 16 | p[3] << 24; | |
139 | +} | |
140 | + | |
141 | +void put32(UCHAR *p, int i) | |
142 | +{ | |
143 | + p[0] = i & 0xff; | |
144 | + p[1] = (i >> 8) & 0xff; | |
145 | + p[2] = (i >> 16) & 0xff; | |
146 | + p[3] = (i >> 24) & 0xff; | |
147 | + return; | |
148 | +} | |
149 | + | |
150 | +/* | |
151 | + | |
152 | +memo | |
153 | + | |
154 | +[ .bimファイルの構造 ] | |
155 | + | |
156 | ++ 0 : .textサイズ | |
157 | ++ 4 : ファイル中の.textスタートアドレス(0x24) | |
158 | ++ 8 : メモリロード時の.textスタートアドレス(0x24) | |
159 | ++12 : .dataサイズ | |
160 | ++16 : ファイル中の.dataスタートアドレス | |
161 | ++20 : メモリロード時の.dataスタートアドレス | |
162 | ++24 : エントリポイント | |
163 | ++28 : bss領域のバイト数 | |
164 | ++36 : コード | |
165 | + | |
166 | +[ .orbファイルの構造 ] | |
167 | + | |
168 | ++0x00 stack+.data+.heapのサイズ(4KBの倍数) | |
169 | ++0x04 0xe9 | |
170 | ++0x05 エントリアドレス-0x09 | |
171 | ++0x09 シグネチャ "ORB" | |
172 | ++0x0c ESPの初期値 | |
173 | ++0x10 .dataのサイズ | |
174 | ++0x14 .dataのファイル内でのアドレス | |
175 | + | |
176 | +*/ |
@@ -1,13 +1,14 @@ | ||
1 | 1 | MKORBFS = mkorbfs/mkorbfs.exe |
2 | 2 | |
3 | 3 | default: |
4 | + make -C bim2orb | |
4 | 5 | make -C mkorbfs |
5 | 6 | make -C orbspace |
6 | 7 | make orbspace.img |
7 | 8 | |
8 | -orbspace.img: $(MKORBFS) orbspace\ipl.bin Makefile | |
9 | +orbspace.img: $(MKORBFS) orbspace\ipl.bin orbspace\orbspace.sys Makefile | |
9 | 10 | $(MKORBFS) orbspace.img 131072 orbspace\ipl.bin \ |
10 | - +File orbspace\ipl.bin Author=tatsu Keyword=orbspace \ | |
11 | + +File orbspace\orbspace.sys Author=tatsu Keyword=orbspace \ | |
11 | 12 | +Ball orbspace Color=0x00ff00 \ |
12 | 13 | +Ball orbfs Color=0xff0000 \ |
13 | 14 | +File orbspace\ipl.nas [orbspace] Author=tatsu Keyword=orbspace \ |
@@ -15,5 +16,6 @@ | ||
15 | 16 | +Func search.orb Color=0x0000ff |
16 | 17 | |
17 | 18 | clean: |
19 | + make -C bim2orb clean | |
18 | 20 | make -C mkorbfs clean |
19 | 21 | make -C orbspace clean |
@@ -0,0 +1,7 @@ | ||
1 | +void OrbMain(void) | |
2 | +{ | |
3 | + unsigned int *vram = (unsigned int *) *((unsigned int *) 0x0ff2); | |
4 | + | |
5 | + vram[0] = 0xffffff; | |
6 | + for(;;); | |
7 | +} |
@@ -64,6 +64,7 @@ | ||
64 | 64 | { |
65 | 65 | struct entry *ent; |
66 | 66 | #ifdef ORBSPACE |
67 | + unsigned char *buf = 0; | |
67 | 68 | #else |
68 | 69 | unsigned char *buf = (unsigned char *) malloc(512); |
69 | 70 | #endif |
@@ -123,6 +124,7 @@ | ||
123 | 124 | } |
124 | 125 | io_write((unsigned char *) orbsat, 0x200, 7168); |
125 | 126 | #ifdef ORBSPACE |
127 | + buf = 0; | |
126 | 128 | #else |
127 | 129 | buf = (unsigned char *) malloc(512); |
128 | 130 | #endif |
@@ -159,6 +161,7 @@ | ||
159 | 161 | return 1; |
160 | 162 | } |
161 | 163 | #ifdef ORBSPACE |
164 | + ent = 0; | |
162 | 165 | #else |
163 | 166 | ent = (struct entry *) malloc(512); |
164 | 167 | #endif |
@@ -204,6 +207,7 @@ | ||
204 | 207 | unsigned int *sat, addr, no, i, j; |
205 | 208 | |
206 | 209 | #ifdef ORBSPACE |
210 | + buf = 0; | |
207 | 211 | #else |
208 | 212 | buf = (unsigned char *) malloc(512); |
209 | 213 | #endif |
@@ -1,14 +1,45 @@ | ||
1 | +OBJS = main.obj orbfs.obj | |
2 | + | |
1 | 3 | TOOLPATH = ../../z_tools/ |
4 | +INCPATH = $(TOOLPATH)haribote/ | |
2 | 5 | NASK = $(TOOLPATH)nask.exe |
6 | +CC1 = $(TOOLPATH)cc1.exe -I$(INCPATH) -Os -Wall -quiet | |
7 | +GAS2NASK = $(TOOLPATH)gas2nask.exe -a | |
8 | +OBJ2BIM = $(TOOLPATH)obj2bim.exe | |
9 | +BIN2OBJ = $(TOOLPATH)bin2obj.exe | |
10 | +BIM2ORB = ../bim2orb/bim2orb.exe | |
11 | +RULEFILE = ../orbspace.rul | |
3 | 12 | |
4 | 13 | default: |
5 | 14 | make ipl.bin |
15 | + make orbspace.sys | |
6 | 16 | |
7 | 17 | ipl.bin: ipl.nas Makefile |
8 | 18 | $(NASK) ipl.nas ipl.bin ipl.lst |
9 | 19 | |
20 | +orbfs.gas: orbfs.c Makefile | |
21 | + $(CC1) -DORBSPACE -o orbfs.gas orbfs.c | |
22 | + | |
23 | +orbspace.bim: $(OBJS) Makefile | |
24 | + $(OBJ2BIM) @$(RULEFILE) out:orbspace.bim stack:3136k map:orbspace.map \ | |
25 | + $(OBJS) | |
26 | + | |
27 | +orbspace.sys: orbspace.bim Makefile | |
28 | + $(BIM2ORB) orbspace.bim orbspace.sys 0 | |
29 | + | |
30 | +%.gas: %.c Makefile | |
31 | + $(CC1) -o $*.gas $*.c | |
32 | + | |
33 | +%.nas: %.gas Makefile | |
34 | + $(GAS2NASK) $*.gas $*.nas | |
35 | + | |
36 | +%.obj: %.nas Makefile | |
37 | + $(NASK) $*.nas $*.obj $*.lst | |
38 | + | |
10 | 39 | clean: |
11 | 40 | del ipl.bin |
12 | - del ipl.lst | |
41 | + del *.lst | |
13 | 42 | del *.obj |
14 | 43 | del *.map |
44 | + del *.map | |
45 | + del orbspace.sys |