1 /* $OpenBSD: pmon.h,v 1.5 2017/05/21 13:00:53 visa Exp $ */ 2 3 /* 4 * Copyright (c) 2009, 2012 Miodrag Vallat. 5 * 6 * Permission to use, copy, modify, and distribute this software for any 7 * purpose with or without fee is hereby granted, provided that the above 8 * copyright notice and this permission notice appear in all copies. 9 * 10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 13 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 15 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 17 */ 18 19 #ifndef _MACHINE_PMON_H_ 20 #define _MACHINE_PMON_H_ 21 22 #if defined(_KERNEL) || defined(_STANDALONE) 23 24 /* 25 * PMON2000 callvec definitions 26 */ 27 28 /* 32-bit compatible types */ 29 typedef uint32_t pmon_size_t; 30 typedef int32_t pmon_ssize_t; 31 typedef int64_t pmon_off_t; 32 33 int pmon_open(const char *, int, ...); 34 int pmon_close(int); 35 int pmon_read(int, void *, pmon_size_t); 36 pmon_ssize_t pmon_write(int, const void *, pmon_size_t); 37 pmon_off_t pmon_lseek(int, pmon_off_t, int); 38 int pmon_printf(const char *, ...); 39 void pmon_cacheflush(void); 40 char * pmon_gets(char *); 41 42 #define PMON_MAXLN 256 /* internal gets() size limit */ 43 44 extern int32_t pmon_callvec; 45 46 const char *pmon_getarg(const int); 47 void pmon_init(int32_t, int32_t, int32_t, int32_t, uint32_t); 48 49 #define PMON_ENVTYPE_ENVP 0 50 #define PMON_ENVTYPE_EFI 1 51 int pmon_getenvtype(void); 52 53 /* 54 * The new environment interface is a /salmigondis/ of badly thought-out 55 * structs put together, pretending to be inspired by EFI but conveniently 56 * omitting key EFI structs because they are deemed non-applicable to 57 * MIPS systems. 58 * Of course, some fields are absolute addresses, while others are relative 59 * pointers, to add to the confusion. 60 */ 61 62 struct pmon_env_reset { 63 void (*cold_boot)(void); /* not filled */ 64 void (*warm_boot)(void); 65 void (*boot)(unsigned int); /* not filled */ 66 void (*poweroff)(void); 67 }; 68 69 /* all values are offsets relative to the beginning of the struct */ 70 struct pmon_env_ptr { 71 uint64_t offs_mem; 72 uint64_t offs_cpu; 73 uint64_t offs_sys; 74 uint64_t offs_irq; 75 uint64_t offs_iface; 76 uint64_t offs_special; 77 uint64_t offs_device; 78 }; 79 80 struct pmon_env_smbios { 81 uint16_t version; 82 uint64_t vga_bios; 83 struct pmon_env_ptr ptrs; 84 }; 85 86 struct pmon_env_efi { 87 uint64_t mps; /* not filled */ 88 uint64_t acpi; /* not filled */ 89 uint64_t acpi20; /* not filled */ 90 struct pmon_env_smbios bios; 91 uint64_t sal_systab; /* not filled */ 92 uint64_t bootinfo; /* not filled */ 93 }; 94 95 struct pmon_env { 96 struct pmon_env_efi efi; 97 struct pmon_env_reset reset; 98 }; 99 100 #define PMON_MEM_MAX 128 101 struct pmon_env_mem_entry { 102 uint32_t node; 103 uint32_t type; 104 #define PMON_MEM_SYSTEM_LOW 1 /* physical memory <= 256 MB */ 105 #define PMON_MEM_SYSTEM_HIGH 2 /* physical memory > 256 MB */ 106 #define PMON_MEM_RESERVED 3 107 #define PMON_MEM_PCI_IO 4 108 #define PMON_MEM_PCI_MEM 5 109 #define PMON_MEM_CPU_REGISTERS 6 110 #define PMON_MEM_VIDEO_ROM 7 111 #define PMON_MEM_OTHER_ROM 8 112 #define PMON_MEM_ACPI_TABLE 9 113 uint64_t address; 114 uint32_t size; 115 }; 116 struct pmon_env_mem { 117 uint16_t version; /* not filled */ 118 uint32_t nentries; 119 uint32_t mem_freq; 120 struct pmon_env_mem_entry mem_map[PMON_MEM_MAX]; 121 } __packed; 122 123 struct pmon_env_cpu { 124 uint16_t version; /* not filled */ 125 uint32_t prid; /* cop0 PrID */ 126 uint32_t cputype; 127 /* 0 and 1 are supposedly intended for 2E and 2F, which do NOT provide this 128 interface; moreover Linux and PMON disagree on the values and have 2E and 129 2F swapped. */ 130 #define PMON_CPUTYPE_LS3A 2 131 #define PMON_CPUTYPE_LS3B 3 132 #define PMON_CPUTYPE_LS1A 4 133 #define PMON_CPUTYPE_LS1B 5 134 uint32_t node; /* total number of NUMA nodes */ 135 uint16_t coreid; /* boot CPU core id */ 136 uint16_t reserved_cores; /* mask of reserved cores */ 137 uint32_t speed; 138 uint32_t ncpus; 139 } __packed; 140 141 struct pmon_env_sys { 142 uint16_t version; /* not filled */ 143 uint32_t ccnuma_smp; 144 uint32_t double_channel; 145 } __packed; 146 147 struct pmon_env_irq { 148 uint16_t version; /* not filled */ 149 uint16_t size; /* not filled */ 150 uint16_t rtr_bus; /* not filled */ 151 uint16_t rtr_devfn; /* not filled */ 152 uint32_t vendor; /* not filled */ 153 uint32_t device; /* not filled */ 154 uint32_t pic_type; 155 #define PMON_IRQ_PIC_HT 0 156 #define PMON_IRQ_PIC_I8259 1 157 uint64_t ht_interrupt_bit; 158 uint64_t ht_enable; 159 uint32_t node; 160 uint64_t pci_memory_space_start; 161 uint64_t pci_memory_space_end; 162 uint64_t pci_io_space_start; /* not filled */ 163 uint64_t pci_io_space_end; /* not filled */ 164 uint64_t pci_cfg_space; /* not filled */ 165 } __packed; 166 167 struct pmon_env_iface { 168 uint16_t version; 169 #define PMON_IFACE_VERSION 0x0001 170 uint16_t size; 171 uint8_t flag; 172 char description[64]; /* firmware version */ 173 } __packed; 174 175 #define PMON_RESOURCE_MAX 128 176 struct pmon_env_resource { 177 uint64_t start; 178 uint64_t end; 179 char name[64]; 180 uint32_t flags; 181 }; 182 struct pmon_env_special { 183 uint16_t version; 184 char name[64]; 185 uint32_t type; 186 struct pmon_env_resource resource[PMON_RESOURCE_MAX]; 187 }; 188 189 struct pmon_env_device { 190 char name[64]; /* system description */ 191 uint32_t nentries; 192 struct pmon_env_resource resource[PMON_RESOURCE_MAX]; 193 }; 194 195 const char *pmon_getenv(const char *); 196 197 const struct pmon_env_reset *pmon_get_env_reset(void); 198 const struct pmon_env_smbios *pmon_get_env_smbios(void); 199 const struct pmon_env_mem *pmon_get_env_mem(void); 200 const struct pmon_env_cpu *pmon_get_env_cpu(void); 201 const struct pmon_env_sys *pmon_get_env_sys(void); 202 const struct pmon_env_irq *pmon_get_env_irq(void); 203 const struct pmon_env_iface *pmon_get_env_iface(void); 204 const struct pmon_env_special *pmon_get_env_special(void); 205 const struct pmon_env_device *pmon_get_env_device(void); 206 207 #endif /* _KERNEL || _STANDALONE */ 208 209 #endif /* _MACHINE_PMON_H_ */ 210