| 1 |
|
| 2 | #ifndef STICORE_H
|
| 3 | #define STICORE_H
|
| 4 |
|
| 5 | struct device;
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 | #define MAX_STI_ROMS 4
|
| 10 |
|
| 11 | #define STI_REGION_MAX 8
|
| 12 | #define STI_DEV_NAME_LENGTH 32
|
| 13 | #define STI_MONITOR_MAX 256
|
| 14 |
|
| 15 | #define STI_FONT_HPROMAN8 1
|
| 16 | #define STI_FONT_KANA8 2
|
| 17 |
|
| 18 | #define ALT_CODE_TYPE_UNKNOWN 0x00
|
| 19 | #define ALT_CODE_TYPE_PA_RISC_64 0x01
|
| 20 |
|
| 21 | |
| 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.
|
| 25 | *
|
| 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.
|
| 29 | *
|
| 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.
|
| 32 | *
|
| 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
|
| 35 |
|
| 36 |
|
| 37 | #include <asm/io.h>
|
| 38 |
|
| 39 | #define STI_WAIT 1
|
| 40 |
|
| 41 | #define STI_PTR(p) ( virt_to_phys(p) )
|
| 42 |
|
| 43 | #define sti_onscreen_x(sti) (sti->glob_cfg->onscreen_x)
|
| 44 | #define sti_onscreen_y(sti) (sti->glob_cfg->onscreen_y)
|
| 45 |
|
| 46 |
|
| 47 | #define sti_font_x(sti) (PTR_STI(sti->font)->width)
|
| 48 | #define sti_font_y(sti) (PTR_STI(sti->font)->height)
|
| 49 |
|
| 50 | #ifdef CONFIG_64BIT
|
| 51 | #define STI_LOWMEM (GFP_KERNEL | GFP_DMA)
|
| 52 | #else
|
| 53 | #define STI_LOWMEM (GFP_KERNEL)
|
| 54 | #endif
|
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
|
| 59 | typedef union region {
|
| 60 | struct {
|
| 61 | u32 offset : 14;
|
| 62 | u32 sys_only : 1;
|
| 63 | u32 cache : 1;
|
| 64 | u32 btlb : 1;
|
| 65 | u32 last : 1;
|
| 66 | u32 length : 14;
|
| 67 | } region_desc;
|
| 68 |
|
| 69 | u32 region;
|
| 70 | } region_t;
|
| 71 |
|
| 72 | #define REGION_OFFSET_TO_PHYS( rt, hpa ) \
|
| 73 | (((rt).region_desc.offset << 12) + (hpa))
|
| 74 |
|
| 75 | struct sti_glob_cfg_ext {
|
| 76 | u8 curr_mon;
|
| 77 | u8 friendly_boot;
|
| 78 | s16 power;
|
| 79 | s32 freq_ref;
|
| 80 | u32 *sti_mem_addr;
|
| 81 | u32 *future_ptr;
|
| 82 | };
|
| 83 |
|
| 84 | struct sti_glob_cfg {
|
| 85 | s32 text_planes;
|
| 86 | s16 onscreen_x;
|
| 87 | s16 onscreen_y;
|
| 88 | s16 offscreen_x;
|
| 89 | s16 offscreen_y;
|
| 90 | s16 total_x;
|
| 91 | s16 total_y;
|
| 92 | u32 *region_ptrs[STI_REGION_MAX];
|
| 93 | s32 reent_lvl;
|
| 94 | u32 *save_addr;
|
| 95 | u32 *ext_ptr;
|
| 96 | };
|
| 97 |
|
| 98 |
|
| 99 |
|
| 100 |
|
| 101 | struct sti_init_flags {
|
| 102 | u32 wait : 1;
|
| 103 | u32 reset : 1;
|
| 104 | u32 text : 1;
|
| 105 | u32 nontext : 1;
|
| 106 | u32 clear : 1;
|
| 107 | u32 cmap_blk : 1;
|
| 108 | u32 enable_be_timer : 1;
|
| 109 | u32 enable_be_int : 1;
|
| 110 | u32 no_chg_tx : 1;
|
| 111 | u32 no_chg_ntx : 1;
|
| 112 | u32 no_chg_bet : 1;
|
| 113 | u32 no_chg_bei : 1;
|
| 114 | u32 init_cmap_tx : 1;
|
| 115 | u32 cmt_chg : 1;
|
| 116 | u32 retain_ie : 1;
|
| 117 | u32 caller_bootrom : 1;
|
| 118 | u32 caller_kernel : 1;
|
| 119 | u32 caller_other : 1;
|
| 120 | u32 pad : 14;
|
| 121 | u32 *future_ptr;
|
| 122 | };
|
| 123 |
|
| 124 | struct sti_init_inptr_ext {
|
| 125 | u8 config_mon_type;
|
| 126 | u8 pad[1];
|
| 127 | u16 inflight_data;
|
| 128 | u32 *future_ptr;
|
| 129 | };
|
| 130 |
|
| 131 | struct sti_init_inptr {
|
| 132 | s32 text_planes;
|
| 133 | u32 *ext_ptr;
|
| 134 | };
|
| 135 |
|
| 136 |
|
| 137 | struct sti_init_outptr {
|
| 138 | s32 errno;
|
| 139 | s32 text_planes;
|
| 140 | u32 *future_ptr;
|
| 141 | };
|
| 142 |
|
| 143 |
|
| 144 |
|
| 145 |
|
| 146 |
|
| 147 | struct sti_conf_flags {
|
| 148 | u32 wait : 1;
|
| 149 | u32 pad : 31;
|
| 150 | u32 *future_ptr;
|
| 151 | };
|
| 152 |
|
| 153 | struct sti_conf_inptr {
|
| 154 | u32 *future_ptr;
|
| 155 | };
|
| 156 |
|
| 157 | struct sti_conf_outptr_ext {
|
| 158 | u32 crt_config[3];
|
| 159 | u32 crt_hdw[3];
|
| 160 | u32 *future_ptr;
|
| 161 | };
|
| 162 |
|
| 163 | struct sti_conf_outptr {
|
| 164 | s32 errno;
|
| 165 | s16 onscreen_x;
|
| 166 | s16 onscreen_y;
|
| 167 | s16 offscreen_x;
|
| 168 | s16 offscreen_y;
|
| 169 | s16 total_x;
|
| 170 | s16 total_y;
|
| 171 | s32 bits_per_pixel;
|
| 172 | s32 bits_used;
|
| 173 | s32 planes;
|
| 174 | u8 dev_name[STI_DEV_NAME_LENGTH];
|
| 175 | u32 attributes;
|
| 176 | u32 *ext_ptr;
|
| 177 | };
|
| 178 |
|
| 179 | struct sti_rom {
|
| 180 | u8 type[4];
|
| 181 | u8 res004;
|
| 182 | u8 num_mons;
|
| 183 | u8 revno[2];
|
| 184 | u32 graphics_id[2];
|
| 185 |
|
| 186 | u32 font_start;
|
| 187 | u32 statesize;
|
| 188 | u32 last_addr;
|
| 189 | u32 region_list;
|
| 190 |
|
| 191 | u16 reentsize;
|
| 192 | u16 maxtime;
|
| 193 | u32 mon_tbl_addr;
|
| 194 | u32 user_data_addr;
|
| 195 | u32 sti_mem_req;
|
| 196 |
|
| 197 | u32 user_data_size;
|
| 198 | u16 power;
|
| 199 | u8 bus_support;
|
| 200 | u8 ext_bus_support;
|
| 201 | u8 alt_code_type;
|
| 202 | u8 ext_dd_struct[3];
|
| 203 | u32 cfb_addr;
|
| 204 |
|
| 205 | u32 init_graph;
|
| 206 | u32 state_mgmt;
|
| 207 | u32 font_unpmv;
|
| 208 | u32 block_move;
|
| 209 | u32 self_test;
|
| 210 | u32 excep_hdlr;
|
| 211 | u32 inq_conf;
|
| 212 | u32 set_cm_entry;
|
| 213 | u32 dma_ctrl;
|
| 214 | u8 res040[7 * 4];
|
| 215 |
|
| 216 | u32 init_graph_addr;
|
| 217 | u32 state_mgmt_addr;
|
| 218 | u32 font_unp_addr;
|
| 219 | u32 block_move_addr;
|
| 220 | u32 self_test_addr;
|
| 221 | u32 excep_hdlr_addr;
|
| 222 | u32 inq_conf_addr;
|
| 223 | u32 set_cm_entry_addr;
|
| 224 | u32 image_unpack_addr;
|
| 225 | u32 pa_risx_addrs[7];
|
| 226 | };
|
| 227 |
|
| 228 | struct sti_rom_font {
|
| 229 | u16 first_char;
|
| 230 | u16 last_char;
|
| 231 | u8 width;
|
| 232 | u8 height;
|
| 233 | u8 font_type;
|
| 234 | u8 bytes_per_char;
|
| 235 | s32 next_font;
|
| 236 | u8 underline_height;
|
| 237 | u8 underline_pos;
|
| 238 | u8 res008[2];
|
| 239 | };
|
| 240 |
|
| 241 |
|
| 242 |
|
| 243 | struct sti_cooked_font {
|
| 244 | struct sti_rom_font *raw;
|
| 245 | void *raw_ptr;
|
| 246 | struct sti_cooked_font *next_font;
|
| 247 | int height, width;
|
| 248 | int refcount;
|
| 249 | u32 crc;
|
| 250 | };
|
| 251 |
|
| 252 | struct sti_cooked_rom {
|
| 253 | struct sti_rom *raw;
|
| 254 | struct sti_cooked_font *font_start;
|
| 255 | };
|
| 256 |
|
| 257 |
|
| 258 |
|
| 259 | struct sti_font_inptr {
|
| 260 | u32 *font_start_addr;
|
| 261 | s16 index;
|
| 262 | u8 fg_color;
|
| 263 | u8 bg_color;
|
| 264 | s16 dest_x;
|
| 265 | s16 dest_y;
|
| 266 | u32 *future_ptr;
|
| 267 | };
|
| 268 |
|
| 269 | struct sti_font_flags {
|
| 270 | u32 wait : 1;
|
| 271 | u32 non_text : 1;
|
| 272 | u32 pad : 30;
|
| 273 | u32 *future_ptr;
|
| 274 | };
|
| 275 |
|
| 276 | struct sti_font_outptr {
|
| 277 | s32 errno;
|
| 278 | u32 *future_ptr;
|
| 279 | };
|
| 280 |
|
| 281 |
|
| 282 |
|
| 283 | struct sti_blkmv_flags {
|
| 284 | u32 wait : 1;
|
| 285 | u32 color : 1;
|
| 286 | u32 clear : 1;
|
| 287 | u32 non_text : 1;
|
| 288 | u32 pad : 28;
|
| 289 | u32 *future_ptr;
|
| 290 | };
|
| 291 |
|
| 292 | struct sti_blkmv_inptr {
|
| 293 | u8 fg_color;
|
| 294 | u8 bg_color;
|
| 295 | s16 src_x;
|
| 296 | s16 src_y;
|
| 297 | s16 dest_x;
|
| 298 | s16 dest_y;
|
| 299 | s16 width;
|
| 300 | s16 height;
|
| 301 | u32 *future_ptr;
|
| 302 | };
|
| 303 |
|
| 304 | struct sti_blkmv_outptr {
|
| 305 | s32 errno;
|
| 306 | u32 *future_ptr;
|
| 307 | };
|
| 308 |
|
| 309 |
|
| 310 | |
| 311 | * low memory (< 4GB) if STI is used with 32bit STI on a 64bit kernel
|
| 312 |
|
| 313 | struct sti_all_data {
|
| 314 | struct sti_glob_cfg glob_cfg;
|
| 315 | struct sti_glob_cfg_ext glob_cfg_ext;
|
| 316 |
|
| 317 | struct sti_conf_inptr inq_inptr;
|
| 318 | struct sti_conf_outptr inq_outptr;
|
| 319 | struct sti_conf_outptr_ext inq_outptr_ext;
|
| 320 |
|
| 321 | struct sti_init_inptr_ext init_inptr_ext;
|
| 322 | struct sti_init_inptr init_inptr;
|
| 323 | struct sti_init_outptr init_outptr;
|
| 324 |
|
| 325 | struct sti_blkmv_inptr blkmv_inptr;
|
| 326 | struct sti_blkmv_outptr blkmv_outptr;
|
| 327 |
|
| 328 | struct sti_font_inptr font_inptr;
|
| 329 | struct sti_font_outptr font_outptr;
|
| 330 |
|
| 331 |
|
| 332 | unsigned long save_addr[1024 / sizeof(unsigned long)];
|
| 333 |
|
| 334 | unsigned long sti_mem_addr[256 / sizeof(unsigned long)];
|
| 335 |
|
| 336 | };
|
| 337 |
|
| 338 |
|
| 339 |
|
| 340 | struct sti_struct {
|
| 341 | spinlock_t lock;
|
| 342 |
|
| 343 |
|
| 344 | int sti_mem_request;
|
| 345 | u32 graphics_id[2];
|
| 346 |
|
| 347 | struct sti_cooked_rom *rom;
|
| 348 |
|
| 349 | unsigned long font_unpmv;
|
| 350 | unsigned long block_move;
|
| 351 | unsigned long init_graph;
|
| 352 | unsigned long inq_conf;
|
| 353 | int do_call64;
|
| 354 |
|
| 355 |
|
| 356 | int text_planes;
|
| 357 | region_t regions[STI_REGION_MAX];
|
| 358 | unsigned long regions_phys[STI_REGION_MAX];
|
| 359 |
|
| 360 | struct sti_glob_cfg *glob_cfg;
|
| 361 |
|
| 362 | int wordmode;
|
| 363 | struct sti_cooked_font *font;
|
| 364 |
|
| 365 | struct pci_dev *pd;
|
| 366 |
|
| 367 |
|
| 368 | u8 rm_entry[16];
|
| 369 |
|
| 370 |
|
| 371 | struct device *dev;
|
| 372 |
|
| 373 |
|
| 374 | struct sti_all_data *sti_data;
|
| 375 |
|
| 376 |
|
| 377 | char pa_path[24];
|
| 378 | };
|
| 379 |
|
| 380 |
|
| 381 |
|
| 382 |
|
| 383 | struct sti_struct *sti_get_rom(unsigned int index);
|
| 384 | void sti_font_convert_bytemode(struct sti_struct *sti, struct sti_cooked_font *f);
|
| 385 |
|
| 386 |
|
| 387 |
|
| 388 |
|
| 389 | int sti_call(const struct sti_struct *sti, unsigned long func,
|
| 390 | const void *flags, void *inptr, void *outptr,
|
| 391 | struct sti_glob_cfg *glob_cfg);
|
| 392 |
|
| 393 |
|
| 394 |
|
| 395 |
|
| 396 | void sti_putc(struct sti_struct *sti, int c, int y, int x,
|
| 397 | struct sti_cooked_font *font);
|
| 398 | void sti_set(struct sti_struct *sti, int src_y, int src_x,
|
| 399 | int height, int width, u8 color);
|
| 400 | void sti_clear(struct sti_struct *sti, int src_y, int src_x,
|
| 401 | int height, int width, int c, struct sti_cooked_font *font);
|
| 402 | void sti_bmove(struct sti_struct *sti, int src_y, int src_x,
|
| 403 | int dst_y, int dst_x, int height, int width,
|
| 404 | struct sti_cooked_font *font);
|
| 405 |
|
| 406 | #endif
|