-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathpowerpc.h
83 lines (55 loc) · 1.79 KB
/
powerpc.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
/*
BootMii - a Free Software replacement for the Nintendo/BroadOn bootloader.
Requires mini.
Copyright (C) 2008 Segher Boessenkool <segher@kernel.crashing.org>
# This code is licensed to you under the terms of the GNU GPL, version 2;
# see file COPYING or http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt
*/
#ifndef __PPC_H__
#define __PPC_H__
#include "time.h"
#include "hollywood.h"
void dsp_reset(void);
void powerpc_hang(void);
void powerpc_reset(void);
void powerpc_poweroff(void);
#include "types.h"
#include "printf.h"
#define OK 0
#define EFAIL 1
#define MEM2_BSS __attribute__ ((section (".bss.mem2")))
#define MEM2_DATA __attribute__ ((section (".data.mem2")))
#define MEM2_RODATA __attribute__ ((section (".rodata.mem2")))
#define ALIGNED(x) __attribute__((aligned(x)))
#define STACK_ALIGN(type, name, cnt, alignment) \
u8 _al__##name[((sizeof(type)*(cnt)) + (alignment) + \
(((sizeof(type)*(cnt))%(alignment)) > 0 ? ((alignment) - \
((sizeof(type)*(cnt))%(alignment))) : 0))]; \
type *name = (type*)(((u32)(_al__##name)) + ((alignment) - (( \
(u32)(_al__##name))&((alignment)-1))))
// Address mapping.
static inline u32 virt_to_phys(const void *p)
{
return (u32)p & 0x7fffffff;
}
static inline void *phys_to_virt(u32 x)
{
return (void *)(x | 0x80000000);
}
// Cache synchronisation.
void sync_before_read(void *p, u32 len);
void sync_after_write(const void *p, u32 len);
void sync_before_exec(const void *p, u32 len);
// Special purpose registers.
#define mtspr(n, x) do { asm("mtspr %1,%0" : : "r"(x), "i"(n)); } while (0)
#define mfspr(n) ({ \
u32 x; asm volatile("mfspr %0,%1" : "=r"(x) : "i"(n)); x; \
})
// Exceptions.
void exception_init(void);
// Debug: blink the tray led.
static inline void blink(void)
{
write32(0x0d8000c0, read32(0x0d8000c0) ^ 0x20);
}
#endif