fixed emulator "struct emu"-dependent calls

This commit is contained in:
Markus Fröschle
2015-02-18 15:54:14 +00:00
parent 6424385631
commit d5db802afa
7 changed files with 41 additions and 35 deletions

View File

@@ -206,3 +206,4 @@ util/setjmp.c
util/setjmp.S util/setjmp.S
include/x86emu_regs.h include/x86emu_regs.h
x86emu/x86emu_util.c x86emu/x86emu_util.c
include/setjmp.h

View File

@@ -217,7 +217,7 @@ define CC_TEMPLATE
#$(1)/objs/x86ops.o: CFLAGS=$(CFLAGS_OPTIMIZED) #$(1)/objs/x86ops.o: CFLAGS=$(CFLAGS_OPTIMIZED)
#$(1)/objs/x86ops2.o: CFLAGS=$(CFLAGS_OPTIMIZED) #$(1)/objs/x86ops2.o: CFLAGS=$(CFLAGS_OPTIMIZED)
#$(1)/objs/x86fpu.o: CFLAGS=$(CFLAGS_OPTIMIZED) #$(1)/objs/x86fpu.o: CFLAGS=$(CFLAGS_OPTIMIZED)
#$(1)/objs/x86biosemu.o: CFLAGS=$(CFLAGS_OPTIMIZED) $(1)/objs/x86biosemu.o: CFLAGS=$(CFLAGS_OPTIMIZED)
#$(1)/objs/x86pcibios.o: CFLAGS=$(CFLAGS_OPTIMIZED) #$(1)/objs/x86pcibios.o: CFLAGS=$(CFLAGS_OPTIMIZED)
$(1)/objs/%.o:%.c $(1)/objs/%.o:%.c

View File

@@ -99,6 +99,7 @@ SECTIONS
OBJDIR/x86emu.o(.text) OBJDIR/x86emu.o(.text)
OBJDIR/x86emu_util.o(.text) OBJDIR/x86emu_util.o(.text)
OBJDIR/x86biosemu.o(.text)
OBJDIR/radeon_base.o(.text) OBJDIR/radeon_base.o(.text)
OBJDIR/radeon_accel.o(.text) OBJDIR/radeon_accel.o(.text)

11
BaS_gcc/include/setjmp.h Normal file
View File

@@ -0,0 +1,11 @@
#ifndef _SETJMP_H_
#define _SETJMP_H_
#include "bas_types.h"
typedef uint32_t jmp_buf[18];
extern int setjmp(jmp_buf env);
extern void longjmp(jmp_buf env, int val);
#endif /* _SETJMP_H_ */

View File

@@ -35,7 +35,7 @@
#define __X86EMU_X86EMU_H #define __X86EMU_X86EMU_H
#include "bas_types.h" #include "bas_types.h"
#include "setjmp.h"
/* /*
* General EAX, EBX, ECX, EDX type registers. Note that for * General EAX, EBX, ECX, EDX type registers. Note that for
@@ -111,8 +111,6 @@ struct X86EMU_regs {
uint8_t __pad[3]; uint8_t __pad[3];
}; };
typedef uint32_t jmp_buf[18];
struct X86EMU struct X86EMU
{ {
char *mem_base; char *mem_base;

View File

@@ -12,13 +12,13 @@
#define USE_SDRAM #define USE_SDRAM
#define DIRECT_ACCESS #define DIRECT_ACCESS
#define MEM_WB(where, what) wrb(where, what) #define MEM_WB(where, what) emu->emu_wrb(emu, where, what)
#define MEM_WW(where, what) wrw(where, what) #define MEM_WW(where, what) emu->emu_wrw(emu, where, what)
#define MEM_WL(where, what) wrl(where, what) #define MEM_WL(where, what) emu->emu_wrl(emu, where, what)
#define MEM_RB(where) rdb(where) #define MEM_RB(where) emu->emu_rdb(emu, where)
#define MEM_RW(where) rdw(where) #define MEM_RW(where) emu->emu_rdw(emu, where)
#define MEM_RL(where) rdl(where) #define MEM_RL(where) emu->emu_rdl(emu, where)
#define PCI_VGA_RAM_IMAGE_START 0xC0000 #define PCI_VGA_RAM_IMAGE_START 0xC0000
#define PCI_RAM_IMAGE_START 0xD0000 #define PCI_RAM_IMAGE_START 0xD0000
@@ -81,7 +81,7 @@ extern int x86_pcibios_emulator();
//X86EMU_sysEnv _X86EMU_env; //X86EMU_sysEnv _X86EMU_env;
/* general software interrupt handler */ /* general software interrupt handler */
uint32_t getIntVect(int num) uint32_t getIntVect(struct X86EMU *emu, int num)
{ {
return MEM_RW(num << 2) + (MEM_RW((num << 2) + 2) << 4); return MEM_RW(num << 2) + (MEM_RW((num << 2) + 2) << 4);
} }
@@ -219,9 +219,9 @@ void do_int(struct X86EMU *emu, int num)
case 0x10: case 0x10:
case 0x42: case 0x42:
case 0x6D: case 0x6D:
if (getIntVect(num) == 0x0000) if (getIntVect(emu, num) == 0x0000)
dbg("uninitialised int vector\r\n"); dbg("uninitialised int vector\r\n");
if (getIntVect(num) == 0xFF065) if (getIntVect(emu, num) == 0xFF065)
{ {
//ret = int42_handler(); //ret = int42_handler();
ret = 1; ret = 1;
@@ -360,9 +360,9 @@ void run_bios(struct radeonfb_info *rinfo)
{ {
char *date = "01/01/99"; char *date = "01/01/99";
for (i = 0; date[i]; i++) for (i = 0; date[i]; i++)
wrb(0xffff5 + i, date[i]); emu.emu_wrb(&emu, 0xffff5 + i, date[i]);
wrb(0xffff7, '/'); emu.emu_wrb(&emu, 0xffff7, '/');
wrb(0xffffa, '/'); emu.emu_wrb(&emu, 0xffffa, '/');
} }
{ {
/* FixME: move PIT init to its own file */ /* FixME: move PIT init to its own file */

View File

@@ -34,6 +34,7 @@
#include <stdbool.h> #include <stdbool.h>
#include <x86emu.h> #include <x86emu.h>
#include <x86emu_regs.h> #include <x86emu_regs.h>
#include "setjmp.h"
static void x86emu_intr_raise (struct X86EMU *, uint8_t type); static void x86emu_intr_raise (struct X86EMU *, uint8_t type);
@@ -174,12 +175,14 @@ static uint32_t pop_long (struct X86EMU *);
REMARKS: REMARKS:
Handles any pending asychronous interrupts. Handles any pending asychronous interrupts.
****************************************************************************/ ****************************************************************************/
static void static void x86emu_intr_dispatch(struct X86EMU *emu, uint8_t intno)
x86emu_intr_dispatch(struct X86EMU *emu, uint8_t intno) {
if (emu->_X86EMU_intrTab[intno])
{ {
if (emu->_X86EMU_intrTab[intno]) {
(*emu->_X86EMU_intrTab[intno]) (emu, intno); (*emu->_X86EMU_intrTab[intno]) (emu, intno);
} else { }
else
{
push_word(emu, (uint16_t) emu->x86.R_FLG); push_word(emu, (uint16_t) emu->x86.R_FLG);
CLEAR_FLAG(F_IF); CLEAR_FLAG(F_IF);
CLEAR_FLAG(F_TF); CLEAR_FLAG(F_TF);
@@ -190,17 +193,18 @@ x86emu_intr_dispatch(struct X86EMU *emu, uint8_t intno)
} }
} }
static void static void x86emu_intr_handle(struct X86EMU *emu)
x86emu_intr_handle(struct X86EMU *emu)
{ {
uint8_t intno; uint8_t intno;
if (emu->x86.intr & INTR_SYNCH) { if (emu->x86.intr & INTR_SYNCH)
{
intno = emu->x86.intno; intno = emu->x86.intno;
emu->x86.intr = 0; emu->x86.intr = 0;
x86emu_intr_dispatch(emu, intno); x86emu_intr_dispatch(emu, intno);
} }
} }
/**************************************************************************** /****************************************************************************
PARAMETERS: PARAMETERS:
intrnum - Interrupt number to raise intrnum - Interrupt number to raise
@@ -209,8 +213,7 @@ REMARKS:
Raise the specified interrupt to be handled before the execution of the Raise the specified interrupt to be handled before the execution of the
next instruction. next instruction.
****************************************************************************/ ****************************************************************************/
void void x86emu_intr_raise(struct X86EMU *emu, uint8_t intrnum)
x86emu_intr_raise(struct X86EMU *emu, uint8_t intrnum)
{ {
emu->x86.intno = intrnum; emu->x86.intno = intrnum;
emu->x86.intr |= INTR_SYNCH; emu->x86.intr |= INTR_SYNCH;
@@ -221,20 +224,12 @@ Main execution loop for the emulator. We return from here when the system
halts, which is normally caused by a stack fault when we return from the halts, which is normally caused by a stack fault when we return from the
original real mode call. original real mode call.
****************************************************************************/ ****************************************************************************/
void void X86EMU_exec(struct X86EMU *emu)
X86EMU_exec(struct X86EMU *emu)
{ {
emu->x86.intr = 0; emu->x86.intr = 0;
#ifdef _NOT_USED_
#ifdef _KERNEL
if (setjmp(&emu->exec_state))
return;
#else
if (setjmp(emu->exec_state)) if (setjmp(emu->exec_state))
return; return;
#endif
#endif /* _NOT_USED_ */
for (;;) { for (;;) {
if (emu->x86.intr) { if (emu->x86.intr) {