X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?p=rpikern;a=blobdiff_plain;f=src%2Fmain.c;h=97fcda79efe429e79b40482fde592f3080f2d4a1;hp=49ea500fe163a1c63faeb3898ee60bef60fae85b;hb=993155fee2327f1f3cda285c9548bbb09688a3f3;hpb=7144c35379850a9638350f8e11cbdca7d3234d7e diff --git a/src/main.c b/src/main.c index 49ea500..97fcda7 100644 --- a/src/main.c +++ b/src/main.c @@ -1,111 +1,39 @@ -/* mailbox registers (MB 0: input 1: output) - * function | MB 0 | MB 1 - * rd/wr | 00 | 20 ( upper 28: data, lower 4: channel ) - * peek | 10 | 30 - * sender | 14 | 34 - * status | 18 | 38 - * config | 1c | 3c - * - * channel 1: framebuffer - * channel 8: request - * - * read: read status reg loop while empty flag is set - * write: read status loop while full flag is set - */ +#include "config.h" + #include #include +#include "asm.h" +#include "serial.h" -#ifdef RPI1 -#define IOBASEADDR 0x20000000 -#else -#define IOBASEADDR 0x3f000000 -#endif - -#define phys2bus(addr) ((addr) | 0x40000000) -#define bus2phys(addr) ((addr) & 0x3fffffff) - -#define IOREG_ADDR(x) (IOBASEADDR | (x)) -#define REG_MB_READ *((volatile uint32_t*)IOREG_ADDR(0xb880)) -#define REG_MB_STAT *((volatile uint32_t*)IOREG_ADDR(0xb898)) -#define REG_MB_WRITE *((volatile uint32_t*)IOREG_ADDR(0xb8a0)) - -#define MB_STAT_FULL 0x80000000 -#define MB_STAT_EMPTY 0x40000000 - -#define MB_CHAN_FRAMEBUF 1 -#define MB_CHAN_PROP 8 - -#define PROP_CODE_REQ 0 -#define PROP_RESP_OK 0x80000000 - - -#define PROP_TAG_END 0 - -#define PROP_TAG_SET 0x08000 -#define PROP_TAG_TEST 0x04000 -#define PROP_TAG_GET 0 - -#define PROP_TAG_ALLOCBUF 0x40001 -#define PROP_TAG_BLANKSCR 0x40002 -#define PROP_TAG_PHYSRES 0x40003 -#define PROP_TAG_VIRTRES 0x40004 -#define PROP_TAG_DEPTH 0x40005 -#define PROP_TAG_PIXEL_ORDER 0x40006 -#define PROP_TAG_ALPHA_MODE 0x40007 -#define PROP_TAG_PITCH 0x40008 -#define PROP_TAG_VOFFS 0x40009 -#define PROP_TAG_OVERSCAN 0x4000a -#define PROP_TAG_PALETTE 0x4000b -#define PROP_TAG_CUR_INFO 0x00010 -#define PROP_TAG_CUR_STATE 0x00011 - - -int prop_blankscr(int onoff); - -uint32_t mb_read(int chan); -void mb_write(int chan, uint32_t val); +void dbgled(int x); +void exit(int x); int main(void) { - prop_blankscr(1); - - return 0; -} + disable_intr(); -static uint32_t propbuf[64] __attribute__((aligned(16))); + dbgled(2); -int prop_blankscr(int onoff) -{ - uint32_t *pb = propbuf; + init_serial(115200); + ser_printstr("starting rpkern\n"); - *pb++ = 0; - *pb++ = 0; - *pb++ = PROP_TAG_BLANKSCR; - *pb++ = 4; /* data size */ - *pb++ = PROP_CODE_REQ; - *pb++ = onoff ? 1 : 0; - *pb++ = PROP_TAG_END; - *pb++ = 0; /* padding */ - propbuf[0] = (char*)pb - (char*)propbuf; + for(;;) { + int c = ser_getchar(); + if(c == -1) { + ser_printstr("error!\n"); + } else { + ser_printstr("got: "); + ser_putchar(c); + ser_putchar('\r'); + ser_putchar('\n'); + } + } - mb_write(MB_CHAN_PROP, (uint32_t)propbuf >> 4); - mb_read(MB_CHAN_PROP); - - return propbuf[1] == PROP_RESP_OK ? 0 : -1; -} - -uint32_t mb_read(int chan) -{ - uint32_t val; - do { - while(REG_MB_STAT & MB_STAT_EMPTY); - val = REG_MB_READ; - } while((val & 0xf) != chan); - return val >> 4; + return 0; } -void mb_write(int chan, uint32_t val) +void panic(void) { - while(REG_MB_STAT & MB_STAT_FULL); - REG_MB_WRITE = (val << 4) | chan; + dbgled(1); + exit(0); }