|
|
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 "mpu.h"
16: #include "videoctlr.h"
17:
1.1.1.8 ! root 18: // InsideOut p.135
! 19: static const busdata wait = busdata::Wait(9 * 40_nsec);
! 20:
1.1.1.6 root 21: // コンストラクタ
1.1 root 22: GVRAMDevice::GVRAMDevice()
1.1.1.7 root 23: : inherited(OBJ_GVRAM)
1.1 root 24: {
1.1.1.7 root 25: uint devlen = 0x20'0000; // XXX とりあえず
1.1 root 26:
1.1.1.2 root 27: mem.reset(new uint8[devlen]);
1.1 root 28: }
29:
1.1.1.6 root 30: // デストラクタ
1.1 root 31: GVRAMDevice::~GVRAMDevice()
32: {
33: }
34:
1.1.1.8 ! root 35: busdata
1.1 root 36: GVRAMDevice::Read8(uint32 addr)
37: {
1.1.1.8 ! root 38: busdata data;
1.1.1.7 root 39: uint32 offset = addr - baseaddr;
1.1.1.8 ! root 40: data = mem[HB(offset)];
! 41: data |= wait;
! 42: return data;
1.1 root 43: }
44:
1.1.1.8 ! root 45: busdata
1.1 root 46: GVRAMDevice::Read16(uint32 addr)
47: {
1.1.1.8 ! root 48: busdata data;
1.1.1.7 root 49: uint32 offset = addr - baseaddr;
1.1.1.8 ! root 50: data = *(uint16 *)&mem[offset];
! 51: data |= wait;
! 52: return data;
1.1 root 53: }
54:
1.1.1.8 ! root 55: busdata
1.1 root 56: GVRAMDevice::Write8(uint32 addr, uint32 data)
57: {
1.1.1.7 root 58: uint32 offset = addr - baseaddr;
1.1 root 59: mem[HB(offset)] = data;
1.1.1.8 ! root 60: return wait;
1.1 root 61: }
62:
1.1.1.8 ! root 63: busdata
1.1 root 64: GVRAMDevice::Write16(uint32 addr, uint32 data)
65: {
1.1.1.7 root 66: uint32 offset = addr - baseaddr;
1.1 root 67: *(uint16 *)&mem[offset] = data;
1.1.1.8 ! root 68: return wait;
1.1 root 69: }
70:
1.1.1.8 ! root 71: busdata
1.1 root 72: GVRAMDevice::Peek8(uint32 addr)
73: {
1.1.1.7 root 74: return mem[HB(addr - baseaddr)];
1.1 root 75: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.