Subversion Repositories Kolibri OS

Rev

Rev 9917 | Rev 9930 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

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