OSDN Git Service

4af4ad652ef301478483c3cf4551ce5b7305f71d
[chnosproject/CHNOSProject.git] / CHNOSProject / chnos / tolset_chn_000 / chnos_010 / chnos / coredef1.h
1 \r
2 /*\83V\83X\83e\83\80\83f\81[\83^\8c^\90é\8c¾*/\r
3 \r
4 /*new object types*/\r
5 //typedef enum _bool { false, true} bool;\r
6 typedef unsigned char bool;\r
7 typedef unsigned char uchar;\r
8 typedef unsigned short ushort;\r
9 typedef unsigned int uint;\r
10 typedef enum _col_text { black, blue, green, skyblue, red, purple, brown, white} col_text;\r
11 typedef unsigned char sector[512];\r
12 \r
13 /*structs*/\r
14 /*CPU structs*/\r
15 typedef union CPU_CONTROL_REGISTER0 {\r
16         uint cr0;\r
17         struct CPU_CONTROL_REGISTER0_BIT {\r
18                 unsigned PE : 1;\r
19                 unsigned MP : 1;\r
20                 unsigned EM : 1;\r
21                 unsigned TS : 1;\r
22                 unsigned ET : 1;\r
23                 unsigned NE : 1;\r
24                 unsigned bit6 : 1;\r
25                 unsigned bit7 : 1;\r
26                 unsigned bit8 : 1;\r
27                 unsigned bit9 : 1;\r
28                 unsigned bit10 : 1;\r
29                 unsigned bit11 : 1;\r
30                 unsigned bit12 : 1;\r
31                 unsigned bit13 : 1;\r
32                 unsigned bit14 : 1;\r
33                 unsigned bit15 : 1;\r
34                 unsigned WP : 1;\r
35                 unsigned bit17 : 1;\r
36                 unsigned AM : 1;\r
37                 unsigned bit19 : 1;\r
38                 unsigned bit20 : 1;\r
39                 unsigned bit21 : 1;\r
40                 unsigned bit22 : 1;\r
41                 unsigned bit23 : 1;\r
42                 unsigned bit24 : 1;\r
43                 unsigned bit25 : 1;\r
44                 unsigned bit26 : 1;\r
45                 unsigned bit27 : 1;\r
46                 unsigned bit28 : 1;\r
47                 unsigned NW : 1;\r
48                 unsigned CD : 1;\r
49                 unsigned PG : 1;\r
50         } bit;\r
51 } CPU_ControlRegister0;\r
52 \r
53 typedef union CPU_CONTROL_REGISTER3 {\r
54         uint cr3;\r
55         struct CPU_CONTROL_REGISTER3_BIT {\r
56                 unsigned bit0 : 1;\r
57                 unsigned bit1 : 1;\r
58                 unsigned bit2 : 1;\r
59                 unsigned PWT : 1;\r
60                 unsigned PCD : 1;\r
61                 unsigned bit5 : 1;\r
62                 unsigned bit6 : 1;\r
63                 unsigned bit7 : 1;\r
64                 unsigned bit8 : 1;\r
65                 unsigned bit9 : 1;\r
66                 unsigned bit10 : 1;\r
67                 unsigned bit11 : 1;\r
68                 unsigned PDB : 20;\r
69         } bit;\r
70 } CPU_ControlRegister3;\r
71 \r
72 typedef union CPU_CONTROL_REGISTER4 {\r
73         uint cr4;\r
74         struct CPU_CONTROL_REGISTER4_BIT {\r
75                 unsigned VME : 1;\r
76                 unsigned PVI : 1;\r
77                 unsigned TSD : 1;\r
78                 unsigned DE : 1;\r
79                 unsigned PSE : 1;\r
80                 unsigned PAE : 1;\r
81                 unsigned MCE : 1;\r
82                 unsigned PGE : 1;\r
83                 unsigned PCE : 1;\r
84                 unsigned OSFXSR : 1;\r
85                 unsigned OSXMMEXCPT : 1;\r
86                 unsigned bit11 : 1;\r
87                 unsigned bit12 : 1;\r
88                 unsigned VMXE : 1;\r
89                 unsigned SMXE : 1;\r
90                 unsigned bit15 : 1;\r
91                 unsigned bit16 : 1;\r
92                 unsigned PCIDE : 1;\r
93                 unsigned OSXSAVE : 1;\r
94                 unsigned bit19 : 1;\r
95                 unsigned SMEP : 1;\r
96                 unsigned bit21 : 1;\r
97                 unsigned bit22 : 1;\r
98                 unsigned bit23 : 1;\r
99                 unsigned bit24 : 1;\r
100                 unsigned bit25 : 1;\r
101                 unsigned bit26 : 1;\r
102                 unsigned bit27 : 1;\r
103                 unsigned bit28 : 1;\r
104                 unsigned bit29 : 1;\r
105                 unsigned bit30 : 1;\r
106                 unsigned bit31 : 1;\r
107         } bit;\r
108 } CPU_ControlRegister4;\r
109 \r
110 typedef union CPU_DEBUG_REGISTER6 {\r
111         uint dr6;\r
112         struct CPU_DEBUG_REGISTER6_BIT {\r
113                 unsigned B0 : 1;\r
114                 unsigned B1 : 1;\r
115                 unsigned B2 : 1;\r
116                 unsigned B3 : 1;\r
117                 unsigned bit4_11 : 8;   //1\r
118                 unsigned bit12 : 1;     //0\r
119                 unsigned BD : 1;\r
120                 unsigned BS : 1;\r
121                 unsigned BT : 1;\r
122                 unsigned bit16_31 : 16;\r
123         } bit;\r
124 } CPU_DebugRegister6;\r
125 \r
126 typedef union CPU_DEBUG_REGISTER7 {\r
127         uint dr7;\r
128         struct CPU_DEBUG_REGISTER7_BIT {\r
129                 unsigned L0 : 1;\r
130                 unsigned G0 : 1;\r
131                 unsigned L1 : 1;\r
132                 unsigned G1 : 1;\r
133                 unsigned L2 : 1;\r
134                 unsigned G2 : 1;\r
135                 unsigned L3 : 1;\r
136                 unsigned G3 : 1;\r
137                 unsigned LE : 1;        //must be 1\r
138                 unsigned GE : 1;        //must be 1\r
139                 unsigned bit10 : 1;     //1\r
140                 unsigned bit11 : 1;     //0\r
141                 unsigned bit12 : 1;     //0\r
142                 unsigned GD : 1;\r
143                 unsigned bit14 : 1;     //0\r
144                 unsigned bit15 : 1;     //0\r
145                 unsigned RW0 : 2;\r
146                 unsigned LEN0 : 2;\r
147                 unsigned RW1 : 2;\r
148                 unsigned LEN1 : 2;\r
149                 unsigned RW2 : 2;\r
150                 unsigned LEN2 : 2;\r
151                 unsigned RW3 : 2;\r
152                 unsigned LEN3 : 2;\r
153         } bit;\r
154 } CPU_DebugRegister7;\r
155 \r
156 typedef union CPU_EFLAGS {\r
157         uint eflags;\r
158         struct CPU_EFLAGS_BIT {\r
159                 unsigned CF : 1;\r
160                 unsigned bit1 : 1;      //\8fí\82ÉTrue\81A\82±\82ê\88È\8aO\82Ì\97\\96ñ\8dÏ\82Ý\83r\83b\83g\82Í\8fí\82ÉFalse\r
161                 unsigned PF : 1;\r
162                 unsigned bit3 : 1;\r
163                 unsigned AF : 1;\r
164                 unsigned bit5 : 1;\r
165                 unsigned ZF : 1;\r
166                 unsigned SF : 1;\r
167                 unsigned TF : 1;\r
168                 unsigned IF : 1;\r
169                 unsigned DF : 1;\r
170                 unsigned OF : 1;\r
171                 unsigned IOPL : 2;\r
172                 unsigned NT : 1;\r
173                 unsigned bit15 : 1;\r
174                 unsigned RF : 1;\r
175                 unsigned VM : 1;\r
176                 unsigned AC : 1;\r
177                 unsigned VIF : 1;\r
178                 unsigned VIP : 1;\r
179                 unsigned ID : 1;\r
180                 unsigned bit22 : 1;\r
181                 unsigned bit23 : 1;\r
182                 unsigned bit24 : 1;\r
183                 unsigned bit25 : 1;\r
184                 unsigned bit26 : 1;\r
185                 unsigned bit27 : 1;\r
186                 unsigned bit28 : 1;\r
187                 unsigned bit29 : 1;\r
188                 unsigned bit30 : 1;\r
189                 unsigned bit31 : 1;\r
190         } bit;\r
191 } CPU_EFlags;\r
192 \r
193 typedef struct TASK_STATE_SEGMENT {\r
194         ushort backlink, reserve00;\r
195         uint esp0;\r
196         ushort ss0, reserve01;\r
197         uint esp1;\r
198         ushort ss1, reserve02;\r
199         uint esp2;\r
200         ushort ss2, reserve03;\r
201         uint cr3;\r
202         uint eip;\r
203         CPU_EFlags eflags;\r
204         uint eax;\r
205         uint ecx;\r
206         uint edx;\r
207         uint ebx;\r
208         uint esp;\r
209         uint ebp;\r
210         uint esi;\r
211         uint edi;\r
212         ushort es, reserve04;\r
213         ushort cs, reserve05;\r
214         ushort ss, reserve06;\r
215         ushort ds, reserve07;\r
216         ushort fs, reserve08;\r
217         ushort gs, reserve09;\r
218         ushort ldtr, reserve10;\r
219         unsigned flag_trap : 1;\r
220         unsigned reserve11 : 15;\r
221         ushort iomap_base;\r
222 } CPU_TaskStateSegment;\r
223 \r
224 typedef struct SEGMENT_DESCRIPTOR { \r
225         ushort limit_low, base_low;\r
226         uchar base_mid, access_right;\r
227         uchar limit_high, base_high;\r
228 } IO_SegmentDescriptor;\r
229 \r
230 typedef struct GATE_DESCRIPTOR { \r
231         ushort offset_low, selector;\r
232         uchar dw_count, access_right;\r
233         ushort offset_high;\r
234 } IO_GateDescriptor;\r
235 \r
236 /*memory*/\r
237 typedef struct IO_MEMORYCONTROLTAG {\r
238         void *addr;\r
239         uint size;\r
240 } IO_MemoryControlTag;\r
241 \r
242 typedef IO_MemoryControlTag* IO_MemoryControl;\r
243 \r
244 /*common tag*/\r
245 typedef struct SYSTEM_COMMON_STRUCT {\r
246         uint structid;\r
247         uint structsize;\r
248 } System_CommonStruct;\r
249 \r
250 /*FIFO*/\r
251 typedef struct FIFO32 {\r
252         System_CommonStruct common_tag;\r
253         uint *buf;\r
254         uint p, q, size, free;\r
255         struct FIFO32_FLAGS {\r
256                 unsigned initialized : 1;\r
257                 unsigned overflow : 1;\r
258         } flags;\r
259         struct UI_TASK *task;\r
260 } DATA_FIFO32;\r
261 \r
262 /*task*/\r
263 typedef struct UI_TASK {\r
264         uint selector;\r
265         struct UI_TASK *next;\r
266         uint count;\r
267         DATA_FIFO32 *fifo;\r
268         CPU_TaskStateSegment *tss;\r
269         struct UI_TASK_STATE_FLAGS {\r
270                 unsigned initialized : 1;\r
271                 unsigned linked : 1;\r
272                 unsigned running : 1;\r
273                 unsigned first_run : 1;\r
274         } flags;\r
275 } UI_Task;\r
276 \r
277 typedef struct UI_TASK_CONTROL {\r
278         struct UI_TASK *start;\r
279         struct UI_TASK *now;\r
280         IO_MemoryControl sysmemctrl;\r
281 } UI_TaskControl;\r
282 \r
283 /*callbios*/\r
284 typedef struct CALL_BIOS_CONTROL {\r
285         UI_Task *CallBIOS_Task;\r
286         uint codesize;\r
287         DATA_FIFO32 *fifo;\r
288         uint endsignal;\r
289         CPU_TaskStateSegment retvalue;\r
290         uint esp0;\r
291 } IO_CallBIOSControl;\r
292 \r
293 /*cfunction*/\r
294 typedef struct CFUNCTION_VSNPRINTF_WORKAREA {\r
295         uchar *destination_buf;         /*\8f\91\82«\8d\9e\82Ý\90æ\95\8e\9a\97ñ\82Ì\8aJ\8en\83A\83h\83\8c\83X*/\r
296         uint length_destination_buf;    /*\8f\91\82«\8d\9e\82Ý\90æ\95\8e\9a\97ñ\82Ì\8dÅ\91å\83T\83C\83Y*/\r
297         uint index_destination_buf;     /*\8f\91\82«\8d\9e\82Ý\90æ\95\8e\9a\97ñ\82Ì\83C\83\93\83f\83b\83N\83X*/\r
298 \r
299         const uchar *format_buf;        /*\8f\91\8e®\8ew\92è\95\8e\9a\97ñ\82Ì\8aJ\8en\83A\83h\83\8c\83X*/\r
300         uint index_format_buf;          /*\8f\91\8e®\8ew\92è\95\8e\9a\97ñ\82Ì\83C\83\93\83f\83b\83N\83X*/\r
301 \r
302         uchar temporary_data[16];       /*\88ê\8e\9e\83f\81[\83^\82Ì\94z\97ñ*/\r
303         uchar temporary_data_double[8]; /*64\83r\83b\83g\95\82\93®\8f¬\90\94\93_\97p\83o\83b\83t\83@*/\r
304 \r
305         uint *vargs;                    /*\89Â\95Ï\92·\88ø\90\94\82Ì\8aJ\8en\83A\83h\83\8c\83X*/\r
306         uint index_vargs;               /*\89Â\95Ï\92·\88ø\90\94\82Ì\8c»\8dÝ\82Ì\8fê\8f\8a*/\r
307 \r
308         uint format_phase;              /*\83t\83H\81[\83}\83b\83g\82Ì\92i\8aK\82ð\8e¦\82·\81B*/\r
309                                                 /*\90\94\92l  :\88Ó\96¡*/\r
310                                                 /*0     :\83t\83H\81[\83}\83b\83g\8ew\92è\92\86\82Å\82Í\82È\82¢*/\r
311                                                 /*1     :\83t\83\89\83O\88È\8d~\82Ì\8f\91\8e®\82ð\97v\8b\81*/\r
312                                                 /*2     :\83t\83B\81[\83\8b\83h\95\9d\88È\8d~\82Ì\8f\91\8e®\82ð\97v\8b\81\81B*/\r
313                                                 /*3     :\90¸\93x\88È\8d~\82Ì\8f\91\8e®\82ð\97v\8b\81\81B*/\r
314                                                 /*4     :\95Ï\8a·\8fC\8fü\8eq\88È\8d~\82Ì\8f\91\8e®\82ð\97v\8b\81\81B*/\r
315                                                 /*5     :\83t\83H\81[\83}\83b\83g\8ew\92è\8eq\82ð\97v\8b\81*/\r
316 } CFunction_vsnprintf_WorkArea;\r
317 \r
318 /*emu86*/\r
319 typedef struct EMULATOR_X86_ENVIRONMENT_SEGMENT_REGISTER {\r
320         ushort selector;\r
321         ushort type;\r
322         uint base;\r
323         uint limit;\r
324 } Emulator_x86_Environment_SegmentRegister;\r
325 \r
326 typedef struct EMULATOR_X86_ENVIRONMENT_SYSTEM_TABLE_REGISTER {\r
327         uint base;\r
328         ushort limit;\r
329 } Emulator_x86_Environment_SystemTableRegister;\r
330 \r
331 typedef struct EMULATOR_X86_ENVIRONMENT {\r
332         CPU_EFlags EFLAGS;\r
333         uint EIP;\r
334 \r
335         uint GReg[8];\r
336 \r
337         Emulator_x86_Environment_SystemTableRegister GDTR;\r
338         Emulator_x86_Environment_SystemTableRegister IDTR;\r
339 \r
340         Emulator_x86_Environment_SegmentRegister SReg[8];\r
341 \r
342         CPU_ControlRegister0 CR0;\r
343         uint CR2;\r
344         CPU_ControlRegister3 CR3;\r
345         CPU_ControlRegister4 CR4;\r
346 \r
347         uchar now_opcode;\r
348         uchar operation_end;\r
349         uchar operation_32bit;\r
350         uchar operation_prefix_lock_repeat;\r
351         uchar operation_prefix_segment;\r
352         uchar operation_prefix_opsize;\r
353         uchar operation_prefix_addrsize;\r
354 } Emulator_x86_Environment;\r
355 \r
356 typedef union EMULATOR_X86_OPCODE_MODRM {\r
357         uchar modrm;\r
358         struct EMULATOR_X86_OPCODE_MODRM_BIT {\r
359                 unsigned RM : 3;\r
360                 unsigned Reg : 3;\r
361                 unsigned Mod : 2;\r
362         } bit;\r
363 } Emulator_x86_OperationCode_ModRM;\r
364 \r
365 typedef struct EMULATOR_X86_FAR_POINTER {\r
366         ushort offset;\r
367         ushort selector;\r
368 } Emulator_x86_FarPointer;\r
369 \r
370 /*drawing*/\r
371 typedef struct DATA_LOCATION_2D {\r
372         int x;\r
373         int y;\r
374 } DATA_Location2D;\r
375 \r
376 typedef struct DATA_LOCATION_2DU {\r
377         uint x;\r
378         uint y;\r
379 } DATA_Location2DU;\r
380 \r
381 /*display*/\r
382 typedef struct _INFO_VBE_BIOS {\r
383         uchar sign[4];\r
384         uchar ver_minor;\r
385         uchar ver_major;\r
386         ushort oem_string_offset;\r
387         ushort oem_string_segment;\r
388         ushort flags[2];        //\83p\83f\83B\83\93\83O\82Ì\8aÖ\8cW\82Å\81A\96{\93\96\82Íuint\82¾\82ªushort*2\82É\82µ\82Ä\82¢\82é\81B\r
389         ushort vmode_args_offset;\r
390         ushort vmode_args_segment;\r
391         ushort vram_supported_size_kb;\r
392 } INFO_VBE_BIOS;\r
393 \r
394 typedef struct _INFO_VBE_VIDEO_MODE {\r
395         ushort  ModeAttributes;\r
396         uchar   WinAAttributes;\r
397         uchar   WinBAttributes;\r
398         ushort  WinGranularity;\r
399         ushort  WinSize;\r
400         ushort  WinASegment;\r
401         ushort  WinBSegment;\r
402         uint    WinFuncPtr;\r
403         ushort  BytesPerScanLine;\r
404         ushort  XResolution;\r
405         ushort  YResolution;\r
406         uchar   XCharSize;\r
407         uchar   YCharSize;\r
408         uchar   NumberOfPlanes;\r
409         uchar   BitsPerPixel;\r
410         uchar   NumberOfBanks;\r
411         uchar   MemoryModel;\r
412         uchar   BankSize;\r
413         uchar   NumberOfImagePages;\r
414         uchar   Reserved;\r
415         uchar   RedMaskSize;\r
416         uchar   RedFieldPosition;\r
417         uchar   GreenMaskSize;\r
418         uchar   GreenFieldPosition;\r
419         uchar   BlueMaskSize;\r
420         uchar   BlueFieldPosition;\r
421         uchar   RsvdMaskSize;\r
422         uchar   RsvdFieldPodition;\r
423         uchar   DirectColorModeInfo;\r
424         void*   PhysBasePtr;\r
425 } INFO_VBE_VideoMode;\r
426 \r
427 typedef struct _INFO_VBE_VIDEOMODETAG {\r
428         ushort mode_number;\r
429         ushort xsize;\r
430         ushort ysize;\r
431         uchar bpp;\r
432         uchar memory_model;     //0x00:text 0x04:256palette 0x06:direct color\r
433         ushort attribute;       //bit3:1:color 0:monochrome\r
434                                 //bit4:1:graphic 0:text\r
435                                 //bit7:linear buffer support\r
436         ushort reserve;\r
437         void *vram;     //vram:0=not supported.\r
438 } INFO_VBE_VideoModeTag;\r
439 \r
440 typedef struct IO_DISPLAY_CONTROL {\r
441         struct IO_DISPLAY_CONTROL_VBE {\r
442                 uchar version_minor;\r
443                 uchar version_major;\r
444                 ushort vram_supported_size_kb;\r
445                 uint flags;\r
446                 uchar *oem_string;\r
447                 ushort *vmode_args;\r
448                 uint list_vmode_tags;\r
449                 INFO_VBE_VideoModeTag *list_vmode;\r
450         } VBE;\r
451         ushort display_mode;    //0x0000:BIOS 0x0001:VBE Window Access(version < 2.0)(not implemented) 0x0002:VBE Linear Access\r
452         ushort vmode;   //0x0000:VGA 320x200 8bit\r
453         ushort vmode_index;\r
454         ushort bpp;\r
455         ushort xsize;\r
456         ushort ysize;\r
457         void *vram;\r
458         DATA_FIFO32 *bios_signal;\r
459         struct UI_SHEET *vramsheet;\r
460 } IO_DisplayControl;\r
461 \r
462 /*sheet*/\r
463 typedef struct UI_SHEET {\r
464         System_CommonStruct common_tag;\r
465         struct UI_SHEET *parent;        //one sheet has one parent(if vramseet then:0)\r
466         struct UI_SHEET *next;          //same level sheet link\r
467         struct UI_SHEET *child;         //lowest height sheet in children\r
468         DATA_Location2D location;\r
469         DATA_Location2DU size;\r
470         ushort bpp;\r
471         union UI_SHEET_FLAGS {\r
472                 ushort flags;\r
473                 struct UI_SHEET_FLAGS_BITS {\r
474                         unsigned initialized : 1;\r
475                         unsigned buffer_configured : 1;\r
476                         unsigned visible : 1;\r
477                         unsigned using_map : 1;\r
478                         unsigned vram_auto_allocated : 1;\r
479                         unsigned using_invcol : 1;\r
480                         unsigned topmost : 1;\r
481                         unsigned movable : 1;\r
482                         unsigned autorefresh_upperlevel : 1;\r
483                 } bit;\r
484         } flags;\r
485         void *vram;\r
486         uint *map;\r
487         uint vramsize;\r
488         uint mapsize;\r
489         uint invcol;\r
490         uint (*Config_Functions)(struct UI_SHEET *sheet);\r
491         uint (*RefreshSheet)(struct UI_SHEET *sheet, int px0, int py0, int px1, int py1);\r
492         bool (*IsVisiblePixel)(struct UI_SHEET *sheet, int px, int py);\r
493         struct UI_SHEET_DRAWING {\r
494                 uint (*Fill_Rectangle)(struct UI_SHEET *sheet, uint c, int px0, int py0, int px1, int py1);\r
495                 uint (*Put_String)(struct UI_SHEET *sheet, int x, int y, uint fc, const uchar s[]);\r
496                 uint (*Draw_Point)(struct UI_SHEET *sheet, int x, int y, uint c);\r
497         } Drawing;\r
498         DATA_FIFO32 *input_fifo;\r
499 } UI_Sheet;\r
500 \r
501 /*timer*/\r
502 typedef struct UI_TIMER {\r
503         uint tick;\r
504         uint timeout;\r
505         struct UI_TIMER *root_next;\r
506         struct UI_TIMER *tree_next;\r
507         DATA_FIFO32 *fifo;\r
508         uint fifo_putdata;\r
509         union UI_TIMER_FLAGS {\r
510                 uint flags;\r
511                 struct UI_TIMER_FLAGS_BITS {\r
512                         unsigned initialized : 1;\r
513                         unsigned configured : 1;\r
514                         unsigned running : 1;\r
515                         unsigned interval : 1;\r
516                 } bit;\r
517         } flags;\r
518 } UI_Timer;\r
519 \r
520 typedef struct UI_TIMER_CONTROL {\r
521         uint tick_10ms;\r
522         void (*TaskSwitch)(void);\r
523         UI_Timer *timer_root;\r
524 } UI_TimerControl;\r
525 \r
526 /*color*/\r
527 typedef union RGB_32BIT {\r
528         uint c32;\r
529         struct RGB_32BIT_RGBA {\r
530                 uchar b;\r
531                 uchar g;\r
532                 uchar r;\r
533                 uchar a;\r
534         } bit;\r
535 } RGB32;\r
536 \r
537 /*mouse*/\r
538 \r
539 typedef struct IO_MOUSE_CONTROL {\r
540         uint decode_phase;\r
541         uchar decode_buf[4];\r
542         DATA_Location2D move;\r
543         int scroll;\r
544         struct IO_MOUSE_CONTROL_FLAGS {\r
545                 unsigned scroll : 1;\r
546         } flags;\r
547         union IO_MOUSE_CONTROL_BUTTON {\r
548                 uchar button;\r
549                 struct IO_MOUSE_CONTROL_BUTTON_BIT {\r
550                         unsigned L : 1;\r
551                         unsigned R : 1;\r
552                         unsigned C : 1;\r
553                 } bit;\r
554         } button;\r
555 } IO_MouseControl;\r
556 \r
557 typedef struct UI_MOUSE_CURSOR {\r
558         UI_Sheet *cursor_sheet;\r
559         struct UI_MOUSE_CURSOR_FLAGS {\r
560                 unsigned mode : 2;\r
561         } flags;\r
562         uchar *cursors[4];\r
563 } UI_MouseCursor;\r
564 \r
565 /*textbox*/\r
566 typedef struct UI_TEXT_BOX {\r
567         System_CommonStruct common_tag;\r
568         UI_Sheet *sheet;\r
569         uint forecol;\r
570         uint backcol;\r
571         DATA_Location2D location_cursor;\r
572         DATA_Location2D location_cursor_record_started;\r
573         DATA_Location2DU chars;\r
574         uchar *text_buf;\r
575         uint size_text_buf;\r
576         uint using_text_buf;\r
577         \r
578         union UI_TEXT_BOX_FLAGS {\r
579                 uint flags;\r
580                 struct UI_TEXT_BOX_FLAGS_BITS {\r
581                         unsigned initialized : 1;\r
582                         unsigned textbuffer_configured : 1;\r
583                         unsigned record_input_text : 1;\r
584                         unsigned cursor_blink : 1;\r
585                         unsigned cursor_state : 1;\r
586                 } bit;\r
587         } flags;\r
588 } UI_TextBox;\r
589 \r
590 typedef struct IO_FLOPPYDISK_DIRECTORY_ENTRY {\r
591         uchar name[8];  //0x00:empty(no more files)\r
592                                         //0x05:=0xe5\r
593                                         //0x2e:(only directory)\r
594                                         //.             0x2e:current directory\r
595                                         //..    0x2e, 0x2e:parent directory\r
596                                         //0xe5:deleted(usable)\r
597         uchar ext[3];\r
598         uchar attribute;        //0x0f=LongFileNameEntry\r
599         uchar reserved;\r
600         uchar VFAT_createTimeMs;\r
601         ushort VFAT_createTime;\r
602         ushort VFAT_createDate;\r
603         ushort VFAT_accessDate;\r
604         ushort VFAT_clusterHighWord;\r
605         ushort updatetime;\r
606         ushort updatedate;\r
607         ushort cluster;\r
608         uint size;      //attribute.bit.directory==true:0\r
609 } IO_FloppyDisk_DirectoryEntry;\r
610 \r
611 typedef struct IO_FLOPPYDISK {\r
612         System_CommonStruct common_tag;\r
613         uchar *img;\r
614         IO_FloppyDisk_DirectoryEntry *files;\r
615         sector *userdataarea;\r
616         ushort *fat;\r
617 } IO_FloppyDisk;\r
618 \r
619 typedef union IO_FLOPPYDISK_DIRECTORY_ENTRY_ATTRIBUTE {\r
620         uchar attribute;        //0x0f=LongFileNameEntry\r
621         struct IO_FLOPPYDISK_RDE_ATTRIBUTE_BITS {\r
622                 unsigned readonly : 1;\r
623                 unsigned hidden : 1;\r
624                 unsigned system : 1;\r
625                 unsigned volumelabel : 1;\r
626                 unsigned directory : 1;\r
627                 unsigned archive : 1;\r
628                 unsigned bit6 : 1;\r
629                 unsigned bit7 : 1;\r
630         } bit;\r
631 } IO_FloppyDisk_DirectoryEntry_Attribute;\r
632 \r
633 typedef union IO_FLOPPYDISK_DIRECTORY_ENTRY_UPDATETIME {\r
634         ushort updatetime;\r
635         struct IO_FLOPPYDISK_RDE_UPDATETIME_BITS {\r
636                 unsigned second : 5;    //second/2\r
637                 unsigned minute : 6;\r
638                 unsigned hour : 5;\r
639         } bit;\r
640 } IO_FloppyDisk_DirectoryEntry_UpdateTime;\r
641 \r
642 typedef union IO_FLOPPYDISK_DIRECTORY_ENTRY_UPDATEDATE {\r
643         ushort updatedate;\r
644         struct IO_FLOPPYDISK_RDE_UPDATEDATE_BITS {\r
645                 unsigned day : 5;               //day(1-31)\r
646                 unsigned month : 4;     //month(1-12)\r
647                 unsigned year : 7;              //year(from 1980)\r
648         } bit;\r
649 } IO_FloppyDisk_DirectoryEntry_UpdateDate;\r
650 \r
651 typedef struct UI_CONSOLE {\r
652         UI_TextBox *textbox;\r
653         UI_Task *task;\r
654         uchar *printf_buffer;\r
655         union UI_CONSOLE_FLAGS {\r
656                 uint flags;\r
657                 struct UI_CONSOLE_FLAGS_BITS {\r
658                         unsigned initialized : 1;\r
659                         unsigned configured_size : 1;\r
660                         unsigned isprompt : 1;\r
661                 } bit;\r
662         } flags;\r
663         IO_FloppyDisk *boot_fd;\r
664 } UI_Console;\r
665 \r
666 typedef struct IO_FILE {\r
667         System_CommonStruct common_tag;\r
668         uchar *path;\r
669         uint size;\r
670         void *img;\r
671         union IO_FILE_FLAGS {\r
672                 uint flags;\r
673                 struct IO_FILE_FLAGS_BITS {\r
674                         unsigned initialized : 1;\r
675                         unsigned img_loaded : 1;\r
676                 } bit;\r
677         } flags;\r
678 } IO_File;\r
679 \r
680 \r