1 /* ______ ___ ___ 2 * /\ _ \ /\_ \ /\_ \ 3 * \ \ \L\ \\//\ \ \//\ \ __ __ _ __ ___ 4 * \ \ __ \ \ \ \ \ \ \ /'__`\ /'_ `\/\`'__\/ __`\ 5 * \ \ \/\ \ \_\ \_ \_\ \_/\ __//\ \L\ \ \ \//\ \L\ \ 6 * \ \_\ \_\/\____\/\____\ \____\ \____ \ \_\\ \____/ 7 * \/_/\/_/\/____/\/____/\/____/\/___L\ \/_/ \/___/ 8 * /\____/ 9 * \_/__/ 10 * 11 * Some definitions for internal use by the Linux console code. 12 * 13 * By George Foot. 14 * 15 * See readme.txt for copyright information. 16 */ 17 18 #ifndef AINTLNX_H 19 #define AINTLNX_H 20 21 #ifdef __cplusplus 22 extern "C" { 23 #endif 24 25 26 /**************************************/ 27 /************ Driver lists ************/ 28 /**************************************/ 29 30 extern _DRIVER_INFO _linux_gfx_driver_list[]; 31 extern _DRIVER_INFO _linux_keyboard_driver_list[]; 32 extern _DRIVER_INFO _linux_mouse_driver_list[]; 33 extern _DRIVER_INFO _linux_timer_driver_list[]; 34 /* _linux_joystick_driver_list is in aintunix.h */ 35 36 37 /****************************************/ 38 /************ Memory mapping ************/ /* (src/linux/lmemory.c) */ 39 /****************************************/ 40 41 /* struct MAPPED_MEMORY: Used to describe a block of memory mapped 42 * into our address space (in particular, the video memory). 43 */ 44 struct MAPPED_MEMORY { 45 unsigned int base, size; /* linear address and size of block */ 46 int perms; /* PROT_READ | PROT_WRITE, etc */ 47 void *data; /* pointer to block after mapping */ 48 }; 49 50 extern int __al_linux_have_ioperms; 51 52 int __al_linux_init_memory (void); 53 int __al_linux_shutdown_memory (void); 54 int __al_linux_map_memory (struct MAPPED_MEMORY *info); 55 int __al_linux_unmap_memory (struct MAPPED_MEMORY *info); 56 57 58 /******************************************/ 59 /************ Standard drivers ************/ /* (src/linux/lstddrv.c) */ 60 /******************************************/ 61 62 /* This "standard drivers" business is mostly a historical artifact. 63 * It was highly over-engineered, now simplified. It has been mostly 64 * superseded by the newer, shinier, better bg_man. But hey, at least 65 * it didn't suffer the fate of its cousin lasyncio.c, now dead, 66 * buried, and without a tombstone to show for it. --pw 67 */ 68 69 typedef struct STD_DRIVER { 70 unsigned type; /* One of the below STD_ constants */ 71 72 int (*update) (void); 73 void (*resume) (void); 74 void (*suspend) (void); 75 76 int fd; /* Descriptor of the opened device */ 77 } STD_DRIVER; 78 79 #define STD_MOUSE 0 80 #define STD_KBD 1 81 82 #define N_STD_DRIVERS 2 83 84 /* List of standard drivers */ 85 extern STD_DRIVER *__al_linux_std_drivers[]; 86 87 /* Exported functions */ 88 int __al_linux_add_standard_driver (STD_DRIVER *spec); 89 int __al_linux_remove_standard_driver (STD_DRIVER *spec); 90 void __al_linux_update_standard_drivers (int threaded); 91 void __al_linux_suspend_standard_drivers (void); 92 void __al_linux_resume_standard_drivers (void); 93 94 95 /******************************************/ 96 /************ Console routines ************/ /* (src/linux/lconsole.c) */ 97 /******************************************/ 98 99 #define N_CRTC_REGS 24 100 #define N_ATC_REGS 21 101 #define N_GC_REGS 9 102 #define N_SEQ_REGS 5 103 104 #define MISC_REG_R 0x03CC 105 #define MISC_REG_W 0x03C2 106 #define ATC_REG_IW 0x03C0 107 #define ATC_REG_R 0x03C1 108 #define GC_REG_I 0x03CE 109 #define GC_REG_RW 0x03CF 110 #define SEQ_REG_I 0x03C4 111 #define SEQ_REG_RW 0x03C5 112 #define PEL_REG_IW 0x03C8 113 #define PEL_REG_IR 0x03C7 114 #define PEL_REG_D 0x03C9 115 116 #define _is1 0x03DA 117 118 #define ATC_DELAY 10 /* microseconds - for usleep() */ 119 120 #define VGA_MEMORY_BASE 0xA0000 121 #define VGA_MEMORY_SIZE 0x10000 122 #define VGA_FONT_SIZE 0x02000 123 124 /* This structure is also used for video state saving/restoring, therefore it 125 * contains fields that are used only when saving/restoring the text mode. */ 126 typedef struct MODE_REGISTERS 127 { 128 unsigned char crt[N_CRTC_REGS]; 129 unsigned char seq[N_SEQ_REGS]; 130 unsigned char atc[N_ATC_REGS]; 131 unsigned char gc[N_GC_REGS]; 132 unsigned char misc; 133 unsigned char *ext; 134 unsigned short ext_count; 135 unsigned char *text_font1; 136 unsigned char *text_font2; 137 unsigned long flags; 138 union { 139 unsigned char vga[768]; 140 PALETTE allegro; 141 } palette; 142 } MODE_REGISTERS; 143 144 extern int __al_linux_vt; 145 extern int __al_linux_console_fd; 146 extern int __al_linux_prev_vt; 147 extern int __al_linux_got_text_message; 148 extern struct termios __al_linux_startup_termio; 149 extern struct termios __al_linux_work_termio; 150 151 int __al_linux_use_console (void); 152 int __al_linux_leave_console (void); 153 154 int __al_linux_console_graphics (void); 155 int __al_linux_console_text (void); 156 157 int __al_linux_wait_for_display (void); 158 159 160 /*************************************/ 161 /************ VGA helpers ************/ /* (src/linux/lvgahelp.c) */ 162 /*************************************/ 163 164 int __al_linux_init_vga_helpers (void); 165 int __al_linux_shutdown_vga_helpers (void); 166 167 void __al_linux_screen_off (void); 168 void __al_linux_screen_on (void); 169 170 void __al_linux_clear_vram (void); 171 172 void __al_linux_set_vga_regs (MODE_REGISTERS *regs); 173 void __al_linux_get_vga_regs (MODE_REGISTERS *regs); 174 175 void __al_linux_save_gfx_mode (void); 176 void __al_linux_restore_gfx_mode (void); 177 void __al_linux_save_text_mode (void); 178 void __al_linux_restore_text_mode (void); 179 180 #define __just_a_moment() usleep(ATC_DELAY) 181 182 183 /**************************************/ 184 /************ VT switching ************/ /* (src/linux/vtswitch.c) */ 185 /**************************************/ 186 187 /* signals for VT switching */ 188 #define SIGRELVT SIGUSR1 189 #define SIGACQVT SIGUSR2 190 191 int __al_linux_init_vtswitch (void); 192 int __al_linux_done_vtswitch (void); 193 194 void __al_linux_acquire_bitmap (BITMAP *bmp); 195 void __al_linux_release_bitmap (BITMAP *bmp); 196 197 int __al_linux_set_display_switch_mode (int mode); 198 void __al_linux_display_switch_lock (int lock, int foreground); 199 200 extern volatile int __al_linux_switching_blocked; 201 202 203 /**************************************/ 204 /************ Mode setting ************/ /* (src/linux/lgraph.c) */ 205 /**************************************/ 206 207 typedef struct GFX_MODE_INFO { 208 int w,h,c; /* width, height, colour depth */ 209 int id; /* ID code, for driver's reference */ 210 void *data; /* data for driver's use in setting the mode */ 211 } GFX_MODE_INFO; 212 213 BITMAP *__al_linux_gfx_mode_set_helper ( 214 int w, int h, int v_w, int v_h, int c, 215 GFX_DRIVER *driver, GFX_MODE_INFO *mode, 216 int (*set_video_mode) (GFX_MODE_INFO *mode), 217 void (*set_width) (int w) 218 ); 219 220 221 /*******************************/ 222 /************ Mouse ************/ /* (src/linux/lmouse.c) */ 223 /*******************************/ 224 225 typedef struct INTERNAL_MOUSE_DRIVER { 226 int device; 227 int (*process) (unsigned char *buf, int buf_size); 228 int num_buttons; 229 } INTERNAL_MOUSE_DRIVER; 230 231 int __al_linux_mouse_init (INTERNAL_MOUSE_DRIVER *drv); 232 void __al_linux_mouse_exit (void); 233 void __al_linux_mouse_position (int x, int y); 234 void __al_linux_mouse_set_range (int x1, int y_1, int x2, int y2); 235 void __al_linux_mouse_set_speed (int xspeed, int yspeed); 236 void __al_linux_mouse_get_mickeys (int *mickeyx, int *mickeyy); 237 void __al_linux_mouse_handler (int x, int y, int z, int b); 238 239 240 #ifdef __cplusplus 241 } 242 #endif 243 244 /* VGA register access helpers */ 245 /* This is conditional because configure may have disabled VGA support */ 246 #ifdef ALLEGRO_LINUX_VGA 247 #include "allegro/internal/aintern.h" 248 #include "allegro/internal/aintvga.h" 249 #endif 250 251 /* Functions for querying the framebuffer, for the fbcon driver */ 252 #if (defined ALLEGRO_LINUX_FBCON) && (!defined ALLEGRO_WITH_MODULES) 253 extern int __al_linux_get_fb_color_depth(void); 254 extern int __al_linux_get_fb_resolution(int *width, int *height); 255 #endif 256 257 #endif /* ifndef AINTLNX_H */ 258 259