Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

516 lines
13 KiB

  1. ;++
  2. ;
  3. ; Module name
  4. ;
  5. ; su.asm
  6. ;
  7. ; Author
  8. ;
  9. ; Thomas Parslow (tomp) Mar-1-90
  10. ;
  11. ; Description
  12. ;
  13. ; Static data for Startup module for the 386 NT OS loader. The gdt
  14. ; idt, and double fault tss are statically defined here. Also most
  15. ; of the zero init static data is defined here because the SU module
  16. ; must have a zero length .bss section.
  17. ;
  18. ;
  19. ;--
  20. .386p
  21. SU_DATAMODULE equ 1
  22. include su.inc
  23. include memmap.inc
  24. _DATA SEGMENT PARA USE16 PUBLIC 'DATA'
  25. ;
  26. ; Global Descriptor Table
  27. ;
  28. ; Note, the SuCode and SuData segments must have limits of 64k in
  29. ; order for the mode switch code to work.
  30. ;
  31. public _Beginx86Relocation
  32. public _GDT
  33. _Beginx86Relocation equ $
  34. _GDT equ $
  35. ;;;
  36. ;;; Lim 0-15, Base0-15,Base 16-23, LimAcc,
  37. ;;;
  38. ;
  39. ; Selector 00h - Null selector - unsused
  40. ;
  41. GDTDesc <00000h, 00000h, 000h, 000h, 000h, 000h>
  42. ;
  43. ; Selector 08h KeCodeSelector - kernel code segment : FLAT 4gig limit
  44. ;
  45. GDTDesc <0ffffh, 00000h, 000h, 09ah, 0cfh, 000h>
  46. ;
  47. ; Selector 10h - KeDataSelector - kernel data segment : FLAT 4gig limit
  48. ;
  49. GDTDesc <0ffffh, 00000h, 000h, 092h, 0cfh, 000h>
  50. ;
  51. ; Selector 18h - UsCodeSelector - User code segment : FLAT 2gig limit
  52. ;
  53. GDTDesc <0ffffh, 00000h, 000h, 0fah, 0cfh, 000h>
  54. ;
  55. ; Selector 20h - UsDataSelector - User data segment : FLAT 2gig limit
  56. ;
  57. GDTDesc <0ffffh, 00000h, 000h, 0f2h, 0cfh, 000h>
  58. ;
  59. ; Selector 28h - TSS_Selector - Kernels TSS
  60. ;
  61. GDTDesc <EndTssKernel - _TssKernel - 1, offset _TEXT:_TssKernel, \
  62. 002h, 089h, 000h, 000h> ; TSS
  63. ;
  64. ; Selector 30h - PCR_Selector - Master Boot Processor's PCR segment
  65. ; This is actually edited later in BlSetupForNt in order to
  66. ; point to a page located at a high virtual address.
  67. ;
  68. GDTDesc <01h, 00000h, 000h, 092h, 0c0h, 000h>
  69. ;
  70. ; Selector 38h - TEP_Selector - Thread Environment
  71. ;
  72. GDTDesc <0fffh, 00000h, 000h, 0f3h, 040h, 000h>
  73. ;
  74. ; Selector 40 - BDA_SAelector - Bios Data Area near-clone
  75. ;
  76. GDTDesc <0ffffh, 00400h, 000h, 0f2h, 000h, 000h>
  77. ;
  78. ; Selector 48h - LdtDescriptor - used to load an ldt
  79. ; (Gets set at Ldt set and process switch by the kernel)
  80. ;
  81. GDTDesc <00000h, 00000h, 000h, 000h, 000h, 000h>
  82. ;
  83. ; Selector 50h - DblFltTskSelector - Double Fault TSS
  84. ;
  85. GDTDesc <EndTssDblFault32 - _TssDblFault32 - 1, offset _TEXT:_TssDblFault32, \
  86. 002h, 089h, 000h, 000h> ;
  87. ;
  88. ; Selector 58h - SuCodeSelector - Startup module's code segment
  89. ;
  90. GDTDesc <0ffffh, 00000h, 002h, 09ah, 000h, 000h>
  91. ;
  92. ; Selector 60h - SuDataSelector - Startup module's data segment
  93. ;
  94. GDTDesc <0ffffh, offset _TEXT:DGROUP, 002h, 092h, 000h, 000h>
  95. ;
  96. ; Selector 68h - VideoSelector - Video display buffer
  97. ;
  98. GDTDesc <03fffh, 08000h, 00bh, 092h, 000h, 000h>
  99. ;
  100. ; Selector 70h - GDT_AliasSelector - GDT Alias Selector
  101. ;
  102. GDTDesc <EndGDT - _GDT - 1, 7000h, 0ffh, 092h, 000h,0ffh>
  103. ; Debug selectors : CURRENTLY NOT USED
  104. GDTDesc <0ffffh, 00000h, 040h, 09ah, 000h, 080h> ; 70 Debug Code
  105. GDTDesc <0ffffh, 00000h, 040h, 092h, 000h, 080h> ; 78 Debug Data
  106. GDTDesc <00000h, 00000h, 000h, 092h, 000h, 000h> ; 80 Debug Use
  107. GDTDesc <00000h, 00000h, 000h, 000h, 000h, 000h> ; 88 Spare
  108. DEFINED_GDT_ENTRIES equ ($ - _GDT) / size GDTDesc
  109. dq ((1024 / size GDTDesc) - DEFINED_GDT_ENTRIES) DUP(0)
  110. EndGDT equ $
  111. GDT_SIZE equ (EndGDT - _GDT)
  112. ;;
  113. ;; Interrupt Descriptor Table
  114. ;;
  115. public _IDT
  116. align 16
  117. _IDT equ $
  118. TrapDesc <offset Trap0, KeCodeSelector, 8f00h, 0>
  119. TrapDesc <offset Trap1, SuCodeSelector, 8f00h, 0>
  120. TrapDesc <offset Trap2, SuCodeSelector, 8f00h, 0>
  121. TrapDesc <offset Trap3, SuCodeSelector, 8f00h, 0>
  122. TrapDesc <offset Trap4, SuCodeSelector, 8f00h, 0>
  123. TrapDesc <offset Trap5, SuCodeSelector, 8f00h, 0>
  124. TrapDesc <offset Trap6, SuCodeSelector, 8f00h, 0>
  125. TrapDesc <offset Trap7, SuCodeSelector, 8f00h, 0>
  126. TrapDesc <offset Trap8, SuCodeSelector, 8f00h, 0>
  127. ;TrapDesc <offset Trap8, DblFltTskSelector,8500h, 0>
  128. TrapDesc <offset Trap9, SuCodeSelector, 8f00h, 0>
  129. TrapDesc <offset TrapA, SuCodeSelector, 8f00h, 0>
  130. TrapDesc <offset TrapB, SuCodeSelector, 8f00h, 0>
  131. TrapDesc <offset TrapC, SuCodeSelector, 8f00h, 0>
  132. TrapDesc <offset TrapD, SuCodeSelector, 8f00h, 0>
  133. TrapDesc <offset TrapE, SuCodeSelector, 8f00h, 0>
  134. TrapDesc <offset TrapF, SuCodeSelector, 8f00h, 0>
  135. DEFINED_IDT_ENTRIES equ ($ - _IDT) / size TrapDesc
  136. dq (IDT_ENTRIES - DEFINED_IDT_ENTRIES) DUP(0)
  137. EndIDT equ $
  138. public _Endx86Relocation
  139. _Endx86Relocation equ $
  140. ;
  141. ; disk-base table. We copy it from the ROM to here so we can patch the
  142. ; last sector number. This lets us access both 5.25" and 3.5" drives.
  143. ;
  144. Public _DiskBaseTable
  145. _DiskBaseTable equ $
  146. SpecifyBytes dw 0
  147. WaitTime db 0
  148. SectorLength db 0
  149. LastSector db 0
  150. SecGapLength db 0
  151. DataTransfer db 0
  152. TrackGapLength db 0
  153. DataValue db 0
  154. HeadSettle db 0
  155. StartupTime db 0
  156. Public _RomDiskBasePointer
  157. _RomDiskBasePointer dd 0
  158. ;
  159. ; Enhanced Disk Drive Spec. Disk Address Packet
  160. ;
  161. Public _EddsAddressPacket
  162. _EddsAddressPacket equ $
  163. PacketSize db 10h
  164. Reserved1 db 0
  165. Blocks2Xfer dw 0
  166. XferBuf dd 0
  167. LBALow dd 0
  168. LBAHigh dd 0
  169. ;
  170. ; Task State Segment for Double Fault Handler
  171. ;
  172. Public _TssDblFault
  173. align 16
  174. _TssDblFault equ $
  175. dw 0 ;link
  176. dw offset _DATA:DblFaultStack
  177. dw SuDataSelector
  178. dd 0 ; ring1 ss:sp
  179. dd 0 ; ring2 ss:sp
  180. dw offset _TEXT:Trap8
  181. dw 0 ; flags
  182. dw 0 ; ax
  183. dw 0 ; cx
  184. dw 0 ; dx
  185. dw 0 ; bx
  186. dw offset _DATA:DblFaultStack ; sp
  187. dw 0 ; bp
  188. dw 0 ; si
  189. dw 0 ; di
  190. dw SuDataSelector ; es
  191. dw SuCodeSelector ; cs
  192. dw SuDataSelector ; ss
  193. dw SuDataSelector ; ds
  194. dw 0 ; ldt selector
  195. dw 0
  196. EndTssDblFault equ $
  197. _TssDblFault32 equ $
  198. dd 0 ;link
  199. dd offset _DATA:DblFaultStack
  200. dd SuDataSelector
  201. dd 0 ; ring1 esp
  202. dd 0 ; ring1 ss
  203. dd 0 ; ring2 esp
  204. dd 0 ; ring2 ss
  205. dd PD_PHYSICAL_ADDRESS
  206. dd offset _TEXT:Trap8
  207. dd 0 ; eflags
  208. dd 0 ; eax
  209. dd 0 ; ecx
  210. dd 0 ; edx
  211. dd 0 ; ebx
  212. dd offset _DATA:DblFaultStack ; sp
  213. dd 0 ; bp
  214. dd 0 ; si
  215. dd 0 ; di
  216. dd SuDataSelector ; es
  217. dd SuCodeSelector ; cs
  218. dd SuDataSelector ; ss
  219. dd SuDataSelector ; ds
  220. dd 0 ;fs
  221. dd 0 ;gs
  222. dd 0 ; ldt selector
  223. dd 0 ; i/o map
  224. dd 0 ;
  225. dd 0 ;
  226. EndTssDblFault32 equ $
  227. ;
  228. ; Stack for Double Fault Handler Task
  229. ;
  230. public _FileStart
  231. _FileStart dd 0
  232. align 4
  233. public DblFaultStack
  234. dw 50 DUP(0)
  235. DblFaultStack equ $
  236. ;
  237. ; Note that we need at least 2k of real-mode stack because some EISA BIOS
  238. ; routines require it.
  239. ;
  240. align 4
  241. public SuStack
  242. public _SuStackBegin
  243. _SuStackBegin equ $
  244. db 2048 DUP (0)
  245. SuStack equ $
  246. align 16
  247. public _TssKernel
  248. _TssKernel dw 60 DUP(0)
  249. EndTssKernel equ $
  250. align 4
  251. public _GDTregister
  252. _GDTregister dw EndGDT - _GDT - 1
  253. dw (SYSTEM_PAGE_PA and 0ffffh) + offset DGROUP:_GDT
  254. dw (SYSTEM_PAGE_PA SHR 16) and 0ffh
  255. align 4
  256. public _IDTregister
  257. _IDTregister dw EndIDT - _IDT - 1
  258. dw (SYSTEM_PAGE_PA and 0ffffh) + offset DGROUP:_IDT
  259. dw (SYSTEM_PAGE_PA SHR 16) and 0ffh
  260. ;
  261. ; We load the idtr from the this fword .
  262. ;
  263. public _IDTregisterZero
  264. _IDTregisterZero dw 0ffffh
  265. dd 0
  266. ;
  267. ; We save the base of the real mode data segment here so we
  268. ; can use it later in calculations of the linear address of
  269. ; the start of DGROUP.
  270. ;
  271. public saveDS
  272. saveDS dw 0
  273. ;
  274. ; When ever we enter the debugger we set this variable to
  275. ; on so we can tell if we've faulted in the debugger when
  276. ; we get an exception.
  277. ;
  278. public _InDebugger
  279. _InDebugger dw 0
  280. ; We save SP here when we get an exception in the debugging
  281. ; version of the SU module. If we get an exception in the
  282. ; debugger, we use this value to reset the stack to point to
  283. ; the base of the original exception/break-point stack frame.
  284. ;
  285. public SaveSP
  286. SaveSP dw 0
  287. ;
  288. ; BOOT CONTEXT RECORD
  289. ;
  290. ;
  291. ; Export Entry Table
  292. ;
  293. extrn RebootProcessor:near
  294. extrn GetSector:near
  295. extrn GetEddsSector:near
  296. extrn GetKey:near
  297. extrn GetCounter:near
  298. extrn Reboot:near
  299. extrn DetectHardware:near
  300. extrn HardwareCursor:near
  301. extrn GetDateTime:near
  302. extrn ComPort:near
  303. extrn GetStallCount:near
  304. extrn InitializeDisplayForNt:near
  305. extrn GetMemoryDescriptor:near
  306. extrn GetElToritoStatus:near
  307. extrn GetExtendedInt13Params:near
  308. extrn ApmAttemptReconnect:near
  309. SU_LOAD_ADDRESS equ 20000h
  310. ; FsContext
  311. ;
  312. ;
  313. public _FsContext
  314. align 4
  315. _FsContext FsContextRecord <0>
  316. ;
  317. ; Memory Descriptor Table
  318. ; The Memory Descriptor Table begins at 7000:0000 and grows upward.
  319. ; Note that this is 64k above the start of the OS Loader Heap and
  320. ; 64k below the start of the OS Loader Stack. This is ok, since the
  321. ; x86 Arc Emulation will have converted all of this information into
  322. ; Arc Memory Descriptors before the OS Loader is initialized.
  323. ;
  324. align 4
  325. public _MemoryDescriptorList
  326. _MemoryDescriptorList dw 0
  327. dw 7000h
  328. ;
  329. ; This is called the External Services Table by the OS loader
  330. ;
  331. ;**
  332. ; NOTE WELL
  333. ; The offsets of entries in this table must match its twin
  334. ; in startup\i386\sudata.asm, and the structure in boot\inc\bldrx86.h
  335. ;**
  336. align 4
  337. public _ExportEntryTable
  338. _ExportEntryTable equ $
  339. dw offset _TEXT:RebootProcessor
  340. dw SU_LOAD_ADDRESS SHR 16
  341. dw offset _TEXT:GetSector
  342. dw SU_LOAD_ADDRESS SHR 16
  343. dw offset _TEXT:GetKey
  344. dw SU_LOAD_ADDRESS SHR 16
  345. dw offset _TEXT:GetCounter
  346. dw SU_LOAD_ADDRESS SHR 16
  347. dw offset _TEXT:Reboot
  348. dw SU_LOAD_ADDRESS SHR 16
  349. dw offset _TEXT:DetectHardware
  350. dw SU_LOAD_ADDRESS SHR 16
  351. dw offset _TEXT:HardwareCursor
  352. dw SU_LOAD_ADDRESS SHR 16
  353. dw offset _TEXT:GetDateTime
  354. dw SU_LOAD_ADDRESS SHR 16
  355. dw offset _TEXT:ComPort
  356. dw SU_LOAD_ADDRESS SHR 16
  357. dw offset _TEXT:GetStallCount
  358. dw SU_LOAD_ADDRESS SHR 16
  359. dw offset _TEXT:InitializeDisplayForNt
  360. dw SU_LOAD_ADDRESS SHR 16
  361. dw offset _TEXT:GetMemoryDescriptor
  362. dw SU_LOAD_ADDRESS SHR 16
  363. dw offset _TEXT:GetEddsSector
  364. dw SU_LOAD_ADDRESS SHR 16
  365. dw offset _TEXT:GetElToritoStatus
  366. dw SU_LOAD_ADDRESS SHR 16
  367. dw offset _TEXT:GetExtendedInt13Params
  368. dw SU_LOAD_ADDRESS SHR 16
  369. dw 0 ; fake entry for
  370. dw 0 ; NetPcRomServices
  371. dw offset _TEXT:ApmAttemptReconnect
  372. dw SU_LOAD_ADDRESS SHR 16
  373. dw 0 ; fake entry for
  374. dw 0 ; BiosRedirectService
  375. dd 0
  376. ;**
  377. ; See note above
  378. ;**
  379. align 4
  380. Public _BootRecord
  381. _BootRecord dw offset _TEXT:_FsContext
  382. dw SU_LOAD_ADDRESS SHR 16
  383. dw offset _TEXT:_ExportEntryTable
  384. dw SU_LOAD_ADDRESS SHR 16
  385. ;
  386. ; The memory descriptor table begins at 0x70000
  387. ;
  388. dw 0
  389. dw 7
  390. public _MachineType
  391. _MachineType dd 0 ; Machine type infor.
  392. ;
  393. ; pointer to where osloader.exe is in memory
  394. ;
  395. public _OsLoaderStart
  396. _OsLoaderStart dd 0
  397. public _OsLoaderEnd
  398. _OsLoaderEnd dd 0
  399. public _ResourceDirectory
  400. _ResourceDirectory dd 0
  401. public _ResourceOffset
  402. _ResourceOffset dd 0
  403. public _OsLoaderBase
  404. _OsLoaderBase dd 0
  405. public _OsLoaderExports
  406. _OsLoaderExports dd 0
  407. public _BootFlags
  408. _BootFlags dd 0
  409. public _NtDetectStart
  410. _NtDetectStart dd 0
  411. public _NtDetectEnd
  412. _NtDetectEnd dd 0
  413. ;
  414. ; Defines the machine variables, we can use them to check the validity of
  415. ; loaded Ram Extension later.
  416. ;
  417. public MachineModel, MachineSubmodel, BiosRevision
  418. MachineModel db 0
  419. MachineSubmodel db 0
  420. BiosRevision db 0
  421. ;
  422. ; keeps track of 8042 access failing so we can avoid doing it repeatedly
  423. ;
  424. public _Empty_8042Failed
  425. _Empty_8042Failed db 0
  426. _DATA ends
  427. end