From: David Given Date: Sun, 3 Jun 2018 12:50:20 +0000 (+0200) Subject: Modify 8086tiny so that the bios image is built in (which makes invocation X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=6013035f5959f88173f3648514b1ec4b6c37c29f;p=ack.git Modify 8086tiny so that the bios image is built in (which makes invocation vastly simpler). --- diff --git a/plat/pc86/emu/8086tiny.c b/plat/pc86/emu/8086tiny.c index 0d3e88089..a0eec055e 100644 --- a/plat/pc86/emu/8086tiny.c +++ b/plat/pc86/emu/8086tiny.c @@ -8,6 +8,7 @@ #include #include #include +#include #ifndef _WIN32 #include @@ -18,6 +19,9 @@ #include "SDL.h" #endif +extern uint8_t bios[]; +extern uint32_t bios_size; + // Emulator system constants #define IO_PORT_COUNT 0x10000 #define RAM_SIZE 0x10FFF0 @@ -158,7 +162,7 @@ unsigned char mem[RAM_SIZE], io_ports[IO_PORT_COUNT], *opcode_stream, *regs8, i_rm, i_w, i_reg, i_mod, i_mod_size, i_d, i_reg4bit, raw_opcode_id, xlat_opcode_id, extra, rep_mode, seg_override_en, rep_override_en, trap_flag, int8_asap, scratch_uchar, io_hi_lo, *vid_mem_base, spkr_en, bios_table_lookup[20][256]; unsigned short *regs16, reg_ip, seg_override, file_index, wave_counter; unsigned int op_source, op_dest, rm_addr, op_to_addr, op_from_addr, i_data0, i_data1, i_data2, scratch_uint, scratch2_uint, inst_counter, set_flags_type, GRAPHICS_X, GRAPHICS_Y, pixel_colors[16], vmem_ctr; -int op_result, disk[3], scratch_int; +int op_result, disk[2], scratch_int; time_t clock_buf; struct timeb ms_clock; @@ -279,15 +283,16 @@ int main(int argc, char **argv) // But, if the HD image file is prefixed with @, then boot from the HD regs8[REG_DL] = ((argc > 3) && (*argv[3] == '@')) ? argv[3]++, 0x80 : 0; - // Open BIOS (file id disk[2]), floppy disk image (disk[1]), and hard disk image (disk[0]) if specified - for (file_index = 3; file_index;) + // Open floppy disk image (disk[1]), and hard disk image (disk[0]) if specified + for (file_index = 2; file_index;) disk[--file_index] = *++argv ? open(*argv, 32898) : 0; // Set CX:AX equal to the hard disk image size, if present CAST(unsigned)regs16[REG_AX] = *disk ? lseek(*disk, 0, 2) >> 9 : 0; // Load BIOS image into F000:0100, and set IP to 0100 - read(disk[2], regs8 + (reg_ip = 0x100), 0xFF00); + reg_ip = 0x100; + memcpy(regs8+reg_ip, bios, bios_size); // Load instruction decoding helper table for (int i = 0; i < 20; i++) diff --git a/plat/pc86/emu/Makefile b/plat/pc86/emu/Makefile deleted file mode 100644 index e97681701..000000000 --- a/plat/pc86/emu/Makefile +++ /dev/null @@ -1,28 +0,0 @@ -# 8086tiny: a tiny, highly functional, highly portable PC emulator/VM -# Copyright 2013-14, Adrian Cable (adrian.cable@gmail.com) - http://www.megalith.co.uk/8086tiny -# -# This work is licensed under the MIT License. See included LICENSE.TXT. - -# 8086tiny builds with graphics and sound support -# 8086tiny_slowcpu improves graphics performance on slow platforms (e.g. Raspberry Pi) -# no_graphics compiles without SDL graphics/sound - -OPTS_ALL=-O3 -fsigned-char -std=c99 -OPTS_SDL=`sdl-config --cflags --libs` -OPTS_NOGFX=-DNO_GRAPHICS -OPTS_SLOWCPU=-DGRAPHICS_UPDATE_DELAY=25000 - -8086tiny: 8086tiny.c - ${CC} 8086tiny.c ${OPTS_SDL} ${OPTS_ALL} -o 8086tiny - strip 8086tiny - -8086tiny_slowcpu: 8086tiny.c - ${CC} 8086tiny.c ${OPTS_SDL} ${OPTS_ALL} ${OPTS_SLOWCPU} -o 8086tiny - strip 8086tiny - -no_graphics: 8086tiny.c - ${CC} 8086tiny.c ${OPTS_NOGFX} ${OPTS_ALL} -o 8086tiny - strip 8086tiny - -clean: - rm 8086tiny diff --git a/plat/pc86/emu/README.ACK.md b/plat/pc86/emu/README.ACK.md new file mode 100644 index 000000000..381c9bd89 --- /dev/null +++ b/plat/pc86/emu/README.ACK.md @@ -0,0 +1,3 @@ +This is a hacked-up copy of Adrian Cable's 8086tiny, modified for use running +the compiler tests. It's MIT licensed which makes it compatible with the ACK. + diff --git a/plat/pc86/emu/build.lua b/plat/pc86/emu/build.lua new file mode 100644 index 000000000..6982b0976 --- /dev/null +++ b/plat/pc86/emu/build.lua @@ -0,0 +1,21 @@ +normalrule { + name = "bios", + ins = { + "util/cmisc+bin2c", + "./bios", + }, + outleaves = {"bios.c"}, + commands = {"%{ins[1]} bios < %{ins[2]} > %{outs[1]}"} +} + +cprogram { + name = "8086tiny", + vars = { + ["+cflags"] = {"-DNO_GRAPHICS", "-fsigned-char"}, + }, + srcs = { + "./8086tiny.c", + "+bios" + } +} + diff --git a/plat/pc86/emu/runme b/plat/pc86/emu/runme deleted file mode 100755 index 450aa08eb..000000000 --- a/plat/pc86/emu/runme +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/sh -clear -stty cbreak raw -echo min 0 -if [ -f hd.img ] -then - ./8086tiny bios fd.img hd.img -else - ./8086tiny bios fd.img -fi -stty cooked echo diff --git a/plat/pc86/tests/build.lua b/plat/pc86/tests/build.lua index fe871e450..34ba49c2a 100644 --- a/plat/pc86/tests/build.lua +++ b/plat/pc86/tests/build.lua @@ -3,5 +3,5 @@ include("tests/plat/build.lua") plat_testsuite { name = "tests", plat = "pc86", - method = "qemu-system-i386" + method = "plat/pc86/emu+8086tiny", } diff --git a/util/cmisc/build.lua b/util/cmisc/build.lua index dec466279..11f512fa9 100644 --- a/util/cmisc/build.lua +++ b/util/cmisc/build.lua @@ -29,3 +29,8 @@ cprogram { srcs = { "./ed.c" } } +cprogram { + name = "bin2c", + srcs = { "./bin2c.c" } +} +