Add --enable-sim-stdio to make console I/O use stdio, not printf_filtered and polling input
This commit is contained in:
parent
0e88ffa284
commit
d6103e8eb6
|
@ -1,3 +1,38 @@
|
||||||
|
Fri Mar 29 12:17:58 1996 Michael Meissner <meissner@tiktok.cygnus.com>
|
||||||
|
|
||||||
|
* Makefile.in (STDIO_CFLAGS): Pass on result of @sim_stdio@
|
||||||
|
configuration variable.
|
||||||
|
(CONFIG_CFLAGS): Include STDIO_CFLAGS.
|
||||||
|
|
||||||
|
* std-config.h (DO{,NT}_USE_STDIO): New flags for whether we
|
||||||
|
should use stdio for console input.
|
||||||
|
(WITH_STDIO): If not defined, define as DONT_USE_STDIO.
|
||||||
|
|
||||||
|
* configure.in (--enable-sim-stdio): Add new switch to control
|
||||||
|
whether stdio is used for console I/O.
|
||||||
|
* configure: Regenerate.
|
||||||
|
|
||||||
|
* device_table.c (console_use_stdio): New static variable set from
|
||||||
|
WITH_STDIO.
|
||||||
|
(scan_console): If console_use_stdio, use getchar to read byte
|
||||||
|
instead of doing polling I/O.
|
||||||
|
(write_console): If console_use_stdio, write byte with putchar.
|
||||||
|
(console_io_write_buffer_callback): If console_use_stdio, fflush
|
||||||
|
stdout.
|
||||||
|
(console_instance_write_callback): Ditto.
|
||||||
|
(console_instance_read_callback): If console_use_stdio, use fgets
|
||||||
|
to read line.
|
||||||
|
|
||||||
|
Fri Mar 29 12:17:58 1996 Andrew Cagney <cagney@kremvax.highland.com.au>
|
||||||
|
|
||||||
|
* emul_bugapi.c (_os_emul_data): Add fields for output, input.
|
||||||
|
(emul_bugapi_create): Create input, output from /chosen/stdin and
|
||||||
|
/chosen/stdout.
|
||||||
|
(emul_bugapi_do_{read,write}): Switch to use device_instance
|
||||||
|
interface.
|
||||||
|
(emul_bugapi_instruction_call): Change calls to
|
||||||
|
emul_bugapi_do_{read,write} to pass device instance argument.
|
||||||
|
|
||||||
Tue Mar 26 14:57:58 1996 Michael Meissner <meissner@tiktok.cygnus.com>
|
Tue Mar 26 14:57:58 1996 Michael Meissner <meissner@tiktok.cygnus.com>
|
||||||
|
|
||||||
* igen.c (idecode_switch_end): Fix 2/26 change so that an extra
|
* igen.c (idecode_switch_end): Fix 2/26 change so that an extra
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#
|
#
|
||||||
# This file is part of the program psim.
|
# This file is part of the program psim.
|
||||||
#
|
#
|
||||||
# Copyright (C) 1994-1995, Andrew Cagney <cagney@highland.com.au>
|
# Copyright (C) 1994-1996, Andrew Cagney <cagney@highland.com.au>
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or modify
|
# This program is free software; you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
@ -84,6 +84,7 @@ ASSERT_CFLAGS = @sim_assert@
|
||||||
RESERVED_CFLAGS = @sim_reserved@
|
RESERVED_CFLAGS = @sim_reserved@
|
||||||
MONITOR_CFLAGS = @sim_monitor@
|
MONITOR_CFLAGS = @sim_monitor@
|
||||||
MODEL_CFLAGS = @sim_model@ @sim_default_model@ @sim_model_issue@
|
MODEL_CFLAGS = @sim_model@ @sim_default_model@ @sim_model_issue@
|
||||||
|
STDIO_CFLAGS = @sim_stdio@
|
||||||
WARNING_CFLAGS = @sim_warnings@
|
WARNING_CFLAGS = @sim_warnings@
|
||||||
CONFIG_CFLAGS = $(BSWAP_CFLAGS) \
|
CONFIG_CFLAGS = $(BSWAP_CFLAGS) \
|
||||||
$(ENDIAN_CFLAGS) \
|
$(ENDIAN_CFLAGS) \
|
||||||
|
@ -100,7 +101,8 @@ CONFIG_CFLAGS = $(BSWAP_CFLAGS) \
|
||||||
$(ASSERT_CFLAGS) \
|
$(ASSERT_CFLAGS) \
|
||||||
$(RESERVED_CFLAGS) \
|
$(RESERVED_CFLAGS) \
|
||||||
$(MONITOR_CFLAGS) \
|
$(MONITOR_CFLAGS) \
|
||||||
$(MODEL_CFLAGS)
|
$(MODEL_CFLAGS) \
|
||||||
|
$(STDIO_CFLAGS)
|
||||||
|
|
||||||
STD_CFLAGS = $(CFLAGS) $(INLINE_CFLAGS) $(CONFIG_CFLAGS) $(WARNING_CFLAGS) $(SIM_CFLAGS) $(HDEFINES) $(TDEFINES) $(INCLUDES)
|
STD_CFLAGS = $(CFLAGS) $(INLINE_CFLAGS) $(CONFIG_CFLAGS) $(WARNING_CFLAGS) $(SIM_CFLAGS) $(HDEFINES) $(TDEFINES) $(INCLUDES)
|
||||||
NOWARN_CFLAGS = $(CFLAGS) $(INLINE_CFLAGS) $(CONFIG_CFLAGS) $(SIM_CFLAGS) $(HDEFINES) $(TDEFINES) $(INCLUDES)
|
NOWARN_CFLAGS = $(CFLAGS) $(INLINE_CFLAGS) $(CONFIG_CFLAGS) $(SIM_CFLAGS) $(HDEFINES) $(TDEFINES) $(INCLUDES)
|
||||||
|
@ -297,7 +299,7 @@ os_emul.o: os_emul.c emul_netbsd.h emul_chirp.h emul_bugapi.h $(EMUL_GENERIC_H)
|
||||||
emul_generic.o: emul_generic.c $(EMUL_GENERIC_H)
|
emul_generic.o: emul_generic.c $(EMUL_GENERIC_H)
|
||||||
|
|
||||||
emul_netbsd.o: emul_netbsd.c emul_netbsd.h $(EMUL_GENERIC_H)
|
emul_netbsd.o: emul_netbsd.c emul_netbsd.h $(EMUL_GENERIC_H)
|
||||||
emul_chirp.o: emul_chirp.c emul_chirp.h cap.h $(EMUL_GENERIC_H)
|
emul_chirp.o: emul_chirp.c emul_chirp.h $(EMUL_GENERIC_H)
|
||||||
emul_bugapi.o: emul_bugapi.c emul_bugapi.h $(EMUL_GENERIC_H)
|
emul_bugapi.o: emul_bugapi.c emul_bugapi.h $(EMUL_GENERIC_H)
|
||||||
|
|
||||||
registers.o: registers.c $(REGISTERS_H) $(BASICS_H)
|
registers.o: registers.c $(REGISTERS_H) $(BASICS_H)
|
||||||
|
@ -326,7 +328,7 @@ spreg.o: spreg.h spreg.c $(BASICS_H)
|
||||||
|
|
||||||
main.o: main.c $(PSIM_H) itable.h options.h
|
main.o: main.c $(PSIM_H) itable.h options.h
|
||||||
|
|
||||||
device.o: device.c $(DEVICE_TABLE_H)
|
device.o: device.c $(DEVICE_TABLE_H) cap.h
|
||||||
|
|
||||||
device_table.o: device_table.c $(DEVICE_TABLE_H) events.h
|
device_table.o: device_table.c $(DEVICE_TABLE_H) events.h
|
||||||
|
|
||||||
|
|
|
@ -364,6 +364,17 @@ if test x"$silent" != x"yes"; then
|
||||||
echo "Setting model-issue flags = $sim_model_issue" 6>&1
|
echo "Setting model-issue flags = $sim_model_issue" 6>&1
|
||||||
fi],[sim_model_issue=""])dnl
|
fi],[sim_model_issue=""])dnl
|
||||||
|
|
||||||
|
AC_ARG_ENABLE(sim-stdio,
|
||||||
|
[ --enable-sim-stdio Specify whether to use stdio for console input/output.],
|
||||||
|
[case "${enableval}" in
|
||||||
|
yes) sim_stdio="-DWITH_STDIO=DO_USE_STDIO";;
|
||||||
|
no) sim_stdio="-DWITH_STDIO=DONT_USE_STDIO";;
|
||||||
|
*) AC_MSG_ERROR("Unknown value $enableval passed to --enable-sim-stdio"); sim_stdio="";;
|
||||||
|
esac
|
||||||
|
if test x"$silent" != x"yes" && test x"$sim_stdio" != x""; then
|
||||||
|
echo "Setting stdio flags = $sim_stdio" 6>&1
|
||||||
|
fi],[sim_stdio=""])dnl
|
||||||
|
|
||||||
AC_CONFIG_AUX_DIR(`cd $srcdir;pwd`/../..)
|
AC_CONFIG_AUX_DIR(`cd $srcdir;pwd`/../..)
|
||||||
AC_CANONICAL_SYSTEM
|
AC_CANONICAL_SYSTEM
|
||||||
AC_ARG_PROGRAM
|
AC_ARG_PROGRAM
|
||||||
|
@ -405,6 +416,7 @@ AC_SUBST(sim_monitor)
|
||||||
AC_SUBST(sim_model)
|
AC_SUBST(sim_model)
|
||||||
AC_SUBST(sim_default_model)
|
AC_SUBST(sim_default_model)
|
||||||
AC_SUBST(sim_model_issue)
|
AC_SUBST(sim_model_issue)
|
||||||
|
AC_SUBST(sim_stdio)
|
||||||
|
|
||||||
AC_CHECK_FUNCS(getrusage)
|
AC_CHECK_FUNCS(getrusage)
|
||||||
|
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -166,6 +166,9 @@ struct _os_emul_data {
|
||||||
unsigned_word stall_cpu_loop_address;
|
unsigned_word stall_cpu_loop_address;
|
||||||
int little_endian;
|
int little_endian;
|
||||||
int floating_point_available;
|
int floating_point_available;
|
||||||
|
/* I/O devices */
|
||||||
|
device_instance *output;
|
||||||
|
device_instance *input;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -214,6 +217,10 @@ emul_bugapi_create(device *root,
|
||||||
= device_find_boolean_property(root, "/options/little-endian?");
|
= device_find_boolean_property(root, "/options/little-endian?");
|
||||||
bugapi->floating_point_available
|
bugapi->floating_point_available
|
||||||
= device_find_boolean_property(root, "/openprom/options/floating-point?");
|
= device_find_boolean_property(root, "/openprom/options/floating-point?");
|
||||||
|
bugapi->input
|
||||||
|
= device_find_ihandle_property(root, "/chosen/stdin");
|
||||||
|
bugapi->output
|
||||||
|
= device_find_ihandle_property(root, "/chosen/stdout");
|
||||||
|
|
||||||
/* initialization */
|
/* initialization */
|
||||||
device_tree_add_parsed(root, "/openprom/init/register/0.pc 0x%lx",
|
device_tree_add_parsed(root, "/openprom/init/register/0.pc 0x%lx",
|
||||||
|
@ -239,15 +246,15 @@ emul_bugapi_create(device *root,
|
||||||
/* patch the system call instruction to call this emulation and then
|
/* patch the system call instruction to call this emulation and then
|
||||||
do an rfi */
|
do an rfi */
|
||||||
node = device_tree_add_parsed(root, "/openprom/init/data@0x%lx",
|
node = device_tree_add_parsed(root, "/openprom/init/data@0x%lx",
|
||||||
(long)bugapi->system_call_address);
|
(unsigned long)bugapi->system_call_address);
|
||||||
device_tree_add_parsed(node, "./real-address 0x%lx",
|
device_tree_add_parsed(node, "./real-address 0x%lx",
|
||||||
(long)bugapi->system_call_address);
|
(unsigned long)bugapi->system_call_address);
|
||||||
device_tree_add_parsed(node, "./data 0x%x",
|
device_tree_add_parsed(node, "./data 0x%x",
|
||||||
emul_call_instruction);
|
emul_call_instruction);
|
||||||
node = device_tree_add_parsed(root, "/openprom/init/data@0x%lx",
|
node = device_tree_add_parsed(root, "/openprom/init/data@0x%lx",
|
||||||
(long)(bugapi->system_call_address + 4));
|
(unsigned long)bugapi->system_call_address + 4);
|
||||||
device_tree_add_parsed(node, "./real-address 0x%lx",
|
device_tree_add_parsed(node, "./real-address 0x%lx",
|
||||||
(long)(bugapi->system_call_address + 4));
|
(unsigned long)bugapi->system_call_address + 4);
|
||||||
device_tree_add_parsed(node, "./data 0x%x",
|
device_tree_add_parsed(node, "./data 0x%x",
|
||||||
emul_rfi_instruction);
|
emul_rfi_instruction);
|
||||||
|
|
||||||
|
@ -293,7 +300,8 @@ emul_bugapi_instruction_name(int call_id)
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
emul_bugapi_do_read(cpu *processor,
|
emul_bugapi_do_read(os_emul_data *bugapi,
|
||||||
|
cpu *processor,
|
||||||
unsigned_word cia,
|
unsigned_word cia,
|
||||||
unsigned_word buf,
|
unsigned_word buf,
|
||||||
int nbytes)
|
int nbytes)
|
||||||
|
@ -308,9 +316,11 @@ emul_bugapi_do_read(cpu *processor,
|
||||||
emul_read_buffer((void *)scratch_buffer, buf, nbytes, processor, cia);
|
emul_read_buffer((void *)scratch_buffer, buf, nbytes, processor, cia);
|
||||||
|
|
||||||
/* read */
|
/* read */
|
||||||
status = read (0, (void *)scratch_buffer, nbytes);
|
status = device_instance_read(bugapi->input,
|
||||||
|
(void *)scratch_buffer, nbytes);
|
||||||
|
|
||||||
if (status == -1) {
|
/* -1 = error, -2 = nothing available - see "serial" [IEEE1275] */
|
||||||
|
if (status < 0) {
|
||||||
status = 0;
|
status = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -327,14 +337,14 @@ emul_bugapi_do_read(cpu *processor,
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
emul_bugapi_do_write(cpu *processor,
|
emul_bugapi_do_write(os_emul_data *bugapi,
|
||||||
|
cpu *processor,
|
||||||
unsigned_word cia,
|
unsigned_word cia,
|
||||||
unsigned_word buf,
|
unsigned_word buf,
|
||||||
int nbytes,
|
int nbytes,
|
||||||
const char *suffix)
|
const char *suffix)
|
||||||
{
|
{
|
||||||
void *scratch_buffer = NULL;
|
void *scratch_buffer = NULL;
|
||||||
char *p;
|
|
||||||
int nr_moved;
|
int nr_moved;
|
||||||
|
|
||||||
/* get a tempoary bufer */
|
/* get a tempoary bufer */
|
||||||
|
@ -354,14 +364,13 @@ emul_bugapi_do_write(cpu *processor,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* write */
|
/* write */
|
||||||
for (p = (char *)scratch_buffer; nbytes-- > 0; p++)
|
device_instance_write(bugapi->output, scratch_buffer, nbytes);
|
||||||
printf_filtered("%c", *p);
|
|
||||||
|
|
||||||
zfree(scratch_buffer);
|
zfree(scratch_buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (suffix)
|
if (suffix)
|
||||||
printf_filtered("%s", suffix);
|
device_instance_write(bugapi->output, suffix, strlen(suffix));
|
||||||
|
|
||||||
flush_stdoutput ();
|
flush_stdoutput ();
|
||||||
}
|
}
|
||||||
|
@ -370,10 +379,10 @@ static int
|
||||||
emul_bugapi_instruction_call(cpu *processor,
|
emul_bugapi_instruction_call(cpu *processor,
|
||||||
unsigned_word cia,
|
unsigned_word cia,
|
||||||
unsigned_word ra,
|
unsigned_word ra,
|
||||||
os_emul_data *emul_data)
|
os_emul_data *bugapi)
|
||||||
{
|
{
|
||||||
const int call_id = cpu_registers(processor)->gpr[10];
|
const int call_id = cpu_registers(processor)->gpr[10];
|
||||||
const char *my_prefix = "bugapi";
|
const char *my_prefix UNUSED = "bugapi";
|
||||||
unsigned char uc;
|
unsigned char uc;
|
||||||
|
|
||||||
ITRACE (trace_os_emul,(" 0x%x %s, r3 = 0x%lx, r4 = 0x%lx\n",
|
ITRACE (trace_os_emul,(" 0x%x %s, r3 = 0x%lx, r4 = 0x%lx\n",
|
||||||
|
@ -382,7 +391,7 @@ emul_bugapi_instruction_call(cpu *processor,
|
||||||
(long)cpu_registers(processor)->gpr[4]));;
|
(long)cpu_registers(processor)->gpr[4]));;
|
||||||
|
|
||||||
/* check that this isn't an invalid instruction */
|
/* check that this isn't an invalid instruction */
|
||||||
if (cia != emul_data->system_call_address)
|
if (cia != bugapi->system_call_address)
|
||||||
return 0;
|
return 0;
|
||||||
switch (call_id) {
|
switch (call_id) {
|
||||||
default:
|
default:
|
||||||
|
@ -392,23 +401,28 @@ emul_bugapi_instruction_call(cpu *processor,
|
||||||
/* read a single character, output r3 = byte */
|
/* read a single character, output r3 = byte */
|
||||||
/* FIXME: Add support to unbuffer input */
|
/* FIXME: Add support to unbuffer input */
|
||||||
case _INCHR:
|
case _INCHR:
|
||||||
if (read (0, &uc, 1) < 0)
|
if (device_instance_read(bugapi->input, (void *)&uc, 1) <= 0)
|
||||||
uc = 0;
|
uc = 0;
|
||||||
cpu_registers(processor)->gpr[3] = uc;
|
cpu_registers(processor)->gpr[3] = uc;
|
||||||
break;
|
break;
|
||||||
/* read a line of at most 256 bytes, r3 = ptr to 1st byte, output r3 = ptr to last byte+1 */
|
/* read a line of at most 256 bytes, r3 = ptr to 1st byte, output r3 = ptr to last byte+1 */
|
||||||
case _INLN:
|
case _INLN:
|
||||||
cpu_registers(processor)->gpr[3] += emul_bugapi_do_read(processor, cia,
|
cpu_registers(processor)->gpr[3] += emul_bugapi_do_read(bugapi,
|
||||||
|
processor, cia,
|
||||||
cpu_registers(processor)->gpr[3],
|
cpu_registers(processor)->gpr[3],
|
||||||
256);
|
256);
|
||||||
break;
|
break;
|
||||||
/* output a character, r3 = character */
|
/* output a character, r3 = character */
|
||||||
case _OUTCHR:
|
case _OUTCHR:
|
||||||
printf_filtered("%c", (char)cpu_registers(processor)->gpr[3]);
|
{
|
||||||
|
char out = (char)cpu_registers(processor)->gpr[3];
|
||||||
|
device_instance_write(bugapi->output, &out, 1);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
/* output a string, r3 = ptr to 1st byte, r4 = ptr to last byte+1 */
|
/* output a string, r3 = ptr to 1st byte, r4 = ptr to last byte+1 */
|
||||||
case _OUTSTR:
|
case _OUTSTR:
|
||||||
emul_bugapi_do_write(processor, cia,
|
emul_bugapi_do_write(bugapi,
|
||||||
|
processor, cia,
|
||||||
cpu_registers(processor)->gpr[3],
|
cpu_registers(processor)->gpr[3],
|
||||||
cpu_registers(processor)->gpr[4] - cpu_registers(processor)->gpr[3],
|
cpu_registers(processor)->gpr[4] - cpu_registers(processor)->gpr[3],
|
||||||
(const char *)0);
|
(const char *)0);
|
||||||
|
@ -416,14 +430,15 @@ emul_bugapi_instruction_call(cpu *processor,
|
||||||
/* output a string followed by \r\n, r3 = ptr to 1st byte, r4 = ptr to last byte+1 */
|
/* output a string followed by \r\n, r3 = ptr to 1st byte, r4 = ptr to last byte+1 */
|
||||||
case _OUTLN:
|
case _OUTLN:
|
||||||
|
|
||||||
emul_bugapi_do_write(processor, cia,
|
emul_bugapi_do_write(bugapi,
|
||||||
|
processor, cia,
|
||||||
cpu_registers(processor)->gpr[3],
|
cpu_registers(processor)->gpr[3],
|
||||||
cpu_registers(processor)->gpr[4] - cpu_registers(processor)->gpr[3],
|
cpu_registers(processor)->gpr[4] - cpu_registers(processor)->gpr[3],
|
||||||
"\n");
|
"\n");
|
||||||
break;
|
break;
|
||||||
/* output a \r\n */
|
/* output a \r\n */
|
||||||
case _PCRLF:
|
case _PCRLF:
|
||||||
printf_filtered("\n");
|
device_instance_write(bugapi->output, "\n", 1);
|
||||||
break;
|
break;
|
||||||
/* return to ppcbug monitor */
|
/* return to ppcbug monitor */
|
||||||
case _RETURN:
|
case _RETURN:
|
||||||
|
|
Loading…
Reference in New Issue