The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/kernel/start.c

Version: -  FREEBSD  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-2  -  FREEBSD-11-1  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-4  -  FREEBSD-10-3  -  FREEBSD-10-2  -  FREEBSD-10-1  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-3  -  FREEBSD-9-2  -  FREEBSD-9-1  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-4  -  FREEBSD-8-3  -  FREEBSD-8-2  -  FREEBSD-8-1  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-4  -  FREEBSD-7-3  -  FREEBSD-7-2  -  FREEBSD-7-1  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-4  -  FREEBSD-6-3  -  FREEBSD-6-2  -  FREEBSD-6-1  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-5  -  FREEBSD-5-4  -  FREEBSD-5-3  -  FREEBSD-5-2  -  FREEBSD-5-1  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  linux-2.6  -  linux-2.4.22  -  MK83  -  MK84  -  PLAN9  -  DFBSD  -  NETBSD  -  NETBSD5  -  NETBSD4  -  NETBSD3  -  NETBSD20  -  OPENBSD  -  xnu-517  -  xnu-792  -  xnu-792.6.70  -  xnu-1228  -  xnu-1456.1.26  -  xnu-1699.24.8  -  xnu-2050.18.24  -  OPENSOLARIS  -  minix-3-1-1 
SearchContext: -  none  -  3  -  10 

    1 /* This file contains the C startup code for Minix on Intel processors.
    2  * It cooperates with mpx.s to set up a good environment for main().
    3  *
    4  * This code runs in real mode for a 16 bit kernel and may have to switch
    5  * to protected mode for a 286.
    6  * For a 32 bit kernel this already runs in protected mode, but the selectors
    7  * are still those given by the BIOS with interrupts disabled, so the
    8  * descriptors need to be reloaded and interrupt descriptors made.
    9  */
   10 
   11 #include "kernel.h"
   12 #include "protect.h"
   13 #include "proc.h"
   14 #include <stdlib.h>
   15 #include <string.h>
   16 
   17 FORWARD _PROTOTYPE( char *get_value, (_CONST char *params, _CONST char *key));
   18 /*===========================================================================*
   19  *                              cstart                                       *
   20  *===========================================================================*/
   21 PUBLIC void cstart(cs, ds, mds, parmoff, parmsize)
   22 U16_t cs, ds;                   /* kernel code and data segment */
   23 U16_t mds;                      /* monitor data segment */
   24 U16_t parmoff, parmsize;        /* boot parameters offset and length */
   25 {
   26 /* Perform system initializations prior to calling main(). Most settings are
   27  * determined with help of the environment strings passed by MINIX' loader.
   28  */
   29   char params[128*sizeof(char *)];              /* boot monitor parameters */
   30   register char *value;                         /* value in key=value pair */
   31   extern int etext, end;
   32 
   33   /* Decide if mode is protected; 386 or higher implies protected mode.
   34    * This must be done first, because it is needed for, e.g., seg2phys().
   35    * For 286 machines we cannot decide on protected mode, yet. This is 
   36    * done below. 
   37    */
   38 #if _WORD_SIZE != 2
   39   machine.protected = 1;        
   40 #endif
   41 
   42   /* Record where the kernel and the monitor are. */
   43   kinfo.code_base = seg2phys(cs);
   44   kinfo.code_size = (phys_bytes) &etext;        /* size of code segment */
   45   kinfo.data_base = seg2phys(ds);
   46   kinfo.data_size = (phys_bytes) &end;          /* size of data segment */
   47 
   48   /* Initialize protected mode descriptors. */
   49   prot_init();
   50 
   51   /* Copy the boot parameters to the local buffer. */
   52   kinfo.params_base = seg2phys(mds) + parmoff;
   53   kinfo.params_size = MIN(parmsize,sizeof(params)-2);
   54   phys_copy(kinfo.params_base, vir2phys(params), kinfo.params_size);
   55 
   56   /* Record miscellaneous information for user-space servers. */
   57   kinfo.nr_procs = NR_PROCS;
   58   kinfo.nr_tasks = NR_TASKS;
   59   strncpy(kinfo.release, OS_RELEASE, sizeof(kinfo.release));
   60   kinfo.release[sizeof(kinfo.release)-1] = '\0';
   61   strncpy(kinfo.version, OS_VERSION, sizeof(kinfo.version));
   62   kinfo.version[sizeof(kinfo.version)-1] = '\0';
   63   kinfo.proc_addr = (vir_bytes) proc;
   64   kinfo.kmem_base = vir2phys(0);
   65   kinfo.kmem_size = (phys_bytes) &end;  
   66 
   67   /* Processor?  86, 186, 286, 386, ... 
   68    * Decide if mode is protected for older machines. 
   69    */
   70   machine.processor=atoi(get_value(params, "processor")); 
   71 #if _WORD_SIZE == 2
   72   machine.protected = machine.processor >= 286;         
   73 #endif
   74   if (! machine.protected) mon_return = 0;
   75 
   76   /* XT, AT or MCA bus? */
   77   value = get_value(params, "bus");
   78   if (value == NIL_PTR || strcmp(value, "at") == 0) {
   79       machine.pc_at = TRUE;                     /* PC-AT compatible hardware */
   80   } else if (strcmp(value, "mca") == 0) {
   81       machine.pc_at = machine.ps_mca = TRUE;    /* PS/2 with micro channel */
   82   }
   83 
   84   /* Type of VDU: */
   85   value = get_value(params, "video");           /* EGA or VGA video unit */
   86   if (strcmp(value, "ega") == 0) machine.vdu_ega = TRUE;
   87   if (strcmp(value, "vga") == 0) machine.vdu_vga = machine.vdu_ega = TRUE;
   88 
   89   /* Return to assembler code to switch to protected mode (if 286), 
   90    * reload selectors and call main().
   91    */
   92 }
   93 
   94 /*===========================================================================*
   95  *                              get_value                                    *
   96  *===========================================================================*/
   97 
   98 PRIVATE char *get_value(params, name)
   99 _CONST char *params;                            /* boot monitor parameters */
  100 _CONST char *name;                              /* key to look up */
  101 {
  102 /* Get environment value - kernel version of getenv to avoid setting up the
  103  * usual environment array.
  104  */
  105   register _CONST char *namep;
  106   register char *envp;
  107 
  108   for (envp = (char *) params; *envp != 0;) {
  109         for (namep = name; *namep != 0 && *namep == *envp; namep++, envp++)
  110                 ;
  111         if (*namep == '\0' && *envp == '=') return(envp + 1);
  112         while (*envp++ != 0)
  113                 ;
  114   }
  115   return(NIL_PTR);
  116 }

Cache object: a376f3581ce732e57d90f4629eef172d


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.