diff options
| author | Thomas Gellekum <tg@FreeBSD.org> | 2001-05-25 12:27:40 +0000 |
|---|---|---|
| committer | Thomas Gellekum <tg@FreeBSD.org> | 2001-05-25 12:27:40 +0000 |
| commit | a158a39e089e6fcaccfcc3e7e69a5654b4ce112a (patch) | |
| tree | f20de5b182c386dae0cf6f3f1fa1f5e0eb0f68d6 | |
| parent | 77e47e5f45665136c119c64fec262300b6bb60ea (diff) | |
Notes
| -rw-r--r-- | usr.bin/doscmd/dos.c | 29 | ||||
| -rw-r--r-- | usr.bin/doscmd/doscmd.c | 44 | ||||
| -rw-r--r-- | usr.bin/doscmd/int10.c | 15 | ||||
| -rw-r--r-- | usr.bin/doscmd/int13.c | 5 | ||||
| -rw-r--r-- | usr.bin/doscmd/intff.c | 4 | ||||
| -rw-r--r-- | usr.bin/doscmd/timer.c | 11 |
6 files changed, 85 insertions, 23 deletions
diff --git a/usr.bin/doscmd/dos.c b/usr.bin/doscmd/dos.c index 36e11aeee6b8..43a290bbdfd4 100644 --- a/usr.bin/doscmd/dos.c +++ b/usr.bin/doscmd/dos.c @@ -569,7 +569,7 @@ int21_0a(regcontext_t *REGS) int n; /* pointer to buffer */ - addr = (unsigned char *)MAKEPTR(R_DS, R_DL); + addr = (unsigned char *)MAKEPTR(R_DS, R_DX); /* capacity of buffer */ avail = addr[0]; @@ -1309,6 +1309,22 @@ int21_3f(regcontext_t *REGS) ** write */ static int +write_or_truncate(int fd, char *addr, int len) +{ + off_t offset; + + if (len == 0) { + offset = lseek(fd, 0, SEEK_CUR); + if (offset < 0) + return -1; + else + return ftruncate(fd, offset); + } else { + return write(fd, addr, len); + } +} + +static int int21_40(regcontext_t *REGS) { char *addr; @@ -1322,7 +1338,7 @@ int21_40(regcontext_t *REGS) switch (R_BX) { case 0: if (redirect0) { - n = write (R_BX, addr, nbytes); + n = write_or_truncate(R_BX, addr, nbytes); break; } n = nbytes; @@ -1331,7 +1347,7 @@ int21_40(regcontext_t *REGS) break; case 1: if (redirect1) { - n = write (R_BX, addr, nbytes); + n = write_or_truncate(R_BX, addr, nbytes); break; } n = nbytes; @@ -1340,7 +1356,7 @@ int21_40(regcontext_t *REGS) break; case 2: if (redirect2) { - n = write (R_BX, addr, nbytes); + n = write_or_truncate(R_BX, addr, nbytes); break; } n = nbytes; @@ -1348,7 +1364,7 @@ int21_40(regcontext_t *REGS) tty_write(*addr++, -1); break; default: - n = write (R_BX, addr, nbytes); + n = write_or_truncate(R_BX, addr, nbytes); break; } if (n < 0) @@ -1705,6 +1721,7 @@ int21_4c(regcontext_t *REGS) { return_status = R_AL; done(REGS, R_AL); + return 0; } /* @@ -2353,7 +2370,7 @@ static struct intfunc_table int21_table [] = { { 0x4e, IFT_NOSUBFUNC, int21_find, "findfirst"}, { 0x4f, IFT_NOSUBFUNC, int21_find, "findnext"}, { 0x50, IFT_NOSUBFUNC, int21_50, "set psp"}, - { 0x50, IFT_NOSUBFUNC, int21_62, "get psp"}, + { 0x51, IFT_NOSUBFUNC, int21_62, "get psp"}, { 0x52, IFT_NOSUBFUNC, int21_NOFUNC, "get LoL"}, { 0x53, IFT_NOSUBFUNC, int21_NOFUNC, "translate BPB to DPB"}, { 0x54, IFT_NOSUBFUNC, int21_NULLFUNC, "get verify flag"}, diff --git a/usr.bin/doscmd/doscmd.c b/usr.bin/doscmd/doscmd.c index 7463af6add23..9aaf73015394 100644 --- a/usr.bin/doscmd/doscmd.c +++ b/usr.bin/doscmd/doscmd.c @@ -79,6 +79,7 @@ struct vconnect_area vconnect_area = { /* local prototypes */ static void setup_boot(regcontext_t *REGS); +static int try_boot(int); static void setup_command(int argc, char *argv[], regcontext_t *REGS); static FILE *find_doscmdrc(void); static int do_args(int argc, char *argv[]); @@ -306,21 +307,15 @@ setup_boot(regcontext_t *REGS) booting = read_config(fp); /* where to boot from? */ fclose(fp); if (booting < 0) { /* not specified */ - if ((fd = disk_fd(booting = 0)) < 0) /* try A: */ - fd = disk_fd(booting = 2); /* try C: */ + if ((fd = try_boot(booting = 0)) < 0) /* try A: */ + fd = try_boot(booting = 2); /* try C: */ } else { - fd = disk_fd(booting); /* do like the man says */ - } - - if (fd < 0) { /* can we boot it? */ - errx(1, "Cannot boot from %c", drntol(booting)); - } - - /* read bootblock */ - if (read(fd, (char *)0x7c00, 512) != 512) { - errx(1, "Short read on boot block from %c:", drntol(booting)); + fd = try_boot(booting); /* do like the man says */ } + if (fd < 0) + errx(1, "Failed to boot"); + /* initialise registers for entry to bootblock */ R_EFLAGS = 0x20202; R_CS = 0x0000; @@ -342,6 +337,31 @@ setup_boot(regcontext_t *REGS) } /* +** try_boot +** +** try to read the boot sector from the specified disk +*/ +static int +try_boot(int booting) +{ + int fd; + + fd = disk_fd(booting); + if (fd < 0) { /* can we boot it? */ + debug(D_DISK, "Cannot boot from %c\n", drntol(booting)); + return -1; + } + + /* read bootblock */ + if (read(fd, (char *)0x7c00, 512) != 512) { + debug(D_DISK, "Short read on boot block from %c:\n", drntol(booting)); + return -1; + } + + return fd; +} + +/* ** setup_command ** ** Setup to run a single command and emulate DOS diff --git a/usr.bin/doscmd/int10.c b/usr.bin/doscmd/int10.c index c05e6263c0c9..f79f96f09952 100644 --- a/usr.bin/doscmd/int10.c +++ b/usr.bin/doscmd/int10.c @@ -253,6 +253,19 @@ int10(REGISTERS) break; case 0x1b: /* Functionality state information */ + break; + + case 0x6f: + switch (R_AL) { + case 0x00: /* HP-Vectra or Video7 installation check */ + R_BX = 0; /* nope, none of that */ + break; + default: + unknown_int3(0x10, 0x6f, R_AL, REGS); + break; + } + break; + case 0xef: case 0xfe: /* Get video buffer */ break; @@ -271,7 +284,7 @@ int10(REGISTERS) R_AH, R_AL); unknown: default: - unknown_int2(0x10, R_AH, REGS); + unknown_int3(0x10, R_AH, R_AL, REGS); break; } } diff --git a/usr.bin/doscmd/int13.c b/usr.bin/doscmd/int13.c index ded17c857f9c..7873b0c4b224 100644 --- a/usr.bin/doscmd/int13.c +++ b/usr.bin/doscmd/int13.c @@ -235,14 +235,15 @@ init_hdisk(int drive, int cyl, int head, int tracksize, char *file, char *fake_p for (fd = 0; fd < 4; ++fd) { if (*(u_short *)(di->sector0 + 0x1FE) == 0xAA55 && ptab[fd].numSectors == head * tracksize * cyl && - (ptab[fd].systemID == 1 || ptab[fd].systemID == 4)) + (ptab[fd].systemID == 1 || ptab[fd].systemID == 4 || + ptab[fd].systemID == 6)) break; } if (fd < 4) { if (fd) memcpy(ptab, ptab + fd, sizeof(PTAB)); memset(ptab + 1, 0, sizeof(PTAB) * 3); - di->offset = ptab[fd].relSector; + di->offset = ptab[0].relSector; di->cylinders += di->offset / cylsize(di); } else { memset(ptab, 0, sizeof(PTAB) * 4); diff --git a/usr.bin/doscmd/intff.c b/usr.bin/doscmd/intff.c index 800424ca6395..7955f814b013 100644 --- a/usr.bin/doscmd/intff.c +++ b/usr.bin/doscmd/intff.c @@ -748,7 +748,7 @@ install_drive(int drive, u_char *path) /* check that DOS considers this a valid drive */ if (drive < 0 || drive >= lol->lastdrive) { - debug(D_REDIR, "Drive %c beyond limit of %c)\n", + debug(D_REDIR, "Drive %c beyond limit of %c\n", drntol(drive), drntol(lol->lastdrive - 1)); return; } @@ -793,7 +793,7 @@ intff(regcontext_t *REGS) { if (lol && sda) { /* already been called? */ - debug(D_REDIR, "redirector duplicate install ignored\n"); + debug(D_REDIR, "redirector duplicate install ignored"); return; } lol = (LOL *)MAKEPTR(R_BX, R_DX); /* where DOS keeps its goodies */ diff --git a/usr.bin/doscmd/timer.c b/usr.bin/doscmd/timer.c index 41b30199585a..a91c8d106cf2 100644 --- a/usr.bin/doscmd/timer.c +++ b/usr.bin/doscmd/timer.c @@ -8,6 +8,17 @@ static void int08(regcontext_t *REGS) { + struct timeval tv; + time_t tv_sec; + struct timezone tz; + struct tm tm; + + gettimeofday(&tv, &tz); + tv_sec = tv.tv_sec; + tm = *localtime(&tv_sec); + *(u_long *)&BIOSDATA[0x6c] = + (((tm.tm_hour * 60 + tm.tm_min) * 60) + tm.tm_sec) * 182 / 10; + softint(0x1c); } |
