|
|
1.1 root 1: //
2: // nono
1.1.1.3 root 3: // Copyright (C) 2020 nono project
4: // Licensed under nono-license.txt
1.1 root 5: //
6:
7: //
8: // GVRAM
9: //
1.1.1.6 root 10:
1.1 root 11: // GVRAM はワード単位でホストバイトオーダ配置なので、
12: // バイトアクセス時は HB() マクロを使用のこと。
13:
1.1.1.6 root 14: #include "gvram.h"
15: #include "videoctlr.h"
16:
1.1.1.8 root 17: // InsideOut p.135
18: static const busdata wait = busdata::Wait(9 * 40_nsec);
19:
1.1.1.6 root 20: // コンストラクタ
1.1 root 21: GVRAMDevice::GVRAMDevice()
1.1.1.7 root 22: : inherited(OBJ_GVRAM)
1.1 root 23: {
1.1.1.7 root 24: uint devlen = 0x20'0000; // XXX とりあえず
1.1 root 25:
1.1.1.2 root 26: mem.reset(new uint8[devlen]);
1.1 root 27: }
28:
1.1.1.6 root 29: // デストラクタ
1.1 root 30: GVRAMDevice::~GVRAMDevice()
31: {
32: }
33:
1.1.1.9 ! root 34: inline uint32
! 35: GVRAMDevice::Decoder(uint32 addr) const
1.1 root 36: {
1.1.1.9 ! root 37: return addr - baseaddr;
1.1 root 38: }
39:
1.1.1.8 root 40: busdata
1.1.1.9 ! root 41: GVRAMDevice::Read(busaddr addr)
1.1 root 42: {
1.1.1.9 ! root 43: uint32 offset = Decoder(addr.Addr());
1.1.1.8 root 44: busdata data;
1.1.1.9 ! root 45:
! 46: data = *(uint16 *)&mem[offset & ~1U];
1.1.1.8 root 47: data |= wait;
1.1.1.9 ! root 48: data |= BusData::Size2;
1.1.1.8 root 49: return data;
1.1 root 50: }
51:
1.1.1.8 root 52: busdata
1.1.1.9 ! root 53: GVRAMDevice::Write(busaddr addr, uint32 data)
1.1 root 54: {
1.1.1.9 ! root 55: uint32 offset = Decoder(addr.Addr());
! 56: uint32 reqsize = addr.GetSize();
! 57: uint32 datasize = std::min(2 - (offset & 1U), reqsize);
! 58: data >>= (reqsize - datasize) * 8;
! 59:
! 60: if (datasize == 1) {
! 61: mem[HB(offset)] = data;
! 62: } else {
! 63: *(uint16 *)&mem[offset] = data;
! 64: }
! 65:
! 66: busdata r = wait;
! 67: r |= busdata::Size(datasize);
! 68: return r;
1.1 root 69: }
70:
1.1.1.8 root 71: busdata
1.1.1.9 ! root 72: GVRAMDevice::Peek1(uint32 addr)
1.1 root 73: {
1.1.1.9 ! root 74: uint32 offset = Decoder(addr);
! 75: return mem[HB(offset)];
1.1 root 76: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.