Home | History | Annotate | Line # | Download | only in include
      1 /*       $NetBSD: bootinfo.h,v 1.9 2019/01/08 19:53:40 jdolecek 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 <sparc/bootinfo.h>
     33 
     34 /*
     35  * The bootloader v1.9 and higher makes a call into a kernel with the following
     36  * arguments:
     37  *
     38  * %o0		OpenFirmware entry point, to keep Sun's updaters happy
     39  * %o1		Address of boot information vector (see below)
     40  * %o2		Length of the vector, in bytes
     41  * %o3		OpenFirmware entry point, to mimic Sun bootloader behavior
     42  * %o4		OpenFirmware entry point, to meet earlier NetBSD kernels
     43  *              expectations
     44  *
     45  * All parameters are of void* type except for vector length which is of
     46  * integer type.
     47  *
     48  * The boot information vector format was dictated by earlier kernels and
     49  * starting from ofwboot v1.9 has four entries:
     50  *
     51  *      +-------------------------------------+
     52  * #0   | NetBSD boot magic number ('DDB2')   |
     53  *      +-------------------------------------+
     54  * #1   | ksyms' table end address            |
     55  *      +-------------------------------------+
     56  * #2   | ksyms' table start address          |
     57  *      +-------------------------------------+
     58  * #3   | Pointer to a bootinfo binary object |
     59  *      +-------------------------------------+
     60  *
     61  * Kernels written for pre-v1.8 ofwboot require first three cells to present
     62  * in this particular order, those that rely on v1.9 and higher won't work if
     63  * the last pointer is not in the table; therefore, the vector cannot be
     64  * shorter than 4 * sizeof(uint32_t) or 4 * sizeof(uint64_t) for 32-bit and
     65  * 64-bit boot loader, respectively.
     66  *
     67  * As of ofwboot v1.9,  bootinfo binary object is placed right after the kernel
     68  * data segment end, i.e. in the permanently locked 4MB page. There is no order
     69  * for the data located in bootinfo binary object. The kernel however expects
     70  * at least following parameters to exist in there:
     71  *
     72  * - Symbol information (size, start, end; see struct btinfo_symtab)
     73  * - Kernel end address, calculated as true kernel end address plus size of
     74  *   space reserved for bootinfo binary object (struct btinfo_kernend)
     75  * - Number of text segment pages (struct btinfo_count)
     76  * - Number of data segment pages (struct btinfo_count)
     77  * - Array of text pages VA/PA (struct btinfo_tlb)
     78  * - Array of data pages VA/PA (struct btinfo_tlb)
     79  *
     80  * The last four data structures fully describe kernel mappings. ofwboot v1.9
     81  * and higher map the kernel with 4MB permanent pages and this is the only
     82  * way to let kernel know how exactly it was mapped.
     83  */
     84 
     85 /* Boot magic number */
     86 #define SPARC_MACHINE_OPENFIRMWARE	0x44444230
     87 
     88 #ifdef BOOTINFO_SIZE
     89 #undef BOOTINFO_SIZE
     90 #endif
     91 
     92 #define BOOTINFO_SIZE			NBPG
     93 
     94 #define BTINFO_DTLB_SLOTS		100
     95 #define BTINFO_ITLB_SLOTS		101
     96 #define BTINFO_DTLB			102
     97 #define BTINFO_ITLB			103
     98 #define BTINFO_KERNEND			104
     99 #define BTINFO_BOOTDEV			105
    100 #define BTINFO_BOOTDEV_UNIT		106
    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 struct btinfo_bootdev_unit {
    135 	struct btinfo_common common;
    136 	uint32_t phandle;	/* the boot path package handle */
    137 	uint32_t parent;	/* the controller handle */
    138 	uint32_t lun;		/* scsi address details */
    139 	uint32_t target;	/* or primary/secondary channel for IDE */
    140 	uint64_t wwn;		/* zero for non FC-AL drives */
    141 };
    142 
    143 #endif /* _BOOTINFO_H_ */
    144