Home | History | Annotate | Line # | Download | only in include
bootinfo.h revision 1.2.4.1
      1  1.2.4.1  simonb /*       $NetBSD: bootinfo.h,v 1.2.4.1 2006/04/22 11:38:01 simonb Exp $        */
      2      1.1     mrg 
      3      1.2     cdi /*-
      4      1.2     cdi  * Copyright (c) 2005 The NetBSD Foundation, Inc.
      5      1.2     cdi  * All rights reserved.
      6      1.2     cdi  *
      7      1.2     cdi  * Redistribution and use in source and binary forms, with or without
      8      1.2     cdi  * modification, are permitted provided that the following conditions
      9      1.2     cdi  * are met:
     10      1.2     cdi  * 1. Redistributions of source code must retain the above copyright
     11      1.2     cdi  *    notice, this list of conditions and the following disclaimer.
     12      1.2     cdi  * 2. Redistributions in binary form must reproduce the above copyright
     13      1.2     cdi  *    notice, this list of conditions and the following disclaimer in the
     14      1.2     cdi  *    documentation and/or other materials provided with the distribution.
     15      1.2     cdi  * 3. All advertising materials mentioning features or use of this software
     16      1.2     cdi  *    must display the following acknowledgement:
     17      1.2     cdi  *        This product includes software developed by the NetBSD
     18      1.2     cdi  *        Foundation, Inc. and its contributors.
     19      1.2     cdi  * 4. Neither the name of The NetBSD Foundation nor the names of its
     20      1.2     cdi  *    contributors may be used to endorse or promote products derived
     21      1.2     cdi  *    from this software without specific prior written permission.
     22      1.2     cdi  *
     23      1.2     cdi  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     24      1.2     cdi  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     25      1.2     cdi  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     26      1.2     cdi  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     27      1.2     cdi  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     28      1.2     cdi  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     29      1.2     cdi  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     30      1.2     cdi  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     31      1.2     cdi  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     32      1.2     cdi  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     33      1.2     cdi  * POSSIBILITY OF SUCH DAMAGE.
     34      1.2     cdi  */
     35      1.2     cdi 
     36      1.2     cdi #ifndef _BOOTINFO_H_
     37      1.2     cdi #define _BOOTINFO_H_
     38      1.2     cdi 
     39      1.2     cdi #include <machine/param.h>
     40      1.1     mrg #include <sparc/bootinfo.h>
     41      1.2     cdi 
     42      1.2     cdi /*
     43      1.2     cdi  * The bootloader v1.9 and higher makes a call into a kernel with the following
     44      1.2     cdi  * arguments:
     45      1.2     cdi  *
     46      1.2     cdi  * %o0		OpenFirmware entry point, to keep Sun's updaters happy
     47      1.2     cdi  * %o1		Address of boot information vector (see below)
     48      1.2     cdi  * %o2		Length of the vector, in bytes
     49      1.2     cdi  * %o3		OpenFirmware entry point, to mimic Sun bootloader behavior
     50      1.2     cdi  * %o4		OpenFirmware entry point, to meet earlier NetBSD kernels
     51      1.2     cdi  *              expectations
     52      1.2     cdi  *
     53      1.2     cdi  * All parameters are of void* type except for vector length which is of
     54      1.2     cdi  * integer type.
     55      1.2     cdi  *
     56      1.2     cdi  * The boot information vector format was dictated by earlier kernels and
     57      1.2     cdi  * starting from ofwboot v1.9 has four entries:
     58      1.2     cdi  *
     59      1.2     cdi  *      +-------------------------------------+
     60      1.2     cdi  * #0   | NetBSD boot magic number ('DDB2')   |
     61      1.2     cdi  *      +-------------------------------------+
     62      1.2     cdi  * #1   | ksyms' table end address            |
     63      1.2     cdi  *      +-------------------------------------+
     64      1.2     cdi  * #2   | ksyms' table start address          |
     65      1.2     cdi  *      +-------------------------------------+
     66      1.2     cdi  * #3   | Pointer to a bootinfo binary object |
     67      1.2     cdi  *      +-------------------------------------+
     68      1.2     cdi  *
     69      1.2     cdi  * Kernels written for pre-v1.8 ofwboot require first three cells to present
     70      1.2     cdi  * in this particular order, those that rely on v1.9 and higher won't work if
     71      1.2     cdi  * the last pointer is not in the table; therefore, the vector cannot be
     72  1.2.4.1  simonb  * shorter than 4 * sizeof(uint32_t) or 4 * sizeof(uint64_t) for 32-bit and
     73      1.2     cdi  * 64-bit boot loader, respectively.
     74      1.2     cdi  *
     75      1.2     cdi  * As of ofwboot v1.9,  bootinfo binary object is placed right after the kernel
     76      1.2     cdi  * data segment end, i.e. in the permanently locked 4MB page. There is no order
     77      1.2     cdi  * for the data located in bootinfo binary object. The kernel however expects
     78      1.2     cdi  * at least following parameters to exist in there:
     79      1.2     cdi  *
     80      1.2     cdi  * - Symbol information (size, start, end; see struct btinfo_symtab)
     81      1.2     cdi  * - Kernel end address, calculated as true kernel end address plus size of
     82      1.2     cdi  *   space reserved for bootinfo binary object (struct btinfo_kernend)
     83      1.2     cdi  * - Number of text segment pages (struct btinfo_count)
     84      1.2     cdi  * - Number of data segment pages (struct btinfo_count)
     85      1.2     cdi  * - Array of text pages VA/PA (struct btinfo_tlb)
     86      1.2     cdi  * - Array of data pages VA/PA (struct btinfo_tlb)
     87      1.2     cdi  *
     88      1.2     cdi  * The last four data structures fully describe kernel mappings. ofwboot v1.9
     89      1.2     cdi  * and higher map the kernel with 4MB permanent pages and this is the only
     90      1.2     cdi  * way to let kernel know how exactly it was mapped.
     91      1.2     cdi  */
     92      1.2     cdi 
     93      1.2     cdi /* Boot magic number */
     94      1.2     cdi #define SPARC_MACHINE_OPENFIRMWARE	0x44444230
     95      1.2     cdi 
     96      1.2     cdi #ifdef BOOTINFO_SIZE
     97      1.2     cdi #undef BOOTINFO_SIZE
     98      1.2     cdi #endif
     99      1.2     cdi 
    100      1.2     cdi #define BOOTINFO_SIZE			NBPG
    101      1.2     cdi 
    102      1.2     cdi #define BTINFO_DTLB_SLOTS		100
    103      1.2     cdi #define BTINFO_ITLB_SLOTS		101
    104      1.2     cdi #define BTINFO_DTLB			102
    105      1.2     cdi #define BTINFO_ITLB			103
    106      1.2     cdi #define BTINFO_KERNEND			104
    107      1.2     cdi 
    108      1.2     cdi #define LOOKUP_BOOTINFO(btp, info) \
    109      1.2     cdi do { \
    110      1.2     cdi 	if ( ((btp) = lookup_bootinfo(info)) == NULL) { \
    111      1.2     cdi 		panic("lookup_bootinfo: No " #info " found.\n"); \
    112      1.2     cdi 	} \
    113      1.2     cdi } while (0)
    114      1.2     cdi 
    115      1.2     cdi struct tlb_entry {
    116      1.2     cdi 	uint64_t te_pa;
    117      1.2     cdi 	uint64_t te_va;
    118      1.2     cdi };
    119      1.2     cdi 
    120      1.2     cdi struct btinfo_count {
    121      1.2     cdi 	struct btinfo_common common;
    122      1.2     cdi 	int count;
    123      1.2     cdi };
    124      1.2     cdi 
    125      1.2     cdi struct btinfo_tlb {
    126      1.2     cdi 	struct btinfo_common common;
    127      1.2     cdi 	struct tlb_entry tlb[1];
    128      1.2     cdi };
    129      1.2     cdi 
    130      1.2     cdi struct btinfo_kernend {
    131      1.2     cdi 	struct btinfo_common common;
    132      1.2     cdi 	uint64_t addr;
    133      1.2     cdi };
    134      1.2     cdi 
    135      1.2     cdi #endif /* _BOOTINFO_H_ */
    136