Leaked source code of windows server 2003
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.

247 lines
5.3 KiB

  1. ; SCCSID = @(#)ibmhalo.asm 1.1 85/04/10
  2. ; On 2K (800h) boundaries beginning at address C0000h and ending at EF800h
  3. ; there is a header that describes a block of rom program. This header
  4. ; contains information needed to initialize a module and to provide PCDOS
  5. ; with a set of reserved names for execution.
  6. ;
  7. ; This header has the following format:
  8. ;
  9. ; rom_header STRUC
  10. ; Signature1 DB 55h
  11. ; Signature2 DB AAh
  12. ; rom_length DB ? ; number of 512 byte pieces
  13. ; init_jmp DB 3 dup (?)
  14. ; name_list name_struc <>
  15. ; rom_header ENDS
  16. ;
  17. ; name_struc STRUC
  18. ; name_len DB ?
  19. ; name_text DB ? DUP (?)
  20. ; name_jmp DB 3 DUP (?)
  21. ; name_struc ENDS
  22. ;
  23. ; The name list is a list of names that are reserved by a particular section
  24. ; of a module. This list of names is terminated by a null name (length
  25. ; is zero).
  26. ;
  27. ; Consider now, the PCDOS action when a user enters a command:
  28. ;
  29. ; COMMAND.COM has control.
  30. ; o If location FFFFEh has FDh then
  31. ; o Start scanning at C0000h, every 800h for a byte 55h followed
  32. ; by AAh, stop scan if we get above or = F0000H
  33. ; o When we've found one, compare the name entered by the user
  34. ; with the one found in the rom. If we have a match, then
  35. ; set up the environment for execution and do a long jump
  36. ; to the near jump after the found name.
  37. ; o If no more names in the list, then continue scanning the module
  38. ; for more 55h followed by AAh.
  39. ; o We get to this point only if there is no matching name in the
  40. ; rom. We now look on disk for the command.
  41. ;
  42. ; This gives us the flexibility to execute any rom cartridge without having
  43. ; to 'hard-code' the name of the cartridge into PCDOS. Rom modules that
  44. ; want to be invisible to the DOS should not have any names in their lists
  45. ; (i.e. they have a single null name).
  46. ;
  47. ; Consider a new release of BASIC, say, that patches bugs in the ROM version.
  48. ; Clearly this version will be available on disk. How does a user actually
  49. ; invoke this new BASIC?? He cannot call it BASIC on the disk because the
  50. ; EXEC loader will execute the ROM before it even looks at the disk! Only
  51. ; solution:
  52. ;
  53. ; o Keep things consistent and force the user to have his software named
  54. ; differently from the ROM names (BASIC1, BASIC2, etc).
  55. rom_header STRUC
  56. Signature1 DB ?
  57. Signature2 DB ?
  58. rom_length DB ?
  59. init_jmp DB 3 dup (?)
  60. name_list DB ?
  61. rom_header ENDS
  62. name_struc STRUC
  63. name_len DB ?
  64. name_text DB 1 DUP (?)
  65. name_jmp DB 3 DUP (?)
  66. name_struc ENDS
  67. ASSUME CS:TRANGROUP,DS:NOTHING,ES:NOTHING,SS:NOTHING
  68. ;
  69. ; Check for IBM PC Jr rom cartrides. DS:DX is a pointer to name
  70. ;
  71. ROM_SCAN:
  72. PUSH ES
  73. PUSH SI
  74. PUSH DI
  75. PUSH CX
  76. PUSH AX
  77. PUSH BX
  78. ;
  79. ; check for PC Jr signature in rom
  80. ;
  81. MOV AX,0F000h
  82. MOV ES,AX
  83. CMP BYTE PTR ES:[0FFFEh],0FDh
  84. JZ SCAN_IT
  85. NO_ROM:
  86. CLC
  87. ROM_RET:
  88. POP BX
  89. POP AX
  90. POP CX
  91. POP DI
  92. POP SI
  93. POP ES
  94. RET
  95. SCAN_IT:
  96. ;
  97. ; start scanning at C000
  98. ;
  99. MOV AX,0C000h
  100. SCAN_ONE:
  101. MOV ES,AX
  102. XOR DI,DI
  103. SCAN_MODULE:
  104. ;
  105. ; check for a valid header
  106. ;
  107. CMP WORD PTR ES:[DI],0AA55h
  108. JZ SCAN_LIST
  109. ADD AX,080h
  110. SCAN_END:
  111. CMP AX,0F000h
  112. JB SCAN_ONE
  113. JMP NO_ROM
  114. ;
  115. ; trundle down list of names
  116. ;
  117. SCAN_LIST:
  118. MOV BL,ES:[DI].rom_length ; number of 512-byte jobbers
  119. XOR BH,BH ; nothing in the high byte
  120. SHL BX,1
  121. SHL BX,1 ; number of paragraphs
  122. ADD BX,7Fh
  123. AND BX,0FF80h ; round to 2k
  124. MOV DI,name_list
  125. SCAN_NAME:
  126. MOV CL,ES:[DI] ; length of name
  127. INC DI ; point to name
  128. XOR CH,CH
  129. OR CX,CX ; zero length name
  130. JNZ SCAN_TEST ; nope... compare
  131. ADD AX,BX ; yep, skip to next block
  132. JMP SCAN_END
  133. ;
  134. ; compare a single name
  135. ;
  136. SCAN_TEST:
  137. MOV SI,DX
  138. INC SI
  139. REPE CMPSB ; compare name
  140. JZ SCAN_FOUND ; success!
  141. SCAN_NEXT:
  142. ADD DI,CX ; failure, next name piece
  143. ADD DI,3
  144. JMP SCAN_NAME
  145. ;
  146. ; found a name. save entry location
  147. ;
  148. SCAN_FOUND:
  149. CMP BYTE PTR DS:[SI],'?'
  150. JZ SCAN_SAVE
  151. CMP BYTE PTR DS:[SI],' '
  152. JNZ SCAN_NEXT
  153. SCAN_SAVE:
  154. MOV [rom_cs],ES
  155. MOV [ROM_ip],DI
  156. STC
  157. JMP ROM_RET
  158. ;
  159. ; execute a rom-placed body of code. allocate largest block
  160. ;
  161. ROM_EXEC:
  162. MOV BX,0FFFFh
  163. MOV AH,ALLOC
  164. INT int_command
  165. MOV AH,ALLOC
  166. INT int_command
  167. PUSH BX
  168. PUSH AX
  169. ;
  170. ; set terminate addresses
  171. ;
  172. MOV AX,(set_interrupt_vector SHL 8) + int_terminate
  173. PUSH DS
  174. MOV DS,[RESSEG]
  175. ASSUME DS:RESGROUP
  176. MOV DX,OFFSET RESGROUP:EXEC_WAIT
  177. INT int_command
  178. MOV DX,DS
  179. MOV ES,DX
  180. ASSUME ES:RESGROUP
  181. POP DS
  182. ASSUME DS:NOTHING
  183. ;
  184. ; and create program header and dup all jfn's
  185. ;
  186. POP DX
  187. MOV AH,DUP_PDB
  188. INT int_command
  189. ;
  190. ; set up dma address
  191. ;
  192. MOV DS,DX
  193. MOV DX,080h
  194. MOV AH,SET_DMA
  195. INT int_command
  196. ;
  197. ; copy in environment info
  198. ;
  199. MOV AX,[ENVIRSEG]
  200. MOV DS:[PDB_environ],AX
  201. ;
  202. ; set up correct size of block
  203. ;
  204. POP BX ; BX has size, DS has segment
  205. MOV DX,DS
  206. ADD DX,BX
  207. MOV DS:[PDB_block_len],DX
  208. ;
  209. ; change ownership of block
  210. ;
  211. MOV DX,DS
  212. DEC DX
  213. MOV DS,DX
  214. INC DX
  215. MOV DS:[arena_owner],DX
  216. MOV DS,DX
  217. ;
  218. ; set up correct stack
  219. ;
  220. CMP BX,1000h
  221. JB GOT_STACK
  222. XOR BX,BX
  223. GOT_STACK:
  224. MOV CL,4
  225. SHL BX,CL
  226. MOV DX,DS
  227. MOV SS,DX
  228. MOV SP,BX
  229. XOR AX,AX
  230. PUSH AX
  231. ;
  232. ; set up initial registers and go to the guy
  233. ;
  234. NOT AX
  235. PUSH [ROM_CS]
  236. PUSH [ROM_IP]
  237. MOV ES,DX
  238. ASSUME ES:NOTHING
  239. FOOBAR PROC FAR
  240. RET
  241. FOOBAR ENDP