old9load 10 KB

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