• R/O
  • SSH
  • HTTPS

chnosproject: コミット


コミットメタ情報

リビジョン307 (tree)
日時2011-12-18 18:17:27
作者hikarupsp

ログメッセージ

32ビット保護モードからの画面切り替えはほとんど確実にできるようになった。
FIFOバッファのバッファサイズがおかしかったの問題を修正。
CallBIOSタスクのesp0が毎回直されていなかった問題を修正。
とりあえず、VESA8ビットモードへの切り替えだけはサポートしたが、切り替えた後にどうするかはまだ作っていないので真っ暗なままである。

変更サマリ

差分

--- beta/tolset_chn_000/chnos_010/chnos/coredef3.h (nonexistent)
+++ beta/tolset_chn_000/chnos_010/chnos/coredef3.h (revision 307)
@@ -0,0 +1,4 @@
1+
2+/*システムFIFOコマンド宣言*/
3+
4+#define FIFOCMD_KBCT_SET_FOCUS_FIFO 0x80000001 //[CMD][DATA_FIFO32 *][offset][(FLAGS)][EOA]
--- beta/tolset_chn_000/chnos_010/chnos/keyboard.c (revision 306)
+++ beta/tolset_chn_000/chnos_010/chnos/keyboard.c (revision 307)
@@ -4,6 +4,322 @@
44 uint kbd_data0;
55 DATA_FIFO32 *kbd_fifo;
66
7+union STATE_KEYLOCK {
8+ uchar keylock;
9+ struct STATE_KEYLOCK_KEY {
10+ unsigned num : 1;
11+ unsigned caps : 1;
12+ unsigned scroll : 1;
13+ } key;
14+} state_keylock;
15+
16+union STATE_KEYSHIFT {
17+ uchar keyshift;
18+ struct STATE_KEYSHIFT_KEY {
19+ unsigned L : 1;
20+ unsigned R : 1;
21+ } key;
22+} state_keyshift;
23+
24+union STATE_KEYCTRL {
25+ uchar keyctrl;
26+ struct STATE_KEYCTRL_KEY {
27+ unsigned L : 1;
28+ unsigned R : 1;
29+ } key;
30+} state_keyctrl;
31+
32+union STATE_KEYALT {
33+ uchar keyalt;
34+ struct STATE_KEYALT_KEY {
35+ unsigned L : 1;
36+ unsigned R : 1;
37+ } key;
38+} state_keyalt;
39+
40+ushort state_shift;
41+
42+uint key_decode_phase;
43+uchar key_decode_buf[4];
44+
45+/*キーコード変換テーブル*/
46+ushort Keyboard_KeyCodeTable[0x80] = {
47+ KEYID_MASK_EXTENDED | KEYID_KBD_ERROR,
48+ KEYID_MASK_EXTENDED | KEYID_ESC,
49+ '1',
50+ '2',
51+ '3',
52+ '4',
53+ '5',
54+ '6',
55+ '7',
56+ '8',
57+ '9',
58+ '0',
59+ '-',
60+ '^',
61+ KEYID_MASK_EXTENDED | KEYID_BACKSPACE,
62+ KEYID_MASK_EXTENDED | KEYID_TAB,
63+/*0x10*/
64+ 'Q',
65+ 'W',
66+ 'E',
67+ 'R',
68+ 'T',
69+ 'Y',
70+ 'U',
71+ 'I',
72+ 'O',
73+ 'P',
74+ '@',
75+ '[',
76+ KEYID_MASK_EXTENDED | KEYID_ENTER,
77+ KEYID_MASK_EXTENDED | KEYID_CTRL_L,
78+ 'A',
79+ 'S',
80+/*0x20*/
81+ 'D',
82+ 'F',
83+ 'G',
84+ 'H',
85+ 'J',
86+ 'K',
87+ 'L',
88+ ';',
89+ ':',
90+ KEYID_MASK_EXTENDED | KEYID_KANJI,
91+ KEYID_MASK_EXTENDED | KEYID_SHIFT_L,
92+ ']',
93+ 'Z',
94+ 'X',
95+ 'C',
96+ 'V',
97+/*0x30*/
98+ 'B',
99+ 'N',
100+ 'M',
101+ ',',
102+ '.',
103+ '/',
104+ KEYID_MASK_EXTENDED | KEYID_SHIFT_R,
105+ KEYID_MASK_TENKEY | '*',
106+ KEYID_MASK_EXTENDED | KEYID_ALT_L,
107+ ' ',
108+ KEYID_MASK_EXTENDED | KEYID_LOCK_CAPS,
109+ KEYID_MASK_EXTENDED | KEYID_F1,
110+ KEYID_MASK_EXTENDED | KEYID_F2,
111+ KEYID_MASK_EXTENDED | KEYID_F3,
112+ KEYID_MASK_EXTENDED | KEYID_F4,
113+ KEYID_MASK_EXTENDED | KEYID_F5,
114+/*0x40*/
115+ KEYID_MASK_EXTENDED | KEYID_F6,
116+ KEYID_MASK_EXTENDED | KEYID_F7,
117+ KEYID_MASK_EXTENDED | KEYID_F8,
118+ KEYID_MASK_EXTENDED | KEYID_F9,
119+ KEYID_MASK_EXTENDED | KEYID_F10,
120+ KEYID_MASK_EXTENDED | KEYID_LOCK_NUM,
121+ KEYID_MASK_EXTENDED | KEYID_LOCK_SCROOL,
122+ KEYID_MASK_TENKEY | '7',
123+ KEYID_MASK_TENKEY | '8',
124+ KEYID_MASK_TENKEY | '9',
125+ KEYID_MASK_TENKEY | '-',
126+ KEYID_MASK_TENKEY | '4',
127+ KEYID_MASK_TENKEY | '5',
128+ KEYID_MASK_TENKEY | '6',
129+ KEYID_MASK_TENKEY | '+',
130+ KEYID_MASK_TENKEY | '1',
131+/*0x50*/
132+ KEYID_MASK_TENKEY | '2',
133+ KEYID_MASK_TENKEY | '3',
134+ KEYID_MASK_TENKEY | '0',
135+ KEYID_MASK_TENKEY | '.',
136+ KEYID_MASK_EXTENDED | KEYID_SYS_RQ,
137+ 0x0000,
138+ 0x0000,
139+ KEYID_MASK_EXTENDED | KEYID_F11,
140+ KEYID_MASK_EXTENDED | KEYID_F12,
141+ 0x0000,
142+ 0x0000,
143+ 0x0000,
144+ 0x0000,
145+ 0x0000,
146+ 0x0000,
147+ 0x0000,
148+/*0x60*/
149+ 0x0000,
150+ 0x0000,
151+ 0x0000,
152+ 0x0000,
153+ 0x0000,
154+ 0x0000,
155+ 0x0000,
156+ 0x0000,
157+ 0x0000,
158+ 0x0000,
159+ 0x0000,
160+ 0x0000,
161+ 0x0000,
162+ 0x0000,
163+ 0x0000,
164+ 0x0000,
165+/*0x70*/
166+ KEYID_MASK_EXTENDED | KEYID_HIRAGANA,
167+ 0x0000,
168+ 0x0000,
169+ '_',
170+ 0x0000,
171+ 0x0000,
172+ 0x0000,
173+ 0x0000,
174+ 0x0000,
175+ KEYID_MASK_EXTENDED | KEYID_HENKAN,
176+ 0x0000,
177+ KEYID_MASK_EXTENDED | KEYID_MUHENKAN,
178+ 0x0000,
179+ 0x5c, //\ for mikan-trap
180+ 0x0000,
181+ 0x0000
182+};
183+
184+//ゼロの所はシフト文字が無いので、テーブル0を参照
185+uchar Keyboard_KeyCodeTable_Shift[0x80] = {
186+ 0x00,
187+ 0x00,
188+ '!',
189+ 0x22, //double quote
190+ '#',
191+ '$',
192+ '%',
193+ '&',
194+ 0x27, //single quote
195+ '(',
196+ ')',
197+ '~',
198+ '=',
199+ '~',
200+ 0x00,
201+ 0x00,
202+/*0x10*/
203+ 0x00,
204+ 0x00,
205+ 0x00,
206+ 0x00,
207+ 0x00,
208+ 0x00,
209+ 0x00,
210+ 0x00,
211+ 0x00,
212+ 0x00,
213+ '`',
214+ '{',
215+ 0x00,
216+ 0x00,
217+ 0x00,
218+ 0x00,
219+/*0x20*/
220+ 0x00,
221+ 0x00,
222+ 0x00,
223+ 0x00,
224+ 0x00,
225+ 0x00,
226+ 0x00,
227+ '+',
228+ '*',
229+ 0x00,
230+ 0x00,
231+ '}',
232+ 0x00,
233+ 0x00,
234+ 0x00,
235+ 0x00,
236+/*0x30*/
237+ 0x00,
238+ 0x00,
239+ 0x00,
240+ '<',
241+ '>',
242+ '?',
243+ 0x00,
244+ 0x00,
245+ 0x00,
246+ 0x00,
247+ 0x00,
248+ 0x00,
249+ 0x00,
250+ 0x00,
251+ 0x00,
252+ 0x00,
253+/*0x40*/
254+ 0x00,
255+ 0x00,
256+ 0x00,
257+ 0x00,
258+ 0x00,
259+ 0x00,
260+ 0x00,
261+ 0x00,
262+ 0x00,
263+ 0x00,
264+ 0x00,
265+ 0x00,
266+ 0x00,
267+ 0x00,
268+ 0x00,
269+ 0x00,
270+/*0x50*/
271+ 0x00,
272+ 0x00,
273+ 0x00,
274+ 0x00,
275+ 0x00,
276+ 0x00,
277+ 0x00,
278+ 0x00,
279+ 0x00,
280+ 0x00,
281+ 0x00,
282+ 0x00,
283+ 0x00,
284+ 0x00,
285+ 0x00,
286+ 0x00,
287+/*0x60*/
288+ 0x00,
289+ 0x00,
290+ 0x00,
291+ 0x00,
292+ 0x00,
293+ 0x00,
294+ 0x00,
295+ 0x00,
296+ 0x00,
297+ 0x00,
298+ 0x00,
299+ 0x00,
300+ 0x00,
301+ 0x00,
302+ 0x00,
303+ 0x00,
304+/*0x70*/
305+ 0x00,
306+ 0x00,
307+ 0x00,
308+ '_',
309+ 0x00,
310+ 0x00,
311+ 0x00,
312+ 0x00,
313+ 0x00,
314+ 0x00,
315+ 0x00,
316+ 0x00,
317+ 0x00,
318+ '|',
319+ 0x00,
320+ 0x00
321+};
322+
7323 void Initialise_Keyboard(void)
8324 {
9325 System_GateDescriptor_Set(0x21, (uint)asm_InterruptHandler21, 0x02, AR_INTGATE32);
@@ -10,6 +326,11 @@
10326 ProgrammableInterruptController_InterruptMask_Clear(0x01);
11327 kbd_data0 = 0;
12328 kbd_fifo = 0;
329+ state_keylock.keylock = 0;
330+ state_keyshift.keyshift = 0;
331+ state_keyctrl.keyctrl = 0;
332+ state_keyalt.keyalt = 0;
333+ key_decode_phase = 0;
13334 return;
14335 }
15336
@@ -35,3 +356,189 @@
35356
36357 return;
37358 }
359+
360+ushort Keyboard_Decode_KeyCode(uchar keycode)
361+{
362+ ushort keyid;
363+ ushort table;
364+ keyid = 0;
365+ table = 0;
366+
367+ key_decode_buf[key_decode_phase] = keycode;
368+
369+ switch(key_decode_phase){
370+ case 0:
371+ if(key_decode_buf[0] == 0xe0){
372+ key_decode_phase = 1;
373+ break;
374+ } else if(key_decode_buf[0] == 0xe1){
375+ key_decode_phase = 2;
376+ break;
377+ } else{
378+ if(state_keylock.key.caps){
379+ if(!state_keyshift.keyshift){
380+ table = 1;
381+ }
382+ } else{
383+ if(state_keyshift.keyshift){
384+ table = 1;
385+ }
386+ }
387+
388+ if(state_keyshift.keyshift){
389+ keyid = Keyboard_KeyCodeTable_Shift[(key_decode_buf[0] & KEYID_MASK_ID)];
390+ if(keyid == 0){
391+ keyid = Keyboard_KeyCodeTable[(key_decode_buf[0] & KEYID_MASK_ID)];
392+ }
393+ } else{
394+ keyid = Keyboard_KeyCodeTable[(key_decode_buf[0] & KEYID_MASK_ID)];
395+ }
396+
397+ if(!table && ('A' <= keyid && keyid <= 'Z')){
398+ keyid += 0x20;
399+ }
400+
401+ if(keyid & KEYID_MASK_EXTENDED){
402+ if(keyid == (KEYID_MASK_EXTENDED | KEYID_CTRL_L)){
403+ if((key_decode_buf[0] & KEYID_MASK_BREAK)){
404+ state_keyctrl.key.L = False;
405+ } else{
406+ state_keyctrl.key.L = True;
407+ }
408+ } else if(keyid == (KEYID_MASK_EXTENDED | KEYID_SHIFT_L)){
409+ if((key_decode_buf[0] & KEYID_MASK_BREAK)){
410+ state_keyshift.key.L = False;
411+ } else{
412+ state_keyshift.key.L = True;
413+ }
414+ } else if(keyid == (KEYID_MASK_EXTENDED | KEYID_SHIFT_R)){
415+ if((key_decode_buf[0] & KEYID_MASK_BREAK)){
416+ state_keyshift.key.R = False;
417+ } else{
418+ state_keyshift.key.R = True;
419+ }
420+ } else if(keyid == (KEYID_MASK_EXTENDED | KEYID_ALT_L)){
421+ if((key_decode_buf[0] & KEYID_MASK_BREAK)){
422+ state_keyalt.key.L = False;
423+ } else{
424+ state_keyalt.key.L = True;
425+ }
426+ } else if(keyid == (KEYID_MASK_EXTENDED | KEYID_LOCK_CAPS)){
427+ if(!(key_decode_buf[0] & KEYID_MASK_BREAK)){
428+ if(state_keylock.key.caps){
429+ state_keylock.key.caps = False;
430+ } else{
431+ state_keylock.key.caps = True;
432+ }
433+ }
434+ } else if(keyid == (KEYID_MASK_EXTENDED | KEYID_LOCK_NUM)){
435+ if(!(key_decode_buf[0] & KEYID_MASK_BREAK)){
436+ if(state_keylock.key.num){
437+ state_keylock.key.num = False;
438+ } else{
439+ state_keylock.key.num = True;
440+ }
441+ }
442+ } else if(keyid == (KEYID_MASK_EXTENDED | KEYID_LOCK_SCROOL)){
443+ if(!(key_decode_buf[0] & KEYID_MASK_BREAK)){
444+ if(state_keylock.key.scroll){
445+ state_keylock.key.scroll = False;
446+ } else{
447+ state_keylock.key.scroll = True;
448+ }
449+ }
450+ }
451+ }
452+
453+ if(keyid != 0 && (key_decode_buf[0] & KEYID_MASK_BREAK)){
454+ keyid |= KEYID_MASK_BREAK;
455+ }
456+
457+ }
458+ key_decode_phase = 0;
459+ break;
460+ case 1: //E0拡張キーコード
461+ if((key_decode_buf[1] & KEYID_MASK_ID) == 0x1c){
462+ keyid |= KEYID_MASK_TENKEY | KEYID_ENTER;
463+ } else if((key_decode_buf[1] & KEYID_MASK_ID) == 0x1d){
464+ keyid |= KEYID_MASK_EXTENDED | KEYID_CTRL_R;
465+ if((key_decode_buf[1] & KEYID_MASK_BREAK)){
466+ state_keyctrl.key.R = False;
467+ } else{
468+ state_keyctrl.key.R = True;
469+ }
470+ } else if((key_decode_buf[1] & KEYID_MASK_ID) == 0x35){
471+ keyid |= KEYID_MASK_TENKEY | '/';
472+ } else if((key_decode_buf[1] & KEYID_MASK_ID) == 0x37){
473+ keyid |= KEYID_MASK_EXTENDED | KEYID_PRINT_SCREEN;
474+ } else if((key_decode_buf[1] & KEYID_MASK_ID) == 0x38){
475+ keyid |= KEYID_MASK_EXTENDED | KEYID_ALT_R;
476+ if((key_decode_buf[1] & KEYID_MASK_BREAK)){
477+ state_keyalt.key.R = False;
478+ } else{
479+ state_keyalt.key.R = True;
480+ }
481+ } else if((key_decode_buf[1] & KEYID_MASK_ID) == 0x46){
482+ keyid |= KEYID_MASK_EXTENDED | KEYID_BREAK;
483+ } else if((key_decode_buf[1] & KEYID_MASK_ID) == 0x47){
484+ keyid |= KEYID_MASK_EXTENDED | KEYID_HOME;
485+ } else if((key_decode_buf[1] & KEYID_MASK_ID) == 0x48){
486+ keyid |= KEYID_MASK_EXTENDED | KEYID_CURSOR_U;
487+ } else if((key_decode_buf[1] & KEYID_MASK_ID) == 0x49){
488+ keyid |= KEYID_MASK_EXTENDED | KEYID_PAGE_UP;
489+ } else if((key_decode_buf[1] & KEYID_MASK_ID) == 0x4b){
490+ keyid |= KEYID_MASK_EXTENDED | KEYID_CURSOR_L;
491+ } else if((key_decode_buf[1] & KEYID_MASK_ID) == 0x4d){
492+ keyid |= KEYID_MASK_EXTENDED | KEYID_CURSOR_R;
493+ } else if((key_decode_buf[1] & KEYID_MASK_ID) == 0x4f){
494+ keyid |= KEYID_MASK_EXTENDED | KEYID_END;
495+ } else if((key_decode_buf[1] & KEYID_MASK_ID) == 0x50){
496+ keyid |= KEYID_MASK_EXTENDED | KEYID_CURSOR_D;
497+ } else if((key_decode_buf[1] & KEYID_MASK_ID) == 0x51){
498+ keyid |= KEYID_MASK_EXTENDED | KEYID_PAGE_DOWN;
499+ } else if((key_decode_buf[1] & KEYID_MASK_ID) == 0x52){
500+ keyid |= KEYID_MASK_EXTENDED | KEYID_INSERT;
501+ } else if((key_decode_buf[1] & KEYID_MASK_ID) == 0x53){
502+ keyid |= KEYID_MASK_EXTENDED | KEYID_DELETE;
503+ } else if((key_decode_buf[1] & KEYID_MASK_ID) == 0x5b){
504+ keyid |= KEYID_MASK_EXTENDED | KEYID_ICON_L;
505+ } else if((key_decode_buf[1] & KEYID_MASK_ID) == 0x5c){
506+ keyid |= KEYID_MASK_EXTENDED | KEYID_ICON_R;
507+ } else if((key_decode_buf[1] & KEYID_MASK_ID) == 0x5d){
508+ keyid |= KEYID_MASK_EXTENDED | KEYID_MENU;
509+ }
510+
511+ if(keyid != 0 && (key_decode_buf[1] & KEYID_MASK_BREAK)){
512+ keyid |= KEYID_MASK_BREAK;
513+ }
514+
515+ key_decode_phase = 0;
516+ break;
517+ case 2: //E1拡張キーコードフェーズ0
518+ key_decode_phase = 3;
519+ break;
520+ case 3: //E1拡張キーコードフェーズ1
521+ if((key_decode_buf[1] == 0x1d) && (key_decode_buf[2] == 0x45)){ //Pause-Key Make
522+ keyid = KEYID_MASK_EXTENDED | KEYID_PAUSE;
523+ } else if((key_decode_buf[1] == 0x9d) && (key_decode_buf[2] == 0xc5)){ //Pause-Key Break
524+ keyid = KEYID_MASK_EXTENDED | KEYID_MASK_BREAK | KEYID_PAUSE;
525+ }
526+ key_decode_phase = 0;
527+ break;
528+ }
529+
530+ if(keyid != 0){
531+ if(state_keyshift.keyshift){
532+ keyid |= KEYID_MASK_STATE_SHIFT;
533+ }
534+ if(state_keyctrl.keyctrl){
535+ keyid |= KEYID_MASK_STATE_CTRL;
536+ }
537+ if(state_keyalt.keyalt){
538+ keyid |= KEYID_MASK_STATE_ALT;
539+ }
540+ keyid |= ((ushort)state_keylock.keylock << 12);
541+ }
542+
543+ return keyid;
544+}
--- beta/tolset_chn_000/chnos_010/chnos/display.c (nonexistent)
+++ beta/tolset_chn_000/chnos_010/chnos/display.c (revision 307)
@@ -0,0 +1,275 @@
1+
2+#include "core.h"
3+
4+//VBEが使えるのは、ctrl->display_mode == DISPLAYMODE_VBE_LINEARの時だけ。
5+
6+#define SIGNAL_BIOS_OPERATION_END 0xff
7+
8+IO_DisplayControl *Initialise_Display(void)
9+{
10+ //最初に現在の画面モードをVGA320*200-8bitに設定する。(BIOS)
11+
12+ IO_CallBIOSControl *callbiosctrl;
13+ INFO_VBE_BIOS *info_vbe_bios;
14+ uint data;
15+ IO_DisplayControl *ctrl;
16+ uint i;
17+ INFO_VBE_VideoMode *info_vbe_vmode;
18+
19+ ctrl = (IO_DisplayControl *)System_Memory_Allocate(sizeof(IO_DisplayControl));
20+
21+ ctrl->bios_signal = System_FIFO32_Initialise(64);
22+
23+ callbiosctrl = System_CallBIOS_Get_Controller();
24+ callbiosctrl->CallBIOS_Task->tss->eax = 0x0013;
25+ System_CallBIOS_Execute(0x10, ctrl->bios_signal, SIGNAL_BIOS_OPERATION_END);
26+
27+ for(;;){
28+ if(FIFO32_Status(ctrl->bios_signal) == 0){
29+
30+ } else{
31+ data = FIFO32_Get(ctrl->bios_signal);
32+ if(data == SIGNAL_BIOS_OPERATION_END || data == SIGNAL_BIOS_OPERATION_END + 1){
33+ break;
34+ }
35+ }
36+ }
37+
38+ ctrl->vmode = 0x0000;
39+ ctrl->vmode_index = 0;
40+ ctrl->bpp = 8;
41+ ctrl->xsize = VGA08_VRAM_XSIZE;
42+ ctrl->ysize = VGA08_VRAM_YSIZE;
43+ ctrl->vram = VGA_VRAM_ADR;
44+
45+ Drawing08_Initialise_Palette();
46+
47+ //次に、VBEのBIOS情報を得る。
48+
49+ callbiosctrl->CallBIOS_Task->tss->eax = 0x4f00;
50+ callbiosctrl->CallBIOS_Task->tss->es = 0x0000;
51+ callbiosctrl->CallBIOS_Task->tss->edi = 0x0e00;
52+ System_CallBIOS_Execute(0x10, ctrl->bios_signal, SIGNAL_BIOS_OPERATION_END);
53+
54+ for(;;){
55+ if(FIFO32_Status(ctrl->bios_signal) == 0){
56+
57+ } else{
58+ data = FIFO32_Get(ctrl->bios_signal);
59+ if(data == SIGNAL_BIOS_OPERATION_END || data == SIGNAL_BIOS_OPERATION_END + 1){
60+ break;
61+ }
62+ }
63+ }
64+
65+ info_vbe_bios = VBE_REALMODE_RETVALUE_ADDRESS;
66+
67+ if(data == SIGNAL_BIOS_OPERATION_END && (callbiosctrl->retvalue.eax & 0x000000ff) == 0x4f && (callbiosctrl->retvalue.eax & 0x0000ff00) == 0x00){
68+ ctrl->VBE.version_minor = info_vbe_bios->ver_minor;
69+ ctrl->VBE.version_major = info_vbe_bios->ver_major;
70+ ctrl->VBE.vram_supported_size_kb = info_vbe_bios->vram_supported_size_kb;
71+ ctrl->VBE.flags = (info_vbe_bios->flags[1] << 8) | info_vbe_bios->flags[0];
72+ ctrl->VBE.oem_string = (uchar *)(info_vbe_bios->oem_string_segment << 4 | info_vbe_bios->oem_string_offset);
73+ ctrl->VBE.vmode_args = (ushort *)(info_vbe_bios->vmode_args_segment << 4 | info_vbe_bios->vmode_args_offset);
74+ if(ctrl->VBE.version_major >= 0x02){
75+ ctrl->display_mode = DISPLAYMODE_VBE_LINEAR;
76+ } else{
77+ ctrl->display_mode = DISPLAYMODE_VBE_WINDOW;
78+ }
79+ #ifdef CHNOSPROJECT_DEBUG_DISPLAY
80+ debug("Display:VBE is Enbaled(Version %d.%d).\n", ctrl->VBE.version_major, ctrl->VBE.version_minor);
81+ debug("Display:OEM:[%s]\n", ctrl->VBE.oem_string);
82+ #endif
83+ } else{
84+ ctrl->display_mode = DISPLAYMODE_BIOS;
85+ }
86+
87+ if(ctrl->display_mode == DISPLAYMODE_VBE_LINEAR){
88+ #ifdef CHNOSPROJECT_DEBUG_DISPLAY
89+ debug("Display:Getting Video Modes...\n");
90+ #endif
91+ for(i = 0; ctrl->VBE.vmode_args[i] != 0xffff; i++){
92+
93+ }
94+ ctrl->VBE.list_vmode_tags = i;
95+ ctrl->VBE.list_vmode = (INFO_VBE_VideoModeTag *)System_Memory_Allocate(sizeof(INFO_VBE_VideoModeTag) * ctrl->VBE.list_vmode_tags);
96+ info_vbe_vmode = VBE_REALMODE_RETVALUE_ADDRESS;
97+ #ifdef CHNOSPROJECT_DEBUG_DISPLAY
98+ debug("Display:VBE has %d Video Modes.\n", ctrl->VBE.list_vmode_tags);
99+ #endif
100+ for(i = 0; i < ctrl->VBE.list_vmode_tags; i++){
101+ callbiosctrl->CallBIOS_Task->tss->eax = 0x4f01;
102+ callbiosctrl->CallBIOS_Task->tss->es = 0x0000;
103+ callbiosctrl->CallBIOS_Task->tss->edi = 0x0e00;
104+ callbiosctrl->CallBIOS_Task->tss->ecx = ctrl->VBE.vmode_args[i];
105+ System_CallBIOS_Execute(0x10, ctrl->bios_signal, SIGNAL_BIOS_OPERATION_END);
106+
107+ for(;;){
108+ if(FIFO32_Status(ctrl->bios_signal) == 0){
109+
110+ } else{
111+ data = FIFO32_Get(ctrl->bios_signal);
112+ if(data == SIGNAL_BIOS_OPERATION_END || data == SIGNAL_BIOS_OPERATION_END + 1){
113+ break;
114+ }
115+ }
116+ }
117+
118+ if(data == SIGNAL_BIOS_OPERATION_END && (callbiosctrl->retvalue.eax & 0x000000ff) == 0x4f && (callbiosctrl->retvalue.eax & 0x0000ff00) == 0x00){
119+ ctrl->VBE.list_vmode[i].mode_number = ctrl->VBE.vmode_args[i];
120+ ctrl->VBE.list_vmode[i].xsize = info_vbe_vmode->XResolution;
121+ ctrl->VBE.list_vmode[i].ysize = info_vbe_vmode->YResolution;
122+ ctrl->VBE.list_vmode[i].bpp = info_vbe_vmode->BitsPerPixel;
123+ ctrl->VBE.list_vmode[i].memory_model = info_vbe_vmode->MemoryModel;
124+ ctrl->VBE.list_vmode[i].attribute = info_vbe_vmode->ModeAttributes;
125+ ctrl->VBE.list_vmode[i].vram = info_vbe_vmode->PhysBasePtr;
126+ #ifdef CHNOSPROJECT_DEBUG_DISPLAY
127+ debug("Display:%d:0x%X (%dx%d-%dbit) [0x%X]\nDisplay:", i, ctrl->VBE.list_vmode[i].mode_number, ctrl->VBE.list_vmode[i].xsize, ctrl->VBE.list_vmode[i].ysize, ctrl->VBE.list_vmode[i].bpp, ctrl->VBE.list_vmode[i].vram);
128+ if(ctrl->VBE.list_vmode[i].memory_model == 0x04){
129+ debug(" 256-palette");
130+ }
131+ if(ctrl->VBE.list_vmode[i].memory_model == 0x06){
132+ debug(" direct-color");
133+ }
134+ if((ctrl->VBE.list_vmode[i].attribute & (1 << 3)) != 0){
135+ debug(" color");
136+ } else{
137+ debug(" monochrome");
138+ }
139+ if((ctrl->VBE.list_vmode[i].attribute & (1 << 4)) != 0){
140+ debug(" graphic");
141+ } else{
142+ debug(" text");
143+ }
144+ if((ctrl->VBE.list_vmode[i].attribute & (1 << 7)) != 0){
145+ debug(" linear-access-supported");
146+ }
147+ debug("\n");
148+ debug("%d:0x%X %dx%d-%dbits\n", 0, ctrl->VBE.list_vmode[0].mode_number, ctrl->VBE.list_vmode[0].xsize, ctrl->VBE.list_vmode[0].ysize, ctrl->VBE.list_vmode[0].bpp);
149+
150+ #endif
151+ } else{
152+ ctrl->VBE.list_vmode[i].mode_number = ctrl->VBE.vmode_args[i];
153+ ctrl->VBE.list_vmode[i].vram = (void *)0x00000000;
154+ #ifdef CHNOSPROJECT_DEBUG_DISPLAY
155+ debug("Display:%d:0x%X Function Failed.\n", i, ctrl->VBE.list_vmode[i].mode_number);
156+ #endif
157+ }
158+ }
159+
160+
161+ }
162+
163+ #ifdef CHNOSPROJECT_DEBUG_DISPLAY
164+ debug("Display:Ctrl:[0x%X]\n", ctrl);
165+ debug("Display:ctrl->VBE.list_vmode[0]:[0x%X]\n", &ctrl->VBE.list_vmode[0]);
166+ debug("Display:ctrl->bios_signal->buf:[0x%X]\n", ctrl->bios_signal->buf);
167+ #endif
168+
169+ return ctrl;
170+}
171+
172+uint Display_VESA_Set_VideoMode(IO_DisplayControl *ctrl, uint index)
173+{
174+ //retvalue:0 = 切り替え成功
175+ //retvalue:1 = 切り替え失敗(BIOS Call Error)
176+ //retvalue:2 = 切り替え失敗(VBE無効 version < 2.0)
177+ //retvalue:3 = 切り替え失敗(Invalid VideoMode Index)
178+ //retvalue:4 = 切り替え失敗(Linear Mode Not Supported)
179+ //retvalue:5 = 切り替え失敗(システム(CHNOSProject)上で未対応のビット数のため)
180+ //retvalue:6 = 切り替え失敗(システム(CHNOSProject)上で無効とマークされている(vram == null)ため)
181+
182+ IO_CallBIOSControl *callbiosctrl;
183+ uint data;
184+
185+ callbiosctrl = System_CallBIOS_Get_Controller();
186+
187+ if(ctrl->display_mode != DISPLAYMODE_VBE_LINEAR){
188+ #ifdef CHNOSPROJECT_DEBUG_DISPLAY
189+ debug("SetVideo:Error:VBE version < 2.0.\n");
190+ #endif
191+ return 2;
192+ }
193+
194+ if(index >= ctrl->VBE.list_vmode_tags){
195+ #ifdef CHNOSPROJECT_DEBUG_DISPLAY
196+ debug("SetVideo:Error:Invalid VideoMode Index.\n");
197+ #endif
198+ return 3;
199+ }
200+
201+ if((ctrl->VBE.list_vmode[index].attribute & (1 << 7)) == 0){
202+ #ifdef CHNOSPROJECT_DEBUG_DISPLAY
203+ debug("SetVideo:Error:This VideoMode is Not Supported Linear Mode.\n");
204+ #endif
205+ return 4;
206+ }
207+
208+ if(!(ctrl->VBE.list_vmode[index].bpp == 8)){
209+ #ifdef CHNOSPROJECT_DEBUG_DISPLAY
210+ debug("SetVideo:Error:This VideoMode's BitsPerPixel is Not Supported in CHNOSProject.\n");
211+ #endif
212+ return 5;
213+ }
214+
215+ if(ctrl->VBE.list_vmode[index].vram == 0x00000000){
216+ #ifdef CHNOSPROJECT_DEBUG_DISPLAY
217+ debug("SetVideo:Error:This VideoMode has been Marked Invalid(vram==null).\n");
218+ #endif
219+ return 6;
220+ }
221+
222+ callbiosctrl->CallBIOS_Task->tss->eax = 0x4f02;
223+ callbiosctrl->CallBIOS_Task->tss->ebx = ctrl->VBE.list_vmode[index].mode_number | VESA_LINEAR_ACCESS;
224+ System_CallBIOS_Execute(0x10, ctrl->bios_signal, SIGNAL_BIOS_OPERATION_END);
225+
226+ for(;;){
227+ if(FIFO32_Status(ctrl->bios_signal) == 0){
228+
229+ } else{
230+ data = FIFO32_Get(ctrl->bios_signal);
231+ if(data == SIGNAL_BIOS_OPERATION_END || data == SIGNAL_BIOS_OPERATION_END + 1){
232+ break;
233+ }
234+ }
235+ }
236+
237+ if(data == SIGNAL_BIOS_OPERATION_END && (callbiosctrl->retvalue.eax & 0x000000ff) == 0x4f && (callbiosctrl->retvalue.eax & 0x0000ff00) == 0x00){
238+ ctrl->vmode = ctrl->VBE.list_vmode[index].mode_number;
239+ ctrl->vmode_index = index;
240+ ctrl->bpp = ctrl->VBE.list_vmode[index].bpp;
241+ ctrl->xsize = ctrl->VBE.list_vmode[index].xsize;
242+ ctrl->ysize = ctrl->VBE.list_vmode[index].ysize;
243+ ctrl->vram = ctrl->VBE.list_vmode[index].vram;
244+ #ifdef CHNOSPROJECT_DEBUG_DISPLAY
245+ debug("Display:VBE VideoMode Changed.\nDisplay:%d:0x%X (%dx%d-%dbit) [0x%X]\nDisplay:", index, ctrl->VBE.list_vmode[index].mode_number, ctrl->VBE.list_vmode[index].xsize, ctrl->VBE.list_vmode[index].ysize, ctrl->VBE.list_vmode[index].bpp, ctrl->VBE.list_vmode[index].vram);
246+ if(ctrl->VBE.list_vmode[index].memory_model == 0x04){
247+ debug(" 256-palette");
248+ }
249+ if(ctrl->VBE.list_vmode[index].memory_model == 0x06){
250+ debug(" direct-color");
251+ }
252+ if((ctrl->VBE.list_vmode[index].attribute & (1 << 3)) != 0){
253+ debug(" color");
254+ } else{
255+ debug(" monochrome");
256+ }
257+ if((ctrl->VBE.list_vmode[index].attribute & (1 << 4)) != 0){
258+ debug(" graphic");
259+ } else{
260+ debug(" text");
261+ }
262+ if((ctrl->VBE.list_vmode[index].attribute & (1 << 7)) != 0){
263+ debug(" linear-access-supported");
264+ }
265+ debug("\n");
266+ #endif
267+ return 0;
268+ }
269+
270+ #ifdef CHNOSPROJECT_DEBUG_DISPLAY
271+ debug("Display:%d:0x%X Function Failed.\n", index, ctrl->VBE.list_vmode[index].mode_number);
272+ #endif
273+
274+ return 1;
275+}
--- beta/tolset_chn_000/chnos_010/chnos/system.c (revision 306)
+++ beta/tolset_chn_000/chnos_010/chnos/system.c (revision 307)
@@ -85,6 +85,7 @@
8585 IO_MemoryControl MemoryController;
8686 UI_TaskControl *TaskController;
8787 IO_CallBIOSControl *CallBIOSController;
88+ IO_DisplayControl *DisplayController;
8889 struct SYSTEM_COMMONDATA_ENVIRONMENT {
8990 struct SYSTEM_COMMONDATA_ENVIRONMENT_CPUID {
9091 uint max_id;
@@ -123,6 +124,11 @@
123124 Initialise_SerialPort();
124125 Error_Set_Enable_SerialPort(true);
125126
127+ #ifdef CHNOSPROJECT_DEBUG
128+ debug("%s:%d\n", __FILE__, __LINE__);
129+ debug("CHNOSProject is Running in Debug Mode.\n");
130+ #endif
131+
126132 TextMode_Put_String("\tInitialising Memory...\n", white);
127133 System_Check_Memory();
128134 i = System_Get_PhisycalMemorySize();
@@ -206,6 +212,9 @@
206212 TextMode_Put_String("\tSystem Initialising Phase End.\n", white);
207213
208214 IO_STI();
215+
216+ System.DisplayController = Initialise_Display();
217+
209218 return;
210219 }
211220
@@ -350,9 +359,9 @@
350359 return;
351360 }
352361
353-void System_CallBIOS_Send_End_Of_Operation(void)
362+void System_CallBIOS_Send_End_Of_Operation(uint abort)
354363 {
355- CallBIOS_Send_End_Of_Operation(System.CallBIOSController);
364+ CallBIOS_Send_End_Of_Operation(System.CallBIOSController, abort);
356365 return;
357366 }
358367
@@ -362,6 +371,21 @@
362371 return;
363372 }
364373
374+DATA_FIFO32 *System_FIFO32_Initialise(uint size)
375+{
376+ return FIFO32_Initialise(System.MemoryController, size);
377+}
378+
379+uint System_Display_VESA_Set_VideoMode(uint index)
380+{
381+ return Display_VESA_Set_VideoMode(System.DisplayController, index);
382+}
383+
384+IO_DisplayControl *System_Display_Get_Controller(void)
385+{
386+ return System.DisplayController;
387+}
388+
365389 //
366390 void System_Check_Memory(void)
367391 {
--- beta/tolset_chn_000/chnos_010/chnos/callbios.c (revision 306)
+++ beta/tolset_chn_000/chnos_010/chnos/callbios.c (revision 307)
@@ -50,7 +50,8 @@
5050 }
5151 q[i] = 0xff;
5252
53- ctrl->CallBIOS_Task->tss->esp0 = (uint)System_Memory_Allocate(1024 * 32) + (1024 * 32);
53+ ctrl->esp0 = (uint)System_Memory_Allocate(1024 * 32) + (1024 * 32);
54+ ctrl->CallBIOS_Task->tss->esp0 = ctrl->esp0;
5455 ctrl->CallBIOS_Task->tss->ss0 = SYSTEM_DS << 3;
5556
5657 return ctrl;
@@ -67,6 +68,8 @@
6768 ctrl->CallBIOS_Task->tss->ds = 0;
6869 ctrl->CallBIOS_Task->tss->esp = 0xc200;
6970
71+ ctrl->CallBIOS_Task->tss->esp0 = ctrl->esp0;
72+
7073 ctrl->fifo = fifo;
7174 ctrl->endsignal = endsignal;
7275
@@ -78,10 +81,14 @@
7881 return;
7982 }
8083
81-void CallBIOS_Send_End_Of_Operation(IO_CallBIOSControl *ctrl)
84+void CallBIOS_Send_End_Of_Operation(IO_CallBIOSControl *ctrl, uint abort)
8285 {
8386 if(ctrl->fifo != 0){
84- FIFO32_Put(ctrl->fifo, ctrl->endsignal);
87+ if(!abort){
88+ FIFO32_Put(ctrl->fifo, ctrl->endsignal);
89+ } else{
90+ FIFO32_Put(ctrl->fifo, ctrl->endsignal + 1);
91+ }
8592 }
8693 return;
8794 }
@@ -160,10 +167,12 @@
160167 #ifdef CHNOSPROJECT_DEBUG_CALLBIOS
161168 debug("CallBIOS:Privileged Operation Found in v8086mode.\n");
162169 debug("Opcode[0x%X]:0x%X\n", eip, eip[0]);
163- debug("Task Sleeping...\n");
170+ debug("Task Terminate...\n");
164171 #endif
165172 }
166173
174+ System_CallBIOS_Send_End_Of_Operation(True);
175+
167176 for(;;){
168177 System_MultiTask_Task_Sleep(System_MultiTask_GetNowTask());
169178 }
--- beta/tolset_chn_000/chnos_010/chnos/Makefile (revision 306)
+++ beta/tolset_chn_000/chnos_010/chnos/Makefile (revision 307)
@@ -1,7 +1,7 @@
11
22 #OBJS_BOOTPACK = naskfunc.obj hankaku.obj gdtidt.obj graphic.obj grap_08.obj grap_16.obj grap_32.obj init.obj intrpt.obj io.obj memory.obj paging.obj sheet.obj fifo.obj mtask.obj timer.obj keyboard.obj mouse.obj window.obj console.obj file.obj uuid.obj api.obj bootpack.obj
3-OBJS_BOOTPACK = nasfunc0.obj nasfunc1.obj nasfunc2.obj hankaku.obj callbios.obj cfunc.obj drawing.obj dsctbl.obj emu86.obj emu86asm.obj error.obj fifo.obj intrpt.obj keyboard.obj memory.obj mtask.obj serial.obj system.obj timer.obj vgatmode.obj xception.obj bootpack.obj
4-HEADS_BOOTPACK = core.h coredef0.h coredef1.h coredef2.h keyid.h
3+OBJS_BOOTPACK = nasfunc0.obj nasfunc1.obj nasfunc2.obj hankaku.obj callbios.obj cfunc.obj display.obj drawing.obj dsctbl.obj emu86.obj emu86asm.obj error.obj fifo.obj intrpt.obj keyboard.obj memory.obj mtask.obj serial.obj system.obj timer.obj vgatmode.obj xception.obj bootpack.obj
4+HEADS_BOOTPACK = core.h coredef0.h coredef1.h coredef2.h coredef3.h keyid.h
55 TOOLPATH = ../../z_tools/
66 INCPATH = ../../z_tools/CHNOSProject/
77
--- beta/tolset_chn_000/chnos_010/chnos/core.h (revision 306)
+++ beta/tolset_chn_000/chnos_010/chnos/core.h (revision 307)
@@ -3,6 +3,8 @@
33 #include "coredef0.h" /*システム定数宣言*/
44 #include "coredef1.h" /*システムデータ型宣言*/
55 #include "coredef2.h" /*システム外部リソース宣言*/
6+#include "coredef3.h" /*システムFIFOコマンド宣言*/
7+#include "keyid.h" /*KeyIdentifier キーID宣言*/
68
79 /*functions*/
810 /*bootpack.c 基幹部分*/
@@ -12,7 +14,7 @@
1214
1315 IO_CallBIOSControl *Initialise_CallBIOS(void);
1416 void CallBIOS_Execute(IO_CallBIOSControl *ctrl, uchar intn, DATA_FIFO32 *fifo, uint endsignal);
15-void CallBIOS_Send_End_Of_Operation(IO_CallBIOSControl *ctrl);
17+void CallBIOS_Send_End_Of_Operation(IO_CallBIOSControl *ctrl, uint abort);
1618 void CallBIOS_Check_Privileged_Operation(uint *esp);
1719 uint CallBIOS_Push_Data_To_Stack(uint *esp, ushort data);
1820 uint CallBIOS_Pop_Data_From_Stack(uint *esp);
@@ -33,6 +35,10 @@
3335 void CFunction_vsnprintf_To_String_From_Hex_Lower(CFunction_vsnprintf_WorkArea *work, uint hex);
3436 void CFunction_vsnprintf_To_String_From_Decimal_Unsigned(CFunction_vsnprintf_WorkArea *work, uint d);
3537
38+/*display.c ディスプレイ制御関連*/
39+IO_DisplayControl *Initialise_Display(void);
40+uint Display_VESA_Set_VideoMode(IO_DisplayControl *ctrl, uint index);
41+
3642 /*drawing.c 描画関連*/
3743 void Drawing08_Initialise_Palette(void);
3844 void Drawing08_Set_Palette(uint start, uint end, uchar *rgb);
@@ -140,6 +146,7 @@
140146 void Initialise_Keyboard(void);
141147 void InterruptHandler21(uint *esp);
142148 void Keyboard_Set_ReceiveFIFO(DATA_FIFO32 *fifo, uint data0);
149+ushort Keyboard_Decode_KeyCode(uchar keycode);
143150
144151 /*memory.c メモリ関連*/
145152 uint Memory_Test(uint start, uint end);
@@ -185,8 +192,11 @@
185192 IO_CallBIOSControl *System_CallBIOS_Get_Controller(void);
186193 void System_CallBIOS_Execute(uchar intn, DATA_FIFO32 *fifo, uint endsignal);
187194 void System_Memory_Free(void *addr, uint size);
188-void System_CallBIOS_Send_End_Of_Operation(void);
195+void System_CallBIOS_Send_End_Of_Operation(uint abort);
189196 void System_MultiTask_Task_Sleep(UI_Task *task);
197+DATA_FIFO32 *System_FIFO32_Initialise(uint size);
198+uint System_Display_VESA_Set_VideoMode(uint index);
199+IO_DisplayControl *System_Display_Get_Controller(void);
190200
191201 /*timer.c タイマー関連*/
192202 void Initialise_ProgrammableIntervalTimer(void);
--- beta/tolset_chn_000/chnos_010/chnos/bootpack.c (revision 306)
+++ beta/tolset_chn_000/chnos_010/chnos/bootpack.c (revision 307)
@@ -1,15 +1,15 @@
11
22 #include "core.h"
33
4-void TestTask2(void);
5-
4+#define MAIN_KEYBASE 0x100
65 void CHNMain(void)
76 {
8- //uchar s[128];
9- uint i, data;
10- UI_Task *KBCT, *test2;
7+ uchar s[128];
8+ uint data;
9+ UI_Task *KBCT;
1110 UI_Task *mytask;
12- IO_CallBIOSControl *callbiosctrl;
11+ uint i;
12+ IO_DisplayControl *disp_ctrl;
1313
1414 Initialise_System();
1515
@@ -23,39 +23,61 @@
2323 KBCT->tss->esp = (uint)System_Memory_Allocate(1024 * 32) + (1024 * 32);
2424 System_MultiTask_Task_Run(KBCT);
2525
26- test2 = System_MultiTask_Task_Initialise(0);
27- test2->tss->eip = (uint)&TestTask2;
28- test2->tss->cs = SYSTEM_CS << 3;
29- test2->tss->ss = SYSTEM_DS << 3;
30- test2->tss->ds = SYSTEM_DS << 3;
31- test2->tss->esp = (uint)System_Memory_Allocate(1024 * 32) + (1024 * 32);
32- System_MultiTask_Task_Run(test2);
26+ disp_ctrl = System_Display_Get_Controller();
3327
3428 i = 0;
29+ data = 0;
3530
36- callbiosctrl = System_CallBIOS_Get_Controller();
37- callbiosctrl->CallBIOS_Task->tss->eax = 0x0013;
38- System_CallBIOS_Execute(0x10, mytask->fifo, 0xff);
31+ Drawing08_Fill_Rectangle(VGA_VRAM_ADR, VGA08_VRAM_XSIZE, 0xffffff, 0, 0, VGA08_VRAM_XSIZE - 1, VGA08_VRAM_YSIZE - 1);
32+ Drawing08_Put_String(VGA_VRAM_ADR, VGA08_VRAM_XSIZE, 10, 10, 0x000000, "Welcome to CHNOSProject!");
3933
40- for(;;){
41- if(FIFO32_MyTaskFIFO_Status() == 0){
42-
43- } else{
44- data = FIFO32_MyTaskFIFO_Get();
45- if(data == 0xff){
46- #ifdef CHNOSPROJECT_DEBUG_CALLBIOS
47- debug("Main:Receive BIOS Control End.\n");
48- #endif
49- break;
34+ if(disp_ctrl->display_mode == DISPLAYMODE_VBE_LINEAR){
35+ Drawing08_Put_String(VGA_VRAM_ADR, VGA08_VRAM_XSIZE, 10, 10 + 16 * 1, 0x000000, "Please Select the VideoMode Number.");
36+ Drawing08_Put_String(VGA_VRAM_ADR, VGA08_VRAM_XSIZE, 10, 10 + 16 * 2, 0x000000, "(Use cursor Up or Down, Select Enter.)");
37+ Drawing08_Fill_Rectangle(VGA_VRAM_ADR, VGA08_VRAM_XSIZE, 0x00ff00, 10, 10 + 16 * 3, VGA08_VRAM_XSIZE - 10 - 1, 10 + 16 * 5 - 1);
38+ snprintf(s, "%d:0x%X %dx%d-%dbits", sizeof(s), i, disp_ctrl->VBE.list_vmode[i].mode_number, disp_ctrl->VBE.list_vmode[i].xsize, disp_ctrl->VBE.list_vmode[i].ysize, disp_ctrl->VBE.list_vmode[i].bpp);
39+ Drawing08_Put_String(VGA_VRAM_ADR, VGA08_VRAM_XSIZE, 10, 10 + 16 * 3, 0x000000, s);
40+
41+ FIFO32_Put_Arguments(KBCT->fifo, 4, FIFOCMD_KBCT_SET_FOCUS_FIFO, mytask->fifo, MAIN_KEYBASE, 0);
42+
43+ for(;;){
44+ if(FIFO32_MyTaskFIFO_Status() == 0){
45+
46+ } else{
47+ data = FIFO32_MyTaskFIFO_Get();
48+ if(MAIN_KEYBASE <= data && data <= (MAIN_KEYBASE + 0xFFFF)){
49+ data -= MAIN_KEYBASE;
50+ if(!(data & KEYID_MASK_BREAK) && (data & KEYID_MASK_EXTENDED)){
51+ if((data & KEYID_MASK_ID) == KEYID_CURSOR_U){
52+ if(i == 0){
53+ i = disp_ctrl->VBE.list_vmode_tags - 1;
54+ } else{
55+ i--;
56+ }
57+ Drawing08_Fill_Rectangle(VGA_VRAM_ADR, VGA08_VRAM_XSIZE, 0x00ff00, 10, 10 + 16 * 3, VGA08_VRAM_XSIZE - 10 - 1, 10 + 16 * 5 - 1);
58+ snprintf(s, "%d:0x%X %dx%d-%dbits", sizeof(s), i, disp_ctrl->VBE.list_vmode[i].mode_number, disp_ctrl->VBE.list_vmode[i].xsize, disp_ctrl->VBE.list_vmode[i].ysize, disp_ctrl->VBE.list_vmode[i].bpp);
59+ Drawing08_Put_String(VGA_VRAM_ADR, VGA08_VRAM_XSIZE, 10, 10 + 16 * 3, 0x000000, s);
60+ } else if((data & KEYID_MASK_ID) == KEYID_CURSOR_D){
61+ if(i == disp_ctrl->VBE.list_vmode_tags - 1){
62+ i = 0;
63+ } else{
64+ i ++;
65+ }
66+ Drawing08_Fill_Rectangle(VGA_VRAM_ADR, VGA08_VRAM_XSIZE, 0x00ff00, 10, 10 + 16 * 3, VGA08_VRAM_XSIZE - 10 - 1, 10 + 16 * 5 - 1);
67+ snprintf(s, "%d:0x%X %dx%d-%dbits", sizeof(s), i, disp_ctrl->VBE.list_vmode[i].mode_number, disp_ctrl->VBE.list_vmode[i].xsize, disp_ctrl->VBE.list_vmode[i].ysize, disp_ctrl->VBE.list_vmode[i].bpp);
68+ Drawing08_Put_String(VGA_VRAM_ADR, VGA08_VRAM_XSIZE, 10, 10 + 16 * 3, 0x000000, s);
69+ } else if((data & KEYID_MASK_ID) == KEYID_ENTER){
70+ if(!System_Display_VESA_Set_VideoMode(i)){
71+ break;
72+ }
73+ Drawing08_Fill_Rectangle(VGA_VRAM_ADR, VGA08_VRAM_XSIZE, 0x00ff00, 10, 10 + 16 * 3, VGA08_VRAM_XSIZE - 10 - 1, 10 + 16 * 4 - 1);
74+ Drawing08_Put_String(VGA_VRAM_ADR, VGA08_VRAM_XSIZE, 10, 10 + 16 * 4, 0x000000, "Function Failed. Try again.");
75+ }
76+ }
77+ }
5078 }
5179 }
5280 }
53-
54- Drawing08_Initialise_Palette();
55- Drawing08_Fill_Rectangle(VGA_VRAM_ADR, VGA08_VRAM_XSIZE, 0xffffff, 0, 0, VGA08_VRAM_XSIZE - 1, VGA08_VRAM_YSIZE - 1);
56- Drawing08_Fill_Rectangle(VGA_VRAM_ADR, VGA08_VRAM_XSIZE, 0x00ff00, 100, 100, VGA08_VRAM_XSIZE - 10 - 1, VGA08_VRAM_YSIZE - 10);
57- Drawing08_Put_String(VGA_VRAM_ADR, VGA08_VRAM_XSIZE, 10, 10, 0x000000, "Welcome to CHNOSProject!");
58-
5981 for(;;){
6082
6183 }
@@ -65,8 +87,15 @@
6587 {
6688 UI_Task *mytask;
6789 uchar s[128];
68- uint data;
90+ uint data, offset;
91+ DATA_FIFO32 *sendto;
92+ uint args[5];
93+ uint i;
6994
95+ sendto = 0;
96+ data = 0;
97+ offset = 0;
98+
7099 mytask = System_MultiTask_GetNowTask();
71100
72101 snprintf(s, "KBCT:KeyboardControlTask Start Running.\nKBCT:UI_Task=0x%X\n", sizeof(s), mytask);
@@ -76,31 +105,29 @@
76105
77106 for(;;){
78107 if(FIFO32_MyTaskFIFO_Status() == 0){
79-
108+
80109 } else{
81110 data = FIFO32_MyTaskFIFO_Get();
82111 if(0x100 <= data && data <= 0x1ff){
83112 data -= 0x100;
84- snprintf(s, "KBCT:KeyCode=0x%X\n", sizeof(s), data);
85- TextMode_Put_String(s, white);
113+ data = Keyboard_Decode_KeyCode(data);
114+ if(sendto != 0 && data != 0){
115+ FIFO32_Put(sendto, data + offset);
116+ }
117+ } else if(data == FIFOCMD_KBCT_SET_FOCUS_FIFO){
118+ args[0] = FIFOCMD_KBCT_SET_FOCUS_FIFO;
119+ for(i = 1; i < 5; i++){
120+ args[i] = FIFO32_MyTaskFIFO_Get();
121+ }
122+ if(args[4] == SIGNAL_ARGUMENTS_END){
123+ sendto = (DATA_FIFO32 *)args[1];
124+ offset = args[2];
125+ } else{
126+ #ifdef CHNOSPROJECT_DEBUG_KBCT
127+ debug("KBCT:Invalid Arguments to Set Focus FIFO.\n");
128+ #endif
129+ }
86130 }
87131 }
88132 }
89133 }
90-
91-void TestTask2(void)
92-{
93- uchar s[128];
94- uint i;
95- UI_Task *mytask;
96-
97- i = 0;
98-
99- mytask = System_MultiTask_GetNowTask();
100-
101- for(;;){
102- i++;
103- snprintf(s, "TestTask2=%d=%d", sizeof(s), mytask->count, i);
104- TextMode_Put_String_Absolute(s, white, 0, 3);
105- }
106-}
--- beta/tolset_chn_000/chnos_010/chnos/keyid.h (revision 306)
+++ beta/tolset_chn_000/chnos_010/chnos/keyid.h (revision 307)
@@ -6,7 +6,7 @@
66 // :拡張キーID(拡張フラグが1のとき)
77 //bit07 :Make,Break種別(0:Make,1:Break)(0:種別なし)
88 //bit08 :テンキー種別(0:フルキー,1:テンキー)(0:種別なし)
9-//bit19 :Shiftキー状態(0:オフ,1:オン)
9+//bit09 :Shiftキー状態(0:オフ,1:オン)
1010 //bit10 :Ctrlキー状態(0:オフ,1:オン)
1111 //bit11 :Altキー状態(0:オフ,1:オン)
1212 //bit12 :NumLock状態(0:オフ,1:オン)
@@ -13,7 +13,6 @@
1313 //bit13 :CapsLock状態(0:オフ,1:オン)
1414 //bit14 :ScrollLock状態(0:オフ,1:オン)
1515 //bit15 :拡張フラグ(0:ASCII,1:拡張キーコード)
16-//bit09-14 :予約
1716
1817 //つまり、FIFOで受け取って、バイアスを引いたら、KEYID_EXTENDEDフラグを調べる。
1918 //次に、BREAKフラグを調べる。
@@ -110,6 +109,10 @@
110109 #define KEYID_HENKAN 0x0029
111110 #define KEYID_MUHENKAN 0x002a
112111
112+#define KEYID_BACKSPACE 0x0040
113+#define KEYID_TAB 0x0041
114+#define KEYID_ENTER 0x0042
115+
113116 #define KEYID_KBD_ERROR 0x007e
114117 #define KEYID_UNKNOWN 0x007f
115118
--- beta/tolset_chn_000/chnos_010/chnos/fifo.c (revision 306)
+++ beta/tolset_chn_000/chnos_010/chnos/fifo.c (revision 307)
@@ -1,6 +1,9 @@
11
22 #include "core.h"
33
4+//指定サイズは、バイト単位。
5+//内部サイズは、エントリ(uint=4byte)単位。
6+
47 DATA_FIFO32 *FIFO32_Initialise(IO_MemoryControl memctrl, uint size)
58 {
69 DATA_FIFO32 *fifo;
@@ -7,9 +10,9 @@
710
811 fifo = Memory_Allocate(memctrl, sizeof(DATA_FIFO32));
912
10- fifo->size = size;
11- fifo->buf = Memory_Allocate(memctrl, size);
12- fifo->free = size; /*freesize*/
13+ fifo->size = size >> 2;
14+ fifo->buf = Memory_Allocate(memctrl, fifo->size << 2);
15+ fifo->free = fifo->size; /*freesize*/
1316 fifo->flags.initialized = False;
1417 fifo->flags.overflow = False;
1518 fifo->p = 0; /*write*/
@@ -61,6 +64,10 @@
6164 return -1;
6265 }
6366
67+ if(args == 0){
68+ return 0;
69+ }
70+
6471 eflags = IO_Load_EFlags();
6572 IO_CLI();
6673
@@ -124,7 +131,7 @@
124131 return;
125132 }
126133
127- System_Memory_Free(fifo->buf, fifo->size);
134+ System_Memory_Free(fifo->buf, fifo->size << 2);
128135
129136 fifo->size = 0;
130137 fifo->buf = 0;
--- beta/tolset_chn_000/chnos_010/chnos/xception.c (revision 306)
+++ beta/tolset_chn_000/chnos_010/chnos/xception.c (revision 307)
@@ -33,12 +33,30 @@
3333
3434 void CPU_ExceptionHandler06(uint *esp)
3535 {
36+ IO_CallBIOSControl *callbios;
37+
38+ callbios = System_CallBIOS_Get_Controller();
3639 /*Invalid Opcode Exception*/
37- if(System_MultiTask_GetNowTask() == System_CallBIOS_Get_Controller()->CallBIOS_Task){ /*もし、例外を起こしたタスクがCallBIOSだったら*/
40+ if(System_MultiTask_GetNowTask() == callbios->CallBIOS_Task){ /*もし、例外を起こしたタスクがCallBIOSだったら*/
3841 #ifdef CHNOSPROJECT_DEBUG_CALLBIOS
3942 debug("Exception_0x06:UD2 Opcode Found in v8086mode.\n");
4043 #endif
41- System_CallBIOS_Send_End_Of_Operation();
44+ callbios->retvalue.eip = esp[0x0a];
45+ callbios->retvalue.eax = esp[0x07];
46+ callbios->retvalue.ecx = esp[0x06];
47+ callbios->retvalue.edx = esp[0x05];
48+ callbios->retvalue.ebx = esp[0x04];
49+ callbios->retvalue.esp = esp[0x03];
50+ callbios->retvalue.ebp = esp[0x02];
51+ callbios->retvalue.esi = esp[0x01];
52+ callbios->retvalue.edi = esp[0x00];
53+ callbios->retvalue.es = esp[0x09];
54+ callbios->retvalue.cs = esp[0x0b];
55+ callbios->retvalue.ss = esp[0x0e];
56+ callbios->retvalue.ds = esp[0x08];
57+ callbios->retvalue.eflags.eflags = esp[0x0c];
58+
59+ System_CallBIOS_Send_End_Of_Operation(False);
4260 System_MultiTask_Task_Sleep(System_MultiTask_GetNowTask());
4361 } else{
4462 Error_Report(ERROR_CPU_EXCEPTION_06, esp);
--- beta/tolset_chn_000/chnos_010/chnos/coredef0.h (revision 306)
+++ beta/tolset_chn_000/chnos_010/chnos/coredef0.h (revision 307)
@@ -9,6 +9,8 @@
99 //#define CHNOSPROJECT_DEBUG_EMULATOR_X86
1010 //#define CHNOSPROJECT_DEBUG_CALLBIOS
1111 //#define CHNOSPROJECT_DEBUG_FIFO
12+ //#define CHNOSPROJECT_DEBUG_KBCT
13+ #define CHNOSPROJECT_DEBUG_DISPLAY
1214 #endif
1315
1416 /*defines*/
@@ -222,6 +224,14 @@
222224 #define VGA08_VRAM_XSIZE 320
223225 #define VGA08_VRAM_YSIZE 200
224226
227+#define VESA_LINEAR_ACCESS 0x4000
228+#define VESA_OMIT_CLEARING_VRAM 0x8000
229+
230+#define VBE_REALMODE_RETVALUE_ADDRESS (void *)0x00000e00;
231+#define DISPLAYMODE_BIOS 0x0000
232+#define DISPLAYMODE_VBE_WINDOW 0x0001
233+#define DISPLAYMODE_VBE_LINEAR 0x0002
234+
225235 /*settings*/
226236 /*system segments*/
227237 #define SYSTEM_DS 0x01
--- beta/tolset_chn_000/chnos_010/chnos/coredef1.h (revision 306)
+++ beta/tolset_chn_000/chnos_010/chnos/coredef1.h (revision 307)
@@ -228,6 +228,8 @@
228228 uint codesize;
229229 DATA_FIFO32 *fifo;
230230 uint endsignal;
231+ CPU_TaskStateSegment retvalue;
232+ uint esp0;
231233 } IO_CallBIOSControl;
232234
233235 /*cfunction*/
@@ -312,3 +314,83 @@
312314 int x;
313315 int y;
314316 } DATA_Location2D;
317+
318+/*display*/
319+typedef struct _INFO_VBE_BIOS {
320+ uchar sign[4];
321+ uchar ver_minor;
322+ uchar ver_major;
323+ ushort oem_string_offset;
324+ ushort oem_string_segment;
325+ ushort flags[2]; //パディングの関係で、本当はuintだがushort*2にしている。
326+ ushort vmode_args_offset;
327+ ushort vmode_args_segment;
328+ ushort vram_supported_size_kb;
329+} INFO_VBE_BIOS;
330+
331+typedef struct _INFO_VBE_VIDEO_MODE {
332+ ushort ModeAttributes;
333+ uchar WinAAttributes;
334+ uchar WinBAttributes;
335+ ushort WinGranularity;
336+ ushort WinSize;
337+ ushort WinASegment;
338+ ushort WinBSegment;
339+ uint WinFuncPtr;
340+ ushort BytesPerScanLine;
341+ ushort XResolution;
342+ ushort YResolution;
343+ uchar XCharSize;
344+ uchar YCharSize;
345+ uchar NumberOfPlanes;
346+ uchar BitsPerPixel;
347+ uchar NumberOfBanks;
348+ uchar MemoryModel;
349+ uchar BankSize;
350+ uchar NumberOfImagePages;
351+ uchar Reserved;
352+ uchar RedMaskSize;
353+ uchar RedFieldPosition;
354+ uchar GreenMaskSize;
355+ uchar GreenFieldPosition;
356+ uchar BlueMaskSize;
357+ uchar BlueFieldPosition;
358+ uchar RsvdMaskSize;
359+ uchar RsvdFieldPodition;
360+ uchar DirectColorModeInfo;
361+ void* PhysBasePtr;
362+} INFO_VBE_VideoMode;
363+
364+typedef struct _INFO_VBE_VIDEOMODETAG {
365+ ushort mode_number;
366+ ushort xsize;
367+ ushort ysize;
368+ uchar bpp;
369+ uchar memory_model; //0x00:text 0x04:256palette 0x06:direct color
370+ ushort attribute; //bit3:1:color 0:monochrome
371+ //bit4:1:graphic 0:text
372+ //bit7:linear buffer support
373+ ushort reserve;
374+ void *vram; //vram:0=not supported.
375+} INFO_VBE_VideoModeTag;
376+
377+typedef struct IO_DISPLAY_CONTROL {
378+ struct IO_DISPLAY_CONTROL_VBE {
379+ uchar version_minor;
380+ uchar version_major;
381+ ushort vram_supported_size_kb;
382+ uint flags;
383+ uchar *oem_string;
384+ ushort *vmode_args;
385+ uint list_vmode_tags;
386+ INFO_VBE_VideoModeTag *list_vmode;
387+ } VBE;
388+ ushort display_mode; //0x0000:BIOS 0x0001:VBE Window Access(version < 2.0)(not implemented) 0x0002:VBE Linear Access
389+ ushort vmode; //0x0000:VGA 320x200 8bit
390+ ushort vmode_index;
391+ ushort bpp;
392+ ushort xsize;
393+ ushort ysize;
394+ void *vram;
395+ DATA_FIFO32 *bios_signal;
396+} IO_DisplayControl;
旧リポジトリブラウザで表示