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