1
2
3
4
5
6
7
8
9
10
11
12
13#ifndef MACFB_H
14#define MACFB_H
15
16#include "exec/memory.h"
17#include "hw/irq.h"
18#include "hw/nubus/nubus.h"
19#include "hw/sysbus.h"
20#include "ui/console.h"
21#include "qemu/timer.h"
22
23typedef enum {
24 MACFB_DISPLAY_APPLE_21_COLOR = 0,
25 MACFB_DISPLAY_APPLE_PORTRAIT = 1,
26 MACFB_DISPLAY_APPLE_12_RGB = 2,
27 MACFB_DISPLAY_APPLE_2PAGE_MONO = 3,
28 MACFB_DISPLAY_NTSC_UNDERSCAN = 4,
29 MACFB_DISPLAY_NTSC_OVERSCAN = 5,
30 MACFB_DISPLAY_APPLE_12_MONO = 6,
31 MACFB_DISPLAY_APPLE_13_RGB = 7,
32 MACFB_DISPLAY_16_COLOR = 8,
33 MACFB_DISPLAY_PAL1_UNDERSCAN = 9,
34 MACFB_DISPLAY_PAL1_OVERSCAN = 10,
35 MACFB_DISPLAY_PAL2_UNDERSCAN = 11,
36 MACFB_DISPLAY_PAL2_OVERSCAN = 12,
37 MACFB_DISPLAY_VGA = 13,
38 MACFB_DISPLAY_SVGA = 14,
39} MacfbDisplayType;
40
41typedef struct MacFbMode {
42 uint8_t type;
43 uint8_t depth;
44 uint32_t mode_ctrl1;
45 uint32_t mode_ctrl2;
46 uint32_t width;
47 uint32_t height;
48 uint32_t stride;
49 uint32_t offset;
50} MacFbMode;
51
52#define MACFB_CTRL_TOPADDR 0x200
53#define MACFB_NUM_REGS (MACFB_CTRL_TOPADDR / sizeof(uint32_t))
54
55typedef struct MacfbState {
56 MemoryRegion mem_vram;
57 MemoryRegion mem_ctrl;
58 QemuConsole *con;
59
60 uint8_t *vram;
61 uint32_t vram_bit_mask;
62 uint32_t palette_current;
63 uint8_t color_palette[256 * 3];
64 uint32_t width, height;
65 uint8_t depth;
66 uint8_t type;
67
68 uint32_t regs[MACFB_NUM_REGS];
69 MacFbMode *mode;
70
71 QEMUTimer *vbl_timer;
72 qemu_irq irq;
73} MacfbState;
74
75#define TYPE_MACFB "sysbus-macfb"
76OBJECT_DECLARE_SIMPLE_TYPE(MacfbSysBusState, MACFB)
77
78struct MacfbSysBusState {
79 SysBusDevice busdev;
80
81 MacfbState macfb;
82};
83
84#define TYPE_NUBUS_MACFB "nubus-macfb"
85OBJECT_DECLARE_TYPE(MacfbNubusState, MacfbNubusDeviceClass, NUBUS_MACFB)
86
87struct MacfbNubusDeviceClass {
88 DeviceClass parent_class;
89
90 DeviceRealize parent_realize;
91 DeviceUnrealize parent_unrealize;
92};
93
94
95struct MacfbNubusState {
96 NubusDevice busdev;
97
98 MacfbState macfb;
99};
100
101#endif
102