Merge remote-tracking branch 'remotes/vivier-m68k/tags/m68k-next-pull-request' into staging

Pull request q800 20211008

macfb: fixes for booting MacOS

# gpg: Signature made Fri 08 Oct 2021 04:44:44 AM PDT
# gpg:                using RSA key CD2F75DDC8E3A4DC2E4F5173F30C38BD3F2FBE3C
# gpg:                issuer "laurent@vivier.eu"
# gpg: Good signature from "Laurent Vivier <lvivier@redhat.com>" [full]
# gpg:                 aka "Laurent Vivier <laurent@vivier.eu>" [full]
# gpg:                 aka "Laurent Vivier (Red Hat) <lvivier@redhat.com>" [full]

* remotes/vivier-m68k/tags/m68k-next-pull-request:
  q800: wire macfb IRQ to separate video interrupt on VIA2
  macfb: add vertical blank interrupt
  macfb: fix 24-bit RGB pixel encoding
  macfb: fix up 1-bit pixel encoding
  macfb: add common monitor modes supported by the MacOS toolbox ROM
  macfb: add qdev property to specify display type
  macfb: implement mode sense to allow display type to be detected
  macfb: add trace events for reading and writing the control registers
  macfb: use memory_region_init_ram() in macfb_common_realize() for the framebuffer
  macfb: fix overflow of color_palette array
  macfb: fix invalid object reference in macfb_common_realize()
  macfb: update macfb.c to use the Error API best practices
  macfb: handle errors that occur during realize

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
This commit is contained in:
Richard Henderson
2021-10-08 05:02:19 -07:00
4 changed files with 429 additions and 30 deletions
+362 -24
View File
File diff suppressed because it is too large Load Diff
+7
View File
@@ -167,3 +167,10 @@ sm501_disp_ctrl_read(uint32_t addr, uint32_t val) "addr=0x%x, val=0x%x"
sm501_disp_ctrl_write(uint32_t addr, uint32_t val) "addr=0x%x, val=0x%x"
sm501_2d_engine_read(uint32_t addr, uint32_t val) "addr=0x%x, val=0x%x"
sm501_2d_engine_write(uint32_t addr, uint32_t val) "addr=0x%x, val=0x%x"
# macfb.c
macfb_ctrl_read(uint64_t addr, uint64_t value, unsigned int size) "addr 0x%"PRIx64 " value 0x%"PRIx64 " size %u"
macfb_ctrl_write(uint64_t addr, uint64_t value, unsigned int size) "addr 0x%"PRIx64 " value 0x%"PRIx64 " size %u"
macfb_sense_read(uint32_t value) "video sense: 0x%"PRIx32
macfb_sense_write(uint32_t value) "video sense: 0x%"PRIx32
macfb_update_mode(uint32_t width, uint32_t height, uint8_t depth) "setting mode to width %"PRId32 " height %"PRId32 " size %d"
+17 -6
View File
@@ -74,7 +74,7 @@
* is needed by the kernel to have early display and
* thus provided by the bootloader
*/
#define VIDEO_BASE 0xf9001000
#define VIDEO_BASE 0xf9000000
#define MAC_CLOCK 3686418
@@ -221,6 +221,7 @@ static void q800_init(MachineState *machine)
uint8_t *prom;
const int io_slice_nb = (IO_SIZE / IO_SLICE) - 1;
int i, checksum;
MacFbMode *macfb_mode;
ram_addr_t ram_size = machine->ram_size;
const char *kernel_filename = machine->kernel_filename;
const char *initrd_filename = machine->initrd_filename;
@@ -406,8 +407,10 @@ static void q800_init(MachineState *machine)
MAC_NUBUS_FIRST_SLOT * NUBUS_SUPER_SLOT_SIZE);
sysbus_mmio_map(SYS_BUS_DEVICE(dev), 1, NUBUS_SLOT_BASE +
MAC_NUBUS_FIRST_SLOT * NUBUS_SLOT_SIZE);
for (i = 0; i < VIA2_NUBUS_IRQ_NB; i++) {
qdev_connect_gpio_out(dev, 9,
qdev_get_gpio_in_named(via2_dev, "nubus-irq",
VIA2_NUBUS_IRQ_INTVIDEO));
for (i = 1; i < VIA2_NUBUS_IRQ_NB; i++) {
qdev_connect_gpio_out(dev, 9 + i,
qdev_get_gpio_in_named(via2_dev, "nubus-irq",
VIA2_NUBUS_IRQ_9 + i));
@@ -418,11 +421,19 @@ static void q800_init(MachineState *machine)
/* framebuffer in nubus slot #9 */
dev = qdev_new(TYPE_NUBUS_MACFB);
qdev_prop_set_uint32(dev, "slot", 9);
qdev_prop_set_uint32(dev, "width", graphic_width);
qdev_prop_set_uint32(dev, "height", graphic_height);
qdev_prop_set_uint8(dev, "depth", graphic_depth);
if (graphic_width == 1152 && graphic_height == 870 && graphic_depth == 8) {
qdev_prop_set_uint8(dev, "display", MACFB_DISPLAY_APPLE_21_COLOR);
} else {
qdev_prop_set_uint8(dev, "display", MACFB_DISPLAY_VGA);
}
qdev_realize_and_unref(dev, BUS(nubus), &error_fatal);
macfb_mode = (NUBUS_MACFB(dev)->macfb).mode;
cs = CPU(cpu);
if (linux_boot) {
uint64_t high;
@@ -445,12 +456,12 @@ static void q800_init(MachineState *machine)
BOOTINFO1(cs->as, parameters_base,
BI_MAC_MEMSIZE, ram_size >> 20); /* in MB */
BOOTINFO2(cs->as, parameters_base, BI_MEMCHUNK, 0, ram_size);
BOOTINFO1(cs->as, parameters_base, BI_MAC_VADDR, VIDEO_BASE);
BOOTINFO1(cs->as, parameters_base, BI_MAC_VADDR,
VIDEO_BASE + macfb_mode->offset);
BOOTINFO1(cs->as, parameters_base, BI_MAC_VDEPTH, graphic_depth);
BOOTINFO1(cs->as, parameters_base, BI_MAC_VDIM,
(graphic_height << 16) | graphic_width);
BOOTINFO1(cs->as, parameters_base, BI_MAC_VROW,
(graphic_width * graphic_depth + 7) / 8);
BOOTINFO1(cs->as, parameters_base, BI_MAC_VROW, macfb_mode->stride);
BOOTINFO1(cs->as, parameters_base, BI_MAC_SCCBASE, SCC_BASE);
rom = g_malloc(sizeof(*rom));
+43
View File
@@ -14,9 +14,42 @@
#define MACFB_H
#include "exec/memory.h"
#include "hw/irq.h"
#include "ui/console.h"
#include "qemu/timer.h"
#include "qom/object.h"
typedef enum {
MACFB_DISPLAY_APPLE_21_COLOR = 0,
MACFB_DISPLAY_APPLE_PORTRAIT = 1,
MACFB_DISPLAY_APPLE_12_RGB = 2,
MACFB_DISPLAY_APPLE_2PAGE_MONO = 3,
MACFB_DISPLAY_NTSC_UNDERSCAN = 4,
MACFB_DISPLAY_NTSC_OVERSCAN = 5,
MACFB_DISPLAY_APPLE_12_MONO = 6,
MACFB_DISPLAY_APPLE_13_RGB = 7,
MACFB_DISPLAY_16_COLOR = 8,
MACFB_DISPLAY_PAL1_UNDERSCAN = 9,
MACFB_DISPLAY_PAL1_OVERSCAN = 10,
MACFB_DISPLAY_PAL2_UNDERSCAN = 11,
MACFB_DISPLAY_PAL2_OVERSCAN = 12,
MACFB_DISPLAY_VGA = 13,
MACFB_DISPLAY_SVGA = 14,
} MacfbDisplayType;
typedef struct MacFbMode {
uint8_t type;
uint8_t depth;
uint32_t mode_ctrl1;
uint32_t mode_ctrl2;
uint32_t width;
uint32_t height;
uint32_t stride;
uint32_t offset;
} MacFbMode;
#define MACFB_NUM_REGS 8
typedef struct MacfbState {
MemoryRegion mem_vram;
MemoryRegion mem_ctrl;
@@ -28,6 +61,15 @@ typedef struct MacfbState {
uint8_t color_palette[256 * 3];
uint32_t width, height; /* in pixels */
uint8_t depth;
uint8_t type;
uint32_t regs[MACFB_NUM_REGS];
MacFbMode *mode;
uint32_t irq_state;
uint32_t irq_mask;
QEMUTimer *vbl_timer;
qemu_irq irq;
} MacfbState;
#define TYPE_MACFB "sysbus-macfb"
@@ -46,6 +88,7 @@ struct MacfbNubusDeviceClass {
DeviceClass parent_class;
DeviceRealize parent_realize;
DeviceUnrealize parent_unrealize;
};