• R/O
  • SSH
  • HTTPS

chnosproject: Commit


Commit MetaInfo

Revisión192 (tree)
Tiempo2010-10-31 00:06:23
Autorhikarupsp

Log Message

一般保護例外の際の強制終了とスタック切り替えなどに対応。
harib18g相当。

Cambiar Resumen

Diferencia incremental

--- beta/tolset_chn_000/chnos_007/chnos/console.c (revision 191)
+++ beta/tolset_chn_000/chnos_007/chnos/console.c (revision 192)
@@ -181,7 +181,8 @@
181181 uint cons_app_hrb_start(uchar *cmdline)
182182 {
183183 uint i, j;
184- char *p;
184+ char *p, *q;
185+ UI_Task *task = task_now();
185186
186187 i = search_file(cmdline);
187188 if(i == 0xFFFFFFFF){
@@ -191,6 +192,7 @@
191192 if(i != 0xFFFFFFFF){
192193 j = system.file.list[i].size;
193194 p = system.io.mem.alloc(j);
195+ q = system.io.mem.alloc(64 * 1024);
194196 *((int *) 0x0fe0) = (int) p;
195197 load_file(i, p);
196198 if(j >= 8 && strncmp(p + 4, "Hari", 4) == 0){
@@ -201,9 +203,11 @@
201203 p[4] = 0x00;
202204 p[5] = 0xcb;
203205 }
204- set_segmdesc(system.sys.gdt + 1003, j - 1, (int)p, AR_CODE32_ER);
205- farcall(0, 1003 * 8);
206+ set_segmdesc(system.sys.gdt + 1003, j - 1, (int)p, AR_CODE32_ER + AR_APP);
207+ set_segmdesc(system.sys.gdt + 1004, 64 * 1024 - 1, (int)q, AR_DATA32_RW + AR_APP);
208+ start_app(0, 1003 * 8, 64 * 1024, 1004 * 8, &(task->tss.esp0));
206209 system.io.mem.free(p, j);
210+ system.io.mem.free(q, 64 * 1024);
207211 return i;
208212 }
209213 return 0xFFFFFFFF;
--- beta/tolset_chn_000/chnos_007/chnos/api.c (revision 191)
+++ beta/tolset_chn_000/chnos_007/chnos/api.c (revision 192)
@@ -1,16 +1,21 @@
11
22 #include "core.h"
33
4-void hrb_api(uint edi, uint esi, uint ebp, uint esp, uint ebx, uint edx, uint ecx, uint eax)
4+uint hrb_api(uint edi, uint esi, uint ebp, uint esp, uint ebx, uint edx, uint ecx, uint eax)
55 {
66 UI_Window *win = (UI_Window *) *((int *) 0x0fec);
77 DATA_Position2D *prompt = (DATA_Position2D *) *((int *) 0x0fe8);
88 DATA_Position2D *cursor = (DATA_Position2D *) *((int *) 0x0fe4);
99 uint app_cs_base = *((uint *) 0x0fe0);
10+ UI_Task *task = task_now();
1011 if(edx == 1){
1112 cons_put_char(win, prompt, cursor, (uchar)(eax & 0xff));
1213 } else if(edx == 2){
1314 cons_put_str(win, prompt, cursor, (uchar *)(ebx + app_cs_base));
15+ } else if(edx == 3){
16+
17+ } else if(edx == 4){
18+ return (uint)&(task->tss.esp0);
1419 }
15- return;
20+ return 0;
1621 }
--- beta/tolset_chn_000/chnos_007/chnos/int.c (revision 191)
+++ beta/tolset_chn_000/chnos_007/chnos/int.c (revision 192)
@@ -100,7 +100,7 @@
100100 "APP's SS "
101101 };
102102
103-void cpu_exception_alert(int exception, int *esp)
103+void cpu_exception_abort(int exception, int *esp)
104104 {
105105 int i;
106106 char s[32];
@@ -130,163 +130,171 @@
130130 }
131131 }
132132
133+uint cpu_exception_fault(int exception, int *esp)
134+{
135+ UI_Task *task = task_now();
136+
137+ cons_put_str((UI_Window *) *((int *) 0x0fec), (DATA_Position2D *) *((int *) 0x0fe8), (DATA_Position2D *) *((int *) 0x0fe4), (uchar *)cpu_exceptions[exception]);
138+ return (uint)&(task->tss.esp0);
139+}
140+
133141 void inthandler00(int *esp)
134142 {
135- cpu_exception_alert(0x00, esp);
143+ cpu_exception_abort(0x00, esp);
136144 }
137145
138146 void inthandler01(int *esp)
139147 {
140- cpu_exception_alert(0x01, esp);
148+ cpu_exception_abort(0x01, esp);
141149 }
142150
143151 void inthandler02(int *esp)
144152 {
145- cpu_exception_alert(0x02, esp);
153+ cpu_exception_abort(0x02, esp);
146154 }
147155
148156 void inthandler03(int *esp)
149157 {
150- cpu_exception_alert(0x03, esp);
158+ cpu_exception_abort(0x03, esp);
151159 }
152160
153161 void inthandler04(int *esp)
154162 {
155- cpu_exception_alert(0x04, esp);
163+ cpu_exception_abort(0x04, esp);
156164 }
157165
158166 void inthandler05(int *esp)
159167 {
160- cpu_exception_alert(0x05, esp);
168+ cpu_exception_abort(0x05, esp);
161169 }
162170
163171 void inthandler06(int *esp)
164172 {
165- cpu_exception_alert(0x06, esp);
173+ cpu_exception_abort(0x06, esp);
166174 }
167175
168176 void inthandler07(int *esp)
169177 {
170- cpu_exception_alert(0x07, esp);
178+ cpu_exception_abort(0x07, esp);
171179 }
172180
173181 void inthandler08(int *esp)
174182 {
175- cpu_exception_alert(0x08, esp);
183+ cpu_exception_abort(0x08, esp);
176184 }
177185
178186 void inthandler09(int *esp)
179187 {
180- cpu_exception_alert(0x09, esp);
188+ cpu_exception_abort(0x09, esp);
181189 }
182190
183191 void inthandler0a(int *esp)
184192 {
185- cpu_exception_alert(0x0a, esp);
193+ cpu_exception_abort(0x0a, esp);
186194 }
187195
188196 void inthandler0b(int *esp)
189197 {
190- cpu_exception_alert(0x0b, esp);
198+ cpu_exception_abort(0x0b, esp);
191199 }
192200
193201 void inthandler0c(int *esp)
194202 {
195- cpu_exception_alert(0x0c, esp);
203+ cpu_exception_abort(0x0c, esp);
196204 }
197205
198206 void inthandler0d(int *esp)
199207 {
200- cpu_exception_alert(0x0d, esp);
208+ cpu_exception_fault(0x0d, esp);
201209 }
202210
203211 void inthandler0e(int *esp)
204212 {
205- cpu_exception_alert(0x0e, esp);
213+ cpu_exception_abort(0x0e, esp);
206214 }
207215
208216 void inthandler0f(int *esp)
209217 {
210- cpu_exception_alert(0x0f, esp);
218+ cpu_exception_abort(0x0f, esp);
211219 }
212220
213221 void inthandler10(int *esp)
214222 {
215- cpu_exception_alert(0x10, esp);
223+ cpu_exception_abort(0x10, esp);
216224 }
217225
218226 void inthandler11(int *esp)
219227 {
220- cpu_exception_alert(0x11, esp);
228+ cpu_exception_abort(0x11, esp);
221229 }
222230
223231 void inthandler12(int *esp)
224232 {
225- cpu_exception_alert(0x12, esp);
233+ cpu_exception_abort(0x12, esp);
226234 }
227235
228236 void inthandler13(int *esp)
229237 {
230- cpu_exception_alert(0x13, esp);
238+ cpu_exception_abort(0x13, esp);
231239 }
232240
233241 void inthandler14(int *esp)
234242 {
235- cpu_exception_alert(0x14, esp);
243+ cpu_exception_abort(0x14, esp);
236244 }
237245
238246 void inthandler15(int *esp)
239247 {
240- cpu_exception_alert(0x15, esp);
248+ cpu_exception_abort(0x15, esp);
241249 }
242250
243251 void inthandler16(int *esp)
244252 {
245- cpu_exception_alert(0x16, esp);
253+ cpu_exception_abort(0x16, esp);
246254 }
247255
248256 void inthandler17(int *esp)
249257 {
250- cpu_exception_alert(0x17, esp);
258+ cpu_exception_abort(0x17, esp);
251259 }
252260
253261 void inthandler18(int *esp)
254262 {
255- cpu_exception_alert(0x18, esp);
263+ cpu_exception_abort(0x18, esp);
256264 }
257265
258266 void inthandler19(int *esp)
259267 {
260- cpu_exception_alert(0x19, esp);
268+ cpu_exception_abort(0x19, esp);
261269 }
262270
263271 void inthandler1a(int *esp)
264272 {
265- cpu_exception_alert(0x1a, esp);
273+ cpu_exception_abort(0x1a, esp);
266274 }
267275
268276 void inthandler1b(int *esp)
269277 {
270- cpu_exception_alert(0x1b, esp);
278+ cpu_exception_abort(0x1b, esp);
271279 }
272280
273281 void inthandler1c(int *esp)
274282 {
275- cpu_exception_alert(0x1c, esp);
283+ cpu_exception_abort(0x1c, esp);
276284 }
277285
278286 void inthandler1d(int *esp)
279287 {
280- cpu_exception_alert(0x1d, esp);
288+ cpu_exception_abort(0x1d, esp);
281289 }
282290
283291 void inthandler1e(int *esp)
284292 {
285- cpu_exception_alert(0x1e, esp);
293+ cpu_exception_abort(0x1e, esp);
286294 }
287295
288296 void inthandler1f(int *esp)
289297 {
290- cpu_exception_alert(0x1f, esp);
298+ cpu_exception_abort(0x1f, esp);
291299 }
292300
--- beta/tolset_chn_000/chnos_007/chnos/Makefile (revision 191)
+++ beta/tolset_chn_000/chnos_007/chnos/Makefile (revision 192)
@@ -56,6 +56,9 @@
5656 hello2.hrb : hello2.nas Makefile
5757 $(NASK) hello2.nas hello2.hrb hello2.lst
5858
59+crack2.hrb : crack2.nas Makefile
60+ $(NASK) crack2.nas crack2.hrb crack2.lst
61+
5962 a.bim : a.obj a_nask.obj Makefile
6063 $(OBJ2BIM) @$(RULEFILE) out:a.bim map:a.map a.obj a_nask.obj
6164
@@ -68,6 +71,12 @@
6871 hello3.hrb : hello3.bim Makefile
6972 $(BIM2HRB) hello3.bim hello3.hrb 0
7073
74+crack1.bim : crack1.obj a_nask.obj Makefile
75+ $(OBJ2BIM) @$(RULEFILE) out:crack1.bim map:crack1.map crack1.obj a_nask.obj
76+
77+crack1.hrb : crack1.bim Makefile
78+ $(BIM2HRB) crack1.bim crack1.hrb 0
79+
7180 bootpack.bim : $(OBJS_BOOTPACK) Makefile
7281 $(OBJ2BIM) @$(RULEFILE) out:bootpack.bim stack:3136k map:bootpack.map \
7382 $(OBJS_BOOTPACK)
@@ -79,7 +88,7 @@
7988 chnos.sys : asmhead.bin bootpack.hrb Makefile
8089 copy /B asmhead.bin+bootpack.hrb chnos.sys
8190
82-chnos.img : chnipl.bin chnos.sys hello.hrb hello2.hrb hello3.hrb a.hrb Makefile
91+chnos.img : chnipl.bin chnos.sys hello.hrb hello2.hrb hello3.hrb crack1.hrb crack2.hrb a.hrb Makefile
8392 $(EDIMG) imgin:../../z_tools/fdimg0at.tek \
8493 wbinimg src:chnipl.bin len:512 from:0 to:0 \
8594 copy from:chnos.sys to:@: \
@@ -109,6 +118,8 @@
109118 copy from:hello2.hrb to:@: \
110119 copy from:a.hrb to:@: \
111120 copy from:hello3.hrb to:@: \
121+ copy from:crack1.hrb to:@: \
122+ copy from:crack2.hrb to:@: \
112123 imgout:chnos.img
113124
114125 #一般規則
--- beta/tolset_chn_000/chnos_007/chnos/core.h (revision 191)
+++ beta/tolset_chn_000/chnos_007/chnos/core.h (revision 192)
@@ -64,6 +64,7 @@
6464 #define AR_LDT 0x0082
6565 #define AR_TSS32 0x0089
6666 #define AR_INTGATE32 0x008e
67+#define AR_APP 0x60
6768
6869 #define MEMMAN_FREES 4096
6970
@@ -475,7 +476,7 @@
475476 /*functions*/
476477
477478 /*api.c*/
478-void hrb_api(uint edi, uint esi, uint ebp, uint esp, uint ebx, uint edx, uint ecx, uint eax);
479+uint hrb_api(uint edi, uint esi, uint ebp, uint esp, uint ebx, uint edx, uint ecx, uint eax);
479480
480481 /*file.c*/
481482 void decode_fat(ushort *fat, bool backup);
@@ -539,6 +540,7 @@
539540
540541 /*int.c*/
541542 void cpu_exception_alert(int exception, int *esp);
543+uint cpu_exception_fault(int exception, int *esp);
542544 void init_pic(void);
543545 void inthandler27(int *esp);
544546
--- beta/tolset_chn_000/chnos_007/chnos/crack1.c (nonexistent)
+++ beta/tolset_chn_000/chnos_007/chnos/crack1.c (revision 192)
@@ -0,0 +1,7 @@
1+void api_end(void);
2+
3+void CHNMain(void)
4+{
5+ *((char *)0x00102600) = 0;
6+ api_end();
7+}
--- beta/tolset_chn_000/chnos_007/chnos/gdtidt.c (revision 191)
+++ beta/tolset_chn_000/chnos_007/chnos/gdtidt.c (revision 192)
@@ -57,7 +57,7 @@
5757 set_gatedesc(idt+0x27, (int) asm_inthandler27, 2 * 8, AR_INTGATE32);
5858 set_gatedesc(idt+0x2c, (int) asm_inthandler2c, 2 * 8, AR_INTGATE32);
5959
60- set_gatedesc(idt+0x40, (int) asm_hrb_api, 2 * 8, AR_INTGATE32);
60+ set_gatedesc(idt+0x40, (int) asm_hrb_api, 2 * 8, AR_INTGATE32 + AR_APP);
6161
6262 return;
6363 }
--- beta/tolset_chn_000/chnos_007/chnos/a.c (revision 191)
+++ beta/tolset_chn_000/chnos_007/chnos/a.c (revision 192)
@@ -1,7 +1,8 @@
11 void api_putchar(unsigned char c);
2+void api_end(void);
23
34 void CHNMain(void)
45 {
56 api_putchar('A');
6- return;
7+ api_end();
78 }
--- beta/tolset_chn_000/chnos_007/chnos/hello3.c (revision 191)
+++ beta/tolset_chn_000/chnos_007/chnos/hello3.c (revision 192)
@@ -1,4 +1,5 @@
11 void api_putchar(unsigned char c);
2+void api_end(void);
23
34 void CHNMain(void)
45 {
@@ -8,5 +9,5 @@
89 api_putchar('l');
910 api_putchar('o');
1011 api_putchar('3');
11- return;
12+ api_end();
1213 }
Show on old repository browser