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/i386ps2/model_dep.c

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /* 
    2  * Mach Operating System
    3  * Copyright (c) 1993,1991,1990,1989,1988 Carnegie Mellon University
    4  * Copyright (c) 1991 IBM Corporation 
    5  * All Rights Reserved.
    6  * 
    7  * Permission to use, copy, modify and distribute this software and its
    8  * documentation is hereby granted, provided that both the copyright
    9  * notice and this permission notice appear in all copies of the
   10  * software, derivative works or modified versions, and any portions
   11  * thereof, and that both notices appear in supporting documentation,
   12  * and that the name IBM not be used in advertising or publicity 
   13  * pertaining to distribution of the software without specific, written
   14  * prior permission.
   15  * 
   16  * CARNEGIE MELLON AND IBM ALLOW FREE USE OF THIS SOFTWARE IN ITS "AS IS"
   17  * CONDITION.  CARNEGIE MELLON AND IBM DISCLAIM ANY LIABILITY OF ANY KIND FOR
   18  * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
   19  * 
   20  * Carnegie Mellon requests users of this software to return to
   21  * 
   22  *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
   23  *  School of Computer Science
   24  *  Carnegie Mellon University
   25  *  Pittsburgh PA 15213-3890
   26  * 
   27  * any improvements or extensions that they make and grant Carnegie Mellon
   28  * the rights to redistribute these changes.
   29  */
   30 
   31 /*
   32  * COMPONENT_NAME: (I386) Mach port to i386 platform
   33  *
   34  * FUNCTIONS: 
   35  *
   36  * ORIGINS: 6, 27
   37  */
   38 /*
   39  * HISTORY
   40  * $Log:        model_dep.c,v $
   41  * Revision 2.3  93/11/17  16:54:27  dbg
   42  *      Added ANSI function prototypes.
   43  *      [93/09/21            dbg]
   44  *      Removed timemmap - it is now machine independent.  Removed
   45  *      inittodr and startrtclock for new clock devices.
   46  *      [93/06/16            dbg]
   47  * 
   48  * Revision 2.2  93/02/04  08:01:21  danner
   49  *      Initialize NMI here.
   50  *      [92/03/30            dbg@ibm]
   51  * 
   52  *      Add io_space_offset_to_addr - first step in IO space object
   53  *      [92/03/22            dbg@ibm]
   54  * 
   55  *      PS2 version
   56  *      [92/02/24            dbg@ibm]
   57  * 
   58  * Revision 2.7  92/01/03  20:11:49  dbg
   59  *      Fixed so that mem_size can be patched to limit physical memory
   60  *      use.
   61  *      [91/09/29            dbg]
   62  * 
   63  *      Rename kdb_init to ddb_init.  Remove esym.
   64  *      [91/09/11            dbg]
   65  * 
   66  * Revision 2.6  91/07/31  17:42:41  dbg
   67  *      Remove call to pcb_module_init (in machine-independent code).
   68  *      [91/07/26            dbg]
   69  * 
   70  * Revision 2.5  91/06/19  11:55:48  rvb
   71  *      cputypes.h->platforms.h
   72  *      [91/06/12  13:45:37  rvb]
   73  * 
   74  * Revision 2.4  91/05/18  14:30:38  rpd
   75  *      Changed pmap_bootstrap arguments.
   76  *      Moved pmap_free_pages and pmap_next_page here.
   77  *      [91/05/15            rpd]
   78  * 
   79  * Revision 2.3  91/05/14  16:29:13  mrt
   80  *      Correcting copyright
   81  * 
   82  * Revision 2.2  91/05/08  12:44:52  dbg
   83  *      Initialization for i386 AT bus machines only.
   84  *      Combine code that was in i386/init.c and i386/i386_init.c.
   85  *      [91/04/26  14:40:43  dbg]
   86  * 
   87  * Revision 2.3  90/09/23  17:45:10  jsb
   88  *      Added support for iPSC2.
   89  *      [90/09/21  16:39:41  jsb]
   90  * 
   91  * Revision 2.2  90/05/03  15:27:39  dbg
   92  *      Alter for pure kernel.
   93  *      [90/02/15            dbg]
   94  * 
   95  * Revision 1.5.1.4  90/02/01  13:36:37  rvb
   96  *      esym must always be defined.  This is as good a place as any.
   97  *      [90/01/31            rvb]
   98  * 
   99  * Revision 1.5.1.3  89/12/28  12:43:10  rvb
  100  *      Fix av_start & esym initialization, esp for MACH_KDB.
  101  *      [89/12/26            rvb]
  102  * 
  103  * Revision 1.5.1.2  89/12/21  17:59:49  rvb
  104  *      enable esym processing.
  105  * 
  106  * 
  107  * Revision 1.5.1.1  89/10/22  11:30:41  rvb
  108  *      Setup of rootdevice should not be here.  And it was wrong.
  109  *      [89/10/17            rvb]
  110  * 
  111  *      Scary!  We've changed sbss to edata.  AND the coff loader
  112  *      following the vuifile spec was actually aligning the bss 
  113  *      on 4k boundaries.
  114  *      [89/10/16            rvb]
  115  * 
  116  * Revision 1.5  89/04/05  12:57:39  rvb
  117  *      Move extern out of function scope for gcc.
  118  *      [89/03/04            rvb]
  119  * 
  120  * Revision 1.4  89/02/26  12:31:25  gm0w
  121  *      Changes for cleanup.
  122  * 
  123  * 31-Dec-88  Robert Baron (rvb) at Carnegie-Mellon University
  124  *      Derived from MACH2.0 vax release.
  125  *
  126  */
  127 
  128 /*
  129  *      File:   model_dep.c
  130  *      Author: Avadis Tevanian, Jr., Michael Wayne Young
  131  *
  132  *      Copyright (C) 1986, Avadis Tevanian, Jr., Michael Wayne Young
  133  *
  134  *      Basic initialization for I386 - PS2 (MCA bus) machines.
  135  */
  136 
  137 #include <platforms.h>
  138 #include <mach_kdb.h>
  139 
  140 #include <mach/i386/vm_param.h>
  141 
  142 #include <mach/vm_param.h>
  143 #include <mach/vm_prot.h>
  144 #include <kern/kern_io.h>
  145 #include <kern/machine.h>
  146 #include <kern/memory.h>
  147 #include <vm/vm_page.h>
  148 #include <i386/machspl.h>
  149 
  150 #if     MACH_KDB
  151 #include <sys/reboot.h>
  152 #endif  /* MACH_KDB */
  153 
  154 int             loadpt;
  155 
  156 vm_size_t       mem_size = 0;
  157 vm_size_t       rawmem_size;
  158 vm_offset_t     first_addr = 0; /* set by start.s - keep out of bss */
  159 vm_offset_t     first_avail = 0;/* first after page tables */
  160 vm_offset_t     last_addr;
  161 
  162 vm_offset_t     avail_start, avail_end;
  163 vm_offset_t     virtual_avail, virtual_end;
  164 vm_offset_t     hole_start, hole_end;
  165 vm_offset_t     avail_next;
  166 unsigned int    avail_remaining;
  167 
  168 /* parameters passed from bootstrap loader */
  169 int             cnvmem = 0;             /* must be in .data section */
  170 int             extmem = 0;
  171 int             boottype = 0;
  172 
  173 extern char     edata, end;
  174 
  175 extern char     version[];
  176 
  177 extern void     setup_main(void);
  178 
  179 int             rebootflag = 0; /* exported to kdintr */
  180 
  181 void    i386_init(void);        /* forward */
  182 
  183 /*
  184  *      Cpu initialization.  Running virtual, but without MACH VM
  185  *      set up.  First C routine called.
  186  */
  187 void machine_startup(void)
  188 {
  189         /*
  190          * Do basic VM initialization
  191          */
  192         i386_init();
  193 
  194         /*
  195          * Initialize the console so we can print.
  196          */
  197         cninit();
  198 #if     MACH_KDB
  199 
  200         /*
  201          * Initialize the kernel debugger.
  202          */
  203         ddb_init();
  204 
  205         /*
  206          * Cause a breakpoint trap to the debugger before proceeding
  207          * any further if the proper option bit was specified in
  208          * the boot flags.
  209          *
  210          * XXX use -a switch to invoke kdb, since there's no
  211          *     boot-program switch to turn on RB_HALT!
  212          */
  213         if (boothowto & RB_ASKNAME)
  214             Debugger("");
  215 #endif  /* MACH_KDB */
  216 
  217         pos_init();             /* get POS registers */
  218         abios_init();           /* set up ABIOS */
  219 
  220 #if     MACH_RDB
  221         printf("entering db_kdb\n");
  222         db_kdb(-1,0,0);
  223 #endif  /* MACH_RDB */
  224 
  225         printf(version);
  226 
  227         machine_slot[0].is_cpu = TRUE;
  228         machine_slot[0].running = TRUE;
  229         machine_slot[0].cpu_type = CPU_TYPE_I386;
  230         machine_slot[0].cpu_subtype = CPU_SUBTYPE_PS2;
  231 
  232         /*
  233          * Start the system.
  234          */
  235         setup_main();
  236 }
  237 
  238 /*
  239  * Find devices.  The system is alive.
  240  */
  241 void machine_init(void)
  242 {
  243         /*
  244          * Set up to use floating point.
  245          */
  246         init_fpu();
  247 
  248         /*
  249          * Find the devices
  250          */
  251         probeio();
  252 
  253         /*
  254          * Find the root device
  255          */
  256         get_root_device();
  257 
  258         /*
  259          * Enable NMI interrupts.
  260          */
  261         nmi_enable();
  262 }
  263 
  264 /*
  265  * Halt a cpu.
  266  */
  267 void halt_cpu(void)
  268 {
  269   printf("\n*** HALTED ***\n");
  270   (void) spl0();
  271   for (;;)
  272     continue;
  273 }
  274 
  275 /*
  276  * Halt the system or reboot.
  277  */
  278 void halt_all_cpus(
  279         boolean_t       reboot)
  280 {
  281         if (reboot) {
  282             /*
  283              * Tell the BIOS not to clear and test memory.
  284              */
  285             *(unsigned short *)phystokv(0x472) = 0x1234;
  286 
  287             kdreboot();
  288         }
  289         else {
  290             rebootflag = 1;
  291             printf("In tight loop: hit ctl-alt-del to reboot\n");
  292             (void) spl0();
  293         }
  294         for (;;)
  295             continue;
  296 }
  297 
  298 /*
  299  * Basic VM initialization.
  300  */
  301 void i386_init(void)
  302 {
  303         /*
  304          * Zero the BSS.
  305          */
  306         bzero((char *)&edata,(unsigned)(&end - &edata));
  307 
  308         /*
  309          * Initialize the pic prior to any possible call to an spl.
  310          */
  311         picinit();
  312 
  313         vm_set_page_size();
  314 
  315         /*
  316          * Compute the memory size.
  317          */
  318         first_addr = 0x1000;
  319                 /* BIOS leaves data in low memory */
  320         last_addr = 1024*1024 + extmem*1024;
  321                 /* extended memory starts at 1MB */
  322         if (mem_size != 0) {
  323             if (mem_size < last_addr - loadpt)
  324                 last_addr = loadpt + mem_size;
  325         }
  326         mem_size = last_addr - loadpt;
  327 
  328         first_addr = round_page(first_addr);
  329         last_addr = trunc_page(last_addr);
  330 
  331         /*
  332          *      Initialize kernel physical map, mapping the
  333          *      region from loadpt to avail_start.
  334          *      Kernel virtual address starts at VM_KERNEL_MIN_ADDRESS.
  335          */
  336 
  337         avail_start = first_addr;
  338         avail_end = last_addr;
  339         printf("PS2 boot: memory from 0x%x to 0x%x\n", avail_start,
  340                         avail_end);
  341 
  342         pmap_bootstrap(loadpt);
  343 
  344         /*
  345          *      Initialize for pmap_free_pages and pmap_next_page.
  346          *      These guys should be page-aligned.
  347          */
  348 
  349         hole_start = trunc_page((vm_offset_t)(1024 * cnvmem));
  350         hole_end = round_page((vm_offset_t)first_avail);
  351 
  352         avail_remaining = atop((avail_end - avail_start) -
  353                                (hole_end - hole_start));
  354         avail_next = avail_start;
  355 
  356         printf("PS2_init: virtual_avail = %x, virtual_end = %x\n",
  357                 virtual_avail, virtual_end);
  358 
  359 }
  360 
  361 unsigned int pmap_free_pages(void)
  362 {
  363         return avail_remaining;
  364 }
  365 
  366 boolean_t pmap_next_page(
  367         vm_offset_t *addrp)
  368 {
  369         if (avail_next == avail_end)
  370                 return FALSE;
  371 
  372         /* skip the hole */
  373 
  374         if (avail_next == hole_start)
  375                 avail_next = hole_end;
  376 
  377         *addrp = avail_next;
  378         avail_next += PAGE_SIZE;
  379         avail_remaining--;
  380         return TRUE;
  381 }
  382 
  383 boolean_t pmap_valid_page(
  384         vm_offset_t x)
  385 {
  386         return (avail_start <= x && x < avail_end) &&
  387                !(hole_start <= x && x < hole_end);
  388 }
  389 
  390 /*
  391  * Given an offset into the IO space object:
  392  * return (TRUE, phys_addr) if the offset is valid,
  393  * return (FALSE, *)        if the offset is invalid.
  394  */
  395 boolean_t
  396 io_space_offset_to_addr(
  397         vm_offset_t     offset,
  398         vm_offset_t     *phys_addr)     /* OUT */
  399 {
  400         /*
  401          * Include:
  402          * BIOS vectors:        0..3ff
  403          * BIOS data:         400..5ff
  404          * ABIOS data: hole_start..9ffff
  405          * IO space:        a0000..fffff
  406          *
  407          * and eventually the rest of the 24-bit and
  408          * 32-bit IO spaces...
  409          */
  410         if (offset <= 0x1000 ||
  411             (offset >= hole_start && offset < 0x100000))
  412         {
  413             *phys_addr = offset;
  414             return TRUE;
  415         }
  416         return FALSE;
  417 }
  418 

Cache object: 4aaeb26e8afc97ad9dd72c487a01a239


[ 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.