xref: /netbsd-src/sys/arch/sparc64/include/bootinfo.h (revision 2a4cbf24708a56fdec1a8aa5ff0c0edd42cbcd18)
1*2a4cbf24Sjdolecek /*       $NetBSD: bootinfo.h,v 1.9 2019/01/08 19:53:40 jdolecek Exp $        */
2154a2d2aSmrg 
34c2e4320Scdi /*-
44c2e4320Scdi  * Copyright (c) 2005 The NetBSD Foundation, Inc.
54c2e4320Scdi  * All rights reserved.
64c2e4320Scdi  *
74c2e4320Scdi  * Redistribution and use in source and binary forms, with or without
84c2e4320Scdi  * modification, are permitted provided that the following conditions
94c2e4320Scdi  * are met:
104c2e4320Scdi  * 1. Redistributions of source code must retain the above copyright
114c2e4320Scdi  *    notice, this list of conditions and the following disclaimer.
124c2e4320Scdi  * 2. Redistributions in binary form must reproduce the above copyright
134c2e4320Scdi  *    notice, this list of conditions and the following disclaimer in the
144c2e4320Scdi  *    documentation and/or other materials provided with the distribution.
154c2e4320Scdi  *
164c2e4320Scdi  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
174c2e4320Scdi  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
184c2e4320Scdi  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
194c2e4320Scdi  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
204c2e4320Scdi  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
214c2e4320Scdi  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
224c2e4320Scdi  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
234c2e4320Scdi  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
244c2e4320Scdi  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
254c2e4320Scdi  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
264c2e4320Scdi  * POSSIBILITY OF SUCH DAMAGE.
274c2e4320Scdi  */
284c2e4320Scdi 
294c2e4320Scdi #ifndef _BOOTINFO_H_
304c2e4320Scdi #define _BOOTINFO_H_
314c2e4320Scdi 
32154a2d2aSmrg #include <sparc/bootinfo.h>
334c2e4320Scdi 
344c2e4320Scdi /*
354c2e4320Scdi  * The bootloader v1.9 and higher makes a call into a kernel with the following
364c2e4320Scdi  * arguments:
374c2e4320Scdi  *
384c2e4320Scdi  * %o0		OpenFirmware entry point, to keep Sun's updaters happy
394c2e4320Scdi  * %o1		Address of boot information vector (see below)
404c2e4320Scdi  * %o2		Length of the vector, in bytes
414c2e4320Scdi  * %o3		OpenFirmware entry point, to mimic Sun bootloader behavior
424c2e4320Scdi  * %o4		OpenFirmware entry point, to meet earlier NetBSD kernels
434c2e4320Scdi  *              expectations
444c2e4320Scdi  *
454c2e4320Scdi  * All parameters are of void* type except for vector length which is of
464c2e4320Scdi  * integer type.
474c2e4320Scdi  *
484c2e4320Scdi  * The boot information vector format was dictated by earlier kernels and
494c2e4320Scdi  * starting from ofwboot v1.9 has four entries:
504c2e4320Scdi  *
514c2e4320Scdi  *      +-------------------------------------+
524c2e4320Scdi  * #0   | NetBSD boot magic number ('DDB2')   |
534c2e4320Scdi  *      +-------------------------------------+
544c2e4320Scdi  * #1   | ksyms' table end address            |
554c2e4320Scdi  *      +-------------------------------------+
564c2e4320Scdi  * #2   | ksyms' table start address          |
574c2e4320Scdi  *      +-------------------------------------+
584c2e4320Scdi  * #3   | Pointer to a bootinfo binary object |
594c2e4320Scdi  *      +-------------------------------------+
604c2e4320Scdi  *
614c2e4320Scdi  * Kernels written for pre-v1.8 ofwboot require first three cells to present
624c2e4320Scdi  * in this particular order, those that rely on v1.9 and higher won't work if
634c2e4320Scdi  * the last pointer is not in the table; therefore, the vector cannot be
64d50f0c62Scdi  * shorter than 4 * sizeof(uint32_t) or 4 * sizeof(uint64_t) for 32-bit and
654c2e4320Scdi  * 64-bit boot loader, respectively.
664c2e4320Scdi  *
674c2e4320Scdi  * As of ofwboot v1.9,  bootinfo binary object is placed right after the kernel
684c2e4320Scdi  * data segment end, i.e. in the permanently locked 4MB page. There is no order
694c2e4320Scdi  * for the data located in bootinfo binary object. The kernel however expects
704c2e4320Scdi  * at least following parameters to exist in there:
714c2e4320Scdi  *
724c2e4320Scdi  * - Symbol information (size, start, end; see struct btinfo_symtab)
734c2e4320Scdi  * - Kernel end address, calculated as true kernel end address plus size of
744c2e4320Scdi  *   space reserved for bootinfo binary object (struct btinfo_kernend)
754c2e4320Scdi  * - Number of text segment pages (struct btinfo_count)
764c2e4320Scdi  * - Number of data segment pages (struct btinfo_count)
774c2e4320Scdi  * - Array of text pages VA/PA (struct btinfo_tlb)
784c2e4320Scdi  * - Array of data pages VA/PA (struct btinfo_tlb)
794c2e4320Scdi  *
804c2e4320Scdi  * The last four data structures fully describe kernel mappings. ofwboot v1.9
814c2e4320Scdi  * and higher map the kernel with 4MB permanent pages and this is the only
824c2e4320Scdi  * way to let kernel know how exactly it was mapped.
834c2e4320Scdi  */
844c2e4320Scdi 
854c2e4320Scdi /* Boot magic number */
864c2e4320Scdi #define SPARC_MACHINE_OPENFIRMWARE	0x44444230
874c2e4320Scdi 
884c2e4320Scdi #ifdef BOOTINFO_SIZE
894c2e4320Scdi #undef BOOTINFO_SIZE
904c2e4320Scdi #endif
914c2e4320Scdi 
924c2e4320Scdi #define BOOTINFO_SIZE			NBPG
934c2e4320Scdi 
944c2e4320Scdi #define BTINFO_DTLB_SLOTS		100
954c2e4320Scdi #define BTINFO_ITLB_SLOTS		101
964c2e4320Scdi #define BTINFO_DTLB			102
974c2e4320Scdi #define BTINFO_ITLB			103
984c2e4320Scdi #define BTINFO_KERNEND			104
99d1f79d81Smartin #define BTINFO_BOOTDEV			105
100be9f90e8Smartin #define BTINFO_BOOTDEV_UNIT		106
1014c2e4320Scdi 
1024c2e4320Scdi #define LOOKUP_BOOTINFO(btp, info) \
1034c2e4320Scdi do { \
1044c2e4320Scdi 	if ( ((btp) = lookup_bootinfo(info)) == NULL) { \
1054c2e4320Scdi 		panic("lookup_bootinfo: No " #info " found.\n"); \
1064c2e4320Scdi 	} \
1074c2e4320Scdi } while (0)
1084c2e4320Scdi 
1094c2e4320Scdi struct tlb_entry {
1104c2e4320Scdi 	uint64_t te_pa;
1114c2e4320Scdi 	uint64_t te_va;
1124c2e4320Scdi };
1134c2e4320Scdi 
1144c2e4320Scdi struct btinfo_count {
1154c2e4320Scdi 	struct btinfo_common common;
1164c2e4320Scdi 	int count;
1174c2e4320Scdi };
1184c2e4320Scdi 
1194c2e4320Scdi struct btinfo_tlb {
1204c2e4320Scdi 	struct btinfo_common common;
1214c2e4320Scdi 	struct tlb_entry tlb[1];
1224c2e4320Scdi };
1234c2e4320Scdi 
1244c2e4320Scdi struct btinfo_kernend {
1254c2e4320Scdi 	struct btinfo_common common;
1264c2e4320Scdi 	uint64_t addr;
1274c2e4320Scdi };
1284c2e4320Scdi 
129d1f79d81Smartin struct btinfo_bootdev {
130d1f79d81Smartin 	struct btinfo_common common;
131d1f79d81Smartin 	char name[1];
132d1f79d81Smartin };
133d1f79d81Smartin 
134be9f90e8Smartin struct btinfo_bootdev_unit {
135be9f90e8Smartin 	struct btinfo_common common;
136be9f90e8Smartin 	uint32_t phandle;	/* the boot path package handle */
137be9f90e8Smartin 	uint32_t parent;	/* the controller handle */
138be9f90e8Smartin 	uint32_t lun;		/* scsi address details */
139be9f90e8Smartin 	uint32_t target;	/* or primary/secondary channel for IDE */
140be9f90e8Smartin 	uint64_t wwn;		/* zero for non FC-AL drives */
141be9f90e8Smartin };
142be9f90e8Smartin 
1434c2e4320Scdi #endif /* _BOOTINFO_H_ */
144