home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / os / minix / 4238 < prev    next >
Encoding:
Internet Message Format  |  1992-08-18  |  29.5 KB

  1. Xref: sparky comp.os.minix:4238 fj.sources:658 fj.os.minix:217
  2. Path: sparky!uunet!sun-barr!sh.wide!ascwide!ascgw!uitecgw!nemossan
  3. From: nemossan@uitec.ac.jp (Sakurao NEMOTO)
  4. Newsgroups: comp.os.minix,fj.sources,fj.os.minix
  5. Subject: Inside of MXboot/minix-V: Part-1....booting processes (English)
  6. Summary: Inside document on MXboot-201/minix-V for IBM-PCs/clones
  7.      supports both v1(minix-1.5) and v2(minix-1.6.16) File-Sytems
  8.      and 16/32-bits minix.
  9. Keywords: MXboot, HDD-boot, minix, minix-V, PC/clones, Japanese-Kanji
  10. Message-ID: <1188@uitecgw.uitec.ac.jp>
  11. Date: 19 Aug 92 03:11:17 GMT
  12. References: <1144@uitecgw.uitec.ac.jp> <1165@uitecgw.uitec.ac.jp>
  13. Followup-To: comp.os.minix
  14. Organization: Univ. Industrial Tech., Sagamihara, JAPAN
  15. Lines: 632
  16.  
  17.  
  18. This  is  the Part-1  of "inside-documents" of  MXboot and minix-V,  and
  19. describes processes to boot-up Minix.
  20.  
  21. In this document, "Bible" should be read as our text book by  Prof. Andy
  22.     Operating Systems: Design and Implementation
  23.         by Andrew S. Tanenbaum
  24.         Prentice-Hall, 1987
  25.  
  26.  
  27. This is originally written by takamiti@mix, the developper of MXboot and
  28. minix-V,  the former is a system  to  boot-up Minix from HDDs,  and  the
  29. latter is a system  to display  Japanese-Kanji (and  other  2-byte-coded
  30. Language) in Minix on IBM-AT/clones.
  31.  
  32. This is  originally  written in  Japanese  and  trially translated  into
  33. (broken :-) English by nemossan@mix == nemossan@uitec.ac.jp.
  34.  
  35. ========================================================================
  36. Table of contents
  37. 0.    Introduction
  38. 1.0    Reading the DISK-IPL
  39. 2.0    Booting process from the floppy
  40. 2.1    structure of Minix-boot-disks
  41. 2.1.1        How original "bootblok.s" works
  42. 2.2.2        how "bootblok.x" in Mix-version (MXboot/minix-V) works
  43. 3.0    Booting from Hard Disks
  44. 3.1    How to control the Hard-disks
  45. 3.2    Master-IPL of a Hard-disk
  46. 3.2.1        Master-IPL of a standard Hard-disk
  47. 3.2.2        assistIPL
  48. 3.2.2.1        Memory-map of assistIPL
  49. 3.2.2.2        How assistIPL works
  50. 3.3    MXboot: boot-loader of Minix on Hard-disks
  51. 3.3.1        Memory-map of MXboot
  52. 3.3.2        outline of MXboot
  53. 3.3.2.1        preparation stage
  54. 3.2.2.2        searching the image file
  55. 3.3.2.3        Loading the image-file.
  56. 3.3.2.4        Transfering control from MXboot to mune
  57. 3.4    what "menu" do when booted from Hard-drive.
  58. ========================================================================
  59. 0.    Introduction
  60.     How do you think about the process  after the machine is powered on?
  61. It is written in our Bible about the process  after the control is given
  62. to the kernel of Minix, so refer it on the process after it.  Here let's
  63. consider  about  the  processes  after  the  System-ROM initialized  the
  64. hardware,  and  how to read the kernel of Minix from a floppy or a Hard-
  65. disk,  and  how to  give the control  to  the start-up routine of Minix.
  66. Official-Minix  does not support  booting  from  Hard-disks,  but we can
  67. boot-up minix via "assistIPL" + "MXboot", so  I'll explain the processes
  68. in this system as an example.
  69.  
  70.     By the way, the structure of the Minix-File-system is written in our
  71. Bible,  so  I'll not write here, please refer it.  You can get the manul
  72. on  managing  the partition  from  IBM-Japan,   titled  "BIOS  interface
  73. manual", so refer it.  This was the best manual I've ever had,  in other
  74. words, there is very little amount of manuals... ;-)   But, it should be
  75. good for us that official manual is availalbe.  There are many makers in
  76. Japan, who want to keep secret their hardwares.
  77.  
  78.     There may be many mistakes  where I explain with the pseud-code, but
  79. I hope you can understand.  (^_^;;)
  80.  
  81.  
  82.  
  83. 1.0    Reading the DISK-IPL
  84.  
  85.     After the initializations of the hardware by the system-ROM,   trial
  86. to load the "disk-IPL" from Floppy:system-#0 (usually Drive A:) is made.
  87. If the no-floppy is inserted into the drive  the trial fails,  then BIOS
  88. tries to read from the First-HDDrive.  If this fails too, ps55 from IBM-
  89. Japan boots ROM-Basic, according to the manual from IBM-Japan,  and IBM-
  90. clones will show BIOS-setup menu (really?  this is the case of my clone,
  91. I don't know other machines).
  92.  
  93.     This Disk-IPL  is  written in its physical top-sector,  in both FDDs
  94. and HDDs,  and it will be loaded to  the absolute address  0x7C00 at the
  95. last of the BIOS routine,  and  the cotrol  will be transfered  into the
  96. address 0x7C00.  After that,  all the control will be done  by  the code
  97. written in the disk, and thus the Operating-System written there will be
  98. booted.
  99.  
  100.  
  101.  
  102. 2.0    Booting process from the floppy
  103.  
  104. 2.1    structure of Minix-boot-disks
  105.  
  106.     Boot disk  of  Minix  differs  its  structure  from usual Minix-file
  107. system.  You can see  the layout of normal file systems  at 5.6.2 in our
  108. Bible,  it has  super block,  bit-map, i-nodes and data-blocks....  Boot
  109. disks differ from them and there written core-image  made by tools/build
  110. sequentially from its start, rather simple structure.   512-bytes of the
  111. top of the core-image  is  written on the first sector of the boot-disk,
  112. and it was loaded at 0x7C00 by BIOS-ROM,  and the rest of the core image
  113. will be loaded by this program onto the memory.
  114.  
  115.  
  116.  
  117. 2.1.1    How original "bootblok.s" works
  118.  
  119.     The  boot-sector,  at the top of the boot-disk,  whose size is  512-
  120. bytes, can be seen such structure as
  121.  
  122.     struct org_boot_sector {
  123.     byte  ipl_code[504];    /* boot code */
  124.     short load_sectors;    /* number of sectors loaded by bootblok */
  125.     short menu_ds;        /* value of DS in menu */
  126.     long  menu_pc;        /* start-address of menu */
  127.     }
  128.  
  129. Where  "ipl_code[]"  contains  the program code  to load  the core-image
  130. shown tools/bootblok.s, and "load_sectors",  "menu_ds" and "menu_pc" are
  131. calculated by "build" when it combines "kernel", "mm", "fs", "init"  and
  132. "menu" to make boot-image, they are written on the first-sector.
  133.  
  134.     Initial-Program-Loader of the ROM-BIOS  loads this "org_boot_sector"
  135. to absolute address 0x7C00, and the control is given to its top-address,
  136. ipl_code[].  After  it, "bootblok.s", of the original PH-code, relocates
  137. itself to  absolute address 0x3F700  and  loads the main body of kernel-
  138. image  onto  the absolute address at  0x600.   After  all of the sectors
  139. shown in  "load_sectors"  have been  loaded  from  the boot-floppy,  the
  140. values shown "menu_ds" are set to the data-segments, DS, ES and SS, then
  141. it indirectly-long-jumps  to  the address written on "menu_pc", which is
  142. the start-address of the "menu"-program.
  143.  
  144.     After the "menu" starts, it is a usual course of changing the "boot-
  145. disk" to "root-file-system", pressing <=>-key, then Minix starts.
  146.  
  147.  
  148.  
  149. 2.2.2    how "bootblok.x" in Mix-version (MXboot/minix-V) works
  150.  
  151.     "bootblok.x" accompanied with  "MXboot-2.01"  or  "minix-V" from Mix
  152. has the same concept with the original "bootblok.s" from PH,  but it has
  153. different structure for loading big (more than 400kB) core-image  or  to
  154. support "MXboot".  It looks like
  155.  
  156.     struct mix_boot_sector {
  157.     short jmp_id; (0x02EB)    /* jmp short &ipl_code[0] */
  158.     short open_msg;        /* address of subroutine for opening message */
  159.     byte  ipl_code[500];    /* boot code */
  160.     short load_sectors;    /* number of sectors loaded by bootblok */
  161.     short menu_ds;        /* value of DS in "menu" */
  162.     long  menu_pc;        /* start-address of "menu" */
  163.     }
  164.  
  165. Different from PH-original,  you will see  0x02EB constant at the top of
  166. it, then the start address of the subroutine to show "Booting MINIX ..."
  167. message follows.  The constant "0x02EB" is  a short-jump instruction  to
  168. the address of "ipl_code[0]".   Those  4-bytes may be seen as  wastes of
  169. memory at first glance,  but it is prepared for MXboot,  which I'll tell
  170. you later.  In  MXboot, "0x02EB" is treated as a kind of  identifier and
  171. "open_msg"   is  refered   at  the  time  of  subroutine  call  to  show
  172. "Booting ...".
  173.  
  174.     Instruction-codes  for  booting  the kernel-image  are  contained in
  175. "ipl_code[]",  and after the control is given from ROM-BIOS,  it  starts
  176. running via "0x02EB" short-jump instruction.   Program-codes  start from
  177. ipl_code[]  loads  "kernel" onto absolulte address 0x600  and  jumps  to
  178. "menu"  same as  original PH-version, but the address to relocate itself
  179. differs.  In  case of  PH-original-version,  the  relocating address  is
  180. written in the source-code, thus the address is fixed, while Mix-version
  181. tests the upper-limit of the real-memory  by "int 0x12" and relocates to
  182. the address below 4kB of the upper_limit.  For example, if the amount of
  183. the real-memory is 640-kB, the upper-limit address is 0xA0000,  then the
  184. contents of the boot-sector will be relocated to 0x9F000. Thus the load-
  185. ing of  more than 400kB  of  kernel-image  (of 32-bit-Minix) can be made
  186. successfully to boot-up it.
  187.  
  188.  
  189.  
  190. 3.0    Booting from Hard Disks
  191.  
  192.     Original Minix does not support booting from the Hard-disk, but I'll
  193. tell you  how  the master-IPL of the hard-disk loads an OS  and  tranfer
  194. control on it, and booting process of Minix by "assistIPL" + "MXboot".
  195.  
  196.  
  197.  
  198. 3.1    How to control the Hard-disks
  199.  
  200.     "BIOS-interface manual" from IBM-Japan tells how to control the par-
  201. tition-table of hard-disk  in detail.  The followings are the summary of
  202. it.
  203.     One hard-disk  is able to  have upto four-partitions, and any one of
  204. the partition  can  boot-up an OS.  The table for control the partitions
  205. is  placed from the 446-th byte of the boot-sector of the Hard-disk, and
  206. it uses 16-bytes  to control  one partition, its structure is equivalent
  207. to the one listed below.   At the last 2-byte of the boot-sector (510-th
  208. and 511-th byte counting from 0), there written "boot-sector-ID", "0x55"
  209. and "0xAA", which show this is valid boot-sector.
  210.  
  211.     typedef struct {
  212.     byte head;
  213.     byte sector;
  214.     byte cyl;
  215.     } hd_addr;
  216.  
  217.     typedef struct {            /* shows one partition */
  218.     byte    boot_id;    /* bootable-partition (0x80) or not (0x00) */
  219.                 /* "fdisk" writes 0x80 to active-partiton */
  220.                 /* plural partitions may not be active */
  221.     hd_addr    start;        /* head/sector/cylinder of the start */
  222.     byte    system_id;    /* shows the OS-type in the partition */
  223.     hd_addr end;        /* head/sector/cylindar of the end */
  224.     long    start_sector;    /* top sector address of the partition */
  225.     long    nr_sector;    /* number of sectors in the partition */
  226.     } partition;
  227.  
  228.     struct hd_boot_sector {        /* shows total of the drive */
  229.     byte ipl_code[446];    /* master-IPL codes for Hard-disk */
  230.     partition part_tab[4];    /* partition-tables */
  231.     short ipl_id; (0xAA55)    /* ID to show effective boot-sector 0xAA55 */
  232.     }
  233.  
  234. where
  235.     partition.system_id:
  236.     is a code to show the type of OSs installed in this partition.
  237.     Codes for various OSs are as follows (quoted from fdisk.c/*systype()).
  238.         0x00:    not used area
  239.         0x01:    PC-DOS, 12-bit-FAT
  240.         0x02:    XENIX
  241.         0x03:    XENIX(OLD)
  242.         0x04:    PC-DOS, 16-bit-FAT (less than 32MB)
  243.         0x05:    PC-DOS extended
  244.         0x06:    PC-DOS, 16-bit-FAT (more than 32MB)
  245.         0x08:    AIX
  246.         0x09:    OPUS
  247.         0x51:    NOVELL?
  248.         0x52:    CP/M?
  249.         0x63:    386/IX
  250.         0x64:    NOVELL
  251.         0x75:    PCIX
  252.         0x80:    OLD-MINIX
  253.         0x81:    MINIX
  254.         0xDB:    CP/M
  255.         0xFF:    BAD BLOCKS
  256.  
  257.     partition.start, partition.end
  258.     They contain start and end addresses of cylindar/head/sector  in
  259.     this partition.  Every partition (except the top partition which
  260.     starts from the drive) should be aligned to head=0, sector=1.
  261.     "start.cyl" and "start.sector" correspond to the value to be set
  262.     on CX-register at the DISK-BIOS call (int 0x13), and 2-bits from
  263.     MSB of "start.sector"  and 8-bits of "start.cyl" decide the cyl-
  264.     indar address in 10-bits.
  265.  
  266.     partition.start_sector
  267.     This contains the start sector address of the partition.
  268.  
  269.     partition.nr_sectors
  270.     This contains the number of sectors in the partition.
  271.  
  272.  
  273.  
  274. 3.2    Master-IPL of a Hard-disk
  275.  
  276.     Master-Initial-Program-Loader  is placed at the top of an Hard-disk,
  277. ie. boot-sector,  in order to  boot-up the OSs installed in every parti-
  278. tion,  as well as  the managing table  for partitions.  This IPL will be
  279. loaded onto 0x7C00  after  ROM-BIOS's initialization, and the control is
  280. moved to the code written in the master-IPL of the Hard-drive.
  281.  
  282.  
  283.  
  284. 3.2.1    Master-IPL of a standard Hard-disk
  285.  
  286.     Standard master-IPL of IBM-PCs and its clones works as follows;
  287.     At first, it relocates itself, because the address of the loader for
  288. the OSs to be loaded after the Master-IPL is 0x7C00, same address of the
  289. Master-IPL.  In many cases its relocating address is 0x600.
  290.  
  291.     Next, it searches partition-table to find the active-partition, then
  292. the loader of the OS (of the active-partition) is loaded onto 0x7C00, at
  293. last the control will be transfered into the address.  In these process,
  294. such checks  will be  done as  "Is there 'boot-ID:0xAA55'?",  "Do plural
  295. partitions have active-flag?"  or  "Does no partiton have active-flag?".
  296. If any trouble are found, it displays an Error-messaage and stops.
  297.  
  298.     If no error is found in the checks and the loader of the OSs written
  299. in the active partition  (size is 1 [sector] == 512 [bytes]) is success-
  300. fully loaded,  then  the top-address of the partition table  is  set  to
  301. DS:SI, and control moves there.   For example, when the second partition
  302. is active  and  the OS  is  loaded  from  the  partition,  then
  303. "&hd_boot_sector.part_tab[1]" will be set to DS:SI.
  304.  
  305.  
  306.  
  307. 3.2.2    assistIPL
  308.  
  309.     At the time of  boot,  you cannot  select OSs  to be booted-up,   if
  310. limited to the standard master-IPL.   If you use only one OS, it must be
  311. no problem, but if you use ex. both ??-dos and Minix, you have to change
  312. active-partition  by the tool like "fdisk",  every time when you want to
  313. change OS.   It is very inconvenient, isn't it?    "assisstIPL"  has the
  314. function of standard-IPL,  further more,  it has the function to  select
  315. OSs.   Functions  of "assistIPL" are as follows;
  316.     1.  For the active-OS,  you can  boot it up  without any manual-
  317.         operation (same as standard-IPL).
  318.     2.  You can select  boot-OS  at the time of  booting.   You  can
  319.         boot-up the OS even the partition is non-active (changing it
  320.         to be active or remaining non-active).
  321.     3.  The setting of active-partition  can be done by  the conven-
  322.         tional tools such as "fdisk",  moreover "assistIPL"  has the
  323.         function  to select the partition  and  set  it  as  active-
  324.         partition, allowing next boot automatically from this parti-
  325.         tion. This can be done at the time of booting (not after the
  326.         boot).
  327.     4.  If the OS's loader has its function, the OS can be booted up
  328.         even from the second-Hard-Drive (at least Minix under MXboot
  329.         can be booted).
  330.  
  331.  
  332.  
  333. 3.2.2.1    Memory-map of assistIPL
  334.  
  335.     "assistIPL" is  a masterIPL  of a hard-disk  and placed at the boot-
  336. sector.  It will be loaded  on  0x7C00  by  the IPL-routine of ROM-BIOS,
  337. then it works.   Like the other masterIPLs,  assistiIPL reloactes itself
  338. to 0x600,  then does its own  works.  The memory map  at the time  is as
  339. follows;
  340.  
  341.     ^                      ^
  342.     ^                      ^
  343.     |----------------------|
  344.     |     512 bytes        | <- assistIPL loads OS-loader, here
  345. 0x07C00 +======================+ <- upper-limit of assistIPL's stack
  346.     |                      |        (sp is set here at the start)
  347.     ^                      ^
  348.     ^                      ^
  349.     |------------------55AA|
  350.     |      64 bytes        | <- work-area of partition-table
  351.     |~~~~~~~~~~~~~~~~~~~~~~|
  352.     |     446 bytes        | <- code and data area of assistIPL
  353. 0x00600 +======================+
  354.     ^                      ^
  355.     ^                      ^
  356.     |                      | <- work-area for BIOS and table for
  357.     |                      | <- interrupt-vectors
  358. 0x00000 +----------------------+
  359.     ////////////////////////
  360.  
  361.  
  362.  
  363. 3.2.2.2    How assistIPL works
  364.  
  365.     "assistIPL"  has compatible mode with the standard-IPL, and has also
  366. specific function to select boot-partition.   The latter  does not  work
  367. unless  the  operator  intendedly  call,  thus  usually  it  works  like
  368. standard-IPL.
  369.  
  370.     "assistIPL"  checks  if the <shift>-key  is pressed,  at the time of
  371. waiting the stopping of the FDD-motor.  As I have said earlier,  ROM-IPL
  372. tries to boot from floppy at first,  and if it fails,  it tries  to boot
  373. from HDD.  The motor for FDD keeps rotating after the failure of booting
  374. from FDD by its momemt of inertia.  While waiting this, assistIPL checks
  375. if the <shift>-key is pressed  or  not,  it means partition-selection is
  376. specified or not.
  377.  
  378.     If <shift>-key has not been pressed in this waiting time,  assistIPL
  379. searches active-partition in the partition-table,  and  loads the loader
  380. of the OS in that partition onto 0x7C00, then jumps there.   This is the
  381. same action as the conventional masterIPL.
  382.  
  383.     If the <shift>-key has been pressed, or if it has never been pressed
  384. but active partition cannot be  found,  assistIPL enters into  selection
  385. mode of boot-partition. In the selection mode, you will see "No. of HDD-
  386. drives",  "Partition No-s"  and  "system-ID" on the CRT.  Current active
  387. partition number will be shown after the  "Which?" prompt.  (If there is
  388. no-active-partition, it will show "1".)   If you choose a number  from 1
  389. to 4, and press <Enter> or <End>,   the partiton  will be selected,  and
  390. the  machine  will  boot-up  from  the  specified  partition.   In  this
  391. selection,  if  you choose  <Enter>-key,  the OS will be loaded from the
  392. specified  partiton,  while if choose  <End>-key instead of <Enter>-key,
  393. the selected-partition will be set as "active",  and  it is written back
  394. to the boot-sector of the partition,  then  boots-up from the partition,
  395. thus next booting will be done  from this partition  if you do not enter
  396. into the selection-mode.
  397.  
  398.     After the <Enter> or <End> key,  specifying start of booting, loader
  399. of the OS is loaded.   In datail,  at first it checks whether the parti-
  400. tion is "unused",  then  one-sector  from the partition  be  loaded  and
  401. checked if the first 2-bytes are code or not.  If all of them are normal
  402. in those simple checks,  "boot_id" of the corresponding area  is written
  403. by "0x80", specifying active-area,  and its top-address is set to DS:SI,
  404. then the control will be moved to the loader of the OS just loaded. When
  405. started by <End>-key, partition-table of the drive will be  written-back
  406. before the control transfered into the OS's loader.
  407.  
  408.     Limiting only to Minix,  you can boot-up even from  any parition  of
  409. the second drive, like in the case of the first-drive.  As usual, IBM-PC
  410. does not support booting from the second-drive (NEC-PC9801 can be booted
  411. from the second drive), so booting-from-2nd-drive may be limited only to
  412. Minix (in Minix, it is done by both "assistIPL" and "MXboot").
  413.  
  414.     In order to boot-up Minix from the second-drive,  specify "0" parti-
  415. tion on selection-menu of assistIPL.   Then the boot-sector of the other
  416. drive will be loaded to 0x7C00, and assistIPL copies the partition-table
  417. of it.  After that,  the same processes of the selection will be done as
  418. the first drive.   Only one-difference is that "0x81" will be written on
  419. the "boot_id" of the correspondig area.    Loaders of usual OSs check if
  420. the "boot_id" is "0x80", and  if not,  they  cause  error.  Thus MS-DOS,
  421. ex., will fail to boot from the second drive.   This function to boot-up
  422. from the second-drive  is  made in order to boot-up Minix  even there is
  423. no-space for Minix in the first drive.
  424.  
  425.     At the time of  making  this,  I have read  several MasterIPLs,  and
  426. tried  to find  the conditions  common to them,  and made  assistIPL  to
  427. satisfy such conditions.  Later, I have had the manual  from  IBM-Japan,
  428. and there written as "two 'mov' instructions are enough to set the para-
  429. meter for Disk-BIOS on DX and CX, then the drive-number 0x80 (set at DL)
  430. corresponds to boot_id".
  431.  
  432.  
  433.  
  434. 3.3    MXboot: boot-loader of Minix on Hard-disks
  435.  
  436.     "MXboot"  is  written  on  the   "bootblock"  of  Minix-File-System,
  437. reserved by "mkfs", size of which is 1k-byte,  located at the top of the
  438. Minix-FS,  (refer to our Bible, 5.6.2:File System Layout).   And  MXboot
  439. loads kernel-image from pre-defined Minix-file (usually "/system/minix.sys")
  440. onto the memory, then jumps to "menu"-program.
  441.  
  442.  
  443.  
  444. 3.3.1    Memory-map of MXboot
  445.  
  446.      MXboot will be loaded by assistIPL from 0x7C00, at first 512-bytes,
  447. half  of  its size.   Then  it will load itself again  to the address of
  448. "upper-limit" minus 4kB, this time all of the MXboot is loaded and jumps
  449. normal entry point of MXboot.   The memory map  of  MXboot at the normal
  450. run is as follows;
  451.  
  452.  
  453. Upper-limit of Memory
  454. limit   //////////////////////// <- upper-limit returned by "int 0x12"
  455.     |                      |
  456.     | DiskBuff_#2          |
  457.     |    (i-node buffer)   |
  458.     |            (1K bytes)|
  459. limit-1K|======================|
  460.     |                      |
  461.     | DiskBuff_#1          |   ___________________________________
  462.     |    (data buffer)     |  / auxiliary disk buffer (28 bytes max.)
  463.     |            (1K bytes)| /  |~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  464. limit-2K|======================|/   |
  465.     | work area (64 bytes) |    |
  466.     |~~~~~~~~~~~~~~~~~~~~~~|\   |   MXboot work area (28 bytes)
  467.     | stack area           | \  |
  468.     |           (958 bytes)|  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  469. limit-3K|======================|
  470.     |                      |
  471.     |                      |
  472.     |   MXboot code area   | ___________________________________
  473.     |            (1K bytes)|/       key buffer (14 bytes)
  474. limit-4K|======================|------------------------------------
  475.     ^                      ^
  476.         ^                      ^
  477.         |                      |
  478.  
  479.  
  480.  
  481. 3.3.2    outline of MXboot
  482.  
  483. 3.3.2.1    preparation stage
  484.  
  485.     After the reload to "upper_limit - 4kB"  and  start  its own  entry,
  486. MXboot saves the booted drive number (shown in boot_id of the partition-
  487. table given by DS:SI)  and  relative sector address of the partition  to
  488. its own variables.  Then MXboot decides the entry of the partition-table
  489. (at the boot-sector of the drive)  from  which  MXboot is called.   This
  490. decision is done according to the address shown by DS:SI and  the  boot-
  491. sector-ID, 0xAA55.   Thus MXboot  gets parameters (by Disk-BIOS call) of
  492. the Hard-Drive where it was booted.  All the preparations to access (via
  493. Disk-BIOS) the partition are ready, now.
  494.  
  495.     Then, MXboot reads the super-block (next to the bootblock) to access
  496. this partition  as a Minix-file-system.   From  the super-block,  MXboot
  497. reads  several data  and  saves  them  to  its  own  work area (slightly
  498. modifying).  These data are 2-bytes magic_number to distinguish the type
  499. of  Minix-File-systems  (V1 or V2),  start addresses (block)  of i-node-
  500. block or zone-block, in short  they are the necessary data  to specify a
  501. certain file and to read the file.   From the magic_number, MXboot knows
  502. the version of  File-system of Minix  (V1:until Minix-1.5   or  V2:after
  503. Minix-1.6), and changes/modifies not only parameter-tables  for the two-
  504. versions of File-systems  but also  program codes  incident to the File-
  505. systems.
  506.  
  507.  
  508.  
  509. 3.2.2.2    searching the image file
  510.  
  511.     MXboot checks  key-board status  before searching predefined kernel-
  512. image file (usualy "/system/minix.sys").  If <shift>-key is pressed,  it
  513. is  operator's command  to change the boot-image  temporaly,  and MXboot
  514. prompts its version-number ("MX.201>" in case of MXboot-V2.01) and waits
  515. for input file name.   The File name of the kernel-image is limited upto
  516. 13-characters  in length  and  path  cannot be  specified (restricted to
  517. /system or /).  The  input-buffer  used  here  is  the area  where  were
  518. program-code already used  and  not be used in future.  Key-input can be
  519. edited by <BackSpace>-key, so  miss-typing  can be corrected by <BS> and
  520. if you press  <Enter>  witout  any  keyinput  (including  as a result of
  521. <BS>s),  standard boot-image ("/system/minix.sys") file will be tried to
  522. load.
  523.  
  524.     Here,  I'll tell you the order of the searching the boot-image file.
  525.     If <shift>-key is not pressed,  MXboot searches "/system/minix.sys".
  526. If it is pressed,  MXboot  prompts file name of boot-image, as mentioned
  527. above, and after the file-name is  given, it searchs the file,  at first
  528. in root (/) directory.  If it fails, MXboot searchs in the sub-directory
  529. "/system".     This   order  of  directories   may  be   curious,    but
  530. "/system/minix.sys" is  the  full-name of the file  including full-path,
  531. and the file-name given by key-input is the only file-name,  which lacks
  532. its path.   Further, even if <shift>-key is not pressed, if there was no
  533. "/system/minix.sys" file,  MXboot  forces to enter into File-name-input-
  534. mode.
  535.  
  536.     Process to approach to the intended file  is  described in detail on
  537. our  Bible,  see   Fig.5-11  "The  steps  in looking up  /usr/ast/mbox".
  538. According to the steps described there, MXboot searchs the intended file
  539. looking up i-nodes and data-zones.   In order to  read  i-node,  i-node-
  540. buffer mentioed at the memory-map in 3.3.1 is used. For data-zone, data-
  541. buffer is used.   Reading is always done  in block of Minix (1024-bytes,
  542. 2-sectors).
  543.  
  544.     If  the file specified from key-board  cannot be found, MXboot gives
  545. up booting showing "No File. Please reboot".
  546.  
  547.  
  548.  
  549. 3.3.2.3    Loading the image-file.
  550.  
  551.     After finding the i-node of the inteded kernel-image-file, next step
  552. is loading the file onto the memory. At first, contents of i-node.zone[0]
  553. will be loaded into data buffer.  The boot-image to be loaded is the one
  554. which made by "build",  and this is the same as one of the floppy-disks.
  555. So, the contents of the data-block shown by zone[0] is  512-bytes of the
  556. boot-routine from floppy (former-half) and the latter-512-bytes contains
  557. kernel's start-up routine which should be loaded from 0x600. In order to
  558. load the kernel-image,  MXboot should proceed the  first-block.   MXboot
  559. checks,  at first,  top of 2-bytes  of the block.  If they are "0x02EB",
  560. key-word of "bootblok.x" of Mix-version as mentioned in 2.2.2, then next
  561. 2-bytes  are  regarded as  the entry-point  to  the Opening-message,  so
  562. (adjusting the data-segment) indirectly-calls to the address
  563. (mix_boot_sector.open_msg) to show "Booting.." message.   If the 2-bytes
  564. are not "0x02EB",  MXboot regards this image-file  as  one of  original-
  565. version (not Mix-version), and resets the variable for automatic-booting
  566. (it will be used after the image-file loaded) and keeps booting.
  567. "*_boot_sector" has the entry address of "menu"  and  the value of data-
  568. segment,  so  MXboot copies them  on its variables  and  calculates  the
  569. block-number to be loaded  by *_boot_sector.load_sectors.   After  these
  570. values are obtained,  the latter 512-bytes  will be  copied into  0x600,
  571. thus ends reading of the most complex block.
  572.  
  573.     Then  MXboot loads  boot-image of the kernel,  from 0x0600 + 0x0200,
  574. sequentially, moving the pointer.  One point to be careful  at this time
  575. is  block-specification of the i-node, which type is used from "direct",
  576. "indirect"  or  "double-indirect".  MXboot  copies the contents  of from
  577. zone[1]  to zone[6],  direct-zone, to the  auxiliary  disk-buffer.  Then
  578. saving the value of zone[7], indirect-zone, reads the contents  shown by
  579. zone[8] into i-node buffer.   Next, the block shown by zone[7] (saved in
  580. a variable) is read to data buffer.  In case of V2-File-system, indirect
  581. zone continues to zone[9],  but considering the size of the kernel-boot-
  582. image,  the process is  enough upto zone[8] (64-MB, see "5.6.4. I-nodes"
  583. at our Bible).   The disk buffer usage at this time is as follows;
  584.     ________________________
  585.     |                      |
  586.     |                      | <- contents of data block shown
  587.     |     DiskBuff_#2      |    by zone[8]  (double indirect zone)
  588.     |                      |
  589.     |======================|
  590.     |                      |
  591.     |                      | <- contents of data block shown by zone[7]
  592.     |     DiskBuff_#1      |
  593.     |                      |
  594.     |======================|~~~~~~~~~~~~~~~~~~~~ contens of zone[6]..[1]
  595.     |     work area        |\ aux disk buffer    ques here downward to
  596.     |~~~~~~~~~~~~~~~~~~~~~~| \__________________ lower memory address
  597.     |    stack area        |
  598.  
  599.  
  600.     Thus the numbers of blocks which show the addresses of boot-image of
  601. Minix  is arranged  from  top of the auxiliary buffer,  ie.  the  lowest
  602. address, to DiskBuff_#1.  To read image-file, put the pointer to the top
  603. of the aux-buffer  and  read  the contents of block shown by it, sequen-
  604. tially.   When the pointer arrived at the bottom of the Buffer_#1,  then
  605. get the indirect-block address from DiskBuff_#2 and the contents of  the
  606. block  should be  loaded  into  memory  increasing  the pointer  to  the
  607. DisdBuff_#1.....until the block-number is satisfied.  Of course, increa-
  608. sing the pointer should be in 1024-bytes.
  609.  
  610.  
  611.  
  612. 3.3.2.4    Transfering control from MXboot to mune
  613.  
  614.     After the boot-image loaded successfully,  MXboot  long-jumps to the
  615. entry of "menu" setting partition number (where started booting) to  BH,
  616. and  data-segment value to DS, ES  and SS.   When "bootblock" is not one
  617. expected and automatic booting is suspended, "0x000F" will be set on BX.
  618. (no matter if MSB of "BL" is reset).
  619.  
  620.  
  621.  
  622. 3.4    what "menu" do when booted from Hard-drive.
  623.  
  624.     MXboot  loads  kernel-image-file  from Minix's file system.   MXboot
  625. knows the drive-number  and  its partition number  where it is  written,
  626. so it tells to  "menu", and  "menu"  sets these  as root-file-system  of
  627. Minix.  Setting the root-file-system  is  made by  setting  the  device-
  628. number at boot_parameters.bp_rootdev defined in /usr/include/minix/boot.h.
  629. This is done in function setparam() in menu.c, which gets boot drive and
  630. its partition number in BX-register from MXboot.  If it is the partition
  631. of the hard-disk,  it reads the partition-table of the drive  from which
  632. it was booted,  then  sorts the table.   This sort is necessary to match
  633. with Minix's driver.   Then  it calculates device-number from the drive-
  634. number and partition-number after sort, and set it to
  635. boot_parameters.bp_rootdev.
  636.  
  637.     In case of minix-V,  further works such as reading font-files placed
  638. in  /system directory  or  checks for OADG-keyboards....  are  necessary
  639. besides setting root-file-system.  Routines for font-files are placed in
  640. tools/option.c,  and it is almost same as MXboot's logic,  expressed  in
  641. C-language.
  642.  
  643.             (to be continued.)
  644. ========================================================================
  645. This is  originally  written in  Japanese  and  trially translated  into
  646. (broken :-) English by nemossan@mix == nemossan@uitec.ac.jp.
  647.  
  648.     Aug 19 '92 (Wed) 11:00 JST(+9:00)   nemossan@uitec.ac.jp
  649.