diff options
Diffstat (limited to 'board/MAI/bios_emulator/scitech/src/v86bios')
16 files changed, 1404 insertions, 1422 deletions
diff --git a/board/MAI/bios_emulator/scitech/src/v86bios/AsmMacros.h b/board/MAI/bios_emulator/scitech/src/v86bios/AsmMacros.h index e824299c05..77c545aef4 100644 --- a/board/MAI/bios_emulator/scitech/src/v86bios/AsmMacros.h +++ b/board/MAI/bios_emulator/scitech/src/v86bios/AsmMacros.h @@ -2,24 +2,24 @@ /* * (c) Copyright 1993,1994 by David Wexelblat <dwex@xfree86.org> * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * DAVID WEXELBLAT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF - * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * DAVID WEXELBLAT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF + * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. - * + * * Except as contained in this notice, the name of David Wexelblat shall not be * used in advertising or otherwise to promote the sale, use or other dealings * in this Software without prior written authorization from David Wexelblat. @@ -28,32 +28,32 @@ /* * Copyright 1997 * Digital Equipment Corporation. All rights reserved. - * This software is furnished under license and may be used and copied only in - * accordance with the following terms and conditions. Subject to these - * conditions, you may download, copy, install, use, modify and distribute - * this software in source and/or binary form. No title or ownership is + * This software is furnished under license and may be used and copied only in + * accordance with the following terms and conditions. Subject to these + * conditions, you may download, copy, install, use, modify and distribute + * this software in source and/or binary form. No title or ownership is * transferred hereby. * - * 1) Any source code used, modified or distributed must reproduce and retain + * 1) Any source code used, modified or distributed must reproduce and retain * this copyright notice and list of conditions as they appear in the source * file. * - * 2) No right is granted to use any trade name, trademark, or logo of Digital - * Equipment Corporation. Neither the "Digital Equipment Corporation" name - * nor any trademark or logo of Digital Equipment Corporation may be used - * to endorse or promote products derived from this software without the + * 2) No right is granted to use any trade name, trademark, or logo of Digital + * Equipment Corporation. Neither the "Digital Equipment Corporation" name + * nor any trademark or logo of Digital Equipment Corporation may be used + * to endorse or promote products derived from this software without the * prior written permission of Digital Equipment Corporation. * - * 3) This software is provided "AS-IS" and any express or implied warranties, - * including but not limited to, any implied warranties of merchantability, - * fitness for a particular purpose, or non-infringement are disclaimed. In - * no event shall DIGITAL be liable for any damages whatsoever, and in - * particular, DIGITAL shall not be liable for special, indirect, - * consequential, or incidental damages or damages for - * lost profits, loss of revenue or loss of use, whether such damages arise - * in contract, - * negligence, tort, under statute, in equity, at law or otherwise, even if - * advised of the possibility of such damage. + * 3) This software is provided "AS-IS" and any express or implied warranties, + * including but not limited to, any implied warranties of merchantability, + * fitness for a particular purpose, or non-infringement are disclaimed. In + * no event shall DIGITAL be liable for any damages whatsoever, and in + * particular, DIGITAL shall not be liable for special, indirect, + * consequential, or incidental damages or damages for + * lost profits, loss of revenue or loss of use, whether such damages arise + * in contract, + * negligence, tort, under statute, in equity, at law or otherwise, even if + * advised of the possibility of such damage. * */ @@ -356,8 +356,8 @@ inb(port) { unsigned int ret; __asm__ __volatile__("in%B0 (%1)" : - "=a" (ret) : - "d" (port)); + "=a" (ret) : + "d" (port)); return ret; } @@ -367,8 +367,8 @@ inw(port) { unsigned int ret; __asm__ __volatile__("in%W0 (%1)" : - "=a" (ret) : - "d" (port)); + "=a" (ret) : + "d" (port)); return ret; } @@ -378,8 +378,8 @@ inl(port) { unsigned int ret; __asm__ __volatile__("in%L0 (%1)" : - "=a" (ret) : - "d" (port)); + "=a" (ret) : + "d" (port)); return ret; } @@ -395,7 +395,7 @@ inl(port) #define intr_disable() #define intr_enable() -#else +#else static __inline__ void intr_disable() diff --git a/board/MAI/bios_emulator/scitech/src/v86bios/README b/board/MAI/bios_emulator/scitech/src/v86bios/README index 4b7d0fa029..cb65674b2d 100644 --- a/board/MAI/bios_emulator/scitech/src/v86bios/README +++ b/board/MAI/bios_emulator/scitech/src/v86bios/README @@ -2,12 +2,12 @@ This is a preliminary version of a VGA softbooter for LINUX. It makes use of the of the vm86() call and is therefore only -usable on ix86 systems. +usable on ix86 systems. There are plans to port this program to use a x86 emulator like x86emu. Also it may be ported to other operating systems. So far it has been tested on a small number of cards. It might -well be that it will fail on your card. +well be that it will fail on your card. If you need to make modifications to the programs to be able to boot your card please let the author know. @@ -16,20 +16,17 @@ So far there is no command line interface. All options need to be hardcoded. You can do this by editing debug.h. You can turn on a bunch of debug output. Other options allow you to boot the primary card (CONFIG_ACTIVE_DEVICE), save the bios -to a file (SAVE_BIOS), and map the original system bios +to a file (SAVE_BIOS), and map the original system bios (MAP_SYS_BIOS). The author wants to thank Hans Lermen (dosemu) and Kendall Bennett (x86emu) -for their support. +for their support. Parts of the code - especially in v86.c and io.c - are based on code taken from dosemu. Parts of the code in int.c are based on code taken from x86emu Egbert Eich. <Egbert.Eich@Physik.TU-Darmstadt.DE> - - - diff --git a/board/MAI/bios_emulator/scitech/src/v86bios/cbios.c b/board/MAI/bios_emulator/scitech/src/v86bios/cbios.c index 4173c953ba..6b12dff4f9 100644 --- a/board/MAI/bios_emulator/scitech/src/v86bios/cbios.c +++ b/board/MAI/bios_emulator/scitech/src/v86bios/cbios.c @@ -57,18 +57,18 @@ main(int argc,char **argv) Config.IoStatistics = IO_STATISTICS; Config.PrintIrq = PRINT_IRQ; Config.PrintPci = PRINT_PCI; - Config.ShowAllDev = SHOW_ALL_DEV; - Config.PrintIp = PRINT_IP; - Config.SaveBios = SAVE_BIOS; - Config.Trace = TRACE; - Config.ConfigActiveOnly = CONFIG_ACTIVE_ONLY; + Config.ShowAllDev = SHOW_ALL_DEV; + Config.PrintIp = PRINT_IP; + Config.SaveBios = SAVE_BIOS; + Config.Trace = TRACE; + Config.ConfigActiveOnly = CONFIG_ACTIVE_ONLY; Config.ConfigActiveDevice = CONFIG_ACTIVE_DEVICE; - Config.MapSysBios = MAP_SYS_BIOS; - Config.Resort = RESORT; - Config.FixRom = FIX_ROM; - Config.NoConsole = NO_CONSOLE; + Config.MapSysBios = MAP_SYS_BIOS; + Config.Resort = RESORT; + Config.FixRom = FIX_ROM; + Config.NoConsole = NO_CONSOLE; Config.Verbose = VERBOSE; - + if (!map()) exit(1); if (!copy_sys_bios()) @@ -79,7 +79,7 @@ main(int argc,char **argv) exit(1); if (!copy_vbios(vbios_base)) exit(1); - + iopl(3); setup_io(); runBIOS(argc,argv); @@ -91,18 +91,18 @@ main(int argc,char **argv) exit (1); } -int +int map(void) { void* mem; mem = mmap(0, (size_t)SIZE, - PROT_EXEC | PROT_READ | PROT_WRITE, - MAP_FIXED | MAP_PRIVATE | MAP_ANON, - -1, 0 ); + PROT_EXEC | PROT_READ | PROT_WRITE, + MAP_FIXED | MAP_PRIVATE | MAP_ANON, + -1, 0 ); if (mem != 0) { - perror("anonymous map"); - return (0); + perror("anonymous map"); + return (0); } memset(mem,0,SIZE); @@ -117,14 +117,14 @@ copy_sys_bios(void) int mem_fd; if ((mem_fd = open(MEM_FILE,O_RDONLY))<0) { - perror("opening memory"); - return (0); + perror("opening memory"); + return (0); } - - if (lseek(mem_fd,(off_t) SYS_BIOS,SEEK_SET) != (off_t) SYS_BIOS) - goto Error; - if (read(mem_fd, (char *)SYS_BIOS, (size_t) 0xFFFF) != (size_t) 0xFFFF) - goto Error; + + if (lseek(mem_fd,(off_t) SYS_BIOS,SEEK_SET) != (off_t) SYS_BIOS) + goto Error; + if (read(mem_fd, (char *)SYS_BIOS, (size_t) 0xFFFF) != (size_t) 0xFFFF) + goto Error; close(mem_fd); return (1); @@ -141,33 +141,33 @@ map_vram(void) int mem_fd; #ifdef __ia64__ - if ((mem_fd = open(MEM_FILE,O_RDWR | O_SYNC))<0) + if ((mem_fd = open(MEM_FILE,O_RDWR | O_SYNC))<0) #else - if ((mem_fd = open(MEM_FILE,O_RDWR))<0) + if ((mem_fd = open(MEM_FILE,O_RDWR))<0) #endif { - perror("opening memory"); - return 0; + perror("opening memory"); + return 0; } #ifndef __alpha__ if (mmap((void *) VRAM_START, (size_t) VRAM_SIZE, - PROT_EXEC | PROT_READ | PROT_WRITE, MAP_SHARED | MAP_FIXED, - mem_fd, VRAM_START) == (void *) -1) + PROT_EXEC | PROT_READ | PROT_WRITE, MAP_SHARED | MAP_FIXED, + mem_fd, VRAM_START) == (void *) -1) #else - if (!_bus_base()) sparse_shift = 7; /* Uh, oh, JENSEN... */ - if (!_bus_base_sparse()) sparse_shift = 0; - if ((vram_map = mmap(0,(size_t) (VRAM_SIZE << sparse_shift), - PROT_READ | PROT_WRITE, - MAP_SHARED, - mem_fd, (VRAM_START << sparse_shift) - | _bus_base_sparse())) == (void *) -1) + if (!_bus_base()) sparse_shift = 7; /* Uh, oh, JENSEN... */ + if (!_bus_base_sparse()) sparse_shift = 0; + if ((vram_map = mmap(0,(size_t) (VRAM_SIZE << sparse_shift), + PROT_READ | PROT_WRITE, + MAP_SHARED, + mem_fd, (VRAM_START << sparse_shift) + | _bus_base_sparse())) == (void *) -1) #endif { - perror("mmap error in map_hardware_ram"); - close(mem_fd); - return (0); - } + perror("mmap error in map_hardware_ram"); + close(mem_fd); + return (0); + } vram_mapped = 1; close(mem_fd); return (1); @@ -181,39 +181,39 @@ copy_vbios(memType v_base) int size; if ((mem_fd = open(MEM_FILE,O_RDONLY))<0) { - perror("opening memory"); - return (0); + perror("opening memory"); + return (0); } - if (lseek(mem_fd,(off_t) v_base, SEEK_SET) != (off_t) v_base) { - fprintf(stderr,"Cannot lseek\n"); - goto Error; + if (lseek(mem_fd,(off_t) v_base, SEEK_SET) != (off_t) v_base) { + fprintf(stderr,"Cannot lseek\n"); + goto Error; } tmp = (unsigned char *)malloc(3); if (read(mem_fd, (char *)tmp, (size_t) 3) != (size_t) 3) { - fprintf(stderr,"Cannot read\n"); - goto Error; + fprintf(stderr,"Cannot read\n"); + goto Error; } - if (lseek(mem_fd,(off_t) v_base,SEEK_SET) != (off_t) v_base) - goto Error; + if (lseek(mem_fd,(off_t) v_base,SEEK_SET) != (off_t) v_base) + goto Error; if (*tmp != 0x55 || *(tmp+1) != 0xAA ) { - fprintf(stderr,"No bios found at: 0x%lx\n",v_base); - goto Error; + fprintf(stderr,"No bios found at: 0x%lx\n",v_base); + goto Error; } #ifdef DEBUG - dprint((unsigned long)tmp,0x100); + dprint((unsigned long)tmp,0x100); #endif size = *(tmp+2) * 512; if (read(mem_fd, (char *)v_base, (size_t) size) != (size_t) size) { - fprintf(stderr,"Cannot read\n"); - goto Error; + fprintf(stderr,"Cannot read\n"); + goto Error; } free(tmp); close(mem_fd); if (!chksum((CARD8*)v_base)) - return (0); + return (0); return (1); @@ -233,7 +233,7 @@ static void unmap_vram(void) { if (!vram_mapped) return; - + munmap((void*)VRAM_START,VRAM_SIZE); vram_mapped = 0; } @@ -259,15 +259,15 @@ setup_int_vect(void) int mem_fd; CARD32 vbase; void *map; - + if ((mem_fd = open(MEM_FILE,O_RDONLY))<0) { perror("opening memory"); return (0); } - + if ((map = mmap((void *) 0, (size_t) 0x2000, - PROT_EXEC | PROT_READ | PROT_WRITE, MAP_SHARED, - mem_fd, 0)) == (void *)-1) { + PROT_EXEC | PROT_READ | PROT_WRITE, MAP_SHARED, + mem_fd, 0)) == (void *)-1) { perror("mmap error in map_hardware_ram"); close(mem_fd); return (0); @@ -282,7 +282,7 @@ setup_int_vect(void) */ bios_var = (char *)malloc(BIOS_MEM); memcpy(bios_var,0,BIOS_MEM); - + vbase = (*((CARD16*)(0x10 << 2) + 1)) << 4; fprintf(stderr,"vbase: 0x%x\n",vbase); return vbase; @@ -294,28 +294,28 @@ update_bios_vars(void) int mem_fd; void *map; memType i; - + #ifdef __ia64__ - if ((mem_fd = open(MEM_FILE,O_RDWR | O_SYNC))<0) + if ((mem_fd = open(MEM_FILE,O_RDWR | O_SYNC))<0) #else - if ((mem_fd = open(MEM_FILE,O_RDWR))<0) + if ((mem_fd = open(MEM_FILE,O_RDWR))<0) #endif { - perror("opening memory"); - return; + perror("opening memory"); + return; } - + if ((map = mmap((void *) 0, (size_t) 0x2000, - PROT_EXEC | PROT_READ | PROT_WRITE, MAP_SHARED, - mem_fd, 0)) == (void *)-1) { + PROT_EXEC | PROT_READ | PROT_WRITE, MAP_SHARED, + mem_fd, 0)) == (void *)-1) { perror("mmap error in map_hardware_ram"); close(mem_fd); return; } for (i = 0; i < BIOS_MEM; i++) { - if (bios_var[i] != *(CARD8*)i) - *((CARD8*)map + i) = *(CARD8*)i; + if (bios_var[i] != *(CARD8*)i) + *((CARD8*)map + i) = *(CARD8*)i; } munmap(map,0x2000); @@ -338,23 +338,23 @@ setup_bios_regs(i86biosRegsPtr regs, int argc, char **argv) while ((c = getopt(argc,argv,"a:b:c:d:e:i:")) != EOF) { switch (c) { case 'a': - regs->ax = strtol(optarg,NULL,0); - break; + regs->ax = strtol(optarg,NULL,0); + break; case 'b': - regs->bx = strtol(optarg,NULL,0); - break; + regs->bx = strtol(optarg,NULL,0); + break; case 'c': - regs->cx = strtol(optarg,NULL,0); - break; + regs->cx = strtol(optarg,NULL,0); + break; case 'd': - regs->dx = strtol(optarg,NULL,0); - break; + regs->dx = strtol(optarg,NULL,0); + break; case 'e': - regs->es = strtol(optarg,NULL,0); - break; + regs->es = strtol(optarg,NULL,0); + break; case 'i': - regs->di = strtol(optarg,NULL,0); - break; + regs->di = strtol(optarg,NULL,0); + break; } } } @@ -367,10 +367,10 @@ chksum(CARD8 *start) CARD8 val = 0; int i; - size = *(start+2) * 512; + size = *(start+2) * 512; for (i = 0; i<size; i++) val += *(start + i); - + if (!val) return 1; @@ -391,25 +391,25 @@ loadCodeToMem(unsigned char *ptr, CARD8 code[]) { int i; CARD8 val; - + for ( i=0;;i++) { - val = code[i]; - *ptr++ = val; - if (val == 0xf4) break; + val = code[i]; + *ptr++ = val; + if (val == 0xf4) break; } return; } -void +void dprint(unsigned long start, unsigned long size) { int i,j; char *c = (char *)start; for (j = 0; j < (size >> 4); j++) { - printf ("\n0x%lx: ",(unsigned long)c); - for (i = 0; i<16; i++) - printf("%x ",(unsigned char) (*(c++))); + printf ("\n0x%lx: ",(unsigned long)c); + for (i = 0; i<16; i++) + printf("%x ",(unsigned char) (*(c++))); } printf("\n"); } diff --git a/board/MAI/bios_emulator/scitech/src/v86bios/command.c b/board/MAI/bios_emulator/scitech/src/v86bios/command.c index 5494ff83ae..e2bce6df1b 100644 --- a/board/MAI/bios_emulator/scitech/src/v86bios/command.c +++ b/board/MAI/bios_emulator/scitech/src/v86bios/command.c @@ -15,24 +15,24 @@ getline(char *buf,int *num,int max_num) static int len = 0; int tmp_len; char *buff; - + if (len <= 0) { buff = readline(PROMPT); add_history(buff); - + if ((tmp_len = strlen(buff)) > line_len) { - free(line); - line = malloc(tmp_len); - line_len = tmp_len; + free(line); + line = malloc(tmp_len); + line_len = tmp_len; } sprintf(line,"%s\n",buff); free(buff); line_pointer = line; len = strlen(line); } - - *num = max_num > len? len : max_num; - strncpy(buf,line_pointer,*num); + + *num = max_num > len? len : max_num; + strncpy(buf,line_pointer,*num); line_pointer = line_pointer + *num; len = len - *num; } diff --git a/board/MAI/bios_emulator/scitech/src/v86bios/console.c b/board/MAI/bios_emulator/scitech/src/v86bios/console.c index 46805155f8..5e9c924b64 100644 --- a/board/MAI/bios_emulator/scitech/src/v86bios/console.c +++ b/board/MAI/bios_emulator/scitech/src/v86bios/console.c @@ -36,43 +36,43 @@ open_console(void) char VTname[11]; console Con = {-1,-1}; struct vt_stat vts; - + if (NO_CONSOLE) - return Con; - + return Con; + if ((fd = open("/dev/tty0",O_WRONLY,0)) < 0) - return Con; + return Con; if ((ioctl(fd, VT_OPENQRY, &VTno) < 0) || (VTno == -1)) { - fprintf(stderr,"cannot get a vt\n"); - return Con; + fprintf(stderr,"cannot get a vt\n"); + return Con; } - + close(fd); sprintf(VTname,"/dev/tty%i",VTno); - + if ((fd = open(VTname, O_RDWR|O_NDELAY, 0)) < 0) { - fprintf(stderr,"cannot open console\n"); - return Con; + fprintf(stderr,"cannot open console\n"); + return Con; } - - if (ioctl(fd, VT_GETSTATE, &vts) == 0) - Con.vt = vts.v_active; + + if (ioctl(fd, VT_GETSTATE, &vts) == 0) + Con.vt = vts.v_active; if (ioctl(fd, VT_ACTIVATE, VTno) != 0) { - fprintf(stderr,"cannot activate console\n"); - close(fd); - return Con; + fprintf(stderr,"cannot activate console\n"); + close(fd); + return Con; } if (ioctl(fd, VT_WAITACTIVE, VTno) != 0) { - fprintf(stderr,"wait for active console failed\n"); - close(fd); - return Con; + fprintf(stderr,"wait for active console failed\n"); + close(fd); + return Con; } #if 0 if (ioctl(fd, KDSETMODE, KD_GRAPHICS) < 0) { - close(fd); - return Con; + close(fd); + return Con; } #endif Con.fd = fd; @@ -83,22 +83,13 @@ void close_console(console Con) { if (Con.fd == -1) - return; - + return; + #if 0 ioctl(Con.fd, KDSETMODE, KD_TEXT); #endif if (Con.vt >=0) - ioctl(Con.fd, VT_ACTIVATE, Con.vt); - + ioctl(Con.fd, VT_ACTIVATE, Con.vt); + close(Con.fd); } - - - - - - - - - diff --git a/board/MAI/bios_emulator/scitech/src/v86bios/debug.h b/board/MAI/bios_emulator/scitech/src/v86bios/debug.h index bc0b1117db..c5c906b622 100644 --- a/board/MAI/bios_emulator/scitech/src/v86bios/debug.h +++ b/board/MAI/bios_emulator/scitech/src/v86bios/debug.h @@ -19,7 +19,7 @@ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR * PERFORMANCE OF THIS SOFTWARE. */ -//#define V86BIOS_DEBUG +/*#define V86BIOS_DEBUG */ /* * uncomment the following if needed @@ -32,7 +32,7 @@ #define PRINT_PCI 1 #define PRINT_IP 0 /* print IP address with PIO information */ #define TRACE 0 /* turn on debugger in x86emu */ - /* requires x86emu compiled with -DDEBUG */ + /* requires x86emu compiled with -DDEBUG */ /* * these should not be here. @@ -48,10 +48,8 @@ #define SHOW_ALL_DEV 0 #define VERBOSE 0 -//#define V_BIOS 0xe0000 -//#define V_BIOS 0xe4000 - - +/*#define V_BIOS 0xe0000 */ +/*#define V_BIOS 0xe4000 */ #if (PRINT_IO == 1) && (PRINT_PORT == 0) diff --git a/board/MAI/bios_emulator/scitech/src/v86bios/int.c b/board/MAI/bios_emulator/scitech/src/v86bios/int.c index 40b17b1d70..3504c6cc3c 100644 --- a/board/MAI/bios_emulator/scitech/src/v86bios/int.c +++ b/board/MAI/bios_emulator/scitech/src/v86bios/int.c @@ -37,11 +37,11 @@ int_handler(int num, struct regs86 *regs) switch (num) { case 0x10: case 0x42: - return (int42_handler(num,regs)); + return (int42_handler(num,regs)); case 0x1A: - return (int1A_handler(regs)); + return (int1A_handler(regs)); default: - return 0; + return 0; } return 0; } @@ -53,38 +53,38 @@ int42_handler(int num,struct regs86 *regs) CARD32 val; i_printf("int 0x%x: ax:0x%lx bx:0x%lx cx:0x%lx dx:0x%lx\n",num, - regs->eax,regs->ebx, regs->ecx, regs->edx); - + regs->eax,regs->ebx, regs->ecx, regs->edx); + /* * video bios has modified these - * leave it to the video bios to do this */ val = getIntVect(num); - if (val != 0xF000F065) + if (val != 0xF000F065) return 0; - + if ((regs->ebx & 0xff) == 0x32) { - switch (regs->eax & 0xFFFF) { - case 0x1200: - i_printf("enabling video\n"); - c = inb(0x3cc); - c |= 0x02; - outb(0x3c2,c); - return 1; - case 0x1201: - i_printf("disabling video\n"); - c = inb(0x3cc); - c &= ~0x02; - outb(0x3c2,c); - return 1; - default: - } + switch (regs->eax & 0xFFFF) { + case 0x1200: + i_printf("enabling video\n"); + c = inb(0x3cc); + c |= 0x02; + outb(0x3c2,c); + return 1; + case 0x1201: + i_printf("disabling video\n"); + c = inb(0x3cc); + c &= ~0x02; + outb(0x3c2,c); + return 1; + default: + } } if (num == 0x42) - return 1; + return 1; else - return 0; + return 0; } #define SUCCESSFUL 0x00 @@ -100,139 +100,139 @@ int1A_handler(struct regs86 *regs) if (! CurrentPci) return 0; /* oops */ i_printf("int 0x1a: ax=0x%lx bx=0x%lx cx=0x%lx dx=0x%lx di=0x%lx" - " si=0x%lx\n", regs->eax,regs->ebx,regs->ecx,regs->edx, - regs->edi,regs->esi); + " si=0x%lx\n", regs->eax,regs->ebx,regs->ecx,regs->edx, + regs->edi,regs->esi); switch (regs->eax & 0xFFFF) { case 0xb101: - regs->eax &= 0xFF00; /* no config space/special cycle support */ - regs->edx = 0x20494350; /* " ICP" */ - regs->ebx = 0x0210; /* Version 2.10 */ - regs->ecx &= 0xFF00; - regs->ecx |= (pciMaxBus & 0xFF); /* Max bus number in system */ - regs->eflags &= ~((unsigned long)0x01); /* clear carry flag */ - i_printf("ax=0x%lx dx=0x%lx bx=0x%lx cx=0x%lx flags=0x%lx\n", - regs->eax,regs->edx,regs->ebx,regs->ecx,regs->eflags); - return 1; + regs->eax &= 0xFF00; /* no config space/special cycle support */ + regs->edx = 0x20494350; /* " ICP" */ + regs->ebx = 0x0210; /* Version 2.10 */ + regs->ecx &= 0xFF00; + regs->ecx |= (pciMaxBus & 0xFF); /* Max bus number in system */ + regs->eflags &= ~((unsigned long)0x01); /* clear carry flag */ + i_printf("ax=0x%lx dx=0x%lx bx=0x%lx cx=0x%lx flags=0x%lx\n", + regs->eax,regs->edx,regs->ebx,regs->ecx,regs->eflags); + return 1; case 0xb102: - if (((regs->edx & 0xFFFF) == CurrentPci->VendorID) && - ((regs->ecx & 0xFFFF) == CurrentPci->DeviceID) && - (regs->esi == 0)) { - regs->eax = (regs->eax & 0x00FF) | (SUCCESSFUL << 8); - regs->eflags &= ~((unsigned long)0x01); /* clear carry flag */ - regs->ebx = pciSlotBX(CurrentPci); - } - else if (Config.ShowAllDev && - (pPci = findPciDevice(regs->edx,regs->ecx,regs->esi)) != NULL) { - regs->eax = (regs->eax & 0x00FF) | (SUCCESSFUL << 8); - regs->eflags &= ~((unsigned long)0x01); /* clear carry flag */ - regs->ebx = pciSlotBX(pPci); - } else { - regs->eax = (regs->eax & 0x00FF) | (DEVICE_NOT_FOUND << 8); - regs->eflags |= ((unsigned long)0x01); /* set carry flag */ - } - i_printf("ax=0x%lx bx=0x%lx flags=0x%lx\n", - regs->eax,regs->ebx,regs->eflags); - return 1; + if (((regs->edx & 0xFFFF) == CurrentPci->VendorID) && + ((regs->ecx & 0xFFFF) == CurrentPci->DeviceID) && + (regs->esi == 0)) { + regs->eax = (regs->eax & 0x00FF) | (SUCCESSFUL << 8); + regs->eflags &= ~((unsigned long)0x01); /* clear carry flag */ + regs->ebx = pciSlotBX(CurrentPci); + } + else if (Config.ShowAllDev && + (pPci = findPciDevice(regs->edx,regs->ecx,regs->esi)) != NULL) { + regs->eax = (regs->eax & 0x00FF) | (SUCCESSFUL << 8); + regs->eflags &= ~((unsigned long)0x01); /* clear carry flag */ + regs->ebx = pciSlotBX(pPci); + } else { + regs->eax = (regs->eax & 0x00FF) | (DEVICE_NOT_FOUND << 8); + regs->eflags |= ((unsigned long)0x01); /* set carry flag */ + } + i_printf("ax=0x%lx bx=0x%lx flags=0x%lx\n", + regs->eax,regs->ebx,regs->eflags); + return 1; case 0xb103: - if (((regs->ecx & 0xFF) == CurrentPci->Interface) && - (((regs->ecx & 0xFF00) >> 8) == CurrentPci->SubClass) && - (((regs->ecx & 0xFFFF0000) >> 16) == CurrentPci->BaseClass) && - ((regs->esi & 0xff) == 0)) { - regs->eax = (regs->eax & 0x00FF) | (SUCCESSFUL << 8); - regs->ebx = pciSlotBX(CurrentPci); - regs->eflags &= ~((unsigned long)0x01); /* clear carry flag */ - } - else if (Config.ShowAllDev - && (pPci = findPciClass(regs->ecx & 0xFF, (regs->ecx & 0xff00) >> 8, - (regs->ecx & 0xffff0000) >> 16, regs->esi)) != NULL) { - regs->eax = (regs->eax & 0x00FF) | (SUCCESSFUL << 8); - regs->ebx = pciSlotBX(pPci); - regs->eflags &= ~((unsigned long)0x01); /* clear carry flag */ - } else { - regs->eax = (regs->eax & 0x00FF) | (DEVICE_NOT_FOUND << 8); - regs->eflags |= ((unsigned long)0x01); /* set carry flag */ - } - i_printf("ax=0x%lx flags=0x%lx\n",regs->eax,regs->eflags); - return 1; + if (((regs->ecx & 0xFF) == CurrentPci->Interface) && + (((regs->ecx & 0xFF00) >> 8) == CurrentPci->SubClass) && + (((regs->ecx & 0xFFFF0000) >> 16) == CurrentPci->BaseClass) && + ((regs->esi & 0xff) == 0)) { + regs->eax = (regs->eax & 0x00FF) | (SUCCESSFUL << 8); + regs->ebx = pciSlotBX(CurrentPci); + regs->eflags &= ~((unsigned long)0x01); /* clear carry flag */ + } + else if (Config.ShowAllDev + && (pPci = findPciClass(regs->ecx & 0xFF, (regs->ecx & 0xff00) >> 8, + (regs->ecx & 0xffff0000) >> 16, regs->esi)) != NULL) { + regs->eax = (regs->eax & 0x00FF) | (SUCCESSFUL << 8); + regs->ebx = pciSlotBX(pPci); + regs->eflags &= ~((unsigned long)0x01); /* clear carry flag */ + } else { + regs->eax = (regs->eax & 0x00FF) | (DEVICE_NOT_FOUND << 8); + regs->eflags |= ((unsigned long)0x01); /* set carry flag */ + } + i_printf("ax=0x%lx flags=0x%lx\n",regs->eax,regs->eflags); + return 1; case 0xb108: - i_printf("Slot=0x%x\n",CurrentPci->Slot.l); - if ((Slot = findPci(regs->ebx))) { - regs->ecx &= 0xFFFFFF00; - regs->ecx |= PciRead8(regs->edi,Slot); - regs->eax = (regs->eax & 0x00FF) | (SUCCESSFUL << 8); - regs->eflags &= ~((unsigned long)0x01); /* clear carry flag */ - } else { - regs->eax = (regs->eax & 0x00FF) | (BAD_REGISTER_NUMBER << 8); - regs->eflags |= ((unsigned long)0x01); /* set carry flag */ - } - i_printf("ax=0x%lx cx=0x%lx flags=0x%lx\n", - regs->eax,regs->ecx,regs->eflags); - return 1; + i_printf("Slot=0x%x\n",CurrentPci->Slot.l); + if ((Slot = findPci(regs->ebx))) { + regs->ecx &= 0xFFFFFF00; + regs->ecx |= PciRead8(regs->edi,Slot); + regs->eax = (regs->eax & 0x00FF) | (SUCCESSFUL << 8); + regs->eflags &= ~((unsigned long)0x01); /* clear carry flag */ + } else { + regs->eax = (regs->eax & 0x00FF) | (BAD_REGISTER_NUMBER << 8); + regs->eflags |= ((unsigned long)0x01); /* set carry flag */ + } + i_printf("ax=0x%lx cx=0x%lx flags=0x%lx\n", + regs->eax,regs->ecx,regs->eflags); + return 1; case 0xb109: - i_printf("Slot=0x%x\n",CurrentPci->Slot.l); - if ((Slot = findPci(regs->ebx))) { - regs->ecx &= 0xFFFF0000; - regs->ecx |= PciRead16(regs->edi,Slot); - regs->eax = (regs->eax & 0x00FF) | (SUCCESSFUL << 8); - regs->eflags &= ~((unsigned long)0x01); /* clear carry flag */ - } else { - regs->eax = (regs->eax & 0x00FF) | (BAD_REGISTER_NUMBER << 8); - regs->eflags |= ((unsigned long)0x01); /* set carry flag */ - } - i_printf("ax=0x%lx cx=0x%lx flags=0x%lx\n", - regs->eax,regs->ecx,regs->eflags); - return 1; + i_printf("Slot=0x%x\n",CurrentPci->Slot.l); + if ((Slot = findPci(regs->ebx))) { + regs->ecx &= 0xFFFF0000; + regs->ecx |= PciRead16(regs->edi,Slot); + regs->eax = (regs->eax & 0x00FF) | (SUCCESSFUL << 8); + regs->eflags &= ~((unsigned long)0x01); /* clear carry flag */ + } else { + regs->eax = (regs->eax & 0x00FF) | (BAD_REGISTER_NUMBER << 8); + regs->eflags |= ((unsigned long)0x01); /* set carry flag */ + } + i_printf("ax=0x%lx cx=0x%lx flags=0x%lx\n", + regs->eax,regs->ecx,regs->eflags); + return 1; case 0xb10a: - i_printf("Slot=0x%x\n",CurrentPci->Slot.l); - if ((Slot = findPci(regs->ebx))) { - regs->ecx &= 0; - regs->ecx |= PciRead32(regs->edi,Slot); - regs->eax = (regs->eax & 0x00FF) | (SUCCESSFUL << 8); - regs->eflags &= ~((unsigned long)0x01); /* clear carry flag */ - } else { - regs->eax = (regs->eax & 0x00FF) | (BAD_REGISTER_NUMBER << 8); - regs->eflags |= ((unsigned long)0x01); /* set carry flag */ - } - i_printf("ax=0x%lx cx=0x%lx flags=0x%lx\n", - regs->eax,regs->ecx,regs->eflags); - return 1; + i_printf("Slot=0x%x\n",CurrentPci->Slot.l); + if ((Slot = findPci(regs->ebx))) { + regs->ecx &= 0; + regs->ecx |= PciRead32(regs->edi,Slot); + regs->eax = (regs->eax & 0x00FF) | (SUCCESSFUL << 8); + regs->eflags &= ~((unsigned long)0x01); /* clear carry flag */ + } else { + regs->eax = (regs->eax & 0x00FF) | (BAD_REGISTER_NUMBER << 8); + regs->eflags |= ((unsigned long)0x01); /* set carry flag */ + } + i_printf("ax=0x%lx cx=0x%lx flags=0x%lx\n", + regs->eax,regs->ecx,regs->eflags); + return 1; case 0xb10b: - i_printf("Slot=0x%x\n",CurrentPci->Slot.l); - if ((Slot = findPci(regs->ebx))) { - PciWrite8(regs->edi,(CARD8)regs->ecx,Slot); - regs->eax = (regs->eax & 0x00FF) | (SUCCESSFUL << 8); - regs->eflags &= ~((unsigned long)0x01); /* clear carry flag */ - } else { - regs->eax = (regs->eax & 0x00FF) | (BAD_REGISTER_NUMBER << 8); - regs->eflags |= ((unsigned long)0x01); /* set carry flag */ - } - i_printf("ax=0x%lx flags=0x%lx\n", regs->eax,regs->eflags); - return 1; + i_printf("Slot=0x%x\n",CurrentPci->Slot.l); + if ((Slot = findPci(regs->ebx))) { + PciWrite8(regs->edi,(CARD8)regs->ecx,Slot); + regs->eax = (regs->eax & 0x00FF) | (SUCCESSFUL << 8); + regs->eflags &= ~((unsigned long)0x01); /* clear carry flag */ + } else { + regs->eax = (regs->eax & 0x00FF) | (BAD_REGISTER_NUMBER << 8); + regs->eflags |= ((unsigned long)0x01); /* set carry flag */ + } + i_printf("ax=0x%lx flags=0x%lx\n", regs->eax,regs->eflags); + return 1; case 0xb10c: - i_printf("Slot=0x%x\n",CurrentPci->Slot.l); - if ((Slot = findPci(regs->ebx))) { - PciWrite16(regs->edi,(CARD16)regs->ecx,Slot); - regs->eax = (regs->eax & 0x00FF) | (SUCCESSFUL << 8); - regs->eflags &= ~((unsigned long)0x01); /* clear carry flag */ - } else { - regs->eax = (regs->eax & 0x00FF) | (BAD_REGISTER_NUMBER << 8); - regs->eflags |= ((unsigned long)0x01); /* set carry flag */ - } - i_printf("ax=0x%lx flags=0x%lx\n", regs->eax,regs->eflags); - return 1; + i_printf("Slot=0x%x\n",CurrentPci->Slot.l); + if ((Slot = findPci(regs->ebx))) { + PciWrite16(regs->edi,(CARD16)regs->ecx,Slot); + regs->eax = (regs->eax & 0x00FF) | (SUCCESSFUL << 8); + regs->eflags &= ~((unsigned long)0x01); /* clear carry flag */ + } else { + regs->eax = (regs->eax & 0x00FF) | (BAD_REGISTER_NUMBER << 8); + regs->eflags |= ((unsigned long)0x01); /* set carry flag */ + } + i_printf("ax=0x%lx flags=0x%lx\n", regs->eax,regs->eflags); + return 1; case 0xb10d: - i_printf("Slot=0x%x\n",CurrentPci->Slot.l); - if ((Slot = findPci(regs->ebx))) { - PciWrite32(regs->edi,(CARD32)regs->ecx,Slot); - regs->eax = (regs->eax & 0x00FF) | (SUCCESSFUL << 8); - regs->eflags &= ~((unsigned long)0x01); /* clear carry flag */ - } else { - regs->eax = (regs->eax & 0x00FF) | (BAD_REGISTER_NUMBER << 8); - regs->eflags |= ((unsigned long)0x01); /* set carry flag */ - } - i_printf("ax=0x%lx flags=0x%lx\n", regs->eax,regs->eflags); - return 1; + i_printf("Slot=0x%x\n",CurrentPci->Slot.l); + if ((Slot = findPci(regs->ebx))) { + PciWrite32(regs->edi,(CARD32)regs->ecx,Slot); + regs->eax = (regs->eax & 0x00FF) | (SUCCESSFUL << 8); + regs->eflags &= ~((unsigned long)0x01); /* clear carry flag */ + } else { + regs->eax = (regs->eax & 0x00FF) | (BAD_REGISTER_NUMBER << 8); + regs->eflags |= ((unsigned long)0x01); /* set carry flag */ + } + i_printf("ax=0x%lx flags=0x%lx\n", regs->eax,regs->eflags); + return 1; default: - return 0; + return 0; } } diff --git a/board/MAI/bios_emulator/scitech/src/v86bios/io.c b/board/MAI/bios_emulator/scitech/src/v86bios/io.c index 129e24f383..f35b43e9b9 100644 --- a/board/MAI/bios_emulator/scitech/src/v86bios/io.c +++ b/board/MAI/bios_emulator/scitech/src/v86bios/io.c @@ -38,17 +38,17 @@ port_rep_inb(CARD16 port, CARD8 *base, int d_f, CARD32 count) { register int inc = d_f ? -1 : 1; CARD8 *dst = base; - + p_printf(" rep_insb(%#x) %d bytes at %p %s", - port, count, base, d_f?"up":"down"); + port, count, base, d_f?"up":"down"); if (Config.PrintIp) - p_printf(" %x\n",getIP()); + p_printf(" %x\n",getIP()); else p_printf("\n"); r_inb++; while (count--) { - *dst = inb(port); - dst += inc; + *dst = inb(port); + dst += inc; } return (dst-base); } @@ -58,17 +58,17 @@ port_rep_inw(CARD16 port, CARD16 *base, int d_f, CARD32 count) { register int inc = d_f ? -1 : 1; CARD16 *dst = base; - + p_printf(" rep_insw(%#x) %d bytes at %p %s", - port, count, base, d_f?"up":"down"); + port, count, base, d_f?"up":"down"); if (Config.PrintIp) - p_printf(" %x\n",getIP()); + p_printf(" %x\n",getIP()); else p_printf("\n"); r_inw++; while (count--) { - *dst = inw(port); - dst += inc; + *dst = inw(port); + dst += inc; } return (dst-base); } @@ -78,17 +78,17 @@ port_rep_inl(CARD16 port, CARD32 *base, int d_f, CARD32 count) { register int inc = d_f ? -1 : 1; CARD32 *dst = base; - + p_printf(" rep_insl(%#x) %d bytes at %p %s", - port, count, base, d_f?"up":"down"); + port, count, base, d_f?"up":"down"); if (Config.PrintIp) - p_printf(" %x\n",getIP()); + p_printf(" %x\n",getIP()); else p_printf("\n"); r_inl++; while (count--) { - *dst = inl(port); - dst += inc; + *dst = inl(port); + dst += inc; } return (dst-base); } @@ -98,17 +98,17 @@ port_rep_outb(CARD16 port, CARD8 *base, int d_f, CARD32 count) { register int inc = d_f ? -1 : 1; CARD8 *dst = base; - + p_printf(" rep_outb(%#x) %d bytes at %p %s", - port, count, base, d_f?"up":"down"); + port, count, base, d_f?"up":"down"); if (Config.PrintIp) - p_printf(" %x\n",getIP()); + p_printf(" %x\n",getIP()); else p_printf("\n"); r_outb++; while (count--) { - outb(port,*dst); - dst += inc; + outb(port,*dst); + dst += inc; } return (dst-base); } @@ -118,17 +118,17 @@ port_rep_outw(CARD16 port, CARD16 *base, int d_f, CARD32 count) { register int inc = d_f ? -1 : 1; CARD16 *dst = base; - + p_printf(" rep_outw(%#x) %d bytes at %p %s", - port, count, base, d_f?"up":"down"); + port, count, base, d_f?"up":"down"); if (Config.PrintIp) - p_printf(" %x\n",getIP()); + p_printf(" %x\n",getIP()); else p_printf("\n"); r_outw++; while (count--) { - outw(port,*dst); - dst += inc; + outw(port,*dst); + dst += inc; } return (dst-base); } @@ -138,17 +138,17 @@ port_rep_outl(CARD16 port, CARD32 *base, int d_f, CARD32 count) { register int inc = d_f ? -1 : 1; CARD32 *dst = base; - + p_printf(" rep_outl(%#x) %d bytes at %p %s", - port, count, base, d_f?"up":"down"); + port, count, base, d_f?"up":"down"); if (Config.PrintIp) - p_printf(" %x\n",getIP()); + p_printf(" %x\n",getIP()); else p_printf("\n"); r_outl++; while (count--) { - outl(port,*dst); - dst += inc; + outl(port,*dst); + dst += inc; } return (dst-base); } @@ -161,7 +161,7 @@ p_inb(CARD16 port) val = inb(port); p_printf(" inb(%#x) = %2.2x",port,val); if (Config.PrintIp) - p_printf(" %x\n",getIP()); + p_printf(" %x\n",getIP()); else p_printf("\n"); return val; @@ -175,7 +175,7 @@ p_inw(CARD16 port) val = inw(port); p_printf(" inw(%#x) = %4.4x",port,val); if (Config.PrintIp) - p_printf(" %x\n",getIP()); + p_printf(" %x\n",getIP()); else p_printf("\n"); return val; @@ -188,13 +188,13 @@ p_inl(CARD16 port) in_l++; #ifdef NEED_PCI_IO if (cfg1in(port,&val)) - return val; + return val; else #endif val = inl(port); p_printf(" inl(%#x) = %8.8x",port,val); if (Config.PrintIp) - p_printf(" %x\n",getIP()); + p_printf(" %x\n",getIP()); else p_printf("\n"); return val; @@ -206,7 +206,7 @@ p_outb(CARD16 port, CARD8 val) out_b++; p_printf(" outb(%#x, %2.2x)",port,val); if (Config.PrintIp) - p_printf(" %x\n",getIP()); + p_printf(" %x\n",getIP()); else p_printf("\n"); outb(port,val); @@ -218,7 +218,7 @@ p_outw(CARD16 port, CARD16 val) out_w++; p_printf(" outw(%#x, %4.4x)",port,val); if (Config.PrintIp) - p_printf(" %x\n",getIP()); + p_printf(" %x\n",getIP()); else p_printf("\n"); outw(port,val); @@ -230,12 +230,12 @@ p_outl(CARD16 port, CARD32 val) out_l++; p_printf(" outl(%#x, %8.8x)",port,val); if (Config.PrintIp) - p_printf(" %x\n",getIP()); + p_printf(" %x\n",getIP()); else p_printf("\n"); #ifdef NEED_PCI_IO if (cfg1out(port,val)) - return; + return; #endif outl(port,val); } @@ -244,9 +244,9 @@ void io_statistics(void) { p_printf("rep: inb: %i, inw: %i, inl: %i, outb: %i, outw: %i, outl: %i\n", - r_inb,r_inw,r_inl,r_outb,r_outw,r_outl); + r_inb,r_inw,r_inl,r_outb,r_outw,r_outl); p_printf("inb: %i, inw: %i, inl: %i, outb: %i, outw: %i, outl: %i\n", - in_b,in_w,in_l,out_b,out_w,out_l); + in_b,in_w,in_l,out_b,out_w,out_l); } void diff --git a/board/MAI/bios_emulator/scitech/src/v86bios/main.c b/board/MAI/bios_emulator/scitech/src/v86bios/main.c index b73d05776e..15f91150f8 100644 --- a/board/MAI/bios_emulator/scitech/src/v86bios/main.c +++ b/board/MAI/bios_emulator/scitech/src/v86bios/main.c @@ -45,12 +45,12 @@ #define V_BIOS_SIZE 0x1FFFF #define BIOS_START 0x7C00 /* default BIOS entry */ -//CARD8 code[] = { 0xb8 , 0xf0 , 0xf0, 0xf4 }; +/*CARD8 code[] = { 0xb8 , 0xf0 , 0xf0, 0xf4 }; */ #define VB_X(x) (V_BIOS >> x) & 0xFF CARD8 code[] = { 0x9a, 0x03, 0x00, 0x00, VB_X(12), 0xf4 }; -//CARD8 code[] = { 0x9a, 0x03, 0x00, 0x00, VB_X(12), 0xb8, 0x03, 0x00, -//0xcd, 0x10, 0xf4 }; -//CARD8 code[] = { 0xb8 , 0xf0 , 0xf0 ,0xf4 }; +/*CARD8 code[] = { 0x9a, 0x03, 0x00, 0x00, VB_X(12), 0xb8, 0x03, 0x00, */ +/*0xcd, 0x10, 0xf4 }; */ +/*CARD8 code[] = { 0xb8 , 0xf0 , 0xf0 ,0xf4 }; */ static void sig_handler(int); static int map(void); @@ -87,154 +87,154 @@ main(void) Config.IoStatistics = IO_STATISTICS; Config.PrintIrq = PRINT_IRQ; Config.PrintPci = PRINT_PCI; - Config.ShowAllDev = SHOW_ALL_DEV; - Config.PrintIp = PRINT_IP; - Config.SaveBios = SAVE_BIOS; - Config.Trace = TRACE; - Config.ConfigActiveOnly = CONFIG_ACTIVE_ONLY; + Config.ShowAllDev = SHOW_ALL_DEV; + Config.PrintIp = PRINT_IP; + Config.SaveBios = SAVE_BIOS; + Config.Trace = TRACE; + Config.ConfigActiveOnly = CONFIG_ACTIVE_ONLY; Config.ConfigActiveDevice = CONFIG_ACTIVE_DEVICE; - Config.MapSysBios = MAP_SYS_BIOS; - Config.Resort = RESORT; - Config.FixRom = FIX_ROM; - Config.NoConsole = NO_CONSOLE; + Config.MapSysBios = MAP_SYS_BIOS; + Config.Resort = RESORT; + Config.FixRom = FIX_ROM; + Config.NoConsole = NO_CONSOLE; Config.Verbose = VERBOSE; if (!map()) - exit(1); - + exit(1); + if (!setup_system_bios()) - exit(1); - + exit(1); + iopl(3); setup_io(); - + scan_pci(); if (!CurrentPci && !Config.ConfigActiveDevice && !Config.ConfigActiveOnly) - exit (1); + exit (1); #endif Console = open_console(); if (Config.ConfigActiveOnly) { - CARD16 ax; - int activePci = 0; - int error = 0; - - while (CurrentPci) { - if (CurrentPci->active) { - activePci = 1; - if (!(mapPciRom(NULL) && chksum((CARD8*)V_BIOS))) - error = 1; - break; - } - CurrentPci = CurrentPci->next; - } - ax = ((CARD16)(CurrentPci->bus) << 8) - | (CurrentPci->dev << 3) | (CurrentPci->func & 0x7); - P_printf("ax: 0x%x\n",ax); - setup_int_vect(); - if (!error && (activePci || copy_vbios())) { - - if (Config.SaveBios) save_bios_to_file(); - if (map_vram()) { - printf("initializing ISA\n"); - bootBIOS(0); - } - } - unmap_vram(); - sleep(1); + CARD16 ax; + int activePci = 0; + int error = 0; + + while (CurrentPci) { + if (CurrentPci->active) { + activePci = 1; + if (!(mapPciRom(NULL) && chksum((CARD8*)V_BIOS))) + error = 1; + break; + } + CurrentPci = CurrentPci->next; + } + ax = ((CARD16)(CurrentPci->bus) << 8) + | (CurrentPci->dev << 3) | (CurrentPci->func & 0x7); + P_printf("ax: 0x%x\n",ax); + setup_int_vect(); + if (!error && (activePci || copy_vbios())) { + + if (Config.SaveBios) save_bios_to_file(); + if (map_vram()) { + printf("initializing ISA\n"); + bootBIOS(0); + } + } + unmap_vram(); + sleep(1); } else { - /* disable primary card */ - save_msr = inb(0x3CC); - save_vse = inb(0x3C3); - save_46e8 = inb(0x46e8); - save_pos102 = inb(0x102); - - signal(2,sig_handler); - signal(11,sig_handler); - - outb(0x3C2,~(CARD8)0x03 & save_msr); - outb(0x3C3,~(CARD8)0x01 & save_vse); - outb(0x46e8, ~(CARD8)0x08 & save_46e8); - outb(0x102, ~(CARD8)0x01 & save_pos102); - - pciVideoDisable(); - - while (CurrentPci) { - CARD16 ax; - - if (CurrentPci->active) { - Active_is_Pci = 1; - if (!Config.ConfigActiveDevice) { - CurrentPci = CurrentPci->next; - continue; - } - } - - EnableCurrent(); - - if (CurrentPci->active) { - outb(0x102, save_pos102); - outb(0x46e8, save_46e8); - outb(0x3C3, save_vse); - outb(0x3C2, save_msr); - } - - /* clear interrupt vectors */ - setup_int_vect(); - - ax = ((CARD16)(CurrentPci->bus) << 8) - | (CurrentPci->dev << 3) | (CurrentPci->func & 0x7); - P_printf("ax: 0x%x\n",ax); - - if (!((mapPciRom(NULL) && chksum((CARD8*)V_BIOS)) - || (CurrentPci->active && copy_vbios()))) { - CurrentPci = CurrentPci->next; - continue; - } - if (!map_vram()) { - CurrentPci = CurrentPci->next; - continue; - } - if (Config.SaveBios) save_bios_to_file(); - printf("initializing PCI bus: %i dev: %i func: %i\n",CurrentPci->bus, - CurrentPci->dev,CurrentPci->func); - bootBIOS(ax); - unmap_vram(); - - CurrentPci = CurrentPci->next; - } - - /* We have an ISA device - configure if requested */ - if (!Active_is_Pci && Config.ConfigActiveDevice) { - pciVideoDisable(); - - outb(0x102, save_pos102); - outb(0x46e8, save_46e8); - outb(0x3C3, save_vse); - outb(0x3C2, save_msr); - - setup_int_vect(); - if (copy_vbios()) { - - if (Config.SaveBios) save_bios_to_file(); - if (map_vram()) { - printf("initializing ISA\n"); - bootBIOS(0); - } - } - - unmap_vram(); - sleep(1); - } - - pciVideoRestore(); - - outb(0x102, save_pos102); - outb(0x46e8, save_46e8); - outb(0x3C3, save_vse); - outb(0x3C2, save_msr); + /* disable primary card */ + save_msr = inb(0x3CC); + save_vse = inb(0x3C3); + save_46e8 = inb(0x46e8); + save_pos102 = inb(0x102); + + signal(2,sig_handler); + signal(11,sig_handler); + + outb(0x3C2,~(CARD8)0x03 & save_msr); + outb(0x3C3,~(CARD8)0x01 & save_vse); + outb(0x46e8, ~(CARD8)0x08 & save_46e8); + outb(0x102, ~(CARD8)0x01 & save_pos102); + + pciVideoDisable(); + + while (CurrentPci) { + CARD16 ax; + + if (CurrentPci->active) { + Active_is_Pci = 1; + if (!Config.ConfigActiveDevice) { + CurrentPci = CurrentPci->next; + continue; + } + } + + EnableCurrent(); + + if (CurrentPci->active) { + outb(0x102, save_pos102); + outb(0x46e8, save_46e8); + outb(0x3C3, save_vse); + outb(0x3C2, save_msr); + } + + /* clear interrupt vectors */ + setup_int_vect(); + + ax = ((CARD16)(CurrentPci->bus) << 8) + | (CurrentPci->dev << 3) | (CurrentPci->func & 0x7); + P_printf("ax: 0x%x\n",ax); + + if (!((mapPciRom(NULL) && chksum((CARD8*)V_BIOS)) + || (CurrentPci->active && copy_vbios()))) { + CurrentPci = CurrentPci->next; + continue; + } + if (!map_vram()) { + CurrentPci = CurrentPci->next; + continue; + } + if (Config.SaveBios) save_bios_to_file(); + printf("initializing PCI bus: %i dev: %i func: %i\n",CurrentPci->bus, + CurrentPci->dev,CurrentPci->func); + bootBIOS(ax); + unmap_vram(); + + CurrentPci = CurrentPci->next; + } + + /* We have an ISA device - configure if requested */ + if (!Active_is_Pci && Config.ConfigActiveDevice) { + pciVideoDisable(); + + outb(0x102, save_pos102); + outb(0x46e8, save_46e8); + outb(0x3C3, save_vse); + outb(0x3C2, save_msr); + + setup_int_vect(); + if (copy_vbios()) { + + if (Config.SaveBios) save_bios_to_file(); + if (map_vram()) { + printf("initializing ISA\n"); + bootBIOS(0); + } + } + + unmap_vram(); + sleep(1); + } + + pciVideoRestore(); + + outb(0x102, save_pos102); + outb(0x46e8, save_46e8); + outb(0x3C3, save_vse); + outb(0x3C2, save_msr); } - + close_console(Console); #ifdef DELETE iopl(0); @@ -243,24 +243,24 @@ main(void) printf("done !\n"); #endif if (Config.IoStatistics) - io_statistics(); + io_statistics(); #ifdef DELETE exit(0); #endif } -int +int map(void) { void* mem; mem = mmap(0, (size_t)SIZE, - PROT_EXEC | PROT_READ | PROT_WRITE, - MAP_FIXED | MAP_PRIVATE | MAP_ANON, - -1, 0 ); + PROT_EXEC | PROT_READ | PROT_WRITE, + MAP_FIXED | MAP_PRIVATE | MAP_ANON, + -1, 0 ); if (mem != 0) { - perror("anonymous map"); - return (0); + perror("anonymous map"); + return (0); } memset(mem,0,SIZE); @@ -294,33 +294,33 @@ map_vram(void) int mem_fd; #ifdef __ia64__ - if ((mem_fd = open(MEM_FILE,O_RDWR | O_SYNC))<0) + if ((mem_fd = open(MEM_FILE,O_RDWR | O_SYNC))<0) #else - if ((mem_fd = open(MEM_FILE,O_RDWR))<0) + if ((mem_fd = open(MEM_FILE,O_RDWR))<0) #endif { - perror("opening memory"); - return 0; + perror("opening memory"); + return 0; } #ifndef __alpha__ if (mmap((void *) VRAM_START, (size_t) VRAM_SIZE, - PROT_EXEC | PROT_READ | PROT_WRITE, MAP_SHARED | MAP_FIXED, - mem_fd, VRAM_START) == (void *) -1) + PROT_EXEC | PROT_READ | PROT_WRITE, MAP_SHARED | MAP_FIXED, + mem_fd, VRAM_START) == (void *) -1) #else - if (!_bus_base()) sparse_shift = 7; /* Uh, oh, JENSEN... */ - if (!_bus_base_sparse()) sparse_shift = 0; - if ((vram_map = mmap(0,(size_t) (VRAM_SIZE << sparse_shift), - PROT_READ | PROT_WRITE, - MAP_SHARED, - mem_fd, (VRAM_START << sparse_shift) - | _bus_base_sparse())) == (void *) -1) + if (!_bus_base()) sparse_shift = 7; /* Uh, oh, JENSEN... */ + if (!_bus_base_sparse()) sparse_shift = 0; + if ((vram_map = mmap(0,(size_t) (VRAM_SIZE << sparse_shift), + PROT_READ | PROT_WRITE, + MAP_SHARED, + mem_fd, (VRAM_START << sparse_shift) + | _bus_base_sparse())) == (void *) -1) #endif { - perror("mmap error in map_hardware_ram"); - close(mem_fd); - return (0); - } + perror("mmap error in map_hardware_ram"); + close(mem_fd); + return (0); + } vram_mapped = 1; close(mem_fd); return (1); @@ -330,7 +330,7 @@ static void unmap_vram(void) { if (!vram_mapped) return; - + munmap((void*)VRAM_START,VRAM_SIZE); vram_mapped = 0; } @@ -343,39 +343,39 @@ copy_vbios(void) int size; if ((mem_fd = open(MEM_FILE,O_RDONLY))<0) { - perror("opening memory"); - return (0); + perror("opening memory"); + return (0); } - if (lseek(mem_fd,(off_t) V_BIOS, SEEK_SET) != (off_t) V_BIOS) { - fprintf(stderr,"Cannot lseek\n"); - goto Error; + if (lseek(mem_fd,(off_t) V_BIOS, SEEK_SET) != (off_t) V_BIOS) { + fprintf(stderr,"Cannot lseek\n"); + goto Error; } tmp = (unsigned char *)malloc(3); if (read(mem_fd, (char *)tmp, (size_t) 3) != (size_t) 3) { - fprintf(stderr,"Cannot read\n"); - goto Error; + fprintf(stderr,"Cannot read\n"); + goto Error; } - if (lseek(mem_fd,(off_t) V_BIOS,SEEK_SET) != (off_t) V_BIOS) - goto Error; + if (lseek(mem_fd,(off_t) V_BIOS,SEEK_SET) != (off_t) V_BIOS) + goto Error; if (*tmp != 0x55 || *(tmp+1) != 0xAA ) { #ifdef DEBUG - dprint((unsigned long)tmp,0x100); + dprint((unsigned long)tmp,0x100); #endif - fprintf(stderr,"No bios found at: 0x%x\n",V_BIOS); - goto Error; + fprintf(stderr,"No bios found at: 0x%x\n",V_BIOS); + goto Error; } size = *(tmp+2) * 512; if (read(mem_fd, (char *)V_BIOS, (size_t) size) != (size_t) size) { - fprintf(stderr,"Cannot read\n"); - goto Error; + fprintf(stderr,"Cannot read\n"); + goto Error; } free(tmp); close(mem_fd); if (!chksum((CARD8)V_BIOS)) - return (0); + return (0); return (1); @@ -392,14 +392,14 @@ copy_sys_bios(void) int mem_fd; if ((mem_fd = open(MEM_FILE,O_RDONLY))<0) { - perror("opening memory"); - return (0); + perror("opening memory"); + return (0); } - - if (lseek(mem_fd,(off_t) SYS_BIOS,SEEK_SET) != (off_t) SYS_BIOS) - goto Error; - if (read(mem_fd, (char *)SYS_BIOS, (size_t) 0xFFFF) != (size_t) 0xFFFF) - goto Error; + + if (lseek(mem_fd,(off_t) SYS_BIOS,SEEK_SET) != (off_t) SYS_BIOS) + goto Error; + if (read(mem_fd, (char *)SYS_BIOS, (size_t) 0xFFFF) != (size_t) 0xFFFF) + goto Error; close(mem_fd); return (1); @@ -415,16 +415,16 @@ loadCodeToMem(unsigned char *ptr, CARD8 code[]) { int i; CARD8 val; - + for ( i=0;;i++) { - val = code[i]; - *ptr++ = val; - if (val == 0xf4) break; + val = code[i]; + *ptr++ = val; + if (val == 0xf4) break; } return; } - -void + +void dprint(unsigned long start, unsigned long size) { int i,j; @@ -433,13 +433,13 @@ dprint(unsigned long start, unsigned long size) for (j = 0; j < (size >> 4); j++) { char *d = c; printf("\n0x%lx: ",(unsigned long)c); - for (i = 0; i<16; i++) - printf("%2.2x ",(unsigned char) (*(c++))); + for (i = 0; i<16; i++) + printf("%2.2x ",(unsigned char) (*(c++))); c = d; for (i = 0; i<16; i++) { - printf("%c",((((CARD8)(*c)) > 32) && (((CARD8)(*c)) < 128)) ? - (unsigned char) (*(c)): '.'); - c++; + printf("%c",((((CARD8)(*c)) > 32) && (((CARD8)(*c)) < 128)) ? + (unsigned char) (*(c)): '.'); + c++; } } printf("\n"); @@ -452,16 +452,16 @@ save_bios_to_file(void) int size, count; char file_name[256]; int fd; - + sprintf(file_name,"bios_%i.fil",num); if ((fd = open(file_name,O_WRONLY | O_CREAT | O_TRUNC,00644)) == -1) - return; + return; size = (*(unsigned char*)(V_BIOS + 2)) * 512; #ifdef V86BIOS_DEBUG dprint(V_BIOS,20); #endif if ((count = write(fd,(void *)(V_BIOS),size)) != size) - fprintf(stderr,"only saved %i of %i bytes\n",size,count); + fprintf(stderr,"only saved %i of %i bytes\n",size,count); num++; } @@ -511,11 +511,11 @@ setup_int_vect(void) const CARD16 cs = 0x0000; const CARD16 ip = 0x0; int i; - + /* let the int vects point to the SYS_BIOS seg */ for (i=0; i<0x80; i++) { - ((CARD16*)0)[i<<1] = ip; - ((CARD16*)0)[(i<<1)+1] = cs; + ((CARD16*)0)[i<<1] = ip; + ((CARD16*)0)[(i<<1)+1] = cs; } /* video interrupts default location */ ((CARD16*)0)[(0x42<<1)+1] = 0xf000; @@ -566,13 +566,13 @@ setup_system_bios(void) { char *date = "06/01/99"; char *eisa_ident = "PCI/ISA"; - + #if MAP_SYS_BIOS if (!copy_sys_bios()) return 0; return 1; #endif -// memset((void *)0xF0000,0xf4,0xfff7); - +/* memset((void *)0xF0000,0xf4,0xfff7); */ + /* * we trap the "industry standard entry points" to the BIOS * and all other locations by filling them with "hlt" @@ -586,7 +586,7 @@ setup_system_bios(void) * and the font tables (0xfa6e-0xfe6d) * from the original bios here */ - + /* set bios date */ strcpy((char *)0xFFFF5,date); /* set up eisa ident string */ @@ -604,10 +604,10 @@ chksum(CARD8 *start) CARD8 val = 0; int i; - size = *(start+2) * 512; + size = *(start+2) * 512; for (i = 0; i<size; i++) val += *(start + i); - + if (!val) return 1; diff --git a/board/MAI/bios_emulator/scitech/src/v86bios/mem.c b/board/MAI/bios_emulator/scitech/src/v86bios/mem.c index 50dc55fdf5..24c1aef8e5 100644 --- a/board/MAI/bios_emulator/scitech/src/v86bios/mem.c +++ b/board/MAI/bios_emulator/scitech/src/v86bios/mem.c @@ -43,7 +43,7 @@ mem_rb(CARD32 addr) result = *(vuip) ((unsigned long)vram_map + (addr << sparse_shift)); result >>= shift; return 0xffUL & result; - } else + } else #endif return rdb(addr); } @@ -52,15 +52,15 @@ CARD16 mem_rw(CARD32 addr) { unsigned long result, shift; -#if 1 +#if 1 if (addr >= 0xA0000 && addr <= 0xBFFFF) { addr -= 0xA0000; shift = (addr & 0x2) * 8; result = *(vuip)((unsigned long)vram_map+(addr<<sparse_shift) - +(1<<(sparse_shift-2))); + +(1<<(sparse_shift-2))); result >>= shift; return 0xffffUL & result; - } else + } else #endif return rdw(addr); } @@ -69,12 +69,12 @@ CARD32 mem_rl(CARD32 addr) { unsigned long result; -#if 1 +#if 1 if (addr >= 0xA0000 && addr <= 0xBFFFF) { addr -= 0xA0000; result = *(vuip)((unsigned long)vram_map+(addr<<sparse_shift)+(3<<(sparse_shift-2))); return result; - } else + } else #endif return rdl(addr); } @@ -83,12 +83,12 @@ void mem_wb(CARD32 addr, CARD8 val) { unsigned int b = val & 0xffU; -#if 1 +#if 1 if (addr >= 0xA0000 && addr <= 0xBFFFF) { addr -= 0xA0000; *(vuip) ((unsigned long)vram_map + (addr << sparse_shift)) = b * 0x01010101; mem_barrier(); - } else + } else #endif wrb(addr,val); } @@ -97,13 +97,13 @@ void mem_ww(CARD32 addr, CARD16 val) { unsigned int w = val & 0xffffU; -#if 1 +#if 1 if (addr >= 0xA0000 && addr <= 0xBFFFF) { addr -= 0xA0000; *(vuip)((unsigned long)vram_map+(addr<<sparse_shift) - +(1<<(sparse_shift-2))) = w * 0x00010001; + +(1<<(sparse_shift-2))) = w * 0x00010001; mem_barrier(); - } else + } else #endif wrw(addr,val); } @@ -111,16 +111,14 @@ mem_ww(CARD32 addr, CARD16 val) void mem_wl(CARD32 addr, CARD32 val) { -#if 1 +#if 1 if (addr >= 0xA0000 && addr <= 0xBFFFF) { addr -= 0xA0000; *(vuip)((unsigned long)vram_map+(addr<<sparse_shift) - +(3<<(sparse_shift-2))) = val; + +(3<<(sparse_shift-2))) = val; mem_barrier(); - } else + } else #endif wrl(addr,val); } #endif - - diff --git a/board/MAI/bios_emulator/scitech/src/v86bios/pci.c b/board/MAI/bios_emulator/scitech/src/v86bios/pci.c index e68c61d5ef..b58a57195f 100644 --- a/board/MAI/bios_emulator/scitech/src/v86bios/pci.c +++ b/board/MAI/bios_emulator/scitech/src/v86bios/pci.c @@ -51,12 +51,12 @@ int pciMaxBus = 0; static CARD32 PciCfg1Addr; static void readConfigSpaceCfg1(CARD32 bus, CARD32 dev, CARD32 func, - CARD32 *reg); + CARD32 *reg); static int checkSlotCfg1(CARD32 bus, CARD32 dev, CARD32 func); static int checkSlotCfg2(CARD32 bus, int dev); static void readConfigSpaceCfg2(CARD32 bus, int dev, CARD32 *reg); static CARD8 interpretConfigSpace(CARD32 *reg, int busidx, - CARD8 dev, CARD8 func); + CARD8 dev, CARD8 func); static CARD32 findBIOSMap(PciStructPtr pciP, CARD32 *biosSize); static void restoreMem(PciStructPtr pciP); @@ -72,10 +72,10 @@ axpPciCfgRead(CARD32 tag) { int bus, dfn; CARD32 val = 0xffffffff; - + bus = PCI_BUS_FROM_TAG(tag); dfn = PCI_DFN_FROM_TAG(tag); - + syscall(__NR_pciconfig_read, bus, dfn, tag & 0xff, 4, &val); return(val); } @@ -84,10 +84,10 @@ void axpPciCfgWrite(CARD32 tag, CARD32 val) { int bus, dfn; - + bus = PCI_BUS_FROM_TAG(tag); dfn = PCI_DFN_FROM_TAG(tag); - + syscall(__NR_pciconfig_write, bus, dfn, tag & 0xff, 4, &val); } @@ -115,22 +115,21 @@ static int hostbridges = 1; static unsigned long pciMinMemReg = ~0; - void scan_pci(void) { unsigned short configtype; - + CARD32 reg[64]; int busidx; CARD8 cardnum; CARD8 func; int idx; - + int i; PciStructPtr pci1; PciBusPtr pci_b1,pci_b2; - + #if defined(__alpha__) || defined(__powerpc__) || defined(__sparc__) || defined(__ia64__) configtype = 1; #else @@ -141,111 +140,111 @@ scan_pci(void) tmp1 = inb(PCI_MODE2_ENABLE_REG); tmp2 = inb(PCI_MODE2_FORWARD_REG); if ((tmp1 == 0x00) && (tmp2 == 0x00)) { - configtype = 2; - readPci = readPciCfg2; - writePci = writePciCfg2; - P_printf("PCI says configuration type 2\n"); + configtype = 2; + readPci = readPciCfg2; + writePci = writePciCfg2; + P_printf("PCI says configuration type 2\n"); } else { - tmp32_1 = inl(PCI_MODE1_ADDRESS_REG); - outl(PCI_MODE1_ADDRESS_REG, PCI_EN); - tmp32_2 = inl(PCI_MODE1_ADDRESS_REG); - outl(PCI_MODE1_ADDRESS_REG, tmp32_1); - if (tmp32_2 == PCI_EN) { - configtype = 1; - P_printf("PCI says configuration type 1\n"); - } else { - P_printf("No PCI !\n"); - return; - } + tmp32_1 = inl(PCI_MODE1_ADDRESS_REG); + outl(PCI_MODE1_ADDRESS_REG, PCI_EN); + tmp32_2 = inl(PCI_MODE1_ADDRESS_REG); + outl(PCI_MODE1_ADDRESS_REG, tmp32_1); + if (tmp32_2 == PCI_EN) { + configtype = 1; + P_printf("PCI says configuration type 1\n"); + } else { + P_printf("No PCI !\n"); + return; + } } #endif - + if (configtype == 1) { - P_printf("PCI probing configuration type 1\n"); - busidx = 0; - numbus = 1; - idx = 0; - do { - P_printf("\nProbing for devices on PCI bus %d:\n", busidx); - for (cardnum = 0; cardnum < MAX_DEV_PER_VENDOR_CFG1; cardnum++) { - func = 0; - do { - /* loop over the different functions, if present */ - if (!checkSlotCfg1(busidx,cardnum,func)) - break; - readConfigSpaceCfg1(busidx,cardnum,func,reg); - - func = interpretConfigSpace(reg,busidx, - cardnum,func); - - if (idx++ > MAX_PCI_DEVICES) - continue; - } while (func < 8); - } - } while (++busidx < PCI_MAXBUS); + P_printf("PCI probing configuration type 1\n"); + busidx = 0; + numbus = 1; + idx = 0; + do { + P_printf("\nProbing for devices on PCI bus %d:\n", busidx); + for (cardnum = 0; cardnum < MAX_DEV_PER_VENDOR_CFG1; cardnum++) { + func = 0; + do { + /* loop over the different functions, if present */ + if (!checkSlotCfg1(busidx,cardnum,func)) + break; + readConfigSpaceCfg1(busidx,cardnum,func,reg); + + func = interpretConfigSpace(reg,busidx, + cardnum,func); + + if (idx++ > MAX_PCI_DEVICES) + continue; + } while (func < 8); + } + } while (++busidx < PCI_MAXBUS); #if defined(__alpha__) || defined(__powerpc__) || defined(__sparc__) || defined(__ia64__) - /* don't use outl() ;-) */ + /* don't use outl() ;-) */ #else - outl(PCI_MODE1_ADDRESS_REG, 0); + outl(PCI_MODE1_ADDRESS_REG, 0); #endif } else { - int slot; - - P_printf("PCI probing configuration type 2\n"); - busidx = 0; - numbus = 1; - idx = 0; - do { - for (slot=0xc0; slot<0xd0; i++) { - if (!checkSlotCfg2(busidx,slot)) - break; - readConfigSpaceCfg2(busidx,slot,reg); - - interpretConfigSpace(reg,busidx, - slot,0); - if (idx++ > MAX_PCI_DEVICES) - continue; - } - } while (++busidx < PCI_MAXBUS); + int slot; + + P_printf("PCI probing configuration type 2\n"); + busidx = 0; + numbus = 1; + idx = 0; + do { + for (slot=0xc0; slot<0xd0; i++) { + if (!checkSlotCfg2(busidx,slot)) + break; + readConfigSpaceCfg2(busidx,slot,reg); + + interpretConfigSpace(reg,busidx, + slot,0); + if (idx++ > MAX_PCI_DEVICES) + continue; + } + } while (++busidx < PCI_MAXBUS); } - - + + pciMaxBus = numbus - 1; P_printf("Number of buses in system: %i\n",pciMaxBus + 1); P_printf("Min PCI mem address: 0x%lx\n",pciMinMemReg); - + /* link buses */ pci_b1 = PciBuses; while (pci_b1) { - pci_b2 = PciBuses; - pci_b1->pBus = NULL; - while (pci_b2) { - if (pci_b1->primary == pci_b2->secondary) - pci_b1->pBus = pci_b2; - pci_b2 = pci_b2->next; - } - pci_b1 = pci_b1->next; + pci_b2 = PciBuses; + pci_b1->pBus = NULL; + while (pci_b2) { + if (pci_b1->primary == pci_b2->secondary) + pci_b1->pBus = pci_b2; + pci_b2 = pci_b2->next; + } + pci_b1 = pci_b1->next; } pci1 = PciStruct; while (pci1) { - pci_b2 = PciBuses; - pci1->pBus = NULL; - while (pci_b2) { - if (pci1->bus == pci_b2->secondary) - pci1->pBus = pci_b2; - pci_b2 = pci_b2->next; - } - pci1 = pci1->next; + pci_b2 = PciBuses; + pci1->pBus = NULL; + while (pci_b2) { + if (pci1->bus == pci_b2->secondary) + pci1->pBus = pci_b2; + pci_b2 = pci_b2->next; + } + pci1 = pci1->next; } if (RESORT) { - PciStructPtr tmp = PciStruct, tmp1; - PciStruct = NULL; - while (tmp) { - tmp1 = tmp->next; - tmp->next = PciStruct; - PciStruct = tmp; - tmp = tmp1; - } + PciStructPtr tmp = PciStruct, tmp1; + PciStruct = NULL; + while (tmp) { + tmp1 = tmp->next; + tmp->next = PciStruct; + PciStruct = tmp; + tmp = tmp1; + } } PciList = CurrentPci = PciStruct; } @@ -255,7 +254,7 @@ static CARD32 readPciCfg1(CARD32 reg) { CARD32 val; - + outl(PCI_MODE1_ADDRESS_REG, reg); val = inl(PCI_MODE1_DATA_REG); outl(PCI_MODE1_ADDRESS_REG, 0); @@ -279,7 +278,7 @@ readPciCfg2(CARD32 reg) CARD8 bus = (reg >> 16) & 0xff; CARD8 dev = (reg >> 11) & 0x1f; CARD8 num = reg & 0xff; - + outb(PCI_MODE2_ENABLE_REG, 0xF1); outb(PCI_MODE2_FORWARD_REG, bus); val = inl((dev << 8) + num); @@ -309,16 +308,16 @@ pciVideoDisable(void) /* disable VGA routing on bridges */ PciBusPtr pbp = PciBuses; PciStructPtr pcp = PciStruct; - + while (pbp) { - writePci(pbp->Slot.l | 0x3c, pbp->bctl & ~(CARD32)(8<<16)); - pbp = pbp->next; + writePci(pbp->Slot.l | 0x3c, pbp->bctl & ~(CARD32)(8<<16)); + pbp = pbp->next; } /* disable display devices */ while (pcp) { - writePci(pcp->Slot.l | 0x04, pcp->cmd_st & ~(CARD32)3); - writePci(pcp->Slot.l | 0x30, pcp->RomBase & ~(CARD32)1); - pcp = pcp->next; + writePci(pcp->Slot.l | 0x04, pcp->cmd_st & ~(CARD32)3); + writePci(pcp->Slot.l | 0x30, pcp->RomBase & ~(CARD32)1); + pcp = pcp->next; } } @@ -328,16 +327,16 @@ pciVideoRestore(void) /* disable VGA routing on bridges */ PciBusPtr pbp = PciBuses; PciStructPtr pcp = PciStruct; - + while (pbp) { - writePci(pbp->Slot.l | 0x3c, pbp->bctl); - pbp = pbp->next; + writePci(pbp->Slot.l | 0x3c, pbp->bctl); + pbp = pbp->next; } /* disable display devices */ while (pcp) { - writePci(pcp->Slot.l | 0x04, pcp->cmd_st); - writePci(pcp->Slot.l | 0x30, pcp->RomBase); - pcp = pcp->next; + writePci(pcp->Slot.l | 0x04, pcp->cmd_st); + writePci(pcp->Slot.l | 0x30, pcp->RomBase); + pcp = pcp->next; } } @@ -346,13 +345,13 @@ EnableCurrent() { PciBusPtr pbp; PciStructPtr pcp = CurrentPci; - + pciVideoDisable(); - + pbp = pcp->pBus; while (pbp) { /* enable bridges */ - writePci(pbp->Slot.l | 0x3c, pbp->bctl | (CARD32)(8<<16)); - pbp = pbp->pBus; + writePci(pbp->Slot.l | 0x3c, pbp->bctl | (CARD32)(8<<16)); + pbp = pbp->pBus; } writePci(pcp->Slot.l | 0x04, pcp->cmd_st | (CARD32)3); writePci(pcp->Slot.l | 0x30, pcp->RomBase | (CARD32)1); @@ -427,35 +426,35 @@ mapPciRom(PciStructPtr pciP) pciP = CurrentPci; if (FIX_ROM) { - RomBase = findBIOSMap(pciP, &biosSize); - if (!RomBase) { - fprintf(stderr,"Cannot remap BIOS of %i:%i:%i " - "- trying preset address\n",pciP->bus,pciP->dev, - pciP->func); - RomBase = pciP->RomBase & ~(CARD32)0xFF; - } + RomBase = findBIOSMap(pciP, &biosSize); + if (!RomBase) { + fprintf(stderr,"Cannot remap BIOS of %i:%i:%i " + "- trying preset address\n",pciP->bus,pciP->dev, + pciP->func); + RomBase = pciP->RomBase & ~(CARD32)0xFF; + } } else { - RomBase = pciP->RomBase & ~(CARD32)0xFF; - if (~RomBase + 1 < biosSize || !RomBase) - RomBase = findBIOSMap(pciP, &biosSize); + RomBase = pciP->RomBase & ~(CARD32)0xFF; + if (~RomBase + 1 < biosSize || !RomBase) + RomBase = findBIOSMap(pciP, &biosSize); } P_printf("RomBase: 0x%lx\n",RomBase); - + if ((mem_fd = open(MEM_FILE,O_RDONLY))<0) { - perror("opening memory"); - restoreMem(pciP); - return (0); + perror("opening memory"); + restoreMem(pciP); + return (0); } PciWrite32(0x30,RomBase | 1,pciP->Slot.l); #ifdef __alpha__ mem = ptr = (unsigned char *)mmap(0, biosSize, PROT_READ, - MAP_SHARED, mem_fd, RomBase | _bus_base()); + MAP_SHARED, mem_fd, RomBase | _bus_base()); #else mem = ptr = (unsigned char *)mmap(0, biosSize, PROT_READ, - MAP_SHARED, mem_fd, RomBase); + MAP_SHARED, mem_fd, RomBase); #endif if (pciP != CurrentPci) { enablePci = PciRead32(0x4,pciP->Slot.l); @@ -466,37 +465,37 @@ mapPciRom(PciStructPtr pciP) dprint((unsigned long)ptr,0x30); #endif while ( *ptr == 0x55 && *(ptr+1) == 0xAA) { - unsigned short data_off = *(ptr+0x18) | (*(ptr+0x19)<< 8); - unsigned char *data = ptr + data_off; - unsigned char type; - int i; - - if (*data!='P' || *(data+1)!='C' || *(data+2)!='I' || *(data+3)!='R') { - break; - } - type = *(data + 0x14); - P_printf("data segment in BIOS: 0x%x, type: 0x%x ",data_off,type); - - if (type != 0) { /* not PC-AT image: find next one */ - unsigned int image_length; - unsigned char indicator = *(data + 0x15); - if (indicator & 0x80) /* last image */ - break; - image_length = (*(data + 0x10) - | (*(data + 0x11) << 8)) << 9; - P_printf("data image length: 0x%x, ind: 0x%x\n", - image_length,indicator); - ptr = ptr + image_length; - continue; - } - /* OK, we have a PC Image */ - length = (*(ptr + 2) << 9); - P_printf("BIOS length: 0x%x\n",length); - scratch = (unsigned char *)malloc(length); - /* don't use memcpy() here: Reading from bus! */ - for (i=0;i<length;i++) - *(scratch + i)=*(ptr + i); - break; + unsigned short data_off = *(ptr+0x18) | (*(ptr+0x19)<< 8); + unsigned char *data = ptr + data_off; + unsigned char type; + int i; + + if (*data!='P' || *(data+1)!='C' || *(data+2)!='I' || *(data+3)!='R') { + break; + } + type = *(data + 0x14); + P_printf("data segment in BIOS: 0x%x, type: 0x%x ",data_off,type); + + if (type != 0) { /* not PC-AT image: find next one */ + unsigned int image_length; + unsigned char indicator = *(data + 0x15); + if (indicator & 0x80) /* last image */ + break; + image_length = (*(data + 0x10) + | (*(data + 0x11) << 8)) << 9; + P_printf("data image length: 0x%x, ind: 0x%x\n", + image_length,indicator); + ptr = ptr + image_length; + continue; + } + /* OK, we have a PC Image */ + length = (*(ptr + 2) << 9); + P_printf("BIOS length: 0x%x\n",length); + scratch = (unsigned char *)malloc(length); + /* don't use memcpy() here: Reading from bus! */ + for (i=0;i<length;i++) + *(scratch + i)=*(ptr + i); + break; } if (pciP != CurrentPci) @@ -509,10 +508,10 @@ mapPciRom(PciStructPtr pciP) writePci(pciP->Slot.l | 0x30, pciP->RomBase & ~(CARD32)1); if (scratch && length) { - memcpy((unsigned char *)V_BIOS, scratch, length); - free(scratch); + memcpy((unsigned char *)V_BIOS, scratch, length); + free(scratch); } - + restoreMem(pciP); return length; } @@ -523,24 +522,24 @@ findPci(CARD16 slotBX) CARD32 slot = slotBX << 8; if (slot == (CurrentPci->Slot.l & ~PCI_EN)) - return (CurrentPci->Slot.l | PCI_EN); + return (CurrentPci->Slot.l | PCI_EN); else { #if !SHOW_ALL_DEV - PciBusPtr pBus = CurrentPci->pBus; - while (pBus) { - // fprintf(stderr,"slot: 0x%x bridge: 0x%x\n",slot, pBus->Slot.l); - if (slot == (pBus->Slot.l & ~PCI_EN)) - return pBus->Slot.l | PCI_EN; - pBus = pBus->next; - } + PciBusPtr pBus = CurrentPci->pBus; + while (pBus) { + /* fprintf(stderr,"slot: 0x%x bridge: 0x%x\n",slot, pBus->Slot.l); */ + if (slot == (pBus->Slot.l & ~PCI_EN)) + return pBus->Slot.l | PCI_EN; + pBus = pBus->next; + } #else - PciStructPtr pPci = PciStruct; - while (pPci) { - //fprintf(stderr,"slot: 0x%x bridge: 0x%x\n",slot, pPci->Slot.l); - if (slot == (pPci->Slot.l & ~PCI_EN)) - return pPci->Slot.l | PCI_EN; - pPci = pPci->next; - } + PciStructPtr pPci = PciStruct; + while (pPci) { + /*fprintf(stderr,"slot: 0x%x bridge: 0x%x\n",slot, pPci->Slot.l); */ + if (slot == (pPci->Slot.l & ~PCI_EN)) + return pPci->Slot.l | PCI_EN; + pPci = pPci->next; + } #endif } return 0; @@ -559,9 +558,9 @@ findPciDevice(CARD16 vendorID, CARD16 deviceID, char n) n++; while (pPci) { - if ((pPci->VendorID == vendorID) && (pPci->DeviceID == deviceID)) { - if (!(--n)) break; - } + if ((pPci->VendorID == vendorID) && (pPci->DeviceID == deviceID)) { + if (!(--n)) break; + } pPci = pPci->next; } return pPci; @@ -574,10 +573,10 @@ findPciClass(CARD8 intf, CARD8 subClass, CARD16 class, char n) n++; while (pPci) { - if ((pPci->Interface == intf) && (pPci->SubClass == subClass) - && (pPci->BaseClass == class)) { - if (!(--n)) break; - } + if ((pPci->Interface == intf) && (pPci->SubClass == subClass) + && (pPci->BaseClass == class)) { + if (!(--n)) break; + } pPci = pPci->next; } return pPci; @@ -592,14 +591,14 @@ readConfigSpaceCfg1(CARD32 bus, CARD32 dev, CARD32 func, CARD32 *reg) for (i = 0; i<64;i+=4) { #ifdef __alpha__ - reg[i] = axpPciCfgRead(config_cmd | i); + reg[i] = axpPciCfgRead(config_cmd | i); #else - outl(PCI_MODE1_ADDRESS_REG, config_cmd | i); - reg[i] = inl(PCI_MODE1_DATA_REG); + outl(PCI_MODE1_ADDRESS_REG, config_cmd | i); + reg[i] = inl(PCI_MODE1_DATA_REG); #endif #ifdef V86BIOS_DEBUG - P_printf("0x%lx\n",reg[i]); + P_printf("0x%lx\n",reg[i]); #endif } } @@ -611,15 +610,15 @@ checkSlotCfg1(CARD32 bus, CARD32 dev, CARD32 func) (dev<<11) | (func<<8); CARD32 reg; #ifdef __alpha__ - reg = axpPciCfgRead(config_cmd); + reg = axpPciCfgRead(config_cmd); #else - outl(PCI_MODE1_ADDRESS_REG, config_cmd); - reg = inl(PCI_MODE1_DATA_REG); + outl(PCI_MODE1_ADDRESS_REG, config_cmd); + reg = inl(PCI_MODE1_DATA_REG); #endif if (reg != 0xFFFFFFFF) - return 1; + return 1; else - return 0; + return 0; } static int @@ -633,9 +632,9 @@ checkSlotCfg2(CARD32 bus, int dev) outb(PCI_MODE2_FORWARD_REG, 0x00); outb(PCI_MODE2_ENABLE_REG, 0x00); if (val == 0xFFFFFFFF) - return 0; + return 0; if (val == 0xF0F0F0F0) - return 0; + return 0; return 1; } @@ -647,9 +646,9 @@ readConfigSpaceCfg2(CARD32 bus, int dev, CARD32 *reg) outb(PCI_MODE2_ENABLE_REG, 0xF1); outb(PCI_MODE2_FORWARD_REG, bus); for (i = 0; i<64;i+=4) { - reg[i] = inl((dev << 8) + i); + reg[i] = inl((dev << 8) + i); #ifdef V86BIOS_DEBUG - P_printf("0x%lx\n",reg[i]); + P_printf("0x%lx\n",reg[i]); #endif } outb(PCI_MODE2_ENABLE_REG, 0x00); @@ -664,22 +663,22 @@ interpretConfigSpace(CARD32 *reg, int busidx, CARD8 dev, CARD8 func) CARD8 primary, secondary; CARD8 header, interface; int i; - + config_cmd = PCI_EN | busidx<<16 | - (dev<<11) | (func<<8); + (dev<<11) | (func<<8); for (i = 0x10; i < 0x28; i+=4) { - if (IS_MEM32(reg[i])) - if ((reg[i] & 0xFFFFFFF0) < pciMinMemReg) - pciMinMemReg = (reg[i] & 0xFFFFFFF0); + if (IS_MEM32(reg[i])) + if ((reg[i] & 0xFFFFFFF0) < pciMinMemReg) + pciMinMemReg = (reg[i] & 0xFFFFFFF0); #ifdef __alpha__ - if (IS_MEM64(reg[i])) { - unsigned long addr = reg[i] | - (unsigned long)(reg[i+4]) << 32; - if ((addr & ~0xfL) < pciMinMemReg) - pciMinMemReg = (addr & ~0xfL); - i+=4; - } + if (IS_MEM64(reg[i])) { + unsigned long addr = reg[i] | + (unsigned long)(reg[i+4]) << 32; + if ((addr & ~0xfL) < pciMinMemReg) + pciMinMemReg = (addr & ~0xfL); + i+=4; + } #endif } vendor = reg[0] & 0xFFFF; @@ -691,49 +690,49 @@ interpretConfigSpace(CARD32 *reg, int busidx, CARD8 dev, CARD8 func) header = (reg[0x0c] >> 16) & 0xff; P_printf("bc 0x%x, sub 0x%x, if 0x%x, hdr 0x%x\n", - baseclass,subclass,interface,header); + baseclass,subclass,interface,header); if (BRIDGE_CLASS(baseclass)) { - if (BRIDGE_PCI_CLASS(subclass)) { - PciBusPtr pbp = malloc(sizeof(PciBusRec)); - P_printf("Pci-Pci Bridge found; "); - primary = reg[0x18] & 0xFF; - secondary = (reg[0x18] >> 8) & 0xFF; - P_printf("primary: 0x%x secondary: 0x%x\n", - primary,secondary); - pbp->bctl = reg[0x3c]; - pbp->primary = primary; - pbp->secondary = secondary; - pbp->Slot.l = config_cmd; - pbp->next = PciBuses; - PciBuses = pbp; - numbus++; - } else if (BRIDGE_HOST_CLASS(subclass) - && (hostbridges++ > 1)) { - numbus++; - } + if (BRIDGE_PCI_CLASS(subclass)) { + PciBusPtr pbp = malloc(sizeof(PciBusRec)); + P_printf("Pci-Pci Bridge found; "); + primary = reg[0x18] & 0xFF; + secondary = (reg[0x18] >> 8) & 0xFF; + P_printf("primary: 0x%x secondary: 0x%x\n", + primary,secondary); + pbp->bctl = reg[0x3c]; + pbp->primary = primary; + pbp->secondary = secondary; + pbp->Slot.l = config_cmd; + pbp->next = PciBuses; + PciBuses = pbp; + numbus++; + } else if (BRIDGE_HOST_CLASS(subclass) + && (hostbridges++ > 1)) { + numbus++; + } } else if (VIDEO_CLASS(baseclass,subclass)) { - PciStructPtr pcp = malloc(sizeof(PciStructRec)); - P_printf("Display adapter found\n"); - pcp->RomBase = reg[0x30]; - pcp->cmd_st = reg[4]; - pcp->active = (reg[4] & 0x03) == 3 ? 1 : 0; - pcp->VendorID = vendor; - pcp->DeviceID = device; - pcp->Interface = interface; - pcp->BaseClass = baseclass; - pcp->SubClass = subclass; - pcp->Slot.l = config_cmd; - pcp->bus = busidx; - pcp->dev = dev; - pcp->func = func; - pcp->next = PciStruct; - PciStruct = pcp; + PciStructPtr pcp = malloc(sizeof(PciStructRec)); + P_printf("Display adapter found\n"); + pcp->RomBase = reg[0x30]; + pcp->cmd_st = reg[4]; + pcp->active = (reg[4] & 0x03) == 3 ? 1 : 0; + pcp->VendorID = vendor; + pcp->DeviceID = device; + pcp->Interface = interface; + pcp->BaseClass = baseclass; + pcp->SubClass = subclass; + pcp->Slot.l = config_cmd; + pcp->bus = busidx; + pcp->dev = dev; + pcp->func = func; + pcp->next = PciStruct; + PciStruct = pcp; } if ((func == 0) - && ((header & PCI_MULTIFUNC_DEV) == 0)) - func = 8; + && ((header & PCI_MULTIFUNC_DEV) == 0)) + func = 8; else - func++; + func++; return func; } @@ -748,36 +747,36 @@ remapMem(PciStructPtr pciP, int num, CARD32 size) CARD32 org; CARD32 val; CARD32 size_n; - + org = PciRead32(num + 0x10,pciP->Slot.l); - + while (pciPtr) { - for (i = 0; i < 20; i=i+4) { - - val = PciRead32(i + 0x10,pciPtr->Slot.l); - /* don't map it on itself */ - if ((org & 0xfffffff0) == (val & 0xfffffff0)) - continue; - if (val && !(val & 1)) - PciWrite32(i + 0x10,0xffffffff,pciPtr->Slot.l); - else - continue; - size_n = PciRead32(i + 0x10,pciPtr->Slot.l); - PciWrite32(i + 0x10,val,pciPtr->Slot.l); - size_n = ~(CARD32)(size_n & 0xfffffff0) + 1; - - if (size_n >= size) { - PciWrite32(num + 0x10,val,pciP->Slot.l); - return 1; - } - } - pciPtr = pciPtr->next; + for (i = 0; i < 20; i=i+4) { + + val = PciRead32(i + 0x10,pciPtr->Slot.l); + /* don't map it on itself */ + if ((org & 0xfffffff0) == (val & 0xfffffff0)) + continue; + if (val && !(val & 1)) + PciWrite32(i + 0x10,0xffffffff,pciPtr->Slot.l); + else + continue; + size_n = PciRead32(i + 0x10,pciPtr->Slot.l); + PciWrite32(i + 0x10,val,pciPtr->Slot.l); + size_n = ~(CARD32)(size_n & 0xfffffff0) + 1; + + if (size_n >= size) { + PciWrite32(num + 0x10,val,pciP->Slot.l); + return 1; + } + } + pciPtr = pciPtr->next; } /* last resort: try to go below lowest PCI mem address */ val = ((pciMinMemReg & ~(CARD32)(size - 1)) - size); if (val > 0x7fffffff) { - PciWrite32(num + 0x10,val, pciP->Slot.l); - return 1; + PciWrite32(num + 0x10,val, pciP->Slot.l); + return 1; } return 0; @@ -798,7 +797,7 @@ findBIOSMap(PciStructPtr pciP, CARD32 *biosSize) int i; CARD32 val; CARD32 size; - + PciWrite32(0x30,0xffffffff,pciP->Slot.l); *biosSize = PciRead32(0x30,pciP->Slot.l); P_printf("bios size: 0x%x\n",*biosSize); @@ -810,43 +809,43 @@ findBIOSMap(PciStructPtr pciP, CARD32 *biosSize) P_printf("fixing broken BIOS size: 0x%x\n",*biosSize); } while (pciPtr) { - if (pciPtr->bus != pciP->bus) { - pciPtr = pciPtr->next; - continue; - } - for (i = 0; i < 20; i=i+4) { - - val = PciRead32(i + 0x10,pciPtr->Slot.l); - if (!(val & 1)) - - PciWrite32(i + 0x10,0xffffffff,pciPtr->Slot.l); - else - continue; - size = PciRead32(i + 0x10,pciPtr->Slot.l); - PciWrite32(i + 0x10,val,pciPtr->Slot.l); - size = ~(CARD32)(size & 0xFFFFFFF0) + 1; + if (pciPtr->bus != pciP->bus) { + pciPtr = pciPtr->next; + continue; + } + for (i = 0; i < 20; i=i+4) { + + val = PciRead32(i + 0x10,pciPtr->Slot.l); + if (!(val & 1)) + + PciWrite32(i + 0x10,0xffffffff,pciPtr->Slot.l); + else + continue; + size = PciRead32(i + 0x10,pciPtr->Slot.l); + PciWrite32(i + 0x10,val,pciPtr->Slot.l); + size = ~(CARD32)(size & 0xFFFFFFF0) + 1; #ifdef V86_BIOS_DEBUG - P_printf("size: 0x%x\n",size); + P_printf("size: 0x%x\n",size); #endif - if (size >= *biosSize) { - if (pciP == pciPtr) { /* if same device remap ram*/ - if (!(remapMem(pciP,i,size))) - continue; - remapMEM_val = val; - remapMEM_num = i; - } else { - remapMEM_val = 0; - } - return val & 0xFFFFFF00; - } - } - pciPtr = pciPtr->next; + if (size >= *biosSize) { + if (pciP == pciPtr) { /* if same device remap ram*/ + if (!(remapMem(pciP,i,size))) + continue; + remapMEM_val = val; + remapMEM_num = i; + } else { + remapMEM_val = 0; + } + return val & 0xFFFFFF00; + } + } + pciPtr = pciPtr->next; } remapMEM_val = 0; /* very last resort */ - if (pciP->bus == 0 && (pciMinMemReg > *biosSize)) + if (pciP->bus == 0 && (pciMinMemReg > *biosSize)) return (pciMinMemReg - size) & ~(size - 1); - + return 0; } @@ -863,7 +862,7 @@ cfg1out(CARD16 addr, CARD32 val) return 0; } -int +int cfg1in(CARD16 addr, CARD32 *val) { if (addr == 0xCF8) { @@ -883,8 +882,8 @@ list_pci(void) while (pci) { printf("[0x%x:0x%x:0x%x] vendor: 0x%4.4x dev: 0x%4.4x class: 0x%4.4x" - " subclass: 0x%4.4x\n",pci->bus,pci->dev,pci->func, - pci->VendorID,pci->DeviceID,pci->BaseClass,pci->SubClass); + " subclass: 0x%4.4x\n",pci->bus,pci->dev,pci->func, + pci->VendorID,pci->DeviceID,pci->BaseClass,pci->SubClass); pci = pci->next; } } @@ -893,7 +892,7 @@ PciStructPtr findPciByIDs(int bus, int dev, int func) { PciStructPtr pciP = PciList; - + while (pciP) { if (pciP->bus == bus && pciP->dev == dev && pciP->func == func) return pciP; diff --git a/board/MAI/bios_emulator/scitech/src/v86bios/pci.h b/board/MAI/bios_emulator/scitech/src/v86bios/pci.h index 0ab7363df2..58ad52202e 100644 --- a/board/MAI/bios_emulator/scitech/src/v86bios/pci.h +++ b/board/MAI/bios_emulator/scitech/src/v86bios/pci.h @@ -26,13 +26,13 @@ typedef union { struct { - unsigned int zero:2; - unsigned int reg:6; - unsigned int func:3; - unsigned int dev:5; - unsigned int bus:8; - unsigned int reserved:7; - unsigned int enable:1; + unsigned int zero:2; + unsigned int reg:6; + unsigned int func:3; + unsigned int dev:5; + unsigned int bus:8; + unsigned int reserved:7; + unsigned int enable:1; } pci; CARD32 l; } PciSlot; diff --git a/board/MAI/bios_emulator/scitech/src/v86bios/v86.c b/board/MAI/bios_emulator/scitech/src/v86bios/v86.c index 3170a9cb55..4deed044cb 100644 --- a/board/MAI/bios_emulator/scitech/src/v86bios/v86.c +++ b/board/MAI/bios_emulator/scitech/src/v86bios/v86.c @@ -46,14 +46,14 @@ static int vm86_rep(struct vm86_struct *ptr); #define CPU_REG_HW(reg) (*((CARD16 *)&CPU_REG(reg) + 1)) #define CPU_REG_LB(reg) (*(CARD8 *)&CPU_REG(e##reg)) #define SEG_ADR(type, seg, reg) type((CPU_REG_LW(seg) << 4) \ - + CPU_REG_LW(e##reg)) + + CPU_REG_LW(e##reg)) #define DF (1 << 10) struct pio P; void -setup_io(void) +setup_io(void) { if (!Config.PrintPort && !Config.IoStatistics) { P.inb = (CARD8(*)(CARD16))inb; @@ -72,13 +72,13 @@ setup_io(void) } } - + static void setup_vm86(unsigned long bios_start, i86biosRegsPtr regs) { CARD32 eip; CARD16 cs; - + vm86s.flags = VM86_SCREEN_BITMAP; vm86s.flags = 0; vm86s.screen_bitmap = 0; @@ -88,7 +88,7 @@ setup_vm86(unsigned long bios_start, i86biosRegsPtr regs) eip = bios_start & 0xFFFF; cs = (bios_start & 0xFF0000) >> 4; - + CPU_REG(eax) = regs->ax; CPU_REG(ebx) = regs->bx; CPU_REG(ecx) = regs->cx; @@ -97,7 +97,7 @@ setup_vm86(unsigned long bios_start, i86biosRegsPtr regs) CPU_REG(edi) = regs->di; CPU_REG(ebp) = 0; CPU_REG(eip) = eip; - CPU_REG(cs) = cs; + CPU_REG(cs) = cs; CPU_REG(esp) = 0x100; CPU_REG(ss) = 0x30; /* This is the standard pc bios stack */ CPU_REG(es) = regs->es; @@ -124,44 +124,44 @@ static int do_vm86(void) { int retval; - + #ifdef V86BIOS_DEBUG dump_registers(); #endif -// retval = SYS_vm86old(&vm86s); -// retval = syscall(SYS_vm86old,&vm86s); +/* retval = SYS_vm86old(&vm86s); */ +/* retval = syscall(SYS_vm86old,&vm86s); */ retval = vm86_rep(&vm86s); - + switch (VM86_TYPE(retval)) { case VM86_UNKNOWN: - if (!vm86_GP_fault()) return 0; - break; + if (!vm86_GP_fault()) return 0; + break; case VM86_STI: - fprintf(stderr,"vm86_sti :-((\n"); - stack_trace(); - dump_code(); - return 0; + fprintf(stderr,"vm86_sti :-((\n"); + stack_trace(); + dump_code(); + return 0; case VM86_INTx: - if (!vm86_do_int(VM86_ARG(retval))) { - fprintf(stderr,"\nUnknown vm86_int: %X\n\n",VM86_ARG(retval)); - dump_registers(); - return 0; - } - /* I'm not sure yet what to do if we can handle ints */ - break; + if (!vm86_do_int(VM86_ARG(retval))) { + fprintf(stderr,"\nUnknown vm86_int: %X\n\n",VM86_ARG(retval)); + dump_registers(); + return 0; + } + /* I'm not sure yet what to do if we can handle ints */ + break; case VM86_SIGNAL: - fprintf(stderr,"received signal\n"); - return 0; + fprintf(stderr,"received signal\n"); + return 0; default: - fprintf(stderr,"unknown type(0x%x)=0x%x\n", - VM86_ARG(retval),VM86_TYPE(retval)); - dump_registers(); - dump_code(); - stack_trace(); - return 0; + fprintf(stderr,"unknown type(0x%x)=0x%x\n", + VM86_ARG(retval),VM86_TYPE(retval)); + dump_registers(); + dump_code(); + stack_trace(); + return 0; } - + return 1; } @@ -176,17 +176,17 @@ void do_x86(unsigned long bios_start, i86biosRegsPtr regs) { static void (*org_handler)(int); - + setup_vm86(bios_start, regs); if (setjmp(x86_esc) == 0) { - org_handler = signal(2,vmexit); - while(do_vm86()) {}; - signal(2,org_handler); - collect_bios_regs(regs); + org_handler = signal(2,vmexit); + while(do_vm86()) {}; + signal(2,org_handler); + collect_bios_regs(regs); } else { - signal(2,org_handler); - printf("interrupted at 0x%x\n",((CARD16)CPU_REG(cs)) << 4 - | (CARD16)CPU_REG(eip)); + signal(2,org_handler); + printf("interrupted at 0x%x\n",((CARD16)CPU_REG(cs)) << 4 + | (CARD16)CPU_REG(eip)); } } @@ -217,19 +217,19 @@ vm86_GP_fault(void) /* eat up prefixes */ done = 0; do { - switch (*(csp++)) { - case 0x66: /* operand prefix */ prefix66=1; break; - case 0x67: /* address prefix */ prefix67=1; break; - case 0x2e: /* CS */ pref_seg=CPU_REG(cs); break; - case 0x3e: /* DS */ pref_seg=CPU_REG(ds); break; - case 0x26: /* ES */ pref_seg=CPU_REG(es); break; - case 0x36: /* SS */ pref_seg=CPU_REG(ss); break; - case 0x65: /* GS */ pref_seg=CPU_REG(gs); break; - case 0x64: /* FS */ pref_seg=CPU_REG(fs); break; - case 0xf2: /* repnz */ - case 0xf3: /* rep */ is_rep=1; break; - default: done=1; - } + switch (*(csp++)) { + case 0x66: /* operand prefix */ prefix66=1; break; + case 0x67: /* address prefix */ prefix67=1; break; + case 0x2e: /* CS */ pref_seg=CPU_REG(cs); break; + case 0x3e: /* DS */ pref_seg=CPU_REG(ds); break; + case 0x26: /* ES */ pref_seg=CPU_REG(es); break; + case 0x36: /* SS */ pref_seg=CPU_REG(ss); break; + case 0x65: /* GS */ pref_seg=CPU_REG(gs); break; + case 0x64: /* FS */ pref_seg=CPU_REG(fs); break; + case 0xf2: /* repnz */ + case 0xf3: /* rep */ is_rep=1; break; + default: done=1; + } } while (!done); csp--; /* oops one too many */ org_eip = CPU_REG(eip); @@ -238,125 +238,125 @@ vm86_GP_fault(void) switch (*csp) { case 0x6c: /* insb */ - /* NOTE: ES can't be overwritten; prefixes 66,67 should use esi,edi,ecx - * but is anyone using extended regs in real mode? */ - /* WARNING: no test for DI wrapping! */ - CPU_REG_LW(edi) += port_rep_inb(CPU_REG_LW(edx), - SEG_ADR((CARD8 *),es,di), - CPU_REG_LW(eflags)&DF, - (is_rep? LWECX:1)); - if (is_rep) LWECX = 0; - CPU_REG_LW(eip)++; - break; + /* NOTE: ES can't be overwritten; prefixes 66,67 should use esi,edi,ecx + * but is anyone using extended regs in real mode? */ + /* WARNING: no test for DI wrapping! */ + CPU_REG_LW(edi) += port_rep_inb(CPU_REG_LW(edx), + SEG_ADR((CARD8 *),es,di), + CPU_REG_LW(eflags)&DF, + (is_rep? LWECX:1)); + if (is_rep) LWECX = 0; + CPU_REG_LW(eip)++; + break; case 0x6d: /* (rep) insw / insd */ - /* NOTE: ES can't be overwritten */ - /* WARNING: no test for _DI wrapping! */ - if (prefix66) { - CPU_REG_LW(edi) += port_rep_inl(CPU_REG_LW(edx), - SEG_ADR((CARD32 *),es,di), - CPU_REG_LW(eflags)&DF, - (is_rep? LWECX:1)); - } - else { - CPU_REG_LW(edi) += port_rep_inw(CPU_REG_LW(edx), - SEG_ADR((CARD16 *),es,di), - CPU_REG_LW(eflags)&DF, - (is_rep? LWECX:1)); - } - if (is_rep) LWECX = 0; - CPU_REG_LW(eip)++; - break; + /* NOTE: ES can't be overwritten */ + /* WARNING: no test for _DI wrapping! */ + if (prefix66) { + CPU_REG_LW(edi) += port_rep_inl(CPU_REG_LW(edx), + SEG_ADR((CARD32 *),es,di), + CPU_REG_LW(eflags)&DF, + (is_rep? LWECX:1)); + } + else { + CPU_REG_LW(edi) += port_rep_inw(CPU_REG_LW(edx), + SEG_ADR((CARD16 *),es,di), + CPU_REG_LW(eflags)&DF, + (is_rep? LWECX:1)); + } + if (is_rep) LWECX = 0; + CPU_REG_LW(eip)++; + break; case 0x6e: /* (rep) outsb */ - if (pref_seg < 0) pref_seg = CPU_REG_LW(ds); - /* WARNING: no test for _SI wrapping! */ - CPU_REG_LW(esi) += port_rep_outb(CPU_REG_LW(edx),(CARD8*)LIN_PREF_SI, - CPU_REG_LW(eflags)&DF, - (is_rep? LWECX:1)); - if (is_rep) LWECX = 0; - CPU_REG_LW(eip)++; - break; + if (pref_seg < 0) pref_seg = CPU_REG_LW(ds); + /* WARNING: no test for _SI wrapping! */ + CPU_REG_LW(esi) += port_rep_outb(CPU_REG_LW(edx),(CARD8*)LIN_PREF_SI, + CPU_REG_LW(eflags)&DF, + (is_rep? LWECX:1)); + if (is_rep) LWECX = 0; + CPU_REG_LW(eip)++; + break; case 0x6f: /* (rep) outsw / outsd */ - if (pref_seg < 0) pref_seg = CPU_REG_LW(ds); - /* WARNING: no test for _SI wrapping! */ - if (prefix66) { - CPU_REG_LW(esi) += port_rep_outl(CPU_REG_LW(edx), - (CARD32 *)LIN_PREF_SI, - CPU_REG_LW(eflags)&DF, - (is_rep? LWECX:1)); - } - else { - CPU_REG_LW(esi) += port_rep_outw(CPU_REG_LW(edx), - (CARD16 *)LIN_PREF_SI, - CPU_REG_LW(eflags)&DF, - (is_rep? LWECX:1)); - } - if (is_rep) LWECX = 0; - CPU_REG_LW(eip)++; - break; + if (pref_seg < 0) pref_seg = CPU_REG_LW(ds); + /* WARNING: no test for _SI wrapping! */ + if (prefix66) { + CPU_REG_LW(esi) += port_rep_outl(CPU_REG_LW(edx), + (CARD32 *)LIN_PREF_SI, + CPU_REG_LW(eflags)&DF, + (is_rep? LWECX:1)); + } + else { + CPU_REG_LW(esi) += port_rep_outw(CPU_REG_LW(edx), + (CARD16 *)LIN_PREF_SI, + CPU_REG_LW(eflags)&DF, + (is_rep? LWECX:1)); + } + if (is_rep) LWECX = 0; + CPU_REG_LW(eip)++; + break; case 0xe5: /* inw xx, inl xx */ - if (prefix66) CPU_REG(eax) = P.inl((int) csp[1]); - else CPU_REG_LW(eax) = P.inw((int) csp[1]); - CPU_REG_LW(eip) += 2; - break; + if (prefix66) CPU_REG(eax) = P.inl((int) csp[1]); + else CPU_REG_LW(eax) = P.inw((int) csp[1]); + CPU_REG_LW(eip) += 2; + break; case 0xe4: /* inb xx */ - CPU_REG_LW(eax) &= ~(CARD32)0xff; - CPU_REG_LB(ax) |= P.inb((int) csp[1]); - CPU_REG_LW(eip) += 2; - break; + CPU_REG_LW(eax) &= ~(CARD32)0xff; + CPU_REG_LB(ax) |= P.inb((int) csp[1]); + CPU_REG_LW(eip) += 2; + break; case 0xed: /* inw dx, inl dx */ - if (prefix66) CPU_REG(eax) = P.inl(CPU_REG_LW(edx)); - else CPU_REG_LW(eax) = P.inw(CPU_REG_LW(edx)); - CPU_REG_LW(eip) += 1; - break; + if (prefix66) CPU_REG(eax) = P.inl(CPU_REG_LW(edx)); + else CPU_REG_LW(eax) = P.inw(CPU_REG_LW(edx)); + CPU_REG_LW(eip) += 1; + break; case 0xec: /* inb dx */ - CPU_REG_LW(eax) &= ~(CARD32)0xff; - CPU_REG_LB(ax) |= P.inb(CPU_REG_LW(edx)); - CPU_REG_LW(eip) += 1; - break; + CPU_REG_LW(eax) &= ~(CARD32)0xff; + CPU_REG_LB(ax) |= P.inb(CPU_REG_LW(edx)); + CPU_REG_LW(eip) += 1; + break; case 0xe7: /* outw xx */ - if (prefix66) P.outl((int)csp[1], CPU_REG(eax)); - else P.outw((int)csp[1], CPU_REG_LW(eax)); - CPU_REG_LW(eip) += 2; - break; + if (prefix66) P.outl((int)csp[1], CPU_REG(eax)); + else P.outw((int)csp[1], CPU_REG_LW(eax)); + CPU_REG_LW(eip) += 2; + break; case 0xe6: /* outb xx */ - P.outb((int) csp[1], CPU_REG_LB(ax)); - CPU_REG_LW(eip) += 2; - break; + P.outb((int) csp[1], CPU_REG_LB(ax)); + CPU_REG_LW(eip) += 2; + break; case 0xef: /* outw dx */ - if (prefix66) P.outl(CPU_REG_LW(edx), CPU_REG(eax)); - else P.outw(CPU_REG_LW(edx), CPU_REG_LW(eax)); - CPU_REG_LW(eip) += 1; - break; + if (prefix66) P.outl(CPU_REG_LW(edx), CPU_REG(eax)); + else P.outw(CPU_REG_LW(edx), CPU_REG_LW(eax)); + CPU_REG_LW(eip) += 1; + break; case 0xee: /* outb dx */ - P.outb(CPU_REG_LW(edx), CPU_REG_LB(ax)); - CPU_REG_LW(eip) += 1; - break; + P.outb(CPU_REG_LW(edx), CPU_REG_LB(ax)); + CPU_REG_LW(eip) += 1; + break; case 0xf4: #ifdef V86BIOS_DEBUG - printf("hlt at %p\n", lina); + printf("hlt at %p\n", lina); #endif - return 0; + return 0; - case 0x0f: - fprintf(stderr,"CPU 0x0f Trap at eip=0x%lx\n",CPU_REG(eip)); - goto op0ferr; - break; + case 0x0f: + fprintf(stderr,"CPU 0x0f Trap at eip=0x%lx\n",CPU_REG(eip)); + goto op0ferr; + break; case 0xf0: /* lock */ default: - fprintf(stderr,"unknown reason for exception\n"); - dump_registers(); - stack_trace(); + fprintf(stderr,"unknown reason for exception\n"); + dump_registers(); + stack_trace(); op0ferr: - dump_code(); - fprintf(stderr,"cannot continue\n"); - return 0; + dump_code(); + fprintf(stderr,"cannot continue\n"); + return 0; } /* end of switch() */ return 1; } @@ -369,16 +369,16 @@ vm86_do_int(int num) i_printf("int 0x%x received: ax:0x%lx",num,CPU_REG(eax)); if (Config.PrintIp) - i_printf(" at: 0x%x\n",getIP()); + i_printf(" at: 0x%x\n",getIP()); else - i_printf("\n"); + i_printf("\n"); /* try to run bios interrupt */ - + /* if not installed fall back */ #define COPY(x) regs.##x = CPU_REG(x) #define COPY_R(x) CPU_REG(x) = regs.##x - + COPY(eax); COPY(ebx); COPY(ecx); @@ -397,9 +397,9 @@ vm86_do_int(int num) COPY(eflags); if (!(val = int_handler(num,®s))) - if (!(val = run_bios_int(num,®s))) - return val; - + if (!(val = run_bios_int(num,®s))) + return val; + COPY_R(eax); COPY_R(ebx); COPY_R(ecx); @@ -429,11 +429,11 @@ dump_code(void) unsigned char *lina = SEG_ADR((unsigned char *), cs, ip); fprintf(stderr,"code at 0x%8.8x: ",(CARD32)lina); - for (i=0; i<0x10; i++) - fprintf(stderr,"%2.2x ",*(lina + i)); + for (i=0; i<0x10; i++) + fprintf(stderr,"%2.2x ",*(lina + i)); fprintf(stderr,"\n "); - for (; i<0x20; i++) - fprintf(stderr,"%2.2x ",*(lina + i)); + for (; i<0x20; i++) + fprintf(stderr,"%2.2x ",*(lina + i)); fprintf(stderr,"\n"); } @@ -466,41 +466,41 @@ static void stack_trace(void) { int i; - unsigned char *stack = SEG_ADR((unsigned char *), ss, sp); + unsigned char *stack = SEG_ADR((unsigned char *), ss, sp); fprintf(stderr,"stack at 0x%8.8lx:\n",(unsigned long)stack); - for (i=0; i < 0x10; i++) - fprintf(stderr,"%2.2x ",*(stack + i)); + for (i=0; i < 0x10; i++) + fprintf(stderr,"%2.2x ",*(stack + i)); fprintf(stderr,"\n"); - + } static int -vm86_rep(struct vm86_struct *ptr) +vm86_rep(struct vm86_struct *ptr) { int __res; __asm__ __volatile__("int $0x80\n" - :"=a" (__res):"a" ((int)113), - "b" ((struct vm86_struct *)ptr)); - - if ((__res) < 0) { - errno = -__res; - __res=-1; - } - else errno = 0; - return __res; + :"=a" (__res):"a" ((int)113), + "b" ((struct vm86_struct *)ptr)); + + if ((__res) < 0) { + errno = -__res; + __res=-1; + } + else errno = 0; + return __res; } #define pushw(base, ptr, val) \ __asm__ __volatile__( \ - "decw %w0\n\t" \ - "movb %h2,(%1,%0)\n\t" \ - "decw %w0\n\t" \ - "movb %b2,(%1,%0)" \ - : "=r" (ptr) \ - : "r" (base), "q" (val), "0" (ptr)) + "decw %w0\n\t" \ + "movb %h2,(%1,%0)\n\t" \ + "decw %w0\n\t" \ + "movb %b2,(%1,%0)" \ + : "=r" (ptr) \ + : "r" (base), "q" (val), "0" (ptr)) int run_bios_int(int num, struct regs86 *regs) @@ -515,25 +515,25 @@ run_bios_int(int num, struct regs86 *regs) /* check if bios vector is initialized */ if (((CARD16*)0)[(num<<1)+1] == 0x0000) { /* SYS_BIOS_SEG ?*/ #ifdef V86BIOS_DEBUG - i_printf("card BIOS not loaded\n"); + i_printf("card BIOS not loaded\n"); #endif - return 0; + return 0; } - + #ifdef V86BIOS_DEBUG if (firsttime) { - dprint(0,0x3D0); - firsttime = 0; + dprint(0,0x3D0); + firsttime = 0; } #endif - + i_printf("calling card BIOS at: "); ssp = (CARD16*)(CPU_REG(ss)<<4); sp = (CARD32) CPU_REG_LW(esp); eflags = regs->eflags; eflags = ((eflags & VIF_MASK) != 0) - ? (eflags | IF_MASK) : (eflags & ~(CARD32) IF_MASK); + ? (eflags | IF_MASK) : (eflags & ~(CARD32) IF_MASK); pushw(ssp, sp, eflags); pushw(ssp, sp, regs->cs); pushw(ssp, sp, (CARD16)regs->eip); @@ -545,7 +545,7 @@ run_bios_int(int num, struct regs86 *regs) dump_code(); #endif regs->eflags = regs->eflags - & ~(VIF_MASK | TF_MASK | IF_MASK | NT_MASK); + & ~(VIF_MASK | TF_MASK | IF_MASK | NT_MASK); return 1; } diff --git a/board/MAI/bios_emulator/scitech/src/v86bios/v86bios.c b/board/MAI/bios_emulator/scitech/src/v86bios/v86bios.c index 7a3fb36655..101c1f26e6 100644 --- a/board/MAI/bios_emulator/scitech/src/v86bios/v86bios.c +++ b/board/MAI/bios_emulator/scitech/src/v86bios/v86bios.c @@ -48,12 +48,12 @@ #define BIOS_START 0x7C00 /* default BIOS entry */ #define BIOS_MEM 0x600 -//CARD8 code[] = { 0xb8 , 0xf0 , 0xf0, 0xf4 }; +/*CARD8 code[] = { 0xb8 , 0xf0 , 0xf0, 0xf4 }; */ #define VB_X(x) (V_BIOS >> x) & 0xFF CARD8 code[] = { 6, 0x9a, 0x03, 0x00, 0x00, VB_X(12), 0xf4 }; -//CARD8 code[] = { 0x9a, 0x03, 0x00, 0x00, VB_X(12), 0xb8, 0x03, 0x00, -//0xcd, 0x10, 0xf4 }; -//CARD8 code[] = { 0xb8 , 0xf0 , 0xf0 ,0xf4 }; +/*CARD8 code[] = { 0x9a, 0x03, 0x00, 0x00, VB_X(12), 0xb8, 0x03, 0x00, */ +/*0xcd, 0x10, 0xf4 }; */ +/*CARD8 code[] = { 0xb8 , 0xf0 , 0xf0 ,0xf4 }; */ int ioperm_list[IOPERM_BITS] = {0,}; @@ -97,87 +97,87 @@ struct config Config; int main(int argc,char **argv) { int c; - + Config.PrintPort = PRINT_PORT; Config.IoStatistics = IO_STATISTICS; Config.PrintIrq = PRINT_IRQ; Config.PrintPci = PRINT_PCI; - Config.ShowAllDev = SHOW_ALL_DEV; - Config.PrintIp = PRINT_IP; - Config.SaveBios = SAVE_BIOS; - Config.Trace = TRACE; + Config.ShowAllDev = SHOW_ALL_DEV; + Config.PrintIp = PRINT_IP; + Config.SaveBios = SAVE_BIOS; + Config.Trace = TRACE; Config.ConfigActiveOnly = CONFIG_ACTIVE_ONLY; /* boot */ Config.ConfigActiveDevice = CONFIG_ACTIVE_DEVICE; /* boot */ - Config.MapSysBios = MAP_SYS_BIOS; - Config.Resort = RESORT; /* boot */ - Config.FixRom = FIX_ROM; + Config.MapSysBios = MAP_SYS_BIOS; + Config.Resort = RESORT; /* boot */ + Config.FixRom = FIX_ROM; Config.NoConsole = NO_CONSOLE; Config.BootOnly = FALSE; Config.Verbose = VERBOSE; - - opterr = 0; + + opterr = 0; while ((c = getopt(argc,argv,"psicaPStAdbrfnv:?")) != EOF) { switch(c) { case 'p': - Config.PrintPort = TRUE; - break; + Config.PrintPort = TRUE; + break; case 's': - Config.IoStatistics = TRUE; - break; + Config.IoStatistics = TRUE; + break; case 'i': - Config.PrintIrq = TRUE; - break; + Config.PrintIrq = TRUE; + break; case 'c': - Config.PrintPci = TRUE; - break; + Config.PrintPci = TRUE; + break; case 'a': - Config.ShowAllDev = TRUE; - break; + Config.ShowAllDev = TRUE; + break; case 'P': - Config.PrintIp = TRUE; - break; + Config.PrintIp = TRUE; + break; case 'S': - Config.SaveBios = TRUE; - break; + Config.SaveBios = TRUE; + break; case 't': - Config.Trace = TRUE; - break; + Config.Trace = TRUE; + break; case 'A': - Config.ConfigActiveOnly = TRUE; - break; + Config.ConfigActiveOnly = TRUE; + break; case 'd': - Config.ConfigActiveDevice = TRUE; - break; + Config.ConfigActiveDevice = TRUE; + break; case 'b': - Config.MapSysBios = TRUE; - break; + Config.MapSysBios = TRUE; + break; case 'r': - Config.Resort = TRUE; - break; + Config.Resort = TRUE; + break; case 'f': - Config.FixRom = TRUE; - break; + Config.FixRom = TRUE; + break; case 'n': - Config.NoConsole = TRUE; - break; + Config.NoConsole = TRUE; + break; case 'v': - Config.Verbose = strtol(optarg,NULL,0); - break; + Config.Verbose = strtol(optarg,NULL,0); + break; case '?': - print_usage(); - break; + print_usage(); + break; default: - break; + break; } } - - + + if (!map()) exit(1); - + if (!setup_system_bios()) exit(1); - + iopl(3); scan_pci(); @@ -188,23 +188,23 @@ int main(int argc,char **argv) save_pos102 = inb(0x102); if (Config.BootOnly) { - + if (!CurrentPci && !Config.ConfigActiveDevice - && !Config.ConfigActiveOnly) { - iopl(0); - unmap(); - exit (1); + && !Config.ConfigActiveOnly) { + iopl(0); + unmap(); + exit (1); } call_boot(NULL); } else { using_history(); yyparse(); } - + unmap(); pciVideoRestore(); - + outb(0x102, save_pos102); outb(0x46e8, save_46e8); outb(0x3C3, save_vse); @@ -223,139 +223,139 @@ call_boot(struct device *dev) { int Active_is_Pci = 0; CARD32 vbios_base; - + CurrentPci = PciList; Console = open_console(); - + set_ioperm(); - + signal(2,sig_handler); signal(11,sig_handler); - + /* disable primary card */ pciVideoRestore(); /* reset PCI state to see primary card */ outb(0x3C2,~(CARD8)0x03 & save_msr); outb(0x3C3,~(CARD8)0x01 & save_vse); outb(0x46e8, ~(CARD8)0x08 & save_46e8); outb(0x102, ~(CARD8)0x01 & save_pos102); - + pciVideoDisable(); - + while (CurrentPci) { CARD16 ax; - + if (CurrentPci->active) { - Active_is_Pci = 1; - if (!Config.ConfigActiveDevice && !dev) { - CurrentPci = CurrentPci->next; - continue; - } + Active_is_Pci = 1; + if (!Config.ConfigActiveDevice && !dev) { + CurrentPci = CurrentPci->next; + continue; + } } else if (Config.ConfigActiveOnly && !dev) { - CurrentPci = CurrentPci->next; - continue; + CurrentPci = CurrentPci->next; + continue; } if (dev && ((dev->type != PCI) - || (dev->type == PCI - && (dev->loc.pci.dev != CurrentPci->dev - || dev->loc.pci.bus != CurrentPci->bus - || dev->loc.pci.func != CurrentPci->func)))) { - CurrentPci = CurrentPci->next; - continue; - } - + || (dev->type == PCI + && (dev->loc.pci.dev != CurrentPci->dev + || dev->loc.pci.bus != CurrentPci->bus + || dev->loc.pci.func != CurrentPci->func)))) { + CurrentPci = CurrentPci->next; + continue; + } + EnableCurrent(); - + if (CurrentPci->active) { - outb(0x102, save_pos102); - outb(0x46e8, save_46e8); - outb(0x3C3, save_vse); - outb(0x3C2, save_msr); + outb(0x102, save_pos102); + outb(0x46e8, save_46e8); + outb(0x3C3, save_vse); + outb(0x3C2, save_msr); } - + /* clear interrupt vectors */ #ifdef __ia32__ vbios_base = CurrentPci->active ? setup_primary_int_vect() - : setup_int_vect(); + : setup_int_vect(); #else vbios_base = setup_int_vect(); #endif ax = ((CARD16)(CurrentPci->bus) << 8) - | (CurrentPci->dev << 3) | (CurrentPci->func & 0x7); + | (CurrentPci->dev << 3) | (CurrentPci->func & 0x7); if (Config.Verbose > 1) P_printf("ax: 0x%x\n",ax); - + BootBios = findPciByIDs(CurrentPci->bus,CurrentPci->dev, - CurrentPci->func); + CurrentPci->func); if (!((mapPciRom(BootBios) && chksum((CARD8*)V_BIOS)) - || (CurrentPci->active && copy_vbios(vbios_base)))) { - CurrentPci = CurrentPci->next; - continue; + || (CurrentPci->active && copy_vbios(vbios_base)))) { + CurrentPci = CurrentPci->next; + continue; } if (!map_vram()) { - CurrentPci = CurrentPci->next; - continue; + CurrentPci = CurrentPci->next; + continue; } if (Config.SaveBios) save_bios_to_file(); printf("initializing PCI bus: %i dev: %i func: %i\n",CurrentPci->bus, - CurrentPci->dev,CurrentPci->func); + CurrentPci->dev,CurrentPci->func); bootBIOS(ax); unmap_vram(); if (CurrentPci->active) - close_console(Console); + close_console(Console); if (dev) return; - + CurrentPci = CurrentPci->next; } - + /* We have an ISA device - configure if requested */ if (!Active_is_Pci /* no isa card in system! */ && ((!dev && (Config.ConfigActiveDevice || Config.ConfigActiveOnly)) - || (dev && dev->type == ISA))) { + || (dev && dev->type == ISA))) { pciVideoDisable(); if (!dev || dev->type == ISA) { - outb(0x102, save_pos102); - outb(0x46e8, save_46e8); - outb(0x3C3, save_vse); - outb(0x3C2, save_msr); - + outb(0x102, save_pos102); + outb(0x46e8, save_46e8); + outb(0x3C3, save_vse); + outb(0x3C2, save_msr); + #ifdef __ia32__ - vbios_base = setup_primary_int_vect(); + vbios_base = setup_primary_int_vect(); #else - vbios_base = setup_int_vect(); + vbios_base = setup_int_vect(); #endif - if (copy_vbios(vbios_base)) { - - if (Config.SaveBios) save_bios_to_file(); - if (map_vram()) { - printf("initializing ISA bus\n"); - bootBIOS(0); - } - } - - unmap_vram(); - sleep(1); - close_console(Console); - } - } - - + if (copy_vbios(vbios_base)) { + + if (Config.SaveBios) save_bios_to_file(); + if (map_vram()) { + printf("initializing ISA bus\n"); + bootBIOS(0); + } + } + + unmap_vram(); + sleep(1); + close_console(Console); + } + } + + } -int +int map(void) { void* mem; mem = mmap(0, (size_t)SIZE, - PROT_EXEC | PROT_READ | PROT_WRITE, - MAP_FIXED | MAP_PRIVATE | MAP_ANON, - -1, 0 ); + PROT_EXEC | PROT_READ | PROT_WRITE, + MAP_FIXED | MAP_PRIVATE | MAP_ANON, + -1, 0 ); if (mem != 0) { - perror("anonymous map"); - return (0); + perror("anonymous map"); + return (0); } memset(mem,0,SIZE); @@ -390,33 +390,33 @@ map_vram(void) int mem_fd; #ifdef __ia64__ - if ((mem_fd = open(MEM_FILE,O_RDWR | O_SYNC))<0) + if ((mem_fd = open(MEM_FILE,O_RDWR | O_SYNC))<0) #else - if ((mem_fd = open(MEM_FILE,O_RDWR))<0) + if ((mem_fd = open(MEM_FILE,O_RDWR))<0) #endif - { - perror("opening memory"); - return 0; + { + perror("opening memory"); + return 0; } #ifdef __alpha__ if (!_bus_base()) sparse_shift = 7; /* Uh, oh, JENSEN... */ - if (!_bus_base_sparse()) sparse_shift = 0; - if ((vram_map = mmap(0,(size_t) (VRAM_SIZE << sparse_shift), - PROT_READ | PROT_WRITE, - MAP_SHARED, - mem_fd, (VRAM_START << sparse_shift) - | _bus_base_sparse())) == (void *) -1) + if (!_bus_base_sparse()) sparse_shift = 0; + if ((vram_map = mmap(0,(size_t) (VRAM_SIZE << sparse_shift), + PROT_READ | PROT_WRITE, + MAP_SHARED, + mem_fd, (VRAM_START << sparse_shift) + | _bus_base_sparse())) == (void *) -1) #else if (mmap((void *) VRAM_START, (size_t) VRAM_SIZE, - PROT_EXEC | PROT_READ | PROT_WRITE, MAP_SHARED | MAP_FIXED, - mem_fd, VRAM_START) == (void *) -1) + PROT_EXEC | PROT_READ | PROT_WRITE, MAP_SHARED | MAP_FIXED, + mem_fd, VRAM_START) == (void *) -1) #endif { - perror("mmap error in map_hardware_ram (1)"); - close(mem_fd); - return (0); - } + perror("mmap error in map_hardware_ram (1)"); + close(mem_fd); + return (0); + } vram_mapped = 1; close(mem_fd); return (1); @@ -426,7 +426,7 @@ static void unmap_vram(void) { if (!vram_mapped) return; - + munmap((void*)VRAM_START,VRAM_SIZE); vram_mapped = 0; } @@ -439,39 +439,39 @@ copy_vbios(memType v_base) int size; if ((mem_fd = open(MEM_FILE,O_RDONLY))<0) { - perror("opening memory"); - return (0); + perror("opening memory"); + return (0); } - if (lseek(mem_fd,(off_t) v_base, SEEK_SET) != (off_t) v_base) { - fprintf(stderr,"Cannot lseek\n"); - goto Error; + if (lseek(mem_fd,(off_t) v_base, SEEK_SET) != (off_t) v_base) { + fprintf(stderr,"Cannot lseek\n"); + goto Error; } tmp = (unsigned char *)malloc(3); if (read(mem_fd, (char *)tmp, (size_t) 3) != (size_t) 3) { - fprintf(stderr,"Cannot read\n"); - goto Error; + fprintf(stderr,"Cannot read\n"); + goto Error; } - if (lseek(mem_fd,(off_t) v_base,SEEK_SET) != (off_t) v_base) - goto Error; + if (lseek(mem_fd,(off_t) v_base,SEEK_SET) != (off_t) v_base) + goto Error; if (*tmp != 0x55 || *(tmp+1) != 0xAA ) { - fprintf(stderr,"No bios found at: 0x%lx\n",v_base); - goto Error; + fprintf(stderr,"No bios found at: 0x%lx\n",v_base); + goto Error; } #ifdef DEBUG - dprint((unsigned long)tmp,0x100); + dprint((unsigned long)tmp,0x100); #endif size = *(tmp+2) * 512; if (read(mem_fd, (char *)v_base, (size_t) size) != (size_t) size) { - fprintf(stderr,"Cannot read\n"); - goto Error; + fprintf(stderr,"Cannot read\n"); + goto Error; } free(tmp); close(mem_fd); if (!chksum((CARD8*)v_base)) - return (0); + return (0); return (1); @@ -488,14 +488,14 @@ copy_sys_bios(void) int mem_fd; if ((mem_fd = open(MEM_FILE,O_RDONLY))<0) { - perror("opening memory"); - return (0); + perror("opening memory"); + return (0); } - - if (lseek(mem_fd,(off_t) SYS_BIOS,SEEK_SET) != (off_t) SYS_BIOS) - goto Error; - if (read(mem_fd, (char *)SYS_BIOS, (size_t) 0xFFFF) != (size_t) 0xFFFF) - goto Error; + + if (lseek(mem_fd,(off_t) SYS_BIOS,SEEK_SET) != (off_t) SYS_BIOS) + goto Error; + if (read(mem_fd, (char *)SYS_BIOS, (size_t) 0xFFFF) != (size_t) 0xFFFF) + goto Error; close(mem_fd); return (1); @@ -512,15 +512,15 @@ loadCodeToMem(unsigned char *ptr, CARD8 code[]) int i; CARD8 val; int size = code[0]; - + for ( i=1;i<=size;i++) { - val = code[i]; - *ptr++ = val; + val = code[i]; + *ptr++ = val; } return; } - -void + +void dprint(unsigned long start, unsigned long size) { int i,j; @@ -529,13 +529,13 @@ dprint(unsigned long start, unsigned long size) for (j = 0; j < (size >> 4); j++) { char *d = c; printf("\n0x%lx: ",(unsigned long)c); - for (i = 0; i<16; i++) - printf("%2.2x ",(unsigned char) (*(c++))); + for (i = 0; i<16; i++) + printf("%2.2x ",(unsigned char) (*(c++))); c = d; for (i = 0; i<16; i++) { - printf("%c",((((CARD8)(*c)) > 32) && (((CARD8)(*c)) < 128)) ? - (unsigned char) (*(c)): '.'); - c++; + printf("%c",((((CARD8)(*c)) > 32) && (((CARD8)(*c)) < 128)) ? + (unsigned char) (*(c)): '.'); + c++; } } printf("\n"); @@ -548,16 +548,16 @@ save_bios_to_file(void) int size, count; char file_name[256]; int fd; - + sprintf(file_name,"bios_%i.fil",num); if ((fd = open(file_name,O_WRONLY | O_CREAT | O_TRUNC,00644)) == -1) - return; + return; size = (*(unsigned char*)(V_BIOS + 2)) * 512; #ifdef V86BIOS_DEBUG dprint(V_BIOS,20); #endif if ((count = write(fd,(void *)(V_BIOS),size)) != size) - fprintf(stderr,"only saved %i of %i bytes\n",size,count); + fprintf(stderr,"only saved %i of %i bytes\n",size,count); num++; } @@ -612,15 +612,15 @@ setup_primary_int_vect(void) CARD32 vbase; void *map; - if ((mem_fd = open(MEM_FILE,O_RDWR))<0) - { + if ((mem_fd = open(MEM_FILE,O_RDWR))<0) + { perror("opening memory"); return (0); } - + if ((map = mmap((void *) 0, (size_t) 0x2000, - PROT_EXEC | PROT_READ | PROT_WRITE, MAP_SHARED, - mem_fd, 0)) == (void *)-1) { + PROT_EXEC | PROT_READ | PROT_WRITE, MAP_SHARED, + mem_fd, 0)) == (void *)-1) { perror("mmap error in map_hardware_ram (2)"); close(mem_fd); return (0); @@ -636,7 +636,7 @@ setup_primary_int_vect(void) if (!bios_var) bios_var = (char *)malloc(BIOS_MEM); memcpy(bios_var,0,BIOS_MEM); - + vbase = (*((CARD16*)(0x10 << 2) + 1)) << 4; if (Config.Verbose > 0) printf("vbase: 0x%x\n",vbase); return vbase; @@ -649,11 +649,11 @@ setup_int_vect(void) const CARD16 cs = 0x0; const CARD16 ip = 0x0; int i; - + /* let the int vects point to the SYS_BIOS seg */ for (i=0; i<0x80; i++) { - ((CARD16*)0)[i<<1] = ip; - ((CARD16*)0)[(i<<1)+1] = cs; + ((CARD16*)0)[i<<1] = ip; + ((CARD16*)0)[(i<<1)+1] = cs; } /* video interrupts default location */ ((CARD16*)0)[(0x42<<1)+1] = 0xf000; @@ -705,40 +705,40 @@ setup_system_bios(void) { char *date = "06/01/99"; char *eisa_ident = "PCI/ISA"; - + if (Config.MapSysBios) { - if (!copy_sys_bios()) return 0; - return 1; + if (!copy_sys_bios()) return 0; + return 1; } else { -// memset((void *)0xF0000,0xf4,0xfff7); - - /* - * we trap the "industry standard entry points" to the BIOS - * and all other locations by filling them with "hlt" - * TODO: implement hlt-handler for these - */ - memset((void *)0xF0000,0xf4,0x10000); - - /* - * TODO: we should copy the fdd table (0xfec59-0xfec5b) - * the video parameter table (0xf0ac-0xf0fb) - * and the font tables (0xfa6e-0xfe6d) - * from the original bios here - */ - - /* set bios date */ - strcpy((char *)0xFFFF5,date); - /* set up eisa ident string */ - strcpy((char *)0xFFFD9,eisa_ident); - /* write system model id for IBM-AT */ - ((char *)0)[0xFFFFE] = 0xfc; - - return 1; - } - +/* memset((void *)0xF0000,0xf4,0xfff7); */ + + /* + * we trap the "industry standard entry points" to the BIOS + * and all other locations by filling them with "hlt" + * TODO: implement hlt-handler for these + */ + memset((void *)0xF0000,0xf4,0x10000); + + /* + * TODO: we should copy the fdd table (0xfec59-0xfec5b) + * the video parameter table (0xf0ac-0xf0fb) + * and the font tables (0xfa6e-0xfe6d) + * from the original bios here + */ + + /* set bios date */ + strcpy((char *)0xFFFF5,date); + /* set up eisa ident string */ + strcpy((char *)0xFFFD9,eisa_ident); + /* write system model id for IBM-AT */ + ((char *)0)[0xFFFFE] = 0xfc; + + return 1; + } + } static void @@ -747,28 +747,28 @@ update_bios_vars(void) int mem_fd; void *map; memType i; - + #ifdef __ia64__ - if ((mem_fd = open(MEM_FILE,O_RDWR | O_SYNC))<0) + if ((mem_fd = open(MEM_FILE,O_RDWR | O_SYNC))<0) #else - if ((mem_fd = open(MEM_FILE,O_RDWR))<0) + if ((mem_fd = open(MEM_FILE,O_RDWR))<0) #endif - { + { perror("opening memory"); return; } - + if ((map = mmap((void *) 0, (size_t) 0x2000, - PROT_EXEC | PROT_READ | PROT_WRITE, MAP_SHARED, - mem_fd, 0)) == (void *)-1) { + PROT_EXEC | PROT_READ | PROT_WRITE, MAP_SHARED, + mem_fd, 0)) == (void *)-1) { perror("mmap error in map_hardware_ram (3)"); close(mem_fd); return; } for (i = 0; i < BIOS_MEM; i++) { - if (bios_var[i] != *(CARD8*)i) - *((CARD8*)map + i) = *(CARD8*)i; + if (bios_var[i] != *(CARD8*)i) + *((CARD8*)map + i) = *(CARD8*)i; } munmap(map,0x2000); @@ -782,10 +782,10 @@ chksum(CARD8 *start) CARD8 val = 0; int i; - size = *(start+2) * 512; + size = *(start+2) * 512; for (i = 0; i<size; i++) val += *(start + i); - + if (!val) return 1; @@ -800,10 +800,10 @@ runINT(int num, i86biosRegsPtr Regs) CARD8 code_int[] = { 3, 0xcd, 0x00, 0xf4 }; code_int[2] = (CARD8) num; - + if (num == 0x10) isVideo = TRUE; - + if (!setup_system_bios()) return; @@ -815,16 +815,16 @@ runINT(int num, i86biosRegsPtr Regs) #else if (!(vbios_base = setup_int_vect())) #endif - return; + return; if (!copy_vbios(vbios_base)) - return; + return; } - + if (!map_vram()) return; - + #ifdef V86BIOS_DEBUG - printf("starting BIOS\n"); + printf("starting BIOS\n"); #endif loadCodeToMem((unsigned char *) BIOS_START, code_int); setup_io(); @@ -834,12 +834,12 @@ runINT(int num, i86biosRegsPtr Regs) do_x86(BIOS_START,Regs); set_hlt(FALSE); print_regs(Regs); - + #ifdef V86BIOS_DEBUG printf("done\n"); #endif - if ((isVideo && (!CurrentPci || CurrentPci->active)) || !isVideo) + if ((isVideo && (!CurrentPci || CurrentPci->active)) || !isVideo) update_bios_vars(); } @@ -867,11 +867,11 @@ add_hlt(unsigned long val) printf("address out of range\n"); return; } - + for (i=0; i<20; i++) { if (hltp[i].address == 0) { - hltp[i].address = (void*)val; - break; + hltp[i].address = (void*)val; + break; } } if (i == 20) printf("no more hltpoints available\n"); @@ -884,7 +884,7 @@ del_hlt(int val) int i; printf("clearing all hltpoints\n"); for (i=0; i <20; i++) - hltp[i].address = NULL; + hltp[i].address = NULL; } else if (val >= 0 && val <20) hltp[val].address = NULL; else printf("hltpoint %i out of range: valid range 0-19\n",val); @@ -894,22 +894,22 @@ void list_hlt() { int i; - for (i=0; i<20; i++) + for (i=0; i<20; i++) if (hltp[i].address) - printf("hltpoint[%i]: 0x%lx\n",i,(unsigned long)hltp[i].address); + printf("hltpoint[%i]: 0x%lx\n",i,(unsigned long)hltp[i].address); } static void set_hlt(Bool set) { int i; - for (i=0; i<20; i++) + for (i=0; i<20; i++) if (hltp[i].address) { - if (set) { - hltp[i].orgval = *(CARD8*)hltp[i].address; - *(CARD8*)hltp[i].address = 0xf4; - } else - *(CARD8*)hltp[i].address = hltp[i].orgval; + if (set) { + hltp[i].orgval = *(CARD8*)hltp[i].address; + *(CARD8*)hltp[i].address = 0xf4; + } else + *(CARD8*)hltp[i].address = hltp[i].orgval; } } @@ -922,12 +922,12 @@ set_ioperm(void) for (i = 0; i < IOPERM_BITS;i++) if (ioperm_list[i]) { - start = i; - for (;i < IOPERM_BITS; i++) { - if (!ioperm_list[i]) { - ioperm(start,i - start, 1); - break; - } - } + start = i; + for (;i < IOPERM_BITS; i++) { + if (!ioperm_list[i]) { + ioperm(start,i - start, 1); + break; + } + } } } diff --git a/board/MAI/bios_emulator/scitech/src/v86bios/v86bios.h b/board/MAI/bios_emulator/scitech/src/v86bios/v86bios.h index 06d0f9ff52..a8f3f8e649 100644 --- a/board/MAI/bios_emulator/scitech/src/v86bios/v86bios.h +++ b/board/MAI/bios_emulator/scitech/src/v86bios/v86bios.h @@ -31,11 +31,11 @@ #include <stdio.h> #define p_printf(f,a...) do {if (Config.PrintPort) lprintf(f,##a);} \ - while(0) + while(0) #define i_printf(f,a...) do {if (Config.PrintIrq) lprintf(f,##a);} \ - while(0) + while(0) #define P_printf(f,a...) do {if (Config.PrintPci) lprintf(f,##a);} \ - while(0) + while(0) typedef unsigned char CARD8; typedef unsigned short CARD16; @@ -65,7 +65,7 @@ struct config { Bool MapSysBios; Bool Resort; Bool FixRom; - Bool NoConsole; + Bool NoConsole; Bool BootOnly; int Verbose; }; @@ -80,21 +80,21 @@ struct pio { }; struct regs86 { - long ebx; - long ecx; - long edx; - long esi; - long edi; - long ebp; - long eax; - long eip; - long esp; - unsigned short cs; - unsigned short ss; - unsigned short es; - unsigned short ds; - unsigned short fs; - unsigned short gs; + long ebx; + long ecx; + long edx; + long esi; + long edi; + long ebp; + long eax; + long eip; + long esp; + unsigned short cs; + unsigned short ss; + unsigned short es; + unsigned short ds; + unsigned short fs; + unsigned short gs; long eflags; }; @@ -127,9 +127,9 @@ struct device { union { int none; struct pci { - int bus; - int dev; - int func; + int bus; + int dev; + int func; } pci; } loc; }; @@ -212,4 +212,3 @@ extern void lprintf(const char *f, ...); #endif #endif - diff --git a/board/MAI/bios_emulator/scitech/src/v86bios/x86emu.c b/board/MAI/bios_emulator/scitech/src/v86bios/x86emu.c index 2cc72df995..b5c99d7a7f 100644 --- a/board/MAI/bios_emulator/scitech/src/v86bios/x86emu.c +++ b/board/MAI/bios_emulator/scitech/src/v86bios/x86emu.c @@ -28,7 +28,7 @@ #include </usr/include/unistd.h> #include <errno.h> #include <asm/unistd.h> -//#include <syscall-list.h> +/*#include <syscall-list.h> */ #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -50,10 +50,10 @@ struct pio P; void -setup_io(void) +setup_io(void) { if (!Config.PrintPort && !Config.IoStatistics) { - + #if defined (__i386__) P.inb = (u8(*)(u16))inb; P.inw = (u16(*)(u16))inw; @@ -86,19 +86,19 @@ void x86emu_do_int(int num) { struct regs86 regs; - + i_printf("int 0x%x received: ax:0x%x",num,CPU_REG(AX)); if (Config.PrintIp) - i_printf(" at: 0x%x\n",getIP()); + i_printf(" at: 0x%x\n",getIP()); else - i_printf("\n"); - + i_printf("\n"); + /* try to run bios interrupt */ - + /* if not installed fall back */ #define COPY(x,y) regs.y = M.x86.x #define COPY_R(x,y) M.x86.x = regs.y - + COPY(R_EAX,eax); COPY(R_EBX,ebx); COPY(R_ECX,ecx); @@ -117,12 +117,12 @@ x86emu_do_int(int num) COPY(R_EFLG,eflags); if (!(int_handler(num,®s))) { - if (!run_bios_int(num,®s)) - goto unknown_int; - else - return; + if (!run_bios_int(num,®s)) + goto unknown_int; + else + return; } - + COPY_R(R_EAX,eax); COPY_R(R_EBX,ebx); COPY_R(R_ECX,ecx); @@ -145,7 +145,7 @@ x86emu_do_int(int num) fprintf(stderr,"\nUnknown vm86_int: %X\n\n",num); X86EMU_halt_sys(); return; - + #undef COPY #undef COPY_R } @@ -159,12 +159,12 @@ setup_x86emu(unsigned long bios_start, i86biosRegsPtr regs) X86EMU_intrFuncs intFuncs[256]; X86EMU_pioFuncs pioFuncs = { - (u8(*)(u16))P.inb, - (u16(*)(u16))P.inw, - (u32(*)(u16))P.inl, - (void(*)(u16,u8))P.outb, - (void(*)(u16,u16))P.outw, - (void(*)(u16,u32))P.outl + (u8(*)(u16))P.inb, + (u16(*)(u16))P.inw, + (u32(*)(u16))P.inl, + (void(*)(u16,u8))P.outb, + (void(*)(u16,u16))P.outw, + (void(*)(u16,u32))P.outl }; #ifdef __alpha__ X86EMU_memFuncs memFuncs = { @@ -178,29 +178,29 @@ setup_x86emu(unsigned long bios_start, i86biosRegsPtr regs) #endif M.mem_base = 0; M.mem_size = 1024*1024 + 1024; - // M.x86.debug = DEBUG_DISASSEMBLE_F | DEBUG_TRACE_F | DEBUG_DECODE_F; - // M.x86.debug |= DEBUG_DECODE_F | DEBUG_TRACE_F; + /* M.x86.debug = DEBUG_DISASSEMBLE_F | DEBUG_TRACE_F | DEBUG_DECODE_F; */ + /* M.x86.debug |= DEBUG_DECODE_F | DEBUG_TRACE_F; */ /* * For single step tracing compile x86emu with option -DDEBUG */ M.x86.debug = 0; if (Config.PrintIp) - M.x86.debug = DEBUG_SAVE_CS_IP; + M.x86.debug = DEBUG_SAVE_CS_IP; if (Config.Trace) - X86EMU_trace_on(); + X86EMU_trace_on(); X86EMU_setupPioFuncs(&pioFuncs); #ifdef __alpha__ X86EMU_setupMemFuncs(&memFuncs); #endif for (i=0;i<256;i++) - intFuncs[i] = x86emu_do_int; + intFuncs[i] = x86emu_do_int; X86EMU_setupIntrFuncs(intFuncs); eip = bios_start & 0xFFFF; cs = (bios_start & 0xFF0000) >> 4; - + CPU_REG(EAX) = regs->ax; CPU_REG(EBX) = regs->bx; CPU_REG(ECX) = regs->cx; @@ -209,7 +209,7 @@ setup_x86emu(unsigned long bios_start, i86biosRegsPtr regs) CPU_REG(EDI) = regs->di; CPU_REG(EBP) = 0; CPU_REG(EIP) = eip; - CPU_REG(CS) = cs; + CPU_REG(CS) = cs; CPU_REG(SP) = 0x100; CPU_REG(SS) = 0x30; /* This is the standard pc bios stack */ CPU_REG(ES) = regs->es; @@ -252,14 +252,14 @@ do_x86(unsigned long bios_start, i86biosRegsPtr regs) setup_x86emu(bios_start,regs); if (setjmp(x86_esc) == 0) { - org_handler = signal(2,vmexit); - do_x86emu(); - signal(2,org_handler); - collect_bios_regs(regs); + org_handler = signal(2,vmexit); + do_x86emu(); + signal(2,org_handler); + collect_bios_regs(regs); } else { - signal(2,org_handler); - printf("interrupted at 0x%x\n",((CARD16)CPU_REG(CS)) << 4 - | (CARD16)CPU_REG(EIP)); + signal(2,org_handler); + printf("interrupted at 0x%x\n",((CARD16)CPU_REG(CS)) << 4 + | (CARD16)CPU_REG(EIP)); } } @@ -272,23 +272,23 @@ run_bios_int(int num, struct regs86 *regs) /* check if bios vector is initialized */ if (((CARD16*)0)[(num<<1)+1] == 0x0000) { /* SYS_BIOS_SEG ?*/ #ifdef V86BIOS_DEBUG - i_printf("card BIOS not loaded\n"); + i_printf("card BIOS not loaded\n"); #endif - return 0; + return 0; } - + #ifdef V86BIOS_DEBUG if (firsttime) { - dprint(0,0x3D0); - firsttime = 0; + dprint(0,0x3D0); + firsttime = 0; } #endif - + i_printf("calling card BIOS at: "); i_printf("0x%x:%x\n",((CARD16 *) 0)[(num << 1) + 1], - (CARD32)((CARD16 *) 0)[num << 1]); + (CARD32)((CARD16 *) 0)[num << 1]); X86EMU_prepareForInt(num); - + return 1; } |