aboutsummaryrefslogtreecommitdiff
path: root/snilib/sniprom.h
blob: db079ad6d66f94c213ad3fdff2308c2dd33f88e3 (plain)
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

#include <subarch.h>

#define PROM_VEC                KSEG1ADDR(0x1fc00000)
#define PROM_ENTRY(x)           (PROM_VEC + (x*8))

#define PROM_RESET		0
#define PROM_OPEN		6
#define PROM_READ		7
#define PROM_WRITE		8
//#define PROM_SEEK		8
#define PROM_PUTCHAR            12
#define PROM_FLUSHCACHE		28
#define PROM_CLEARCACHE		29
#define PROM_GETENV             33
#define PROM_GET_MEMCONF        58


typedef struct {
	unsigned int	size;
	unsigned int	base;
	unsigned int	size2;
	unsigned int	pad1;
	unsigned int	pad2;
} MEMBANK;

typedef struct {
	MEMBANK		bank[8];
} MEMCONF;

static inline int __prom_get_memconf(MEMCONF *mc) {
	return ((int (*)(MEMCONF *))PROM_ENTRY(PROM_GET_MEMCONF))(mc);
}

static inline int __prom_putchar(char a) {
	return ((int (*)(int))PROM_ENTRY(PROM_PUTCHAR))(a);
}

static inline int __prom_open(char *filename, int mode) {
	return ((int (*)(char *, int))PROM_ENTRY(PROM_OPEN))(filename, mode);
}

static inline int __prom_write(FILE stream, char *buf, unsigned long len) {
	return ((int (*)(FILE, char *, unsigned long))PROM_ENTRY(PROM_WRITE))
		(stream, buf, len);
}

static inline int __prom_read(FILE stream, char *buf, unsigned long len) {
	return ((int (*)(FILE, char *, unsigned long))PROM_ENTRY(PROM_READ))
		(stream, buf, len);
}

static inline void __prom_reset(void ) {
	((void (*)(void ))PROM_ENTRY(PROM_RESET))();
}

static inline void __prom_flushcache(void) {
	((void (*)(void ))PROM_ENTRY(PROM_FLUSHCACHE))();
}