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