📄 prom.c
字号:
int i, n; for (pp = np->properties; pp != 0; pp = pp->next) { printk(KERN_INFO "%s", pp->name); for (i = strlen(pp->name); i < 16; ++i) printk(" "); cp = (char *) pp->value; for (i = pp->length; i > 0; --i, ++cp) if ((i > 1 && (*cp < 0x20 || *cp > 0x7e)) || (i == 1 && *cp != 0)) break; if (i == 0 && pp->length > 1) { /* looks like a string */ printk(" %s\n", (char *) pp->value); } else { /* dump it in hex */ n = pp->length; if (n > 64) n = 64; if (pp->length % 4 == 0) { unsigned int *p = (unsigned int *) pp->value; n /= 4; for (i = 0; i < n; ++i) { if (i != 0 && (i % 4) == 0) printk("\n "); printk(" %08x", *p++); } } else { unsigned char *bp = pp->value; for (i = 0; i < n; ++i) { if (i != 0 && (i % 16) == 0) printk("\n "); printk(" %02x", *bp++); } } printk("\n"); if (pp->length > 64) printk(" ... (length = %d)\n", pp->length); } }}#endifspinlock_t rtas_lock = SPIN_LOCK_UNLOCKED;/* this can be called after setup -- Cort */__openfirmwareintcall_rtas(const char *service, int nargs, int nret, unsigned long *outputs, ...){ va_list list; int i; unsigned long s; struct device_node *rtas; int *tokp; union { unsigned long words[16]; double align; } u; rtas = find_devices("rtas"); if (rtas == NULL) return -1; tokp = (int *) get_property(rtas, service, NULL); if (tokp == NULL) { printk(KERN_ERR "No RTAS service called %s\n", service); return -1; } u.words[0] = *tokp; u.words[1] = nargs; u.words[2] = nret; va_start(list, outputs); for (i = 0; i < nargs; ++i) u.words[i+3] = va_arg(list, unsigned long); va_end(list); spin_lock_irqsave(&rtas_lock, s); enter_rtas((void *)__pa(&u)); spin_unlock_irqrestore(&rtas_lock, s); if (nret > 1 && outputs != NULL) for (i = 0; i < nret-1; ++i) outputs[i] = u.words[i+nargs+4]; return u.words[nargs+3];}__initvoidabort(){#ifdef CONFIG_XMON xmon(NULL);#endif for (;;) prom_exit();}#ifdef CONFIG_BOOTX_TEXT/* Here's a small text engine to use during early boot or for debugging purposes * * todo: * * - build some kind of vgacon with it to enable early printk * - move to a separate file * - add a few video driver hooks to keep in sync with display * changes. */voidmap_bootx_text(void){ unsigned long base, offset, size; if (disp_bi == 0) return; base = ((unsigned long) disp_bi->dispDeviceBase) & 0xFFFFF000UL; offset = ((unsigned long) disp_bi->dispDeviceBase) - base; size = disp_bi->dispDeviceRowBytes * disp_bi->dispDeviceRect[3] + offset + disp_bi->dispDeviceRect[0]; disp_bi->logicalDisplayBase = ioremap(base, size); if (disp_bi->logicalDisplayBase == 0) return; disp_bi->logicalDisplayBase += offset; bootx_text_mapped = 1;}/* Calc the base address of a given point (x,y) */__pmacstatic unsigned char *calc_base(boot_infos_t *bi, int x, int y){ unsigned char *base; base = bi->logicalDisplayBase; if (base == 0) base = bi->dispDeviceBase; base += (x + bi->dispDeviceRect[0]) * (bi->dispDeviceDepth >> 3); base += (y + bi->dispDeviceRect[1]) * bi->dispDeviceRowBytes; return base;}/* Adjust the display to a new resolution */voidbootx_update_display(unsigned long phys, int width, int height, int depth, int pitch){ if (disp_bi == 0) return; /* check it's the same frame buffer (within 16MB) */ if ((phys ^ (unsigned long)disp_bi->dispDeviceBase) & 0xff000000) return; disp_bi->dispDeviceBase = (__u8 *) phys; disp_bi->dispDeviceRect[0] = 0; disp_bi->dispDeviceRect[1] = 0; disp_bi->dispDeviceRect[2] = width; disp_bi->dispDeviceRect[3] = height; disp_bi->dispDeviceDepth = depth; disp_bi->dispDeviceRowBytes = pitch; if (bootx_text_mapped) { iounmap(disp_bi->logicalDisplayBase); bootx_text_mapped = 0; } map_bootx_text(); g_loc_X = 0; g_loc_Y = 0; g_max_loc_X = width / 8; g_max_loc_Y = height / 16;}__pmacstatic voidclearscreen(void){ unsigned long offset = reloc_offset(); boot_infos_t* bi = PTRRELOC(RELOC(disp_bi)); unsigned long *base = (unsigned long *)calc_base(bi, 0, 0); unsigned long width = ((bi->dispDeviceRect[2] - bi->dispDeviceRect[0]) * (bi->dispDeviceDepth >> 3)) >> 2; int i,j; for (i=0; i<(bi->dispDeviceRect[3] - bi->dispDeviceRect[1]); i++) { unsigned long *ptr = base; for(j=width; j; --j) *(ptr++) = 0; base += (bi->dispDeviceRowBytes >> 2); }}__inline__ void dcbst(const void* addr){ __asm__ __volatile__ ("dcbst 0,%0" :: "r" (addr));}__pmacstatic voidflushscreen(void){ unsigned long offset = reloc_offset(); boot_infos_t* bi = PTRRELOC(RELOC(disp_bi)); unsigned long *base = (unsigned long *)calc_base(bi, 0, 0); unsigned long width = ((bi->dispDeviceRect[2] - bi->dispDeviceRect[0]) * (bi->dispDeviceDepth >> 3)) >> 2; int i,j; for (i=0; i<(bi->dispDeviceRect[3] - bi->dispDeviceRect[1]); i++) { unsigned long *ptr = base; for(j=width; j>0; j-=8) { dcbst(ptr); ptr += 8; } base += (bi->dispDeviceRowBytes >> 2); }}#ifndef NO_SCROLL__pmacstatic voidscrollscreen(void){ unsigned long offset = reloc_offset(); boot_infos_t* bi = PTRRELOC(RELOC(disp_bi)); unsigned long *src = (unsigned long *)calc_base(bi,0,16); unsigned long *dst = (unsigned long *)calc_base(bi,0,0); unsigned long width = ((bi->dispDeviceRect[2] - bi->dispDeviceRect[0]) * (bi->dispDeviceDepth >> 3)) >> 2; int i,j; #ifdef CONFIG_ADB_PMU pmu_suspend(); /* PMU will not shut us down ! */#endif for (i=0; i<(bi->dispDeviceRect[3] - bi->dispDeviceRect[1] - 16); i++) { unsigned long *src_ptr = src; unsigned long *dst_ptr = dst; for(j=width; j; --j) *(dst_ptr++) = *(src_ptr++); src += (bi->dispDeviceRowBytes >> 2); dst += (bi->dispDeviceRowBytes >> 2); } for (i=0; i<16; i++) { unsigned long *dst_ptr = dst; for(j=width; j; --j) *(dst_ptr++) = 0; dst += (bi->dispDeviceRowBytes >> 2); }#ifdef CONFIG_ADB_PMU pmu_resume(); /* PMU will not shut us down ! */#endif}#endif /* ndef NO_SCROLL */__pmacvoidprom_drawchar(char c){ unsigned long offset = reloc_offset(); int cline = 0, x; if (!RELOC(bootx_text_mapped)) return; switch (c) { case '\b': if (RELOC(g_loc_X) > 0) --RELOC(g_loc_X); break; case '\t': RELOC(g_loc_X) = (RELOC(g_loc_X) & -8) + 8; break; case '\r': RELOC(g_loc_X) = 0; break; case '\n': RELOC(g_loc_X) = 0; RELOC(g_loc_Y)++; cline = 1; break; default: draw_byte(c, RELOC(g_loc_X)++, RELOC(g_loc_Y)); } if (RELOC(g_loc_X) >= RELOC(g_max_loc_X)) { RELOC(g_loc_X) = 0; RELOC(g_loc_Y)++; cline = 1; }#ifndef NO_SCROLL while (RELOC(g_loc_Y) >= RELOC(g_max_loc_Y)) { scrollscreen(); RELOC(g_loc_Y)--; }#else /* wrap around from bottom to top of screen so we don't waste time scrolling each line. -- paulus. */ if (RELOC(g_loc_Y) >= RELOC(g_max_loc_Y)) RELOC(g_loc_Y) = 0; if (cline) { for (x = 0; x < RELOC(g_max_loc_X); ++x) draw_byte(' ', x, RELOC(g_loc_Y)); }#endif}__pmacvoidprom_drawstring(const char *c){ unsigned long offset = reloc_offset(); if (!RELOC(bootx_text_mapped)) return; while (*c) prom_drawchar(*c++);}__pmacvoidprom_drawhex(unsigned long v){ static char hex_table[] = "0123456789abcdef"; unsigned long offset = reloc_offset(); if (!RELOC(bootx_text_mapped)) return; prom_drawchar(RELOC(hex_table)[(v >> 28) & 0x0000000FUL]); prom_drawchar(RELOC(hex_table)[(v >> 24) & 0x0000000FUL]); prom_drawchar(RELOC(hex_table)[(v >> 20) & 0x0000000FUL]); prom_drawchar(RELOC(hex_table)[(v >> 16) & 0x0000000FUL]); prom_drawchar(RELOC(hex_table)[(v >> 12) & 0x0000000FUL]); prom_drawchar(RELOC(hex_table)[(v >> 8) & 0x0000000FUL]); prom_drawchar(RELOC(hex_table)[(v >> 4) & 0x0000000FUL]); prom_drawchar(RELOC(hex_table)[(v >> 0) & 0x0000000FUL]);}__pmacstatic voiddraw_byte(unsigned char c, long locX, long locY){ unsigned long offset = reloc_offset(); boot_infos_t* bi = PTRRELOC(RELOC(disp_bi)); unsigned char *base = calc_base(bi, locX << 3, locY << 4); unsigned char *font = &RELOC(vga_font)[((unsigned long)c) * 16]; int rb = bi->dispDeviceRowBytes; switch(bi->dispDeviceDepth) { case 32: draw_byte_32(font, (unsigned long *)base, rb); break; case 16: draw_byte_16(font, (unsigned long *)base, rb); break; case 8: draw_byte_8(font, (unsigned long *)base, rb); break; default: break; }}__pmacstatic unsigned long expand_bits_8[16] = { 0x00000000, 0x000000ff, 0x0000ff00, 0x0000ffff, 0x00ff0000, 0x00ff00ff, 0x00ffff00, 0x00ffffff, 0xff000000, 0xff0000ff, 0xff00ff00, 0xff00ffff, 0xffff0000, 0xffff00ff, 0xffffff00, 0xffffffff};__pmacstatic unsigned long expand_bits_16[4] = { 0x00000000, 0x0000ffff, 0xffff0000, 0xffffffff};__pmacstatic voiddraw_byte_32(unsigned char *font, unsigned long *base, int rb){ int l, bits; int fg = 0xFFFFFFFFUL; int bg = 0x00000000UL; for (l = 0; l < 16; ++l) { bits = *font++; base[0] = (-(bits >> 7) & fg) ^ bg; base[1] = (-((bits >> 6) & 1) & fg) ^ bg; base[2] = (-((bits >> 5) & 1) & fg) ^ bg; base[3] = (-((bits >> 4) & 1) & fg) ^ bg; base[4] = (-((bits >> 3) & 1) & fg) ^ bg; base[5] = (-((bits >> 2) & 1) & fg) ^ bg; base[6] = (-((bits >> 1) & 1) & fg) ^ bg; base[7] = (-(bits & 1) & fg) ^ bg; base = (unsigned long *) ((char *)base + rb); }}__pmacstatic voiddraw_byte_16(unsigned char *font, unsigned long *base, int rb){ int l, bits; int fg = 0xFFFFFFFFUL; int bg = 0x00000000UL; unsigned long offset = reloc_offset(); unsigned long *eb = RELOC(expand_bits_16); for (l = 0; l < 16; ++l) { bits = *font++; base[0] = (eb[bits >> 6] & fg) ^ bg; base[1] = (eb[(bits >> 4) & 3] & fg) ^ bg; base[2] = (eb[(bits >> 2) & 3] & fg) ^ bg; base[3] = (eb[bits & 3] & fg) ^ bg; base = (unsigned long *) ((char *)base + rb); }}__pmacstatic voiddraw_byte_8(unsigned char *font, unsigned long *base, int rb){ int l, bits; int fg = 0x0F0F0F0FUL; int bg = 0x00000000UL; unsigned long offset = reloc_offset(); unsigned long *eb = RELOC(expand_bits_8); for (l = 0; l < 16; ++l) { bits = *font++; base[0] = (eb[bits >> 4] & fg) ^ bg; base[1] = (eb[bits & 0xf] & fg) ^ bg; base = (unsigned long *) ((char *)base + rb); }}__pmacstatic unsigned char vga_font[cmapsz] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x81, 0xa5, 0x81, 0x81, 0xbd, 0x99, 0x81, 0x81, 0x7e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7e, 0xff, 0xdb, 0xff, 0xff, 0xc3, 0xe7, 0xff, 0xff, 0x7e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6c, 0xfe, 0xfe, 0xfe, 0xfe, 0x7c, 0x38, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x38, 0x7c, 0xfe, 0x7c, 0x38, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x3c, 0x3c, 0xe7, 0xe7, 0xe7, 0x18, 0x18, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x3c, 0x7e, 0xff, 0xff, 0x7e, 0x18, 0x18, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x3c, 0x3c, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe7, 0xc3, 0xc3, 0xe7, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x66, 0x42, 0x42, 0x66, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xc3, 0x99, 0xbd, 0xbd, 0x99, 0xc3, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x1e, 0x0e, 0x1a, 0x32, 0x78, 0xcc, 0xcc, 0xcc, 0xcc, 0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x66, 0x66, 0x66, 0x66, 0x3c, 0x18, 0x7e, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x33, 0x3f, 0x30, 0x30, 0x30, 0x30, 0x70, 0xf0, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7f, 0x63, 0x7f, 0x63, 0x63, 0x63, 0x63, 0x67, 0xe7, 0xe6, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0xdb, 0x3c, 0xe7, 0x3c, 0xdb, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xc0, 0xe0, 0xf0, 0xf8, 0xfe, 0xf8, 0xf0, 0xe0, 0xc0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x06, 0x0e, 0x1e, 0x3e, 0xfe, 0x3e, 0x1e, 0x0e, 0x06, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x3c, 0x7e, 0x18, 0x18, 0x18, 0x7e, 0x3c, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x00, 0x66, 0x66, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7f, 0xdb, 0xdb, 0xdb, 0x7b, 0x1b, 0x1b, 0x1b, 0x1b, 0x1b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7c, 0xc6, 0x60, 0x38, 0x6c, 0xc6, 0xc6, 0x6c, 0x38, 0x0c, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0xfe, 0xfe, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x3c, 0x7e, 0x18, 0x18, 0x18, 0x7e, 0x3c, 0x18, 0x7e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x3c,
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -