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

4.104.114.84.9
Last change on this file since 18a3bbe was 18a3bbe, checked in by Ralf Corsepius <ralf.corsepius@…>, on Mar 31, 2007 at 1:14:39 AM

Use stdint.h fixed-size types.

  • 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 <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
80extern 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
86extern 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
92extern 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
98extern 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
104extern 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
110extern 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
116extern 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
123extern 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
130extern 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
137extern 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
144extern 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
151extern 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#endif
212
213#ifdef ASM
214/* These definitions simplify the ugly declarations necessary for
215 * GOT definitions.
216 */
217
218#define GOT_ENTRY(NAME) .L_ ## NAME = . - .LCTOC1       ; .long NAME
219#define GOT(NAME) .L_ ## NAME (r30)
220
221#define START_GOT       \
222        .section        ".got2","aw"; \
223.LCTOC1 = .+ 0x8000
224
225#define END_GOT \
226        .text
227
228#define GET_GOT \
229        bl      1f; \
230        .text   2; \
2310:      .long   .LCTOC1-1f; \
232        .text   ; \
2331:      mflr    r30; \
234        lwz     r0,0b-1b(r30); \
235        add     r30,r0,r30
236
237#define bd r13
238#define cache_lsize 32  /* Offset into bd area */
239#define image   36
240#define stack   40
241#define mover   44
242#define o_msr   48
243#define o_hid0  52
244#define o_r31   56
245/* Stack offsets for saved registers on exceptions */
246#define save_lr    8(r1)
247#define save_ctr  12(r1)
248#define save_cr   16(r1)
249#define save_xer  20(r1)
250#define save_nip  24(r1)
251#define save_msr  28(r1)
252#define save_r(n) 32+4*n(r1)
253#endif
254
255#endif
Note: See TracBrowser for help on using the repository browser.