Subversion Repositories Kolibri OS

Rev

Rev 9926 | Rev 9932 | 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: 9930 $
  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. background_window   = window_data + sizeof.WDATA
  227.  
  228. ;TASK_TABLE          = OS_BASE + 0x0003000
  229. ;CURRENT_TASK        = OS_BASE + 0x0003000
  230. ;TASK_COUNT          = OS_BASE + 0x0003004
  231. ;TASK_BASE           = OS_BASE + 0x0003010
  232. ;TASK_DATA           = OS_BASE + 0x0003020
  233. ;TASK_EVENT          = OS_BASE + 0x0003020
  234.  
  235. ;CDDataBuf           = OS_BASE + 0x0005000
  236.  
  237. ;unused                 0x6000 - 0x8fff
  238.  
  239. BOOT_VARS           = 0x9000
  240.  
  241. idts                = OS_BASE + 0x000B100
  242. WIN_STACK           = OS_BASE + 0x000C000
  243. WIN_POS             = OS_BASE + 0x000C400
  244. FDD_BUFF            = OS_BASE + 0x000D000     ;512
  245.  
  246. WIN_TEMP_XY         = OS_BASE + 0x000F300
  247. KEY_COUNT           = OS_BASE + 0x000F400
  248. KEY_BUFF            = OS_BASE + 0x000F401 ; 120*2 + 2*2 = 244 bytes, actually 255 bytes
  249.  
  250. BTN_COUNT           = OS_BASE + 0x000F500
  251. BTN_BUFF            = OS_BASE + 0x000F501
  252.  
  253.  
  254. BTN_ADDR            = OS_BASE + 0x000FE88
  255. MEM_AMOUNT          = OS_BASE + 0x000FE8C
  256.  
  257. SYS_SHUTDOWN        = OS_BASE + 0x000FF00
  258.  
  259.  
  260. TMP_STACK_TOP       = 0x007CC00
  261.  
  262. sys_proc            = OS_BASE + 0x007E000
  263.  
  264. SLOT_BASE           = OS_BASE + 0x0080000
  265.  
  266. VGABasePtr          = OS_BASE + 0x00A0000
  267.  
  268. virtual at            OS_BASE + 0x05FFF80
  269.   tss  TSS
  270. end virtual
  271.  
  272. HEAP_BASE           = OS_BASE + 0x0800000
  273. HEAP_MIN_SIZE       = 0x01000000
  274.  
  275. page_tabs           = 0xFDC00000
  276. app_page_tabs       = 0xFDC00000
  277. kernel_tabs         = page_tabs + (OS_BASE shr 10)   ;0xFDE00000
  278. master_tab          = page_tabs + (page_tabs shr 10) ;0xFDFF70000
  279.  
  280. LFB_BASE            = 0xFE000000
  281.  
  282. std_application_base_address   = 0
  283. RING0_STACK_SIZE    = 0x2000
  284.  
  285. REG_SS              = RING0_STACK_SIZE -  4
  286. REG_APP_ESP         = RING0_STACK_SIZE -  8
  287. REG_EFLAGS          = RING0_STACK_SIZE - 12
  288. REG_CS              = RING0_STACK_SIZE - 16
  289. REG_EIP             = RING0_STACK_SIZE - 20
  290. REG_EAX             = RING0_STACK_SIZE - 24
  291. REG_ECX             = RING0_STACK_SIZE - 28
  292. REG_EDX             = RING0_STACK_SIZE - 32
  293. REG_EBX             = RING0_STACK_SIZE - 36
  294. REG_ESP             = RING0_STACK_SIZE - 40  ;RING0_STACK_SIZE-20
  295. REG_EBP             = RING0_STACK_SIZE - 44
  296. REG_ESI             = RING0_STACK_SIZE - 48
  297. REG_EDI             = RING0_STACK_SIZE - 52
  298. REG_RET             = RING0_STACK_SIZE - 56  ;irq0.return
  299.  
  300.  
  301. PAGE_SIZE           = 4096
  302.  
  303. PG_UNMAP            = 0x000
  304. PG_READ             = 0x001
  305. PG_WRITE            = 0x002
  306. PG_USER             = 0x004
  307. PG_PCD              = 0x008
  308. PG_PWT              = 0x010
  309. PG_ACCESSED         = 0x020
  310. PG_DIRTY            = 0x040
  311. PG_PAT              = 0x080
  312. PG_GLOBAL           = 0x100
  313. PG_SHARED           = 0x200
  314.  
  315. PG_SWR              = 0x003 ; PG_WRITE + PG_READ
  316. PG_UR               = 0x005 ; PG_USER + PG_READ
  317. PG_UWR              = 0x007 ; PG_USER + PG_WRITE + PG_READ
  318. PG_NOCACHE          = 0x018 ; PG_PCD + PG_PWT
  319.  
  320. PDE_LARGE           = 0x080
  321.  
  322. MEM_WB              = 6     ; write-back memory
  323. MEM_WC              = 1     ; write combined memory
  324. MEM_UC              = 0     ; uncached memory
  325.  
  326. PAT_WB              = 0x000
  327. PAT_WC              = 0x008
  328. PAT_UCM             = 0x010
  329. PAT_UC              = 0x018
  330.  
  331. PAT_TYPE_UC         = 0
  332. PAT_TYPE_WC         = 1
  333. PAT_TYPE_WB         = 6
  334. PAT_TYPE_UCM        = 7
  335.  
  336. PAT_VALUE           = 0x00070106; (UC<<24)|(UCM<<16)|(WC<<8)|WB
  337.  
  338. MAX_MEMMAP_BLOCKS   = 32
  339.  
  340. EVENT_REDRAW       = 0x00000001
  341. EVENT_KEY          = 0x00000002
  342. EVENT_BUTTON       = 0x00000004
  343. EVENT_BACKGROUND   = 0x00000010
  344. EVENT_MOUSE        = 0x00000020
  345. EVENT_IPC          = 0x00000040
  346. EVENT_NETWORK      = 0x00000080
  347. EVENT_DEBUG        = 0x00000100
  348. EVENT_NETWORK2     = 0x00000200
  349. EVENT_EXTENDED     = 0x00000400
  350.  
  351. EVM_MOUSE_FILTER  = 0x80000000  ; see in macros.inc for apps
  352. EVM_CURSOR_FILTER = 0x40000000
  353.  
  354. EV_INTR            = 1
  355.  
  356. STDIN_FILENO       = 0
  357. STDOUT_FILENO      = 1
  358. STDERR_FILENO      = 2
  359.  
  360. SYSTEM_SHUTDOWN    = 2
  361. SYSTEM_REBOOT      = 3
  362. SYSTEM_RESTART     = 4
  363.  
  364. BLIT_CLIENT_RELATIVE = 0x20000000
  365.  
  366. struct SYSCALL_STACK
  367.         eip     dd ?    ;  +0
  368.         edi     dd ?    ;  +4
  369.         esi     dd ?    ;  +8
  370.         ebp     dd ?    ; +12
  371.         esp     dd ?    ; +16
  372.         ebx     dd ?    ; +20
  373.         edx     dd ?    ; +24
  374.         ecx     dd ?    ; +28
  375.         eax     dd ?    ; +32
  376. ends
  377.  
  378. struct  LHEAD
  379.         next            dd ?   ;next object in list
  380.         prev            dd ?   ;prev object in list
  381. ends
  382.  
  383. struct  MUTEX_WAITER
  384.         list    LHEAD
  385.         task    dd ?
  386.         type    dd ?
  387. ends
  388.  
  389. struct  MUTEX
  390.         wait_list       LHEAD
  391.         count           dd ?
  392. ends
  393.  
  394. struct  RWSEM
  395.         wait_list       LHEAD
  396.         count           dd ?
  397. ends
  398.  
  399. struct  FUTEX
  400.         list            LHEAD
  401.         magic           dd ?
  402.         handle          dd ?
  403.         destroy         dd ?
  404.  
  405.         wait_list       LHEAD
  406.         pointer         dd ?
  407.         flags           dd ?
  408. ends
  409.  
  410. FUTEX_INIT      = 0
  411. FUTEX_DESTROY   = 1
  412. FUTEX_WAIT      = 2
  413. FUTEX_WAKE      = 3
  414.  
  415. struct  FILED
  416.         list            LHEAD
  417.         magic           rd 1
  418.         handle          rd 1
  419.         destroy         rd 1
  420.         mode            rd 1
  421.         file            rd 1
  422. ends
  423.  
  424. struct  PIPE
  425.         pipe_ops        rd 1
  426.         buffer          rd 1
  427.         readers         rd 1
  428.         writers         rd 1
  429.  
  430.         pipe_lock       MUTEX
  431.         count           rd 1
  432.  
  433.         read_end        rd 1
  434.         write_end       rd 1
  435.         rlist           LHEAD
  436.         wlist           LHEAD
  437. ends
  438.  
  439. struct  PROC
  440.         list            LHEAD
  441.         thr_list        LHEAD
  442.         heap_lock       MUTEX
  443.         heap_base       rd 1
  444.         heap_top        rd 1
  445.         mem_used        rd 1
  446.         dlls_list_ptr   rd 1
  447.         pdt_0_phys      rd 1
  448.         pdt_1_phys      rd 1
  449.         io_map_0        rd 1
  450.         io_map_1        rd 1
  451.  
  452.         ht_lock         rd 1
  453.         ht_free         rd 1                ;htab[0] stdin
  454.         ht_next         rd 1                ;htab[1] stdout
  455.         htab            rd 1024-PROC.htab/4 ;htab[2] stderr
  456.         pdt_0           rd 1024
  457. ends
  458.  
  459. struct  DBG_REGS
  460.         dr0             dd ?
  461.         dr1             dd ?
  462.         dr2             dd ?
  463.         dr3             dd ?
  464.         dr7             dd ?
  465. ends
  466.  
  467. struct  POINT
  468.         x       dd ?
  469.         y       dd ?
  470. ends
  471.  
  472. struct  RECT
  473.         left    dd ?
  474.         top     dd ?
  475.         right   dd ?
  476.         bottom  dd ?
  477. ends
  478.  
  479. struct  BOX
  480.         left    dd ?
  481.         top     dd ?
  482.         width   dd ?
  483.         height  dd ?
  484. ends
  485.  
  486. ; Fields, marked as R now not used, but will be used soon,
  487. ; when legacy TASKDATA structure will be deleted
  488. struct  APPDATA
  489.         app_name        rb 11
  490.                         rb 5
  491.  
  492.         list            LHEAD           ;+16
  493.         process         dd ?            ;+24
  494.         fpu_state       dd ?            ;+28
  495.         exc_handler     dd ?            ;+32
  496.         except_mask     dd ?            ;+36
  497.         pl0_stack       dd ?            ;+40
  498.                         dd ?            ;+44
  499.         fd_ev           dd ?            ;+48
  500.         bk_ev           dd ?            ;+52
  501.         fd_obj          dd ?            ;+56
  502.         bk_obj          dd ?            ;+60
  503.         saved_esp       dd ?            ;+64
  504.         io_map          rd 2            ;+68
  505.         dbg_state       dd ?            ;+76
  506.         cur_dir         dd ?            ;+80   ; directory this thread
  507.         wait_timeout    dd ?            ;+84
  508.         saved_esp0      dd ?            ;+88
  509.         wait_begin      dd ?            ;+92   +++
  510.         wait_test       dd ?            ;+96   +++
  511.         wait_param      dd ?            ;+100  +++
  512.         tls_base        dd ?            ;+104
  513.         event_mask      dd ?            ;+108   stores event types allowed for task
  514.         tid             dd ?            ;+112   thread id
  515.                         dd ?            ;+116
  516.                         dd ?            ;+120
  517.         state           db ?            ;+124   thread state
  518.         wnd_number      db ?            ;+125
  519.                         dw ?            ;+126
  520.         window          dd ?            ;+128   ptr WDATA
  521.                         dd ?            ;+132
  522.                         dd ?            ;+136
  523.         counter_sum     dd ?            ;+140  ; R
  524.                         rd 4            ;+144
  525.         ipc_start       dd ?            ;+160
  526.         ipc_size        dd ?            ;+164
  527.         occurred_events dd ?            ;+168  ; mask which accumulates occurred events
  528.         debugger_slot   dd ?            ;+172  ; index in SLOT_BASE array
  529.         terminate_protection dd ?       ;+176
  530.         keyboard_mode   db ?            ;+180
  531.                         rb 3
  532.         exec_params     dd ?            ;+184
  533.         dbg_event_mem   dd ?            ;+188
  534.         dbg_regs        DBG_REGS        ;+192
  535.                         dd ?            ;+212
  536.                         rd 4            ;+216
  537.         priority        dd ?            ;+232
  538.         in_schedule     LHEAD           ;+236
  539.         counter_add     dd ?            ;+244  ; R
  540.         cpu_usage       dd ?            ;+248  ; R
  541.                         dd ?            ;+252  ; temporary place to save cursor
  542. ends
  543.  
  544. assert sizeof.APPDATA = 256
  545.  
  546. APP_OBJ_OFFSET  = 48
  547. APP_EV_OFFSET   = 40
  548.  
  549. ; Note: in future TASKDATA will be merged into APPDATA
  550. ;struct  TASKDATA
  551. ;        event_mask      dd ? ;+0 mask which stores event types allowed for task
  552. ;        pid             dd ? ;+4
  553. ;                        dw ? ;+8
  554. ;        state           db ? ;+10
  555. ;                        db ? ;+11
  556. ;                        dw ? ;+12
  557. ;        wnd_number      db ? ;+14
  558. ;                        db ? ;+15
  559. ;        mem_start       dd ? ;+16
  560. ;        counter_sum     dd ? ;+20
  561. ;        counter_add     dd ? ;+24
  562. ;        cpu_usage       dd ? ;+28
  563. ;ends
  564.  
  565. ; Thread states:
  566. TSTATE_RUNNING        = 0
  567. TSTATE_RUN_SUSPENDED  = 1
  568. TSTATE_WAIT_SUSPENDED = 2
  569. TSTATE_ZOMBIE         = 3
  570. TSTATE_TERMINATING    = 4
  571. TSTATE_WAITING        = 5
  572. TSTATE_FREE           = 9
  573.  
  574. ; Window constants:
  575. WSTATE_NORMAL    = 00000000b
  576. WSTATE_MAXIMIZED = 00000001b
  577. WSTATE_MINIMIZED = 00000010b
  578. WSTATE_ROLLEDUP  = 00000100b
  579. WSTATE_USED      = 10000000b
  580.  
  581. ; fl_redraw
  582. WSTATE_REDRAW    = 00000001b
  583. WSTATE_WNDDRAWN  = 00000010b
  584.  
  585. WSTYLE_HASCAPTION     = 00010000b
  586. WSTYLE_CLIENTRELATIVE = 00100000b
  587.  
  588. ZPOS_DESKTOP            = -2
  589. ZPOS_ALWAYS_BACK        = -1
  590. ZPOS_NORMAL             = 0
  591. ZPOS_ALWAYS_TOP         = 1     ;ZPOS_ALWAYS_TOP is always last and has max number!
  592.  
  593. ; Window structure:
  594. struct  WDATA
  595.         box             BOX
  596.         cl_workarea     dd ?
  597.         cl_titlebar     dd ?
  598.         cl_frames       dd ?
  599.         z_modif         db ?
  600.         fl_wstate       db ?
  601.         fl_wdrawn       db ?
  602.         fl_redraw       db ?
  603.         clientbox       BOX
  604.         shape           dd ?
  605.         shape_scale     dd ?
  606.         caption         dd ?
  607.         captionEncoding db ?
  608.                         rb 3
  609.         saved_box       BOX
  610.         cursor          dd ?
  611.         temp_cursor     dd ?
  612.         draw_bgr_x      dd ?
  613.         draw_bgr_y      dd ?
  614.         draw_data       RECT
  615.         thread          dd ? ; prt APPDATA
  616.                         rb 64 - 16 - 4*2 - 4*2 - 4 - 16
  617. ends
  618.  
  619. label WDATA.fl_wstyle byte at WDATA.cl_workarea + 3
  620.  
  621. assert sizeof.WDATA = 128
  622.  
  623. struct  SYS_VARS
  624.         bpp             dd ?
  625.         scanline        dd ?
  626.         vesa_mode       dd ?
  627.         x_res           dd ?
  628.         y_res           dd ?
  629. ends
  630.  
  631. struct  APPOBJ                  ; common object header
  632.         magic           dd ?    ;
  633.         destroy         dd ?    ; internal destructor
  634.         fd              dd ?    ; next object in list
  635.         bk              dd ?    ; prev object in list
  636.         pid             dd ?    ; owner id
  637. ends
  638.  
  639. struct  CURSOR          APPOBJ
  640.         base            dd ?   ;allocated memory
  641.         hot_x           dd ?   ;hotspot coords
  642.         hot_y           dd ?
  643.  
  644.         list_next       dd ?   ;next cursor in cursor list
  645.         list_prev       dd ?   ;prev cursor in cursor list
  646.         dev_obj         dd ?   ;device depended data
  647. ends
  648.  
  649.  
  650. struct  EVENT           APPOBJ
  651.         id              dd ?   ;event uid
  652.         state           dd ?   ;internal flags
  653.         code            dd ?
  654.                         rd 5
  655. ends
  656.  
  657.  
  658. struct  SMEM
  659.         bk              dd ?
  660.         fd              dd ?    ;+4
  661.         base            dd ?    ;+8
  662.         size            dd ?    ;+12
  663.         access          dd ?    ;+16
  664.         refcount        dd ?    ;+20
  665.         name            rb 32   ;+24
  666. ends
  667.  
  668. struct  SMAP            APPOBJ
  669.         base            dd ?   ;mapped base
  670.         parent          dd ?   ;SMEM
  671. ends
  672.  
  673. struct  DLLDESCR
  674.         bk              dd ?
  675.         fd              dd ?    ;+4
  676.         data            dd ?    ;+8
  677.         size            dd ?    ;+12
  678.         timestamp       dq ?
  679.         refcount        dd ?
  680.         defaultbase     dd ?
  681.         coff_hdr        dd ?
  682.         symbols_ptr     dd ?
  683.         symbols_num     dd ?
  684.         symbols_lim     dd ?
  685.         exports         dd ?   ;export table
  686.         name            rb 260
  687. ends
  688.  
  689. struct  HDLL
  690.         fd              dd ?   ;next object in list
  691.         bk              dd ?   ;prev object in list
  692.         pid             dd ?   ;owner id
  693.  
  694.         base            dd ?   ;mapped base
  695.         size            dd ?   ;mapped size
  696.         refcount        dd ?   ;reference counter for this process and this lib
  697.         parent          dd ?   ;DLLDESCR
  698. ends
  699.  
  700. struct DQ
  701.         union
  702.                 lo    dd ?
  703.                 hi_be dd ?      ; big endian
  704.         ends
  705.         union
  706.                 hi    dd ?
  707.                 lo_be dd ?
  708.         ends
  709. ends
  710.  
  711. struct e820entry
  712.         addr DQ ?
  713.         size DQ ?
  714.         type dd ?
  715. ends
  716.  
  717. RD_LOAD_FROM_FLOPPY = 1
  718. RD_LOAD_FROM_HD     = 2
  719. RD_LOAD_FROM_MEMORY = 3
  720. RD_LOAD_FROM_FORMAT = 4
  721. RD_LOAD_FROM_NONE   = 5
  722.  
  723. struct boot_pci_data
  724.         access_mechanism db ?
  725.         last_bus         db ?
  726.         version          dw ?   ; bcd minor, then major
  727.         pm_entry         dd ?   ; physical address of protected-mode entry point
  728. ends
  729.  
  730. struct  boot_data
  731.         bpp             db ?    ; bits per pixel
  732.         pitch           dw ?    ; scanline length
  733.                         db ?
  734.                         dd ?
  735.         vesa_mode       dw ?
  736.         x_res           dw ?
  737.         y_res           dw ?
  738.                         dw ?
  739.                         dd ?
  740.         bank_switch     dd ?    ; Vesa 1.2 pm bank switch
  741.         lfb             dd ?    ; Vesa 2.0 LFB address
  742.         mtrr            db ?    ; 0 or 1: enable MTRR graphics acceleration
  743.         launcher_start  db ?    ; 0 or 1: start the first app (right now it's
  744.                                 ; LAUNCHER) after kernel is loaded
  745.         debug_print     db ?    ; if nonzero, duplicates debug output to the screen
  746.         dma             db ?    ; DMA write: 1=yes, 2=no
  747.         pci_data        boot_pci_data
  748.                         rb 8
  749.         shutdown_type   db ?    ; see sysfn 18.9
  750.                         rb 15
  751.         apm_entry       dd ?    ; entry point of APM BIOS
  752.         apm_version     dw ?    ; BCD
  753.         apm_flags       dw ?
  754.                         rb 8
  755.         apm_code_32     dw ?
  756.         apm_code_16     dw ?
  757.         apm_data_16     dw ?
  758.         rd_load_from    db ?    ; Device to load ramdisk from, RD_LOAD_FROM_*
  759.                         db ?
  760.         kernel_restart  dw ?
  761.         sys_disk        dw ?    ; Device to mount on /sys/, see loader_doc.txt for details
  762.         acpi_rsdp       dd ?
  763.         syspath         rb 0x17
  764.         devicesdat_data dd ?
  765.         devicesdat_size dd ?
  766.         bios_hd_cnt     db ?    ; number of BIOS hard disks
  767.         bios_hd         rb 0x80 ; BIOS hard disks
  768.         memmap_block_cnt dd ?   ; available physical memory map: number of blocks
  769.         memmap_blocks   e820entry
  770.                         rb sizeof.e820entry * (MAX_MEMMAP_BLOCKS - 1)
  771. ends
  772.  
  773. virtual at BOOT_VARS
  774.         BOOT_LO boot_data
  775. end virtual
  776. virtual at OS_BASE + BOOT_VARS
  777.         BOOT boot_data
  778. end virtual
  779.  
  780. MAX_SCREEN_WIDTH  = 3840
  781. MAX_SCREEN_HEIGHT = 2160
  782.  
  783. struct  display_t
  784.         x               dd ?
  785.         y               dd ?
  786.         width           dd ?
  787.         height          dd ?
  788.         bits_per_pixel  dd ?
  789.         vrefresh        dd ?
  790.         current_lfb     dd ?
  791.         lfb_pitch       dd ?
  792.  
  793.         win_map_lock    RWSEM
  794.         win_map         dd ?
  795.         win_map_pitch   dd ?
  796.         win_map_size    dd ?
  797.  
  798.         modes           dd ?
  799.         ddev            dd ?
  800.         connector       dd ?
  801.         crtc            dd ?
  802.  
  803.         cr_list.next    dd ?
  804.         cr_list.prev    dd ?
  805.  
  806.         cursor          dd ?
  807.  
  808.         init_cursor     dd ?
  809.         select_cursor   dd ?
  810.         show_cursor     dd ?
  811.         move_cursor     dd ?
  812.         restore_cursor  dd ?
  813.         disable_mouse   dd ?
  814.         mask_seqno      dd ?
  815.         check_mouse     dd ?
  816.         check_m_pixel   dd ?
  817.  
  818.         bytes_per_pixel dd ?
  819. ends
  820.  
  821. struct  DISPMODE
  822.         width   dw ?
  823.         height  dw ?
  824.         bpp     dw ?
  825.         freq    dw ?
  826. ends
  827.  
  828.  
  829. struct  PCIDEV
  830.         bk              dd ?
  831.         fd              dd ?
  832.         vendor_device_id dd ?
  833.         class           dd ?
  834.         devfn           db ?
  835.         bus             db ?
  836.                         rb 2
  837.         owner           dd ? ; pointer to SRV or 0
  838. ends
  839.  
  840. struct  IDE_DATA
  841.         ProgrammingInterface dd ?
  842.         Interrupt            dw ?
  843.         RegsBaseAddres       dw ?
  844.         BAR0_val             dw ?
  845.         BAR1_val             dw ?
  846.         BAR2_val             dw ?
  847.         BAR3_val             dw ?
  848.         dma_hdd_channel_1    db ?
  849.         dma_hdd_channel_2    db ?
  850.         pcidev               dd ?       ; pointer to corresponding PCIDEV structure
  851. ends
  852.  
  853. struct  IDE_CACHE
  854.         pointer              dd ?
  855.         size                 dd ?   ; not use
  856.         data_pointer         dd ?
  857.         system_data_size     dd ?   ; not use
  858.         appl_data_size       dd ?   ; not use
  859.         system_data          dd ?
  860.         appl_data            dd ?
  861.         system_sad_size      dd ?
  862.         appl_sad_size        dd ?
  863.         search_start         dd ?
  864.         appl_search_start    dd ?
  865. ends
  866.  
  867. struct  IDE_DEVICE
  868.         UDMA_possible_modes  db ?
  869.         UDMA_set_mode        db ?
  870. ends
  871.  
  872. ; The following macro assume that we are on uniprocessor machine.
  873. ; Serious work is needed for multiprocessor machines.
  874. macro spin_lock_irqsave spinlock
  875. {
  876.         pushf
  877.         cli
  878. }
  879. macro spin_unlock_irqrestore spinlock
  880. {
  881.         popf
  882. }
  883. macro spin_lock_irq spinlock
  884. {
  885.         cli
  886. }
  887. macro spin_unlock_irq spinlock
  888. {
  889.         sti
  890. }
  891.  
  892. struct  MEM_STATE
  893.         mutex           MUTEX
  894.         smallmap        dd ?
  895.         treemap         dd ?
  896.         topsize         dd ?
  897.         top             dd ?
  898.         smallbins       rd 4*32
  899.         treebins        rd 32
  900. ends
  901.  
  902. struct  PG_DATA
  903.         mem_amount      dd ?
  904.         vesa_mem        dd ?
  905.         pages_count     dd ?
  906.         pages_free      dd ?
  907.         pages_faults    dd ?
  908.         pagemap_size    dd ?
  909.         kernel_pages    dd ?
  910.         kernel_tables   dd ?
  911.         sys_page_dir    dd ?
  912.         mutex           MUTEX
  913. ends
  914.  
  915. struct  SRV
  916.         srv_name        rb 16    ;ASCIIZ string
  917.         magic           dd ?     ;+0x10 ;'SRV '
  918.         size            dd ?     ;+0x14 ;size of structure SRV
  919.         fd              dd ?     ;+0x18 ;next SRV descriptor
  920.         bk              dd ?     ;+0x1C ;prev SRV descriptor
  921.         base            dd ?     ;+0x20 ;service base address
  922.         entry           dd ?     ;+0x24 ;service START function
  923.         srv_proc        dd ?     ;+0x28 ;user mode service handler
  924.         srv_proc_ex     dd ?     ;+0x2C ;kernel mode service handler
  925. ends
  926.  
  927. struct USBSRV
  928.         srv             SRV
  929.         usb_func        dd ?
  930. ends
  931.  
  932. struct USBFUNC
  933.         strucsize       dd ?
  934.         add_device      dd ?
  935.         device_disconnect dd ?
  936. ends
  937.  
  938. DRV_ENTRY    =  1
  939. DRV_EXIT     = -1
  940.  
  941. struct  COFF_HEADER
  942.         machine         dw ?
  943.         nSections       dw ?
  944.         DataTime        dd ?
  945.         pSymTable       dd ?
  946.         nSymbols        dd ?
  947.         optHeader       dw ?
  948.         flags           dw ?
  949. ends
  950.  
  951. struct  COFF_SECTION
  952.         Name            rb 8
  953.         VirtualSize     dd ?
  954.         VirtualAddress  dd ?
  955.         SizeOfRawData   dd ?
  956.         PtrRawData      dd ?
  957.         PtrReloc        dd ?
  958.         PtrLinenumbers  dd ?
  959.         NumReloc        dw ?
  960.         NumLinenum      dw ?
  961.         Characteristics dd ?
  962. ends
  963.  
  964. struct  COFF_RELOC
  965.         VirtualAddress  dd ?
  966.         SymIndex        dd ?
  967.         Type            dw ?
  968. ends
  969.  
  970. struct  COFF_SYM
  971.         Name            rb 8
  972.         Value           dd ?
  973.         SectionNumber   dw ?
  974.         Type            dw ?
  975.         StorageClass    db ?
  976.         NumAuxSymbols   db ?
  977. ends
  978.  
  979. struct  STRIPPED_PE_HEADER
  980.         Signature           dw ?
  981.         Characteristics     dw ?
  982.         AddressOfEntryPoint dd ?
  983.         ImageBase           dd ?
  984.         SectionAlignmentLog db ?
  985.         FileAlignmentLog    db ?
  986.         MajorOSVersion      db ?
  987.         MinorOSVersion      db ?
  988.         SizeOfImage         dd ?
  989.         SizeOfStackReserve  dd ?
  990.         SizeOfHeapReserve   dd ?
  991.         SizeOfHeaders       dd ?
  992.         Subsystem           db ?
  993.         NumberOfRvaAndSizes db ?
  994.         NumberOfSections    dw ?
  995. ends
  996. STRIPPED_PE_SIGNATURE = 0x4503 ; 'PE' xor 'S'
  997. SPE_DIRECTORY_IMPORT    = 0
  998. SPE_DIRECTORY_EXPORT    = 1
  999. SPE_DIRECTORY_BASERELOC = 2
  1000.  
  1001. struct  IOCTL
  1002.         handle          dd ?
  1003.         io_code         dd ?
  1004.         input           dd ?
  1005.         inp_size        dd ?
  1006.         output          dd ?
  1007.         out_size        dd ?
  1008. ends
  1009.  
  1010. struct  IRQH
  1011.         list            LHEAD
  1012.         handler         dd ?   ;handler roututine
  1013.         data            dd ?   ;user-specific data
  1014.         num_ints        dd ?   ;how many times handled
  1015. ends
  1016.  
  1017.