9load 10 KB

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