?? sticon-bmode.c
字號:
DPRINTK(("!!!!\n")); { u32 foo = 0; while(foo += 0x100); } }#endif offset += 4; dest += 4; } while(count) { count--; *(u8 *)dest = gsc_readb(base + offset); offset++; dest++; } flush_kernel_dcache_range((unsigned long)dest, count); flush_icache_range((unsigned long)dest, dest + count);}static void dump_sti_rom(struct sti_rom *rom){ printk("STI byte mode ROM type %d\n", STI_U8(rom->type)); printk(" supports %d monitors\n", STI_U8(rom->num_mons)); printk(" conforms to STI ROM spec revision %d.%02x\n", STI_U8(rom->revno[0]) >> 4, STI_U8(rom->revno[0]) & 0x0f); printk(__FUNCTION__ ": %d\n", __LINE__); printk(" graphics id %02x%02x%02x%02x%02x%02x%02x%02x\n", (unsigned int) STI_U8(rom->graphics_id[0]), (unsigned int) STI_U8(rom->graphics_id[1]), (unsigned int) STI_U8(rom->graphics_id[2]), (unsigned int) STI_U8(rom->graphics_id[3]), (unsigned int) STI_U8(rom->graphics_id[4]), (unsigned int) STI_U8(rom->graphics_id[5]), (unsigned int) STI_U8(rom->graphics_id[6]), (unsigned int) STI_U8(rom->graphics_id[7])); printk(__FUNCTION__ ": %d\n", __LINE__); printk(" font start %08x\n", STI_U32(rom->font_start)); printk(__FUNCTION__ ": %d\n", __LINE__); printk(" region list %08x\n", STI_U32(rom->region_list)); printk(__FUNCTION__ ": %d\n", __LINE__); printk(" init_graph %08x\n", STI_U32(rom->init_graph)); printk(__FUNCTION__ ": %d\n", __LINE__); printk(" alternate code type %d\n", STI_U8(rom->alt_code_type)); printk(__FUNCTION__ ": %d\n", __LINE__);}static void __init sti_cook_fonts(struct sti_cooked_rom *cooked_rom, struct sti_rom *raw_rom){ struct sti_rom_font *raw_font; struct sti_cooked_font *cooked_font; struct sti_rom_font *font_start; cooked_font = kmalloc(sizeof *cooked_font, GFP_KERNEL); if(!cooked_font) return; cooked_rom->font_start = cooked_font;#if 0 DPRINTK(("%p = %p + %08x\n", ((void *)raw_rom) + (STI_U32(raw_rom->font_start)), ((void *)raw_rom), (STI_U32(raw_rom->font_start))));#endif raw_font = ((void *)raw_rom) + STI_U32(raw_rom->font_start) - 3; font_start = raw_font; cooked_font->raw = raw_font; DPRINTK(("next font %08x\n", STI_U32(raw_font->next_font))); while(0 && STI_U32(raw_font->next_font)) { raw_font = ((void *)font_start) + STI_U32(raw_font->next_font); cooked_font->next_font = kmalloc(sizeof *cooked_font, GFP_KERNEL); if(!cooked_font->next_font) return; cooked_font = cooked_font->next_font;// cooked_font->raw = raw_font; DPRINTK(("raw_font %p\n", raw_font)); DPRINTK(("next_font %08x %p\n", STI_U32(raw_font->next_font), ((void *)font_start) + STI_U32(raw_font->next_font))); } cooked_font->next_font = NULL;}static unsigned long __init sti_cook_function(void *function, u32 size){ sti_u32 *func = (sti_u32 *)function; u32 *ret; int i; ret = kmalloc(size, GFP_KERNEL); if(!ret) { printk(KERN_ERR __FILE__ ": could not get memory.\n"); return 0; } for(i=0; i<(size/4); i++) ret[i] = STI_U32(func[i]); flush_all_caches(); return virt_to_phys(ret);}static int font_index, font_height, font_width;static int __init sti_search_font(struct sti_cooked_rom *rom, int height, int width){ struct sti_cooked_font *font; int i = 0; for(font = rom->font_start; font; font = font->next_font, i++) { if((STI_U8(font->raw->width) == width) && (STI_U8(font->raw->height) == height)) return i; } return 0;}static struct sti_cooked_font * __initsti_select_font(struct sti_cooked_rom *rom){ struct sti_cooked_font *font; int i; if(font_width && font_height) font_index = sti_search_font(rom, font_height, font_width); for(font = rom->font_start, i = font_index; font && (i > 0); font = font->next_font, i--); if(font) return font; else return rom->font_start;} /* address is a pointer to a word mode or pci rom */static struct sti_struct * __init sti_read_rom(unsigned long address){ struct sti_struct *ret = NULL; struct sti_cooked_rom *cooked = NULL; struct sti_rom *raw = NULL; unsigned long size; ret = &default_sti; if(!ret) goto out_err; cooked = kmalloc(sizeof *cooked, GFP_KERNEL); raw = kmalloc(sizeof *raw, GFP_KERNEL); if(!(raw && cooked)) goto out_err; /* reallocate raw */ sti_rom_copy(address, 0, sizeof *raw, raw); dump_sti_rom(raw); size = STI_U32(raw->last_addr) + 1; size = 128*1024;// DPRINTK(("size %08lx\n", size));// DPRINTK(("font_start %08x\n", STI_U32(raw->font_start)));// kfree(raw); raw = kmalloc(size, GFP_KERNEL); if(!raw) goto out_err; sti_rom_copy(address, 0, size-1, raw); sti_cook_fonts(cooked, raw);// sti_cook_regions(cooked, raw);// sti_cook_functions(cooked, raw); if(STI_U32(raw->region_list)) { struct sti_rom_region *region = ((void *)raw) + STI_U32(raw->region_list) - 3;// DPRINTK(("region_list %08x\n", STI_U32(raw->region_list))); ret->regions = kmalloc(32, GFP_KERNEL); /* FIXME!! */ ret->regions[0] = STI_U32(region[0].region); ret->regions[1] = STI_U32(region[1].region); ret->regions[2] = STI_U32(region[2].region); ret->regions[3] = STI_U32(region[3].region); ret->regions[4] = STI_U32(region[4].region); ret->regions[5] = STI_U32(region[5].region); ret->regions[6] = STI_U32(region[6].region); ret->regions[7] = STI_U32(region[7].region); } address = virt_to_phys(raw);#if 0 DPRINTK(("init_graph %08x %08x\n" "state_mgmt %08x %08x\n" "font_unpmv %08x %08x\n" "block_move %08x %08x\n" "self_test %08x %08x\n" "excep_hdlr %08x %08x\n" "irq_conf %08x %08x\n" "set_cm_e %08x %08x\n" "dma_ctrl %08x %08x\n" "flow_ctrl %08x %08x\n" "user_timin %08x %08x\n" "process_m %08x %08x\n" "sti_util %08x %08x\n" "end_addr %08x %08x\n", STI_U32(raw->init_graph), STI_U32(raw->init_graph_m68k), STI_U32(raw->state_mgmt), STI_U32(raw->state_mgmt_m68k), STI_U32(raw->font_unpmv), STI_U32(raw->font_unpmv_m68k), STI_U32(raw->block_move), STI_U32(raw->block_move_m68k), STI_U32(raw->self_test), STI_U32(raw->self_test_m68k), STI_U32(raw->excep_hdlr), STI_U32(raw->excep_hdlr_m68k), STI_U32(raw->init_graph), STI_U32(raw->init_graph_m68k), STI_U32(raw->init_graph), STI_U32(raw->init_graph_m68k), STI_U32(raw->init_graph), STI_U32(raw->init_graph_m68k), STI_U32(raw->init_graph), STI_U32(raw->init_graph_m68k), STI_U32(raw->init_graph), STI_U32(raw->init_graph_m68k), STI_U32(raw->init_graph), STI_U32(raw->init_graph_m68k), STI_U32(raw->init_graph), STI_U32(raw->init_graph_m68k), STI_U32(raw->end_addr), STI_U32(raw->end_addr_m68k) ) );#endif ret->init_graph = sti_cook_function(((void *)raw)+STI_U32(raw->init_graph)-3, (STI_U32(raw->state_mgmt) - STI_U32(raw->init_graph))/4); ret->font_unpmv = sti_cook_function(((void *)raw)+STI_U32(raw->font_unpmv)-3, (STI_U32(raw->block_move) - STI_U32(raw->font_unpmv))/4); ret->block_move = sti_cook_function(((void *)raw)+STI_U32(raw->block_move)-3, (STI_U32(raw->self_test) - STI_U32(raw->block_move))/4); ret->inq_conf = sti_cook_function(((void *)raw)+STI_U32(raw->inq_conf), STI_U32(raw->set_cm_entry) - STI_U32(raw->inq_conf)); ret->rom = cooked; ret->rom->raw = raw; ret->font = (struct sti_rom_font *) virt_to_phys(sti_select_font(ret->rom)->raw); return ret;out_err: if(raw) kfree(raw); if(cooked) kfree(cooked); return NULL;}#if 0static void dump_globcfg_ext(struct sti_glob_cfg_ext *cfg){ DPRINTK(("monitor %d\n" "in friendly mode: %d\n" "power consumption %d watts\n" "freq ref %d\n" "sti_mem_addr %p\n", cfg->curr_mon, cfg->friendly_boot, cfg->power, cfg->freq_ref, cfg->sti_mem_addr));}static void dump_globcfg(struct sti_glob_cfg *glob_cfg){ DPRINTK(("%d text planes\n" "%4d x %4d screen resolution\n" "%4d x %4d offscreen\n" "%4d x %4d layout\n" "regions at %08x %08x %08x %08x\n" "regions at %08x %08x %08x %08x\n" "reent_lvl %d\n" "save_addr %p\n", glob_cfg->text_planes, glob_cfg->onscreen_x, glob_cfg->onscreen_y, glob_cfg->offscreen_x, glob_cfg->offscreen_y, glob_cfg->total_x, glob_cfg->total_y, glob_cfg->region_ptrs[0], glob_cfg->region_ptrs[1], glob_cfg->region_ptrs[2], glob_cfg->region_ptrs[3], glob_cfg->region_ptrs[4], glob_cfg->region_ptrs[5], glob_cfg->region_ptrs[6], glob_cfg->region_ptrs[7], glob_cfg->reent_lvl, glob_cfg->save_addr)); dump_globcfg_ext(PTR_STI(glob_cfg->ext_ptr));}#endif static void __init sti_init_glob_cfg(struct sti_struct *sti, unsigned long hpa, unsigned long rom_address){ struct sti_glob_cfg *glob_cfg; struct sti_glob_cfg_ext *glob_cfg_ext; void *save_addr; void *sti_mem_addr; glob_cfg = kmalloc(sizeof *sti->glob_cfg, GFP_KERNEL); glob_cfg_ext = kmalloc(sizeof *glob_cfg_ext, GFP_KERNEL); save_addr = kmalloc(1024 /*XXX*/, GFP_KERNEL); sti_mem_addr = kmalloc(1024, GFP_KERNEL); if((!glob_cfg) || (!glob_cfg_ext) || (!save_addr) || (!sti_mem_addr)) return; memset(glob_cfg, 0, sizeof *glob_cfg); memset(glob_cfg_ext, 0, sizeof *glob_cfg_ext); memset(save_addr, 0, 1024); memset(sti_mem_addr, 0, 1024); glob_cfg->ext_ptr = STI_PTR(glob_cfg_ext); glob_cfg->save_addr = STI_PTR(save_addr); glob_cfg->region_ptrs[0] = ((sti->regions[0]>>18)<<12) + rom_address; glob_cfg->region_ptrs[1] = ((sti->regions[1]>>18)<<12) + hpa; glob_cfg->region_ptrs[2] = ((sti->regions[2]>>18)<<12) + hpa; glob_cfg->region_ptrs[3] = ((sti->regions[3]>>18)<<12) + hpa; glob_cfg->region_ptrs[4] = ((sti->regions[4]>>18)<<12) + hpa; glob_cfg->region_ptrs[5] = ((sti->regions[5]>>18)<<12) + hpa; glob_cfg->region_ptrs[6] = ((sti->regions[6]>>18)<<12) + hpa; glob_cfg->region_ptrs[7] = ((sti->regions[7]>>18)<<12) + hpa; glob_cfg_ext->sti_mem_addr = STI_PTR(sti_mem_addr); sti->glob_cfg = STI_PTR(glob_cfg);}static void __init sti_try_rom(unsigned long address, unsigned long hpa){ struct sti_struct *sti = NULL; u16 sig; /* if we can't read the ROM, bail out early. Not being able * to read the hpa is okay, for romless sti */ if(pdc_add_valid((void*)address)) return; printk("found potential STI ROM at %08lx\n", address); sig = le16_to_cpu(gsc_readw(address)); if((sig&0xff) == 0x01) { sti = sti_read_rom(address); } if(sig == 0x0303) { printk("STI word mode ROM at %08lx, ignored\n", address); sti = NULL; } if(!sti) return; /* this is hacked. We need a better way to find out the HPA for * romless STI (eg search for the graphics devices we know about * by sversion) */ if (!pdc_add_valid((void *)0xf5000000)) DPRINTK(("f4000000 b\n")); if (!pdc_add_valid((void *)0xf7000000)) DPRINTK(("f6000000 b\n")); if (!pdc_add_valid((void *)0xf9000000)) DPRINTK(("f8000000 b\n")); if (!pdc_add_valid((void *)0xfb000000)) DPRINTK(("fa000000 b\n")); sti_init_glob_cfg(sti, hpa, address); sti_init_graph(sti); //sti_inq_conf(sti);#if !defined(SERIAL_CONSOLE) { extern void pdc_console_die(void); pdc_console_die(); }#endif take_over_console(&sti_con, 0, MAX_NR_CONSOLES-1, 1); /* sti_inq_conf(sti); */}static unsigned long sti_address;static unsigned long sti_hpa;static void __init sti_init_roms(void){ /* handle the command line */ if(sti_address && sti_hpa) { sti_try_rom(sti_address, sti_hpa); return; } /* 712, 715, some other boxes don't have a separate STI ROM, * but use part of the regular flash */ if(PAGE0->proc_sti) { printk("STI ROM from PDC at %08x\n", PAGE0->proc_sti); if(!pdc_add_valid((void *)0xf9000000)) sti_try_rom(PAGE0->proc_sti, 0xf8000000); else if(!pdc_add_valid((void *)0xf5000000)) sti_try_rom(PAGE0->proc_sti, 0xf4000000); else if(!pdc_add_valid((void *)0xf7000000)) sti_try_rom(PAGE0->proc_sti, 0xf6000000); else if(!pdc_add_valid((void *)0xfb000000)) sti_try_rom(PAGE0->proc_sti, 0xfa000000); } /* standard locations for GSC graphic devices */ if(!pdc_add_valid((void *)0xf4000000)) sti_try_rom(0xf4000000, 0xf4000000); if(!pdc_add_valid((void *)0xf6000000)) sti_try_rom(0xf6000000, 0xf6000000); if(!pdc_add_valid((void *)0xf8000000)) sti_try_rom(0xf8000000, 0xf8000000); if(!pdc_add_valid((void *)0xfa000000)) sti_try_rom(0xfa000000, 0xfa000000);}static int __init sti_init(void){ printk("searching for byte mode STI ROMs\n"); sti_init_roms(); return 0;}module_init(sti_init)MODULE_LICENSE("GPL");
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -