9load 9.6 KB

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