RTEMS 7.0-rc1
Loading...
Searching...
No Matches
bootldr.h
1/* SPDX-License-Identifier: GPL-2.0+-with-RTEMS-exception */
2
3/*
4 * bootldr.h -- Include file for bootloader.
5 */
6
7/*
8 * Copyright (C) 1998, 1999 Gabriel Paubert, paubert@iram.es
9 *
10 * Modified to compile in RTEMS development environment
11 * by Eric Valette
12 *
13 * Copyright (c) 1999 Eric Valette <eric.valette@free.fr>
14 *
15 * The license and distribution terms for this file may be
16 * found in the file LICENSE in this distribution or at
17 * http://www.rtems.org/license/LICENSE.
18 */
19
20#ifndef _PPC_BOOTLDR_H
21#define _PPC_BOOTLDR_H
22
23#ifndef ASM
24#include <stdint.h>
25#include <bsp/residual.h>
26#include <bsp/consoleIo.h>
27#include "pci.h"
28
29#define abs __builtin_abs
30
31#define PTE_REFD 0x100
32#define PTE_CHNG (0x80|PTE_REFD) /* Modified implies referenced */
33#define PTE_WTHR 0x040
34#define PTE_CINH 0x020
35#define PTE_COHER 0x010
36#define PTE_GUAR 0x008
37#define PTE_RO 0x003
38#define PTE_RW 0x002
39
40#define PTE_RAM (PTE_CHNG|PTE_COHER|PTE_RW)
41#define PTE_ROM (PTE_REFD|PTE_RO)
42#define PTE_IO (PTE_CHNG|PTE_CINH|PTE_GUAR|PTE_RW)
43
44typedef struct {}opaque;
45
46/* The context passed during MMU interrupts. */
47typedef struct _ctxt {
48 u_long lr, ctr;
49 u_int cr, xer;
50 u_long nip, msr;
51 u_long regs[32];
52} ctxt;
53
54/* The main structure which is pointed to permanently by r13. Things
55 * are not separated very well between parts because it would cause
56 * too much code bloat for such a simple program like the bootloader.
57 * The code is designed to be compiled with the -m relocatable option and
58 * tries to minimize the number of relocations/fixups and the number of
59 * functions who have to access the .got2 sections (this increases the
60 * size of the prologue in every function).
61 */
62typedef struct _boot_data {
63 RESIDUAL *residual;
64 void *load_address;
65 void *of_entry;
66 void *r6, *r7, *r8, *r9, *r10;
67 u_long cache_lsize;
68 void *image; /* Where to copy ourselves */
69 void *stack;
70 void *mover; /* where to copy codemove to avoid overlays */
71 u_long o_msr, o_hid0, o_r31;
72 opaque * mm_private;
73 const struct pci_bootloader_config_access_functions* pci_functions;
74 opaque * pci_private;
75 struct pci_dev * pci_devices;
76 opaque * v86_private;
77 char cmd_line[256];
78} boot_data;
79
80register boot_data *bd __asm__("r13");
81
82static inline int
83pcibios_read_config_byte(u_char bus, u_char dev_fn,
84 u_char where, uint8_t *val) {
85 return bd->pci_functions->read_config_byte(bus, dev_fn, where, val);
86}
87
88static inline int
89pcibios_read_config_word(u_char bus, u_char dev_fn,
90 u_char where, uint16_t *val) {
91 return bd->pci_functions->read_config_word(bus, dev_fn, where, val);
92}
93
94static inline int
95pcibios_read_config_dword(u_char bus, u_char dev_fn,
96 u_char where, uint32_t *val) {
97 return bd->pci_functions->read_config_dword(bus, dev_fn, where, val);
98}
99
100static inline int
101pcibios_write_config_byte(u_char bus, u_char dev_fn,
102 u_char where, uint8_t val) {
103 return bd->pci_functions->write_config_byte(bus, dev_fn, where, val);
104}
105
106static inline int
107pcibios_write_config_word(u_char bus, u_char dev_fn,
108 u_char where, uint16_t val) {
109 return bd->pci_functions->write_config_word(bus, dev_fn, where, val);
110}
111
112static inline int
113pcibios_write_config_dword(u_char bus, u_char dev_fn,
114 u_char where, uint32_t val) {
115 return bd->pci_functions->write_config_dword(bus, dev_fn, where, val);
116}
117
118static inline int
119pci_bootloader_read_config_byte(struct pci_dev *dev, u_char where, uint8_t *val) {
120 return bd->pci_functions->read_config_byte(dev->bus->number,
121 dev->devfn,
122 where, val);
123}
124
125static inline int
126pci_bootloader_read_config_word(struct pci_dev *dev, u_char where, uint16_t *val) {
127 return bd->pci_functions->read_config_word(dev->bus->number,
128 dev->devfn,
129 where, val);
130}
131
132static inline int
133pci_bootloader_read_config_dword(struct pci_dev *dev, u_char where, uint32_t *val) {
134 return bd->pci_functions->read_config_dword(dev->bus->number,
135 dev->devfn,
136 where, val);
137}
138
139static inline int
140pci_bootloader_write_config_byte(struct pci_dev *dev, u_char where, uint8_t val) {
141 return bd->pci_functions->write_config_byte(dev->bus->number,
142 dev->devfn,
143 where, val);
144}
145
146static inline int
147pci_bootloader_write_config_word(struct pci_dev *dev, u_char where, uint16_t val) {
148 return bd->pci_functions->write_config_word(dev->bus->number,
149 dev->devfn,
150 where, val);
151}
152
153static inline int
154pci_bootloader_write_config_dword(struct pci_dev *dev, u_char where, uint32_t val) {
155 return bd->pci_functions->write_config_dword(dev->bus->number,
156 dev->devfn,
157 where, val);
158}
159
160/* codemove is like memmove, but it also gets the cache line size
161 * as 4th parameter to synchronize them. If this last parameter is
162 * zero, it performs more or less like memmove. No copy is performed if
163 * source and destination addresses are equal. However the caches
164 * are synchronized. Note that the size is always rounded up to the
165 * next mutiple of 4.
166 */
167extern void * codemove(void *, const void *, size_t, unsigned long);
168
169/* The physical memory allocator allows to align memory by
170 * powers of 2 given by the lower order bits of flags.
171 * By default it allocates from higher addresses towrds lower ones,
172 * setting PA_LOW reverses this behaviour.
173 */
174
175#define palloc(size) __palloc(size,0)
176
177#define isa_io_base (bd->io_base)
178
179void * __palloc(u_long, int);
180void pfree(void *);
181
182#define PA_LOW 0x100
183#define PA_PERM 0x200 /* Not freeable by pfree */
184#define PA_SUBALLOC 0x400 /* Allocate for suballocation by salloc */
185#define PA_ALIGN_MASK 0x1f
186
187void * valloc(u_long size);
188void vfree(void *);
189
190int vmap(void *, u_long, u_long);
191void vunmap(void *);
192
193void * salloc(u_long size);
194void sfree(void *);
195
196void pci_init(void);
197
198void * memset(void *p, int c, size_t n);
199
200void gunzip(void *, int, unsigned char *, int *);
201
202void print_all_maps(const char *);
203void print_hash_table(void);
204void MMUon(void);
205void MMUoff(void);
206void hang(const char *, u_long, ctxt *) __attribute__((noreturn));
207
208int init_v86(void);
209void cleanup_v86_mess(void);
210void em86_main(struct pci_dev *);
211int find_max_mem(struct pci_dev *);
212
213/*
214 * Prototypes for calls from assembly and across files.
215 */
216typedef struct _x86 x86;
217
218int em86_trap(x86 *p);
219void decompress_kernel(int kernel_size, void * zimage_start, int len,
220 void * initrd_start, int initrd_len );
221void boot_udelay(uint32_t _microseconds);
222void setup_hw(void);
223void _handler(int vec, ctxt *p);
224int early_setup(u_long image_size);
225void mm_init(u_long image_size);
226#endif
227
228#ifdef ASM
229/* These definitions simplify the ugly declarations necessary for
230 * GOT definitions.
231 */
232
233#define GOT_ENTRY(NAME) .L_ ## NAME = . - .LCTOC1 ; .long NAME
234#define GOT(NAME) .L_ ## NAME (r30)
235
236#define START_GOT \
237 .section ".got2","aw"; \
238.LCTOC1 = .+ 0x8000
239
240#define END_GOT \
241 .text
242
243#define GET_GOT \
244 bl 1f; \
245 .text 2; \
2460: .long .LCTOC1-1f; \
247 .text ; \
2481: mflr r30; \
249 lwz r0,0b-1b(r30); \
250 add r30,r0,r30
251
252#define bd r13
253#define cache_lsize 32 /* Offset into bd area */
254#define image 36
255#define stack 40
256#define mover 44
257#define o_msr 48
258#define o_hid0 52
259#define o_r31 56
260/* Stack offsets for saved registers on exceptions */
261#define save_lr 8(r1)
262#define save_ctr 12(r1)
263#define save_cr 16(r1)
264#define save_xer 20(r1)
265#define save_nip 24(r1)
266#define save_msr 28(r1)
267#define save_r(n) 32+4*n(r1)
268#endif
269
270#endif
console I/O package interface
Definition: residual.h:294
Definition: xnandpsu_onfi.h:185
Definition: bootldr.h:62
Definition: bootldr.h:47
Definition: em86.c:54
Definition: bootldr.h:44
Definition: pci.h:41