From 540396796ffce0b7cab3e8b7ef4800d140e44533 Mon Sep 17 00:00:00 2001 From: "Guillermo J. Rozas" Date: Thu, 24 Jun 1993 01:52:11 +0000 Subject: [PATCH] Global NT merge --- v7/src/microcode/ntenv.c | 4 +- v7/src/microcode/ntfile.c | 213 ++++++++++++++++++----------- v7/src/microcode/ntfs.c | 3 +- v7/src/microcode/ntio.c | 216 ++++++++++++++++++++--------- v7/src/microcode/ntio.h | 18 +-- v7/src/microcode/ntsig.c | 277 +++++++++++++++++++------------------- v7/src/microcode/ntterm.h | 3 +- v7/src/microcode/nttop.c | 29 ++-- v7/src/microcode/nttop.h | 3 +- v7/src/microcode/nttrap.c | 21 ++- v7/src/microcode/nttrap.h | 3 +- v7/src/microcode/nttty.c | 82 +++-------- 12 files changed, 482 insertions(+), 390 deletions(-) diff --git a/v7/src/microcode/ntenv.c b/v7/src/microcode/ntenv.c index b7fa1efbf..11bac33ca 100644 --- a/v7/src/microcode/ntenv.c +++ b/v7/src/microcode/ntenv.c @@ -1,6 +1,6 @@ /* -*-C-*- -$Id: ntenv.c,v 1.1 1993/02/10 22:39:46 adams Exp $ +$Id: ntenv.c,v 1.2 1993/06/24 01:52:11 gjr Exp $ Copyright (c) 1992-1993 Massachusetts Institute of Technology @@ -208,7 +208,7 @@ DEFUN (OS_set_working_dir_pathname, (name), char * name) size_t name_size = strlen(name); char *filename = name; - STD_VOID_SYSTEM_CALL (syscall_chdir, (SetCurrentDirectory (filename))); + STD_BOOL_SYSTEM_CALL (syscall_chdir, (SetCurrentDirectory (filename))); while (1) { if (name_size < current_dir_path_size) { diff --git a/v7/src/microcode/ntfile.c b/v7/src/microcode/ntfile.c index 61cfb786d..38b935e6e 100644 --- a/v7/src/microcode/ntfile.c +++ b/v7/src/microcode/ntfile.c @@ -1,6 +1,6 @@ /* -*-C-*- -$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/ntfile.c,v 1.1 1993/02/10 22:39:46 adams Exp $ +$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/ntfile.c,v 1.2 1993/06/24 01:52:11 gjr Exp $ Copyright (c) 1992 Massachusetts Institute of Technology @@ -39,74 +39,105 @@ MIT in each case. */ extern void EXFUN (terminal_open, (Tchannel channel)); static enum channel_type -DEFUN (fd_channel_type, (fd), int fd) +DEFUN (handle_channel_type, (hFile), HANDLE hFile) { - static int first_time = 1; - if (first_time) { - printf("\n;; fd_channel_type(fd) is broken.\n"); - first_time = 0; - } - return channel_type_file; -/* SRA:stat is fried on the NT Oct Beta - struct stat stat_buf; - if ((DOS_fstat (fd, (&stat_buf))) < 0){ - return (channel_type_unknown); + if (Screen_IsScreenHandle (hFile)) + return channel_type_terminal; +// if (IsConsoleHandle (hFile)) +// return channel_type_terminal; + switch (GetFileType (hFile)) { - mode_t type = ((stat_buf . st_mode) & S_IFMT); - return - ((type == S_IFREG) ? channel_type_file - : (type == S_IFCHR) - ? ((isatty (fd)) - ? channel_type_terminal - : channel_type_character_device) -#ifdef S_IFIFO - : (type == S_IFIFO) ? channel_type_fifo -#endif -#ifdef S_IFBLK - : (type == S_IFBLK) ? channel_type_block_device -#endif - : (type == S_IFDIR) ? channel_type_directory - : channel_type_unknown); + default: + case FILE_TYPE_UNKNOWN: return channel_type_unknown; + case FILE_TYPE_DISK: return channel_type_file; + case FILE_TYPE_CHAR: return channel_type_character_device; + case FILE_TYPE_PIPE: return channel_type_fifo; } - */ } Tchannel -DEFUN (OS_open_fd, (fd), int fd) +DEFUN (OS_open_handle, (hFile), HANDLE hFile) { - enum channel_type type = (fd_channel_type (fd)); + enum channel_type type; Tchannel channel; - MAKE_CHANNEL (fd, type, channel =); - - /* Like Unix, all terminals initialize to cooked mode. */ - if (type == channel_type_terminal) CHANNEL_COOKED(channel) = 1; + +// if (hFile == STDIN_HANDLE) { +// MAKE_CHANNEL (STDIN_HANDLE, channel_type_terminal, channel=); +// CHANNEL_COOKED(channel) = 1; +// } +// +// else if (hFile == STDOUT_HANDLE) { +// MAKE_CHANNEL (STDOUT_HANDLE, channel_type_terminal, channel=); +// CHANNEL_COOKED(channel) = 1; +// } +// +// else if (hFile == STDERR_HANDLE) { +// MAKE_CHANNEL (STDERR_HANDLE, channel_type_terminal, channel=); +// CHANNEL_COOKED(channel) = 1; +// } + +// else + { + type = handle_channel_type (hFile); + MAKE_CHANNEL (hFile, type, channel =); - return (channel); + /* Like Unix, all terminals initialize to cooked mode. */ + if (type == channel_type_terminal) + CHANNEL_COOKED(channel) = 1; + } + return channel; } -static Tchannel -DEFUN (open_file, (filename, oflag), CONST char * filename AND int oflag) -{ - int fd; - STD_UINT_SYSTEM_CALL - (syscall_open, fd, (DOS_open (filename, oflag, MODE_REG))); - return (OS_open_fd (fd)); -} -#define DEFUN_OPEN_FILE(name, oflag) \ +#define DEFUN_OPEN_FILE(name, args) \ Tchannel \ DEFUN (name, (filename), CONST char * filename) \ { \ - return (open_file)(filename, oflag); \ + HANDLE hFile; \ + STD_HANDLE_SYSTEM_CALL (syscall_open, hFile, CreateFile args); \ + return OS_open_handle (hFile); \ } -DEFUN_OPEN_FILE (OS_open_input_file, O_RDONLY | _O_BINARY) -DEFUN_OPEN_FILE (OS_open_output_file, (O_WRONLY | O_CREAT | O_TRUNC | _O_BINARY)) -DEFUN_OPEN_FILE (OS_open_io_file, (O_RDWR | O_CREAT)) + +DEFUN_OPEN_FILE (OS_open_input_file, + (filename, GENERIC_READ, FILE_SHARE_READ, 0, + OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0)); + +DEFUN_OPEN_FILE (OS_open_output_file, + (filename, GENERIC_WRITE, 0, 0, + CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0)); + +DEFUN_OPEN_FILE (OS_open_io_file, + (filename, GENERIC_READ | GENERIC_WRITE, 0, 0, + OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0)); + + +//DEFUN_OPEN_FILE (OS_open_input_file, O_RDONLY | _O_BINARY) +//DEFUN_OPEN_FILE (OS_open_output_file, (O_WRONLY | O_CREAT | O_TRUNC | _O_BINARY)) +//DEFUN_OPEN_FILE (OS_open_io_file, (O_RDWR | O_CREAT)) + #ifdef HAVE_APPEND -DEFUN_OPEN_FILE (OS_open_append_file, (O_WRONLY | O_CREAT | O_APPEND | _O_BINARY)) +Tchannel +DEFUN (OS_open_append_file, (filename), CONST char * filename) +{ + HANDLE hFile; + STD_HANDLE_SYSTEM_CALL + (syscall_open, hFile, + CreateFile (filename, + GENERIC_WRITE, + 0 /*sharing*/, + 0 /*security*/, + OPEN_ALWAYS, + FILE_ATTRIBUTE_NORMAL /*attributes&flags*/, + 0 /*Template*/)); + SetFilePointer (hFile, 0, 0, FILE_END); + return OS_open_handle (hFile); +} + + +//DEFUN_OPEN_FILE (OS_open_append_file, (O_WRONLY | O_CREAT | O_APPEND | _O_BINARY)) #else @@ -120,57 +151,75 @@ DEFUN (OS_open_append_file, (filename), CONST char * filename) #endif static Tchannel -DEFUN (make_load_channel, (fd), int fd) +DEFUN (make_load_channel, (handle), HANDLE handle) { - enum channel_type type = (fd_channel_type (fd)); -/*SRA: fd_channel_type doesnt work properly - if ((type == channel_type_terminal) - || (type == channel_type_directory) - || (type == channel_type_unknown)) - return (NO_CHANNEL); -*/ + enum channel_type type = handle_channel_type (handle); if ((type == channel_type_terminal) || (type == channel_type_directory) ) return (NO_CHANNEL); - MAKE_CHANNEL (fd, type, return); + MAKE_CHANNEL (handle, type, return); } Tchannel DEFUN (OS_open_load_file, (filename), CONST char * filename) { - while (1) - { /*SRA:*/ - int fd = (DOS_open (filename, O_RDONLY|_O_BINARY, MODE_REG)); - if (fd >= 0) - return (make_load_channel (fd)); - if (errno != EINTR) - return (NO_CHANNEL); - } + HANDLE hFile; + + hFile = CreateFile (filename, GENERIC_READ, + 0 /*FILE_SHARE_READ?*/, + 0 /*security?*/, + OPEN_EXISTING, + 0, + 0); + if (hFile != INVALID_HANDLE_VALUE) + return make_load_channel (hFile); + + /* try to truncate extension for .bcon hack*/ + { + char newname [MAX_PATH+10]; + int i; + strncpy (newname, filename, MAX_PATH); + for (i=0; newname[i]; i++); + if (i<4) return NO_CHANNEL; + if (newname[i-5]=='.') { + newname[i-1] = 0; + hFile = CreateFile (newname, GENERIC_READ, 0, 0, OPEN_EXISTING, 0, 0); + if (hFile != INVALID_HANDLE_VALUE) + return make_load_channel (hFile); + } + } + + return NO_CHANNEL; } Tchannel DEFUN (OS_open_dump_file, (filename), CONST char * filename) { - while (1) - { - /*SRA: +binary*/ - int fd = (DOS_open (filename, (_O_BINARY | O_WRONLY | O_CREAT | O_TRUNC), MODE_REG)); - if (fd >= 0) - return (make_load_channel (fd)); - if (errno != EINTR) - return (NO_CHANNEL); - } + HANDLE hFile = CreateFile ( filename, + GENERIC_WRITE, + 0 /*no sharing*/, + 0 /*security?*/, + CREATE_ALWAYS, + 0, + 0); + + if (hFile != INVALID_HANDLE_VALUE) + return make_load_channel (hFile); + + return NO_CHANNEL; } off_t DEFUN (OS_file_length, (channel), Tchannel channel) { - struct stat stat_buf; - STD_VOID_SYSTEM_CALL - (syscall_fstat, (DOS_fstat ((CHANNEL_DESCRIPTOR (channel)), (&stat_buf)))); - return (stat_buf . st_size); + DWORD result; + while ((result = GetFileSize (CHANNEL_HANDLE (channel), 0)) == 0xffffffffL + && GetLastError() != NO_ERROR) + error_system_call (GetLastError(), syscall_fstat); + + return result; } off_t @@ -180,7 +229,7 @@ DEFUN (OS_file_position, (channel), Tchannel channel) STD_UINT_SYSTEM_CALL (syscall_lseek, result, - (DOS_lseek ((CHANNEL_DESCRIPTOR (channel)), 0L, SEEK_CUR))); + (_llseek ((CHANNEL_HANDLE (channel)), 0L, SEEK_CUR))); return (result); } @@ -189,11 +238,11 @@ DEFUN (OS_file_set_position, (channel, position), Tchannel channel AND off_t position) { - off_t result; + LONG result; STD_UINT_SYSTEM_CALL (syscall_lseek, result, - (DOS_lseek ((CHANNEL_DESCRIPTOR (channel)), position, SEEK_SET))); + (_llseek ((CHANNEL_HANDLE (channel)), position, SEEK_SET))); if (result != position) error_external_return (); } diff --git a/v7/src/microcode/ntfs.c b/v7/src/microcode/ntfs.c index 20240dfcb..4e9b28959 100644 --- a/v7/src/microcode/ntfs.c +++ b/v7/src/microcode/ntfs.c @@ -1,6 +1,6 @@ /* -*-C-*- -$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/ntfs.c,v 1.1 1993/02/10 22:39:46 adams Exp $ +$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/ntfs.c,v 1.2 1993/06/24 01:52:11 gjr Exp $ Copyright (c) 1992 Massachusetts Institute of Technology @@ -35,6 +35,7 @@ MIT in each case. */ #include "nt.h" #include "osfs.h" #include +#include "outf.h" int DEFUN (DOS_read_file_status, (name, s), diff --git a/v7/src/microcode/ntio.c b/v7/src/microcode/ntio.c index 922d8ff5e..4cd3079b1 100644 --- a/v7/src/microcode/ntio.c +++ b/v7/src/microcode/ntio.c @@ -1,6 +1,6 @@ /* -*-C-*- -$Id: ntio.c,v 1.1 1993/02/10 22:39:46 adams Exp $ +$Id: ntio.c,v 1.2 1993/06/24 01:52:11 gjr Exp $ Copyright (c) 1992 Massachusetts Institute of Technology @@ -32,9 +32,16 @@ Technology nor of any adaptation thereof in any advertising, promotional, or sales literature without prior written consent from MIT in each case. */ +#include "scheme.h" #include "nt.h" #include "ntio.h" #include "osterm.h" +#include "prims.h" +#include "outf.h" +#include "ossig.h" +#include "intrpt.h" + +#include "ntscreen.h" #ifndef fileno #define fileno(fp) ((fp)->_file) @@ -45,6 +52,9 @@ struct channel * channel_table; unsigned int OS_channels_registered; +HANDLE STDIN_HANDLE, STDOUT_HANDLE, STDERR_HANDLE; + + static void DEFUN_VOID (DOS_channel_close_all) { @@ -55,17 +65,51 @@ DEFUN_VOID (DOS_channel_close_all) return; } -void -DEFUN_VOID (DOS_initialize_channels) +static BOOL _stdcall +NT_ctrl_handler(DWORD dwCtrlType) { - printf(">> DOS_initialize_channels\n"); + switch (dwCtrlType) { + case CTRL_C_EVENT: + REQUEST_INTERRUPT (INT_Character); + return TRUE; + default: + return FALSE; + } +} + + +extern HANDLE master_tty_window; + + +void +DEFUN_VOID (NT_initialize_channels) +{ + STDIN_HANDLE = GetStdHandle (STD_INPUT_HANDLE); + STDOUT_HANDLE = GetStdHandle (STD_OUTPUT_HANDLE); + STDERR_HANDLE = GetStdHandle (STD_ERROR_HANDLE); + + if (STDIN_HANDLE == INVALID_HANDLE_VALUE || + STDOUT_HANDLE == INVALID_HANDLE_VALUE || + STDERR_HANDLE == INVALID_HANDLE_VALUE) { + outf_fatal ("\nUnable to get standard handles %s(%d).\n", + __FILE__, __LINE__); + termination_init_error (); + } + + SetConsoleMode (STDIN_HANDLE, + ENABLE_LINE_INPUT | ENABLE_ECHO_INPUT | ENABLE_PROCESSED_INPUT); + SetConsoleCtrlHandler (NT_ctrl_handler, TRUE); + + + master_tty_window = Screen_Create (NULL, "MIT Scheme", SW_SHOWNORMAL); + + OS_channel_table_size = (DOS_SC_OPEN_MAX ()); channel_table = (DOS_malloc (OS_channel_table_size * (sizeof (struct channel)))); if (channel_table == 0) { - fprintf (stderr, "\nUnable to allocate channel table.\n"); - fflush (stderr); + outf_fatal ("\nUnable to allocate channel table.\n"); termination_init_error (); } { @@ -114,8 +158,8 @@ DEFUN (OS_channel_close, (channel), Tchannel channel) { if (CHANNEL_REGISTERED (channel)) OS_channel_unregister (channel); - STD_VOID_SYSTEM_CALL - (syscall_close, (DOS_close (CHANNEL_DESCRIPTOR (channel)))); + STD_BOOL_SYSTEM_CALL + (syscall_close, (CloseHandle (CHANNEL_HANDLE (channel)))); MARK_CHANNEL_CLOSED (channel); } return; @@ -128,7 +172,8 @@ DEFUN (OS_channel_close_noerror, (channel), Tchannel channel) { if (CHANNEL_REGISTERED (channel)) OS_channel_unregister (channel); - DOS_close (CHANNEL_DESCRIPTOR (channel)); + if (! Screen_IsScreenHandle (CHANNEL_HANDLE (channel))) + CloseHandle (CHANNEL_HANDLE (channel)); MARK_CHANNEL_CLOSED (channel); } return; @@ -160,8 +205,8 @@ void DEFUN (OS_terminal_flush_input, (channel), Tchannel channel) { extern void EXFUN (flush_conio_buffers, (void)); - if ((CHANNEL_DESCRIPTOR (channel)) == (fileno (stdin))) - flush_conio_buffers(); +// if (IsWindow (CHANNEL_HANDLE (channel))) /*SRA:dubious*/ +// flush_conio_buffers(); return; } @@ -177,53 +222,66 @@ DEFUN (OS_terminal_drain_output, (channel), Tchannel channel) return; } -extern int EXFUN (dos_read, (int, PTR, size_t, int, int, int)); +//extern int EXFUN (dos_read, (int, PTR, size_t, int, int, int)); +// +//int +//DEFUN (dos_read, (fd, buffer, nbytes, buffered_p, blocking_p, intrpt_p), +// HANDLE fd AND PTR buffer AND size_t nbytes +// AND int buffered_p AND int blocking_p AND int intrpt_p) +//{ +// if (nbytes == 0) +// return (0); +// else if (fd == (fileno (stdin))) +// return (console_read (buffer, nbytes, buffered_p, blocking_p, intrpt_p)); +// else +// return (DOS_read (fd, buffer, nbytes)); +//} int -DEFUN (dos_read, (fd, buffer, nbytes, buffered_p, blocking_p, intrpt_p), - int fd AND PTR buffer AND size_t nbytes - AND int buffered_p AND int blocking_p AND int intrpt_p) -{ - if (nbytes == 0) - return (0); - else if (fd == (fileno (stdin))) - return (console_read (buffer, nbytes, buffered_p, blocking_p, intrpt_p)); - else - return (DOS_read (fd, buffer, nbytes)); -} - -int -DEFUN (dos_channel_read, (channel, buffer, nbytes), +DEFUN (nt_channel_read, (channel, buffer, nbytes), Tchannel channel AND PTR buffer AND size_t nbytes) { + DWORD bytesRead = 0; + if (nbytes == 0) return 0; - else if ((CHANNEL_DESCRIPTOR (channel)) == (fileno (stdin))) { + else if (Screen_IsScreenHandle(CHANNEL_HANDLE (channel))) { + bytesRead = Screen_Read (CHANNEL_HANDLE (channel), buffer, nbytes); + if (bytesRead == 0xffffffff) { + Sleep(0); /* for pleasantness give up rest of this timeslice */ + errno = ERRNO_NONBLOCK; + } + return (int)bytesRead; + } + else if (IsConsoleHandle(CHANNEL_HANDLE (channel))) { /* fake the console being a nonblocking channel that has nothing after - each read */ + each alternate read */ static int nonblock = 1; nonblock = !nonblock; if (nonblock) { errno = ERRNO_NONBLOCK; return -1; } - return (DOS_read ((CHANNEL_DESCRIPTOR (channel)), buffer, nbytes)); - /*return (console_read (buffer, nbytes, - (CHANNEL_BUFFERED (channel)), - (CHANNEL_BLOCKING_P (channel)), - 1));*/ + if (ReadFile (CHANNEL_HANDLE (channel), buffer, nbytes, &bytesRead, 0)) + return (int)bytesRead; + else + return -1; + } + else { + if (ReadFile (CHANNEL_HANDLE (channel), buffer, nbytes, &bytesRead, 0)) + return (int)bytesRead; + else + return -1; } - else - return (DOS_read ((CHANNEL_DESCRIPTOR (channel)), buffer, nbytes)); } long DEFUN (OS_channel_read, (channel, buffer, nbytes), Tchannel channel AND PTR buffer AND size_t nbytes) { - while (1) + while (1) { - long scr = (dos_channel_read (channel, buffer, nbytes)); + long scr = nt_channel_read (channel, buffer, nbytes); if (scr < 0) { if (errno == ERRNO_NONBLOCK) @@ -231,7 +289,7 @@ DEFUN (OS_channel_read, (channel, buffer, nbytes), DOS_prim_check_errno (syscall_read); continue; } - else if (scr > nbytes) + else if (((size_t) scr) > nbytes) error_external_return (); else { return (scr); @@ -241,12 +299,19 @@ DEFUN (OS_channel_read, (channel, buffer, nbytes), static int DEFUN (dos_write, (fd, buffer, nbytes), - int fd AND CONST unsigned char * buffer AND size_t nbytes) + HANDLE fd AND CONST unsigned char * buffer AND DWORD nbytes) { - return ((fd == (fileno (stdout))) - ? (dos_console_write (buffer, nbytes)) - - : (DOS_write (fd, buffer, nbytes))); + DWORD bytesWritten; + if (Screen_IsScreenHandle (fd)) { + SendMessage (fd, SCREEN_WRITE, (WPARAM)nbytes, (LPARAM)buffer); + return nbytes; + } + if (IsConsoleHandle (fd)) + return dos_console_write (buffer, nbytes); + if (WriteFile(fd, buffer, nbytes, &bytesWritten, 0)) + return bytesWritten; + else + return -1; } #define Syscall_Write(fd, buffer, size, so_far) \ @@ -259,8 +324,8 @@ do \ } while (0) long -DEFUN (text_write, (fd, buffer, nbytes), - int fd AND CONST unsigned char * buffer AND size_t nbytes) +DEFUN (text_write, (hFile, buffer, nbytes), + HANDLE hFile AND CONST unsigned char * buffer AND size_t nbytes) { /* Map LF to CR/LF */ static CONST unsigned char crlf[] = {CARRIAGE_RETURN, LINEFEED}; CONST unsigned char *start; @@ -272,12 +337,12 @@ DEFUN (text_write, (fd, buffer, nbytes), while ((i < nbytes) && (buffer[i] != LINEFEED)) i++; len = (&buffer[i] - start); - Syscall_Write (fd, start, len, (i - len)); + Syscall_Write (hFile, start, len, (i - len)); if ((i < nbytes) && (buffer[i] == LINEFEED)) { /* We are sitting on a linefeed. Write out CRLF */ /* This backs out incorrectly if only CR is written out */ - Syscall_Write (fd, crlf, (sizeof (crlf)), i); + Syscall_Write (hFile, crlf, (sizeof (crlf)), i); i = i + 1; /* Skip over special character */ } } @@ -295,12 +360,13 @@ DEFUN (OS_channel_write, (channel, buffer, nbytes), while (1) { - int fd, scr; + HANDLE hFile; + DWORD scr; - fd = CHANNEL_DESCRIPTOR(channel); + hFile = CHANNEL_HANDLE(channel); scr = ((CHANNEL_COOKED (channel)) - ? (text_write (fd, buffer, nbytes)) - : (dos_write (fd, buffer, nbytes))); + ? (text_write (hFile, buffer, nbytes)) + : (dos_write (hFile, buffer, nbytes))); if (scr < 0) { @@ -318,18 +384,22 @@ size_t DEFUN (OS_channel_read_load_file, (channel, buffer, nbytes), Tchannel channel AND PTR buffer AND size_t nbytes) { - int scr; - scr = (DOS_read ((CHANNEL_DESCRIPTOR (channel)), buffer, nbytes)); - - return ((scr < 0) ? 0 : scr); + DWORD scr; + if (ReadFile (CHANNEL_HANDLE (channel), buffer, nbytes, &scr, 0)) + return scr; + else + return 0; } size_t DEFUN (OS_channel_write_dump_file, (channel, buffer, nbytes), Tchannel channel AND CONST PTR buffer AND size_t nbytes) { - int scr = (DOS_write ((CHANNEL_DESCRIPTOR (channel)), buffer, nbytes)); - return ((scr < 0) ? 0 : scr); + DWORD scr; + if (WriteFile (CHANNEL_HANDLE (channel), buffer, nbytes, &scr, 0)) + return scr; + else + return 0; } void @@ -337,7 +407,7 @@ DEFUN (OS_channel_write_string, (channel, string), Tchannel channel AND CONST char * string) { - unsigned long length = (strlen (string)); + long length = (strlen (string)); if ((OS_channel_write (channel, string, length)) != length) error_external_return (); } @@ -411,22 +481,36 @@ DEFUN (arg_baud_index, (argument), unsigned int argument) return (arg_index_integer (argument, 1)); } -unsigned long +unsigned int DEFUN (OS_terminal_get_ispeed, (channel), Tchannel channel) { - return (0); + return 0; } -unsigned long +unsigned int DEFUN (OS_terminal_get_ospeed, (channel), Tchannel channel) { - return (0); + return 0; +} + +void +DEFUN (OS_terminal_set_ispeed, (channel, baud), + Tchannel channel AND + unsigned int baud) +{ +} + +void +DEFUN (OS_terminal_set_ospeed, (channel, baud), + Tchannel channel AND + unsigned int baud) +{ } unsigned int DEFUN (OS_baud_index_to_rate, (index), unsigned int index) { - return (9600); + return 9600; } int @@ -507,6 +591,8 @@ DEFUN (OS_channel_unregister, (channel), Tchannel channel) /* No SELECT in DOS */ +CONST int OS_have_select_p = 0; + long DEFUN (OS_channel_select_then_read, (channel, buffer, nbytes), Tchannel channel AND @@ -517,7 +603,7 @@ DEFUN (OS_channel_select_then_read, (channel, buffer, nbytes), */ while (1) { - long scr = (dos_channel_read (channel, buffer, nbytes)); + long scr = (nt_channel_read (channel, buffer, nbytes)); if (scr < 0) { @@ -531,7 +617,7 @@ DEFUN (OS_channel_select_then_read, (channel, buffer, nbytes), continue; } } - else if (scr > nbytes) + else if (((size_t) scr) > nbytes) error_external_return (); else return (scr); diff --git a/v7/src/microcode/ntio.h b/v7/src/microcode/ntio.h index 96a9928e8..5b11cf210 100644 --- a/v7/src/microcode/ntio.h +++ b/v7/src/microcode/ntio.h @@ -1,6 +1,6 @@ /* -*-C-*- -$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/ntio.h,v 1.1 1993/02/10 22:39:46 adams Exp $ +$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/ntio.h,v 1.2 1993/06/24 01:52:11 gjr Exp $ Copyright (c) 1992 Massachusetts Institute of Technology @@ -39,7 +39,7 @@ MIT in each case. */ struct channel { - int descriptor; + HANDLE handle; enum channel_type type; unsigned int internal : 1; unsigned int nonblocking : 1; @@ -48,10 +48,10 @@ struct channel unsigned int cooked : 1; }; -#define MARK_CHANNEL_CLOSED(channel) ((CHANNEL_DESCRIPTOR (channel)) = (-1)) -#define CHANNEL_CLOSED_P(channel) ((CHANNEL_DESCRIPTOR (channel)) < 0) -#define CHANNEL_OPEN_P(channel) ((CHANNEL_DESCRIPTOR (channel)) >= 0) -#define CHANNEL_DESCRIPTOR(channel) ((channel_table [(channel)]) . descriptor) +#define MARK_CHANNEL_CLOSED(chan) ((CHANNEL_HANDLE (chan)) = (HANDLE)(-1)) +#define CHANNEL_CLOSED_P(chan) ((CHANNEL_HANDLE (chan)) == (HANDLE)(-1)) +#define CHANNEL_OPEN_P(chan) ((CHANNEL_HANDLE (chan)) != (HANDLE)(-1)) +#define CHANNEL_HANDLE(channel) ((channel_table [channel]) . handle) #define CHANNEL_TYPE(channel) ((channel_table [(channel)]) . type) #define CHANNEL_INTERNAL(channel) ((channel_table [(channel)]) . internal) #define CHANNEL_NONBLOCKING(channel) \ @@ -65,7 +65,7 @@ struct channel #define MAKE_CHANNEL(descriptor, type, receiver) \ { \ Tchannel MAKE_CHANNEL_temp = (channel_allocate ()); \ - (CHANNEL_DESCRIPTOR (MAKE_CHANNEL_temp)) = (descriptor); \ + (CHANNEL_HANDLE (MAKE_CHANNEL_temp)) = (descriptor); \ (CHANNEL_TYPE (MAKE_CHANNEL_temp)) = (type); \ (CHANNEL_INTERNAL (MAKE_CHANNEL_temp)) = 0; \ (CHANNEL_NONBLOCKING (MAKE_CHANNEL_temp)) = 0; \ @@ -85,5 +85,7 @@ extern Tchannel EXFUN (channel_allocate, (void)); #define CNTRL_Z '\032' #define DELETE '\177' +#define CONSOLE_HANDLE (STDIN_HANDLE) +#define IsConsoleHandle(h) ((h)==CONSOLE_HANDLE) + #endif /* SCM_UXIO_H */ - \ No newline at end of file diff --git a/v7/src/microcode/ntsig.c b/v7/src/microcode/ntsig.c index 2184a2ee3..72ae293fc 100644 --- a/v7/src/microcode/ntsig.c +++ b/v7/src/microcode/ntsig.c @@ -1,6 +1,6 @@ /* -*-C-*- -$Id: ntsig.c,v 1.1 1993/02/10 22:39:46 adams Exp $ +$Id: ntsig.c,v 1.2 1993/06/24 01:52:11 gjr Exp $ Copyright (c) 1992 Massachusetts Institute of Technology @@ -32,6 +32,11 @@ Technology nor of any adaptation thereof in any advertising, promotional, or sales literature without prior written consent from MIT in each case. */ + +/* Hacks by SRA for NT: + 1. punt interactive debugging completely +*/ + #include "scheme.h" #include "nt.h" #include @@ -42,11 +47,17 @@ MIT in each case. */ #include "critsec.h" /*#include SRA*/ #include "ntsys.h" +#include "ntio.h" #include "ntexcp.h" #include "ntkbd.h" #ifdef USE_ZORTECH_CERROR #include #endif +#include "extern.h" +#include "ntutil.h" +#include "ntscreen.h" + +#include #ifndef fileno #define fileno(fp) ((fp)->_file) @@ -66,6 +77,7 @@ DEFUN (current_handler, (signo), int signo) DOS_signal (signo, result); return (result); } +#endif /* UNUSED */ #define INSTALL_HANDLER DOS_signal #define NEED_HANDLER_TRANSACTION @@ -74,7 +86,6 @@ DEFUN (current_handler, (signo), int signo) #define ABORT_HANDLER DOS_signal #define EXIT_HANDLER DOS_signal -#endif /* UNUSED */ /* These could be implemented, at least under DPMI by examining and setting the virtual interrupt state. @@ -139,8 +150,7 @@ DEFUN (defsignal, (signo, name, action, flags), (sizeof (struct signal_descriptor))))); if (signal_descriptors == 0) { - fprintf (stderr, "\nUnable to grow signal definitions table.\n"); - fflush (stderr); + outf_fatal ("\nUnable to grow signal definitions table.\n"); termination_init_error (); } } @@ -193,8 +203,7 @@ DEFUN_VOID (initialize_signal_descriptors) (sizeof (struct signal_descriptor)))); if (signal_descriptors == 0) { - fprintf (stderr, "\nUnable to allocate signal definitions table.\n"); - fflush (stderr); + outf_error ("\nUnable to allocate signal definitions table.\n"); termination_init_error (); } @@ -207,6 +216,7 @@ DEFUN_VOID (initialize_signal_descriptors) OS_SPECIFIC_SIGNALS (); } +#endif /* Signal Handlers */ @@ -242,12 +252,14 @@ DEFUN (name, (signo), int signo) \ SIGNAL_HANDLER_RETURN (); \ } + static void DEFUN (ta_abort_handler, (ap), PTR ap) { ABORT_HANDLER ((((struct handler_record *) ap) -> signo), (((struct handler_record *) ap) -> handler)); } +#ifdef UNUSED #endif /* UNUSED */ #define CONTROL_B_INTERRUPT_CHAR 'B' @@ -258,23 +270,20 @@ DEFUN (ta_abort_handler, (ap), PTR ap) #define TERMINATE_INTERRUPT_CHAR '@' #define NO_INTERRUPT_CHAR '0' -#ifdef UNUSED + static void DEFUN (echo_keyboard_interrupt, (c, dc), cc_t c AND cc_t dc) { c &= 0177; if (c == ALERT_CHAR) - putc (c, stdout); + outf_console ("%c", c); else if (c < '\040') - { - putc ('^', stdout); - putc ((c + '@'), stdout); - } + outf_console ("^%c", (c+'@')); else if (c == '\177') - fputs ("^?", stdout); + outf_console ("^?"); else - putc (c, stdout); - fflush (stdout); + outf_console ("%c", c); + outf_flush_console(); } DEFUN_STD_HANDLER (sighnd_control_g, @@ -291,7 +300,6 @@ DEFUN_STD_HANDLER (sighnd_control_c, tty_set_next_interrupt_char (int_char); }) -#endif /* UNUSED */ /* Keyboard interrupt */ @@ -337,13 +345,24 @@ DEFUN (OS_ctty_set_interrupt_enables, (mask), Tinterrupt_enables * mask) static cc_t int_chars[NUM_INT_CHANNELS]; static cc_t int_handlers[NUM_INT_CHANNELS]; +#define SCREEN_COMMAND_INTERRUPT_FIRST (SCREEN_COMMAND_CLOSE+10) + +LRESULT master_tty_interrupt (HWND tty, WORD command) +{ + int ch = int_chars[command - SCREEN_COMMAND_INTERRUPT_FIRST]; + signal_keyboard_character_interrupt (ch); +} + static void DEFUN_VOID (update_interrupt_characters) { + extern HANDLE master_tty_window; int i; - for (i = 0; i < KB_INT_TABLE_SIZE; i++) + for (i = 0; i < KB_INT_TABLE_SIZE; i++) { keyboard_interrupt_table[i] = NO_INTERRUPT_CHAR; + SendMessage (master_tty_window, SCREEN_SETBINDING, i, 0); + } for (i = 0; i < NUM_INT_CHANNELS; i++) { @@ -380,6 +399,11 @@ DEFUN_VOID (update_interrupt_characters) break; } keyboard_interrupt_table[(int) (int_chars[i])] = handler; + SendMessage (master_tty_window, SCREEN_SETCOMMAND, + SCREEN_COMMAND_INTERRUPT_FIRST+i, + (LPARAM) master_tty_interrupt); + SendMessage (master_tty_window, SCREEN_SETBINDING, + int_chars[i], SCREEN_COMMAND_INTERRUPT_FIRST+i); } return; } @@ -430,26 +454,23 @@ extern long EXFUN (text_write, (int, CONST unsigned char *, size_t)); static void DEFUN (console_write_string, (string), unsigned char * string) { - (void) text_write ((fileno (stdout)), string, (strlen (string))); + outf_console ("%s", string); + outf_flush_console(); return; } static void DEFUN (console_write_character, (c), unsigned char c) { - (void) text_write ((fileno (stdout)), &c, 1); + outf_console ("%c", c); + outf_flush_console(); return; } static unsigned char DEFUN_VOID (console_read_character) { - unsigned char c; - extern int EXFUN (dos_read, (int, PTR, size_t, int, int, int)); - - /* non-buffered, blocking, non-interrupting read. */ - (void) dos_read ((fileno (stdin)), &c, 1, 0, 1, 0); - return (c); + return userio_read_char(); } void @@ -491,6 +512,16 @@ DEFUN (OS_tty_map_interrupt_char, (int_char), cc_t int_char) static void DEFUN_VOID (print_interrupt_help) { + console_write_string ( + "\r\nInterrupt choices are:\r\n" + "C-G interrupt: ^G (abort to top level)\r\n" + "C-X interrupt: ^x (abort)\r\n" + "C-B interrupt: ^B (break)\r\n" + "C-U interrupt: ^U (up)\r\n" + "(exit) to exit Scheme\r\n" + ); + +/* console_write_string ("\nInterrupt Choices are:\n"); console_write_string ("C-G interrupt: G, g, ^G (abort to top level)\n"); console_write_string ("C-X interrupt: X, x, ^x (abort)\n"); @@ -500,6 +531,7 @@ DEFUN_VOID (print_interrupt_help) console_write_string ("Reset scheme: R, r (hard reset)\n"); console_write_string ("Quit scheme: Q, q (exit)\n"); console_write_string ("Print help: ?"); +*/ return; } @@ -575,7 +607,10 @@ interactive_interrupt: { cc_t int_char; - int_char = (DOS_interactive_interrupt_handler ()); + /*int_char = (DOS_interactive_interrupt_handler ());*/ + print_interrupt_help(); + int_char = 0; + if (int_char == ((cc_t) 0)) hard_attn_counter = 0; else @@ -1152,109 +1187,7 @@ DEFUN_VOID (enable_X32_exceptions_p) static void DEFUN_VOID (DOS_install_interrupts) { -/* - extern dos_boolean EXFUN (under_X32_p, (void)); - dos_boolean x32_p = (under_X32_p ()); - dos_boolean dpmi_p = (under_DPMI_p ()); -*/ - -#if 0 - if (x32_p && (feature_enabled_p ("MITSCHEME_X32_INTERRUPTS"))) - { - extern void EXFUN (X32_asm_initialize, (void)); - extern int EXFUN (X32_lock_scheme_microcode, (void)); - extern int EXFUN (X32_interrupt_restore, (unsigned)); - extern int EXFUN (X32_int_intercept, (unsigned, void (*) (), PTR)); - extern void EXFUN (X32_timer_interrupt, (void)); - extern void EXFUN (X32_critical_error, (void)); - extern int X32_timer_interrupt_previous; - extern int X32_critical_error_previous; - - X32_asm_initialize (); - - if ((X32_lock_scheme_microcode ()) != 0) - { - fprintf (stderr, - "\n;; DOS_install_interrupts (X32): Unable to lock memory."); - fprintf (stderr, - "\n;; Interrupt and exceptions handlers not available!\n"); - fflush (stderr); - return; - } - - if ((X32_int_intercept (DOS_INTVECT_USER_TIMER_TICK, - X32_timer_interrupt, - ((PTR) &X32_timer_interrupt_previous))) - != 0) - { - fprintf (stderr, - "\n;; DOS_install_interrupts (X32): Unable to intercept."); - fprintf (stderr, - "\n;; Timer interrupt not available!\n"); - fflush (stderr); - } - else - dos_record_interrupt_interception (DOS_INTVECT_USER_TIMER_TICK, - X32_interrupt_restore); - - if (!dpmi_p) - { -#ifdef USE_ZORTECH_CERROR - _cerror_handler = critical_error_handler; - cerror_open (); -#else /* not USE_ZORTECH_CERROR */ - if ((X32_int_intercept (DOS_INTVECT_CRITICAL_ERROR, - X32_critical_error, - ((PTR) &X32_critical_error_previous))) - == 0) - dos_record_interrupt_interception (DOS_INTVECT_CRITICAL_ERROR, - X32_interrupt_restore); - -#endif /* USE_ZORTECH_CERROR */ - } - } -#endif /* 0 to comment out SRA*/ -#if 0 - else if (feature_enabled_p ("MITSCHEME_DOSX_INTERRUPTS")) - { - scm_int_intercept (DOS_INTVECT_USER_TIMER_TICK, - bios_timer_handler, - 256); - - if (!dpmi_p) - { - scm_int_intercept (DOS_INTVECT_KB_CTRL_BREAK, - control_break_handler, - 256); - -#ifdef USE_ZORTECH_CERROR - _cerror_handler = critical_error_handler; - cerror_open (); -#else /* not USE_ZORTECH_CERROR */ - scm_int_intercept (DOS_INTVECT_CRITICAL_ERROR, - critical_error_handler, - 256); -#endif /* USE_ZORTECH_CERROR */ - } - } - if ((dos_install_kbd_hook ()) == DOS_SUCCESS) - { - dos_record_interrupt_interception (DOS_INTVECT_SYSTEM_SERVICES, - DOS_restore_keyboard); - DOS_keyboard_intercepted_p = true; - } -#endif /*0*/ -/*SRA - if (dpmi_p && (enable_DPMI_exceptions_p ())) - install_exception_handlers (DPMI_get_exception_vector, - DPMI_set_exception_handler, - DPMI_restore_handler); - else if (x32_p && (enable_X32_exceptions_p ())) - install_exception_handlers (X32_get_exception_vector, - X32_set_exception_handler, - X32_restore_handler); -*/ return; } @@ -1272,14 +1205,6 @@ DEFUN_VOID (DOS_restore_interrupts) dos_interrupt_restoration[iv] = ((int (*) (unsigned)) NULL); } -#ifdef USE_ZORTECH_CERROR - if (_cerror_handler == critical_error_handler) - { - cerror_close (); - _cerror_handler = ((int _far _cdecl (*) (int *, int *)) NULL); - } -#endif /* USE_ZORTECH_CERROR */ - dos_interrupts_initialized_p = false; } dos_set_ctrl_c_check_flag (ctrl_c_check_flag); @@ -1304,9 +1229,87 @@ DEFUN (bind_handler, (signo, handler), #endif /* UNUSED */ + + + + + +/* + * Timer interrupt based on multimedia system + * + * WARNING: the docs say that timer_tick and all that it references must + * be in a DLL witha a FIXED attribute. + * Also, it appears to need _stdcall, but mmsystem.h refutes this + */ + +void _stdcall +DEFUN (timer_tick, (wID, wMsg, dwUser, dw1, dw2), + UINT wID AND UINT wMsg AND DWORD dwUser AND DWORD dw1 AND DWORD dw2) +{ +// REQUEST_INTERRUPT(INT_Global_GC); /* windows polling */ + REQUEST_INTERRUPT(INT_Global_1); /* windows polling */ + REQUEST_INTERRUPT(INT_Timer); /* scheme interrupt */ +} + +static TIMECAPS tc; +static UINT msTargetResolution = 50; +static UINT msInterval = 75; +static UINT wTimerRes; +static UINT wTimerID; + +char * +DEFUN_VOID (install_timer) +{ +/* + outf_error (";; !Warning: timer interrupt not installed %s:%d.\n", + __FILE__,__LINE__); + return 0; +/**/ + if (timeGetDevCaps(&tc, sizeof(TIMECAPS)) != TIMERR_NOERROR) + return "timeGetDevCaps"; + wTimerRes = min(max(tc.wPeriodMin, msTargetResolution), tc.wPeriodMax); + if (timeBeginPeriod (wTimerRes) == TIMERR_NOCANDO) + return "timeBeginPeriod"; + wTimerID = + timeSetEvent (msInterval, + wTimerRes, + (LPTIMECALLBACK) timer_tick, + 0, + TIME_PERIODIC); + if (! wTimerID) + return "timeSetEvent"; + + return 0; +} + + + +void +DEFUN (NT_initialize_fov, (fov), SCHEME_OBJECT fov) +{ + extern SCHEME_OBJECT EXFUN (make_primitive, (char *)); + SCHEME_OBJECT iv, prim; + + prim = make_primitive ("NT-DEFAULT-POLL-GUI-INTERRUPT"); + iv = FAST_VECTOR_REF (fov, System_Interrupt_Vector); +// VECTOR_SET (iv, Global_GC_Level, prim); + VECTOR_SET (iv, Global_1_Level, prim); + return; +} + + + void -DEFUN_VOID (DOS_initialize_signals) +DEFUN_VOID (NT_initialize_signals) { + char *timer_error = install_timer(); + if (timer_error) { + outf_fatal ("install_timer: %s", timer_error); + outf_flush_fatal (); + abort (); + } + + #ifdef UNUSED initialize_signal_descriptors (); bind_handler (SIGINT, sighnd_control_c); diff --git a/v7/src/microcode/ntterm.h b/v7/src/microcode/ntterm.h index 28b39a01c..0d63419ad 100644 --- a/v7/src/microcode/ntterm.h +++ b/v7/src/microcode/ntterm.h @@ -1,6 +1,6 @@ /* -*-C-*- -$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/ntterm.h,v 1.1 1993/02/10 22:39:46 adams Exp $ +$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/ntterm.h,v 1.2 1993/06/24 01:52:11 gjr Exp $ Copyright (c) 1992 Massachusetts Institute of Technology @@ -38,4 +38,3 @@ MIT in each case. */ #include "osterm.h" #endif /* SCM_UXTERM_H */ - \ No newline at end of file diff --git a/v7/src/microcode/nttop.c b/v7/src/microcode/nttop.c index 9b8c1ea0b..41ad90d13 100644 --- a/v7/src/microcode/nttop.c +++ b/v7/src/microcode/nttop.c @@ -1,6 +1,6 @@ /* -*-C-*- -$Id: nttop.c,v 1.1 1993/02/10 22:39:46 adams Exp $ +$Id: nttop.c,v 1.2 1993/06/24 01:52:11 gjr Exp $ Copyright (c) 1992 Massachusetts Institute of Technology @@ -33,13 +33,16 @@ promotional, or sales literature without prior written consent from MIT in each case. */ #include "nt.h" +#include "ntgui.h" #include "nttop.h" #include "osctty.h" #include "ntutil.h" +#include "prims.h" #include "errors.h" #include "option.h" +#include "outf.h" -extern void EXFUN (DOS_initialize_channels, (void)); +extern void EXFUN (NT_initialize_channels, (void)); extern void EXFUN (DOS_initialize_ctty, (int interactive)); extern void EXFUN (DOS_initialize_directory_reader, (void)); extern void EXFUN (DOS_initialize_environment, (void)); @@ -49,7 +52,7 @@ extern void EXFUN (DOS_initialize_terminals, (void)); /*extern void EXFUN (DOS_initialize_trap_recovery, (void));*/ extern void EXFUN (DOS_initialize_conio, (void)); extern void EXFUN (DOS_initialize_tty, (void)); -extern void EXFUN (DOS_initialize_userio, (void)); +extern void EXFUN (NT_initialize_userio, (void)); extern void EXFUN (DOS_initialize_real_mode, (void)); extern void EXFUN (DOS_reset_channels, (void)); @@ -62,6 +65,8 @@ extern void EXFUN (DOS_ctty_save_internal_state, (void)); extern void EXFUN (DOS_ctty_restore_internal_state, (void)); extern void EXFUN (DOS_ctty_restore_external_state, (void)); +extern void EXFUN (NT_initialize_signals, (void)); + /* reset_interruptable_extent */ extern CONST char * OS_Name; @@ -82,11 +87,12 @@ DEFUN_VOID (OS_initialize) transaction_initialize (); interactive = 1; - DOS_initialize_channels (); + NT_gui_init (); + NT_initialize_channels (); DOS_initialize_environment (); DOS_initialize_tty (); /*DOS_initialize_trap_recovery ();*/ - DOS_initialize_signals (); + NT_initialize_signals (); DOS_initialize_directory_reader (); DOS_initialize_conio(); /*DOS_initialize_real_mode (); SRA*/ @@ -96,16 +102,16 @@ DEFUN_VOID (OS_initialize) { version_t version_number; dos_get_version(&version_number); - fprintf (stdout, "MIT Scheme running under %s %d.%d 386/486\n", + outf_console ("MIT Scheme running under %s %d.%d 386/486\r\n", OS_Variant, (int) version_number.major, (int) version_number.minor); /* To make our compiler vendors happy. */ - fprintf(stdout, - "Copyright (c) 1992 Massachusetts Institute of Technology\n"); + outf_console( + "Copyright (c) 1992 Massachusetts Institute of Technology\r\n"); } - fputs ("", stdout); - fflush (stdout); + outf_console ("\r\n"); + outf_flush_console (); } void @@ -123,8 +129,7 @@ DEFUN_VOID (OS_reset) void DEFUN (OS_quit, (code, abnormal_p), int code AND int abnormal_p) { - fflush (stdout); - fputs ("\nScheme has terminated abnormally!\n", stdout); + outf_console ("\nScheme has terminated abnormally!\n"); OS_restore_external_state (); } diff --git a/v7/src/microcode/nttop.h b/v7/src/microcode/nttop.h index 12900fa9e..e23071f7e 100644 --- a/v7/src/microcode/nttop.h +++ b/v7/src/microcode/nttop.h @@ -1,6 +1,6 @@ /* -*-C-*- -$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/nttop.h,v 1.1 1993/02/10 22:39:46 adams Exp $ +$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/nttop.h,v 1.2 1993/06/24 01:52:11 gjr Exp $ Copyright (c) 1992 Massachusetts Institute of Technology @@ -38,4 +38,3 @@ MIT in each case. */ #include "ostop.h" #endif /* SCM_DOSTOP_H */ - \ No newline at end of file diff --git a/v7/src/microcode/nttrap.c b/v7/src/microcode/nttrap.c index 831218aa5..7656dcf65 100644 --- a/v7/src/microcode/nttrap.c +++ b/v7/src/microcode/nttrap.c @@ -1,6 +1,6 @@ /* -*-C-*- -$Id: nttrap.c,v 1.1 1993/02/10 22:39:46 adams Exp $ +$Id: nttrap.c,v 1.2 1993/06/24 01:52:11 gjr Exp $ Copyright (c) 1992 Massachusetts Institute of Technology @@ -38,7 +38,7 @@ MIT in each case. */ #include "nttrap.h" #include "ntexcp.h" #include "ntinsn.h" - +#include "extern.h" extern void EXFUN (DOS_initialize_trap_recovery, (void)); CONST char * EXFUN (find_trap_name, (int trapno)); @@ -415,11 +415,10 @@ DEFUN (setup_trap_frame, (trapno, info, scp, trinfo, new_stack_pointer), if ((! (Valid_Fixed_Obj_Vector ())) || ((handler = (Get_Fixed_Obj_Slot (Trap_Handler))) == SHARP_F)) { - fprintf (stderr, "There is no trap handler for recovery!\n"); - fprintf (stderr, "Trap = %s.\n", (find_trap_name (trapno))); - fprintf (stderr, "pc = %04x:%08lx; sp = %04x:%08lx.\n", + outf_fatal ("There is no trap handler for recovery!\n"); + outf_fatal ("Trap = %s.\n", (find_trap_name (trapno))); + outf_fatal ("pc = %04x:%08lx; sp = %04x:%08lx.\n", scp->sc_cs, scp->sc_eip, scp->sc_ss, scp->sc_esp); - fflush (stderr); termination_trap (); } if (Free > MemTop) @@ -602,11 +601,11 @@ DEFUN (continue_from_trap, (trapno, info, scp), the_pc = ((FULL_SIGCONTEXT_PC (scp)) & PC_VALUE_MASK); #if FALSE - fprintf (stderr, "\ncontinue_from_trap:"); - fprintf (stderr, "\tpc = 0x%08lx\n", the_pc); - fprintf (stderr, "\tCsp = 0x%08lx\n", C_sp); - fprintf (stderr, "\tssp = 0x%08lx\n", scheme_sp); - fprintf (stderr, "\tesp = 0x%08lx\n", Ext_Stack_Pointer); + outf_error ("\ncontinue_from_trap:"); + outf_error ("\tpc = 0x%08lx\n", the_pc); + outf_error ("\tCsp = 0x%08lx\n", C_sp); + outf_error ("\tssp = 0x%08lx\n", scheme_sp); + outf_error ("\tesp = 0x%08lx\n", Ext_Stack_Pointer); #endif if (((the_pc & PC_ALIGNMENT_MASK) != 0) diff --git a/v7/src/microcode/nttrap.h b/v7/src/microcode/nttrap.h index 8b2f61fec..39e2c83ac 100644 --- a/v7/src/microcode/nttrap.h +++ b/v7/src/microcode/nttrap.h @@ -1,6 +1,6 @@ /* -*-C-*- -$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/nttrap.h,v 1.1 1993/02/10 22:39:46 adams Exp $ +$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/nttrap.h,v 1.2 1993/06/24 01:52:11 gjr Exp $ Copyright (c) 1992 Massachusetts Institute of Technology @@ -93,4 +93,3 @@ extern void EXFUN (hard_reset, (struct FULL_SIGCONTEXT * scp)); extern void EXFUN (soft_reset, (void)); #endif /* SCM_DOSTRAP_H */ - \ No newline at end of file diff --git a/v7/src/microcode/nttty.c b/v7/src/microcode/nttty.c index b803c929e..11b565bb9 100644 --- a/v7/src/microcode/nttty.c +++ b/v7/src/microcode/nttty.c @@ -1,6 +1,6 @@ /* -*-C-*- -$Id: nttty.c,v 1.1 1993/02/10 22:39:46 adams Exp $ +$Id: nttty.c,v 1.2 1993/06/24 01:52:11 gjr Exp $ Copyright (c) 1992 Massachusetts Institute of Technology @@ -37,11 +37,15 @@ MIT in each case. */ #include "osenv.h" #include "ntio.h" #include "ntterm.h" +#include "ntscreen.h" /* Standard Input and Output */ static Tchannel input_channel; static Tchannel output_channel; + +HANDLE master_tty_window = 0; + int tty_x_size; int tty_y_size; /* 1-based values */ @@ -63,12 +67,14 @@ DEFUN_VOID (OS_tty_output_channel) unsigned int DEFUN_VOID (OS_tty_x_size) { + Screen_GetSize (master_tty_window, &tty_y_size, &tty_x_size); return (tty_x_size); } unsigned int DEFUN_VOID (OS_tty_y_size) { + Screen_GetSize (master_tty_window, &tty_y_size, &tty_x_size); return (tty_y_size); } @@ -96,80 +102,24 @@ DEFUN_VOID (OS_tty_command_clear) #define DEFAULT_TTY_Y_SIZE 25 #endif -void -pc_gestalt_screen_x_size (void) -{ - tty_x_size = DEFAULT_TTY_X_SIZE; -/*SRA - char *psTemp; - - psTemp = (getenv ("MITSCHEME_COLUMNS")); - if (psTemp == NULL) - { - union REGS regs; - - regs.h.ah = 0x0F; - regs.h.al = 0x00; - int10h (®s, ®s); - tty_x_size = regs.h.ah; - } - else - { - tty_x_size = (atoi (psTemp)); - if (tty_x_size == 0) - tty_x_size = DEFAULT_TTY_X_SIZE; /* atoi failed, use default */ /* - } -*/ - return; -} - -void -pc_gestalt_screen_y_size (void) -{ - tty_y_size = DEFAULT_TTY_Y_SIZE; -/*SRA - char *psTemp; - - psTemp = (getenv ("MITSCHEME_LINES")); - if (psTemp == NULL) - { - union REGS regs; - - regs.x.ax = 0x1130; - regs.h.bh = 0x00; - regs.h.dl = DEFAULT_TTY_Y_SIZE-1; - int10h (®s, ®s); - tty_y_size = regs.h.dl + 1; - } - else - { - tty_y_size = (atoi (psTemp)); - if (tty_y_size == 0) - tty_y_size = DEFAULT_TTY_Y_SIZE; /* atoi failed, use default */ /* - } -*/ - return; -} void DEFUN_VOID (DOS_initialize_tty) { - extern Tchannel EXFUN (OS_open_fd, (int fd)); - input_channel = (OS_open_fd (STDIN_FILENO)); + extern Tchannel EXFUN (OS_open_handle, (int fd)); +// master_tty_window = Screen_Create (NULL, "MIT Scheme", SW_SHOWNORMAL); + input_channel = OS_open_handle (master_tty_window); +// input_channel = OS_open_handle (STDIN_HANDLE); (CHANNEL_INTERNAL (input_channel)) = 1; - output_channel = (OS_open_fd (STDOUT_FILENO)); + output_channel = input_channel; +// output_channel = OS_open_handle (STDOUT_HANDLE); (CHANNEL_INTERNAL (output_channel)) = 1; - tty_x_size = (-1); - tty_y_size = (-1); - tty_command_beep = ALERT_STRING; - tty_command_clear = "\033[2J"; + Screen_GetSize (master_tty_window, &tty_y_size, &tty_x_size); - /* Figure out the size of the terminal. Tries environment variables. - If that fails, use default values. */ + tty_command_beep = ALERT_STRING; + tty_command_clear = "\014"; - pc_gestalt_screen_x_size (); - pc_gestalt_screen_y_size (); return; } -- 2.25.1