source: rtems/c/src/lib/libbsp/powerpc/shared/bootloader/bootldr.h @ f2a6ee0

4.104.114.84.95
Last change on this file since f2a6ee0 was 34e458a3, checked in by Jennifer Averett <Jennifer.Averett@…>, on 05/10/05 at 18:27:46

2005-05-10 Jennifer Averett <jennifer.averett@…>

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