diff options
author | marcel <marcel@FreeBSD.org> | 1999-09-29 20:09:19 +0000 |
---|---|---|
committer | marcel <marcel@FreeBSD.org> | 1999-09-29 20:09:19 +0000 |
commit | d4e70391772e9b3fa25d96b93d50278ea1c125ef (patch) | |
tree | 8397c40eb0fbcd1e79470ce8389a29cbebc02ca6 /usr.bin/doscmd | |
parent | 073b941095e3deeaae66ec3452643c4db25deb08 (diff) | |
download | FreeBSD-src-d4e70391772e9b3fa25d96b93d50278ea1c125ef.zip FreeBSD-src-d4e70391772e9b3fa25d96b93d50278ea1c125ef.tar.gz |
Unbreak doscmd after the sigset_t change:
doscmd heavily depends on struct sigcontext which luckily is mostly passed
between functions as usion regcontext_t. By redefining union regcontext_t in
terms of mcontext_t almost all bases are covered.
It also seems to me that doscmd was in a transitional state. The redundant
definitions made it difficult to get a clear overview and could easily cause
oversight. To make sure my changes were ok, I went as far as to complete the
transition. It was not exactly necessary, but I expect to have to come back
here some more ("whistle" if I'm wrong :-).
Diffstat (limited to 'usr.bin/doscmd')
-rw-r--r-- | usr.bin/doscmd/AsyncIO.c | 5 | ||||
-rw-r--r-- | usr.bin/doscmd/bios.c | 2 | ||||
-rw-r--r-- | usr.bin/doscmd/debug.c | 4 | ||||
-rw-r--r-- | usr.bin/doscmd/dos.c | 70 | ||||
-rw-r--r-- | usr.bin/doscmd/doscmd.c | 20 | ||||
-rw-r--r-- | usr.bin/doscmd/doscmd.h | 4 | ||||
-rw-r--r-- | usr.bin/doscmd/ems.c | 6 | ||||
-rw-r--r-- | usr.bin/doscmd/emuint.c | 4 | ||||
-rw-r--r-- | usr.bin/doscmd/int.c | 16 | ||||
-rw-r--r-- | usr.bin/doscmd/int10.c | 132 | ||||
-rw-r--r-- | usr.bin/doscmd/int13.c | 6 | ||||
-rw-r--r-- | usr.bin/doscmd/intff.c | 14 | ||||
-rw-r--r-- | usr.bin/doscmd/mouse.c | 16 | ||||
-rw-r--r-- | usr.bin/doscmd/port.c | 12 | ||||
-rw-r--r-- | usr.bin/doscmd/register.h | 88 | ||||
-rw-r--r-- | usr.bin/doscmd/signal.c | 4 | ||||
-rw-r--r-- | usr.bin/doscmd/trace.c | 10 | ||||
-rw-r--r-- | usr.bin/doscmd/trap.c | 54 | ||||
-rw-r--r-- | usr.bin/doscmd/tty.c | 16 | ||||
-rw-r--r-- | usr.bin/doscmd/xms.c | 4 |
20 files changed, 224 insertions, 263 deletions
diff --git a/usr.bin/doscmd/AsyncIO.c b/usr.bin/doscmd/AsyncIO.c index 92c7e98..992fee5 100644 --- a/usr.bin/doscmd/AsyncIO.c +++ b/usr.bin/doscmd/AsyncIO.c @@ -28,7 +28,10 @@ * SUCH DAMAGE. * * BSDI AsyncIO.c,v 2.2 1996/04/08 19:32:10 bostic Exp + * + * $FreeBSD$ */ + #include <stdio.h> #include <sys/param.h> #include <sys/types.h> @@ -269,7 +272,7 @@ if (0) * STEP 3: Call the handler */ (*handlers[fd].func)(handlers[fd].arg, - &sf->sf_siginfo.si_sc); + (regcontext_t*)&sf->sf_uc); /* * STEP 4: Just turn SIGIO off. No check. diff --git a/usr.bin/doscmd/bios.c b/usr.bin/doscmd/bios.c index c6cea92..1af6ccf 100644 --- a/usr.bin/doscmd/bios.c +++ b/usr.bin/doscmd/bios.c @@ -141,7 +141,7 @@ int15(regcontext_t *REGS) break; case 0xc0: /* get configuration */ debug (D_TRAPS|0x15, "Get configuration\n", R_DX); - N_PUTVEC(R_ES, R_BX, rom_config); + PUTVEC(R_ES, R_BX, rom_config); R_AH = 0; break; case 0xc1: /* get extended BIOS data area */ diff --git a/usr.bin/doscmd/debug.c b/usr.bin/doscmd/debug.c index dde4fcb..bc3524a 100644 --- a/usr.bin/doscmd/debug.c +++ b/usr.bin/doscmd/debug.c @@ -150,13 +150,13 @@ dump_regs(regcontext_t *REGS) debug (D_ALWAYS, "cs=%04x ss=%04x ds=%04x es=%04x\n", R_CS, R_SS, R_DS, R_ES); debug (D_ALWAYS, "ip=%x eflags=%x\n", R_IP, R_EFLAGS); - addr = (u_char *)N_GETPTR(R_CS, R_IP); + addr = (u_char *)MAKEPTR(R_CS, R_IP); for (i = 0; i < 16; i++) debug (D_ALWAYS, "%02x ", addr[i]); debug (D_ALWAYS, "\n"); - addr = (char *)N_GETPTR(R_CS, R_IP); + addr = (char *)MAKEPTR(R_CS, R_IP); i386dis(R_CS, R_IP, addr, buf, 0); debug (D_ALWAYS, "%s\n", buf); diff --git a/usr.bin/doscmd/dos.c b/usr.bin/doscmd/dos.c index 7b8fa0c..0a896b1 100644 --- a/usr.bin/doscmd/dos.c +++ b/usr.bin/doscmd/dos.c @@ -543,7 +543,7 @@ int21_09(regcontext_t *REGS) int len; /* pointer to string */ - addr = (char *)N_GETPTR(R_DS, R_DX); + addr = (char *)MAKEPTR(R_DS, R_DX); /* walk string looking for terminator or overlength */ for (len = 0; len < 10000; len++, addr++) { @@ -568,7 +568,7 @@ int21_0a(regcontext_t *REGS) int n; /* pointer to buffer */ - addr = (unsigned char *)N_GETPTR(R_DS, R_DL); + addr = (unsigned char *)MAKEPTR(R_DS, R_DL); /* capacity of buffer */ avail = addr[0]; @@ -634,7 +634,7 @@ int21_0b(regcontext_t *REGS) return(0); } /* XXX tty_peek is broken */ - n = tty_peek(®S->sc, poll_cnt ? 0 : TTYF_POLL) ? 0xff : 0; + n = tty_peek(REGS, poll_cnt ? 0 : TTYF_POLL) ? 0xff : 0; if (n < 0) /* control-break */ return (0); R_AL = n; /* will be 0 or 0xff */ @@ -703,7 +703,7 @@ static int int21_1a(regcontext_t *REGS) { debug(D_FILE_OPS, "set dta to %x:%x\n", R_DS, R_DX); - disk_transfer_addr = N_GETVEC(R_DS, R_DX); + disk_transfer_addr = MAKEVEC(R_DS, R_DX); return(0); } @@ -731,7 +731,7 @@ static int int21_25(regcontext_t *REGS) { debug(D_MEMORY, "%02x -> %04x:%04x\n", R_AL, R_DS, R_DX); - ivec[R_AL] = N_GETVEC(R_DS, R_DX); + ivec[R_AL] = MAKEVEC(R_DS, R_DX); return(0); } @@ -871,7 +871,7 @@ int21_2d(regcontext_t *REGS) static int int21_2f(regcontext_t *REGS) { - N_PUTVEC(R_ES, R_BX, disk_transfer_addr); + PUTVEC(R_ES, R_BX, disk_transfer_addr); debug(D_FILE_OPS, "get dta at %x:%x\n", R_ES, R_BX); return(0); } @@ -980,7 +980,7 @@ int21_33(regcontext_t *REGS) static int int21_34(regcontext_t *REGS) { - N_PUTVEC(R_ES, R_BX, (u_long)InDOS); + PUTVEC(R_ES, R_BX, (u_long)InDOS); return(0); } @@ -992,7 +992,7 @@ int21_34(regcontext_t *REGS) static int int21_35(regcontext_t *REGS) { - N_PUTVEC(R_ES, R_BX, ivec[R_AL]); + PUTVEC(R_ES, R_BX, ivec[R_AL]); debug(D_MEMORY, "%02x <- %04x:%04x\n", R_AL, R_ES, R_BX); return(0); } @@ -1038,8 +1038,8 @@ int21_38(regcontext_t *REGS) debug(D_HALF, "warning: set country code ignored"); return(0); } - addr = (char *)N_GETPTR(R_DS, R_DX); - N_PUTVEC(countryinfo.ciCaseMapSegment, countryinfo.ciCaseMapOffset, + addr = (char *)MAKEPTR(R_DS, R_DX); + PUTVEC(countryinfo.ciCaseMapSegment, countryinfo.ciCaseMapOffset, upcase_vector); memcpy(addr, &countryinfo, sizeof(countryinfo)); return(0); @@ -1060,7 +1060,7 @@ int21_dirfn(regcontext_t *REGS) char fname[PATH_MAX],tname[PATH_MAX]; int drive; - error = translate_filename((u_char *)N_GETPTR(R_DS, R_DX), fname, &drive); + error = translate_filename((u_char *)MAKEPTR(R_DS, R_DX), fname, &drive); if (error) return (error); @@ -1081,7 +1081,7 @@ int21_dirfn(regcontext_t *REGS) error = unlink(fname); break; case 0x56: /* rename - some extra work */ - error = translate_filename((u_char *)GETPTR(R_ES, R_DI), tname, &drive); + error = translate_filename((u_char *)MAKEPTR(R_ES, R_DI), tname, &drive); if (error) return (error); @@ -1114,8 +1114,8 @@ int21_dirfn(regcontext_t *REGS) static int int21_3b(regcontext_t *REGS) { - debug(D_FILE_OPS, "chdir(%s)\n",(u_char *)N_GETPTR(R_DS, R_DX)); - return(dos_setcwd((u_char *)N_GETPTR(R_DS, R_DX))); + debug(D_FILE_OPS, "chdir(%s)\n",(u_char *)MAKEPTR(R_DS, R_DX)); + return(dos_setcwd((u_char *)MAKEPTR(R_DS, R_DX))); } /* @@ -1138,14 +1138,14 @@ int21_open(regcontext_t *REGS) switch(R_AH) { case 0x3c: /* creat */ - pname = (char *)N_GETPTR(R_DS, R_DX); + pname = (char *)MAKEPTR(R_DS, R_DX); action = 0x12; /* create/truncate regardless */ mode = O_RDWR; debug(D_FILE_OPS, "creat"); break; case 0x3d: /* open */ - pname = (char *)N_GETPTR(R_DS, R_DX); + pname = (char *)MAKEPTR(R_DS, R_DX); action = 0x01; /* fail if not exist, open if exists */ switch (R_AL & 3) { case 0: @@ -1164,14 +1164,14 @@ int21_open(regcontext_t *REGS) break; case 0x5b: /* creat new */ - pname = (char *)N_GETPTR(R_DS, R_DL); + pname = (char *)MAKEPTR(R_DS, R_DL); action = 0x10; /* create if not exist, fail if exists */ mode = O_RDWR; debug(D_FILE_OPS, "creat_new"); break; case 0x6c: /* multipurpose */ - pname = (char *)N_GETPTR(R_DS, R_SI); + pname = (char *)MAKEPTR(R_DS, R_SI); action = R_DX; switch (R_BL & 3) { case 0: @@ -1275,7 +1275,7 @@ int21_3f(regcontext_t *REGS) int nbytes,n; int avail; - addr = (char *)N_GETPTR(R_DS, R_DX); + addr = (char *)MAKEPTR(R_DS, R_DX); debug(D_FILE_OPS, "read(%d, %d)\n", R_BX, R_CX); @@ -1313,7 +1313,7 @@ int21_40(regcontext_t *REGS) char *addr; int nbytes,n; - addr = (char *)N_GETPTR(R_DS, R_DX); + addr = (char *)MAKEPTR(R_DS, R_DX); nbytes = R_CX; debug(D_FILE_OPS, "write(%d, %d)\n", R_BX, nbytes); @@ -1411,7 +1411,7 @@ int21_43(regcontext_t *REGS) int mode; int drive; - error = translate_filename((u_char *)N_GETPTR(R_DS, R_DX), fname, &drive); + error = translate_filename((u_char *)MAKEPTR(R_DS, R_DX), fname, &drive); if (error) return (error); @@ -1582,7 +1582,7 @@ int21_47(regcontext_t *REGS) n = diskdrive; p = (char *)dos_getcwd(n) + 1; - addr = (char *)N_GETPTR(R_DS, R_SI); + addr = (char *)MAKEPTR(R_DS, R_SI); nbytes = strlen(p); if (nbytes > 63) @@ -1661,15 +1661,15 @@ int21_4b(regcontext_t *REGS) char *fname[PATH_MAX]; u_short *param; - debug(D_EXEC, "exec(%s)\n",(u_char *)N_GETPTR(R_DS, R_DX)); + debug(D_EXEC, "exec(%s)\n",(u_char *)MAKEPTR(R_DS, R_DX)); - if ((fd = open_prog((u_char *)N_GETPTR(R_DS, R_DX))) < 0) { + if ((fd = open_prog((u_char *)MAKEPTR(R_DS, R_DX))) < 0) { debug(D_EXEC, "%s: command not found\n", fname); return (FILE_NOT_FOUND); } /* child */ - param = (u_short *)N_GETPTR(R_ES, R_BX); + param = (u_short *)MAKEPTR(R_ES, R_BX); switch (R_AL) { case 0x00: /* load and execute */ @@ -1735,7 +1735,7 @@ int21_find(regcontext_t *REGS) switch (R_AH) { case 0x4e: /* find first */ - error = find_first((u_char *)N_GETPTR(R_DS, R_DX), R_CX, &dosdir, dta); + error = find_first((u_char *)MAKEPTR(R_DS, R_DX), R_CX, &dosdir, dta); break; case 0x4f: error = find_next(&dosdir, dta); @@ -1891,7 +1891,7 @@ int21_5a(regcontext_t *REGS) int fd; /* get and check proposed path */ - pname = (char *)N_GETPTR(R_DS, R_DX); + pname = (char *)MAKEPTR(R_DS, R_DX); error = translate_filename(pname, fname, &drive); if (error) return (error); @@ -1920,8 +1920,8 @@ int21_5a(regcontext_t *REGS) static int int21_60(regcontext_t *REGS) { - return(dos_makepath((char *)GETPTR(R_DS, R_SI), - (char *)GETPTR(R_ES, R_DI))); + return(dos_makepath((char *)MAKEPTR(R_DS, R_SI), + (char *)MAKEPTR(R_ES, R_DI))); } /* @@ -2066,7 +2066,7 @@ int21_fcb(regcontext_t *REGS) int nbytes,n; - fcbp = (struct fcb *)GETPTR(R_DS, R_DX); + fcbp = (struct fcb *)MAKEPTR(R_DS, R_DX); switch (R_AH) { @@ -2201,14 +2201,14 @@ int21_fcb(regcontext_t *REGS) debug(D_FILE_OPS,"parse filename: flag=%d, ", R_AL); R_AX = parse_filename(R_AL, - (char *)N_GETPTR(R_DS, R_SI), - (char *)N_GETPTR(R_ES, R_DI), + (char *)MAKEPTR(R_DS, R_SI), + (char *)MAKEPTR(R_ES, R_DI), &nbytes); debug(D_FILE_OPS, "%d %s, FCB: %d, %.11s\n", nbytes, - N_GETPTR(R_DS, R_SI), - *(int *)N_GETPTR(R_ES, R_DI), - N_GETPTR(R_ES, R_DI) + 1); + MAKEPTR(R_DS, R_SI), + *(int *)MAKEPTR(R_ES, R_DI), + MAKEPTR(R_ES, R_DI) + 1); R_SI += nbytes; break; diff --git a/usr.bin/doscmd/doscmd.c b/usr.bin/doscmd/doscmd.c index 8e8da70..77b9e13 100644 --- a/usr.bin/doscmd/doscmd.c +++ b/usr.bin/doscmd/doscmd.c @@ -103,12 +103,12 @@ int main(int argc, char **argv) { #ifndef USE_VM86 - struct sigcontext sc; + ucontext_t uc; #else struct vm86_struct vm86s; #define sc vm86s.substr.regs.vmsc #endif - regcontext_t *REGS = (regcontext_t *)≻ + regcontext_t *REGS = (regcontext_t *)&uc.uc_mcontext; int fd; int i; char buffer[4096]; @@ -250,14 +250,14 @@ main(int argc, char **argv) video_vector = insert_generic_trampoline( sizeof(video_trampoline), video_trampoline); - N_PUSH(R_FLAGS, REGS); - N_PUSH(R_CS, REGS); - N_PUSH(R_IP, REGS); - N_PUTVEC(R_CS, R_IP, video_vector); + PUSH(R_FLAGS, REGS); + PUSH(R_CS, REGS); + PUSH(R_IP, REGS); + PUTVEC(R_CS, R_IP, video_vector); } - sigemptyset(&sc.sc_mask); - sc.sc_onstack = 0; + sigemptyset(&uc.uc_sigmask); + sigaltstack(NULL, &uc.uc_stack); if (tmode) tracetrap(REGS); @@ -268,7 +268,7 @@ main(int argc, char **argv) i386_vm86(VM86_INIT, &kargs); - sigreturn(&sc); + sigreturn(&uc); debug(D_ALWAYS,"sigreturn failed : %s\n", strerror(errno)); #else vm86s.cpu_type = VCPU_586; @@ -276,7 +276,7 @@ main(int argc, char **argv) #endif /* shouldn't get here */ - if (vflag) dump_regs((regcontext_t *)&sc); + if (vflag) dump_regs(REGS); fatal ("vm86 returned (no kernel support?)\n"); #undef sc } diff --git a/usr.bin/doscmd/doscmd.h b/usr.bin/doscmd/doscmd.h index 1c96064..44d06c9 100644 --- a/usr.bin/doscmd/doscmd.h +++ b/usr.bin/doscmd/doscmd.h @@ -37,6 +37,7 @@ #define USE_VM86 #endif +#include <sys/param.h> #include <sys/types.h> #include <sys/time.h> #include <sys/stat.h> @@ -49,6 +50,9 @@ #include <string.h> #include <errno.h> +#include <sys/signalvar.h> +#include <machine/sigframe.h> + #include <machine/frame.h> #include <machine/psl.h> #include <machine/npx.h> diff --git a/usr.bin/doscmd/ems.c b/usr.bin/doscmd/ems.c index 1b9b045..14bbd94 100644 --- a/usr.bin/doscmd/ems.c +++ b/usr.bin/doscmd/ems.c @@ -817,7 +817,7 @@ ems_entry(regcontext_t *REGS) /* Some checks */ if (emvp->src_type == EMS_MOVE_CONV) { /* Conventional memory source */ - src_addr = N_GETPTR(emvp->src_seg, emvp->src_offset); + src_addr = MAKEPTR(emvp->src_seg, emvp->src_offset); /* May not exceed conventional memory */ if ((src_addr + emvp->length) > 640 * 1024) { R_AH = EMS_SW_MALFUNC; @@ -842,7 +842,7 @@ ems_entry(regcontext_t *REGS) if (emvp->dst_type == EMS_MOVE_CONV) { /* Conventional memory source */ - dst_addr = N_GETPTR(emvp->dst_seg, emvp->dst_offset); + dst_addr = MAKEPTR(emvp->dst_seg, emvp->dst_offset); /* May not exceed conventional memory */ if ((dst_addr + emvp->length) > 640 * 1024) { R_AH = EMS_SW_MALFUNC; @@ -1202,7 +1202,7 @@ static void *get_valid_pointer(u_short seg, u_short offs, u_long size) { u_long addr; - addr = N_GETPTR(seg, offs); + addr = MAKEPTR(seg, offs); /* Check bounds */ if ((addr + size) >= (1024 * 1024) || addr < 1024) return NULL; diff --git a/usr.bin/doscmd/emuint.c b/usr.bin/doscmd/emuint.c index 9c230a3..750a6f9 100644 --- a/usr.bin/doscmd/emuint.c +++ b/usr.bin/doscmd/emuint.c @@ -57,7 +57,7 @@ emuint(regcontext_t *REGS) func = R_AH; subfunc = R_AL; - R_AX = N_POP(REGS); + R_AX = POP(REGS); /* Call the function handler, subfunction is ignored, if unused */ switch (func) @@ -101,7 +101,7 @@ emuint(regcontext_t *REGS) fprintf(stderr, " `redir.com' as soon as possible.\n"); fprintf(stderr, "*** This compatability hack is not permanent.\n"); fprintf(stderr, "***\n"); - N_PUSH(R_AX, REGS); + PUSH(R_AX, REGS); R_BX = R_ES; R_DX = R_DI; R_DI = R_DS; diff --git a/usr.bin/doscmd/int.c b/usr.bin/doscmd/int.c index 3b72e24..7657d21 100644 --- a/usr.bin/doscmd/int.c +++ b/usr.bin/doscmd/int.c @@ -42,15 +42,15 @@ softint(int intnum) debug(D_TRAPS|intnum, "Int%x [%04x:%04x]\n", intnum, vec >> 16, vec & 0xffff); - N_PUSH((R_FLAGS & ~PSL_I) | (R_EFLAGS & PSL_VIF ? PSL_I : 0), REGS); - N_PUSH(R_CS, REGS); - N_PUSH(R_IP, REGS); + PUSH((R_FLAGS & ~PSL_I) | (R_EFLAGS & PSL_VIF ? PSL_I : 0), REGS); + PUSH(R_CS, REGS); + PUSH(R_IP, REGS); #if 1 R_EFLAGS &= ~PSL_VIF; /* XXX disable interrupts? */ #else R_EFLAGS |= PSL_VIF; #endif - N_PUTVEC(R_CS, R_IP, vec); + PUTVEC(R_CS, R_IP, vec); } /* @@ -90,15 +90,15 @@ hardint(int intnum) debug(D_TRAPS|intnum, "Int%x [%04x:%04x]\n", intnum, vec >> 16, vec & 0xffff); - N_PUSH((R_FLAGS & ~PSL_I) | (R_EFLAGS & PSL_VIF ? PSL_I : 0), REGS); - N_PUSH(R_CS, REGS); - N_PUSH(R_IP, REGS); + PUSH((R_FLAGS & ~PSL_I) | (R_EFLAGS & PSL_VIF ? PSL_I : 0), REGS); + PUSH(R_CS, REGS); + PUSH(R_IP, REGS); #if 1 R_EFLAGS &= ~PSL_VIF; /* XXX disable interrupts */ #else R_EFLAGS |= PSL_VIF; #endif - N_PUTVEC(R_CS, R_IP, vec); + PUTVEC(R_CS, R_IP, vec); } typedef void (*foo_t)(int); diff --git a/usr.bin/doscmd/int10.c b/usr.bin/doscmd/int10.c index 32bec88..c05e626 100644 --- a/usr.bin/doscmd/int10.c +++ b/usr.bin/doscmd/int10.c @@ -54,102 +54,102 @@ int10(REGISTERS) */ reset_poll(); - switch (GET8H(sc->sc_eax)) { + switch (R_AH) { case 0x00: /* Set display mode */ - debug(D_HALF, "Set video mode to %02x\n", GET8L(sc->sc_eax)); + debug(D_HALF, "Set video mode to %02x\n", R_AL); break; case 0x01: /* Define cursor */ - curs_start = GET8H(sc->sc_ecx); - curs_end = GET8L(sc->sc_ecx); + curs_start = R_CH; + curs_end = R_CL; break; case 0x02: /* Position cursor */ if (!xmode) goto unsupported; - tty_move(GET8H(sc->sc_edx), GET8L(sc->sc_edx)); + tty_move(R_DH, R_DL); break; case 0x03: /* Read cursor position */ if (!xmode) goto unsupported; tty_report(&i, &j); - SET8H(sc->sc_edx, i); - SET8L(sc->sc_edx, j); - SET8H(sc->sc_ecx, curs_start); - SET8L(sc->sc_ecx, curs_end); + R_DH = i; + R_DL = j; + R_CH = curs_start; + R_CL = curs_end; break; case 0x05: - debug(D_HALF, "Select current display page %d\n", GET8L(sc->sc_eax)); + debug(D_HALF, "Select current display page %d\n", R_AL); break; case 0x06: /* initialize window/scroll text upward */ if (!xmode) goto unsupported; - tty_scroll(GET8H(sc->sc_ecx), GET8L(sc->sc_ecx), - GET8H(sc->sc_edx), GET8L(sc->sc_edx), - GET8L(sc->sc_eax), GET8H(sc->sc_ebx) << 8); + tty_scroll(R_CH, R_CL, + R_DH, R_DL, + R_AL, R_BH << 8); break; case 0x07: /* initialize window/scroll text downward */ if (!xmode) goto unsupported; - tty_rscroll(GET8H(sc->sc_ecx), GET8L(sc->sc_ecx), - GET8H(sc->sc_edx), GET8L(sc->sc_edx), - GET8L(sc->sc_eax), GET8H(sc->sc_ebx) << 8); + tty_rscroll(R_CH, R_CL, + R_DH, R_DL, + R_AL, R_BH << 8); break; case 0x08: /* read character/attribute */ if (!xmode) goto unsupported; i = tty_char(-1, -1); - SET16(sc->sc_eax, i); + R_AX = i; break; case 0x09: /* write character/attribute */ if (!xmode) goto unsupported; - tty_rwrite(GET16(sc->sc_ecx), GET8L(sc->sc_eax), GET8L(sc->sc_ebx) << 8); + tty_rwrite(R_CX, R_AL, R_BL << 8); break; case 0x0a: /* write character */ if (!xmode) goto unsupported; - tty_rwrite(GET16(sc->sc_ecx), GET8L(sc->sc_eax), -1); + tty_rwrite(R_CX, R_AL, -1); break; case 0x0b: /* set border color */ if (!xmode) goto unsupported; - video_setborder(GET8L(sc->sc_ebx)); + video_setborder(R_BL); break; case 0x0e: /* write character */ - tty_write(GET8L(sc->sc_eax), -1); + tty_write(R_AL, -1); break; case 0x0f: /* get display mode */ - SET8H(sc->sc_eax, 80); /* number of columns */ - SET8L(sc->sc_eax, 3); /* color */ - SET8H(sc->sc_ebx, 0); /* display page */ + R_AH = 80; /* number of columns */ + R_AL = 3; /* color */ + R_BH = 0; /* display page */ break; case 0x10: - switch (GET8L(sc->sc_eax)) { + switch (R_AL) { case 0x01: - video_setborder(GET8H(sc->sc_ebx) & 0x0f); + video_setborder(R_BH & 0x0f); break; case 0x02: /* Set pallete registers */ debug(D_HALF, "INT 10 10:02 Set all palette registers\n"); break; case 0x03: /* Enable/Disable blinking mode */ - video_blink(GET8L(sc->sc_ebx) ? 1 : 0); + video_blink(R_BL ? 1 : 0); break; case 0x13: debug(D_HALF, "INT 10 10:13 Select color or DAC (%02x, %02x)\n", - GET8L(sc->sc_ebx), GET8H(sc->sc_ebx)); + R_BL, R_BH); break; case 0x1a: /* get video dac color-page state */ - SET8H(sc->sc_ebx, 0); /* Current page */ - SET8L(sc->sc_ebx, 0); /* four pages of 64... */ + R_BH = 0; /* Current page */ + R_BL = 0; /* four pages of 64... */ break; default: - unknown_int3(0x10, 0x10, GET8L(sc->sc_eax), sc); + unknown_int3(0x10, 0x10, R_AL, REGS); break; } break; #if 1 case 0x11: - switch (GET8L(sc->sc_eax)) { + switch (R_AL) { case 0x00: printf("Tried to load user defined font.\n"); break; case 0x01: printf("Tried to load 8x14 font.\n"); break; case 0x02: printf("Tried to load 8x8 font.\n"); break; @@ -160,14 +160,14 @@ int10(REGISTERS) case 0x12: printf("Tried to load and activate 8x8 font.\n"); break; case 0x14: printf("Tried to load and activate 8x16 font.\n"); break; case 0x30: - SET16(sc->sc_ecx, 14); - SET8L(sc->sc_edx, 24); - switch(GET8H(sc->sc_ebx)) { + R_CX = 14; + R_DL = 24; + switch(R_BH) { case 0: - PUTVEC(sc->sc_es, sc->sc_ebp, ivec[0x1f]); + PUTVEC(R_ES, R_BP, ivec[0x1f]); break; case 1: - PUTVEC(sc->sc_es, sc->sc_ebp, ivec[0x43]); + PUTVEC(R_ES, R_BP, ivec[0x43]); break; case 2: case 3: @@ -175,19 +175,19 @@ int10(REGISTERS) case 5: case 6: case 7: - SET16(sc->sc_es, 0); - SET16(sc->sc_ebp, 0); + R_ES = 0; + R_BP = 0; debug(D_HALF, "INT 10 11:30 Request font address %02x", - GET8H(sc->sc_ebx)); + R_BH); break; default: - unknown_int4(0x10, 0x11, 0x30, GET8H(sc->sc_ebx), sc); + unknown_int4(0x10, 0x11, 0x30, R_BH, REGS); break; } break; default: - unknown_int3(0x10, 0x11, GET8L(sc->sc_eax), sc); + unknown_int3(0x10, 0x11, R_AL, REGS); break; } break; @@ -195,45 +195,45 @@ int10(REGISTERS) case 0x12: /* Load multiple DAC color register */ if (!xmode) goto unsupported; - switch (GET8L(sc->sc_ebx)) { + switch (R_BL) { case 0x10: /* Read EGA/VGA config */ - SET8H(sc->sc_ebx, 0); /* Color */ - SET8L(sc->sc_ebx, 0); /* 64K */ + R_BH = 0; /* Color */ + R_BL = 0; /* 64K */ break; default: - unknown_int3(0x10, 0x12, GET8L(sc->sc_ebx), sc); + unknown_int3(0x10, 0x12, R_BL, REGS); break; } break; case 0x13: /* write character string */ if (!xmode) goto unsupported; - addr = (char *)GETPTR(sc->sc_es, sc->sc_ebp); - switch (GET8L(sc->sc_eax) & 0x03) { + addr = (char *)MAKEPTR(R_ES, R_BP); + switch (R_AL & 0x03) { case 0: tty_report(&saved_row, &saved_col); - tty_move(GET8H(sc->sc_edx), GET8L(sc->sc_edx)); - for (i = 0; i < GET16(sc->sc_ecx); ++i) - tty_write(*addr++, GET8L(sc->sc_ebx) << 8); + tty_move(R_DH, R_DL); + for (i = 0; i < R_CX; ++i) + tty_write(*addr++, R_BL << 8); tty_move(saved_row, saved_col); break; case 1: - tty_move(GET8H(sc->sc_edx), GET8L(sc->sc_edx)); - for (i = 0; i < GET16(sc->sc_ecx); ++i) - tty_write(*addr++, GET8L(sc->sc_ebx) << 8); + tty_move(R_DH, R_DL); + for (i = 0; i < R_CX; ++i) + tty_write(*addr++, R_BL << 8); break; case 2: tty_report(&saved_row, &saved_col); - tty_move(GET8H(sc->sc_edx), GET8L(sc->sc_edx)); - for (i = 0; i < GET16(sc->sc_ecx); ++i) { + tty_move(R_DH, R_DL); + for (i = 0; i < R_CX; ++i) { tty_write(addr[0], addr[1]); addr += 2; } tty_move(saved_row, saved_col); break; case 3: - tty_move(GET8H(sc->sc_edx), GET8L(sc->sc_edx)); - for (i = 0; i < GET16(sc->sc_ecx); ++i) { + tty_move(R_DH, R_DL); + for (i = 0; i < R_CX; ++i) { tty_write(addr[0], addr[1]); addr += 2; } @@ -243,13 +243,13 @@ int10(REGISTERS) case 0x1a: if (!xmode) goto unsupported; - SET8L(sc->sc_eax, 0x1a); /* I am VGA */ - SET8L(sc->sc_ebx, 8); /* Color VGA */ - SET8H(sc->sc_ebx, 0); /* No other card */ + R_AL = 0x1a; /* I am VGA */ + R_BL = 8; /* Color VGA */ + R_BH = 0; /* No other card */ break; case 0x4f: /* get VESA information */ - SET8H(sc->sc_eax, 0x01); /* no VESA support */ + R_AH = 0x01; /* no VESA support */ break; case 0x1b: /* Functionality state information */ @@ -258,7 +258,7 @@ int10(REGISTERS) break; case 0xfa: /* Interrogate mouse driver */ if (xmode) - PUTPTR(sc->sc_es, sc->sc_ebx, (long)mouse_area); + PUTPTR(R_ES, R_BX, (long)mouse_area); break; case 0xff: /* Update real screen from video buffer */ /* XXX - we should allow secondary buffer here and then @@ -266,12 +266,12 @@ int10(REGISTERS) break; unsupported: - if (vflag) dump_regs(sc); + if (vflag) dump_regs(REGS); fatal ("int10 function 0x%02x:%02x only available in X mode\n", - GET8H(sc->sc_eax), GET8L(sc->sc_eax)); + R_AH, R_AL); unknown: default: - unknown_int2(0x10, GET8H(sc->sc_eax), sc); + unknown_int2(0x10, R_AH, REGS); break; } } diff --git a/usr.bin/doscmd/int13.c b/usr.bin/doscmd/int13.c index 84cb13f..ded17c85 100644 --- a/usr.bin/doscmd/int13.c +++ b/usr.bin/doscmd/int13.c @@ -599,7 +599,7 @@ int13(regcontext_t *REGS) break; case 0x02: /* Read */ R_AH = 0; - addr = (char *)N_GETPTR(R_ES, R_BX); + addr = (char *)MAKEPTR(R_ES, R_BX); sectors = R_AL; side = R_DH; R_AL = 0; /* Start out with nothing read */ @@ -658,7 +658,7 @@ int13(regcontext_t *REGS) case 0x03: /* Write */ R_AH = 0; - addr = (char *)GETPTR(R_ES, R_BX); + addr = (char *)MAKEPTR(R_ES, R_BX); sectors = R_AL; side = R_DH; R_AL = 0; /* Start out with nothing written */ @@ -792,7 +792,7 @@ int13(regcontext_t *REGS) R_BX = di->type; if ((drive & 0x80) == 0) - N_PUTVEC(R_ES, R_DI, di->location); + PUTVEC(R_ES, R_DI, di->location); R_CL = di->sectors | ((di->cylinders >> 2) & 0xc0); R_CH = di->cylinders & 0xff; diff --git a/usr.bin/doscmd/intff.c b/usr.bin/doscmd/intff.c index fd167af..800424c 100644 --- a/usr.bin/doscmd/intff.c +++ b/usr.bin/doscmd/intff.c @@ -273,7 +273,7 @@ int2f11_open(regcontext_t *REGS) ** get attributes/access mode off stack : low byte is attribute, high ** byte is (sometimes) used in conjunction with 'action' */ - attr = *(u_short *)N_GETPTR(R_SS, R_SP) & 0xff; + attr = *(u_short *)MAKEPTR(R_SS, R_SP) & 0xff; /* which style? */ switch(R_AL) { @@ -482,8 +482,8 @@ int2f11_fnqual(regcontext_t *REGS) savedrive = diskdrive; /* to get CWD for network drive */ diskdrive = n_drive; - fname = (char *)N_GETPTR(R_DS, R_SI); /* path pointers */ - tname = (char *)N_GETPTR(R_ES, R_DI); + fname = (char *)MAKEPTR(R_DS, R_SI); /* path pointers */ + tname = (char *)MAKEPTR(R_ES, R_DI); error = dos_makepath(fname, tname); if (error) @@ -610,7 +610,7 @@ int2f11_validate(regcontext_t *REGS) case 0x0c: /* in es:di */ case 0x1c: - r_cds = (CDS *)N_GETPTR(R_ES, R_DI); + r_cds = (CDS *)MAKEPTR(R_ES, R_DI); break; } @@ -628,7 +628,7 @@ int2f11_validate(regcontext_t *REGS) case 0x21: case 0x2d: case 0x2e: - r_sft = (SFT *)N_GETPTR(R_ES, R_DI); + r_sft = (SFT *)MAKEPTR(R_ES, R_DI); break; } @@ -796,8 +796,8 @@ intff(regcontext_t *REGS) debug(D_REDIR, "redirector duplicate install ignored\n"); return; } - lol = (LOL *)N_GETPTR(R_BX, R_DX); /* where DOS keeps its goodies */ - sda = (SDA *)N_GETPTR(R_DI, R_SI); + lol = (LOL *)MAKEPTR(R_BX, R_DX); /* where DOS keeps its goodies */ + sda = (SDA *)MAKEPTR(R_DI, R_SI); init_drives(); /* initialise dispatcher */ diff --git a/usr.bin/doscmd/mouse.c b/usr.bin/doscmd/mouse.c index c9a0774..93416b8 100644 --- a/usr.bin/doscmd/mouse.c +++ b/usr.bin/doscmd/mouse.c @@ -151,7 +151,7 @@ int33(regcontext_t *REGS) case 0x0c: /* Set event handler */ mouse_status.mask = R_CX; - mouse_status.handler = N_GETVEC(R_ES, R_DX); + mouse_status.handler = MAKEVEC(R_ES, R_DX); break; case 0x0d: /* Enable light pen */ @@ -177,9 +177,9 @@ int33(regcontext_t *REGS) vec = mouse_status.handler; mouse_status.mask = R_CX; - mouse_status.handler = GETVEC(R_ES, R_DX); + mouse_status.handler = MAKEVEC(R_ES, R_DX); R_CX = mask; - N_PUTVEC(R_ES, R_DX, vec); + PUTVEC(R_ES, R_DX, vec); break; case 0x15: /* Determine mouse status buffer size */ @@ -187,12 +187,12 @@ int33(regcontext_t *REGS) break; case 0x16: /* Store mouse buffer */ - memcpy((char *)N_GETPTR(R_ES, R_DX), &mouse_status, + memcpy((char *)MAKEPTR(R_ES, R_DX), &mouse_status, sizeof(mouse_status)); break; case 0x17: /* Restore mouse buffer */ - memcpy(&mouse_status, (char *)N_GETPTR(R_ES, R_DX), + memcpy(&mouse_status, (char *)MAKEPTR(R_ES, R_DX), sizeof(mouse_status)); break; @@ -209,7 +209,7 @@ int33(regcontext_t *REGS) break; } mouse_status.altmask[i] = R_CX; - mouse_status.althandler[i] = N_GETVEC(R_ES, R_DX); + mouse_status.althandler[i] = MAKEVEC(R_ES, R_DX); break; case 0x19: /* Determine address of alternate event handler */ @@ -222,7 +222,7 @@ int33(regcontext_t *REGS) vec = mouse_status.althandler[2]; else R_CX = 0; - N_PUTVEC(R_ES, R_DX, vec); + PUTVEC(R_ES, R_DX, vec); break; case 0x1a: /* set mouse sensitivity */ @@ -247,7 +247,7 @@ int33(regcontext_t *REGS) case 0x1f: /* Disable mouse driver */ if (mouse_status.installed) { - N_PUTVEC(R_ES, R_DX, mouse_status.handler); + PUTVEC(R_ES, R_DX, mouse_status.handler); mouse_status.installed = 0; } else { R_AX = 0xffff; diff --git a/usr.bin/doscmd/port.c b/usr.bin/doscmd/port.c index eb2158f..9159321 100644 --- a/usr.bin/doscmd/port.c +++ b/usr.bin/doscmd/port.c @@ -246,7 +246,7 @@ insb(regcontext_t *REGS, int port) else in_handler = inb_nullport; data = (*in_handler)(port); - *(u_char *)N_GETPTR(R_ES, R_DI) = data; + *(u_char *)MAKEPTR(R_ES, R_DI) = data; debug(D_PORT, "INS on port %02x -> %02x\n", port, data); if (R_FLAGS & PSL_D) @@ -284,7 +284,7 @@ insx(regcontext_t *REGS, int port) else in_handler = inb_nullport; data = (*in_handler)(port); - *(u_char *)N_GETPTR(R_ES, R_DI) = data; + *(u_char *)MAKEPTR(R_ES, R_DI) = data; debug(D_PORT, "INS on port %02x -> %02x\n", port, data); if ((port >= MINPORT) && (port < MAXPORT)) @@ -292,7 +292,7 @@ insx(regcontext_t *REGS, int port) else in_handler = inb_nullport; data = (*in_handler)(port + 1); - ((u_char *)N_GETPTR(R_ES, R_DI))[1] = data; + ((u_char *)MAKEPTR(R_ES, R_DI))[1] = data; debug(D_PORT, "INS on port %02x -> %02x\n", port, data); if (R_FLAGS & PSL_D) @@ -347,7 +347,7 @@ outsb(regcontext_t *REGS, int port) out_handler = portsw[port].p_outb; else out_handler = outb_nullport; - value = *(u_char *)N_GETPTR(R_ES, R_DI); + value = *(u_char *)MAKEPTR(R_ES, R_DI); debug(D_PORT, "OUT on port %02x <- %02x\n", port, value); (*out_handler)(port, value); @@ -367,7 +367,7 @@ outsx(regcontext_t *REGS, int port) out_handler = portsw[port].p_outb; else out_handler = outb_nullport; - value = *(u_char *)N_GETPTR(R_ES, R_DI); + value = *(u_char *)MAKEPTR(R_ES, R_DI); debug(D_PORT, "OUT on port %02x <- %02x\n", port, value); (*out_handler)(port, value); @@ -375,7 +375,7 @@ outsx(regcontext_t *REGS, int port) out_handler = portsw[port + 1].p_outb; else out_handler = outb_nullport; - value = ((u_char *)N_GETPTR(R_ES, R_DI))[1]; + value = ((u_char *)MAKEPTR(R_ES, R_DI))[1]; debug(D_PORT, "OUT on port %02x <- %02x\n", port+1, value); (*out_handler)(port + 1, value); diff --git a/usr.bin/doscmd/register.h b/usr.bin/doscmd/register.h index ba0e91e..346807e 100644 --- a/usr.bin/doscmd/register.h +++ b/usr.bin/doscmd/register.h @@ -31,8 +31,6 @@ ** */ -#define NEW_REGISTERS - #ifndef _MACHINE_VM86_H_ /* standard register representation */ @@ -60,30 +58,30 @@ typedef union typedef struct { - int pad[2]; - reg86_t esp; - reg86_t ebp; - reg86_t isp; - reg86_t eip; - reg86_t efl; + reg86_t gs; + reg86_t fs; reg86_t es; reg86_t ds; - reg86_t cs; - reg86_t ss; reg86_t edi; reg86_t esi; + reg86_t ebp; + reg86_t isp; reg86_t ebx; reg86_t edx; reg86_t ecx; reg86_t eax; - reg86_t gs; - reg86_t fs; + int pad[2]; + reg86_t eip; + reg86_t cs; + reg86_t efl; + reg86_t esp; + reg86_t ss; } registers_t; typedef union { - struct sigcontext sc; - registers_t r; + mcontext_t sc; + registers_t r; } regcontext_t; /* @@ -146,34 +144,29 @@ typedef union ** register manipulation macros */ -#define N_PUTVEC(s, o, x) ((s) = ((x) >> 16), (o) = (x) & 0xffff) -#define MAKEVEC(s, o) (((s) << 16) + (o)) /* XXX these two should be combined */ -#define N_GETVEC(s, o) (((s) << 16) + (o)) +#define PUTVEC(s, o, x) ((s) = ((x) >> 16), (o) = (x) & 0xffff) +#define MAKEVEC(s, o) (((s) << 16) + (o)) -#define N_PUTPTR(s, o, x) (((s) = ((x) & 0xf0000) >> 4), (o) = (x) & 0xffff) -#define MAKEPTR(s, o) (((s) << 4) + (o)) /* XXX these two should be combined */ -#define N_GETPTR(s, o) (((s) << 4) + (o)) +#define PUTPTR(s, o, x) (((s) = ((x) & 0xf0000) >> 4), (o) = (x) & 0xffff) +#define MAKEPTR(s, o) (((s) << 4) + (o)) #define VECPTR(x) MAKEPTR((x) >> 16, (x) & 0xffff) -#if 0 -#define N_REGISTERS regcontext_t *_regcontext -#define N_REGS _regcontex -#endif +#define REGISTERS regcontext_t *REGS inline static void -N_PUSH(u_short x, regcontext_t *REGS) +PUSH(u_short x, REGISTERS) { R_SP -= 2; - *(u_short *)N_GETPTR(R_SS, R_SP) = (x); + *(u_short *)MAKEPTR(R_SS, R_SP) = (x); } inline static u_short -N_POP(regcontext_t *REGS) +POP(REGISTERS) { u_short x; - x = *(u_short *)N_GETPTR(R_SS, R_SP); + x = *(u_short *)MAKEPTR(R_SS, R_SP); R_SP += 2; return(x); } @@ -181,42 +174,3 @@ N_POP(regcontext_t *REGS) # ifndef PSL_ALLCC /* Grr, FreeBSD doesn't have this */ # define PSL_ALLCC (PSL_C|PSL_PF|PSL_AF|PSL_Z|PSL_N) # endif - -/****************************************************************************** -** older stuff below here -*/ - -#define REGISTERS struct sigcontext *sc - -#define GET16(x) (x & 0xffff) -#define GET8L(x) (x & 0xff) -#define GET8H(x) ((x >> 8) & 0xff) -#define SET16(x, y) (x = (x & ~0xffff) | (y & 0xffff)) -#define SET8L(x, y) (x = (x & ~0xff) | (y & 0xff)) -#define SET8H(x, y) (x = (x & ~0xff00) | ((y & 0xff) << 8)) - -#define PUTVEC(s, o, x) (SET16(s, x >> 16), SET16(o, x)) -#define GETVEC(s, o) MAKEVEC(GET16(s), GET16(o)) - -#define PUTPTR(s, o, x) (SET16(s, (x & 0xf0000) >> 4), SET16(o, x)) -#define GETPTR(s, o) MAKEPTR(GET16(s), GET16(o)) - -#define VECPTR(x) MAKEPTR((x) >> 16, (x) & 0xffff) - -inline static void -PUSH(u_short x, struct sigcontext *sc) -{ - SET16(sc->sc_esp, GET16(sc->sc_esp) - 2); - *(u_short *)GETPTR(sc->sc_ss, sc->sc_esp) = x; -} - -inline static u_short -POP(struct sigcontext *sc) -{ - u_short x; - - x = *(u_short *)GETPTR(sc->sc_ss, sc->sc_esp); - SET16(sc->sc_esp, GET16(sc->sc_esp) + 2); - return (x); -} - diff --git a/usr.bin/doscmd/signal.c b/usr.bin/doscmd/signal.c index 7041597..297bf37 100644 --- a/usr.bin/doscmd/signal.c +++ b/usr.bin/doscmd/signal.c @@ -66,9 +66,9 @@ sanity_check(struct sigframe *sf) static void generichandler(struct sigframe sf) { - if (sf.sf_siginfo.si_sc.sc_efl & PSL_VM) { + if (sf.sf_uc.uc_mcontext.mc_tf.tf_eflags & PSL_VM) { saved_sigframe = &sf; - saved_regcontext = (regcontext_t *)&(sf.sf_siginfo.si_sc); + saved_regcontext = (regcontext_t *)&(sf.sf_uc.uc_mcontext); saved_valid = 1; if (handler[sf.sf_signum]) (*handler[sf.sf_signum])(&sf); diff --git a/usr.bin/doscmd/trace.c b/usr.bin/doscmd/trace.c index 9be758f..0e76b19 100644 --- a/usr.bin/doscmd/trace.c +++ b/usr.bin/doscmd/trace.c @@ -99,7 +99,7 @@ tracetrap(regcontext_t *REGS) if ((R_EFLAGS & PSL_VM) == 0) return; - addr = (u_char *)N_GETPTR(R_CS, R_IP); + addr = (u_char *)MAKEPTR(R_CS, R_IP); n = i386dis(R_CS, R_IP, addr, buf, 0); printtrace(REGS, buf); @@ -129,9 +129,9 @@ tracetrap(regcontext_t *REGS) saddr = (u_short *)MAKEPTR(R_SS, R_SP + 4); #if 0 printf("IRET: %04x %04x %04x\n", - ((u_short *)N_GETPTR(R_SS, R_SP))[0], - ((u_short *)N_GETPTR(R_SS, R_SP))[1], - ((u_short *)N_GETPTR(R_SS, R_SP))[2]); + ((u_short *)MAKEPTR(R_SS, R_SP))[0], + ((u_short *)MAKEPTR(R_SS, R_SP))[1], + ((u_short *)MAKEPTR(R_SS, R_SP))[2]); #endif break; case OPSIZ: @@ -194,7 +194,7 @@ printtrace(regcontext_t *REGS, char *buf) { static int first = 1; - u_char *addr = (u_char *)N_GETPTR(R_CS, R_IP); + u_char *addr = (u_char *)MAKEPTR(R_CS, R_IP); char *bigfmt = "%04x:%04x " #if BIG_DEBUG "%02x %02x %02x %02x %02x %02x " diff --git a/usr.bin/doscmd/trap.c b/usr.bin/doscmd/trap.c index 8b41caa..1c743b3 100644 --- a/usr.bin/doscmd/trap.c +++ b/usr.bin/doscmd/trap.c @@ -88,7 +88,7 @@ user_int: R_CS = 0x2c7; R_IP = 0x14f9; - addr = (char *)N_GETPTR(R_CS, R_IP); + addr = (char *)MAKEPTR(R_CS, R_IP); printf("\n"); for (i = 0; i < 100; i++) { @@ -125,11 +125,11 @@ user_int: reset_poll(); /* stack for and call the interrupt in vm86 space */ - N_PUSH((R_FLAGS & ~PSL_I) | (R_EFLAGS & PSL_VIF ? PSL_I : 0), REGS); - N_PUSH(R_CS, REGS); - N_PUSH(R_IP, REGS); + PUSH((R_FLAGS & ~PSL_I) | (R_EFLAGS & PSL_VIF ? PSL_I : 0), REGS); + PUSH(R_CS, REGS); + PUSH(R_IP, REGS); R_EFLAGS &= ~PSL_VIF; /* disable interrupts */ - N_PUTVEC(R_CS, R_IP, ivec[intnum]); + PUTVEC(R_CS, R_IP, ivec[intnum]); } /* make this read a little more intuitively */ @@ -182,7 +182,7 @@ sigurg(struct sigframe *sf) case VM86_UNKNOWN: /*XXXXX failed vector also gets here without IP adjust*/ - addr = (u_char *)GETPTR(sc->sc_cs, sc->sc_eip); + addr = (u_char *)MAKEPTR(sc->sc_cs, sc->sc_eip); rep = 1; debug (D_TRAPS2, "%04x:%04x [%02x]", GET16(sc->sc_cs), @@ -289,18 +289,18 @@ sigbus(struct sigframe *sf) int intnum; int port; callback_t func; - regcontext_t *REGS = (regcontext_t *)(&sf->sf_siginfo.si_sc); + regcontext_t *REGS = (regcontext_t *)(&sf->sf_uc.uc_mcontext); if (!(R_EFLAGS && PSL_VM)) fatal("SIGBUS in the emulator\n"); - if (sf->sf_arg2 != 0) { + if ((int)sf->sf_siginfo != 0) { fatal("SIGBUS code %d, trapno: %d, err: %d\n", - sf->sf_arg2, sf->sf_siginfo.si_sc.sc_trapno, - sf->sf_siginfo.si_sc.sc_err); + (int)sf->sf_siginfo, sf->sf_uc.uc_mcontext.mc_tf.tf_trapno, + sf->sf_uc.uc_mcontext.mc_tf.tf_err); } - addr = (u_char *)GETPTR(R_CS, R_IP); + addr = (u_char *)MAKEPTR(R_CS, R_IP); if (tmode) resettrace(REGS); @@ -352,13 +352,13 @@ sigbus(struct sigframe *sf) case PUSHF: debug (D_TRAPS2, "pushf <- 0x%x\n", R_EFLAGS); R_IP++; - N_PUSH((R_FLAGS & ~PSL_I) | (R_EFLAGS & PSL_VIF ? PSL_I : 0), + PUSH((R_FLAGS & ~PSL_I) | (R_EFLAGS & PSL_VIF ? PSL_I : 0), REGS); break; case IRET: - R_IP = N_POP(REGS); /* get new cs:ip off the stack */ - R_CS = N_POP(REGS); + R_IP = POP(REGS); /* get new cs:ip off the stack */ + R_CS = POP(REGS); debug (D_TRAPS2, "iret to %04x:%04x ", R_CS, R_IP); /* FALLTHROUGH */ /* 'safe' flag pop operation */ @@ -369,7 +369,7 @@ sigbus(struct sigframe *sf) if (addr[0] == POPF) R_IP++; /* get flags from stack */ - tempflags = N_POP(REGS); + tempflags = POP(REGS); /* flags we consider OK */ okflags = (PSL_ALLCC | PSL_T | PSL_D | PSL_V); /* keep state of non-OK flags */ @@ -475,7 +475,7 @@ sigbus(struct sigframe *sf) break; case HLT: /* BIOS entry points populated with HLT */ - func = find_callback(N_GETVEC(R_CS, R_IP)); + func = find_callback(MAKEVEC(R_CS, R_IP)); if (func) { R_IP++; /* pass HLT opcode */ func(REGS); @@ -509,7 +509,7 @@ void sigtrace(struct sigframe *sf) { int x; - regcontext_t *REGS = (regcontext_t *)(&sf->sf_siginfo.si_sc); + regcontext_t *REGS = (regcontext_t *)(&sf->sf_uc.uc_mcontext); if (R_EFLAGS & PSL_VM) { debug(D_ALWAYS, "Currently in DOS\n"); @@ -528,7 +528,7 @@ sigtrap(struct sigframe *sf) { int intnum; int trapno; - regcontext_t *REGS = (regcontext_t *)(&sf->sf_siginfo.si_sc); + regcontext_t *REGS = (regcontext_t *)(&sf->sf_uc.uc_mcontext); if ((R_EFLAGS & PSL_VM) == 0) { dump_regs(REGS); @@ -540,7 +540,7 @@ sigtrap(struct sigframe *sf) goto doh; #ifdef __FreeBSD__ - trapno = sf->sf_arg2; /* XXX GROSTIC HACK ALERT */ + trapno = (int)sf->sf_siginfo; /* XXX GROSTIC HACK ALERT */ #else trapno = sc->sc_trapno; #endif @@ -549,11 +549,11 @@ sigtrap(struct sigframe *sf) else intnum = 1; - N_PUSH((R_FLAGS & ~PSL_I) | (R_EFLAGS & PSL_VIF ? PSL_I : 0), REGS); - N_PUSH(R_CS, REGS); - N_PUSH(R_IP, REGS); + PUSH((R_FLAGS & ~PSL_I) | (R_EFLAGS & PSL_VIF ? PSL_I : 0), REGS); + PUSH(R_CS, REGS); + PUSH(R_IP, REGS); R_FLAGS &= ~PSL_T; - N_PUTVEC(R_CS, R_IP, ivec[intnum]); + PUTVEC(R_CS, R_IP, ivec[intnum]); doh: if (tmode) @@ -563,7 +563,7 @@ doh: void breakpoint(struct sigframe *sf) { - regcontext_t *REGS = (regcontext_t *)(&sf->sf_siginfo.si_sc); + regcontext_t *REGS = (regcontext_t *)(&sf->sf_uc.uc_mcontext); if (R_EFLAGS & PSL_VM) printf("doscmd "); @@ -581,7 +581,7 @@ breakpoint(struct sigframe *sf) void sigalrm(struct sigframe *sf) { - regcontext_t *REGS = (regcontext_t *)(&sf->sf_siginfo.si_sc); + regcontext_t *REGS = (regcontext_t *)(&sf->sf_uc.uc_mcontext); if (tmode) resettrace(REGS); @@ -599,7 +599,7 @@ sigalrm(struct sigframe *sf) void sigill(struct sigframe *sf) { - regcontext_t *REGS = (regcontext_t *)(&sf->sf_siginfo.si_sc); + regcontext_t *REGS = (regcontext_t *)(&sf->sf_uc.uc_mcontext); fprintf(stderr, "Signal %d from DOS program\n", sf->sf_signum); dump_regs(REGS); @@ -610,7 +610,7 @@ sigill(struct sigframe *sf) void sigfpe(struct sigframe *sf) { - regcontext_t *REGS = (regcontext_t *)(&sf->sf_siginfo.si_sc); + regcontext_t *REGS = (regcontext_t *)(&sf->sf_uc.uc_mcontext); if (R_EFLAGS & PSL_VM) { dump_regs(REGS); diff --git a/usr.bin/doscmd/tty.c b/usr.bin/doscmd/tty.c index d18f157..a76239e 100644 --- a/usr.bin/doscmd/tty.c +++ b/usr.bin/doscmd/tty.c @@ -409,7 +409,7 @@ video_update(REGISTERS) XGCValues v; if (kbd_read) - kbd_event(kbd_fd, sc); + kbd_event(kbd_fd, REGS); if (--icnt == 0) { @@ -734,7 +734,7 @@ debug_event(int fd, REGISTERS) ap += c; } } else if (!strcasecmp(av[0], "regs")) { - dump_regs(sc); + dump_regs(REGS); } else if (!strcasecmp(av[0], "force")) { char *p = av[1]; @@ -962,7 +962,7 @@ printf("FORCED REDRAW\n"); case 0x14: /* T */ tmode ^= 1; if (!tmode) - resettrace(&saved_sigframe->sf_siginfo.si_sc); + resettrace(&saved_sigframe->sf_uc.uc_mcontext); return(0xffff); case 0x53: /* DEL */ quit(0); @@ -1456,7 +1456,7 @@ video_event(XEvent *ev) tmode ^= 1; if (!tmode) resettrace(&saved_sigframe-> - sf_siginfo.si_sc); + sf_uc.uc_mcontext); break; } if (ks == 'R' || ks == 'r') { @@ -1743,8 +1743,8 @@ tty_read(REGISTERS, int flag) * all the way to the user, but... */ if (ivec[0x23] && (ivec[0x23] >> 16) != 0xF000) { - fake_int(sc, 0x23); - SET16(sc->sc_eip, GET16(sc->sc_eip) - 2); + fake_int(REGS, 0x23); + R_EIP = R_EIP - 2; return(-2); } } @@ -1785,8 +1785,8 @@ tty_peek(REGISTERS, int flag) * all the way to the user, but... */ if (ivec[0x23] && (ivec[0x23] >> 16) != 0xF000) { - fake_int(sc, 0x23); - SET16(sc->sc_eip, GET16(sc->sc_eip) - 2); + fake_int(REGS, 0x23); + R_EIP = R_EIP - 2; return(-2); } } diff --git a/usr.bin/doscmd/xms.c b/usr.bin/doscmd/xms.c index 9dbd4ba..08ed808 100644 --- a/usr.bin/doscmd/xms.c +++ b/usr.bin/doscmd/xms.c @@ -482,7 +482,7 @@ int2f_43(regcontext_t *REGS) break; case 0x10: /* get handler address */ - N_PUTVEC(R_ES, R_BX, xms_vector); + PUTVEC(R_ES, R_BX, xms_vector); break; default: @@ -721,7 +721,7 @@ xms_entry(regcontext_t *REGS) int n; debug(D_XMS, "XMS: Move EMM block: "); - eptr = (struct EMM *)N_GETPTR(R_DS, R_SI); + eptr = (struct EMM *)MAKEPTR(R_DS, R_SI); /* Sanity check: Don't allow eptr pointing to emulator data */ if (((u_long)eptr + sizeof(struct EMM)) >= 0x100000) { |