aboutsummaryrefslogtreecommitdiff
path: root/snilib/sniprom.h
diff options
context:
space:
mode:
Diffstat (limited to 'snilib/sniprom.h')
-rw-r--r--snilib/sniprom.h59
1 files changed, 59 insertions, 0 deletions
diff --git a/snilib/sniprom.h b/snilib/sniprom.h
new file mode 100644
index 0000000..db079ad
--- /dev/null
+++ b/snilib/sniprom.h
@@ -0,0 +1,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))();
+}