cgsixreg.h 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336
  1. /* $OpenBSD: cgsixreg.h,v 1.9 2006/06/02 20:00:56 miod Exp $ */
  2. /*
  3. * Copyright (c) 2002 Jason L. Wright (jason@thought.net)
  4. * All rights reserved.
  5. *
  6. * Redistribution and use in source and binary forms, with or without
  7. * modification, are permitted provided that the following conditions
  8. * are met:
  9. * 1. Redistributions of source code must retain the above copyright
  10. * notice, this list of conditions and the following disclaimer.
  11. * 2. Redistributions in binary form must reproduce the above copyright
  12. * notice, this list of conditions and the following disclaimer in the
  13. * documentation and/or other materials provided with the distribution.
  14. *
  15. * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
  16. * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  17. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  18. * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
  19. * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  20. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  21. * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  22. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
  23. * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
  24. * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  25. * POSSIBILITY OF SUCH DAMAGE.
  26. */
  27. union bt_cmap {
  28. u_int8_t cm_map[256][3]; /* 256 r/b/g entries */
  29. u_int32_t cm_chip[256 * 3 / 4]; /* the way the chip is loaded */
  30. };
  31. #define BT_ADDR 0x00 /* map address register */
  32. #define BT_CMAP 0x04 /* colormap data register */
  33. #define BT_CTRL 0x08 /* control register */
  34. #define BT_OMAP 0x0c /* overlay (cursor) map register */
  35. #define BT_D4M3(x) ((((x) >> 2) << 1) + ((x) >> 2)) /* (x / 4) * 3 */
  36. #define BT_D4M4(x) ((x) & ~3) /* (x / 4) * 4 */
  37. #define CGSIX_ROM_OFFSET 0x000000
  38. #define CGSIX_BT_OFFSET 0x200000
  39. #define CGSIX_BT_SIZE (sizeof(u_int32_t) * 4)
  40. #define CGSIX_DHC_OFFSET 0x240000
  41. #define CGSIX_ALT_OFFSET 0x280000
  42. #define CGSIX_FHC_OFFSET 0x300000
  43. #define CGSIX_FHC_SIZE (sizeof(u_int32_t) * 1)
  44. #define CGSIX_THC_OFFSET 0x301000
  45. #define CGSIX_THC_SIZE (sizeof(u_int32_t) * 640)
  46. #define CGSIX_FBC_OFFSET 0x700000
  47. #define CGSIX_FBC_SIZE 0x1000
  48. #define CGSIX_TEC_OFFSET 0x701000
  49. #define CGSIX_TEC_SIZE (sizeof(u_int32_t) * 3)
  50. #define CGSIX_VID_OFFSET 0x800000
  51. #define CGSIX_VID_SIZE (1024 * 1024)
  52. #define CG6_FHC 0x0 /* fhc register */
  53. #define FHC_FBID_MASK 0xff000000 /* frame buffer id */
  54. #define FHC_FBID_SHIFT 24
  55. #define FHC_REV_MASK 0x00f00000 /* revision */
  56. #define FHC_REV_SHIFT 20
  57. #define FHC_FROP_DISABLE 0x00080000 /* disable fast rasterop */
  58. #define FHC_ROW_DISABLE 0x00040000 /* ??? */
  59. #define FHC_SRC_DISABLE 0x00020000 /* ??? */
  60. #define FHC_DST_DISABLE 0x00010000 /* disable dst cache */
  61. #define FHC_RESET 0x00008000 /* ??? */
  62. #define FHC_LEBO 0x00002000 /* set little endian order */
  63. #define FHC_RES_MASK 0x00001800 /* resolution: */
  64. #define FHC_RES_1024 0x00000000 /* 1024x768 */
  65. #define FHC_RES_1152 0x00000800 /* 1152x900 */
  66. #define FHC_RES_1280 0x00001000 /* 1280x1024 */
  67. #define FHC_RES_1600 0x00001800 /* 1600x1200 */
  68. #define FHC_CPU_MASK 0x00000600 /* cpu type: */
  69. #define FHC_CPU_SPARC 0x00000000 /* sparc */
  70. #define FHC_CPU_68020 0x00000200 /* 68020 */
  71. #define FHC_CPU_386 0x00000400 /* i386 */
  72. #define FHC_TEST 0x00000100 /* test window */
  73. #define FHC_TESTX_MASK 0x000000f0 /* test window X */
  74. #define FHC_TESTX_SHIFT 4
  75. #define FHC_TESTY_MASK 0x0000000f /* test window Y */
  76. #define FHC_TESTY_SHIFT 0
  77. #define CG6_FBC_MODE 0x004 /* mode setting */
  78. #define CG6_FBC_CLIP 0x008 /* ??? */
  79. #define CG6_FBC_S 0x010 /* global status */
  80. #define CG6_FBC_DRAW 0x014 /* drawing pipeline status */
  81. #define CG6_FBC_BLIT 0x018 /* blitter status */
  82. #define CG6_FBC_FONT 0x01c /* font */
  83. #define CG6_FBC_X0 0x080 /* blitter, src llx */
  84. #define CG6_FBC_Y0 0x084 /* blitter, src lly */
  85. #define CG6_FBC_Z0 0x088 /* blitter, src llz */
  86. #define CB6_FBC_C0 0x08c /* blitter, src llcolor */
  87. #define CG6_FBC_X1 0x090 /* blitter, src urx */
  88. #define CG6_FBC_Y1 0x094 /* blitter, src ury */
  89. #define CG6_FBC_Z1 0x098 /* blitter, src urz */
  90. #define CB6_FBC_C1 0x09c /* blitter, src urcolor */
  91. #define CG6_FBC_X2 0x0a0 /* blitter, dst llx */
  92. #define CG6_FBC_Y2 0x0a4 /* blitter, dst lly */
  93. #define CG6_FBC_Z2 0x0a8 /* blitter, dst llz */
  94. #define CB6_FBC_C2 0x0ac /* blitter, dst llcolor */
  95. #define CG6_FBC_X3 0x0b0 /* blitter, dst urx */
  96. #define CG6_FBC_Y3 0x0b4 /* blitter, dst ury */
  97. #define CG6_FBC_Z3 0x0b8 /* blitter, dst urz */
  98. #define CB6_FBC_C3 0x0bc /* blitter, dst urcolor */
  99. #define CG6_FBC_OFFX 0x0c0 /* x offset for drawing */
  100. #define CG6_FBC_OFFY 0x0c4 /* y offset for drawing */
  101. #define CG6_FBC_INCX 0x0d0 /* x increment */
  102. #define CG6_FBC_INCY 0x0d4 /* y increment */
  103. #define CG6_FBC_CLIPMINX 0x0e0 /* clip rectangle llx */
  104. #define CG6_FBC_CLIPMINY 0x0e4 /* clip rectangle lly */
  105. #define CG6_FBC_CLIPMAXX 0x0f0 /* clip rectangle urx */
  106. #define CG6_FBC_CLIPMAXY 0x0f4 /* clip rectangle ury */
  107. #define CG6_FBC_FG 0x100 /* fg value for rop */
  108. #define CG6_FBC_BG 0x104 /* bg value for rop */
  109. #define CG6_FBC_ALU 0x108 /* operation */
  110. #define CG6_FBC_PM 0x10c /* */
  111. #define CG6_FBC_PIXELM 0x110 /* */
  112. #define CG6_FBC_PATALIGN 0x11c /* */
  113. #define CG6_FBC_PATTERN 0x120 /* 8 u_int32_t pattern */
  114. #define CG6_FBC_APOINTX 0x800 /* */
  115. #define CG6_FBC_APOINTY 0x804 /* */
  116. #define CG6_FBC_APOINTZ 0x808 /* */
  117. #define CG6_FBC_RPOINTX 0x810 /* */
  118. #define CG6_FBC_RPOINTY 0x814 /* */
  119. #define CG6_FBC_RPOINTZ 0x818 /* */
  120. #define CG6_FBC_POINTR 0x830 /* */
  121. #define CG6_FBC_POINTG 0x834 /* */
  122. #define CG6_FBC_POINTB 0x838 /* */
  123. #define CG6_FBC_POINTA 0x83c /* */
  124. #define CG6_FBC_ALINEX 0x840 /* */
  125. #define CG6_FBC_ALINEY 0x844 /* */
  126. #define CG6_FBC_ALINEZ 0x848 /* */
  127. #define CG6_FBC_RLINEX 0x850 /* */
  128. #define CG6_FBC_RLINEY 0x854 /* */
  129. #define CG6_FBC_RLINEZ 0x858 /* */
  130. #define CG6_FBC_LINER 0x870 /* */
  131. #define CG6_FBC_LINEG 0x874 /* */
  132. #define CG6_FBC_LINEB 0x878 /* */
  133. #define CG6_FBC_LINEA 0x87c /* */
  134. #define CG6_FBC_ATRIX 0x880 /* */
  135. #define CG6_FBC_ATRIY 0x884 /* */
  136. #define CG6_FBC_ATRIZ 0x888 /* */
  137. #define CG6_FBC_RTRIX 0x890 /* */
  138. #define CG6_FBC_RTRIY 0x894 /* */
  139. #define CG6_FBC_RTRIZ 0x898 /* */
  140. #define CG6_FBC_TRIR 0x8b0 /* */
  141. #define CG6_FBC_TRIG 0x8b4 /* */
  142. #define CG6_FBC_TRIB 0x8b8 /* */
  143. #define CG6_FBC_TRIA 0x8bc /* */
  144. #define CG6_FBC_AQUADX 0x8c0 /* */
  145. #define CG6_FBC_AQUADY 0x8c4 /* */
  146. #define CG6_FBC_AQUADZ 0x8c8 /* */
  147. #define CG6_FBC_RQUADX 0x8d0 /* */
  148. #define CG6_FBC_RQUADY 0x8d4 /* */
  149. #define CG6_FBC_RQUADZ 0x8d8 /* */
  150. #define CG6_FBC_QUADR 0x8f0 /* */
  151. #define CG6_FBC_QUADG 0x8f4 /* */
  152. #define CG6_FBC_QUADB 0x8f8 /* */
  153. #define CG6_FBC_QUADA 0x8fc /* */
  154. #define CG6_FBC_ARECTX 0x900 /* rectangle drawing, x coord */
  155. #define CG6_FBC_ARECTY 0x904 /* rectangle drawing, y coord */
  156. #define CG6_FBC_ARECTZ 0x908 /* rectangle drawing, z coord */
  157. #define CG6_FBC_RRECTX 0x910 /* */
  158. #define CG6_FBC_RRECTY 0x914 /* */
  159. #define CG6_FBC_RRECTZ 0x918 /* */
  160. #define CG6_FBC_RRECTR 0x930 /* */
  161. #define CG6_FBC_RRECTG 0x934 /* */
  162. #define CG6_FBC_RRECTB 0x938 /* */
  163. #define CG6_FBC_RRECTA 0x938 /* */
  164. #define FBC_MODE_VAL ( \
  165. 0x00200000 /* GX_BLIT_SRC */ \
  166. | 0x00020000 /* GX_MODE_COLOR8 */ \
  167. | 0x00008000 /* GX_DRAW_RENDER */ \
  168. | 0x00002000 /* GX_BWRITE0_ENABLE */ \
  169. | 0x00001000 /* GX_BWRITE1_DISABLE */ \
  170. | 0x00000200 /* GX_BREAD_0 */ \
  171. | 0x00000080 /* GX_BDISP_0 */ \
  172. )
  173. #define FBC_MODE_MASK ( \
  174. 0x00300000 /* GX_BLIT_ALL */ \
  175. | 0x00060000 /* GX_MODE_ALL */ \
  176. | 0x00018000 /* GX_DRAW_ALL */ \
  177. | 0x00006000 /* GX_BWRITE0_ALL */ \
  178. | 0x00001800 /* GX_BWRITE1_ALL */ \
  179. | 0x00000600 /* GX_BREAD_ALL */ \
  180. | 0x00000180 /* GX_BDISP_ALL */ \
  181. )
  182. #define FBC_S_GXINPROGRESS 0x10000000 /* drawing in progress */
  183. #define FBC_BLIT_UNKNOWN 0x80000000 /* ??? */
  184. #define FBC_BLIT_GXFULL 0x20000000 /* queue is full */
  185. #define FBC_DRAW_UNKNOWN 0x80000000 /* ??? */
  186. #define FBC_DRAW_GXFULL 0x20000000
  187. /* Value for the alu register for screen-to-screen copies */
  188. #define FBC_ALU_COPY ( \
  189. 0x80000000 /* GX_PLANE_ONES (ignore planemask register) */ \
  190. | 0x20000000 /* GX_PIXEL_ONES (ignore pixelmask register) */ \
  191. | 0x00800000 /* GX_ATTR_SUPP (function unknown) */ \
  192. | 0x00000000 /* GX_RAST_BOOL (function unknown) */ \
  193. | 0x00000000 /* GX_PLOT_PLOT (function unknown) */ \
  194. | 0x08000000 /* GX_PATTERN_ONES (ignore pattern) */ \
  195. | 0x01000000 /* GX_POLYG_OVERLAP (unsure - handle overlap?) */ \
  196. | 0x0000cccc /* ALU = src */ \
  197. )
  198. /* Value for the alu register for region fills */
  199. #define FBC_ALU_FILL ( \
  200. 0x80000000 /* GX_PLANE_ONES (ignore planemask register) */ \
  201. | 0x20000000 /* GX_PIXEL_ONES (ignore pixelmask register) */ \
  202. | 0x00800000 /* GX_ATTR_SUPP (function unknown) */ \
  203. | 0x00000000 /* GX_RAST_BOOL (function unknown) */ \
  204. | 0x00000000 /* GX_PLOT_PLOT (function unknown) */ \
  205. | 0x08000000 /* GX_PATTERN_ONES (ignore pattern) */ \
  206. | 0x01000000 /* GX_POLYG_OVERLAP (unsure - handle overlap?) */ \
  207. | 0x0000ff00 /* ALU = fg color */ \
  208. )
  209. /* Value for the alu register for toggling an area */
  210. #define FBC_ALU_FLIP ( \
  211. 0x80000000 /* GX_PLANE_ONES (ignore planemask register) */ \
  212. | 0x20000000 /* GX_PIXEL_ONES (ignore pixelmask register) */ \
  213. | 0x00800000 /* GX_ATTR_SUPP (function unknown) */ \
  214. | 0x00000000 /* GX_RAST_BOOL (function unknown) */ \
  215. | 0x00000000 /* GX_PLOT_PLOT (function unknown) */ \
  216. | 0x08000000 /* GX_PATTERN_ONES (ignore pattern) */ \
  217. | 0x01000000 /* GX_POLYG_OVERLAP (unsure - handle overlap?) */ \
  218. | 0x00005555 /* ALU = ~dst */ \
  219. )
  220. #define CG6_TEC_MV 0x0 /* matrix stuff */
  221. #define CG6_TEC_CLIP 0x4 /* clipping stuff */
  222. #define CG6_TEC_VDC 0x8 /* ??? */
  223. #define CG6_THC_HSYNC1 0x800 /* horizontal sync timing */
  224. #define CG6_THC_HSYNC2 0x804 /* more hsync timing */
  225. #define CG6_THC_HSYNC3 0x808 /* yet more hsync timing */
  226. #define CG6_THC_VSYNC1 0x80c /* vertical sync timing */
  227. #define CG6_THC_VSYNC2 0x810 /* only two of these */
  228. #define CG6_THC_REFRESH 0x814 /* refresh counter */
  229. #define CG6_THC_MISC 0x818 /* misc control/status */
  230. #define CG6_THC_CURSXY 0x8fc /* cursor x/y, 16 bit each */
  231. #define CG6_THC_CURSMASK 0x900 /* cursor mask bits */
  232. #define CG6_THC_CURSBITS 0x980 /* cursor bits */
  233. /* cursor x/y position for 'off' */
  234. #define THC_CURSOFF ((65536-32) | ((65536-32) << 16))
  235. #define THC_MISC_REV_M 0x000f0000 /* chip revision */
  236. #define THC_MISC_REV_S 16
  237. #define THC_MISC_RESET 0x00001000 /* reset */
  238. #define THC_MISC_VIDEN 0x00000400 /* video enable */
  239. #define THC_MISC_SYNC 0x00000200 /* not sure what ... */
  240. #define THC_MISC_VSYNC 0x00000100 /* ... these really are */
  241. #define THC_MISC_SYNCEN 0x00000080 /* sync enable */
  242. #define THC_MISC_CURSRES 0x00000040 /* cursor resolution */
  243. #define THC_MISC_INTEN 0x00000020 /* v.retrace intr enable */
  244. #define THC_MISC_INTR 0x00000010 /* intr pending/ack */
  245. #define THC_MISC_CYCLS 0x0000000f /* cycles before transfer */
  246. struct cgsix_softc {
  247. struct sunfb sc_sunfb;
  248. bus_space_tag_t sc_bustag;
  249. bus_addr_t sc_paddr;
  250. bus_space_handle_t sc_bt_regs;
  251. bus_space_handle_t sc_fhc_regs;
  252. bus_space_handle_t sc_thc_regs;
  253. bus_space_handle_t sc_tec_regs;
  254. bus_space_handle_t sc_vid_regs;
  255. bus_space_handle_t sc_fbc_regs;
  256. int sc_nscreens;
  257. union bt_cmap sc_cmap;
  258. void *sc_ih;
  259. u_int sc_mode;
  260. u_int sc_curs_enabled, sc_curs_fg, sc_curs_bg;
  261. struct wsdisplay_curpos sc_curs_pos, sc_curs_hot, sc_curs_size;
  262. u_char sc_curs_image[128], sc_curs_mask[128];
  263. };
  264. #define CG6_USER_FBC 0x70000000
  265. #define CG6_USER_TEC 0x70001000
  266. #define CG6_USER_BTREGS 0x70002000
  267. #define CG6_USER_FHC 0x70004000
  268. #define CG6_USER_THC 0x70005000
  269. #define CG6_USER_ROM 0x70006000
  270. #define CG6_USER_RAM 0x70016000
  271. #define CG6_USER_DHC 0x80000000
  272. #define THC_READ(sc,r) \
  273. bus_space_read_4((sc)->sc_bustag, (sc)->sc_thc_regs, (r))
  274. #define THC_WRITE(sc,r,v) \
  275. bus_space_write_4((sc)->sc_bustag, (sc)->sc_thc_regs, (r), (v))
  276. #define TEC_READ(sc,r) \
  277. bus_space_read_4((sc)->sc_bustag, (sc)->sc_tec_regs, (r))
  278. #define TEC_WRITE(sc,r,v) \
  279. bus_space_write_4((sc)->sc_bustag, (sc)->sc_tec_regs, (r), (v))
  280. #define FHC_READ(sc) \
  281. bus_space_read_4((sc)->sc_bustag, (sc)->sc_fhc_regs, CG6_FHC)
  282. #define FHC_WRITE(sc,v) \
  283. bus_space_write_4((sc)->sc_bustag, (sc)->sc_fhc_regs, CG6_FHC, (v))
  284. #define FBC_READ(sc,r) \
  285. bus_space_read_4((sc)->sc_bustag, (sc)->sc_fbc_regs, (r))
  286. #define FBC_WRITE(sc,r,v) \
  287. bus_space_write_4((sc)->sc_bustag, (sc)->sc_fbc_regs, (r), (v))
  288. #define BT_WRITE(sc, reg, val) \
  289. bus_space_write_4((sc)->sc_bustag, (sc)->sc_bt_regs, (reg), (val))
  290. #define BT_READ(sc, reg) \
  291. bus_space_read_4((sc)->sc_bustag, (sc)->sc_bt_regs, (reg))
  292. #define BT_BARRIER(sc,reg,flags) \
  293. bus_space_barrier((sc)->sc_bustag, (sc)->sc_bt_regs, (reg), \
  294. sizeof(u_int32_t), (flags))
  295. #define CG6_BLIT_WAIT(sc) \
  296. while ((FBC_READ(sc, CG6_FBC_BLIT) & \
  297. (FBC_BLIT_UNKNOWN|FBC_BLIT_GXFULL)) == \
  298. (FBC_BLIT_UNKNOWN|FBC_BLIT_GXFULL))
  299. #define CG6_DRAW_WAIT(sc) \
  300. while ((FBC_READ(sc, CG6_FBC_DRAW) & \
  301. (FBC_DRAW_UNKNOWN|FBC_DRAW_GXFULL)) == \
  302. (FBC_DRAW_UNKNOWN|FBC_DRAW_GXFULL))
  303. #define CG6_DRAIN(sc) \
  304. while (FBC_READ(sc, CG6_FBC_S) & FBC_S_GXINPROGRESS)
  305. #define CG6_MAX_CURSOR 32
  306. #define CG6_CFFLAG_NOACCEL 0x1 /* disable console acceleration */