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