Initialise all int vectors except the ones at 70:xxxx using a table.

Convert setvec into a function that disables/enables ints (init code only
for now, resident code will follow later); cli/sti (disable/enable) are
now macros (inlined).


git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@918 6ac86273-5f31-0410-b378-82cca8765d1b
This commit is contained in:
Bart Oldeman 2004-05-04 09:32:16 +00:00
parent 859ac24170
commit 6947542a5e
3 changed files with 53 additions and 25 deletions

View File

@ -71,6 +71,9 @@ static char *portab_hRcsId =
#endif
#define PASCAL pascal
void __int__(int);
void __emit__(char, ...);
#define disable() __emit__(0xfa)
#define enable() __emit__(0xfb)
#elif defined (_MSC_VER)
@ -82,6 +85,8 @@ void __int__(int);
#define VA_CDECL
#define PASCAL pascal
#define __int__(intno) asm int intno;
#define disable() asm cli
#define enable() asm sti
#define _CS getCS()
static unsigned short __inline getCS(void)
{
@ -97,6 +102,10 @@ static unsigned short __inline getSS(void)
#define I86
#define __int__(intno) asm int intno;
void disable(void);
#pragma aux disable = "cli" modify exact [];
void enable(void);
#pragma aux enable = "sti" modify exact [];
#define asm __asm
#define far __far
#define CDECL __cdecl

View File

@ -361,7 +361,6 @@ extern UWORD ASM f_nodes_cnt; /* number of allocated f_nodes */
/* Typically, these are in ".asm" files. */
VOID ASMCFUNC FAR cpm_entry(VOID)
/*INRPT FAR handle_break(VOID) */ ;
VOID enable(VOID), disable(VOID);
COUNT ASMCFUNC
CriticalError(COUNT nFlag, COUNT nDrive, COUNT nError,
struct dhdr FAR * lpDevice);

View File

@ -55,6 +55,7 @@ STATIC VOID FsConfig(VOID);
STATIC VOID InitPrinters(VOID);
STATIC VOID InitSerialPorts(VOID);
STATIC void CheckContinueBootFromHarddisk(void);
STATIC void setup_int_vectors(void);
#ifdef _MSC_VER
BYTE _acrtused = 0;
@ -107,11 +108,7 @@ VOID ASMCFUNC FreeDOSmain(void)
drv = 3; /* C: */
LoL->BootDrive = drv;
setvec(0, int0_handler); /* zero divide */
setvec(1, empty_handler); /* single step */
setvec(3, empty_handler); /* debug breakpoint */
setvec(6, int6_handler); /* invalid opcode */
setup_int_vectors();
CheckContinueBootFromHarddisk();
@ -210,6 +207,47 @@ STATIC void PSPInit(void)
p->ps_cmd.ctBuffer[0] = 0xd; /* command tail */
}
void setvec(unsigned char intno, intvec vector)
{
disable();
*(intvec FAR *)MK_FP(0,4 * intno) = vector;
enable();
}
STATIC void setup_int_vectors(void)
{
static struct vec
{
unsigned char intno;
size_t handleroff;
} vectors[] =
{
/* all of these are in the DOS DS */
{ 0x0, FP_OFF(int0_handler) }, /* zero divide */
{ 0x1, FP_OFF(empty_handler) }, /* single step */
{ 0x3, FP_OFF(empty_handler) }, /* debug breakpoint */
{ 0x6, FP_OFF(int6_handler) }, /* invalid opcode */
{ 0x20, FP_OFF(int20_handler) },
{ 0x21, FP_OFF(int21_handler) },
{ 0x22, FP_OFF(int22_handler) },
{ 0x24, FP_OFF(int24_handler) },
{ 0x25, FP_OFF(low_int25_handler) },
{ 0x26, FP_OFF(low_int26_handler) },
{ 0x27, FP_OFF(int27_handler) },
{ 0x28, FP_OFF(int28_handler) },
{ 0x2a, FP_OFF(int2a_handler) },
{ 0x2f, FP_OFF(int2f_handler) }
};
struct vec *pvec;
int i;
for (i = 0x23; i <= 0x3f; i++)
setvec(i, empty_handler);
for (pvec = vectors; pvec < vectors + (sizeof vectors/sizeof *pvec); pvec++)
setvec(pvec->intno, MK_FP(FP_SEG(empty_handler), pvec->handleroff));
pokeb(0, 0x30 * 4, 0xea);
pokel(0, 0x30 * 4 + 1, (ULONG)cpm_entry);
}
STATIC void init_kernel(void)
{
@ -231,30 +269,11 @@ STATIC void init_kernel(void)
MoveKernel(FP_SEG(lpTop));
lpTop = MK_FP(FP_SEG(lpTop) - 0xfff, 0xfff0);
for (i = 0x20; i <= 0x3f; i++)
setvec(i, empty_handler);
/* Initialize IO subsystem */
InitIO();
InitPrinters();
InitSerialPorts();
/* set interrupt vectors */
setvec(0x1b, got_cbreak);
setvec(0x20, int20_handler);
setvec(0x21, int21_handler);
setvec(0x22, int22_handler);
setvec(0x23, empty_handler);
setvec(0x24, int24_handler);
setvec(0x25, low_int25_handler);
setvec(0x26, low_int26_handler);
setvec(0x27, int27_handler);
setvec(0x28, int28_handler);
setvec(0x2a, int2a_handler);
setvec(0x2f, int2f_handler);
pokeb(0, 0x30 * 4, 0xea);
pokel(0, 0x30 * 4 + 1, (ULONG)cpm_entry);
init_PSPSet(DOS_PSP);
set_DTA(MK_FP(DOS_PSP, 0x80));
PSPInit();
@ -576,6 +595,7 @@ STATIC void InitIO(void)
struct dhdr far *device = &LoL->nul_dev;
/* Initialize driver chain */
setvec(0x1b, got_cbreak);
setvec(0x29, int29_handler); /* Requires Fast Con Driver */
do {
init_device(device, NULL, 0, &lpTop);