1/* $NetBSD: bootinfo.h,v 1.5 2024/01/08 05:09:41 thorpej Exp $ */ 2 3/*- 4 * Copyright (c) 2023 The NetBSD Foundation, Inc. 5 * All rights reserved. 6 * 7 * This code is derived from software contributed to The NetBSD Foundation 8 * by Jason R. Thorpe. 9 * 10 * Redistribution and use in source and binary forms, with or without 11 * modification, are permitted provided that the following conditions 12 * are met: 13 * 1. Redistributions of source code must retain the above copyright 14 * notice, this list of conditions and the following disclaimer. 15 * 2. Redistributions in binary form must reproduce the above copyright 16 * notice, this list of conditions and the following disclaimer in the 17 * documentation and/or other materials provided with the distribution. 18 * 19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 29 * POSSIBILITY OF SUCH DAMAGE. 30 */ 31 32#ifndef _VIRT68K_BOOTINFO_H_ 33#define _VIRT68K_BOOTINFO_H_ 34 35/* 36 * Linux/m68k boot information structures. These records are used to 37 * pass information from the Linux boot loader (or Qemu) to the loaded 38 * kernel. 39 * 40 * Each record has a header with the type tag and record size, followed 41 * by a data field. Each record + data is padded to align the record 42 * header at a 4-byte boundary. 43 */ 44 45struct bi_record { 46 uint16_t bi_tag; /* record type */ 47 uint16_t bi_size; /* record size (including header) */ 48 uint8_t bi_data[]; 49}; 50 51/* 52 * Record types. Record types >= 0x8000 are machine-dependent. 53 */ 54#define BI_MACHDEP(x) ((x) + 0x8000) 55#define BI_LAST 0 /* list terminator */ 56#define BI_MACHTYPE 1 /* machine type (uint32_t) */ 57#define BI_CPUTYPE 2 /* CPU type (uint32_t) */ 58#define BI_FPUTYPE 3 /* FPU type (uint32_t) */ 59#define BI_MMUTYPE 4 /* MMU type (uint32_t) */ 60#define BI_MEMCHUNK 5 /* memory segment (bi_mem_info) */ 61#define BI_RAMDISK 6 /* RAM disk (bi_mem_info) */ 62#define BI_COMMAND_LINE 7 /* kernel command line parameters (C string) */ 63#define BI_RNG_SEED 8 /* random number generator seed (bi_data) */ 64 65#define BI_VIRT_QEMU_VERSION BI_MACHDEP(0) /* uint32_t */ 66#define BI_VIRT_GF_PIC_BASE BI_MACHDEP(1) /* bi_virt_dev */ 67#define BI_VIRT_GF_RTC_BASE BI_MACHDEP(2) 68#define BI_VIRT_GF_TTY_BASE BI_MACHDEP(3) 69#define BI_VIRT_VIRTIO_BASE BI_MACHDEP(4) 70#define BI_VIRT_CTRL_BASE BI_MACHDEP(5) 71 72struct bi_mem_info { 73 uint32_t mem_addr; /* PA of memory segment */ 74 uint32_t mem_size; /* size in bytes */ 75}; 76 77struct bi_data { 78 uint16_t data_length; /* length of data */ 79 uint8_t data_bytes[]; 80}; 81 82struct bi_virt_dev { 83 uint32_t vd_mmio_base; 84 uint32_t vd_irq_base; 85}; 86 87/* 88 * Values for BI_MACHTYPE. 89 */ 90#define BI_MACH_AMIGA 1 91#define BI_MACH_ATARI 2 92#define BI_MACH_MAC 3 93#define BI_MACH_APOLLO 4 94#define BI_MACH_SUN3 5 95#define BI_MACH_MVME147 6 96#define BI_MACH_MVME16x 7 97#define BI_MACH_BVME6000 8 98#define BI_MACH_HP300 9 99#define BI_MACH_Q40 10 100#define BI_MACH_SUN3X 11 101#define BI_MACH_M54XX 12 102#define BI_MACH_M5441X 13 103#define BI_MACH_VIRT 14 104 105/* 106 * Values for BI_CPUTYPE. 107 */ 108#define BI_CPU_68020 __BIT(0) 109#define BI_CPU_68030 __BIT(1) 110#define BI_CPU_68040 __BIT(2) 111#define BI_CPU_68060 __BIT(3) 112#define BI_CPU_COLDFIRE __BIT(4) 113 114/* 115 * Values for BI_FPUTYPE. 116 */ 117#define BI_FPU_68881 __BIT(0) 118#define BI_FPU_68882 __BIT(1) 119#define BI_FPU_68040 __BIT(2) 120#define BI_FPU_68060 __BIT(3) 121#define BI_FPU_SUNFPA __BIT(4) 122#define BI_FPU_COLDFIRE __BIT(5) 123 124/* 125 * Values for BI_MMUTYPE. 126 */ 127#define BI_MMU_68851 __BIT(0) 128#define BI_MMU_68030 __BIT(1) 129#define BI_MMU_68040 __BIT(2) 130#define BI_MMU_68060 __BIT(3) 131#define BI_MMU_APOLLO __BIT(4) 132#define BI_MMU_SUN3 __BIT(5) 133#define BI_MMU_COLDFIRE __BIT(6) 134 135#ifdef _KERNEL 136 137#include <sys/bus.h> 138 139extern uint32_t bootinfo_machtype; 140extern int bootinfo_mem_segments_ignored; 141extern size_t bootinfo_mem_segments_ignored_bytes; 142extern struct bi_mem_info bootinfo_mem_segments[]; 143extern struct bi_mem_info bootinfo_mem_segments_avail[]; 144extern int bootinfo_mem_nsegments; 145extern int bootinfo_mem_nsegments_avail; 146extern vaddr_t bootinfo_end; 147 148#define bootinfo_dataptr(bi) ((void *)&(bi)->bi_data[0]) 149#define bootinfo_get_u32(bi) (*(uint32_t *)bootinfo_dataptr(bi)) 150 151void bootinfo_start(struct bi_record *); 152struct bi_record * bootinfo_find(uint32_t tag); 153void bootinfo_enumerate(bool (*)(struct bi_record *, void *), 154 void *); 155bool bootinfo_addr_is_console(paddr_t); 156 157void bootinfo_setup_initrd(void); 158void bootinfo_setup_rndseed(void); 159bool bootinfo_getarg(const char *, char *, size_t); 160 161void bootinfo_md_cnattach(void (*)(bus_space_tag_t, 162 bus_space_handle_t), 163 paddr_t, psize_t); 164 165#endif /* _KERNEL */ 166 167#endif /* _VIRT68K_BOOTINFO_H_ */ 168