|
|
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: #include "gvram.h"
1.1.1.3 ! root 8: #include "videoctlr.h"
1.1 root 9:
10: //
11: // GVRAM
12: //
13: // GVRAM はワード単位でホストバイトオーダ配置なので、
14: // バイトアクセス時は HB() マクロを使用のこと。
15: //
16:
1.1.1.2 root 17: std::unique_ptr<GVRAMDevice> gGVRAM;
1.1 root 18:
19: GVRAMDevice::GVRAMDevice()
20: {
21: logname = "gvram";
22: devname = "GVRAM";
23: devaddr = 0xc00000;
24: devlen = 0x200000; // XXX とりあえず
25:
1.1.1.2 root 26: mem.reset(new uint8[devlen]);
1.1 root 27: }
28:
29: GVRAMDevice::~GVRAMDevice()
30: {
31: }
32:
33: uint64
34: GVRAMDevice::Read8(uint32 addr)
35: {
36: uint32 offset = addr - devaddr;
37: return mem[HB(offset)];
38: }
39:
40: uint64
41: GVRAMDevice::Read16(uint32 addr)
42: {
43: uint32 offset = addr - devaddr;
44: return *(uint16 *)&mem[offset];
45: }
46:
47: uint64
48: GVRAMDevice::Write8(uint32 addr, uint32 data)
49: {
50: uint32 offset = addr - devaddr;
51: mem[HB(offset)] = data;
52: return 0;
53: }
54:
55: uint64
56: GVRAMDevice::Write16(uint32 addr, uint32 data)
57: {
58: uint32 offset = addr - devaddr;
59: *(uint16 *)&mem[offset] = data;
60: return 0;
61: }
62:
63: uint64
64: GVRAMDevice::Peek8(uint32 addr)
65: {
66: return mem[HB(addr - devaddr)];
67: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.