• R/O
  • SSH
  • HTTPS

chnosproject: コミット


コミットメタ情報

リビジョン327 (tree)
日時2012-08-03 00:03:57
作者hikarupsp

ログメッセージ

pciコマンドを追加。
strtolを追加。
dirコマンドを追加。
その他関連関数の整備。

変更サマリ

差分

--- beta/tolset_chn_000/chnos_010/chnos/console.c (revision 326)
+++ beta/tolset_chn_000/chnos_010/chnos/console.c (revision 327)
@@ -76,7 +76,7 @@
7676 return 0;
7777 }
7878
79-void Console_MainTask(UI_Console *myconsole)
79+void Console_MainTask(UI_Console *console)
8080 {
8181 UI_Task *mytask;
8282 uint data;
@@ -91,23 +91,25 @@
9191 debug("CMT:ConsoleMainTask[UI_Task=0x%X] Start Running.\n", mytask);
9292 #endif
9393
94- myconsole->printf_buffer = (uchar *)System_Memory_Allocate(CONSOLE_PRINTF_BUFFER_SIZE);
94+ console->printf_buffer = (uchar *)System_Memory_Allocate(CONSOLE_PRINTF_BUFFER_SIZE);
9595
96- TextBox_Show(myconsole->textbox, SHEET_MAX_CHILDREN, (int)(myconsole->textbox->sheet->parent->size.x >> 1) - (int)(myconsole->textbox->sheet->size.x >> 1), (int)(myconsole->textbox->sheet->parent->size.y >> 1) - (int)(myconsole->textbox->sheet->size.y >> 1));
97- if(myconsole->textbox->sheet->location.x < 0){
98- Sheet_Slide_Absolute(myconsole->textbox->sheet, 0, SHEET_LOCATION_NOCHANGE);
96+ TextBox_Show(console->textbox, SHEET_MAX_CHILDREN, (int)(console->textbox->sheet->parent->size.x >> 1) - (int)(console->textbox->sheet->size.x >> 1), (int)(console->textbox->sheet->parent->size.y >> 1) - (int)(console->textbox->sheet->size.y >> 1));
97+ if(console->textbox->sheet->location.x < 0){
98+ Sheet_Slide_Absolute(console->textbox->sheet, 0, SHEET_LOCATION_NOCHANGE);
9999 }
100- if(myconsole->textbox->sheet->location.y < 0){
101- Sheet_Slide_Absolute(myconsole->textbox->sheet, SHEET_LOCATION_NOCHANGE, 0);
100+ if(console->textbox->sheet->location.y < 0){
101+ Sheet_Slide_Absolute(console->textbox->sheet, SHEET_LOCATION_NOCHANGE, 0);
102102 }
103- TextBox_Put_Character(myconsole->textbox, '>');
104- TextBox_SetEnable_RecordInputText(myconsole->textbox, True);
105- myconsole->flags.bit.isprompt = True;
103+ TextBox_Put_Character(console->textbox, '>');
104+ TextBox_SetEnable_RecordInputText(console->textbox, True);
105+ console->flags.bit.isprompt = True;
106106
107107 ctimer = Timer_Initialize();
108108 Timer_Config(ctimer, 500, mytask->fifo, 1, True);
109109 Timer_Run(ctimer);
110110
111+ console->boot_fd = FloppyDisk_Initialize(ADR_DISKIMG);
112+
111113 for(;;){
112114 if(FIFO32_MyTaskFIFO_Status() == 0){
113115 System_MultiTask_Task_Sleep(mytask);
@@ -119,14 +121,14 @@
119121 if(data < INPUTSIGNAL_OFFSET){
120122 //汎用利用可能領域0
121123 if(data == 1){
122- TextBox_Cursor_Blink(myconsole->textbox);
124+ TextBox_Cursor_Blink(console->textbox);
123125 }
124126 } else if(data < SIGNAL_KEY_OFFSET){
125127 data -= INPUTSIGNAL_OFFSET;
126128 if(data == INPUTSIGNAL_FOCUS_GOT){
127- TextBox_SetEnable_CursorBlink(myconsole->textbox, True);
129+ TextBox_SetEnable_CursorBlink(console->textbox, True);
128130 } else if(data == INPUTSIGNAL_FOCUS_LOST){
129- TextBox_SetEnable_CursorBlink(myconsole->textbox, False);
131+ TextBox_SetEnable_CursorBlink(console->textbox, False);
130132 }
131133 //入力通知領域
132134 } else if(data < SIGNAL_KEY_OFFSET + 0xffff){
@@ -136,24 +138,32 @@
136138 if(!(data & KEYID_MASK_BREAK) && (data & KEYID_MASK_EXTENDED)){
137139 if((data & KEYID_MASK_ID) == KEYID_ENTER){
138140 key_ignore = True;
139- TextBox_SetEnable_RecordInputText(myconsole->textbox, False);
140- TextBox_Put_Character(myconsole->textbox, '\n');
141- if(Console_CompareCommandline_s(myconsole, "test")){
142- TextBox_Put_String(myconsole->textbox, "Hello, World.");
143- } else if(Console_CompareCommandline_s(myconsole, "mem")){
144- Console_printf(myconsole, "Total:%10uBytes %5uKB\n", System_Get_PhisycalMemorySize(), System_Get_PhisycalMemorySize() >> 10);
145- Console_printf(myconsole, "Free :%10uBytes %5uKB\n", System_Memory_Get_FreeSize(), System_Memory_Get_FreeSize() >> 10);
141+ TextBox_SetEnable_RecordInputText(console->textbox, False);
142+ TextBox_Put_Character(console->textbox, '\n');
143+ if(Console_CompareCommandline_n(console, "test", 4)){
144+ TextBox_Put_String(console->textbox, "Hello, World.\n");
145+ if(console->textbox->text_buf[4] == ' '){
146+ Console_printf(console, "value16:0x%X\n", strtol(&console->textbox->text_buf[5], Null, 0));
147+ Console_printf(console, "value10:%u\n", strtol(&console->textbox->text_buf[5], Null, 0));
148+ }
149+ } else if(Console_CompareCommandline_s(console, "mem")){
150+ Console_printf(console, "Total:%10uBytes %5uKB\n", System_Get_PhisycalMemorySize(), System_Get_PhisycalMemorySize() >> 10);
151+ Console_printf(console, "Free :%10uBytes %5uKB\n", System_Memory_Get_FreeSize(), System_Memory_Get_FreeSize() >> 10);
152+ } else if(Console_CompareCommandline_s(console, "dir")){
153+ Console_Command_dir(console);
154+ } else if(Console_CompareCommandline_n(console, "pci", 3)){
155+ Console_Command_pci(console);
146156 } else{
147- TextBox_Put_String(myconsole->textbox, "Console:No such file or command:");
148- TextBox_Put_String(myconsole->textbox, myconsole->textbox->text_buf);
157+ TextBox_Put_String(console->textbox, "Console:There is no such file or command:");
158+ TextBox_Put_String(console->textbox, console->textbox->text_buf);
149159 }
150- TextBox_Put_Character(myconsole->textbox, '\n');
151- TextBox_Put_Character(myconsole->textbox, '>');
152- TextBox_SetEnable_RecordInputText(myconsole->textbox, True);
160+ TextBox_Put_Character(console->textbox, '\n');
161+ TextBox_Put_Character(console->textbox, '>');
162+ TextBox_SetEnable_RecordInputText(console->textbox, True);
153163 }
154164 }
155165 if(!key_ignore){
156- TextBox_Put_Key(myconsole->textbox, data);
166+ TextBox_Put_Key(console->textbox, data);
157167 }
158168 } else if(data < TCM_OFFSET){
159169 //汎用利用可能領域1
@@ -164,15 +174,107 @@
164174 }
165175 }
166176
167-bool Console_CompareCommandline_s(UI_Console *myconsole, const uchar s[])
177+bool Console_CompareCommandline_s(UI_Console *console, const uchar s[])
168178 {
169- return CFunction_CompareStrings(myconsole->textbox->text_buf, s);
179+ return CFunction_CompareStrings(console->textbox->text_buf, s);
170180 }
171181
172-uint Console_printf(UI_Console *myconsole, const uchar format[], ...)
182+bool Console_CompareCommandline_n(UI_Console *console, const uchar s[], unsigned int n)
173183 {
174- CFunction_vsnprintf(myconsole->printf_buffer, CONSOLE_PRINTF_BUFFER_SIZE, format, (uint *)(&format + 1));
175- TextBox_Put_String(myconsole->textbox, myconsole->printf_buffer);
184+ return CFunction_CompareStrings_n(console->textbox->text_buf, s, n);
185+}
186+
187+uint Console_printf(UI_Console *console, const uchar format[], ...)
188+{
189+ CFunction_vsnprintf(console->printf_buffer, CONSOLE_PRINTF_BUFFER_SIZE, format, (uint *)(&format + 1));
190+ TextBox_Put_String(console->textbox, console->printf_buffer);
176191 return 0;
177192 }
178193
194+uint Console_Command_dir(UI_Console *console)
195+{
196+ uint i, j;
197+ IO_FloppyDisk_RDE_UpdateTime rdetime;
198+ IO_FloppyDisk_RDE_UpdateDate rdedate;
199+ IO_FloppyDisk_RDE_Attribute rdeattr;
200+
201+ for(i = 0; i < FLOPPYDISK_RDE_ENTRIES; i++){
202+ if(console->boot_fd->files[i].name[0] == 0x00){
203+ break;
204+ }
205+ rdeattr.attribute = console->boot_fd->files[i].attribute;
206+ if(console->boot_fd->files[i].name[0] != 0xe5 && console->boot_fd->files[i].name[0] != 0x05 && !rdeattr.bit.volumelabel && !rdeattr.bit.directory){
207+ for(j = 0; j < 8; j++){
208+ TextBox_Put_Character(console->textbox, console->boot_fd->files[i].name[j]);
209+ }
210+ TextBox_Put_Character(console->textbox, '.');
211+ for(j = 0; j < 3; j++){
212+ TextBox_Put_Character(console->textbox, console->boot_fd->files[i].ext[j]);
213+ }
214+ Console_printf(console, " %6d", console->boot_fd->files[i].size);
215+ rdedate.updatedate = console->boot_fd->files[i].updatedate;
216+ Console_printf(console, " %04d/%02d/%02d", rdedate.bit.year + 1980, rdedate.bit.month, rdedate.bit.day);
217+ rdetime.updatetime = console->boot_fd->files[i].updatetime;
218+ Console_printf(console, " %02d:%02d:%02d\n", rdetime.bit.hour, rdetime.bit.minute, rdetime.bit.second << 1);
219+ }
220+ }
221+
222+ return 0;
223+}
224+
225+uint Console_Command_pci(UI_Console *console)
226+{
227+ uchar *p;
228+ uint bus, device, function;
229+ uint data;
230+
231+ TextBox_Put_String(console->textbox, "-<pci information>-");
232+ if(CFunction_String_GetWord(console->textbox->text_buf, &p, 1)){
233+ if(CFunction_String_GetWord(console->textbox->text_buf, &p, 3)){
234+ function = strtol(p, Null, 0);
235+ CFunction_String_GetWord(console->textbox->text_buf, &p, 2);
236+ device = strtol(p, Null, 0);
237+ CFunction_String_GetWord(console->textbox->text_buf, &p, 1);
238+ bus = strtol(p, Null, 0);
239+ Console_printf(console, "\nBus%3d.Device%2d.Function%2d:\n", bus, device, function);
240+ if(bus < 256 && device < 32 && function < 8){
241+ PCI_ConfigurationRegister_SelectDevice(bus, device, function);
242+ data = PCI_ConfigurationRegister_Read32(0x00);
243+ if(data == 0xffffffff){
244+ TextBox_Put_String(console->textbox, "Device not exist.\n");
245+ } else{
246+ Console_printf(console, "DeviceVendor:%s(0x%04X)\n", PCI_GetDeviceVendor(data & 0xffff), data & 0xffff);
247+ Console_printf(console, "DeviceID :0x%04X\n", data >> 16);
248+
249+ data = PCI_ConfigurationRegister_Read32(0x08);
250+ data = CFunction_ExtractBits(data, 8, 31);
251+ Console_printf(console, "ClassCode :%s(0x%06X)\n", PCI_GetDeviceClass(data), data);
252+
253+ data = PCI_ConfigurationRegister_Read32(0x0c);
254+ data = CFunction_ExtractBits(data, 16, 22);
255+ Console_printf(console, "DeviceType :%s(%d)\n", PCI_GetDeviceType(data), data);
256+ }
257+ } else{
258+ TextBox_Put_String(console->textbox, "Invalid Device.\n");
259+ }
260+
261+
262+ }
263+ } else{
264+ TextBox_Put_String(console->textbox, "Usage:\n");
265+ TextBox_Put_String(console->textbox, "pci <bus> <device> <function>\n\nDevices which exist:\n");
266+ for(bus = 0; bus < 256; bus++){
267+ for(device = 0; device < 32; device++){
268+ for(function = 0; function < 8; function++){
269+ PCI_ConfigurationRegister_SelectDevice(bus, device, function);
270+ data = PCI_ConfigurationRegister_Read32(0x00);
271+ if(data != 0xffffffff){
272+ Console_printf(console, "Bus%3d.Device%2d.Function%2d\n", bus, device, function);
273+ }
274+ }
275+ }
276+ }
277+ }
278+ return 0;
279+}
280+
--- beta/tolset_chn_000/chnos_010/chnos/draw08.c (revision 326)
+++ beta/tolset_chn_000/chnos_010/chnos/draw08.c (revision 327)
@@ -107,6 +107,10 @@
107107 return;
108108 }
109109
110+ if(s == Null){
111+ return;
112+ }
113+
110114 c = RGB_32_To_08(c);
111115 for(; *s != 0x00; s++){
112116 if(x > xsize - 8){
--- beta/tolset_chn_000/chnos_010/chnos/sheet.c (revision 326)
+++ beta/tolset_chn_000/chnos_010/chnos/sheet.c (revision 327)
@@ -184,8 +184,6 @@
184184
185185 uint Sheet_Show(UI_Sheet *sheet, uint height, int px, int py)
186186 {
187- UI_Sheet **search;
188- uint i;
189187 uint retv;
190188
191189 if(sheet == Null){
@@ -204,13 +202,6 @@
204202 #ifdef CHNOSPROJECT_DEBUG_SHEET
205203 debug("Sheet_Show:Null parent.\n");
206204 #endif
207- sheet->flags.bit.visible = True;
208- if(px != SHEET_LOCATION_NOCHANGE){
209- sheet->location.x = px;
210- }
211- if(py != SHEET_LOCATION_NOCHANGE){
212- sheet->location.y = py;
213- }
214205 return 3;
215206 }
216207 if(sheet->flags.bit.visible == True){
@@ -223,62 +214,8 @@
223214 return 10 + retv;
224215 }
225216
226-//At First, clear old height link.
217+ Sheet_Internal_ChangeHeight(sheet, height);
227218
228- search = &sheet->parent->child;
229- for(i = 0; i < SHEET_MAX_CHILDREN; i++){
230- if(*search == sheet){
231- *search = sheet->next;
232- break;
233- }
234- search = &(*search)->next;
235- }
236-
237-//Next, set new height link.
238- if(!sheet->flags.bit.topmost){
239- search = &sheet->parent->child;
240- for(i = 0; i < SHEET_MAX_CHILDREN; i++){
241- if(i == height){
242- #ifdef CHNOSPROJECT_DEBUG_SHEET
243- debug("Sheet_Show:Search:Break(height).\n");
244- #endif
245- break;
246- }
247- if(*search == Null){
248- #ifdef CHNOSPROJECT_DEBUG_SHEET
249- debug("Sheet_Show:Search:Break(End of link).\n");
250- #endif
251- break;
252- }
253- if((*search)->flags.bit.topmost){
254- #ifdef CHNOSPROJECT_DEBUG_SHEET
255- debug("Sheet_Show:Search:Break(Under topmost sheet).\n");
256- #endif
257- break;
258- }
259- search = &(*search)->next;
260- }
261- } else{ /*topmost sheet. ignore height.*/
262- search = &sheet->parent->child;
263- for(i = 0; i < SHEET_MAX_CHILDREN; i++){
264- if(*search == Null){
265- #ifdef CHNOSPROJECT_DEBUG_SHEET
266- debug("Sheet_Show:Search:Break(Top most).\n");
267- #endif
268- break;
269- }
270- search = &(*search)->next;
271- }
272- }
273- if(i == SHEET_MAX_CHILDREN){
274- #ifdef CHNOSPROJECT_DEBUG_SHEET
275- debug("Sheet_Show:Number of sheets is over SHEET_MAX_CHILDREN.\n");
276- #endif
277- return 3;
278- }
279- sheet->next = *search;
280- *search = sheet;
281-
282219 if(px != SHEET_LOCATION_NOCHANGE){
283220 sheet->location.x = px;
284221 }
@@ -302,6 +239,33 @@
302239 return 0;
303240 }
304241
242+uint Sheet_ChangeHeight(UI_Sheet *sheet, uint height)
243+{
244+ if(sheet == Null){
245+ #ifdef CHNOSPROJECT_DEBUG_SHEET
246+ debug("Sheet_ChangeHeight:Null sheet.\n");
247+ #endif
248+ return 1;
249+ }
250+ if(!sheet->flags.bit.buffer_configured){
251+ #ifdef CHNOSPROJECT_DEBUG_SHEET
252+ debug("Sheet_ChangeHeight:Not buffer_configured sheet.\n");
253+ #endif
254+ return 2;
255+ }
256+ if(sheet->parent == Null){
257+ #ifdef CHNOSPROJECT_DEBUG_SHEET
258+ debug("Sheet_ChangeHeight:Null parent.\n");
259+ #endif
260+ return 3;
261+ }
262+
263+ Sheet_Internal_ChangeHeight(sheet, height);
264+ Sheet_RefreshAllInRange(sheet->parent, sheet->location.x, sheet->location.y, sheet->location.x + (int)sheet->size.x - 1, sheet->location.y + (int)sheet->size.y - 1);
265+
266+ return 0;
267+}
268+
305269 uint Sheet_RefreshSheet_All(UI_Sheet *sheet)
306270 {
307271 #ifdef CHNOSPROJECT_DEBUG_CALLLINK
--- beta/tolset_chn_000/chnos_010/chnos/floppy.c (nonexistent)
+++ beta/tolset_chn_000/chnos_010/chnos/floppy.c (revision 327)
@@ -0,0 +1,19 @@
1+
2+#include "core.h"
3+
4+IO_FloppyDisk *FloppyDisk_Initialize(void *img)
5+{
6+ IO_FloppyDisk *fd;
7+
8+ fd = (IO_FloppyDisk *)System_CommonStruct_Allocate(SYSTEM_STRUCTID_FLOPPYDISK);
9+
10+ fd->img = img;
11+ fd->files = (IO_FloppyDisk_RootDirectoryEntry *)(fd->img + FLOPPYDISK_RDE_OFFSET);
12+ fd->userdataarea = (sector *)(fd->img + FLOPPYDISK_RDE_OFFSET + sizeof(IO_FloppyDisk_RootDirectoryEntry) * FLOPPYDISK_RDE_ENTRIES);
13+
14+// fd->fat = MemoryBlock_Allocate_System(2 * 2880);
15+// MemoryBlock_Write_Description(fd->fat, "IO_FD_FAT");
16+// FloppyDisk_Decode_FAT16(fd->img, fd->fat, false);
17+
18+ return fd;
19+}
--- beta/tolset_chn_000/chnos_010/chnos/shtfunc.c (revision 326)
+++ beta/tolset_chn_000/chnos_010/chnos/shtfunc.c (revision 327)
@@ -636,6 +636,69 @@
636636 return 0;
637637 }
638638
639+uint Sheet_Internal_ChangeHeight(UI_Sheet *sheet, uint height)
640+{
641+ UI_Sheet **search;
642+ uint i;
643+
644+//At First, clear old height link.
645+ search = &sheet->parent->child;
646+ for(i = 0; i < SHEET_MAX_CHILDREN; i++){
647+ if(*search == sheet){
648+ *search = sheet->next;
649+ break;
650+ }
651+ search = &(*search)->next;
652+ }
653+
654+//Next, set new height link.
655+ if(!sheet->flags.bit.topmost){
656+ search = &sheet->parent->child;
657+ for(i = 0; i < SHEET_MAX_CHILDREN; i++){
658+ if(i == height){
659+ #ifdef CHNOSPROJECT_DEBUG_SHEET
660+ debug("Sheet_Internal_ChangeHeight:Search:Break(height).\n");
661+ #endif
662+ break;
663+ }
664+ if(*search == Null){
665+ #ifdef CHNOSPROJECT_DEBUG_SHEET
666+ debug("Sheet_Internal_ChangeHeight:Search:Break(End of link).\n");
667+ #endif
668+ break;
669+ }
670+ if((*search)->flags.bit.topmost){
671+ #ifdef CHNOSPROJECT_DEBUG_SHEET
672+ debug("Sheet_Internal_ChangeHeight:Search:Break(Under topmost sheet).\n");
673+ #endif
674+ break;
675+ }
676+ search = &(*search)->next;
677+ }
678+ } else{ /*topmost sheet. ignore height.*/
679+ search = &sheet->parent->child;
680+ for(i = 0; i < SHEET_MAX_CHILDREN; i++){
681+ if(*search == Null){
682+ #ifdef CHNOSPROJECT_DEBUG_SHEET
683+ debug("Sheet_Internal_ChangeHeight:Search:Break(Top most).\n");
684+ #endif
685+ break;
686+ }
687+ search = &(*search)->next;
688+ }
689+ }
690+ if(i == SHEET_MAX_CHILDREN){
691+ #ifdef CHNOSPROJECT_DEBUG_SHEET
692+ debug("Sheet_Internal_ChangeHeight:Number of sheets is over SHEET_MAX_CHILDREN.\n");
693+ #endif
694+ return 3;
695+ }
696+ sheet->next = *search;
697+ *search = sheet;
698+
699+ return 0;
700+}
701+
639702 //SheetXX_Internal_IsVisiblePixel(UI_Sheet *sheet, int px, int py)
640703 //親シート内座標における、指定されたシートのピクセル(px, py)が可視状態であるかどうかを返す。
641704 //引数チェックはすべて省略しているので、呼び出し元で厳密にチェックする必要がある。
--- beta/tolset_chn_000/chnos_010/chnos/makeset.txt (revision 326)
+++ beta/tolset_chn_000/chnos_010/chnos/makeset.txt (revision 327)
@@ -1,3 +1,3 @@
11
2-OBJS_BOOTPACK = nasfunc0.obj nasfunc1.obj nasfunc2.obj hankaku.obj chnlogo.obj callbios.obj cfunc.obj color.obj console.obj debug.obj display.obj draw08.obj draw16.obj draw32.obj drawing.obj dsctbl.obj emu86.obj emu86asm.obj error.obj fifo.obj fmt_bmp.obj intrpt.obj keyboard.obj memory.obj mouse.obj mtask.obj pci.obj serial.obj sheet.obj sht08.obj sht16.obj sht32.obj shtdraw.obj shtfunc.obj struct.obj system.obj textbox.obj timer.obj vgatmode.obj xception.obj bootpack.obj
2+OBJS_BOOTPACK = nasfunc0.obj nasfunc1.obj nasfunc2.obj hankaku.obj chnlogo.obj callbios.obj cfunc.obj color.obj console.obj debug.obj display.obj draw08.obj draw16.obj draw32.obj drawing.obj dsctbl.obj emu86.obj emu86asm.obj error.obj fifo.obj floppy.obj fmt_bmp.obj intrpt.obj keyboard.obj memory.obj mouse.obj mtask.obj pci.obj serial.obj sheet.obj sht08.obj sht16.obj sht32.obj shtdraw.obj shtfunc.obj struct.obj system.obj textbox.obj timer.obj vgatmode.obj xception.obj bootpack.obj
33 HEADS_BOOTPACK = core.h coredef0.h coredef1.h coredef2.h coredef3.h keyid.h
--- beta/tolset_chn_000/chnos_010/chnos/core.h (revision 326)
+++ beta/tolset_chn_000/chnos_010/chnos/core.h (revision 327)
@@ -25,8 +25,11 @@
2525 void srand(uint seed);
2626 uint rand(void);
2727 uint isqrt(uint n);
28+uint strtol(const uchar s[], uchar *endptr[], uint base);
2829 bool CFunction_CompareStrings(const uchar s1[], const uchar s2[]);
30+bool CFunction_CompareStrings_n(const uchar s1[], const uchar s2[], unsigned int n);
2931 uint CFunction_ExtractBits(uint source, uint start, uint end);
32+bool CFunction_String_GetWord(const uchar s[], uchar *wordptr[], uint n);
3033 uint CFunction_MemoryMove(void *destination, uint destination_size, void *source, uint source_size);
3134 int snprintf(uchar s[], uint n, const uchar format[], ...);
3235 int vsnprintf(uchar s[], uint n, const uchar format[], uint vargs[]);
@@ -57,9 +60,12 @@
5760 UI_Console *Console_Initialize(void);
5861 uint Console_SetSize(UI_Console *console, uint xchars, uint ychars);
5962 uint Console_Run(UI_Console *console);
60-void Console_MainTask(UI_Console *myconsole);
61-bool Console_CompareCommandline_s(UI_Console *myconsole, const uchar s[]);
62-uint Console_printf(UI_Console *myconsole, const uchar format[], ...);
63+void Console_MainTask(UI_Console *console);
64+bool Console_CompareCommandline_s(UI_Console *console, const uchar s[]);
65+bool Console_CompareCommandline_n(UI_Console *console, const uchar s[], unsigned int n);
66+uint Console_printf(UI_Console *console, const uchar format[], ...);
67+uint Console_Command_dir(UI_Console *console);
68+uint Console_Command_pci(UI_Console *console);
6369
6470 /*debug.c デバッグ支援*/
6571 #ifdef CHNOSPROJECT_DEBUG
@@ -195,6 +201,9 @@
195201 uint FIFO32_MyTaskFIFO_Status(void);
196202 uint FIFO32_MyTaskFIFO_Get(void);
197203
204+/*floppy.c フロッピーディスク関連*/
205+IO_FloppyDisk *FloppyDisk_Initialize(void *img);
206+
198207 /*fmt_bmp.c ビットマップ描画関連*/
199208 uint Format_BMP_DrawPicture(void *vram, uint xsize, uint x, uint y, uint pxsize, uint pysize, void *bmp);
200209
@@ -248,6 +257,11 @@
248257
249258 /*pci.c PCI関連*/
250259 void Initialize_PCI(void);
260+void PCI_ConfigurationRegister_SelectDevice(uint bus, uint device, uint function);
261+uint PCI_ConfigurationRegister_Read32(uint addr);
262+uchar *PCI_GetDeviceVendor(uint id);
263+uchar *PCI_GetDeviceClass(uint id);
264+uchar *PCI_GetDeviceType(uint id);
251265
252266 /*serial.c シリアル通信関連*/
253267 void Initialize_SerialPort(void);
@@ -259,6 +273,7 @@
259273 uint Sheet_SetBuffer(UI_Sheet *sheet, void *vram, uint xsize, uint ysize, uint bpp);
260274 uint Sheet_SetParent(UI_Sheet *sheet, UI_Sheet *parent);
261275 uint Sheet_Show(UI_Sheet *sheet, uint height, int px, int py);
276+uint Sheet_ChangeHeight(UI_Sheet *sheet, uint height);
262277 uint Sheet_RefreshSheet_All(UI_Sheet *sheet);
263278 uint Sheet_Slide_Absolute(UI_Sheet *sheet, int apx, int apy);
264279 uint Sheet_Slide_Relative(UI_Sheet *sheet, int rpx, int rpy);
@@ -333,6 +348,7 @@
333348 uint Sheet_Internal_MapRefresh(UI_Sheet *sheet, int px0, int py0, int px1, int py1);
334349 uint Sheet_Internal_RefreshSheet(UI_Sheet *sheet, int px0, int py0, int px1, int py1);
335350 uint Sheet_Internal_SlideSub(UI_Sheet *sheet, int rpx, int rpy);
351+uint Sheet_Internal_ChangeHeight(UI_Sheet *sheet, uint height);
336352 bool Sheet_Internal_IsVisiblePixel_Invalid(UI_Sheet *sheet, int px, int py);
337353 uint Sheet_Internal_RefreshSheet_Invalid(struct UI_SHEET *sheet, int px0, int py0, int px1, int py1);
338354
--- beta/tolset_chn_000/chnos_010/chnos/cfunc.c (revision 326)
+++ beta/tolset_chn_000/chnos_010/chnos/cfunc.c (revision 327)
@@ -120,6 +120,70 @@
120120 return x;
121121 }
122122
123+//文字列から数値を生成します。
124+//base=0:C言語の定数表記ルールに従う。("0x..."=16, "0..."=8, else=10)
125+//base=2-36(数字10+アルファベット26):各数字を基数として文字列を理解しようとする。
126+//アルファベットの大文字・小文字は問わない。
127+//endptr=NULLも可。有効な数字が一つもなければ、*endptr=s, retv=0となる。
128+//出力のオーバーフローについては考慮しないので注意。
129+//現状では負数は扱えない(マイナス記号は変換不能とされる)
130+//sの例:"0xFEC375"(16), "0423"(8), "12345"(10)
131+//文字列全体の前には空白があっても無視される。数字部分開始後は空白は変換不能とされる。
132+//*endptr[0]==0x00のとき、文字列sのすべてが変換されたことを示す。
133+uint strtol(const uchar s[], uchar *endptr[], uint base)
134+{
135+ uint i, v;
136+
137+ v = 0;
138+
139+ if(s == Null || base > 36 || base == 1){
140+ if(endptr != Null){
141+ *endptr = Null;
142+ }
143+ return 0;
144+ }
145+
146+//空白を読み飛ばす
147+ for(i = 0; s[i] != 0x00; i++){
148+ if(s[i] != ' '){
149+ break;
150+ }
151+ }
152+//base=0の時の基数決定
153+ if(base == 0){
154+ if(s[i] == '0'){
155+ i++;
156+ if(s[i] == 'x'){
157+ base = 16;
158+ i++;
159+ } else{
160+ base = 8;
161+ }
162+ } else{
163+ base = 10;
164+ }
165+ }
166+//数値変換
167+ for(; s[i] != 0x00; i++){
168+ if('0' <= s[i] <= '9' && s[i] - '0' < base){
169+ v *= base;
170+ v += s[i] - '0';
171+ } else if('A' <= s[i] <= 'Z' && s[i] - 'A' + 10 < base){
172+ v *= base;
173+ v += s[i] - 'A' + 10;
174+ } else if('a' <= s[i] <= 'z' && s[i] - 'a' + 10 < base){
175+ v *= base;
176+ v += s[i] - 'a' + 10;
177+ } else{
178+ break;
179+ }
180+ }
181+ if(endptr != Null){
182+ *endptr = (uchar *)&s[i];
183+ }
184+ return v;
185+}
186+
123187 bool CFunction_CompareStrings(const uchar s1[], const uchar s2[])
124188 {
125189 uint i;
@@ -132,11 +196,72 @@
132196 return False;
133197 }
134198
199+bool CFunction_CompareStrings_n(const uchar s1[], const uchar s2[], unsigned int n)
200+{
201+ uint i;
202+
203+ for(i = 0; i < n; i++){
204+ if(s1[i] != s2[i]){
205+ return False;
206+ }
207+ if(s1[i] == 0x00){
208+ return True;
209+ }
210+ }
211+ return True;
212+}
213+
135214 uint CFunction_ExtractBits(uint source, uint start, uint end)
136215 {
137216 return (source >> start) & ~(0xffffffff << (end - start + 1));
138217 }
139218
219+//文字列内のn番目の単語(スペース区切りによる)の先頭アドレスを取得する。
220+//戻り値は、n番目の単語が存在するかどうかを返す。
221+//存在しなかった場合の*wordptrはsの末端を返す。
222+//wordptrはNull許容。
223+bool CFunction_String_GetWord(const uchar s[], uchar *wordptr[], uint n)
224+{
225+ uint i, count;
226+
227+ if(s == Null){
228+ if(wordptr != Null){
229+ *wordptr = Null;
230+ }
231+ return False;
232+ }
233+
234+ if(n == 0){
235+ if(wordptr != Null){
236+ *wordptr = (uchar *)s;
237+ }
238+ return True;
239+ }
240+
241+ count = 0;
242+ for(i = 0; s[i] != 0x00; i++){
243+ if(s[i] == ' '){
244+ count++;
245+ for(; s[i] != 0x00; i++){
246+ if(s[i] != ' '){
247+ break;
248+ }
249+ }
250+ if(s[i] != 0x00 && count == n){
251+ if(wordptr != Null){
252+ *wordptr = (uchar *)&s[i];
253+ }
254+ return True;
255+ }
256+ }
257+ }
258+
259+ if(wordptr != Null){
260+ *wordptr = (uchar *)&s[i];
261+ }
262+ return False;
263+}
264+
140265 //source番地からの、destination_sizeを超えないsource_sizeバイトを、destination番地へ移動させる。
141266 //メモリ範囲が重なっていてもデータは破壊されない。
142267 //同一番地へコピーする場合は何もしない。
@@ -258,6 +383,11 @@
258383 work.format_phase = 0;
259384 } else if(c == 'o'){ /*データを8進数で出力します。*/
260385 } else if(c == 'd'){ /*データを10進数で出力します。*/
386+ /*標準精度は一桁以上、ゼロフィルです。*/
387+ if(fill_length == 0xffffffff){
388+ fill_length = 1;
389+ flag_fill_zero = True;
390+ }
261391 i = CFunction_vsnprintf_Get_NextArgument(&work);
262392 if((i & 0x80000000) != 0){
263393 i--;
@@ -265,12 +395,26 @@
265395 CFunction_vsnprintf_Write_DestinationBuffer(&work, '-');
266396 }
267397 CFunction_vsnprintf_To_String_From_Decimal_Unsigned(&work, i);
398+
268399 for(i = 0; i < 10; i++){
269400 if(work.temporary_data[i] != ' '){
270401 break;
271402 }
272- if(i >= 10 - 1){
273- CFunction_vsnprintf_Write_DestinationBuffer(&work, '0');
403+ }
404+ if(i == 10){
405+ i--;
406+ work.temporary_data[10 - 1] = '0';
407+ }
408+
409+ if((10 - i) < fill_length && fill_length != 0xffffffff){
410+ if(flag_fill_zero){
411+ for(j = 0; j < (fill_length - (10 - i)); j++){
412+ CFunction_vsnprintf_Write_DestinationBuffer(&work, '0');
413+ }
414+ } else{
415+ for(j = 0; j < (fill_length - (10 - i)); j++){
416+ CFunction_vsnprintf_Write_DestinationBuffer(&work, ' ');
417+ }
274418 }
275419 }
276420 for(; i < 10; i++){
--- beta/tolset_chn_000/chnos_010/chnos/draw32.c (revision 326)
+++ beta/tolset_chn_000/chnos_010/chnos/draw32.c (revision 327)
@@ -51,6 +51,10 @@
5151 return;
5252 }
5353
54+ if(s == Null){
55+ return;
56+ }
57+
5458 for(; *s != 0x00; s++){
5559 if(x > xsize - 8){
5660 break;
--- beta/tolset_chn_000/chnos_010/chnos/bootpack.c (revision 326)
+++ beta/tolset_chn_000/chnos_010/chnos/bootpack.c (revision 327)
@@ -173,6 +173,7 @@
173173 console = Console_Initialize();
174174 Console_SetSize(console, vramsheet->size.x >> 4, vramsheet->size.y >> 5);
175175 Console_Run(console);
176+ System_InputFocus_Change(console->textbox->sheet->input_fifo);
176177
177178 for(;;){
178179 if(FIFO32_MyTaskFIFO_Status() == 0){
@@ -339,8 +340,12 @@
339340 moveorg_mfocus.y = mcursor->cursor_sheet->location.y;
340341 mfocus = Sheet_GetSheetFromLocation(mcursor->cursor_sheet->parent, mcursor->cursor_sheet->location.x, mcursor->cursor_sheet->location.y);
341342 System_InputFocus_Change(mfocus->input_fifo);
342- if(mfocus != Null && mfocus->flags.bit.movable == False){
343- mfocus = Null;
343+ if(mfocus != Null){
344+ if(mfocus->flags.bit.movable){
345+ Sheet_ChangeHeight(mfocus, SHEET_MAX_CHILDREN);
346+ } else{
347+ mfocus = Null;
348+ }
344349 }
345350 }
346351 old_mouse_buttonL = mctrl->button.bit.L;
--- beta/tolset_chn_000/chnos_010/chnos/draw16.c (revision 326)
+++ beta/tolset_chn_000/chnos_010/chnos/draw16.c (revision 327)
@@ -52,6 +52,10 @@
5252 return;
5353 }
5454
55+ if(s == Null){
56+ return;
57+ }
58+
5559 c = RGB_32_To_16(c);
5660 for(; *s != 0x00; s++){
5761 if(x > xsize - 8){
--- beta/tolset_chn_000/chnos_010/chnos/structid.h (revision 326)
+++ beta/tolset_chn_000/chnos_010/chnos/structid.h (revision 327)
@@ -4,3 +4,4 @@
44 #define SYSTEM_STRUCTID_FIFO32 2
55 #define SYSTEM_STRUCTID_TEXTBOX 3
66 #define SYSTEM_STRUCTID_CONSOLE 4
7+#define SYSTEM_STRUCTID_FLOPPYDISK 5
--- beta/tolset_chn_000/chnos_010/chnos/pci.c (revision 326)
+++ beta/tolset_chn_000/chnos_010/chnos/pci.c (revision 327)
@@ -97,12 +97,6 @@
9797 {3, "[Undefined]"},
9898 };
9999
100-void PCI_ConfigurationRegister_SelectDevice(uint bus, uint device, uint function);
101-uint PCI_ConfigurationRegister_Read32(uint addr);
102-uchar *PCI_GetDeviceVendor(uint id);
103-uchar *PCI_GetDeviceClass(uint id);
104-uchar *PCI_GetDeviceType(uint id);
105-
106100 void Initialize_PCI(void)
107101 {
108102 #ifdef CHNOSPROJECT_DEBUG_PCI
--- beta/tolset_chn_000/chnos_010/chnos/struct.c (revision 326)
+++ beta/tolset_chn_000/chnos_010/chnos/struct.c (revision 327)
@@ -22,6 +22,9 @@
2222 case SYSTEM_STRUCTID_CONSOLE:
2323 strsize = sizeof(UI_Console);
2424 break;
25+ case SYSTEM_STRUCTID_FLOPPYDISK:
26+ strsize = sizeof(IO_FloppyDisk);
27+ break;
2528 default:
2629 #ifdef CHNOSPROJECT_DEBUG_COMMON_STRUCT
2730 debug("System_CommonStruct_Allocate:Unknown Struct.\n");
@@ -43,6 +46,7 @@
4346 case SYSTEM_STRUCTID_FIFO32:
4447 case SYSTEM_STRUCTID_TEXTBOX:
4548 case SYSTEM_STRUCTID_CONSOLE:
49+ case SYSTEM_STRUCTID_FLOPPYDISK:
4650 break;
4751 default:
4852 #ifdef CHNOSPROJECT_DEBUG_COMMON_STRUCT
--- beta/tolset_chn_000/chnos_010/chnos/coredef0.h (revision 326)
+++ beta/tolset_chn_000/chnos_010/chnos/coredef0.h (revision 327)
@@ -272,6 +272,9 @@
272272 #define DISPLAYMODE_VBE_LINEAR 0x0002
273273
274274 /*settings*/
275+/*IPL defines*/
276+#define ADR_DISKIMG (void *)0x00100000
277+
275278 /*system segments*/
276279 #define SYSTEM_DS 0x01
277280 #define SYSTEM_CS 0x02
@@ -358,3 +361,8 @@
358361 /*console*/
359362 #define CONSOLE_PRINTF_BUFFER_SIZE 1024
360363
364+/*floppy*/
365+#define FLOPPYDISK_RDE_OFFSET 0x002600
366+#define FLOPPYDISK_RDE_ENTRIES 224
367+
368+
--- beta/tolset_chn_000/chnos_010/chnos/coredef1.h (revision 326)
+++ beta/tolset_chn_000/chnos_010/chnos/coredef1.h (revision 327)
@@ -8,6 +8,7 @@
88 typedef unsigned short ushort;
99 typedef unsigned int uint;
1010 typedef enum _col_text { black, blue, green, skyblue, red, purple, brown, white} col_text;
11+typedef unsigned char sector[512];
1112
1213 /*structs*/
1314 /*CPU structs*/
@@ -586,6 +587,67 @@
586587 } flags;
587588 } UI_TextBox;
588589
590+typedef struct IO_FLOPPYDISK_RDE {
591+ uchar name[8]; //0x00:empty(no more files)
592+ //0x05:=0xe5
593+ //0x2e:(only directory)
594+ //. 0x2e:current directory
595+ //.. 0x2e, 0x2e:parent directory
596+ //0xe5:deleted(usable)
597+ uchar ext[3];
598+ uchar attribute; //0x0f=LongFileNameEntry
599+ uchar reserved;
600+ uchar VFAT_createTimeMs;
601+ ushort VFAT_createTime;
602+ ushort VFAT_createDate;
603+ ushort VFAT_accessDate;
604+ ushort VFAT_clusterHighWord;
605+ ushort updatetime;
606+ ushort updatedate;
607+ ushort cluster;
608+ uint size; //attribute.bit.directory==true:0
609+} IO_FloppyDisk_RootDirectoryEntry;
610+
611+typedef struct IO_FLOPPYDISK {
612+ System_CommonStruct common_tag;
613+ uchar *img;
614+ IO_FloppyDisk_RootDirectoryEntry *files;
615+ sector *userdataarea;
616+ void *fat;
617+} IO_FloppyDisk;
618+
619+typedef union IO_FLOPPYDISK_RDE_ATTRIBUTE {
620+ uchar attribute; //0x0f=LongFileNameEntry
621+ struct IO_FLOPPYDISK_RDE_ATTRIBUTE_BITS {
622+ unsigned readonly : 1;
623+ unsigned hidden : 1;
624+ unsigned system : 1;
625+ unsigned volumelabel : 1;
626+ unsigned directory : 1;
627+ unsigned archive : 1;
628+ unsigned bit6 : 1;
629+ unsigned bit7 : 1;
630+ } bit;
631+} IO_FloppyDisk_RDE_Attribute;
632+
633+typedef union IO_FLOPPYDISK_RDE_UPDATETIME {
634+ ushort updatetime;
635+ struct IO_FLOPPYDISK_RDE_UPDATETIME_BITS {
636+ unsigned second : 5; //second/2
637+ unsigned minute : 6;
638+ unsigned hour : 5;
639+ } bit;
640+} IO_FloppyDisk_RDE_UpdateTime;
641+
642+typedef union IO_FLOPPYDISK_RDE_UPDATEDATE {
643+ ushort updatedate;
644+ struct IO_FLOPPYDISK_RDE_UPDATEDATE_BITS {
645+ unsigned day : 5; //day(1-31)
646+ unsigned month : 4; //month(1-12)
647+ unsigned year : 7; //year(from 1980)
648+ } bit;
649+} IO_FloppyDisk_RDE_UpdateDate;
650+
589651 typedef struct UI_CONSOLE {
590652 UI_TextBox *textbox;
591653 UI_Task *task;
@@ -598,6 +660,7 @@
598660 unsigned isprompt : 1;
599661 } bit;
600662 } flags;
663+ IO_FloppyDisk *boot_fd;
601664 } UI_Console;
602665
603666
旧リポジトリブラウザで表示