📄 gx.h
字号:
/* masks for %modcl bits */#define STIC_CF_VDAC_T 0x00000100 /* <8> */#define STIC_CF_CONFIG_Y 0x00000600 /* <10:9> */#define STIC_CF_CONFIG_X 0x00000800 /* <11> */#define STIC_CF_CONFIG_OPTION 0x00007000 /* <14:12> */#define STIC_CF_PLANES 0x00004000 /* <14> */#define STIC_CF_ZPLANES 0x00001000 /* <12> */#define STIC_CF_REV 0xff000000 /* <31:24> *//* STIC option types (derived from the STIC modtype option field) */#define STIC_OPT_2DA 0x0 /* 2D Accelerator */#define STIC_OPT_2DA_SH 0x0 /* 2D Accelerator */#define STIC_OPT_3DA_SH STIC_CF_CONFIG_OPTION/* * 2DA STIC polling address: * * For 2DA, <15:17> aren't connected at all. Ditto for <24:26>. * Input <2:14+15:20> become the STIC's <2:14+18:23> and likewise * for <21:22> to STIC <27:28>. * * This means you can specify (input) 32K of physically contiguous * memory to the STIC before bumping against some tie-lines, but... * * The STIC can only "see" 23 bits of address (2da), and only if you form * the polling address such that some bits get shift up into the * STIC's <18:23> & <27:28>, since they're tied to <15:20> & <21:22> * on the bus. This means the packet buffers must be in the 1st * 8MB of physical memory. */#define _0to14 (0x00007fff) /* bits 00-14 set */#define _0to23 (0x00ffffff) /* bits 00-23 set */#define _2to21 (0x003ffffc) /* bits 02-21 set */#define _6to8 (0x000001c0) /* bits 00-08 set */#define _11to28 (0x1ffff800) /* bits 11-28 set */#define _15to17 (0x00038000) /* bits 15-17 set */#define _15to20 (0x001f8000) /* bits 15-20 set */#define _18to23 (0x00fc0000) /* bits 18-23 set */#define _18to28 (0x1ffc0000) /* bits 18-28 set */#define _21to22 (0x00600000) /* bits 21-22 set */#define _24to28 (0x1f000000) /* bits 24-28 set */#define _27to28 (0x18000000) /* bits 27-28 set *//* convert a system physical address to a STIC space physical address */#define GX_SYS2STIC(A) ((((A)&_21to22)<<6)|(((A)&_15to20)<<3)|((A)&_0to14))#define GX_SYS_TO_STIC(A) GX_SYS2STIC(((u_long)(A)))/* convert a STIC space physical address to a system physical address */#define GX_STIC2SYS(A) ((((A)&_27to28)>>6)|(((A)&_18to23)>>3)|((A)&_0to14))#define GX_STIC_TO_SYS(A) GX_STIC2SYS(((u_long)(A)))/* convert a system physical address to STIC DMA encoding - architecture spec */#define GX_PHYS_TO_DMA(A) ((((u_long)(A)) & _11to28) >> 9)/* convert a system physical address to a DMA encoding - implementation spec */#define GX_SYS2DMA(A) ( (((A)&~_0to14)<<3) | ((A)&_0to14) )#define GX_SYS_TO_DMA(A) GX_PHYS_TO_DMA(GX_SYS2DMA(((u_long)(A))))/* * Bt459 VDAC * <C1:C0> control selection of registers. VDAC sits on the I/O bus, * so can read/write to it in the unusual way. */typedef struct _bt459_regs { int addr_lo; /* +0x00 <~c1,~c0> */ int addr_hi; /* +0x04 <~c1, c0> */ int data; /* +0x08 < c1,~c0> */ int cmap; /* +0x0c < c1, c0> */} bt459Regs;#define BT459_regs bt459Regs#define VDAC_RDAT (*vdac_data & gx_planemask)#define _DUPBYTE0(X) \ (((((int)(X))<<16)&0xff0000)|((((int)(X))<<8)&0xff00)|(((int)(X))&0xff))#define _DUPBYTE1(X) \ (((((int)(X))<<8)&0xff0000)|(((int)(X))&0xff00)|((((int)(X))>>8)&0xff))#define _DUPBYTE2(X) \ ((((int)(X))&0xff0000)|((((int)(X))>>8)&0xff00)|((((int)(X))>>16)&0xff))/* * 2 bytes of BT459 internal address. */#define BT459_PIX_COLOR 0x0000 /* pixel color map */#define BT459_OVRLY_COLOR0 0x0100 /* overlay color 0 of 16 */#define BT459_CUR_COLOR1 0x0181 /* rgb: cursor color 1 */#define BT459_CUR_COLOR2 0x0182 /* rgb */#define BT459_CUR_COLOR3 0x0183 /* rgb */#define BT459_ID_REG 0x0200 /* should be 0x4a */#define BT459_CMD_0 0x0201 /* command reg 0 */#define BT459_CMD_1 0x0202 /* */#define BT459_CMD_2 0x0203 /* */#define BT459_PIX_RMASK 0x0204 /* pixel read mask */#define BT459_PIX_BMASK 0x0205 /* pixel blink mask */#define BT459_INTERL_REG 0x020a /* interleave reg */#define BT459_TEST_REG 0x020b /* */#define BT459_SIG_RED 0x020c /* signature reg's */#define BT459_SIG_GREEN 0x020d /* */#define BT459_SIG_BLUE 0x020e /* */#define BT459_CUR_CMD 0x0300 /* cursor command reg */#define BT459_CUR_XLO 0x0301 /* cursor x(lo) */#define BT459_CUR_XHI 0x0302 /* */#define BT459_CUR_YLO 0x0303 /* cursor y(lo) */#define BT459_CUR_YHI 0x0304 /* */#define BT459_WIN_XLO 0x0305 /* window x(lo) */#define BT459_WIN_XHI 0x0306 /* */#define BT459_WIN_YLO 0x0307 /* window y(lo) */#define BT459_WIN_YHI 0x0308 /* */#define BT459_WIN_WLO 0x0309 /* window width(lo) */#define BT459_WIN_WHI 0x030a /* */#define BT459_WIN_HLO 0x030b /* window height(lo) */#define BT459_WIN_HHI 0x030c /* */#define BT459_CUR_RAM 0x0400 /* cursor bitmap: to 0x7ff */#define BT459_MAXERR 10#define BT459_CURH 64#define BT459_CURW 64#define BT459_CURSORBYTES (BT459_CURH*BT459_CURW/4)#define BT459_MAXX 1279#define BT459_MAXY 1023#define BT459_X 31#define BT459_Y 31#define BT459_CURMAXX (BT459_MAXX+BT459_X)#define BT459_CURMAXY (BT459_MAXY+BT459_Y)#define BT459_CURMINX (1-BT459_CURW)#define BT459_CURMINY (1-BT459_CURH)#define BT459_H (370-BT459_X) /* Sony timings in STIC */#define BT459_V (37-BT459_Y) /* ditto */#define BT459_OFFX (0)#define BT459_OFFY (1500)#define BT459_SETLOADDR(V,A) ((bt459Regs *)V)->addr_lo = _DUPBYTE0(A);\ wbflush()#define BT459_SETHIADDR(V,A) ((bt459Regs *)V)->addr_hi = _DUPBYTE1(A);\ wbflush()#define BT459_SETADDR(V,A) ((bt459Regs *)V)->addr_hi = _DUPBYTE1(A);\ BT459_SETLOADDR(V,A)#define GX_CURW 64 /* cursor width in bits */#define GX_CURH 64 /* cursor height ditto */#define GX_CURX 0 /* cursor pos relative to upper */#define GX_CURY 0 /* left of cursor block */#define GX_CURMAXX (BT459_MAXX)#define GX_CURMAXY (BT459_MAXY)#define GX_CURMINX (1-GX_CURW)#define GX_CURMINY (1-GX_CURH)#define GX_CURSORBYTES (GX_CURH * GX_CURW/4)#define GX_POS_CUR(X,Y) gx_pos_cur((X)+1,(Y)+_TEXT_HEIGHT-4)#define GX_CURBEG BT459_CUR_RAM#define GX_CUREND (GX_CURBEG+(0x010*GX_CURH))typedef struct gx_info { pmEventQueue qe; /* event & motion queues */ short mswitches; /* current value of mouse buttons */ pmCursor tablet; /* current tablet position */ short tswitches; /* current tablet buttons NI! */ pmCursor cursor; /* current cursor position */ short row; /* screen row */ short col; /* screen col */ short max_row; /* max character row */ short max_col; /* max character col */ short max_x; /* max x position */ short max_y; /* max y position */ short max_cur_x; /* max cursor x position */ short max_cur_y; /* max cursor y position */ int version; /* version of driver */#define GX_F_NEW_CMAP 0x40000000 /* plz update VDAC colormap */#define GX_F_VIDEO_ON 0x10000000 /* screen saver disabled */#define GX_F_CMAP_LEN 0x000000ff /* # entries updatable / vsync */ int flags; /* sync flags */ int *gram; /* SRAM on graphics board */ int *rb_addr; /* ring buffer vaddr */ int rb_phys; /* ring buffer phys addr */ int rb_size; /* ring buffer char length */ pmCursor mouse; /* atomic read/write */ pmBox mbox; /* atomic read/write */ short mthreshold; /* mouse motion parameter */ short mscale; /* mouse scale factor (if negative, then do square). */ short min_cur_x; /* min cursor x position */ short min_cur_y; /* min cursor y position */ char *gxo; /* board base addr */ char stamp_width; char stamp_height; char nplanes; /* primary buffer */ char n10_present; /* geometry accelerator */ char dplanes; /* double buffer */ char zplanes; /* Z buffer */ char zzplanes; /* extra buffer - high-end only */ u_char curs_bits[GX_CURSORBYTES]; int curs_fg; /* fg rgb */ int curs_bg; /* bg rgb */ u_short cmap_index; /* start CMAP update here */ u_short cmap_count; /* update this # of CMAP entries*/ int colormap[256]; /* 2D - r3000 polls stic */ int *stic_dma_rb; /* STIC polling register */ int *stic_reg; /* STIC control registers */ /* (may not be mapped) */ /* 3D - co-processor support (not mapped to user) */ int ptpt_phys; /* phys addr: ptpt */ int ptpt_size; /* sizeof(ptpt) in entries */ int * ptpt_pgin; /* request (server) pagein */ /* helpful info for (3D) performance tuning (8 words alloc'd) */ u_int host_idle; /* time in cpu[0] idle state */ u_int host_idleCount; /* (see cpudata.h) */ int endpad[6];} gxInfo;#define GX_info gxInfotypedef struct gx_infos { int pid; /* last pid using this entry */ gxInfo *shmat; /* where attached */ gxInfo info; /* the stuff... */} gxInfos;/* * These need to be mapped into user space. I've glumped these * together to save on resources, etc. There's too many of these * little rinky-dink things... * * The 'ringbufferoffset' field is defined to be the offset in ints * (i.e. 32-bit quantities) from the start of gxPriv to the ring * buffer. In the 2DA, this may be some distance from tcs because * of alignment restrictions. * * WARNING: do *not* change gxPriv without also consulting ga.c:ga_dummy(). */#ifdef GX_MULTIOPEN# define GX_MAX_INFOS (8)#else# define GX_MAX_INFOS (1)# define gx_info_get(N) (0)#endif#define GX_ERR_NOOP -1#define GX_ERR_NONE 0#define GX_ERR_PRIV 1#define GX_ERR_GQO 2#define GX_ERR_GAO 3#define GX_ERR_POLL 4#define GX_ERR_STIC 5#define GX_ERR_SRAM 6typedef struct gx_priv { gxInfos infos[GX_MAX_INFOS]; pmEvent events[PMMAXEVQ]; pmTimeCoord tcs[MOTION_BUFFER_SIZE]; int ringbufferoffset; /* in ints, not bytes */} gxPriv;#define gx_events gx_priv->events#define gx_tcs gx_priv->tcs#define gx_cursor gxp->curs_bits#define gx_colormap gxp->colormap#define gx_rboffset gx_priv->ringbufferoffset#define gx_ringbuffer ((int *)gx_priv + gx_rboffset)#define gx_infos gx_priv->infos#define gx_server gx_infos[0]#define gx_info gx_server.infotypedef struct gx_kpcmd { char nbytes; /* number of bytes in parameter */ unsigned char cmd; /* command to be sent, peripheral bit will */ /* be forced by driver */ unsigned char par[2]; /* bytes of parameters to be sent */} gxKPCmd;#define GX_kpcmd gxKPCmd/* * Keyboard state structure */typedef struct gx_keyboard { int shift; /* state variables */ int cntrl; int lock; int hold; char last; /* last character */} gxKeyboard;typedef struct _MyColorMap { short Map; unsigned short index; struct { unsigned short red; unsigned short green; unsigned short blue; } Entry;} MyColorMap;/* * CAUTION: * The numbers of these ioctls must match * the ioctls in qvioctl.h */#define QIOCGINFO _IOR('q', 1, gxInfo *) /* get the info */#define QIOCGXSTATE _IOW('q', 2, pmCursor) /* set mouse pos */#define QIOWCURSORCOLOR _IOW('q', 3, unsigned int[6]) /* bg/fg r/g/b */#define QIOCINIT _IO('q', 4) /* init screen */#define QIOCKPCMD _IOW('q', 5, gxKPCmd) /* keybd. per. cmd */#define QIOCADDR _IOR('q', 6, gxInfo *) /* get phys address */#define QIOWCURSOR _IOW('q', 7, short[32])#define QIOKERNLOOP _IO('q', 8) /* re-route kernel console output */#define QIOKERNUNLOOP _IO('q', 9) /* dont re-rte kernel console output */#define QIOVIDEOON _IO('q', 10) /* turn on the video */#define QIOVIDEOOFF _IO('q', 11) /* turn off the video */#define QIOSETCMAP _IOW('q', 12, MyColorMap)#define QIOWLCURSOR _IOW('q', 13, char[1024]) /* 3MAX/CFB 64x64 cursor */#define QIO_WCCOLOR _IO('q', 14) /* 3MAX/nDA cursor colors */#define QIO_WCURSOR _IO('q', 15) /* 3MAX/nDA cursor */#define QIO_SETCMAP _IO('q', 16) /* 3MAX/nDA colormap */#define QIO_N10RESET _IO('q', 17) /* 3MAX/3DA halt N10 */#define QIO_N10START _IO('q', 18) /* 3MAX/3DA start N10 */#define QIO_N10INTR _IOWR('q', 19, int) /* 3MAX/3DA intr N10 */#define QD_KERN_UNLOOP _IO('g', 21) /* RESERVED for DIGITAL, DON'T CHANGE */#endif _gx_h_
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -