bootimage.c
Skip to line: 7050 - 7100 - 7150 - 7200 - 7250 - 7300 - 7350 - 7400 - 7450 - 7500 - 7550 - 7600 - 7650


Highlighted entries were made in the last day
Select a different time increment to highlight entries
Current GMT time: Jul 23 2008 21:45:54

If you have a comment for bootimage.c, please click here.
Name: kEmail:  kDate: Apr 23 2006 12:00:50 GMT
Subject:  k
Reponse: k
Name: Andy11Email:  Date: Aug 26 2006 18:22:31 GMT
Subject: Re: k
Reponse: Andy11
 
 Continue discussion.
 
 
Name: vuuiEmail:  marena_com@yahoo.comDate: Mar 20 2006 17:43:19 GMT
Subject:  nklp;gh
Reponse: ffd
 
Respond to vuui's comment.
 
 
Name: mahmoudEmail:  mahmoud_salah733@yahoo.comDate: Mar 07 2006 14:08:40 GMT
Subject:  mido
Reponse: انا عاوز البرنامج
 
Respond to mahmoud's comment.
 
 
Name: MOHAMEDEmail:  DR_M_SAID_EG@HOTMAIL.COMDate: Oct 08 2005 09:08:25 GMT
Subject:  BOOTIMAGE FOR XP-PROFESSIONAL SP2
Reponse: THANKS ALOT
Name: SAEID ASWEDFEmail:  SAEID_SARA10@yahoo!.COMDate: Jun 12 2006 00:19:38 GMT
Subject: Re: BOOTIMAGE FOR XP-PROFESSIONAL SP2
Reponse: SAZCFEW FSETSGF
sub Add something below SAEID ASWEDF's comment...
Name: anwEmail:  thatsadd@yahoo.comDate: Jul 28 2006 06:55:52 GMT
Subject: Re: BOOTIMAGE FOR XP-PROFESSIONAL SP2
Reponse: i want's that
sub Add something below anw's comment...
Name: zzzzzzzzzzEmail:  lilil_mo7areb_ilili@yahoo.cnDate: Mar 11 2008 14:22:50 GMT
Subject: Re: BOOTIMAGE FOR XP-PROFESSIONAL SP2
Reponse: as
 
 Continue discussion.
 
 
Name: winxpsp2Email:  bahaafun@yahoo.comDate: Jul 09 2005 20:17:05 GMT
Subject:  xpsp2
Reponse: this programe is very important also itis sample.
Name: hanyEmail:  hany_597@yahoo.comDate: Jul 22 2005 08:00:09 GMT
Subject: Re: xpsp2
Reponse: i want xpsp2
thank you
sub Add something below hany's comment...
Name: mattarEmail:  mahmoud_h_mattar@yahoo.comDate: Jul 27 2005 15:20:34 GMT
Subject: Re: xpsp2
Reponse: i want this file
 
 Continue discussion.
 
 
Name: heshamEmail:  hesham1001@yahoo.comDate: Jul 09 2005 11:47:58 GMT
Subject:  BootImage
Reponse: BootImage
for xp sp2
Name: mahmoudEmail:  Date: Jul 31 2005 03:43:45 GMT
Subject: Re: BootImage
Reponse: save as bootimage
sub Add something below mahmoud's comment...
Name: samerEmail:  samer_mohumed@yahoo.comDate: Jan 18 2006 16:53:19 GMT
Subject: Re: BootImage
Reponse: plz i need the boot file to make the cd bootbale
sub Add something below samer's comment...
Name: kEmail:  kDate: Apr 23 2006 12:01:49 GMT
Subject: Re: BootImage
Reponse: k
sub Add something below k's comment...
Name: rashidEmail:  RASHIDWEST@HOTMAIL>COMDate: Jul 03 2006 00:38:47 GMT
Subject: Re: BootImage
Reponse: i went BOOTIMAGE FOR XP-PROFESSIONAL SP2
 
 Continue discussion.
 
 
Expand/Collapse Item
Expand/Collapse Item7000    /*     bootimage.c - Load an image and start it.      Author: Kees J. Bot
Expand/Collapse Item7001     *                                                            19 Jan 1992
Expand/Collapse Item7002     */
bootminix() (line 7647) is invoked by the boot monitor boot command and (if options are passed to the kernel) by the boot monitor boot -optsvar command.  bootminix() is the high-level function that:

1)  calls
select_image() (line 7589) to find the desired OS image file on disk.

2)  calls
exec_image() (line 7348); exec_image() loads the OS image and calls minix(), which switches the system to protected mode (if the kernel was compiled for protected mode) and then jumps to the kernel.

bootminix() returns when the OS returns to the boot monitor (for example, when the user issues the shutdown command).
Expand/Collapse Item7003    #define BIOS          1       /* Can only be used under the BIOS.*/
#define is a preprocessor command.  The preprocessor replaces all occurrences of the first string (in this case, "BIOS") with the second string (in this case, "1") before compilation.

The string "
BIOS" actually never occurs in this file after this #define.  It is important to note, however, that bootimage.c is used to create boot, the boot monitor, but is not used to create the edparams utility program.
Expand/Collapse Item7004   #define nil 0
The string "nil" is used to increase readability.
7006
7005   #define _POSIX_SOURCE   1
Expand/Collapse Item7006    #define _MINIX        \1
_POSIX_SOURCE and _MINIX are macros that are used by library routines.  In fact, nearly all macros that begin with an underscore (_) are specific to library routines.

The POSIX standard was created to improve portability between UNIX systems.  The 12th paragraph of section 2.6.2, lines 01184-011200, and lines 01241-01245 in Operating Systems describe the
_POSIX_SOURCE and _MINIX macros.
Expand/Collapse Item7007    #include <stddef.h>
A function must be either defined or declared in a file before it can be used.  Header files (files ending in .h) make the task of declaring variables easier.

Before compilation begins, the preprocessor replaces any
#include <filename.h> statement with the contents of filename.h.  If the filename is enclosed in < and >, the preprocessor searches for the file in the default directory (typically /usr/include) and other directories specified by the -I option of the compiler (see line 7018).  If the filename is quoted (see line 7021), the preprocessor looks for the include file in the same directory that the source file is found.  (In this case, bootimage.c is the source file and is found in the /usr/src/boot directory.)

As an example,
strlen() (see line 7622) is declared in the file string.h (see line 7012).  string.h is located in the directory /usr/include.

Header files, in addition to containing function declarations, also frequently contain
#defines.  For example, RATIO (see line 7232) is #defined in boot.h.  Since boot.h is quoted (see line 7023), the preprocessor searches for boot.h in the same directory as bootimage.c.  Indeed, both files are in the /usr/src/boot directory.
7008   #include <sys/types.h>
7009   #include <sys/stat.h>
7010   #include <stdlib.h>
7011   #include <limits.h>
7012   #include <string.h>
Expand/Collapse Item7013    #include <errno.h>
errno is declared in errno.h (see line 00230 in the book) as extern.  Memory for a variable can be allocated in only one file (i.e. the variable is "defined") but the variable must be declared as extern in every other file that accesses it.  However, memory is not allocated for errno in boothead.s, boot.c, bootimage.c, or rawfs.c.  If you understand how memory is allocated for errno, please submit a comment to the site which will be displayed below.
Name: Christos KarayiannisEmail:  christos@kar.forthnet.grDate: Dec 07 2003 17:10:23 GMT
Subject:  where is errno defined?
Reponse: errno is declared in errno.h as extern and is defined in src/lib/other/errno.c
This file contains:

=========

#include
/* errno.c - declare variable errno Author: F. Meulenbroeks */

int errno = 0;

=========

Note that includes
This is because the .c file containing the definition should also #include the header file containing the external declaration, so that the compiler can check that the declarations match.
Name: Christos KarayiannisEmail:  christos@kar.forthnet.grDate: Dec 13 2003 17:18:19 GMT
Subject: Re: where is errno defined?
Reponse: Somehow some words are missing from my text.
Please add lib.h after the #include
and replace the "Note that includes" with
"Note that lib.h includes errno.h"
(I ommited the brackets in the header files because those was the reason of the problem)
Add something below Christos Karayiannis's comment...
Name: hassanEmail:  hassan_7317375@hotmail.comDate: Dec 06 2005 18:29:04 GMT
Subject: Re: where is errno defined?
Reponse: اريد بوت ستارت اب يصلح لكل ويندوزxp
 
 Continue discussion.
 
 
7014   #include <a.out.h>
7015   #include <minix/config.h>
7016   #include <minix/const.h>
7017   #include <minix/type.h>
Expand/Collapse Item7018    #include <kernel/const.h>
If a filename is enclosed in < and >, the preprocessor searches for the file in the default directory (typically /usr/include) and other directories specified by the -I option of the compiler.  In Makefile, the parent directory (..) is specified by the -I option.  Makefile is found in /usr/src/boot; therefore, the parent directory is /usr/src.  After the preprocessor unsuccessfully looks for const.h in the /usr/include/kernel directory, the preprocessor looks for (and finds) const.h in the /usr/src/kernel directory.  Note that the preprocessor can't find const.h in /usr/src/kernel since this directory doesn't exist.
7019   #include <kernel/type.h>
7020   #include <ibm/partition.h>
7021   #include "rawfs.h"
7022   #include "image.h"
7023   #include "boot.h"
7024
Expand/Collapse Item7025    #define click_shift clck_shft      /* 7 char clash with click_size. */
The kernel often uses "clicks" instead of bytes to describe the size of memory objects.  The click shift for the kernel is found at the beginning of the kernel code (i.e. text) segment (see line 06053 in the book) and is equal to 8.  A size in bytes is shifted 8 bits to the right to get the size in clicks.  For example, 0x0300 bytes is equal to 0x03 clicks.

The kernel and the boot monitor save space by converting sizes in bytes to sizes in clicks.  The text and data sizes in clicks for the kernel, memory manager (mm), file system (fs), and init (plus any other server that is part of the OS image) are patched into the beginning of the kernel data (see line 7182).  2 bytes are used for each size in clicks; if byte sizes were instead used, 2 bytes would not be enough.
7026
Expand/Collapse Item7027  /*Some kernels have extra features: */
Different kernels have different capabilities and different requirements.  The word (2 bytes) at offset FLAGS_OFF (=4; see line 7056) into the kernel code (see line 06055 in Operating Systems ) holds the 8 flags that define these capabilities and requirements.  The value of this word is stored in k_flags (on line 7305).

Note that
k_flags for the kernel given in the book is 0x2D ( K_I386, K_CHMEM, K_HIGH, and K_RET are set).
Expand/Collapse Item7028    #define K_I386   0x0001 /* Make the 386 transition before you call me. */
In boothead.s, a switch to protected mode is made if the K_I386 flag is set in k_flags.
Expand/Collapse Item7029    #define K_CLAIM  0x0002 /* I will acquire my own bss pages, thank you. */
If the kernel flag K_CLAIM is set, memory for the stack or the bss is not allocated to any process except the kernel (see line 7481).
Expand/Collapse Item7030    #define K_CHMEM  0x0004 /* This kernel listens to chmem for its stack size. */
If the kernel flag K_CHMEM is not set, memory for the stack is not allocated to any of the processes (see lines 7435 and 7497-7503).
Expand/Collapse Item7031    #define K_HIGH   0x0008 /* Load mm, fs, etc. in extended memory. */
If the K_HIGH flag is set in k_flags, mm, fs, inet (if network support is enabled) and init are loaded into extended memory (>1MB) (see line 7508).  Note that your system must have extended memory if you compile a kernel with this flag set.
Expand/Collapse Item7032    #define K_HDR    0x0010 /* No need to patch sizes, kernel uses the headers. */
Various sizes need to be patched into various locations (see patch_sizes() on line 7160).  However, if the kernel flag K_HDR flag is set, this patching is unnecessary and the kernel instead uses the headers to determine the sizes.
Expand/Collapse Item7033    #define K_RET    0x0020 /* Returns to the monitor on reboot. */
If the K_RET flag is set in k_flags, the shutdown command returns minix to the boot monitor.  The return code is in boothead.s.
Expand/Collapse Item7034    #define K_INT86  0x0040 /* Requires generic INT support. */
The code for generic INT support is in boothead.s.   Generic INT support allows the kernel to switch back to real mode to make a bios function call.
Expand/Collapse Item7035    #define K_MEML   0x0080 /* Pass a list of free memory. */
The array mem[] is the memory map (or list).  mem[] is initialized in boothead.s and is passed to the kernel as the environment variable memory.
7036
7037
7038 /*Data about the different processes. */
7039
Expand/Collapse Item7040    #define PROCESS_MAX    16     /* Must match the space in kernel/mpx.x */
The text and data click sizes (see comments for line 7025) for the kernel, memory manager (mm), file system (fs) and init (plus any other server that is part of the OS image) are patched into the beginning of the kernel data (see line 7182).  16*2*2 = 64 bytes are reserved for these sizes on line 06478 in the book - 2 bytes for each text size and 2 bytes for each data size.  64 bytes is enough space for the kernel sizes, mm sizes, fs sizes, init sizes and the sizes for 12 other servers.

Note that the magic number on line 06480 (in the book) is overwritten.
exec_image() (line 7348) first checks the magic number (see line 7521) and then patches the sizes (see line 7528).
Expand/Collapse Item7041    #define KERNEL        0       /* The first process is the kernel.*/
Expand/Collapse Item7042    #define FS             2       /* The third must be fs. */
The OS is loaded into memory in the following order:

1) kernel
2) memory manager (mm)
3) file system (fs)
4) inet (if network support is enabled)
5) init
7043
Expand/Collapse Item7044    struct  process{       /* Per-process memory adresses. */
struct process describes the layout of a process in memory. process[] (see line 7050) holds the memory layout for each process in the OS image file.  process[] is populated by exec_image() (see lines 7448, 7450, 7458, 7463, 7465, and 7506) and then the values from process[] are used to patch sizes into the kernel data section (see patch_sizes() on line7160).
Expand/Collapse Item7045           u32_t  entry;         /* Entry point.*/
entry is the offset of the first instruction to be executed in an executable.  For example, process[KERNEL].entry is the first argument in the call to minix() (see lines 7055-7056).
Expand/Collapse Item7046           u32_t  cs;            /*Code segment. */
Expand/Collapse Item7047           u32_t  ds;            /*Data segment. */
Expand/Collapse Item7048           u32_t  data;          /* To access the data segment. */
Expand/Collapse Item7049           u32_t   end;           /* End of this process, size = (end - cs). */
cs is the absolute memory address of the beginning of the code and data is the absolute memory address of the beginning of the data. end is the absolute memory address of the end of the process in memory.  The meaning of ds depends on whether the A_SEP flag is set (see line 7453).  (see comment on line 7212 for an explanation of the A_SEP flag.)

7050   }process[PROCESS_MAX ];
Expand/Collapse Item7051    int  n_procs;                   /* Number of processes. */
If the kernel, the memory manager (mm), the file system (fs), the network server (inet), and init are in the OS image file and all these processes are loaded into memory, n_procs will be equal to 5.  n_procs is set in exec_image() (see line 7515).
7052
7053 /*Magic numbers in process' data space. */
Expand/Collapse Item7054    #define MAGIC_OFF     0       /* Offset of magic # in data seg.*/
The magic number (KERNEL_D_MAGIC = 0x526F) is at the beginning (MAGIC_OFF = 0) of the kernel data segment (see line 06478 in the book).

Note that
MAGIC_OFF and P_SIZ_OFF (see line 7060) are both offsets into the kernel data segment and are both equal to 0.  The text and data sizes (see comments for line 7040) are patched into the kernel data segment at offset P_SIZ_OFF (see line 7075). exec_image() (line 7348) first checks the magic number (see line 7521) and then patches over the magic number with the sizes (see line 7528).
Expand/Collapse Item7055    #define CLICK_OFF     2       /* Offset in kernel text to click_shift.*/
Expand/Collapse Item7056    #define FLAGS_OFF      4       /* Offset in kernel text to flags.*/
The kernel often uses "clicks" instead of bytes to describe the sizes of different memory objects.  The click shift for the kernel is found at an offset of CLICK_OFF in the kernel code (i.e. text) segment (see line 06053 in the book) and is equal to 8.  A size in bytes is shifted 8 bits to the right to get the click size.  For example, 0x0300 bytes is equal to 0x03 clicks.

The kernel and the boot monitor save space by converting byte sizes to click sizes.  The text and data click sizes for the kernel, memory manager (mm), file system (fs), and init (plus any other server that is part of the OS image) are patched into the beginning of the kernel data (see line 7182).  2 bytes are used for each click size; if byte sizes were instead used, 2 bytes would not be enough.

The kernel flags are found at an offset of
FLAGS_OFF in the kernel code segment (see line 06055 in the book).  These flags are described in the comments for lines 7028-7035.
7057   #define KERNEL_D_MAGIC  0x526F  /*Kernel magic number. */
7058
7059 /*Offsetsof sizes to be patched into kernel and fs. */
Expand/Collapse Item7060    #define P_SIZ_OFF     0       /* Process' sizes into kernel data.*/
Note that MAGIC_OFF and P_SIZ_OFF (see line 7060) are both offsets into the kernel data segment and are both equal to 0.  The text and data sizes (see comments for line 7040) are patched into the kernel data segment at offset P_SIZ_OFF (see line 7075).  exec_image() (line 7348) first checks the magic number (see line 7521) and then patches the sizes (see line 7528).
Expand/Collapse Item7061    #define P_INIT_OFF     4       /* Init cs & sizes into fs data.*/
The text and data click sizes for init are patched into the file system (fs) data segment (see line 7191).
7062
7063
Expand/Collapse Item7064    #define  between(a,c,z)        ((unsigned) ((c) - (a)) lt;=((z) - (a)))
between() returns TRUE if c is between a and z.
7065
Expand/Collapse Item7066    void  pretty_image(char*image)
OS image files are typically placed in the /minix directory.
7067   /* Pretty print the name of the image to load. Translate '/' and '_' to
7068    * space, first letter goes uppercase. An 'r' before a digit prints as
7069    * 'revision'.  E.g. 'minix/1.6.16r10'->'Minix 1.6.16 revision 10'.
7070    * The idea is that the part before the 'r'is the official Minix release
7071    * and after the 'r' you can put versionnumbers for your own changes.
7072    */
7073   {
7074          int up= 0, c;
7075
Expand/Collapse Item7076           while ((c= *image++) != 0) {