File indexing completed on 2025-05-11 08:23:54
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018 #ifndef _PPC_BOOTLDR_H
0019 #define _PPC_BOOTLDR_H
0020
0021 #ifndef ASM
0022 #include <stdint.h>
0023 #include <bsp/residual.h>
0024 #include <bsp/consoleIo.h>
0025 #include "pci.h"
0026
0027 #define abs __builtin_abs
0028
0029 #define PTE_REFD 0x100
0030 #define PTE_CHNG (0x80|PTE_REFD)
0031 #define PTE_WTHR 0x040
0032 #define PTE_CINH 0x020
0033 #define PTE_COHER 0x010
0034 #define PTE_GUAR 0x008
0035 #define PTE_RO 0x003
0036 #define PTE_RW 0x002
0037
0038 #define PTE_RAM (PTE_CHNG|PTE_COHER|PTE_RW)
0039 #define PTE_ROM (PTE_REFD|PTE_RO)
0040 #define PTE_IO (PTE_CHNG|PTE_CINH|PTE_GUAR|PTE_RW)
0041
0042 typedef struct {}opaque;
0043
0044
0045 typedef struct _ctxt {
0046 u_long lr, ctr;
0047 u_int cr, xer;
0048 u_long nip, msr;
0049 u_long regs[32];
0050 } ctxt;
0051
0052
0053
0054
0055
0056
0057
0058
0059
0060 typedef struct _boot_data {
0061 RESIDUAL *residual;
0062 void *load_address;
0063 void *of_entry;
0064 void *r6, *r7, *r8, *r9, *r10;
0065 u_long cache_lsize;
0066 void *image;
0067 void *stack;
0068 void *mover;
0069 u_long o_msr, o_hid0, o_r31;
0070 opaque * mm_private;
0071 const struct pci_bootloader_config_access_functions* pci_functions;
0072 opaque * pci_private;
0073 struct pci_dev * pci_devices;
0074 opaque * v86_private;
0075 char cmd_line[256];
0076 } boot_data;
0077
0078 register boot_data *bd __asm__("r13");
0079
0080 static inline int
0081 pcibios_read_config_byte(u_char bus, u_char dev_fn,
0082 u_char where, uint8_t *val) {
0083 return bd->pci_functions->read_config_byte(bus, dev_fn, where, val);
0084 }
0085
0086 static inline int
0087 pcibios_read_config_word(u_char bus, u_char dev_fn,
0088 u_char where, uint16_t *val) {
0089 return bd->pci_functions->read_config_word(bus, dev_fn, where, val);
0090 }
0091
0092 static inline int
0093 pcibios_read_config_dword(u_char bus, u_char dev_fn,
0094 u_char where, uint32_t *val) {
0095 return bd->pci_functions->read_config_dword(bus, dev_fn, where, val);
0096 }
0097
0098 static inline int
0099 pcibios_write_config_byte(u_char bus, u_char dev_fn,
0100 u_char where, uint8_t val) {
0101 return bd->pci_functions->write_config_byte(bus, dev_fn, where, val);
0102 }
0103
0104 static inline int
0105 pcibios_write_config_word(u_char bus, u_char dev_fn,
0106 u_char where, uint16_t val) {
0107 return bd->pci_functions->write_config_word(bus, dev_fn, where, val);
0108 }
0109
0110 static inline int
0111 pcibios_write_config_dword(u_char bus, u_char dev_fn,
0112 u_char where, uint32_t val) {
0113 return bd->pci_functions->write_config_dword(bus, dev_fn, where, val);
0114 }
0115
0116 static inline int
0117 pci_bootloader_read_config_byte(struct pci_dev *dev, u_char where, uint8_t *val) {
0118 return bd->pci_functions->read_config_byte(dev->bus->number,
0119 dev->devfn,
0120 where, val);
0121 }
0122
0123 static inline int
0124 pci_bootloader_read_config_word(struct pci_dev *dev, u_char where, uint16_t *val) {
0125 return bd->pci_functions->read_config_word(dev->bus->number,
0126 dev->devfn,
0127 where, val);
0128 }
0129
0130 static inline int
0131 pci_bootloader_read_config_dword(struct pci_dev *dev, u_char where, uint32_t *val) {
0132 return bd->pci_functions->read_config_dword(dev->bus->number,
0133 dev->devfn,
0134 where, val);
0135 }
0136
0137 static inline int
0138 pci_bootloader_write_config_byte(struct pci_dev *dev, u_char where, uint8_t val) {
0139 return bd->pci_functions->write_config_byte(dev->bus->number,
0140 dev->devfn,
0141 where, val);
0142 }
0143
0144 static inline int
0145 pci_bootloader_write_config_word(struct pci_dev *dev, u_char where, uint16_t val) {
0146 return bd->pci_functions->write_config_word(dev->bus->number,
0147 dev->devfn,
0148 where, val);
0149 }
0150
0151 static inline int
0152 pci_bootloader_write_config_dword(struct pci_dev *dev, u_char where, uint32_t val) {
0153 return bd->pci_functions->write_config_dword(dev->bus->number,
0154 dev->devfn,
0155 where, val);
0156 }
0157
0158
0159
0160
0161
0162
0163
0164
0165 extern void * codemove(void *, const void *, size_t, unsigned long);
0166
0167
0168
0169
0170
0171
0172
0173 #define palloc(size) __palloc(size,0)
0174
0175 #define isa_io_base (bd->io_base)
0176
0177 void * __palloc(u_long, int);
0178 void pfree(void *);
0179
0180 #define PA_LOW 0x100
0181 #define PA_PERM 0x200
0182 #define PA_SUBALLOC 0x400
0183 #define PA_ALIGN_MASK 0x1f
0184
0185 void * valloc(u_long size);
0186 void vfree(void *);
0187
0188 int vmap(void *, u_long, u_long);
0189 void vunmap(void *);
0190
0191 void * salloc(u_long size);
0192 void sfree(void *);
0193
0194 void pci_init(void);
0195
0196 void * memset(void *p, int c, size_t n);
0197
0198 void gunzip(void *, int, unsigned char *, int *);
0199
0200 void print_all_maps(const char *);
0201 void print_hash_table(void);
0202 void MMUon(void);
0203 void MMUoff(void);
0204 void hang(const char *, u_long, ctxt *) __attribute__((noreturn));
0205
0206 int init_v86(void);
0207 void cleanup_v86_mess(void);
0208 void em86_main(struct pci_dev *);
0209 int find_max_mem(struct pci_dev *);
0210
0211
0212
0213
0214 typedef struct _x86 x86;
0215
0216 int em86_trap(x86 *p);
0217 void decompress_kernel(int kernel_size, void * zimage_start, int len,
0218 void * initrd_start, int initrd_len );
0219 void boot_udelay(uint32_t _microseconds);
0220 void setup_hw(void);
0221 void _handler(int vec, ctxt *p);
0222 int early_setup(u_long image_size);
0223 void mm_init(u_long image_size);
0224 #endif
0225
0226 #ifdef ASM
0227
0228
0229
0230
0231 #define GOT_ENTRY(NAME) .L_ ## NAME = . - .LCTOC1 ; .long NAME
0232 #define GOT(NAME) .L_ ## NAME (r30)
0233
0234 #define START_GOT \
0235 .section ".got2","aw"; \
0236 .LCTOC1 = .+ 0x8000
0237
0238 #define END_GOT \
0239 .text
0240
0241 #define GET_GOT \
0242 bl 1f; \
0243 .text 2; \
0244 0: .long .LCTOC1-1f; \
0245 .text ; \
0246 1: mflr r30; \
0247 lwz r0,0b-1b(r30); \
0248 add r30,r0,r30
0249
0250 #define bd r13
0251 #define cache_lsize 32
0252 #define image 36
0253 #define stack 40
0254 #define mover 44
0255 #define o_msr 48
0256 #define o_hid0 52
0257 #define o_r31 56
0258
0259 #define save_lr 8(r1)
0260 #define save_ctr 12(r1)
0261 #define save_cr 16(r1)
0262 #define save_xer 20(r1)
0263 #define save_nip 24(r1)
0264 #define save_msr 28(r1)
0265 #define save_r(n) 32+4*n(r1)
0266 #endif
0267
0268 #endif