Add support for XMS memory to doscmd.

Submitted by:	Helmut F. Wirth <hfwirth@ping.at>
This commit is contained in:
Jonathan Lemon 1997-08-15 23:41:26 +00:00
parent fd2e6bbaa6
commit d4e591ffcb
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=28243
7 changed files with 1193 additions and 68 deletions

View File

@ -1,15 +1,13 @@
# from BSDI Makefile,v 2.6 1996/04/08 20:06:40 bostic Exp
#
# $Id: Makefile,v 1.3 1997/08/09 20:04:04 ache Exp $
# $Id: Makefile,v 1.4 1997/08/12 16:08:02 ache Exp $
PROG= doscmd
MAN1= doscmd.1
SRCS= AsyncIO.c ParseBuffer.c \
bios.c callback.c cpu.c dos.c cmos.c config.c cwd.c debug.c disktab.c doscmd.c \
exe.c i386-pinsn.c int.c \
int10.c int13.c int14.c int16.c int17.c \
int1a.c int2f.c intff.c \
mem.c mouse.c net.c port.c setver.c signal.c timer.c trace.c trap.c tty.c xms.c
SRCS= AsyncIO.c ParseBuffer.c bios.c callback.c cpu.c dos.c cmos.c config.c \
cwd.c debug.c disktab.c doscmd.c exe.c i386-pinsn.c int.c int10.c \
int13.c int14.c int16.c int17.c int1a.c int2f.c intff.c mem.c mouse.c \
net.c port.c setver.c signal.c timer.c trace.c trap.c tty.c xms.c
CLEANFILES= doscmd.kernel crt0.o doscmd_loader.o instbsdi.exe

View File

@ -29,7 +29,7 @@
*
* BSDI bios.c,v 2.3 1996/04/08 19:32:19 bostic Exp
*
* $Id: bios.c,v 1.4 1996/09/22 15:42:47 miff Exp $
* $Id: bios.c,v 1.1 1997/08/09 01:42:33 dyson Exp $
*/
#include "doscmd.h"
@ -137,7 +137,7 @@ int15(regcontext_t *REGS)
*/
break;
case 0x88:
R_AX = 0; /* memory past 1M */
get_raw_extmemory_info(REGS);
break;
case 0xc0: /* get configuration */
debug (D_TRAPS|0x15, "Get configuration\n", R_DX);

View File

@ -250,6 +250,11 @@ Same as
.\"
.\"
.\"
.It Fl X
Enable debugging of the XMS operations.
.\"
.\"
.\"
.It Fl x
Open an X11 window to display output. This enables a
variety interrupts not available otherwise. This

View File

@ -29,7 +29,7 @@
*
* BSDI doscmd.c,v 2.3 1996/04/08 19:32:30 bostic Exp
*
* $Id: doscmd.c,v 1.10 1997/03/18 02:36:55 msmith Exp $
* $Id: doscmd.c,v 1.1 1997/08/09 01:42:41 dyson Exp $
*/
#include <sys/types.h>
@ -96,9 +96,6 @@ static char *envs[256];
static char *dos_path = 0;
char cmdname[256]; /* referenced from dos.c */
/* high memory mapfile */
static char *memfile = "/tmp/doscmd.XXXXXX";
static struct i386_vm86_args vm86;
static struct vm86_init_args kargs;
@ -116,7 +113,6 @@ main(int argc, char **argv)
int fd;
int i;
char buffer[4096];
int mfd;
FILE *fp;
@ -142,29 +138,7 @@ main(int argc, char **argv)
setbuf (stdout, NULL);
}
mfd = mkstemp(memfile);
if (mfd < 0) {
fprintf(stderr, "memfile: %s\n", strerror(errno));
fprintf(stderr, "High memory will not be mapped\n");
} else {
caddr_t add;
unlink(memfile);
mfd = squirrel_fd(mfd);
lseek(mfd, 64 * 1024 - 1, 0);
write(mfd, "", 1);
add = mmap((caddr_t)0x000000, 64 * 1024,
PROT_EXEC | PROT_READ | PROT_WRITE,
MAP_FILE | MAP_FIXED | MAP_INHERIT | MAP_SHARED,
mfd, 0);
add = mmap((caddr_t)0x100000, 64 * 1024,
PROT_EXEC | PROT_READ | PROT_WRITE,
MAP_FILE | MAP_FIXED | MAP_INHERIT | MAP_SHARED,
mfd, 0);
}
initHMA();
/* This needs to happen before the executable is loaded */
mem_init();
@ -595,6 +569,9 @@ do_args(int argc, char *argv[])
case 'R':
debug_flags |= D_REDIR;
break;
case 'X':
debug_flags |= D_XMS;
break;
case 'L':
debug_flags |= D_PRINTER;
break;

View File

@ -29,7 +29,7 @@
*
* BSDI doscmd.h,v 2.3 1996/04/08 19:32:32 bostic Exp
*
* $Id: doscmd.h,v 1.9 1996/09/23 09:59:25 miff Exp $
* $Id: doscmd.h,v 1.1 1997/08/09 01:43:09 dyson Exp $
*/
@ -106,6 +106,7 @@ extern int debug_flags;
#define D_TRAPS3 0x0200000
#define D_DEBUGIN 0x0400000
#define D_DOSCALL 0x0800000 /* MS-DOS function results */
#define D_XMS 0x1000000 /* XMS calls */
#define TTYF_ECHO 0x00000001
#define TTYF_ECHONL 0x00000003
@ -230,6 +231,9 @@ extern void printer_timeout(int printer, char *time_out);
/* xms.c */
extern int int2f_43(regcontext_t *REGS);
extern void get_raw_extmemory_info(regcontext_t *REGS);
extern void initHMA(void);
extern u_long xms_maxsize;
/****************************** dirty below here ******************************/

File diff suppressed because it is too large Load Diff

145
usr.bin/doscmd/xms.h Normal file
View File

@ -0,0 +1,145 @@
/*-
* Copyright (c) 1997 Helmut Wirth <hfwirth@ping.at>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice immediately at the beginning of the file, witout modification,
* this list of conditions, and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* $Id$
*/
#ifndef XMS_H
#define XMS_H
#define XMS_VERSION 0x0300 /* version 3.00 */
#define XMS_REVISION 0x0100 /* driver revision 1.0 */
#define NUM_HANDLES 64 /* number of available handles */
#define FIRST_HANDLE 1 /* number of firts valid handle */
#define PARAGRAPH 16 /* bytes in a paragraph */
#define MAX_BLOCK_LOCKS 256 /* number of locks on a block */
#define DEFAULT_EMM_SIZE 512 * 1024 /* default EMM size */
/* Register AH codes for XMS functions */
#define XMS_GET_VERSION 0x00
#define XMS_ALLOCATE_HIGH_MEMORY 0x01
#define XMS_FREE_HIGH_MEMORY 0x02
#define XMS_GLOBAL_ENABLE_A20 0x03
#define XMS_GLOBAL_DISABLE_A20 0x04
#define XMS_LOCAL_ENABLE_A20 0x05
#define XMS_LOCAL_DISABLE_A20 0x06
#define XMS_QUERY_A20 0x07
#define XMS_QUERY_FREE_EXTENDED_MEMORY 0x08
#define XMS_ALLOCATE_EXTENDED_MEMORY 0x09
#define XMS_FREE_EXTENDED_MEMORY 0x0a
#define XMS_MOVE_EXTENDED_MEMORY_BLOCK 0x0b
#define XMS_LOCK_EXTENDED_MEMORY_BLOCK 0x0c
#define XMS_UNLOCK_EXTENDED_MEMORY_BLOCK 0x0d
#define XMS_GET_EMB_HANDLE_INFORMATION 0x0e
#define XMS_RESIZE_EXTENDED_MEMORY_BLOCK 0x0f
#define XMS_ALLOCATE_UMB 0x10
#define XMS_DEALLOCATE_UMB 0x11
#define XMS_REALLOCATE_UMB 0x12
/* New functions for values bigger than 65MB, not implented yet */
#define XMS_QUERY_FREE_EXTENDED_MEMORY_LARGE 0x88
#define XMS_ALLOCATE_EXTENDED_MEMORY_LARGE 0x89
#define XMS_FREE_EXTENDED_MEMORY_LARGE 0x8a
/* XMS error return codes */
#define XMS_SUCCESS 0x0
#define XMS_NOT_IMPLEMENTED 0x80
#define XMS_VDISK 0x81 /* If vdisk.sys is present */
#define XMS_A20_ERROR 0x82
#define XMS_GENERAL_ERROR 0x8e
#define XMS_HMA_NOT_MANAGED 0x90
#define XMS_HMA_ALREADY_USED 0x91
#define XMS_HMA_NOT_ALLOCATED 0x93
#define XMS_A20_STILL_ENABLED 0x94
#define XMS_FULL 0xa0
#define XMS_OUT_OF_HANDLES 0xa1
#define XMS_INVALID_HANDLE 0xa2
#define XMS_INVALID_SOURCE_HANDLE 0xa3
#define XMS_INVALID_SOURCE_OFFSET 0xa4
#define XMS_INVALID_DESTINATION_HANDLE 0xa5
#define XMS_INVALID_DESTINATION_OFFSET 0xa6
#define XMS_INVALID_LENGTH 0xa7
#define XMS_BLOCK_NOT_LOCKED 0xaa
#define XMS_BLOCK_IS_LOCKED 0xab
#define XMS_BLOCK_LOCKCOUNT_OVERFLOW 0xac
#define XMS_REQUESTED_UMB_TOO_BIG 0xb0
#define XMS_NO_UMBS_AVAILABLE 0xb1
#define XMS_INVALID_UMB_SEGMENT 0xb2
/*
* EMM structure for data exchange with DOS caller, hence the
* packed format
*/
struct EMM {
u_long nbytes;
u_short src_handle __attribute__ ((packed));
u_long src_offset __attribute__ ((packed));
u_short dst_handle __attribute__ ((packed));
u_long dst_offset __attribute__ ((packed));
} ;
/*
* XMS info structure, only used to pass information to and from
* DOS
*/
struct XMSinfo {
u_char handle; /* the handle */
u_char num_locks __attribute__ ((packed)); /* number of locks */
u_long size __attribute__ ((packed)); /* size of memory */
u_long phys_addr __attribute__ ((packed)); /* "physical" address */
};
/*
* Handle management inside the emulator for extendend memory pages,
* invisible to DOS
*/
typedef struct {
u_long addr; /* address inside emulator, from malloc() */
u_long size; /* size in bytes */
u_char num_locks; /* lock count for this handle */
} XMS_handle;
/*
* Managment of UMB memory paragraphs (16 bytes). UMB blocks are
* directly accessible by VM86 applications and lie between 0xd0000 and
* 0xefff0 in VM86 memory space.
*/
struct _UMB_block {
u_long addr; /* Start address of block */
u_long size; /* Size in bytes */
struct _UMB_block *next;
};
typedef struct _UMB_block UMB_block;
#endif /* XMS_H */