1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-06-08 10:52:58 +00:00

Wire up a stub RTC plus appropriate option ROM.

This commit is contained in:
Thomas Harte 2023-12-06 22:56:09 -05:00
parent d696c15be5
commit 5fde3b8d5d
7 changed files with 69 additions and 8 deletions

View File

@ -15,6 +15,7 @@
#include "Memory.hpp"
#include "PIC.hpp"
#include "PIT.hpp"
#include "RTC.hpp"
#include "../../InstructionSets/x86/Decoder.hpp"
#include "../../InstructionSets/x86/Flags.hpp"
@ -601,8 +602,8 @@ using PPI = Intel::i8255::i8255<i8255PortHandler>;
template <VideoAdaptor video>
class IO {
public:
IO(PIT &pit, DMA &dma, PPI &ppi, PIC &pic, typename Adaptor<video>::type &card, FloppyController &fdc) :
pit_(pit), dma_(dma), ppi_(ppi), pic_(pic), video_(card), fdc_(fdc) {}
IO(PIT &pit, DMA &dma, PPI &ppi, PIC &pic, typename Adaptor<video>::type &card, FloppyController &fdc, RTC &rtc) :
pit_(pit), dma_(dma), ppi_(ppi), pic_(pic), video_(card), fdc_(fdc), rtc_(rtc) {}
template <typename IntT> void out(uint16_t port, IntT value) {
static constexpr uint16_t crtc_base =
@ -617,6 +618,9 @@ class IO {
}
break;
case 0x0070: rtc_.write<0>(uint8_t(value)); break;
case 0x0071: rtc_.write<1>(uint8_t(value)); break;
// On the XT the NMI can be masked by setting bit 7 on I/O port 0xA0.
case 0x00a0:
printf("TODO: NMIs %s\n", (value & 0x80) ? "masked" : "unmasked");
@ -751,6 +755,8 @@ class IO {
case 0x006c: case 0x006d: case 0x006e: case 0x006f:
return ppi_.read(port);
case 0x0071: return rtc_.read();
case 0x0080: return dma_.pages.page<0>();
case 0x0081: return dma_.pages.page<1>();
case 0x0082: return dma_.pages.page<2>();
@ -804,6 +810,7 @@ class IO {
PIC &pic_;
typename Adaptor<video>::type &video_;
FloppyController &fdc_;
RTC &rtc_;
};
class FlowController {
@ -880,7 +887,7 @@ class ConcreteMachine:
ppi_handler_(speaker_, keyboard_, video, DriveCount),
pit_(pit_observer_),
ppi_(ppi_handler_),
context(pit_, dma_, ppi_, pic_, video_, fdc_)
context(pit_, dma_, ppi_, pic_, video_, fdc_, rtc_)
{
// Set up DMA source/target.
dma_.set_memory(&context.memory);
@ -892,9 +899,10 @@ class ConcreteMachine:
// Fetch the BIOS. [8088 only, for now]
const auto bios = ROM::Name::PCCompatibleGLaBIOS;
const auto tick = ROM::Name::PCCompatibleGLaTICK;
const auto font = Video::FontROM;
ROM::Request request = ROM::Request(bios) && ROM::Request(font);
ROM::Request request = ROM::Request(bios) && ROM::Request(tick) && ROM::Request(font);
auto roms = rom_fetcher(request);
if(!request.validate(roms)) {
throw ROMMachine::Error::MissingROMs;
@ -903,6 +911,9 @@ class ConcreteMachine:
const auto &bios_contents = roms.find(bios)->second;
context.memory.install(0x10'0000 - bios_contents.size(), bios_contents.data(), bios_contents.size());
const auto &tick_contents = roms.find(tick)->second;
context.memory.install(0xd'0000, tick_contents.data(), tick_contents.size());
// Give the video card something to read from.
const auto &font_contents = roms.find(font)->second;
video_.set_source(context.memory.at(Video::BaseAddress), font_contents);
@ -1095,15 +1106,16 @@ class ConcreteMachine:
PIT pit_;
PPI ppi_;
RTC rtc_;
PCCompatible::KeyboardMapper keyboard_mapper_;
struct Context {
Context(PIT &pit, DMA &dma, PPI &ppi, PIC &pic, typename Adaptor<video>::type &card, FloppyController &fdc) :
Context(PIT &pit, DMA &dma, PPI &ppi, PIC &pic, typename Adaptor<video>::type &card, FloppyController &fdc, RTC &rtc) :
segments(registers),
memory(registers, segments),
flow_controller(registers, segments),
io(pit, dma, ppi, pic, card, fdc)
io(pit, dma, ppi, pic, card, fdc, rtc)
{
reset();
}

View File

@ -0,0 +1,40 @@
//
// RTC.hpp
// Clock Signal
//
// Created by Thomas Harte on 06/12/2023.
// Copyright © 2023 Thomas Harte. All rights reserved.
//
#ifndef RTC_h
#define RTC_h
namespace PCCompatible {
class RTC {
public:
template <int address>
void write(uint8_t value) {
switch(address) {
default: break;
case 0:
selected_ = value & 0x7f;
// NMI not yet supported.
break;
case 1:
// TODO.
break;
}
}
uint8_t read() {
return 0x00;
}
private:
int selected_;
};
}
#endif /* RTC_h */

View File

@ -570,6 +570,9 @@ Description::Description(Name name) {
case Name::PCCompatibleGLaBIOS:
*this = Description(name, "PCCompatible", "8088 GLaBIOS 0.2.5", "GLABIOS_0.2.5_8T.ROM", 8 * 1024, 0x9576944cu);
break;
case Name::PCCompatibleGLaTICK:
*this = Description(name, "PCCompatible", "AT GLaTICK 0.8.5", "GLaTICK_0.8.5_AT.ROM", 2 * 1024, 0x371ea3f1u);
break;
case Name::PCCompatiblePhoenix80286BIOS:
*this = Description(name, "PCCompatible", "Phoenix 80286 BIOS 3.05", "Phoenix 80286 ROM BIOS Version 3.05.bin", 32 * 1024, 0x8d0d318au);
break;

View File

@ -134,6 +134,7 @@ enum Name {
// PCCompatible.
PCCompatibleGLaBIOS,
PCCompatibleGLaTICK,
PCCompatiblePhoenix80286BIOS,
PCCompatibleMDAFont,
PCCompatibleCGAFont,

View File

@ -1194,6 +1194,7 @@
42AD55302A0C4D5000ACE410 /* 68000Storage.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = 68000Storage.hpp; sourceTree = "<group>"; };
42AD55312A0C4D5000ACE410 /* 68000Implementation.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = 68000Implementation.hpp; sourceTree = "<group>"; };
42E5C3922AC46A7700DA093D /* Carbon.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Carbon.framework; path = System/Library/Frameworks/Carbon.framework; sourceTree = SDKROOT; };
42EB81252B21788200429AF4 /* RTC.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = RTC.hpp; sourceTree = "<group>"; };
4B018B88211930DE002A3937 /* 65C02_extended_opcodes_test.bin */ = {isa = PBXFileReference; lastKnownFileType = archive.macbinary; name = 65C02_extended_opcodes_test.bin; path = "Klaus Dormann/65C02_extended_opcodes_test.bin"; sourceTree = "<group>"; };
4B01A6871F22F0DB001FD6E3 /* Z80MemptrTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Z80MemptrTests.swift; sourceTree = "<group>"; };
4B0333AD2094081A0050B93D /* AppleDSK.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = AppleDSK.cpp; sourceTree = "<group>"; };
@ -2405,6 +2406,7 @@
4267A9C82B0D4EC2008A59BB /* PIC.hpp */,
4267A9C72B0C26FA008A59BB /* PIT.hpp */,
423820142B1A23C200964EFE /* Registers.hpp */,
42EB81252B21788200429AF4 /* RTC.hpp */,
423820152B1A23E100964EFE /* Segments.hpp */,
);
path = PCCompatible;

Binary file not shown.

View File

@ -1,11 +1,14 @@
Expected files:
GLABIOS_0.2.5_8T.ROM — the 8088 GlaBIOS ROM.
GLABIOS_0.2.5_8T.ROM — the 8088 GLaBIOS ROM.
GLaTICK_0.8.5_AT.ROM — the GLaBIOS AT RTC option ROM.
Phoenix 80286 ROM BIOS Version 3.05.bin — Phoenix's 80286 AT-clone BIOS.
EUMDA9.F14 — a dump of the MDA font.
CGA.F08 — a dump of the CGA font.
GlaBIOS is an open-source GPLv3 alternative BIOS for XT clones, available from https://glabios.org/
GLaBIOS is an open-source GPLv3 alternative BIOS for XT clones, available from https://glabios.org/
GLaTICK is a real-time clock option ROM, also available from available from https://glabios.org/
The MDA and CGA fonts are in the form offered at https://github.com/viler-int10h/vga-text-mode-fonts i.e. it's 256 lots of 14 bytes, the first 14 being the content of character 0, the next 14 being the content of character 1, etc.