void screeninit(void) { uchar *fb; int set; ulong chan; set = screensize() == 0; fb = fbinit(set, &xgscreen.r.max.x, &xgscreen.r.max.y, &xgscreen.depth); if(fb == nil){ print("can't initialise %dx%dx%d framebuffer \n", xgscreen.r.max.x, xgscreen.r.max.y, xgscreen.depth); return; } xgscreen.clipr = xgscreen.r; switch(xgscreen.depth){ default: print("unsupported screen depth %d\n", xgscreen.depth); xgscreen.depth = 16; /* fall through */ case 16: chan = RGB16; break; case 24: chan = BGR24; break; case 32: chan = ARGB32; break; } memsetchan(&xgscreen, chan); conf.monitor = 1; xgdata.bdata = fb; xgdata.ref = 1; gscreen = &xgscreen; gscreen->width = wordsperline(gscreen->r, gscreen->depth); memimageinit(); memdefont = getmemdefont(); screenwin(); screenputs = myscreenputs; swcursorinit(); }
static void vgactl(Cmdbuf *cb) { int align, i, size, x, y, z; char *chanstr, *p; ulong chan; Cmdtab *ct; VGAscr *scr; extern VGAdev *vgadev[]; extern VGAcur *vgacur[]; scr = &vgascreen[0]; ct = lookupcmd(cb, vgactlmsg, nelem(vgactlmsg)); switch(ct->index) { case CMhwgc: if(strcmp(cb->f[1], "off") == 0) { lock(&cursor); if(scr->cur) { if(scr->cur->disable) scr->cur->disable(scr); scr->cur = nil; } unlock(&cursor); return; } if(strcmp(cb->f[1], "soft") == 0) { lock(&cursor); swcursorinit(); if(scr->cur && scr->cur->disable) scr->cur->disable(scr); scr->cur = &swcursor; if(scr->cur->enable) scr->cur->enable(scr); unlock(&cursor); return; } for(i = 0; vgacur[i]; i++) { if(strcmp(cb->f[1], vgacur[i]->name)) continue; lock(&cursor); if(scr->cur && scr->cur->disable) scr->cur->disable(scr); scr->cur = vgacur[i]; if(scr->cur->enable) scr->cur->enable(scr); unlock(&cursor); return; } break; case CMtype: for(i = 0; vgadev[i]; i++) { if(strcmp(cb->f[1], vgadev[i]->name)) continue; if(scr->dev && scr->dev->disable) scr->dev->disable(scr); scr->dev = vgadev[i]; if(scr->dev->enable) scr->dev->enable(scr); return; } break; case CMtextmode: screeninit(); return; case CMsize: x = strtoul(cb->f[1], &p, 0); if(x == 0 || x > 10240) error(Ebadarg); if(*p) p++; y = strtoul(p, &p, 0); if(y == 0 || y > 10240) error(Ebadarg); if(*p) p++; z = strtoul(p, &p, 0); chanstr = cb->f[2]; if((chan = strtochan(chanstr)) == 0) error("bad channel"); if(chantodepth(chan) != z) error("depth, channel do not match"); cursoroff(1); deletescreenimage(); if(screensize(x, y, z, chan)) error(Egreg); vgascreenwin(scr); resetscreenimage(); cursoron(1); return; case CMactualsize: if(scr->gscreen == nil) error("set the screen size first"); x = strtoul(cb->f[1], &p, 0); if(x == 0 || x > 2048) error(Ebadarg); if(*p) p++; y = strtoul(p, nil, 0); if(y == 0 || y > 2048) error(Ebadarg); if(x > scr->gscreen->r.max.x || y > scr->gscreen->r.max.y) error("physical screen bigger than virtual"); physgscreenr = Rect(0,0,x,y); scr->gscreen->clipr = physgscreenr; return; case CMpalettedepth: x = strtoul(cb->f[1], &p, 0); if(x != 8 && x != 6) error(Ebadarg); scr->palettedepth = x; return; case CMdrawinit: memimagedraw(scr->gscreen, scr->gscreen->r, memblack, ZP, nil, ZP, S); if(scr && scr->dev && scr->dev->drawinit) scr->dev->drawinit(scr); return; case CMlinear: if(cb->nf!=2 && cb->nf!=3) error(Ebadarg); size = strtoul(cb->f[1], 0, 0); if(cb->nf == 2) align = 0; else align = strtoul(cb->f[2], 0, 0); if(screenaperture(size, align) < 0) error("not enough free address space"); return; /* case CMmemset: memset((void*)strtoul(cb->f[1], 0, 0), atoi(cb->f[2]), atoi(cb->f[3])); return; */ case CMblank: drawblankscreen(1); return; case CMunblank: drawblankscreen(0); return; case CMblanktime: blanktime = strtoul(cb->f[1], 0, 0); return; case CMpanning: if(strcmp(cb->f[1], "on") == 0) { if(scr == nil || scr->cur == nil) error("set screen first"); if(!scr->cur->doespanning) error("panning not supported"); scr->gscreen->clipr = scr->gscreen->r; panning = 1; } else if(strcmp(cb->f[1], "off") == 0) { scr->gscreen->clipr = physgscreenr; panning = 0; } else break; return; case CMhwaccel: if(strcmp(cb->f[1], "on") == 0) hwaccel = 1; else if(strcmp(cb->f[1], "off") == 0) hwaccel = 0; else break; return; case CMhwblank: if(strcmp(cb->f[1], "on") == 0) hwblank = 1; else if(strcmp(cb->f[1], "off") == 0) hwblank = 0; else break; return; } cmderror(cb, "bad VGA control message"); }
int screensize(int x, int y, int z, uint32_t chan) { Proc *up = externup(); VGAscr *scr; void *oldsoft; lock(&vgascreenlock); if(waserror()){ unlock(&vgascreenlock); nexterror(); } memimageinit(); scr = &vgascreen[0]; oldsoft = softscreen; if(scr->paddr == 0){ int width = (x*z)/BI2WD; void *p; p = malloc(width*BY2WD*y); if(p == nil) error("no memory for vga soft screen"); gscreendata.bdata = softscreen = p; if(scr->dev && scr->dev->page){ scr->vaddr = KADDR(VGAMEM()); scr->apsize = 1<<16; } scr->useflush = 1; } else{ gscreendata.bdata = scr->vaddr; scr->useflush = scr->dev && scr->dev->flush; } scr->gscreen = nil; if(gscreen) freememimage(gscreen); gscreen = allocmemimaged(Rect(0,0,x,y), chan, &gscreendata); if(gscreen == nil) error("no memory for vga memimage"); vgaimageinit(chan); scr->palettedepth = 6; /* default */ scr->gscreendata = &gscreendata; scr->memdefont = getmemdefont(); scr->gscreen = gscreen; physgscreenr = gscreen->r; unlock(&vgascreenlock); poperror(); if(oldsoft) free(oldsoft); memimagedraw(gscreen, gscreen->r, memblack, ZP, nil, ZP, S); flushmemscreen(gscreen->r); if(didswcursorinit) swcursorinit(); drawcmap(); return 0; }
void main() { uint j=0,i=0,k=0; uint rev; ulong pc; pc = getpc(); pl011_addr((void *)pc, 1); pl011_puts("Entered main() at "); pl011_addr(&main, 0); pl011_puts(" with SP="); pl011_addr((void *)getsp(), 0); pl011_puts(" with SC="); pl011_addr((void *)getsc(), 0); pl011_puts(" with CPSR="); pl011_addr((void *)getcpsr(), 0); pl011_puts(" with SPSR="); pl011_addr((void *)getspsr(), 1); pl011_puts("Clearing Mach: "); memset(m, 0, sizeof(Mach)); pl011_addr((char *)m, 0); pl011_puts("-"); pl011_addr((char *)(m+1), 1); pl011_puts("Clearing edata: "); memset(edata, 0, end-edata); pl011_addr((char *)&edata, 0); pl011_puts("-"); pl011_addr((char *)&end, 1); conf.nmach = 1; quotefmtinstall(); confinit(); mmuinit1(); xinit(); poolinit(); poolsizeinit(); //uartconsinit(); screeninit(); trapinit(); timersinit(); clockinit(); printinit(); swcursorinit(); rev = getfirmware(); print("\nARM %ld MHz id %8.8lux firmware: rev %d, mem: %ld\n" ,(m->cpuhz+500000)/1000000, getcpuid(), rev, conf.topofmem/MB); print("Inferno OS %s Vita Nuova\n", VERSION); print("Ported to Raspberry Pi (BCM2835) by LynxLine\n\n"); procinit(); links(); chandevreset(); eve = strdup("inferno"); userinit(); schedinit(); pl011_puts("to inifinite loop\n\n"); for (;;); }