Subversion Repositories Kolibri OS

Rev

Rev 8874 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  2. ;;                                                              ;;
  3. ;; Copyright (C) KolibriOS team 2004-2021. All rights reserved. ;;
  4. ;; Distributed under terms of the GNU General Public License    ;;
  5. ;;                                                              ;;
  6. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  7.  
  8. $Revision: 8874 $
  9.  
  10.  
  11. dpl0    =  10010000b      ; data read       dpl0
  12. drw0    =  10010010b      ; data read/write dpl0
  13. drw3    =  11110010b      ; data read/write dpl3
  14. cpl0    =  10011010b      ; code read dpl0
  15. cpl3    =  11111010b      ; code read dpl3
  16.  
  17. D32     =  01000000b      ; 32bit segment
  18. G32     =  10000000b      ; page gran
  19.  
  20.  
  21. ;;;;;;;;;;;;cpu_caps flags;;;;;;;;;;;;;;;;
  22.  
  23. CPU_386        = 3
  24. CPU_486        = 4
  25. CPU_PENTIUM    = 5
  26. CPU_P6         = 6
  27. CPU_PENTIUM4   = 0x0F
  28.  
  29. CAPS_FPU       =    00 ;on-chip x87 floating point unit
  30. CAPS_VME       =    01 ;virtual-mode enhancements
  31. CAPS_DE        =    02 ;debugging extensions
  32. CAPS_PSE       =    03 ;page-size extensions
  33. CAPS_TSC       =    04 ;time stamp counter
  34. CAPS_MSR       =    05 ;model-specific registers
  35. CAPS_PAE       =    06 ;physical-address extensions
  36. CAPS_MCE       =    07 ;machine check exception
  37. CAPS_CX8       =    08 ;CMPXCHG8B instruction
  38. CAPS_APIC      =    09 ;on-chip advanced programmable
  39.                        ;interrupt controller
  40. ;                   10 ;unused
  41. CAPS_SEP       =    11 ;SYSENTER and SYSEXIT instructions
  42. CAPS_MTRR      =    12 ;memory-type range registers
  43. CAPS_PGE       =    13 ;page global extension
  44. CAPS_MCA       =    14 ;machine check architecture
  45. CAPS_CMOV      =    15 ;conditional move instructions
  46. CAPS_PAT       =    16 ;page attribute table
  47.  
  48. CAPS_PSE36     =    17 ;page-size extensions
  49. CAPS_PSN       =    18 ;processor serial number
  50. CAPS_CLFLUSH   =    19 ;CLFUSH instruction
  51.  
  52. CAPS_DS        =    21 ;debug store
  53. CAPS_ACPI      =    22 ;thermal monitor and software
  54.                        ;controlled clock supported
  55. CAPS_MMX       =    23 ;MMX instructions
  56. CAPS_FXSR      =    24 ;FXSAVE and FXRSTOR instructions
  57. CAPS_SSE       =    25 ;SSE instructions
  58. CAPS_SSE2      =    26 ;SSE2 instructions
  59. CAPS_SS        =    27 ;self-snoop
  60. CAPS_HTT       =    28 ;hyper-threading technology
  61. CAPS_TM        =    29 ;thermal monitor supported
  62. CAPS_IA64      =    30 ;IA64 capabilities
  63. CAPS_PBE       =    31 ;pending break enable
  64.  
  65. ;ecx
  66. CAPS_SSE3      =    32 ;SSE3 instructions
  67. ;                   33
  68. ;                   34
  69. CAPS_MONITOR   =    35 ;MONITOR/MWAIT instructions
  70. CAPS_DS_CPL    =    36 ;
  71. CAPS_VMX       =    37 ;virtual mode extensions
  72. ;                   38 ;
  73. CAPS_EST       =    39 ;enhansed speed step
  74. CAPS_TM2       =    40 ;thermal monitor2 supported
  75. ;                   41
  76. CAPS_CID       =    42 ;
  77. ;                   43
  78. ;                   44
  79. CAPS_CX16      =    45 ;CMPXCHG16B instruction
  80. CAPS_xTPR      =    46 ;
  81. CAPS_XSAVE     =    32 + 26 ; XSAVE and XRSTOR instructions
  82. CAPS_OSXSAVE   =    32 + 27
  83. ; A value of 1 indicates that the OS has set CR4.OSXSAVE[bit 18] to enable
  84. ; XSETBV/XGETBV instructions to access XCR0 and to support processor extended
  85. ; state management using XSAVE/XRSTOR.
  86. CAPS_AVX       =    32 + 28 ; not AVX2
  87. ;
  88. ;reserved
  89. ;
  90. ;ext edx /ecx
  91. CAPS_SYSCAL    =    64 ;
  92. CAPS_XD        =    65 ;execution disable
  93. CAPS_FFXSR     =    66 ;
  94. CAPS_RDTSCP    =    67 ;
  95. CAPS_X64       =    68 ;
  96. CAPS_3DNOW     =    69 ;
  97. CAPS_3DNOWEXT  =    70 ;
  98. CAPS_LAHF      =    71 ;
  99. CAPS_CMP_LEG   =    72 ;
  100. CAPS_SVM       =    73 ;secure virual machine
  101. CAPS_ALTMOVCR8 =    74 ;
  102.  
  103. ; CPU MSR names
  104. MSR_SYSENTER_CS         =     0x174
  105. MSR_SYSENTER_ESP        =     0x175
  106. MSR_SYSENTER_EIP        =     0x176
  107. MSR_CR_PAT              =     0x277
  108. MSR_MTRR_DEF_TYPE       =     0x2FF
  109.  
  110. MSR_AMD_EFER            =     0xC0000080      ; Extended Feature Enable Register
  111. MSR_AMD_STAR            =     0xC0000081      ; SYSCALL/SYSRET Target Address Register
  112.  
  113. CR0_PE         =    0x00000001   ;protected mode
  114. CR0_MP         =    0x00000002   ;monitor fpu
  115. CR0_EM         =    0x00000004   ;fpu emulation
  116. CR0_TS         =    0x00000008   ;task switch
  117. CR0_ET         =    0x00000010   ;extension type hardcoded to 1
  118. CR0_NE         =    0x00000020   ;numeric error
  119. CR0_WP         =    0x00010000   ;write protect
  120. CR0_AM         =    0x00040000   ;alignment check
  121. CR0_NW         =    0x20000000   ;not write-through
  122. CR0_CD         =    0x40000000   ;cache disable
  123. CR0_PG         =    0x80000000   ;paging
  124.  
  125.  
  126. CR4_VME        =    0x000001
  127. CR4_PVI        =    0x000002
  128. CR4_TSD        =    0x000004
  129. CR4_DE         =    0x000008
  130. CR4_PSE        =    0x000010
  131. CR4_PAE        =    0x000020
  132. CR4_MCE        =    0x000040
  133. CR4_PGE        =    0x000080
  134. CR4_PCE        =    0x000100
  135. CR4_OSFXSR     =    0x000200
  136. CR4_OSXMMEXPT  =    0x000400
  137. CR4_OSXSAVE    =    0x040000
  138.  
  139. XCR0_FPU_MMX   =    0x0001
  140. XCR0_SSE       =    0x0002
  141. XCR0_AVX       =    0x0004
  142. XCR0_MPX       =    0x0018
  143. XCR0_AVX512    =    0x00e0
  144.  
  145. MXCSR_IE       =    0x0001
  146. MXCSR_DE       =    0x0002
  147. MXCSR_ZE       =    0x0004
  148. MXCSR_OE       =    0x0008
  149. MXCSR_UE       =    0x0010
  150. MXCSR_PE       =    0x0020
  151. MXCSR_DAZ      =    0x0040
  152. MXCSR_IM       =    0x0080
  153. MXCSR_DM       =    0x0100
  154. MXCSR_ZM       =    0x0200
  155. MXCSR_OM       =    0x0400
  156. MXCSR_UM       =    0x0800
  157. MXCSR_PM       =    0x1000
  158. MXCSR_FZ       =    0x8000
  159.  
  160. MXCSR_INIT     = MXCSR_IM + MXCSR_DM + MXCSR_ZM + MXCSR_OM + MXCSR_UM + MXCSR_PM
  161.  
  162. EFLAGS_CF      =    0x000001  ; carry flag
  163. EFLAGS_PF      =    0x000004  ; parity flag
  164. EFLAGS_AF      =    0x000010  ; auxiliary flag
  165. EFLAGS_ZF      =    0x000040  ; zero flag
  166. EFLAGS_SF      =    0x000080  ; sign flag
  167. EFLAGS_TF      =    0x000100  ; trap flag
  168. EFLAGS_IF      =    0x000200  ; interrupt flag
  169. EFLAGS_DF      =    0x000400  ; direction flag
  170. EFLAGS_OF      =    0x000800  ; overflow flag
  171. EFLAGS_IOPL    =    0x003000  ; i/o priviledge level
  172. EFLAGS_NT      =    0x004000  ; nested task flag
  173. EFLAGS_RF      =    0x010000  ; resume flag
  174. EFLAGS_VM      =    0x020000  ; virtual 8086 mode flag
  175. EFLAGS_AC      =    0x040000  ; alignment check flag
  176. EFLAGS_VIF     =    0x080000  ; virtual interrupt flag
  177. EFLAGS_VIP     =    0x100000  ; virtual interrupt pending
  178. EFLAGS_ID      =    0x200000  ; id flag
  179.  
  180. IRQ_PIC        =    0
  181. IRQ_APIC       =    1
  182.  
  183. struct  TSS
  184.         _back       rw 2
  185.         _esp0       rd 1
  186.         _ss0        rw 2
  187.         _esp1       rd 1
  188.         _ss1        rw 2
  189.         _esp2       rd 1
  190.         _ss2        rw 2
  191.         _cr3        rd 1
  192.         _eip        rd 1
  193.         _eflags     rd 1
  194.         _eax        rd 1
  195.         _ecx        rd 1
  196.         _edx        rd 1
  197.         _ebx        rd 1
  198.         _esp        rd 1
  199.         _ebp        rd 1
  200.         _esi        rd 1
  201.         _edi        rd 1
  202.         _es         rw 2
  203.         _cs         rw 2
  204.         _ss         rw 2
  205.         _ds         rw 2
  206.         _fs         rw 2
  207.         _gs         rw 2
  208.         _ldt        rw 2
  209.         _trap       rw 1
  210.         _io         rw 1
  211.                     rb 24
  212.         _io_map_0   rb 4096
  213.         _io_map_1   rb 4096
  214. ends
  215.  
  216. DRIVE_DATA_SIZE     = 16
  217.  
  218. OS_BASE             = 0x80000000
  219.  
  220. window_data         = OS_BASE + 0x0001000
  221.  
  222. TASK_TABLE          = OS_BASE + 0x0003000
  223. ;CURRENT_TASK        = OS_BASE + 0x0003000
  224. ;TASK_COUNT          = OS_BASE + 0x0003004
  225. TASK_BASE           = OS_BASE + 0x0003010
  226. TASK_DATA           = OS_BASE + 0x0003020
  227. ;TASK_EVENT          = OS_BASE + 0x0003020
  228.  
  229. CDDataBuf           = OS_BASE + 0x0005000
  230.  
  231. ;unused                 0x6000 - 0x8fff
  232.  
  233. BOOT_VARS           = 0x9000
  234.  
  235. idts                = OS_BASE + 0x000B100
  236. WIN_STACK           = OS_BASE + 0x000C000
  237. WIN_POS             = OS_BASE + 0x000C400
  238. FDD_BUFF            = OS_BASE + 0x000D000     ;512
  239.  
  240. WIN_TEMP_XY         = OS_BASE + 0x000F300
  241. KEY_COUNT           = OS_BASE + 0x000F400
  242. KEY_BUFF            = OS_BASE + 0x000F401 ; 120*2 + 2*2 = 244 bytes, actually 255 bytes
  243.  
  244. BTN_COUNT           = OS_BASE + 0x000F500
  245. BTN_BUFF            = OS_BASE + 0x000F501
  246.  
  247.  
  248. BTN_ADDR            = OS_BASE + 0x000FE88
  249. MEM_AMOUNT          = OS_BASE + 0x000FE8C
  250.  
  251. SYS_SHUTDOWN        = OS_BASE + 0x000FF00
  252.  
  253.  
  254. TMP_STACK_TOP       = 0x007CC00
  255.  
  256. sys_proc            = OS_BASE + 0x007E000
  257.  
  258. SLOT_BASE           = OS_BASE + 0x0080000
  259.  
  260. VGABasePtr          = OS_BASE + 0x00A0000
  261.  
  262. virtual at            OS_BASE + 0x05FFF80
  263.   tss  TSS
  264. end virtual
  265.  
  266. HEAP_BASE           = OS_BASE + 0x0800000
  267. HEAP_MIN_SIZE       = 0x01000000
  268.  
  269. page_tabs           = 0xFDC00000
  270. app_page_tabs       = 0xFDC00000
  271. kernel_tabs         = page_tabs + (OS_BASE shr 10)   ;0xFDE00000
  272. master_tab          = page_tabs + (page_tabs shr 10) ;0xFDFF70000
  273.  
  274. LFB_BASE            = 0xFE000000
  275.  
  276.  
  277. new_app_base        = 0;
  278.  
  279. twdw                = TASK_TABLE - window_data
  280.  
  281. std_application_base_address   = new_app_base
  282. RING0_STACK_SIZE    = 0x2000
  283.  
  284. REG_SS              = RING0_STACK_SIZE -  4
  285. REG_APP_ESP         = RING0_STACK_SIZE -  8
  286. REG_EFLAGS          = RING0_STACK_SIZE - 12
  287. REG_CS              = RING0_STACK_SIZE - 16
  288. REG_EIP             = RING0_STACK_SIZE - 20
  289. REG_EAX             = RING0_STACK_SIZE - 24
  290. REG_ECX             = RING0_STACK_SIZE - 28
  291. REG_EDX             = RING0_STACK_SIZE - 32
  292. REG_EBX             = RING0_STACK_SIZE - 36
  293. REG_ESP             = RING0_STACK_SIZE - 40  ;RING0_STACK_SIZE-20
  294. REG_EBP             = RING0_STACK_SIZE - 44
  295. REG_ESI             = RING0_STACK_SIZE - 48
  296. REG_EDI             = RING0_STACK_SIZE - 52
  297. REG_RET             = RING0_STACK_SIZE - 56  ;irq0.return
  298.  
  299.  
  300. PAGE_SIZE           = 4096
  301.  
  302. PG_UNMAP            = 0x000
  303. PG_READ             = 0x001
  304. PG_WRITE            = 0x002
  305. PG_USER             = 0x004
  306. PG_PCD              = 0x008
  307. PG_PWT              = 0x010
  308. PG_ACCESSED         = 0x020
  309. PG_DIRTY            = 0x040
  310. PG_PAT              = 0x080
  311. PG_GLOBAL           = 0x100
  312. PG_SHARED           = 0x200
  313.  
  314. PG_SWR              = 0x003 ; PG_WRITE + PG_READ
  315. PG_UR               = 0x005 ; PG_USER + PG_READ
  316. PG_UWR              = 0x007 ; PG_USER + PG_WRITE + PG_READ
  317. PG_NOCACHE          = 0x018 ; PG_PCD + PG_PWT
  318.  
  319. PDE_LARGE           = 0x080
  320.  
  321. MEM_WB              = 6     ; write-back memory
  322. MEM_WC              = 1     ; write combined memory
  323. MEM_UC              = 0     ; uncached memory
  324.  
  325. PAT_WB              = 0x000
  326. PAT_WC              = 0x008
  327. PAT_UCM             = 0x010
  328. PAT_UC              = 0x018
  329.  
  330. PAT_TYPE_UC         = 0
  331. PAT_TYPE_WC         = 1
  332. PAT_TYPE_WB         = 6
  333. PAT_TYPE_UCM        = 7
  334.  
  335. PAT_VALUE           = 0x00070106; (UC<<24)|(UCM<<16)|(WC<<8)|WB
  336.  
  337. MAX_MEMMAP_BLOCKS   = 32
  338.  
  339. EVENT_REDRAW       = 0x00000001
  340. EVENT_KEY          = 0x00000002
  341. EVENT_BUTTON       = 0x00000004
  342. EVENT_BACKGROUND   = 0x00000010
  343. EVENT_MOUSE        = 0x00000020
  344. EVENT_IPC          = 0x00000040
  345. EVENT_NETWORK      = 0x00000080
  346. EVENT_DEBUG        = 0x00000100
  347. EVENT_NETWORK2     = 0x00000200
  348. EVENT_EXTENDED     = 0x00000400
  349.  
  350. EV_INTR            = 1
  351.  
  352. STDIN_FILENO       = 0
  353. STDOUT_FILENO      = 1
  354. STDERR_FILENO      = 2
  355.  
  356. SYSTEM_SHUTDOWN    = 2
  357. SYSTEM_REBOOT      = 3
  358. SYSTEM_RESTART     = 4
  359.  
  360. BLIT_CLIENT_RELATIVE = 0x20000000
  361.  
  362. struct SYSCALL_STACK
  363.         _eip            dd ?
  364.         _edi            dd ?    ;  +4
  365.         _esi            dd ?    ;  +8
  366.         _ebp            dd ?    ; +12
  367.         _esp            dd ?    ; +16
  368.         _ebx            dd ?    ; +20
  369.         _edx            dd ?    ; +24
  370.         _ecx            dd ?    ; +28
  371.         _eax            dd ?    ; +32
  372. ends
  373.  
  374. struct  LHEAD
  375.         next            dd ?   ;next object in list
  376.         prev            dd ?   ;prev object in list
  377. ends
  378.  
  379. struct  MUTEX_WAITER
  380.         list    LHEAD
  381.         task    dd ?
  382.         type    dd ?
  383. ends
  384.  
  385. struct  MUTEX
  386.         wait_list       LHEAD
  387.         count           dd ?
  388. ends
  389.  
  390. struct  RWSEM
  391.         wait_list       LHEAD
  392.         count           dd ?
  393. ends
  394.  
  395. struct  FUTEX
  396.         list            LHEAD
  397.         magic           dd ?
  398.         handle          dd ?
  399.         destroy         dd ?
  400.  
  401.         wait_list       LHEAD
  402.         pointer         dd ?
  403.         flags           dd ?
  404. ends
  405.  
  406. FUTEX_INIT      = 0
  407. FUTEX_DESTROY   = 1
  408. FUTEX_WAIT      = 2
  409. FUTEX_WAKE      = 3
  410.  
  411. struct  FILED
  412.         list            LHEAD
  413.         magic           rd 1
  414.         handle          rd 1
  415.         destroy         rd 1
  416.         mode            rd 1
  417.         file            rd 1
  418. ends
  419.  
  420. struct  PIPE
  421.         pipe_ops        rd 1
  422.         buffer          rd 1
  423.         readers         rd 1
  424.         writers         rd 1
  425.  
  426.         pipe_lock       MUTEX
  427.         count           rd 1
  428.  
  429.         read_end        rd 1
  430.         write_end       rd 1
  431.         rlist           LHEAD
  432.         wlist           LHEAD
  433. ends
  434.  
  435. struct  PROC
  436.         list            LHEAD
  437.         thr_list        LHEAD
  438.         heap_lock       MUTEX
  439.         heap_base       rd 1
  440.         heap_top        rd 1
  441.         mem_used        rd 1
  442.         dlls_list_ptr   rd 1
  443.         pdt_0_phys      rd 1
  444.         pdt_1_phys      rd 1
  445.         io_map_0        rd 1
  446.         io_map_1        rd 1
  447.  
  448.         ht_lock         rd 1
  449.         ht_free         rd 1                ;htab[0] stdin
  450.         ht_next         rd 1                ;htab[1] stdout
  451.         htab            rd 1024-PROC.htab/4 ;htab[2] stderr
  452.         pdt_0           rd 1024
  453. ends
  454.  
  455. struct  DBG_REGS
  456.         dr0             dd ?
  457.         dr1             dd ?
  458.         dr2             dd ?
  459.         dr3             dd ?
  460.         dr7             dd ?
  461. ends
  462.  
  463. struct  POINT
  464.         x       dd ?
  465.         y       dd ?
  466. ends
  467.  
  468. struct  RECT
  469.         left    dd ?
  470.         top     dd ?
  471.         right   dd ?
  472.         bottom  dd ?
  473. ends
  474.  
  475. struct  BOX
  476.         left    dd ?
  477.         top     dd ?
  478.         width   dd ?
  479.         height  dd ?
  480. ends
  481.  
  482. ; Fields, marked as R now not used, but will be used soon,
  483. ; when legacy TASKDATA structure will be deleted
  484. struct  APPDATA
  485.         app_name        rb 11
  486.                         rb 5
  487.  
  488.         list            LHEAD           ;+16
  489.         process         dd ?            ;+24
  490.         fpu_state       dd ?            ;+28
  491.         exc_handler     dd ?            ;+32
  492.         except_mask     dd ?            ;+36
  493.         pl0_stack       dd ?            ;+40
  494.         cursor          dd ?            ;+44
  495.         fd_ev           dd ?            ;+48
  496.         bk_ev           dd ?            ;+52
  497.         fd_obj          dd ?            ;+56
  498.         bk_obj          dd ?            ;+60
  499.         saved_esp       dd ?            ;+64
  500.         io_map          rd 2            ;+68
  501.         dbg_state       dd ?            ;+76
  502.         cur_dir         dd ?            ;+80
  503.         wait_timeout    dd ?            ;+84
  504.         saved_esp0      dd ?            ;+88
  505.         wait_begin      dd ?            ;+92   +++
  506.         wait_test       dd ?            ;+96   +++
  507.         wait_param      dd ?            ;+100  +++
  508.         tls_base        dd ?            ;+104
  509.         event_mask      dd ?            ;+108  ; R stores event types allowed for task
  510.         tid             dd ?            ;+112  ; R thread id
  511.         draw_bgr_x      dd ?            ;+116
  512.         draw_bgr_y      dd ?            ;+120
  513.         state           db ?            ;+124  ; R thread state
  514.                         db ?            ;+125
  515.                         dw ?            ;+126
  516.         wnd_shape       dd ?            ;+128
  517.         wnd_shape_scale dd ?            ;+132
  518.         mem_start       dd ?            ;+136  ; R
  519.         counter_sum     dd ?            ;+140  ; R
  520.         saved_box       BOX             ;+144
  521.         ipc_start       dd ?            ;+160
  522.         ipc_size        dd ?            ;+164
  523.         occurred_events dd ?            ;+168  ; mask which accumulates occurred events
  524.         debugger_slot   dd ?            ;+172
  525.         terminate_protection dd ?       ;+176
  526.         keyboard_mode   db ?            ;+180
  527.         captionEncoding db ?
  528.                         rb 2
  529.         exec_params     dd ?            ;+184
  530.         dbg_event_mem   dd ?            ;+188
  531.         dbg_regs        DBG_REGS        ;+192
  532.         wnd_caption     dd ?            ;+212
  533.         wnd_clientbox   BOX             ;+216
  534.         priority        dd ?            ;+232
  535.         in_schedule     LHEAD           ;+236
  536.         counter_add     dd ?            ;+244  ; R
  537.         cpu_usage       dd ?            ;+248  ; R
  538.                         dd ?            ;+252
  539. ends
  540.  
  541. assert sizeof.APPDATA = 256
  542.  
  543. APP_OBJ_OFFSET  = 48
  544. APP_EV_OFFSET   = 40
  545.  
  546. ; Note: in future TASKDATA will be merged into APPDATA
  547. struct  TASKDATA
  548.         event_mask      dd ? ;+0 mask which stores event types allowed for task
  549.         pid             dd ? ;+4
  550.                         dw ? ;+8
  551.         state           db ? ;+10
  552.                         db ? ;+11
  553.                         dw ? ;+12
  554.         wnd_number      db ? ;+14
  555.                         db ? ;+15
  556.         mem_start       dd ? ;+16
  557.         counter_sum     dd ? ;+20
  558.         counter_add     dd ? ;+24
  559.         cpu_usage       dd ? ;+28
  560. ends
  561.  
  562. ; Thread states:
  563. TSTATE_RUNNING        = 0
  564. TSTATE_RUN_SUSPENDED  = 1
  565. TSTATE_WAIT_SUSPENDED = 2
  566. TSTATE_ZOMBIE         = 3
  567. TSTATE_TERMINATING    = 4
  568. TSTATE_WAITING        = 5
  569. TSTATE_FREE           = 9
  570.  
  571. ; Window constants:
  572. WSTATE_NORMAL    = 00000000b
  573. WSTATE_MAXIMIZED = 00000001b
  574. WSTATE_MINIMIZED = 00000010b
  575. WSTATE_ROLLEDUP  = 00000100b
  576.  
  577. WSTATE_REDRAW    = 00000001b
  578. WSTATE_WNDDRAWN  = 00000010b
  579.  
  580. WSTYLE_HASCAPTION     = 00010000b
  581. WSTYLE_CLIENTRELATIVE = 00100000b
  582.  
  583. ZPOS_DESKTOP            = -2
  584. ZPOS_ALWAYS_BACK        = -1
  585. ZPOS_NORMAL             = 0
  586. ZPOS_ALWAYS_TOP         = 1     ;ZPOS_ALWAYS_TOP is always last and has max number!
  587.  
  588. ; Window structure:
  589. struct  WDATA
  590.         box             BOX
  591.         cl_workarea     dd ?
  592.         cl_titlebar     dd ?
  593.         cl_frames       dd ?
  594.         z_modif         db ?
  595.         fl_wstate       db ?
  596.         fl_wdrawn       db ?
  597.         fl_redraw       db ?
  598. ends
  599.  
  600. label WDATA.fl_wstyle byte at WDATA.cl_workarea + 3
  601.  
  602. assert sizeof.WDATA = 32
  603.  
  604. struct  SYS_VARS
  605.         bpp             dd ?
  606.         scanline        dd ?
  607.         vesa_mode       dd ?
  608.         x_res           dd ?
  609.         y_res           dd ?
  610. ends
  611.  
  612. struct  APPOBJ                  ; common object header
  613.         magic           dd ?    ;
  614.         destroy         dd ?    ; internal destructor
  615.         fd              dd ?    ; next object in list
  616.         bk              dd ?    ; prev object in list
  617.         pid             dd ?    ; owner id
  618. ends
  619.  
  620. struct  CURSOR          APPOBJ
  621.         base            dd ?   ;allocated memory
  622.         hot_x           dd ?   ;hotspot coords
  623.         hot_y           dd ?
  624.  
  625.         list_next       dd ?   ;next cursor in cursor list
  626.         list_prev       dd ?   ;prev cursor in cursor list
  627.         dev_obj         dd ?   ;device depended data
  628. ends
  629.  
  630.  
  631. struct  EVENT           APPOBJ
  632.         id              dd ?   ;event uid
  633.         state           dd ?   ;internal flags
  634.         code            dd ?
  635.                         rd 5
  636. ends
  637.  
  638.  
  639. struct  SMEM
  640.         bk              dd ?
  641.         fd              dd ?    ;+4
  642.         base            dd ?    ;+8
  643.         size            dd ?    ;+12
  644.         access          dd ?    ;+16
  645.         refcount        dd ?    ;+20
  646.         name            rb 32   ;+24
  647. ends
  648.  
  649. struct  SMAP            APPOBJ
  650.         base            dd ?   ;mapped base
  651.         parent          dd ?   ;SMEM
  652. ends
  653.  
  654. struct  DLLDESCR
  655.         bk              dd ?
  656.         fd              dd ?    ;+4
  657.         data            dd ?    ;+8
  658.         size            dd ?    ;+12
  659.         timestamp       dq ?
  660.         refcount        dd ?
  661.         defaultbase     dd ?
  662.         coff_hdr        dd ?
  663.         symbols_ptr     dd ?
  664.         symbols_num     dd ?
  665.         symbols_lim     dd ?
  666.         exports         dd ?   ;export table
  667.         name            rb 260
  668. ends
  669.  
  670. struct  HDLL
  671.         fd              dd ?   ;next object in list
  672.         bk              dd ?   ;prev object in list
  673.         pid             dd ?   ;owner id
  674.  
  675.         base            dd ?   ;mapped base
  676.         size            dd ?   ;mapped size
  677.         refcount        dd ?   ;reference counter for this process and this lib
  678.         parent          dd ?   ;DLLDESCR
  679. ends
  680.  
  681. struct DQ
  682.         lo dd ?
  683.         hi dd ?
  684. ends
  685.  
  686. struct e820entry
  687.         addr DQ ?
  688.         size DQ ?
  689.         type dd ?
  690. ends
  691.  
  692. RD_LOAD_FROM_FLOPPY = 1
  693. RD_LOAD_FROM_HD     = 2
  694. RD_LOAD_FROM_MEMORY = 3
  695. RD_LOAD_FROM_FORMAT = 4
  696. RD_LOAD_FROM_NONE   = 5
  697.  
  698. struct  boot_data
  699.         bpp             db ?    ; bits per pixel
  700.         pitch           dw ?    ; scanline length
  701.                         db ?
  702.                         dd ?
  703.         vesa_mode       dw ?
  704.         x_res           dw ?
  705.         y_res           dw ?
  706.                         dw ?
  707.                         dd ?
  708.         bank_switch     dd ?    ; Vesa 1.2 pm bank switch
  709.         lfb             dd ?    ; Vesa 2.0 LFB address
  710.         mtrr            db ?    ; 0 or 1: enable MTRR graphics acceleration
  711.         launcher_start  db ?    ; 0 or 1: start the first app (right now it's
  712.                                 ; LAUNCHER) after kernel is loaded
  713.         debug_print     db ?    ; if nonzero, duplicates debug output to the screen
  714.         dma             db ?    ; DMA write: 1=yes, 2=no
  715.         pci_data        rb 8
  716.                         rb 8
  717.         shutdown_type   db ?    ; see sysfn 18.9
  718.                         rb 15
  719.         apm_entry       dd ?    ; entry point of APM BIOS
  720.         apm_version     dw ?    ; BCD
  721.         apm_flags       dw ?
  722.                         rb 8
  723.         apm_code_32     dw ?
  724.         apm_code_16     dw ?
  725.         apm_data_16     dw ?
  726.         rd_load_from    db ?    ; Device to load ramdisk from, RD_LOAD_FROM_*
  727.                         db ?
  728.         kernel_restart  dw ?
  729.         sys_disk        dw ?    ; Device to mount on /sys/, see loader_doc.txt for details
  730.         acpi_rsdp       dd ?
  731.         syspath         rb 0x17
  732.         devicesdat_data dd ?
  733.         devicesdat_size dd ?
  734.         bios_hd_cnt     db ?    ; number of BIOS hard disks
  735.         bios_hd         rb 0x80 ; BIOS hard disks
  736.         memmap_block_cnt dd ?   ; available physical memory map: number of blocks
  737.         memmap_blocks   e820entry
  738.                         rb sizeof.e820entry * (MAX_MEMMAP_BLOCKS - 1)
  739. ends
  740.  
  741. virtual at BOOT_VARS
  742.         BOOT_LO boot_data
  743. end virtual
  744. virtual at OS_BASE + BOOT_VARS
  745.         BOOT boot_data
  746. end virtual
  747.  
  748. MAX_SCREEN_WIDTH  = 3840
  749. MAX_SCREEN_HEIGHT = 2160
  750.  
  751. struct  display_t
  752.         x               dd ?
  753.         y               dd ?
  754.         width           dd ?
  755.         height          dd ?
  756.         bits_per_pixel  dd ?
  757.         vrefresh        dd ?
  758.         current_lfb     dd ?
  759.         lfb_pitch       dd ?
  760.  
  761.         win_map_lock    RWSEM
  762.         win_map         dd ?
  763.         win_map_pitch   dd ?
  764.         win_map_size    dd ?
  765.  
  766.         modes           dd ?
  767.         ddev            dd ?
  768.         connector       dd ?
  769.         crtc            dd ?
  770.  
  771.         cr_list.next    dd ?
  772.         cr_list.prev    dd ?
  773.  
  774.         cursor          dd ?
  775.  
  776.         init_cursor     dd ?
  777.         select_cursor   dd ?
  778.         show_cursor     dd ?
  779.         move_cursor     dd ?
  780.         restore_cursor  dd ?
  781.         disable_mouse   dd ?
  782.         mask_seqno      dd ?
  783.         check_mouse     dd ?
  784.         check_m_pixel   dd ?
  785.  
  786.         bytes_per_pixel dd ?
  787. ends
  788.  
  789. struct  DISPMODE
  790.         width   dw ?
  791.         height  dw ?
  792.         bpp     dw ?
  793.         freq    dw ?
  794. ends
  795.  
  796.  
  797. struct  PCIDEV
  798.         bk              dd ?
  799.         fd              dd ?
  800.         vendor_device_id dd ?
  801.         class           dd ?
  802.         devfn           db ?
  803.         bus             db ?
  804.                         rb 2
  805.         owner           dd ? ; pointer to SRV or 0
  806. ends
  807.  
  808. struct  IDE_DATA
  809.         ProgrammingInterface dd ?
  810.         Interrupt            dw ?
  811.         RegsBaseAddres       dw ?
  812.         BAR0_val             dw ?
  813.         BAR1_val             dw ?
  814.         BAR2_val             dw ?
  815.         BAR3_val             dw ?
  816.         dma_hdd_channel_1    db ?
  817.         dma_hdd_channel_2    db ?
  818.         pcidev               dd ?       ; pointer to corresponding PCIDEV structure
  819. ends
  820.  
  821. struct  IDE_CACHE
  822.         pointer              dd ?
  823.         size                 dd ?   ; not use
  824.         data_pointer         dd ?
  825.         system_data_size     dd ?   ; not use
  826.         appl_data_size       dd ?   ; not use
  827.         system_data          dd ?
  828.         appl_data            dd ?
  829.         system_sad_size      dd ?
  830.         appl_sad_size        dd ?
  831.         search_start         dd ?
  832.         appl_search_start    dd ?
  833. ends
  834.  
  835. struct  IDE_DEVICE
  836.         UDMA_possible_modes  db ?
  837.         UDMA_set_mode        db ?
  838. ends
  839.  
  840. ; The following macro assume that we are on uniprocessor machine.
  841. ; Serious work is needed for multiprocessor machines.
  842. macro spin_lock_irqsave spinlock
  843. {
  844.         pushf
  845.         cli
  846. }
  847. macro spin_unlock_irqrestore spinlock
  848. {
  849.         popf
  850. }
  851. macro spin_lock_irq spinlock
  852. {
  853.         cli
  854. }
  855. macro spin_unlock_irq spinlock
  856. {
  857.         sti
  858. }
  859.  
  860. struct  MEM_STATE
  861.         mutex           MUTEX
  862.         smallmap        dd ?
  863.         treemap         dd ?
  864.         topsize         dd ?
  865.         top             dd ?
  866.         smallbins       rd 4*32
  867.         treebins        rd 32
  868. ends
  869.  
  870. struct  PG_DATA
  871.         mem_amount      dd ?
  872.         vesa_mem        dd ?
  873.         pages_count     dd ?
  874.         pages_free      dd ?
  875.         pages_faults    dd ?
  876.         pagemap_size    dd ?
  877.         kernel_pages    dd ?
  878.         kernel_tables   dd ?
  879.         sys_page_dir    dd ?
  880.         mutex           MUTEX
  881. ends
  882.  
  883. struct  SRV
  884.         srv_name        rb 16    ;ASCIIZ string
  885.         magic           dd ?     ;+0x10 ;'SRV '
  886.         size            dd ?     ;+0x14 ;size of structure SRV
  887.         fd              dd ?     ;+0x18 ;next SRV descriptor
  888.         bk              dd ?     ;+0x1C ;prev SRV descriptor
  889.         base            dd ?     ;+0x20 ;service base address
  890.         entry           dd ?     ;+0x24 ;service START function
  891.         srv_proc        dd ?     ;+0x28 ;user mode service handler
  892.         srv_proc_ex     dd ?     ;+0x2C ;kernel mode service handler
  893. ends
  894.  
  895. struct USBSRV
  896.         srv             SRV
  897.         usb_func        dd ?
  898. ends
  899.  
  900. struct USBFUNC
  901.         strucsize       dd ?
  902.         add_device      dd ?
  903.         device_disconnect dd ?
  904. ends
  905.  
  906. DRV_ENTRY    =  1
  907. DRV_EXIT     = -1
  908.  
  909. struct  COFF_HEADER
  910.         machine         dw ?
  911.         nSections       dw ?
  912.         DataTime        dd ?
  913.         pSymTable       dd ?
  914.         nSymbols        dd ?
  915.         optHeader       dw ?
  916.         flags           dw ?
  917. ends
  918.  
  919. struct  COFF_SECTION
  920.         Name            rb 8
  921.         VirtualSize     dd ?
  922.         VirtualAddress  dd ?
  923.         SizeOfRawData   dd ?
  924.         PtrRawData      dd ?
  925.         PtrReloc        dd ?
  926.         PtrLinenumbers  dd ?
  927.         NumReloc        dw ?
  928.         NumLinenum      dw ?
  929.         Characteristics dd ?
  930. ends
  931.  
  932. struct  COFF_RELOC
  933.         VirtualAddress  dd ?
  934.         SymIndex        dd ?
  935.         Type            dw ?
  936. ends
  937.  
  938. struct  COFF_SYM
  939.         Name            rb 8
  940.         Value           dd ?
  941.         SectionNumber   dw ?
  942.         Type            dw ?
  943.         StorageClass    db ?
  944.         NumAuxSymbols   db ?
  945. ends
  946.  
  947. struct  STRIPPED_PE_HEADER
  948.         Signature           dw ?
  949.         Characteristics     dw ?
  950.         AddressOfEntryPoint dd ?
  951.         ImageBase           dd ?
  952.         SectionAlignmentLog db ?
  953.         FileAlignmentLog    db ?
  954.         MajorOSVersion      db ?
  955.         MinorOSVersion      db ?
  956.         SizeOfImage         dd ?
  957.         SizeOfStackReserve  dd ?
  958.         SizeOfHeapReserve   dd ?
  959.         SizeOfHeaders       dd ?
  960.         Subsystem           db ?
  961.         NumberOfRvaAndSizes db ?
  962.         NumberOfSections    dw ?
  963. ends
  964. STRIPPED_PE_SIGNATURE = 0x4503 ; 'PE' xor 'S'
  965. SPE_DIRECTORY_IMPORT    = 0
  966. SPE_DIRECTORY_EXPORT    = 1
  967. SPE_DIRECTORY_BASERELOC = 2
  968.  
  969. struct  IOCTL
  970.         handle          dd ?
  971.         io_code         dd ?
  972.         input           dd ?
  973.         inp_size        dd ?
  974.         output          dd ?
  975.         out_size        dd ?
  976. ends
  977.  
  978. struct  IRQH
  979.         list            LHEAD
  980.         handler         dd ?   ;handler roututine
  981.         data            dd ?   ;user-specific data
  982.         num_ints        dd ?   ;how many times handled
  983. ends
  984.  
  985.