4 /* generic STI structures & functions */
7 #define DPRINTK(x) printk x
12 #define MAX_STI_ROMS 4 /* max no. of ROMs which this driver handles */
14 #define STI_REGION_MAX 8 /* hardcoded STI constants */
15 #define STI_DEV_NAME_LENGTH 32
16 #define STI_MONITOR_MAX 256
18 #define STI_FONT_HPROMAN8 1
19 #define STI_FONT_KANA8 2
21 /* The latency of the STI functions cannot really be reduced by setting
22 * this to 0; STI doesn't seem to be designed to allow calling a different
23 * function (or the same function with different arguments) after a
24 * function exited with 1 as return value.
26 * As all of the functions below could be called from interrupt context,
27 * we have to spin_lock_irqsave around the do { ret = bla(); } while(ret==1)
28 * block. Really bad latency there.
30 * Probably the best solution to all this is have the generic code manage
31 * the screen buffer and a kernel thread to call STI occasionally.
33 * Luckily, the frame buffer guys have the same problem so we can just wait
34 * for them to fix it and steal their solution. prumpf
39 #include <asm/io.h> /* for USE_HPPA_IOREMAP */
43 #define STI_PTR(p) (p)
44 #define PTR_STI(p) (p)
45 static int inline STI_CALL( unsigned long func,
46 void *flags, void *inptr, void *outptr, void *glob_cfg )
48 int (*f)(void *,void *,void *,void *);
50 return f(flags, inptr, outptr, glob_cfg);
53 #else /* !USE_HPPA_IOREMAP */
55 #define STI_PTR(p) ( virt_to_phys(p) )
56 #define PTR_STI(p) ( phys_to_virt((long)p) )
57 #define STI_CALL(func, flags, inptr, outptr, glob_cfg) \
59 pdc_sti_call( func, (unsigned long)STI_PTR(flags), \
60 (unsigned long)STI_PTR(inptr), \
61 (unsigned long)STI_PTR(outptr), \
62 (unsigned long)STI_PTR(glob_cfg)); \
65 #endif /* USE_HPPA_IOREMAP */
68 #define sti_onscreen_x(sti) (sti->glob_cfg->onscreen_x)
69 #define sti_onscreen_y(sti) (sti->glob_cfg->onscreen_y)
71 /* sti_font_xy() use the native font ROM ! */
72 #define sti_font_x(sti) (PTR_STI(sti->font)->width)
73 #define sti_font_y(sti) (PTR_STI(sti->font)->height)
76 #define offsetof(TYPE, MEMBER) ((unsigned long) &((TYPE *)0)->MEMBER)
79 extern struct sti_struct *sti_init_roms(void);
81 /* XXX: this probably should not be here, but we rely on STI being
82 initialized early and independently of stifb at the moment, so
83 there's no other way for stifb to find it. */
84 extern struct sti_struct *default_sti;
87 int sti_init_graph(struct sti_struct *sti);
88 void sti_inq_conf(struct sti_struct *sti);
89 void sti_putc(struct sti_struct *sti, int c, int y, int x);
90 void sti_set(struct sti_struct *sti, int src_y, int src_x,
91 int height, int width, u8 color);
92 void sti_clear(struct sti_struct *sti, int src_y, int src_x,
93 int height, int width, int c);
94 void sti_bmove(struct sti_struct *sti, int src_y, int src_x,
95 int dst_y, int dst_x, int height, int width);
98 /* STI function configuration structs */
100 typedef union region {
102 u32 offset : 14; /* offset in 4kbyte page */
103 u32 sys_only : 1; /* don't map to user space */
104 u32 cache : 1; /* map to data cache */
105 u32 btlb : 1; /* map to block tlb */
106 u32 last : 1; /* last region in list */
107 u32 length : 14; /* length in 4kbyte page */
110 u32 region; /* complete region value */
113 #define REGION_OFFSET_TO_PHYS( rt, hpa ) \
114 (((rt).region_desc.offset << 12) + (hpa))
116 struct sti_glob_cfg_ext {
117 u8 curr_mon; /* current monitor configured */
118 u8 friendly_boot; /* in friendly boot mode */
119 s16 power; /* power calculation (in Watts) */
120 s32 freq_ref; /* frequency refrence */
121 u32 sti_mem_addr; /* pointer to global sti memory (size=sti_mem_request) */
122 u32 future_ptr; /* pointer to future data */
125 struct sti_glob_cfg {
126 s32 text_planes; /* number of planes used for text */
127 s16 onscreen_x; /* screen width in pixels */
128 s16 onscreen_y; /* screen height in pixels */
129 s16 offscreen_x; /* offset width in pixels */
130 s16 offscreen_y; /* offset height in pixels */
131 s16 total_x; /* frame buffer width in pixels */
132 s16 total_y; /* frame buffer height in pixels */
133 u32 region_ptrs[STI_REGION_MAX]; /* region pointers */
134 s32 reent_lvl; /* storage for reentry level value */
135 u32 save_addr; /* where to save or restore reentrant state */
136 u32 ext_ptr; /* pointer to extended glob_cfg data structure */
140 /* STI init function structs */
142 struct sti_init_flags {
143 u32 wait : 1; /* should routine idle wait or not */
144 u32 reset : 1; /* hard reset the device? */
145 u32 text : 1; /* turn on text display planes? */
146 u32 nontext : 1; /* turn on non-text display planes? */
147 u32 clear : 1; /* clear text display planes? */
148 u32 cmap_blk : 1; /* non-text planes cmap black? */
149 u32 enable_be_timer : 1; /* enable bus error timer */
150 u32 enable_be_int : 1; /* enable bus error timer interrupt */
151 u32 no_chg_tx : 1; /* don't change text settings */
152 u32 no_chg_ntx : 1; /* don't change non-text settings */
153 u32 no_chg_bet : 1; /* don't change berr timer settings */
154 u32 no_chg_bei : 1; /* don't change berr int settings */
155 u32 init_cmap_tx : 1; /* initialize cmap for text planes */
156 u32 cmt_chg : 1; /* change current monitor type */
157 u32 retain_ie : 1; /* don't allow reset to clear int enables */
158 u32 caller_bootrom : 1; /* set only by bootrom for each call */
159 u32 caller_kernel : 1; /* set only by kernel for each call */
160 u32 caller_other : 1; /* set only by non-[BR/K] caller */
161 u32 pad : 14; /* pad to word boundary */
162 u32 future_ptr; /* pointer to future data */
165 struct sti_init_inptr_ext {
166 u8 config_mon_type; /* configure to monitor type */
167 u8 pad[1]; /* pad to word boundary */
168 u16 inflight_data; /* inflight data possible on PCI */
169 u32 future_ptr; /* pointer to future data */
172 struct sti_init_inptr {
173 s32 text_planes; /* number of planes to use for text */
174 u32 ext_ptr; /* pointer to extended init_graph inptr data structure*/
178 struct sti_init_outptr {
179 s32 errno; /* error number on failure */
180 s32 text_planes; /* number of planes used for text */
181 u32 future_ptr; /* pointer to future data */
186 /* STI configuration function structs */
188 struct sti_conf_flags {
189 u32 wait : 1; /* should routine idle wait or not */
190 u32 pad : 31; /* pad to word boundary */
191 u32 future_ptr; /* pointer to future data */
194 struct sti_conf_inptr {
195 u32 future_ptr; /* pointer to future data */
198 struct sti_conf_outptr_ext {
199 u32 crt_config[3]; /* hardware specific X11/OGL information */
204 struct sti_conf_outptr {
205 s32 errno; /* error number on failure */
206 s16 onscreen_x; /* screen width in pixels */
207 s16 onscreen_y; /* screen height in pixels */
208 s16 offscreen_x; /* offscreen width in pixels */
209 s16 offscreen_y; /* offscreen height in pixels */
210 s16 total_x; /* frame buffer width in pixels */
211 s16 total_y; /* frame buffer height in pixels */
212 s32 bits_per_pixel; /* bits/pixel device has configured */
213 s32 bits_used; /* bits which can be accessed */
214 s32 planes; /* number of fb planes in system */
215 u8 dev_name[STI_DEV_NAME_LENGTH]; /* null terminated product name */
216 u32 attributes; /* flags denoting attributes */
217 u32 ext_ptr; /* pointer to future data */
264 u32 set_cm_entry_addr;
265 u32 image_unpack_addr;
266 u32 pa_risx_addrs[7];
269 struct sti_rom_font {
274 u8 font_type; /* language type */
282 /* sticore internal font handling */
284 struct sti_cooked_font {
285 struct sti_rom_font *raw;
286 struct sti_cooked_font *next_font;
289 struct sti_cooked_rom {
291 struct sti_cooked_font *font_start;
294 /* STI font printing function structs */
296 struct sti_font_inptr {
297 u32 font_start_addr; /* address of font start */
298 s16 index; /* index into font table of character */
299 u8 fg_color; /* foreground color of character */
300 u8 bg_color; /* background color of character */
301 s16 dest_x; /* X location of character upper left */
302 s16 dest_y; /* Y location of character upper left */
303 u32 future_ptr; /* pointer to future data */
306 struct sti_font_flags {
307 u32 wait : 1; /* should routine idle wait or not */
308 u32 non_text : 1; /* font unpack/move in non_text planes =1, text =0 */
309 u32 pad : 30; /* pad to word boundary */
310 u32 future_ptr; /* pointer to future data */
313 struct sti_font_outptr {
314 s32 errno; /* error number on failure */
315 u32 future_ptr; /* pointer to future data */
318 /* STI blockmove structs */
320 struct sti_blkmv_flags {
321 u32 wait : 1; /* should routine idle wait or not */
322 u32 color : 1; /* change color during move? */
323 u32 clear : 1; /* clear during move? */
324 u32 non_text : 1; /* block move in non_text planes =1, text =0 */
325 u32 pad : 28; /* pad to word boundary */
326 u32 future_ptr; /* pointer to future data */
329 struct sti_blkmv_inptr {
330 u8 fg_color; /* foreground color after move */
331 u8 bg_color; /* background color after move */
332 s16 src_x; /* source upper left pixel x location */
333 s16 src_y; /* source upper left pixel y location */
334 s16 dest_x; /* dest upper left pixel x location */
335 s16 dest_y; /* dest upper left pixel y location */
336 s16 width; /* block width in pixels */
337 s16 height; /* block height in pixels */
338 u32 future_ptr; /* pointer to future data */
341 struct sti_blkmv_outptr {
342 s32 errno; /* error number on failure */
343 u32 future_ptr; /* pointer to future data */
347 /* internal generic STI struct */
352 /* the following fields needs to be filled in by the word/byte routines */
355 /* char **mon_strings; */
359 struct sti_cooked_rom *rom;
361 unsigned long font_unpmv;
362 unsigned long block_move;
363 unsigned long init_graph;
364 unsigned long inq_conf;
366 /* all following fields are initialized by the generic routines */
368 region_t regions[STI_REGION_MAX];
369 unsigned long regions_phys[STI_REGION_MAX];
371 struct sti_glob_cfg *glob_cfg;
372 struct sti_cooked_font *font; /* ptr to selected font (cooked) */
374 struct sti_conf_outptr outptr; /* configuration */
375 struct sti_conf_outptr_ext outptr_ext;
377 /* PCI data structures (pg. 17ff from sti.pdf) */
379 u8 rm_entry[16]; /* pci region mapper array == pci config space offset */
384 /* helper functions */
385 struct sti_struct *sti_init_roms(void);
386 struct sti_struct *sti_get_rom(int);
387 void sti_rom_copy(unsigned long base, unsigned long count, void *dest);
388 struct sti_cooked_font *sti_select_font(struct sti_cooked_rom *rom,
389 int (*search_font_fnc) (struct sti_cooked_rom *,int,int) );
391 int sti_read_rom(int wordmode, struct sti_struct *sti,
392 unsigned long address);
395 /* FIXME: Do we have another solution for this ? */
396 #include <linux/kernel.h>
397 #include <linux/slab.h>
398 #include <asm/pgalloc.h>
399 static inline void sti_flush(unsigned long from, unsigned long len)
402 flush_kernel_dcache_range(from, len);
403 flush_icache_range(from, from+len);
406 #endif /* STICORE_H */