9load 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417
  1. .TH 9LOAD 8
  2. .SH NAME
  3. 9load, ld, 9pxeload \- PC bootstrap program
  4. .SH SYNOPSIS
  5. .I "(Under MS-DOS)
  6. .br
  7. [
  8. .I drive
  9. :][
  10. .I path
  11. .RB ] ld
  12. [
  13. .I 9load
  14. ]
  15. .SH DESCRIPTION
  16. .I 9load
  17. and
  18. .I ld
  19. are programs that reside in a FAT file system and bootstrap Plan 9.
  20. .I 9load
  21. loads the kernel, but it cannot be run from DOS; use
  22. .I ld
  23. to bootstrap (by starting
  24. .IR 9load )
  25. if DOS is running.
  26. .I 9load
  27. is run automatically by the boot procedures described below;
  28. it cannot be run directly by hand.
  29. There are three bootstrap sequences:
  30. .IP \-
  31. BIOS, MBR, disk partition PBS,
  32. .IR 9load ,
  33. kernel
  34. .IP \-
  35. BIOS, floppy PBS,
  36. .IR 9load ,
  37. kernel
  38. .IP \-
  39. BIOS, MBR, DOS,
  40. .IR ld ,
  41. .IR 9load ,
  42. kernel.
  43. .PP
  44. Details follow.
  45. .PP
  46. .I 9load
  47. is a bootstrap program that loads and starts a program,
  48. typically the kernel, on a PC.
  49. It is run by the PC partition boot sector program (PBS),
  50. which usually resides in the first
  51. sector of the active partition.
  52. A copy of the Plan 9 PBS is kept in
  53. .BR /386/pbs ,
  54. but due to the ``cylinder-head-sector'' (CHS) addressing mode of old BIOSes, it can only
  55. operate up to 8.5GB into the disk.
  56. Plan 9 partitions further into the disk
  57. can only be booted using
  58. .BR /386/pbslba ,
  59. and then only if the machine's BIOS supports
  60. linear block addressing (LBA) mode for disk transfers.
  61. .PP
  62. When booting from floppy or hard disk, the BIOS loads the
  63. first sector of the medium at location 0x7C00. In the
  64. case of a floppy, this is the PBS. In the case of a hard
  65. disk it it the master boot record (MBR).
  66. The MBR copies itself to address
  67. .BR 0x600 ,
  68. finds the active partition and loads its PBS at address
  69. .BR 0x7C00 .
  70. A copy of the Plan 9 MBR is kept in
  71. .BR /386/mbr ;
  72. some commercial MBRs cannot read sectors
  73. past 2GB.
  74. The Plan 9 MBR can read sectors up to 8.5GB into
  75. the disk, and further if the BIOS supports LBA.
  76. The single file
  77. .B /386/mbr
  78. detects whether the BIOS supports LBA and
  79. acts appropriately, defaulting to CHS mode
  80. when LBA is not present.
  81. The PBSs cannot do this due to code size considerations.
  82. The Plan 9 MBR is suitable for booting non-Plan 9
  83. operating systems,
  84. and (modulo the large disk constraints just described)
  85. non-Plan 9 MBRs are suitable for booting Plan 9.
  86. .PP
  87. Thus the default sequence is: BIOS, MBR, PBS,
  88. .IR 9load ,
  89. kernel.
  90. .PP
  91. Because it contains many device drivers for different
  92. disks and networks,
  93. .I 9load
  94. is larger than 64K and cannot be run as a DOS
  95. .RB `` .com ''
  96. executable.
  97. A stripped-down version that knows about disks but not networks,
  98. called
  99. .I ld
  100. (really
  101. .BR ld.com ),
  102. fits in 64K and can be used under DOS to load and start a program (default
  103. .IR 9load )
  104. from the FAT16 partition.
  105. Its command line argument is of the same format as the
  106. .I bootfile
  107. specifiers described below.
  108. This profusion of loaders is unfortunate, but at least
  109. .I ld
  110. and
  111. .I 9load
  112. are compiled from the same source.
  113. .PP
  114. .I 9load
  115. begins execution at address
  116. .B 0x80010000
  117. (64K) and
  118. loads the
  119. .I bootfile
  120. at the entry address specified by the header,
  121. usually
  122. .BR 0x80100020 .
  123. After loading, control is passed to the entry location.
  124. .PP
  125. Finally,
  126. .I 9pxeload
  127. is a version of
  128. .I 9load
  129. that can be booted using the PXE download
  130. found on some ethernet card BIOSs.
  131. .PP
  132. In summary,
  133. Plan 9 can be booted on a PC three different ways:
  134. either by booting MS-DOS and using
  135. .I ld
  136. to start
  137. .I 9load
  138. in the appropriate directory,
  139. by booting directly from a Plan 9 boot floppy or disk
  140. partition
  141. prepared using
  142. .B format
  143. to install the appropriate files and bootstrap sectors
  144. (see
  145. .IR prep (8)),
  146. or by using a PXE capable BIOS to boot
  147. .I 9pxeload
  148. directly over the ethernet.
  149. .PP
  150. The
  151. .IR bootfile ,
  152. which may be compressed with
  153. .IR gzip (1),
  154. can be specified to
  155. .I 9load
  156. as a
  157. .B bootfile=
  158. entry in
  159. .IR plan9.ini ,
  160. or if booting from the ethernet, by a BOOTP server.
  161. If the
  162. .B plan9.ini
  163. file contains multiple
  164. .B bootfile=
  165. entries,
  166. .I 9load
  167. will present a numerical menu of the choices; type
  168. the corresponding number to select an entry.
  169. .PP
  170. The format of the
  171. .I bootfile
  172. name is
  173. .IB device ! file
  174. or
  175. .IB device ! partition ! file\f1.
  176. If
  177. .BI ! file
  178. is omitted, the default for the particular
  179. .I device
  180. is used.
  181. Supported
  182. .I devices
  183. are
  184. .TF \fLethern
  185. .TP
  186. .BI fd n
  187. An MS-DOS floppy disk.
  188. .I N
  189. specifies the floppy drive, either
  190. 0 or 1.
  191. The
  192. .I bootfile
  193. is the contents of the MS-DOS
  194. .IR file .
  195. There is no default file.
  196. For compatibility with hard disks, a
  197. .I partition
  198. may be given, but only
  199. .B dos
  200. is recognized:
  201. .BI fd0!dos! file\f1.
  202. .TP
  203. .BI ether n
  204. Ethernet.
  205. .I N
  206. specifies the Ethernet device number.
  207. If a
  208. .I partition
  209. is specified, it is taken to be the name of a host machine
  210. from which to load the kernel.
  211. .I file
  212. is determined by the
  213. .B /lib/ndb
  214. (see
  215. .IR ndb (6))
  216. entry for this PC.
  217. .TP
  218. .BI sd Cn
  219. Non-floppy disk.
  220. The device name format is described in
  221. .IR sd (3).
  222. A
  223. .I partition
  224. must be given and must
  225. name a partition containing a FAT file system.
  226. The name
  227. .B dos
  228. refers to the first DOS partition on a given device.
  229. It is common for Plan 9 partitions to contain a small
  230. FAT file system for configuration.
  231. By convention, this partition is called
  232. .BR 9fat .
  233. There is no default partition or pathname.
  234. .PD
  235. .PP
  236. When
  237. .I 9load
  238. starts running at physical address 0x10000,
  239. it switches to 32-bit mode.
  240. It then double maps the first 16Mb of physical memory to
  241. virtual addresses 0 and 0x80000000.
  242. Physical memory from 0x300000 upwards is used as data
  243. space.
  244. Next, in order to find configuration information,
  245. .I 9load
  246. searches all units on devices
  247. .BR fd
  248. and
  249. .BI sd Cn \fR,
  250. in that order, for a file called
  251. .B plan9\eplan9.ini
  252. or
  253. .B plan9.ini
  254. (see
  255. .IR plan9.ini (8))
  256. on a partition named
  257. .B dos
  258. or
  259. .BR 9fat .
  260. If one is found, searching stops and the file is read into memory
  261. at physical address 0x1200
  262. where it can be found later by any loaded
  263. .IR bootfile .
  264. Some options in
  265. .B plan9.ini
  266. are used by
  267. .IR 9load :
  268. .TF bootfile=manual
  269. .TP
  270. .B console
  271. .TP
  272. .B baud
  273. Specifies the console device and baud rate if not a display.
  274. .TP
  275. .BI ether n
  276. Ethernet interfaces. These can be used to load the
  277. .I bootfile
  278. over a network.
  279. Probing for Ethernet interfaces is too prone to error.
  280. .TP
  281. .BI bootfile= bootfile
  282. Specifies the
  283. .IR bootfile .
  284. This option is overridden by a command-line argument.
  285. .TP
  286. .B bootfile=auto
  287. Default.
  288. .TP
  289. .B bootfile=local
  290. Like
  291. .IR auto ,
  292. but do not attempt to load over the network.
  293. .TP
  294. .B bootfile=manual
  295. After determining which devices are available for loading from,
  296. enter prompt mode.
  297. .PD
  298. .PP
  299. When the search for
  300. .B plan9.ini
  301. is done,
  302. .I 9load
  303. proceeds to determine which bootfile to load.
  304. If there was no
  305. .I bootfile
  306. option,
  307. .I 9load
  308. chooses a default
  309. from the following prioritized device list:
  310. .EX
  311. fd sd ether
  312. .EE
  313. .I 9load
  314. then attempts to load the
  315. .I bootfile
  316. unless
  317. the
  318. .B bootfile=manual
  319. option was given, in which case prompt mode is entered immediately.
  320. If the default device is
  321. .BR fd ,
  322. .I 9load
  323. will prompt the user for input before proceeding with the
  324. default bootfile load after 5 seconds;
  325. this prompt is omitted if
  326. a command-line argument or
  327. .I bootfile
  328. option
  329. was given.
  330. .PP
  331. .I 9load
  332. prints the list of available
  333. .IR device s
  334. and
  335. enters prompt mode on encountering any error
  336. or if directed to do so by a
  337. .B bootfile=manual
  338. option.
  339. In prompt mode, the user is required to type
  340. a
  341. .IB bootfile
  342. in response to the
  343. .L "Boot from:
  344. prompt.
  345. .PP
  346. .I 9load
  347. parses the master boot record and Plan 9 partition tables
  348. (see
  349. .IR prep (8)),
  350. leaving partitioning information appended to the
  351. in-memory contents of
  352. .I plan9.ini
  353. for the
  354. .IR bootfile .
  355. This is used by
  356. .IR sd (3)
  357. to initialize partitions so that
  358. .IR kfs (4)
  359. file systems can be mounted as the root file system.
  360. A more extensive partitioning is typically done by
  361. .I fdisk
  362. and
  363. .I prep
  364. as part of
  365. .I termrc
  366. or
  367. .I cpurc
  368. (see
  369. .IR cpurc (8)).
  370. .PP
  371. A
  372. control-P
  373. character typed at any time on the console causes
  374. .B 9load
  375. to perform a hardware reset
  376. (Ctrl-Alt-Del can also be used on a PC keyboard).
  377. .PP
  378. When loaded from a PBS (rather than from
  379. .IR ld.com ),
  380. .I 9load
  381. must be contiguously allocated on
  382. the disk.
  383. See
  384. .IR dossrv (4)
  385. for information on ensuring this.
  386. .SH FILES
  387. .RI [ drive :]
  388. [
  389. .I path
  390. .RB ] 9load
  391. .br
  392. .RI [ drive :]
  393. [
  394. .I path
  395. .RB ] ld
  396. .br
  397. .IB "FAT filesystem" :\eplan9\eplan9.ini
  398. .br
  399. .IB "FAT filesystem" :\eplan9.ini
  400. .SH SOURCE
  401. .B /sys/src/boot/pc
  402. .SH "SEE ALSO"
  403. .IR plan9.ini (8),
  404. .IR prep (8)
  405. .SH BUGS
  406. .PP
  407. Much of the work done by
  408. .B 9load
  409. is duplicated by the loaded kernel.
  410. .PP
  411. If
  412. .I ld
  413. detects an installed MS-DOS Extended Memory Manager,
  414. it attempts to de-install it, but the technique
  415. used may not always work.
  416. It is safer not to install the Extended Memory Manager before running
  417. .IR ld .