📄 suncons.c
字号:
return 0; } /* set the font */ for (i = 0; i < 256; i++) for (line = 0; line < CHAR_HEIGHT; line++){ vga_font [i*CHAR_HEIGHT + line] = (get_user (arg + (i * 32 + line))); if (con_depth == 1) vga_font [i*CHAR_HEIGHT + line] = vga_font [i*CHAR_HEIGHT + line]; } return 0;}/* * Adjust the screen to fit a font of a certain height * * Returns < 0 for error, 0 if nothing changed, and the number * of lines on the adjusted console if changed. * * for now, we only support the built-in font... */intcon_adjust_height(unsigned long fontheight){ return -EINVAL;}intset_get_cmap(unsigned char * arg, int set){ int i; i = verify_area(set ? VERIFY_READ : VERIFY_WRITE, (void *)arg, 16*3); if (i) return i; for (i=0; i<16; i++) { if (set) { default_red[i] = get_user(arg++) ; default_grn[i] = get_user(arg++) ; default_blu[i] = get_user(arg++) ; } else { put_user (default_red[i], arg++) ; put_user (default_grn[i], arg++) ; put_user (default_blu[i], arg++) ; } } if (set) { for (i=0; i<MAX_NR_CONSOLES; i++) if (vc_cons_allocated(i)) { int j, k ; for (j=k=0; j<16; j++) { vc_cons[i].d->vc_palette[k++] = default_red[j]; vc_cons[i].d->vc_palette[k++] = default_grn[j]; vc_cons[i].d->vc_palette[k++] = default_blu[j]; } } set_palette(); } return 0;}voidsun_clear_screen(void){ memset (con_fb_base, (con_depth == 1 ? ~(0) : (0)), (con_depth * con_height * con_width) / 8); /* also clear out the "shadow" screen memory */ memset((char *)video_mem_base, 0, (video_mem_term - video_mem_base));}/* * dummy routines for the VESA blanking code, which is VGA only, * so we don't have to carry that stuff around for the Sparc... */void vesa_blank(void){}void vesa_unblank(void){}void set_vesa_blanking(const unsigned long arg){}void vesa_powerdown(void){}#undef color/* cg6 cursor status, kernel tracked copy */struct cg6_cursor { short enable; /* cursor is enabled */ struct fbcurpos cpos; /* position */ struct fbcurpos chot; /* hot-spot */ struct fbcurpos size; /* size of mask & image fields */ int bits[2][32]; /* space for mask & image bits */ char color [6]; /* cursor colors */};struct cg6_info { struct bt_regs *bt; /* color control */ void *fbc; struct cg6_fhc *fhc; struct cg6_tec *tec; struct cg6_thc *thc; struct cg6_cursor cursor; /* cursor control */ void *dhc;};struct bwtwo_info { struct bwtwo_regs *regs;};struct cg3_info { struct bt_regs *bt; /* brooktree (color) registers */};/* Array holding the information for the frame buffers */typedef struct { union { struct bwtwo_info bwtwo; struct cg3_info cg3; struct cg6_info cg6; } info; /* per frame information */ int space; /* I/O space this card resides in */ int blanked; /* true if video blanked */ int open; /* is this fb open? */ int mmaped; /* has this fb been mmapped? */ int vtconsole; /* virtual console where it is opened */ long base; /* frame buffer base */ struct fbtype type; /* frame buffer type */ int (*mmap)(struct inode *, struct file *, struct vm_area_struct *, long fb_base, void *); void (*loadcmap)(void *this, int index, int count); void (*blank)(void *this); void (*unblank)(void *this); int (*ioctl)(struct inode *, struct file *, unsigned int, unsigned long, void *);} fbinfo_t;static fbinfo_t fbinfo [FRAME_BUFFERS];/* We need to keep a copy of the color map to answer ioctl requests */static union { unsigned char map[256][3]; /* reasonable way to access */ unsigned int raw[256*3/4]; /* hardware wants it like this */} color_map;#define FB_MMAP_VM_FLAGS (VM_SHM| VM_LOCKED)static intfb_open (struct inode * inode, struct file * file){ int minor = MINOR (inode->i_rdev); if (minor >= FRAME_BUFFERS) return -EBADF; if (fbinfo [minor].open) return -EBUSY; fbinfo [minor].open = 1; fbinfo [minor].mmaped = 0; return 0;}static intfb_ioctl (struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg){ int minor = MINOR (inode->i_rdev); fbinfo_t *fb; struct fbcmap *cmap; int i; if (minor >= FRAME_BUFFERS) return -EBADF; fb = &fbinfo [minor]; switch (cmd){ case FBIOGTYPE: /* return frame buffer type */ i = verify_area (VERIFY_WRITE, (void *) arg, sizeof (struct fbtype)); if (i) return i; *(struct fbtype *)arg = (fb->type); break; case FBIOGATTR:{ struct fbgattr *fba = (struct fbgattr *) arg; i = verify_area (VERIFY_WRITE, (void *) arg, sizeof (struct fbgattr)); if (i) return i; fba->real_type = fb->type.fb_type; fba->owner = 0; fba->fbtype = fb->type; fba->sattr.flags = 0; fba->sattr.emu_type = fb->type.fb_type; fba->sattr.dev_specific [0] = -1; fba->emu_types [0] = fb->type.fb_type; fba->emu_types [1] = -1; break; } case FBIOSVIDEO: i = verify_area(VERIFY_READ, (void *)arg, sizeof(int)); if (i) return i; if (*(int *)arg){ if (!fb->blanked || !fb->unblank) break; (*fb->unblank)(fb); fb->blanked = 0; } else { if (fb->blanked || !fb->blank) break; (*fb->blank)(fb); fb->blanked = 1; } break; case FBIOGVIDEO: i = verify_area (VERIFY_WRITE, (void *) arg, sizeof (int)); if (i) return i; *(int *) arg = fb->blanked; break; case FBIOPUTCMAP: { /* load color map entries */ char *rp, *gp, *bp; int end, count;; if (!fb->loadcmap) return -EINVAL; i = verify_area (VERIFY_READ, (void *) arg, sizeof (struct fbcmap)); if (i) return i; cmap = (struct fbcmap *) arg; count = cmap->count; if ((cmap->index < 0) || (cmap->index > 255)) return -EINVAL; if (cmap->index + count > 256) count = 256 - cmap->index; i = verify_area (VERIFY_READ, rp = cmap->red, cmap->count); if (i) return i; i = verify_area (VERIFY_READ, gp = cmap->green, cmap->count); if (i) return i; i = verify_area (VERIFY_READ, bp = cmap->blue, cmap->count); if (i) return i; end = cmap->index + count; for (i = cmap->index; i < end; i++){ color_map.map [i][0] = *rp++; color_map.map [i][1] = *gp++; color_map.map [i][2] = *bp++; } (*fb->loadcmap)(fb, cmap->index, count); break; } default: if (fb->ioctl){ i = fb->ioctl (inode, file, cmd, arg, fb); if (i == -EINVAL) printk ("[[FBIO: %8.8x]]\n", cmd); return i; } printk ("[[FBIO: %8.8x]]\n", cmd); return -EINVAL; } return 0;}static voidfb_close (struct inode * inode, struct file *filp){ int minor = MINOR(inode->i_rdev); struct fbcursor cursor; if (minor >= FRAME_BUFFERS) return; if (fbinfo [minor].open) fbinfo [minor].open = 0; vt_cons [fbinfo [minor].vtconsole]->vc_mode = KD_TEXT; /* Leaving graphics mode, turn off the cursor */ graphics_on = 0; if (fbinfo [minor].mmaped) sun_clear_screen (); cursor.set = FB_CUR_SETCUR; cursor.enable = 0; fb_ioctl (inode, filp, FBIOSCURPOS, (unsigned long) &cursor); set_palette (); render_screen (); return;}static intfb_mmap (struct inode *inode, struct file *file, struct vm_area_struct *vma){ int minor = MINOR (inode->i_rdev); fbinfo_t *fb; if (minor >= FRAME_BUFFERS) return -ENXIO; /* FIXME: the fg_console below should actually be the * console on which the invoking process is running */ if (vt_cons [fg_console]->vc_mode == KD_GRAPHICS) return -ENXIO; fbinfo [minor].vtconsole = fg_console; fb = &fbinfo [minor]; if (fb->mmap){ int v; v = (*fb->mmap)(inode, file, vma, fb->base, fb); if (v) return v; fbinfo [minor].mmaped = 1; vt_cons [fg_console]->vc_mode = KD_GRAPHICS; graphics_on = 1; return 0; } else return -ENXIO;}static struct file_operations graphdev_fops ={ NULL, /* lseek */ NULL, /* read */ NULL, /* write */ NULL, /* readdir */ NULL, /* select */ fb_ioctl, fb_mmap, fb_open, /* open */ fb_close, /* close */};/* Call the frame buffer routine for setting the palette */voidset_palette (void){ if (console_blanked || vt_cons [fg_console]->vc_mode == KD_GRAPHICS) return; if (fbinfo [0].loadcmap){ int i, j; /* First keep color_map with the palette colors */ for (i = 0; i < 16; i++){ j = color_table [i]; color_map.map [i][0] = default_red [j]; color_map.map [i][1] = default_grn [j]; color_map.map [i][2] = default_blu [j]; } (*fbinfo [0].loadcmap)(&fbinfo [0], 0, 16); }}/* Called when returning to prom */voidconsole_restore_palette (void){ if (restore_palette) (*restore_palette) ();}/* This routine should be moved to srmmu.c */static __inline__ unsigned intsrmmu_get_pte (unsigned long addr){ register unsigned long entry; __asm__ __volatile__("\n\tlda [%1] %2,%0\n\t" : "=r" (entry): "r" ((addr & 0xfffff000) | 0x400), "i" (ASI_M_FLUSH_PROBE)); return entry;}unsigned intget_phys (unsigned int addr){ switch (sparc_cpu_model){ case sun4c: return sun4c_get_pte (addr) << PAGE_SHIFT; case sun4m: return ((srmmu_get_pte (addr) & 0xffffff00) << 4); default: panic ("get_phys called for unsupported cpu model\n"); return 0;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -