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