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