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.

526 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> ; 78 Debug Code
  105. GDTDesc <0ffffh, 00000h, 040h, 092h, 000h, 080h> ; 80 Debug Data
  106. GDTDesc <00000h, 00000h, 000h, 092h, 000h, 000h> ; 88 Debug Use
  107. GDTDesc <0ffffh, 00000h, 007h, 092h, 000h, 000h> ; 90 Memory Descriptor List
  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. ; NetPcRomEntry is the address of the entry point exported by the
  289. ; NetPC ROM.
  290. ;
  291. public _NetPcRomEntry
  292. _NetPcRomEntry dd 0
  293. ;
  294. ; BOOT CONTEXT RECORD
  295. ;
  296. ;
  297. ; Export Entry Table
  298. ;
  299. extrn RebootProcessor:near
  300. extrn GetSector:near
  301. extrn GetEddsSector:near
  302. extrn GetKey:near
  303. extrn GetCounter:near
  304. extrn Reboot:near
  305. extrn DetectHardware:near
  306. extrn HardwareCursor:near
  307. extrn GetDateTime:near
  308. extrn ComPort:near
  309. extrn GetStallCount:near
  310. extrn InitializeDisplayForNt:near
  311. extrn GetMemoryDescriptor:near
  312. extrn GetElToritoStatus:near
  313. extrn GetExtendedInt13Params:near
  314. extrn NetPcRomServices:near
  315. extrn BiosRedirectService:near
  316. SU_LOAD_ADDRESS equ 20000h
  317. ; FsContext
  318. ;
  319. ;
  320. public _FsContext
  321. align 4
  322. _FsContext FsContextRecord <0>
  323. ;
  324. ; Memory Descriptor Table
  325. ; The Memory Descriptor Table begins at 7000:0000 and grows upward.
  326. ; Note that this is 64k above the start of the OS Loader Heap and
  327. ; 64k below the start of the OS Loader Stack. This is ok, since the
  328. ; x86 Arc Emulation will have converted all of this information into
  329. ; Arc Memory Descriptors before the OS Loader is initialized.
  330. ;
  331. align 4
  332. public _MemoryDescriptorList
  333. _MemoryDescriptorList dw 0
  334. dw 7000h
  335. ;
  336. ; This is called the External Services Table by the OS loader
  337. ;
  338. ;**
  339. ; NOTE WELL
  340. ; The offsets of entries in this table must match its twin
  341. ; in startup\i386\sudata.asm, and the structure in boot\inc\bldrx86.h
  342. ;**
  343. align 4
  344. public _ExportEntryTable
  345. _ExportEntryTable equ $
  346. dw offset _TEXT:RebootProcessor
  347. dw SU_LOAD_ADDRESS SHR 16
  348. dw offset _TEXT:GetSector
  349. dw SU_LOAD_ADDRESS SHR 16
  350. dw offset _TEXT:GetKey
  351. dw SU_LOAD_ADDRESS SHR 16
  352. dw offset _TEXT:GetCounter
  353. dw SU_LOAD_ADDRESS SHR 16
  354. dw offset _TEXT:Reboot
  355. dw SU_LOAD_ADDRESS SHR 16
  356. dw offset _TEXT:DetectHardware
  357. dw SU_LOAD_ADDRESS SHR 16
  358. dw offset _TEXT:HardwareCursor
  359. dw SU_LOAD_ADDRESS SHR 16
  360. dw offset _TEXT:GetDateTime
  361. dw SU_LOAD_ADDRESS SHR 16
  362. dw offset _TEXT:ComPort
  363. dw SU_LOAD_ADDRESS SHR 16
  364. dw offset _TEXT:GetStallCount
  365. dw SU_LOAD_ADDRESS SHR 16
  366. dw offset _TEXT:InitializeDisplayForNt
  367. dw SU_LOAD_ADDRESS SHR 16
  368. dw offset _TEXT:GetMemoryDescriptor
  369. dw SU_LOAD_ADDRESS SHR 16
  370. dw offset _TEXT:GetEddsSector
  371. dw SU_LOAD_ADDRESS SHR 16
  372. dw offset _TEXT:GetElToritoStatus
  373. dw SU_LOAD_ADDRESS SHR 16
  374. dw offset _TEXT:GetExtendedInt13Params
  375. dw SU_LOAD_ADDRESS SHR 16
  376. dw offset _TEXT:NetPcRomServices
  377. dw SU_LOAD_ADDRESS SHR 16
  378. dw 0 ; null slot for
  379. dw 0 ; apmattemptreconnect
  380. dw offset _TEXT:BiosRedirectService
  381. dw SU_LOAD_ADDRESS SHR 16
  382. dd 0
  383. ;**
  384. ; See note above
  385. ;**
  386. align 4
  387. Public _BootRecord
  388. _BootRecord dw offset _TEXT:_FsContext
  389. dw SU_LOAD_ADDRESS SHR 16
  390. dw offset _TEXT:_ExportEntryTable
  391. dw SU_LOAD_ADDRESS SHR 16
  392. ;
  393. ; The memory descriptor table begins at 0x70000
  394. ;
  395. dw 0
  396. dw 7
  397. public _MachineType
  398. _MachineType dd 0 ; Machine type infor.
  399. ;
  400. ; pointer to where osloader.exe is in memory
  401. ;
  402. public _OsLoaderStart
  403. _OsLoaderStart dd 0
  404. public _OsLoaderEnd
  405. _OsLoaderEnd dd 0
  406. public _ResourceDirectory
  407. _ResourceDirectory dd 0
  408. public _ResourceOffset
  409. _ResourceOffset dd 0
  410. public _OsLoaderBase
  411. _OsLoaderBase dd 0
  412. public _OsLoaderExports
  413. _OsLoaderExports dd 0
  414. public _BootFlags
  415. _BootFlags dd 0
  416. public _NtDetectStart
  417. _NtDetectStart dd 0
  418. public _NtDetectEnd
  419. _NtDetectEnd dd 0
  420. public _SdiAddress
  421. _SdiAddress dd 0
  422. ;
  423. ; Defines the machine variables, we can use them to check the validity of
  424. ; loaded Ram Extension later.
  425. ;
  426. public MachineModel, MachineSubmodel, BiosRevision
  427. MachineModel db 0
  428. MachineSubmodel db 0
  429. BiosRevision db 0
  430. ;
  431. ; keeps track of 8042 access failing so we can avoid doing it repeatedly
  432. ;
  433. public _Empty_8042Failed
  434. _Empty_8042Failed db 0
  435. _DATA ends
  436. end