/* * (C) Copyright 1992, ..., 2003 the "DOSEMU-Development-Team". * * for details see file COPYING in the DOSEMU distribution */ /* dos emulator, Matthias Lautner * Extensions by Robert Sanders, 1992-93 * */ #ifndef EMU_H #define EMU_H #include "config.h" #include #include #include #if defined(HAVE_KEYBOARD_V1) && (HAVE_KEYBOARD_V1 > 1) #error "Sorry, wrong keyboard code version for this DOSEMU version" #endif #if defined(HAVE_UNICODE_KEYB) && (HAVE_UNICODE_KEYB != 2) #error "Sorry, wrong unicode keyboard code version for this DOSEMU version" #endif #include "types.h" #include "extern.h" #include "machcompat.h" #include "cpu.h" #include "vm86plus.h" #include "priv.h" #include "mouse.h" #include "extern.h" #if 1 /* Set to 1 to use Silly Interrupt generator */ #define SIG 1 typedef struct { int fd; int irq; } SillyG_t; extern SillyG_t *SillyG; extern int SillyG_do_irq(void); extern inline void irq_select(void); #endif #define inline __inline__ #define BIT(x) (1<> 12)+1 ]; int sillyint; /* IRQ numbers for Silly Interrupt Generator (bitmask, bit3..15 ==> IRQ3 .. IRQ15) */ struct keytable_entry *keytable; struct keytable_entry *altkeytable; unsigned short detach; unsigned char *debugout; unsigned char *pre_stroke; /* pointer to keyboard pre strokes */ unsigned char *pre_stroke_mem; /* Lock File business */ boolean full_file_locks; char *tty_lockdir; /* The Lock directory */ char *tty_lockfile; /* Lock file pretext ie LCK.. */ boolean tty_lockbinary; /* Binary lock files ? */ /* LFN support */ boolean lfn; /* type of mapping driver */ char *mappingdriver; /* list of arbitrary features * (at minimum 1, will be increased when needed) * The purpose of these parameters is to switch between code * or code pieces that in principal do the same, but for some * unknown reasons behave different between machines. * If a 'features' becomes obsolete (problem solved) it will * remain dummy for a while before re-used. * * NOTE: 'features' are not subject to permanent documentation! * They should be considered 'temporary hacks' * * Currently assigned: * * features[0] use new(0) or old(1) Slangcode */ int features[1]; /* Sound emulation */ int sound; uint16_t sb_base; uint8_t sb_dma; uint8_t sb_hdma; uint8_t sb_irq; char *sb_dsp; char *sb_mixer; uint16_t mpu401_base; char *sound_driver; /* OSS-specific options */ int oss_min_frags; int oss_max_frags; int oss_stalled_frags; int oss_do_post; int oss_min_extra_frags; /* joystick */ char *joy_device[2]; /* range for joystick axis values */ int joy_dos_min; /* must be > 0 */ int joy_dos_max; /* avoid setting this to > 250 */ int joy_granularity; /* the higher, the less sensitive - for wobbly joysticks */ int joy_latency; /* delay between nonblocking linux joystick reads */ int cli_timeout; /* cli timeout hack */ int pic_watchdog; /* pic watchdog reschedule hack */ } config_t; #define SPKR_OFF 0 #define SPKR_NATIVE 1 #define SPKR_EMULATED 2 /* * Right now, dosemu only supports two serial ports. */ #define SIG_SER SIGTTIN #define IO_READ 1 #define IO_WRITE 2 #define IO_RDWR (IO_READ | IO_WRITE) #undef cli #undef sti EXTERN void cli(void); EXTERN void sti(void); EXTERN int port_readable(unsigned short); EXTERN int port_writeable(unsigned short); EXTERN unsigned char read_port(unsigned short); EXTERN int write_port(unsigned int, unsigned short); EXTERN __inline__ void parent_nextscan(void); EXTERN __inline__ void disk_close(void); EXTERN void cpu_setup(void); EXTERN void real_run_int(int); #define run_int do_int EXTERN int mfs_redirector(void); EXTERN int mfs_lfn(void); EXTERN int int10(void); EXTERN int int13(void); EXTERN int int16(void); EXTERN int int17(void); EXTERN void io_select(fd_set); EXTERN void io_select_init(void); EXTERN int pd_receive_packet(void); EXTERN int printer_tick(u_long); EXTERN void floppy_tick(void); EXTERN void open_kmem(void); EXTERN void close_kmem(void); EXTERN int parse_config(char *, char *); EXTERN void prepare_dexe_load(char *name); EXTERN void disk_init(void); EXTERN void serial_init(void); EXTERN void close_all_printers(void); EXTERN void serial_close(void); EXTERN void disk_close_all(void); EXTERN void init_all_printers(void); EXTERN int mfs_inte6(void); EXTERN void pkt_helper(void); EXTERN short pop_word(struct vm86_regs *); EXTERN void ems_init(void); EXTERN void leavedos(int) NORETURN; EXTERN void add_to_io_select(int, u_char, void(*)(void)); EXTERN void remove_from_io_select(int, u_char); EXTERN void sigquit(int); #ifdef __linux__ EXTERN void sigalrm(int, struct sigcontext_struct); EXTERN void e_sigalrm(struct sigcontext_struct *context); EXTERN void sigio(int, struct sigcontext_struct); EXTERN int dosemu_sigaction(int sig, struct sigaction *new, struct sigaction *old); EXTERN void SIG_init(void); EXTERN void SIG_close(void); #endif /* set if sigaltstack(2) is available */ EXTERN int have_working_sigaltstack; /* signals for Linux's process control of consoles */ #define SIG_RELEASE SIGWINCH #define SIG_ACQUIRE SIGUSR2 /* DANG_BEGIN_REMARK * We assume system call restarting... under linux 0.99pl8 and earlier, * this was the default. SA_RESTART was defined in 0.99pl8 to explicitly * request restarting (and thus does nothing). However, if this ever * changes, I want to be safe * DANG_END_REMARK */ #ifndef SA_RESTART #define SA_RESTART 0 #error SA_RESTART Not defined #endif /* DANG_BEGIN_FUNCTION NEWSETQSIG * * arguments: * sig - the signal to have a handler installed to. * fun - the signal handler function to install * * description: * All signals that wish to be handled properly in context with the * execution of vm86() mode, and signals that wish to use non-reentrant * functions should add themselves to the ADDSET_SIGNALS_THAT_QUEUE define * and use SETQSIG(). To that end they will also need to be set up in an * order such as SIGIO. * * DANG_END_FUNCTION * */ #define ADDSET_SIGNALS_THAT_QUEUE(x) \ do { \ sigaddset(x, SIGIO); \ sigaddset(x, SIGALRM); \ sigaddset(x, SIG_RELEASE); \ sigaddset(x, SIG_ACQUIRE); \ } while(0) #ifdef __linux__ #ifndef SA_ONSTACK #define SA_ONSTACK 0 #undef HAVE_SIGALTSTACK #endif #define SignalHandler __sighandler_t #define NEWSETQSIG(sig, fun) \ sa.sa_handler = (__sighandler_t)fun; \ sa.sa_flags = SA_RESTART; \ sigemptyset(&sa.sa_mask); \ ADDSET_SIGNALS_THAT_QUEUE(&sa.sa_mask); \ if (have_working_sigaltstack) { \ sa.sa_flags |= SA_ONSTACK; \ sigaction(sig, &sa, NULL); \ } else { \ /* Point to the top of the stack, minus 4 \ just in case, and make it aligned */ \ sa.sa_restorer = \ (void (*)(void)) (((unsigned int)(cstack) + sizeof(cstack) - 4) & ~3); \ dosemu_sigaction(sig, &sa, NULL); \ } #define SETSIG(sig, fun) \ sa.sa_handler = (SignalHandler)fun; \ sa.sa_flags = SA_RESTART; \ sigemptyset(&sa.sa_mask); \ sigaddset(&sa.sa_mask, SIGALRM); \ sigaction(sig, &sa, NULL); #define NEWSETSIG(sig, fun) \ sa.sa_handler = (__sighandler_t) fun; \ sa.sa_flags = SA_RESTART; \ sigemptyset(&sa.sa_mask); \ sigaddset(&sa.sa_mask, SIGALRM); \ if (have_working_sigaltstack) { \ sa.sa_flags |= SA_ONSTACK; \ sigaction(sig, &sa, NULL); \ } else { \ /* Point to the top of the stack, minus 4 \ just in case, and make it aligned */ \ sa.sa_restorer = \ (void (*)(void)) (((unsigned int)(cstack) + sizeof(cstack) - 4) & ~3); \ dosemu_sigaction(sig, &sa, NULL); \ } #endif EXTERN inline void SIGNAL_save( void (*signal_call)(void) ); EXTERN inline void handle_signals(void); /* * DANG_BEGIN_REMARK * DOSEMU keeps system wide configuration status in a structure * called config. * DANG_END_REMARK */ EXTERN struct config_info config; /* * DANG_BEGIN_REMARK * The var `fatalerr` can be given a true value at any time to have DOSEMU * exit on the next return from vm86 mode. * DANG_END_REMARK */ EXTERN int fatalerr INIT(0); /* * DANG_BEGIN_REMARK * The var 'running_DosC' is set by the DosC kernel and is used to handle * some things differently, e.g. the redirector. * It interfaces via INTe6,0xDC (DOS_HELPER_DOSC), but only if running_DosC * is !=0. At the very startup DosC issues a INTe6,0xdcDC to set running_DosC * with the contents of BX (which is the internal DosC version). * DANG_END_REMARK */ EXTERN int running_DosC INIT(0); EXTERN int dosc_interface(void); EXTERN void dump_config_status(void *); EXTERN void signal_init(void); EXTERN void device_init(void); EXTERN void hardware_setup(void); EXTERN void memory_init(void); EXTERN void map_hardware_ram(void); EXTERN void map_video_bios(void); EXTERN void stdio_init(void); EXTERN void time_setting_init(void); EXTERN void timer_interrupt_init(void); EXTERN void low_mem_init(void); EXTERN void print_version(void); EXTERN void keyboard_flags_init(void); EXTERN void video_config_init(void); EXTERN void printer_init(void); EXTERN void video_close(void); EXTERN void hma_exit(void); EXTERN void ems_helper(void); EXTERN boolean_t ems_fn(struct vm86_regs *); EXTERN void mouse_helper(void); EXTERN void cdrom_helper(void); EXTERN void boot(void); EXTERN int pkt_int(void); EXTERN void read_next_scancode_from_queue (void); EXTERN unsigned short detach (void); EXTERN void disallocate_vt (void); EXTERN void restore_vt (unsigned short vt); EXTERN void HMA_init(void); EXTERN void HMA_MAP(int HMA); extern char *Path_cdrom[]; #endif /* EMU_H */