Subversion Repositories Kolibri OS

Rev

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

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