From nobody Fri Oct 10 09:45:07 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1579660865; cv=none; d=zohomail.com; s=zohoarc; b=Pe/V6G7TzrhFNHwUGbknlqGuHAl6/bA//T8F516svNJcW2F0zACSJadIIAL0jamLF2X+rWwI6Q1Ue2xRlv7pGzgBDAztQ3h63aYcSwriwJFm4dPJ0tUZ0F3PRpUtmKkk7+nEIAotecHIPGBUYKT9/T08l7ExQLMi0WdEhNrNZOs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1579660865; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=PL7981JC7THM1oikziOAuWXEXxZeKDn9/mq6lACryMw=; b=QHgc1eqL7g0K9MxhWow2Z/ytotZEh1vRAd+pf1dmQZhOxHH1DL2pR4BFHtssay6T8Scz7n5hTS6K430G4ouPUFgDLoP2PaVmjPmBjfkqL6xmN4IcQYDNORzLNusEB3dg1Ui5Pw4tsfkzwrkvn8Fvn6C31UnzcyI0Ovl/o/gNQRA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1579660865074177.95231838918676; Tue, 21 Jan 2020 18:41:05 -0800 (PST) Received: from localhost ([::1]:35414 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iu5x1-0002DM-UW for importer@patchew.org; Tue, 21 Jan 2020 21:41:03 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:44012) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iu5pi-00017F-5p for qemu-devel@nongnu.org; Tue, 21 Jan 2020 21:33:34 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iu5pd-0001vM-Sa for qemu-devel@nongnu.org; Tue, 21 Jan 2020 21:33:30 -0500 Received: from mail-pj1-x1029.google.com ([2607:f8b0:4864:20::1029]:55178) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iu5pd-0001tj-2h for qemu-devel@nongnu.org; Tue, 21 Jan 2020 21:33:25 -0500 Received: by mail-pj1-x1029.google.com with SMTP id kx11so2357530pjb.4 for ; Tue, 21 Jan 2020 18:33:24 -0800 (PST) Received: from localhost.localdomain (rrcs-173-198-77-92.west.biz.rr.com. [173.198.77.92]) by smtp.gmail.com with ESMTPSA id t1sm42935209pgq.23.2020.01.21.18.33.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Jan 2020 18:33:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=PL7981JC7THM1oikziOAuWXEXxZeKDn9/mq6lACryMw=; b=mhkxzP9eyQ3TWKssAOJXvVwbySkG1BNF2LJinBs1TG9tdUMyL+EoC8KeZkH/Y9eS83 Tq39IMKARRU4x/vge7WH8fQH7jDJ66gy8NFA+16Haef2yAMBwdTJMWuxCcEOFHH/QS5F /pRpI8DCQpxp4KE3FrW0kcrcp8uF2ZTpRJLaooCxCOCleitKIVvlHClpoE7BCyLQaHrf BDxqDbcF0YItAruVY+o+nKuAE/eSiOn9jzol+BHvPqwaU6zhmZH+M/zt8w46QokN5zGo 2N7HW4HrTkDLZnoEJ5jxNWRtcgF8w4RseM0ddzaW4azgl4F0McD/HfV66hZLJlDcaGyW E1zA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=PL7981JC7THM1oikziOAuWXEXxZeKDn9/mq6lACryMw=; b=RmP4ih4qlxbbyzBt5xNbp19L0i4XYd3mJrErPGCgJy7+qNoHOYX/+T1/BB2uO0XD26 HY85qA+HI93hq5ulCviCkAJD5oV8ayg3NNbpYD0PFbzIG7LoaBUnN35Mc43iSTcQ/nFC DxXfY1HuH0EHZN2cEdMrcv50dHKkIDxEVd/DZRC8kZ0IF9A4Fln0HcxP2QsQ1NzUZsoz BlGXjlwou/1OUa5orVng4+RPz6DNVlNUioZPh4ulYjHzNh3JBBP6PeSxp3VUFMJn/Oe8 nQiQ366O4ov3dwCJQzAeoEuAkqCSaoqOuI1NbL1mozPrDiiq9jkzaE8PiKtvUXzgKQZq qQGg== X-Gm-Message-State: APjAAAXB9M5CC4CetoZzMjIXYB6PU868xudJ9+yEpSFOCAbYc+ppURov 2XOD3QyILLhSWqz1bDm4PHFEkpQYYu0= X-Google-Smtp-Source: APXvYqxv6eiLVib0jQUorHgOG+kJ8MjtgFUNLKHa1ZOJU8kyB/Cle0Z16eotiWsdFYDML2vbdtsw3g== X-Received: by 2002:a17:90a:a48c:: with SMTP id z12mr394462pjp.38.1579660402382; Tue, 21 Jan 2020 18:33:22 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 07/11] hppa: Add emulation of Artist graphics Date: Tue, 21 Jan 2020 16:32:52 -1000 Message-Id: <20200122023256.27556-8-richard.henderson@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200122023256.27556-1-richard.henderson@linaro.org> References: <20200122023256.27556-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::1029 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, Sven Schnelle Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) Content-Type: text/plain; charset="utf-8" From: Sven Schnelle This adds emulation of Artist graphics good enough to get a Text console on both Linux and HP-UX. The X11 server from HP-UX also works. Signed-off-by: Sven Schnelle Message-Id: <20191220211512.3289-6-svens@stackframe.org> [rth: Merge Helge's test for machine->enable_graphics] Signed-off-by: Richard Henderson --- hw/hppa/hppa_hardware.h | 1 + hw/display/artist.c | 1450 ++++++++++++++++++++++++++++++++++++++ hw/hppa/machine.c | 10 + hw/display/Kconfig | 4 + hw/display/Makefile.objs | 1 + hw/display/trace-events | 9 + hw/hppa/Kconfig | 1 + 7 files changed, 1476 insertions(+) create mode 100644 hw/display/artist.c diff --git a/hw/hppa/hppa_hardware.h b/hw/hppa/hppa_hardware.h index 507f91e05d..4a2fe2df60 100644 --- a/hw/hppa/hppa_hardware.h +++ b/hw/hppa/hppa_hardware.h @@ -22,6 +22,7 @@ #define LASI_PS2KBD_HPA 0xffd08000 #define LASI_PS2MOU_HPA 0xffd08100 #define LASI_GFX_HPA 0xf8000000 +#define ARTIST_FB_ADDR 0xf9000000 #define CPU_HPA 0xfffb0000 #define MEMORY_HPA 0xfffbf000 =20 diff --git a/hw/display/artist.c b/hw/display/artist.c new file mode 100644 index 0000000000..0885b7b988 --- /dev/null +++ b/hw/display/artist.c @@ -0,0 +1,1450 @@ +/* + * QEMU HP Artist Emulation + * + * Copyright (c) 2019 Sven Schnelle + * + * This work is licensed under the terms of the GNU GPL, version 2 or late= r. + */ + +#include "qemu/osdep.h" +#include "qemu-common.h" +#include "qemu/error-report.h" +#include "qemu/typedefs.h" +#include "qemu/log.h" +#include "qemu/module.h" +#include "qemu/units.h" +#include "qapi/error.h" +#include "hw/sysbus.h" +#include "hw/loader.h" +#include "hw/qdev-core.h" +#include "hw/qdev-properties.h" +#include "migration/vmstate.h" +#include "ui/console.h" +#include "trace.h" +#include "hw/display/framebuffer.h" + +#define TYPE_ARTIST "artist" +#define ARTIST(obj) OBJECT_CHECK(ARTISTState, (obj), TYPE_ARTIST) + +#ifdef HOST_WORDS_BIGENDIAN +#define ROP8OFF(_i) (3 - (_i)) +#else +#define ROP8OFF +#endif + +struct vram_buffer { + MemoryRegion mr; + uint8_t *data; + int size; + int width; + int height; +}; + +typedef struct ARTISTState { + SysBusDevice parent_obj; + + QemuConsole *con; + MemoryRegion vram_mem; + MemoryRegion mem_as_root; + MemoryRegion reg; + MemoryRegionSection fbsection; + + void *vram_int_mr; + AddressSpace as; + + struct vram_buffer vram_buffer[16]; + + uint16_t width; + uint16_t height; + uint16_t depth; + + uint32_t fg_color; + uint32_t bg_color; + + uint32_t vram_char_y; + uint32_t vram_bitmask; + + uint32_t vram_start; + uint32_t vram_pos; + + uint32_t vram_size; + + uint32_t blockmove_source; + uint32_t blockmove_dest; + uint32_t blockmove_size; + + uint32_t line_size; + uint32_t line_end; + uint32_t line_xy; + uint32_t line_pattern_start; + uint32_t line_pattern_skip; + + uint32_t cursor_pos; + + uint32_t cursor_height; + uint32_t cursor_width; + + uint32_t plane_mask; + + uint32_t reg_100080; + uint32_t reg_300200; + uint32_t reg_300208; + uint32_t reg_300218; + + uint32_t cmap_bm_access; + uint32_t dst_bm_access; + uint32_t src_bm_access; + uint32_t control_plane; + uint32_t transfer_data; + uint32_t image_bitmap_op; + + uint32_t font_write1; + uint32_t font_write2; + uint32_t font_write_pos_y; + + int draw_line_pattern; +} ARTISTState; + +typedef enum { + ARTIST_BUFFER_AP =3D 1, + ARTIST_BUFFER_OVERLAY =3D 2, + ARTIST_BUFFER_CURSOR1 =3D 6, + ARTIST_BUFFER_CURSOR2 =3D 7, + ARTIST_BUFFER_ATTRIBUTE =3D 13, + ARTIST_BUFFER_CMAP =3D 15, +} artist_buffer_t; + +typedef enum { + VRAM_IDX =3D 0x1004a0, + VRAM_BITMASK =3D 0x1005a0, + VRAM_WRITE_INCR_X =3D 0x100600, + VRAM_WRITE_INCR_X2 =3D 0x100604, + VRAM_WRITE_INCR_Y =3D 0x100620, + VRAM_START =3D 0x100800, + BLOCK_MOVE_SIZE =3D 0x100804, + BLOCK_MOVE_SOURCE =3D 0x100808, + TRANSFER_DATA =3D 0x100820, + FONT_WRITE_INCR_Y =3D 0x1008a0, + VRAM_START_TRIGGER =3D 0x100a00, + VRAM_SIZE_TRIGGER =3D 0x100a04, + FONT_WRITE_START =3D 0x100aa0, + BLOCK_MOVE_DEST_TRIGGER =3D 0x100b00, + BLOCK_MOVE_SIZE_TRIGGER =3D 0x100b04, + LINE_XY =3D 0x100ccc, + PATTERN_LINE_START =3D 0x100ecc, + LINE_SIZE =3D 0x100e04, + LINE_END =3D 0x100e44, + CMAP_BM_ACCESS =3D 0x118000, + DST_BM_ACCESS =3D 0x118004, + SRC_BM_ACCESS =3D 0x118008, + CONTROL_PLANE =3D 0x11800c, + FG_COLOR =3D 0x118010, + BG_COLOR =3D 0x118014, + PLANE_MASK =3D 0x118018, + IMAGE_BITMAP_OP =3D 0x11801c, + CURSOR_POS =3D 0x300100, + CURSOR_CTRL =3D 0x300104, +} artist_reg_t; + +typedef enum { + ARTIST_ROP_CLEAR =3D 0, + ARTIST_ROP_COPY =3D 3, + ARTIST_ROP_XOR =3D 6, + ARTIST_ROP_NOT_DST =3D 10, + ARTIST_ROP_SET =3D 15, +} artist_rop_t; + +#define REG_NAME(_x) case _x: return " "#_x; +static const char *artist_reg_name(uint64_t addr) +{ + switch ((artist_reg_t)addr) { + REG_NAME(VRAM_IDX); + REG_NAME(VRAM_BITMASK); + REG_NAME(VRAM_WRITE_INCR_X); + REG_NAME(VRAM_WRITE_INCR_X2); + REG_NAME(VRAM_WRITE_INCR_Y); + REG_NAME(VRAM_START); + REG_NAME(BLOCK_MOVE_SIZE); + REG_NAME(BLOCK_MOVE_SOURCE); + REG_NAME(FG_COLOR); + REG_NAME(BG_COLOR); + REG_NAME(PLANE_MASK); + REG_NAME(VRAM_START_TRIGGER); + REG_NAME(VRAM_SIZE_TRIGGER); + REG_NAME(BLOCK_MOVE_DEST_TRIGGER); + REG_NAME(BLOCK_MOVE_SIZE_TRIGGER); + REG_NAME(TRANSFER_DATA); + REG_NAME(CONTROL_PLANE); + REG_NAME(IMAGE_BITMAP_OP); + REG_NAME(CMAP_BM_ACCESS); + REG_NAME(DST_BM_ACCESS); + REG_NAME(SRC_BM_ACCESS); + REG_NAME(CURSOR_POS); + REG_NAME(CURSOR_CTRL); + REG_NAME(LINE_XY); + REG_NAME(PATTERN_LINE_START); + REG_NAME(LINE_SIZE); + REG_NAME(LINE_END); + REG_NAME(FONT_WRITE_INCR_Y); + REG_NAME(FONT_WRITE_START); + } + return ""; +} + +static int16_t artist_get_x(uint32_t reg) +{ + return reg >> 16; +} + +static int16_t artist_get_y(uint32_t reg) +{ + return reg & 0xffff; +} + +static void artist_invalidate_lines(struct vram_buffer *buf, + int starty, int height) +{ + int start =3D starty * buf->width; + int size =3D height * buf->width; + + if (start + size <=3D buf->size) { + memory_region_set_dirty(&buf->mr, start, size); + } +} + +static int vram_write_pix_per_transfer(ARTISTState *s) +{ + if (s->cmap_bm_access) { + return 1 << ((s->cmap_bm_access >> 27) & 0x0f); + } else { + return 1 << ((s->dst_bm_access >> 27) & 0x0f); + } +} + +static int vram_pixel_length(ARTISTState *s) +{ + if (s->cmap_bm_access) { + return (s->cmap_bm_access >> 24) & 0x07; + } else { + return (s->dst_bm_access >> 24) & 0x07; + } +} + +static int vram_write_bufidx(ARTISTState *s) +{ + if (s->cmap_bm_access) { + return (s->cmap_bm_access >> 12) & 0x0f; + } else { + return (s->dst_bm_access >> 12) & 0x0f; + } +} + +static int vram_read_bufidx(ARTISTState *s) +{ + if (s->cmap_bm_access) { + return (s->cmap_bm_access >> 12) & 0x0f; + } else { + return (s->src_bm_access >> 12) & 0x0f; + } +} + +static struct vram_buffer *vram_read_buffer(ARTISTState *s) +{ + return &s->vram_buffer[vram_read_bufidx(s)]; +} + +static struct vram_buffer *vram_write_buffer(ARTISTState *s) +{ + return &s->vram_buffer[vram_write_bufidx(s)]; +} + +static uint8_t artist_get_color(ARTISTState *s) +{ + if (s->image_bitmap_op & 2) { + return s->fg_color; + } else { + return s->bg_color; + } +} + +static artist_rop_t artist_get_op(ARTISTState *s) +{ + return (s->image_bitmap_op >> 8) & 0xf; +} + +static void artist_rop8(ARTISTState *s, uint8_t *dst, uint8_t val) +{ + + const artist_rop_t op =3D artist_get_op(s); + uint8_t plane_mask =3D s->plane_mask & 0xff; + + switch (op) { + case ARTIST_ROP_CLEAR: + *dst &=3D ~plane_mask; + break; + + case ARTIST_ROP_COPY: + *dst &=3D ~plane_mask; + *dst |=3D val & plane_mask; + break; + + case ARTIST_ROP_XOR: + *dst ^=3D val & plane_mask; + break; + + case ARTIST_ROP_NOT_DST: + *dst ^=3D plane_mask; + break; + + case ARTIST_ROP_SET: + *dst |=3D plane_mask; + break; + + default: + qemu_log_mask(LOG_UNIMP, "%s: unsupported rop %d\n", __func__, op); + break; + } +} + +static void artist_get_cursor_pos(ARTISTState *s, int *x, int *y) +{ + /* + * Don't know whether these magic offset values are configurable via + * some register. They are the same for all resolutions, so don't + * bother about it. + */ + + *y =3D 0x47a - artist_get_y(s->cursor_pos); + *x =3D ((artist_get_x(s->cursor_pos) - 338) / 2); + + if (*x > s->width) { + *x =3D 0; + } + + if (*y > s->height) { + *y =3D 0; + } +} + +static void artist_invalidate_cursor(ARTISTState *s) +{ + int x, y; + artist_get_cursor_pos(s, &x, &y); + artist_invalidate_lines(&s->vram_buffer[ARTIST_BUFFER_AP], + y, s->cursor_height); +} + +static void vram_bit_write(ARTISTState *s, int posx, int posy, bool incr_x, + int size, uint32_t data) +{ + struct vram_buffer *buf; + uint32_t vram_bitmask =3D s->vram_bitmask; + int mask, i, pix_count, pix_length, offset, height, width; + uint8_t *data8, *p; + + pix_count =3D vram_write_pix_per_transfer(s); + pix_length =3D vram_pixel_length(s); + + buf =3D vram_write_buffer(s); + height =3D buf->height; + width =3D buf->width; + + if (s->cmap_bm_access) { + offset =3D s->vram_pos; + } else { + offset =3D posy * width + posx; + } + + if (!buf->size) { + qemu_log("write to non-existent buffer\n"); + return; + } + + p =3D buf->data; + + if (pix_count > size * 8) { + pix_count =3D size * 8; + } + + if (posy * width + posx + pix_count > buf->size) { + qemu_log("write outside bounds: wants %dx%d, max size %dx%d\n", + posx, posy, width, height); + return; + } + + + switch (pix_length) { + case 0: + if (s->image_bitmap_op & 0x20000000) { + data &=3D vram_bitmask; + } + + for (i =3D 0; i < pix_count; i++) { + artist_rop8(s, p + offset + pix_count - 1 - i, + (data & 1) ? (s->plane_mask >> 24) : 0); + data >>=3D 1; + } + memory_region_set_dirty(&buf->mr, offset, pix_count); + break; + + case 3: + if (s->cmap_bm_access) { + *(uint32_t *)(p + offset) =3D data; + break; + } + data8 =3D (uint8_t *)&data; + + for (i =3D 3; i >=3D 0; i--) { + if (!(s->image_bitmap_op & 0x20000000) || + s->vram_bitmask & (1 << (28 + i))) { + artist_rop8(s, p + offset + 3 - i, data8[ROP8OFF(i)]); + } + } + memory_region_set_dirty(&buf->mr, offset, 3); + break; + + case 6: + switch (size) { + default: + case 4: + vram_bitmask =3D s->vram_bitmask; + break; + + case 2: + vram_bitmask =3D s->vram_bitmask >> 16; + break; + + case 1: + vram_bitmask =3D s->vram_bitmask >> 24; + break; + } + + for (i =3D 0; i < pix_count; i++) { + mask =3D 1 << (pix_count - 1 - i); + + if (!(s->image_bitmap_op & 0x20000000) || + (vram_bitmask & mask)) { + if (data & mask) { + artist_rop8(s, p + offset + i, s->fg_color); + } else { + if (!(s->image_bitmap_op & 0x10000002)) { + artist_rop8(s, p + offset + i, s->bg_color); + } + } + } + } + memory_region_set_dirty(&buf->mr, offset, pix_count); + break; + + default: + qemu_log_mask(LOG_UNIMP, "%s: unknown pixel length %d\n", + __func__, pix_length); + break; + } + + if (incr_x) { + if (s->cmap_bm_access) { + s->vram_pos +=3D 4; + } else { + s->vram_pos +=3D pix_count << 2; + } + } + + if (vram_write_bufidx(s) =3D=3D ARTIST_BUFFER_CURSOR1 || + vram_write_bufidx(s) =3D=3D ARTIST_BUFFER_CURSOR2) { + artist_invalidate_cursor(s); + } +} + +static void block_move(ARTISTState *s, int source_x, int source_y, int des= t_x, + int dest_y, int width, int height) +{ + struct vram_buffer *buf; + int line, endline, lineincr, startcolumn, endcolumn, columnincr, colum= n; + uint32_t dst, src; + + trace_artist_block_move(source_x, source_y, dest_x, dest_y, width, hei= ght); + + if (s->control_plane !=3D 0) { + /* We don't support CONTROL_PLANE accesses */ + qemu_log_mask(LOG_UNIMP, "%s: CONTROL_PLANE: %08x\n", __func__, + s->control_plane); + return; + } + + buf =3D &s->vram_buffer[ARTIST_BUFFER_AP]; + + if (dest_y > source_y) { + /* move down */ + line =3D height - 1; + endline =3D -1; + lineincr =3D -1; + } else { + /* move up */ + line =3D 0; + endline =3D height; + lineincr =3D 1; + } + + if (dest_x > source_x) { + /* move right */ + startcolumn =3D width - 1; + endcolumn =3D -1; + columnincr =3D -1; + } else { + /* move left */ + startcolumn =3D 0; + endcolumn =3D width; + columnincr =3D 1; + } + + for ( ; line !=3D endline; line +=3D lineincr) { + src =3D source_x + ((line + source_y) * buf->width); + dst =3D dest_x + ((line + dest_y) * buf->width); + + for (column =3D startcolumn; column !=3D endcolumn; column +=3D co= lumnincr) { + if (dst + column > buf->size || src + column > buf->size) { + continue; + } + artist_rop8(s, buf->data + dst + column, buf->data[src + colum= n]); + } + } + + artist_invalidate_lines(buf, dest_y, height); +} + +static void fill_window(ARTISTState *s, int startx, int starty, + int width, int height) +{ + uint32_t offset; + uint8_t color =3D artist_get_color(s); + struct vram_buffer *buf; + int x, y; + + trace_artist_fill_window(startx, starty, width, height, + s->image_bitmap_op, s->control_plane); + + if (s->control_plane !=3D 0) { + /* We don't support CONTROL_PLANE accesses */ + qemu_log_mask(LOG_UNIMP, "%s: CONTROL_PLANE: %08x\n", __func__, + s->control_plane); + return; + } + + if (s->reg_100080 =3D=3D 0x7d) { + /* + * Not sure what this register really does, but + * 0x7d seems to enable autoincremt of the Y axis + * by the current block move height. + */ + height =3D artist_get_y(s->blockmove_size); + s->vram_start +=3D height; + } + + buf =3D &s->vram_buffer[ARTIST_BUFFER_AP]; + + for (y =3D starty; y < starty + height; y++) { + offset =3D y * s->width; + + for (x =3D startx; x < startx + width; x++) { + artist_rop8(s, buf->data + offset + x, color); + } + } + artist_invalidate_lines(buf, starty, height); +} + +static void draw_line(ARTISTState *s, int x1, int y1, int x2, int y2, + bool update_start, int skip_pix, int max_pix) +{ + struct vram_buffer *buf; + uint8_t color =3D artist_get_color(s); + int dx, dy, t, e, x, y, incy, diago, horiz; + bool c1; + uint8_t *p; + + + if (update_start) { + s->vram_start =3D (x2 << 16) | y2; + } + + buf =3D &s->vram_buffer[ARTIST_BUFFER_AP]; + + c1 =3D false; + incy =3D 1; + + if (x2 > x1) { + dx =3D x2 - x1; + } else { + dx =3D x1 - x2; + } + if (y2 > y1) { + dy =3D y2 - y1; + } else { + dy =3D y1 - y2; + } + if (dy > dx) { + t =3D y2; + y2 =3D x2; + x2 =3D t; + + t =3D y1; + y1 =3D x1; + x1 =3D t; + + t =3D dx; + dx =3D dy; + dy =3D t; + + c1 =3D true; + } + + if (x1 > x2) { + t =3D y2; + y2 =3D y1; + y1 =3D t; + + t =3D x1; + x1 =3D x2; + x2 =3D t; + } + + horiz =3D dy << 1; + diago =3D (dy - dx) << 1; + e =3D (dy << 1) - dx; + + if (y1 <=3D y2) { + incy =3D 1; + } else { + incy =3D -1; + } + x =3D x1; + y =3D y1; + + do { + if (c1) { + p =3D buf->data + x * s->width + y; + } else { + p =3D buf->data + y * s->width + x; + } + + if (skip_pix > 0) { + skip_pix--; + } else { + artist_rop8(s, p, color); + } + + if (e > 0) { + artist_invalidate_lines(buf, y, 1); + y +=3D incy; + e +=3D diago; + } else { + e +=3D horiz; + } + x++; + } while (x <=3D x2 && (max_pix =3D=3D -1 || --max_pix > 0)); +} + +static void draw_line_pattern_start(ARTISTState *s) +{ + + int startx =3D artist_get_x(s->vram_start); + int starty =3D artist_get_y(s->vram_start); + int endx =3D artist_get_x(s->blockmove_size); + int endy =3D artist_get_y(s->blockmove_size); + int pstart =3D s->line_pattern_start >> 16; + + trace_artist_draw_line(startx, starty, endx, endy); + draw_line(s, startx, starty, endx, endy, false, -1, pstart); + s->line_pattern_skip =3D pstart; +} + +static void draw_line_pattern_next(ARTISTState *s) +{ + + int startx =3D artist_get_x(s->vram_start); + int starty =3D artist_get_y(s->vram_start); + int endx =3D artist_get_x(s->blockmove_size); + int endy =3D artist_get_y(s->blockmove_size); + int line_xy =3D s->line_xy >> 16; + + trace_artist_draw_line(startx, starty, endx, endy); + draw_line(s, startx, starty, endx, endy, false, s->line_pattern_skip, + s->line_pattern_skip + line_xy); + s->line_pattern_skip +=3D line_xy; + s->image_bitmap_op ^=3D 2; +} + +static void draw_line_size(ARTISTState *s, bool update_start) +{ + + int startx =3D artist_get_x(s->vram_start); + int starty =3D artist_get_y(s->vram_start); + int endx =3D artist_get_x(s->line_size); + int endy =3D artist_get_y(s->line_size); + + trace_artist_draw_line(startx, starty, endx, endy); + draw_line(s, startx, starty, endx, endy, update_start, -1, -1); +} + +static void draw_line_xy(ARTISTState *s, bool update_start) +{ + + int startx =3D artist_get_x(s->vram_start); + int starty =3D artist_get_y(s->vram_start); + int sizex =3D artist_get_x(s->blockmove_size); + int sizey =3D artist_get_y(s->blockmove_size); + int linexy =3D s->line_xy >> 16; + int endx, endy; + + endx =3D startx; + endy =3D starty; + + if (sizex > 0) { + endx =3D startx + linexy; + } + + if (sizex < 0) { + endx =3D startx; + startx -=3D linexy; + } + + if (sizey > 0) { + endy =3D starty + linexy; + } + + if (sizey < 0) { + endy =3D starty; + starty -=3D linexy; + } + + if (startx < 0) { + startx =3D 0; + } + + if (endx < 0) { + endx =3D 0; + } + + if (starty < 0) { + starty =3D 0; + } + + if (endy < 0) { + endy =3D 0; + } + + + if (endx < 0) { + return; + } + + if (endy < 0) { + return; + } + + trace_artist_draw_line(startx, starty, endx, endy); + draw_line(s, startx, starty, endx, endy, false, -1, -1); +} + +static void draw_line_end(ARTISTState *s, bool update_start) +{ + + int startx =3D artist_get_x(s->vram_start); + int starty =3D artist_get_y(s->vram_start); + int endx =3D artist_get_x(s->line_end); + int endy =3D artist_get_y(s->line_end); + + trace_artist_draw_line(startx, starty, endx, endy); + draw_line(s, startx, starty, endx, endy, update_start, -1, -1); +} + +static void font_write16(ARTISTState *s, uint16_t val) +{ + struct vram_buffer *buf; + uint32_t color =3D (s->image_bitmap_op & 2) ? s->fg_color : s->bg_colo= r; + uint16_t mask; + int i; + + int startx =3D artist_get_x(s->vram_start); + int starty =3D artist_get_y(s->vram_start) + s->font_write_pos_y; + int offset =3D starty * s->width + startx; + + buf =3D &s->vram_buffer[ARTIST_BUFFER_AP]; + + if (offset + 16 > buf->size) { + return; + } + + for (i =3D 0; i < 16; i++) { + mask =3D 1 << (15 - i); + if (val & mask) { + artist_rop8(s, buf->data + offset + i, color); + } else { + if (!(s->image_bitmap_op & 0x20000000)) { + artist_rop8(s, buf->data + offset + i, s->bg_color); + } + } + } + artist_invalidate_lines(buf, starty, 1); +} + +static void font_write(ARTISTState *s, uint32_t val) +{ + font_write16(s, val >> 16); + if (++s->font_write_pos_y =3D=3D artist_get_y(s->blockmove_size)) { + s->vram_start +=3D (s->blockmove_size & 0xffff0000); + return; + } + + font_write16(s, val & 0xffff); + if (++s->font_write_pos_y =3D=3D artist_get_y(s->blockmove_size)) { + s->vram_start +=3D (s->blockmove_size & 0xffff0000); + return; + } +} + +static void combine_write_reg(hwaddr addr, uint64_t val, int size, void *o= ut) +{ + /* + * FIXME: is there a qemu helper for this? + */ + +#ifndef HOST_WORDS_BIGENDIAN + addr ^=3D 3; +#endif + + switch (size) { + case 1: + *(uint8_t *)(out + (addr & 3)) =3D val; + break; + + case 2: + *(uint16_t *)(out + (addr & 2)) =3D val; + break; + + case 4: + *(uint32_t *)out =3D val; + break; + + default: + qemu_log_mask(LOG_UNIMP, "unsupported write size: %d\n", size); + } +} + +static void artist_reg_write(void *opaque, hwaddr addr, uint64_t val, + unsigned size) +{ + ARTISTState *s =3D opaque; + int posx, posy; + int width, height; + + trace_artist_reg_write(size, addr, artist_reg_name(addr & ~3ULL), val); + + switch (addr & ~3ULL) { + case 0x100080: + combine_write_reg(addr, val, size, &s->reg_100080); + break; + + case FG_COLOR: + combine_write_reg(addr, val, size, &s->fg_color); + break; + + case BG_COLOR: + combine_write_reg(addr, val, size, &s->bg_color); + break; + + case VRAM_BITMASK: + combine_write_reg(addr, val, size, &s->vram_bitmask); + break; + + case VRAM_WRITE_INCR_Y: + posx =3D (s->vram_pos >> 2) & 0x7ff; + posy =3D (s->vram_pos >> 13) & 0x3ff; + vram_bit_write(s, posx, posy + s->vram_char_y++, false, size, val); + break; + + case VRAM_WRITE_INCR_X: + case VRAM_WRITE_INCR_X2: + posx =3D (s->vram_pos >> 2) & 0x7ff; + posy =3D (s->vram_pos >> 13) & 0x3ff; + vram_bit_write(s, posx, posy + s->vram_char_y, true, size, val); + break; + + case VRAM_IDX: + combine_write_reg(addr, val, size, &s->vram_pos); + s->vram_char_y =3D 0; + s->draw_line_pattern =3D 0; + break; + + case VRAM_START: + combine_write_reg(addr, val, size, &s->vram_start); + s->draw_line_pattern =3D 0; + break; + + case VRAM_START_TRIGGER: + combine_write_reg(addr, val, size, &s->vram_start); + fill_window(s, artist_get_x(s->vram_start), + artist_get_y(s->vram_start), + artist_get_x(s->blockmove_size), + artist_get_y(s->blockmove_size)); + break; + + case VRAM_SIZE_TRIGGER: + combine_write_reg(addr, val, size, &s->vram_size); + + if (size =3D=3D 2 && !(addr & 2)) { + height =3D artist_get_y(s->blockmove_size); + } else { + height =3D artist_get_y(s->vram_size); + } + + if (size =3D=3D 2 && (addr & 2)) { + width =3D artist_get_x(s->blockmove_size); + } else { + width =3D artist_get_x(s->vram_size); + } + + fill_window(s, artist_get_x(s->vram_start), + artist_get_y(s->vram_start), + width, height); + break; + + case LINE_XY: + combine_write_reg(addr, val, size, &s->line_xy); + if (s->draw_line_pattern) { + draw_line_pattern_next(s); + } else { + draw_line_xy(s, true); + } + break; + + case PATTERN_LINE_START: + combine_write_reg(addr, val, size, &s->line_pattern_start); + s->draw_line_pattern =3D 1; + draw_line_pattern_start(s); + break; + + case LINE_SIZE: + combine_write_reg(addr, val, size, &s->line_size); + draw_line_size(s, true); + break; + + case LINE_END: + combine_write_reg(addr, val, size, &s->line_end); + draw_line_end(s, true); + break; + + case BLOCK_MOVE_SIZE: + combine_write_reg(addr, val, size, &s->blockmove_size); + break; + + case BLOCK_MOVE_SOURCE: + combine_write_reg(addr, val, size, &s->blockmove_source); + break; + + case BLOCK_MOVE_DEST_TRIGGER: + combine_write_reg(addr, val, size, &s->blockmove_dest); + + block_move(s, artist_get_x(s->blockmove_source), + artist_get_y(s->blockmove_source), + artist_get_x(s->blockmove_dest), + artist_get_y(s->blockmove_dest), + artist_get_x(s->blockmove_size), + artist_get_y(s->blockmove_size)); + break; + + case BLOCK_MOVE_SIZE_TRIGGER: + combine_write_reg(addr, val, size, &s->blockmove_size); + + block_move(s, + artist_get_x(s->blockmove_source), + artist_get_y(s->blockmove_source), + artist_get_x(s->vram_start), + artist_get_y(s->vram_start), + artist_get_x(s->blockmove_size), + artist_get_y(s->blockmove_size)); + break; + + case PLANE_MASK: + combine_write_reg(addr, val, size, &s->plane_mask); + break; + + case CMAP_BM_ACCESS: + combine_write_reg(addr, val, size, &s->cmap_bm_access); + break; + + case DST_BM_ACCESS: + combine_write_reg(addr, val, size, &s->dst_bm_access); + s->cmap_bm_access =3D 0; + break; + + case SRC_BM_ACCESS: + combine_write_reg(addr, val, size, &s->src_bm_access); + s->cmap_bm_access =3D 0; + break; + + case CONTROL_PLANE: + combine_write_reg(addr, val, size, &s->control_plane); + break; + + case TRANSFER_DATA: + combine_write_reg(addr, val, size, &s->transfer_data); + break; + + case 0x300200: + combine_write_reg(addr, val, size, &s->reg_300200); + break; + + case 0x300208: + combine_write_reg(addr, val, size, &s->reg_300208); + break; + + case 0x300218: + combine_write_reg(addr, val, size, &s->reg_300218); + break; + + case CURSOR_POS: + artist_invalidate_cursor(s); + combine_write_reg(addr, val, size, &s->cursor_pos); + artist_invalidate_cursor(s); + break; + + case CURSOR_CTRL: + break; + + case IMAGE_BITMAP_OP: + combine_write_reg(addr, val, size, &s->image_bitmap_op); + break; + + case FONT_WRITE_INCR_Y: + combine_write_reg(addr, val, size, &s->font_write1); + font_write(s, s->font_write1); + break; + + case FONT_WRITE_START: + combine_write_reg(addr, val, size, &s->font_write2); + s->font_write_pos_y =3D 0; + font_write(s, s->font_write2); + break; + + case 300104: + break; + + default: + qemu_log_mask(LOG_UNIMP, "%s: unknown register: reg=3D%08lx val=3D= %08lx" + " size=3D%d\n", __func__, addr, val, size); + break; + } +} + +static uint64_t combine_read_reg(hwaddr addr, int size, void *in) +{ + /* + * FIXME: is there a qemu helper for this? + */ + +#ifndef HOST_WORDS_BIGENDIAN + addr ^=3D 3; +#endif + + switch (size) { + case 1: + return *(uint8_t *)(in + (addr & 3)); + + case 2: + return *(uint16_t *)(in + (addr & 2)); + + case 4: + return *(uint32_t *)in; + + default: + qemu_log_mask(LOG_UNIMP, "unsupported read size: %d\n", size); + return 0; + } +} + +static uint64_t artist_reg_read(void *opaque, hwaddr addr, unsigned size) +{ + ARTISTState *s =3D opaque; + uint32_t val =3D 0; + + switch (addr & ~3ULL) { + /* Unknown status registers */ + case 0: + break; + + case 0x211110: + val =3D (s->width << 16) | s->height; + if (s->depth =3D=3D 1) { + val |=3D 1 << 31; + } + break; + + case 0x100000: + case 0x300000: + case 0x300004: + case 0x300308: + case 0x380000: + break; + + case 0x300008: + case 0x380008: + /* + * FIFO ready flag. we're not emulating the FIFOs + * so we're always ready + */ + val =3D 0x10; + break; + + case 0x300200: + val =3D s->reg_300200; + break; + + case 0x300208: + val =3D s->reg_300208; + break; + + case 0x300218: + val =3D s->reg_300218; + break; + + case 0x30023c: + val =3D 0xac4ffdac; + break; + + case 0x380004: + /* 0x02000000 Buserror */ + val =3D 0x6dc20006; + break; + + default: + qemu_log("%s: unknown register: %08lx size %d\n", __func__, addr, = size); + } + val =3D combine_read_reg(addr, size, &val); + trace_artist_reg_read(size, addr, artist_reg_name(addr & ~3ULL), val); + return val; +} + +static void artist_vram_write(void *opaque, hwaddr addr, uint64_t val, + unsigned size) +{ + ARTISTState *s =3D opaque; + struct vram_buffer *buf; + int posy =3D (addr >> 11) & 0x3ff; + int posx =3D addr & 0x7ff; + uint32_t offset; + trace_artist_vram_write(size, addr, val); + + if (s->cmap_bm_access) { + buf =3D &s->vram_buffer[ARTIST_BUFFER_CMAP]; + if (addr + 3 < buf->size) { + *(uint32_t *)(buf->data + addr) =3D val; + } + return; + } + + buf =3D vram_write_buffer(s); + if (!buf->size) { + return; + } + + if (posy > buf->height || posx > buf->width) { + return; + } + + offset =3D posy * buf->width + posx; + switch (size) { + case 4: + *(uint32_t *)(buf->data + offset) =3D be32_to_cpu(val); + memory_region_set_dirty(&buf->mr, offset, 4); + break; + case 2: + *(uint16_t *)(buf->data + offset) =3D be16_to_cpu(val); + memory_region_set_dirty(&buf->mr, offset, 2); + break; + case 1: + *(uint8_t *)(buf->data + offset) =3D val; + memory_region_set_dirty(&buf->mr, offset, 1); + break; + default: + break; + } +} + +static uint64_t artist_vram_read(void *opaque, hwaddr addr, unsigned size) +{ + ARTISTState *s =3D opaque; + struct vram_buffer *buf; + uint64_t val; + int posy, posx; + + if (s->cmap_bm_access) { + buf =3D &s->vram_buffer[ARTIST_BUFFER_CMAP]; + val =3D *(uint32_t *)(buf->data + addr); + trace_artist_vram_read(size, addr, 0, 0, val); + return 0; + } + + buf =3D vram_read_buffer(s); + if (!buf->size) { + return 0; + } + + posy =3D (addr >> 13) & 0x3ff; + posx =3D (addr >> 2) & 0x7ff; + + if (posy > buf->height || posx > buf->width) { + return 0; + } + + val =3D cpu_to_be32(*(uint32_t *)(buf->data + posy * buf->width + posx= )); + trace_artist_vram_read(size, addr, posx, posy, val); + return val; +} + +static const MemoryRegionOps artist_reg_ops =3D { + .read =3D artist_reg_read, + .write =3D artist_reg_write, + .endianness =3D DEVICE_NATIVE_ENDIAN, + .valid =3D { + .min_access_size =3D 1, + .max_access_size =3D 4, + }, +}; + +static const MemoryRegionOps artist_vram_ops =3D { + .read =3D artist_vram_read, + .write =3D artist_vram_write, + .endianness =3D DEVICE_NATIVE_ENDIAN, + .valid =3D { + .min_access_size =3D 1, + .max_access_size =3D 4, + }, +}; + +static void artist_draw_cursor(ARTISTState *s) +{ + DisplaySurface *surface =3D qemu_console_surface(s->con); + uint32_t *data =3D (uint32_t *)surface_data(surface); + struct vram_buffer *cursor0, *cursor1 , *buf; + int cx, cy, cursor_pos_x, cursor_pos_y; + + cursor0 =3D &s->vram_buffer[ARTIST_BUFFER_CURSOR1]; + cursor1 =3D &s->vram_buffer[ARTIST_BUFFER_CURSOR2]; + buf =3D &s->vram_buffer[ARTIST_BUFFER_AP]; + + artist_get_cursor_pos(s, &cursor_pos_x, &cursor_pos_y); + + for (cy =3D 0; cy < s->cursor_height; cy++) { + + for (cx =3D 0; cx < s->cursor_width; cx++) { + + if (cursor_pos_y + cy < 0 || + cursor_pos_x + cx < 0 || + cursor_pos_y + cy > buf->height - 1 || + cursor_pos_x + cx > buf->width) { + continue; + } + + int dstoffset =3D (cursor_pos_y + cy) * s->width + + (cursor_pos_x + cx); + + if (cursor0->data[cy * cursor0->width + cx]) { + data[dstoffset] =3D 0; + } else { + if (cursor1->data[cy * cursor1->width + cx]) { + data[dstoffset] =3D 0xffffff; + } + } + } + } +} + +static void artist_draw_line(void *opaque, uint8_t *d, const uint8_t *src, + int width, int pitch) +{ + ARTISTState *s =3D ARTIST(opaque); + uint32_t *cmap, *data =3D (uint32_t *)d; + int x; + + cmap =3D (uint32_t *)(s->vram_buffer[ARTIST_BUFFER_CMAP].data + 0x400); + + for (x =3D 0; x < s->width; x++) { + *data++ =3D cmap[*src++]; + } +} + +static void artist_update_display(void *opaque) +{ + ARTISTState *s =3D opaque; + DisplaySurface *surface =3D qemu_console_surface(s->con); + int first =3D 0, last; + + + framebuffer_update_display(surface, &s->fbsection, s->width, s->height, + s->width, s->width * 4, 0, 0, artist_draw_l= ine, + s, &first, &last); + + artist_draw_cursor(s); + + dpy_gfx_update(s->con, 0, 0, s->width, s->height); +} + +static void artist_invalidate(void *opaque) +{ + ARTISTState *s =3D ARTIST(opaque); + struct vram_buffer *buf =3D &s->vram_buffer[ARTIST_BUFFER_AP]; + memory_region_set_dirty(&buf->mr, 0, buf->size); +} + +static const GraphicHwOps artist_ops =3D { + .invalidate =3D artist_invalidate, + .gfx_update =3D artist_update_display, +}; + +static void artist_initfn(Object *obj) +{ + SysBusDevice *sbd =3D SYS_BUS_DEVICE(obj); + ARTISTState *s =3D ARTIST(obj); + + memory_region_init_io(&s->reg, obj, &artist_reg_ops, s, "artist.reg", + 4 * MiB); + memory_region_init_io(&s->vram_mem, obj, &artist_vram_ops, s, "artist.= vram", + 8 * MiB); + sysbus_init_mmio(sbd, &s->reg); + sysbus_init_mmio(sbd, &s->vram_mem); +} + +static void artist_create_buffer(ARTISTState *s, const char *name, + hwaddr *offset, unsigned int idx, + int width, int height) +{ + struct vram_buffer *buf =3D s->vram_buffer + idx; + + memory_region_init_ram(&buf->mr, NULL, name, width * height, + &error_fatal); + memory_region_add_subregion_overlap(&s->mem_as_root, *offset, &buf->mr= , 0); + + buf->data =3D memory_region_get_ram_ptr(&buf->mr); + buf->size =3D height * width; + buf->width =3D width; + buf->height =3D height; + + *offset +=3D buf->size; +} + +static void artist_realizefn(DeviceState *dev, Error **errp) +{ + ARTISTState *s =3D ARTIST(dev); + struct vram_buffer *buf; + hwaddr offset =3D 0; + + memory_region_init(&s->mem_as_root, OBJECT(dev), "artist", ~0ull); + address_space_init(&s->as, &s->mem_as_root, "artist"); + + artist_create_buffer(s, "cmap", &offset, ARTIST_BUFFER_CMAP, 2048, 4); + artist_create_buffer(s, "ap", &offset, ARTIST_BUFFER_AP, + s->width, s->height); + artist_create_buffer(s, "cursor1", &offset, ARTIST_BUFFER_CURSOR1, 64,= 64); + artist_create_buffer(s, "cursor2", &offset, ARTIST_BUFFER_CURSOR2, 64,= 64); + artist_create_buffer(s, "attribute", &offset, ARTIST_BUFFER_ATTRIBUTE, + 64, 64); + + buf =3D &s->vram_buffer[ARTIST_BUFFER_AP]; + framebuffer_update_memory_section(&s->fbsection, &buf->mr, 0, + buf->width, buf->height); + /* + * no idea whether the cursor is fixed size or not, so assume 32x32 wh= ich + * seems sufficient for HP-UX X11. + */ + s->cursor_height =3D 32; + s->cursor_width =3D 32; + + s->con =3D graphic_console_init(DEVICE(dev), 0, &artist_ops, s); + qemu_console_resize(s->con, s->width, s->height); +} + +static int vmstate_artist_post_load(void *opaque, int version_id) +{ + artist_invalidate(opaque); + return 0; +} + +static const VMStateDescription vmstate_artist =3D { + .name =3D "artist", + .version_id =3D 1, + .minimum_version_id =3D 1, + .post_load =3D vmstate_artist_post_load, + .fields =3D (VMStateField[]) { + VMSTATE_UINT16(height, ARTISTState), + VMSTATE_UINT16(width, ARTISTState), + VMSTATE_UINT16(depth, ARTISTState), + VMSTATE_UINT32(fg_color, ARTISTState), + VMSTATE_UINT32(bg_color, ARTISTState), + VMSTATE_UINT32(vram_char_y, ARTISTState), + VMSTATE_UINT32(vram_bitmask, ARTISTState), + VMSTATE_UINT32(vram_start, ARTISTState), + VMSTATE_UINT32(vram_pos, ARTISTState), + VMSTATE_UINT32(vram_size, ARTISTState), + VMSTATE_UINT32(blockmove_source, ARTISTState), + VMSTATE_UINT32(blockmove_dest, ARTISTState), + VMSTATE_UINT32(blockmove_size, ARTISTState), + VMSTATE_UINT32(line_size, ARTISTState), + VMSTATE_UINT32(line_end, ARTISTState), + VMSTATE_UINT32(line_xy, ARTISTState), + VMSTATE_UINT32(cursor_pos, ARTISTState), + VMSTATE_UINT32(cursor_height, ARTISTState), + VMSTATE_UINT32(cursor_width, ARTISTState), + VMSTATE_UINT32(plane_mask, ARTISTState), + VMSTATE_UINT32(reg_100080, ARTISTState), + VMSTATE_UINT32(reg_300200, ARTISTState), + VMSTATE_UINT32(reg_300208, ARTISTState), + VMSTATE_UINT32(reg_300218, ARTISTState), + VMSTATE_UINT32(cmap_bm_access, ARTISTState), + VMSTATE_UINT32(dst_bm_access, ARTISTState), + VMSTATE_UINT32(src_bm_access, ARTISTState), + VMSTATE_UINT32(control_plane, ARTISTState), + VMSTATE_UINT32(transfer_data, ARTISTState), + VMSTATE_UINT32(image_bitmap_op, ARTISTState), + VMSTATE_UINT32(font_write1, ARTISTState), + VMSTATE_UINT32(font_write2, ARTISTState), + VMSTATE_UINT32(font_write_pos_y, ARTISTState), + VMSTATE_END_OF_LIST() + } +}; + +static Property artist_properties[] =3D { + DEFINE_PROP_UINT16("width", ARTISTState, width, 1280), + DEFINE_PROP_UINT16("height", ARTISTState, height, 1024), + DEFINE_PROP_UINT16("depth", ARTISTState, depth, 8), + DEFINE_PROP_END_OF_LIST(), +}; + +static void artist_reset(DeviceState *qdev) +{ +} + +static void artist_class_init(ObjectClass *klass, void *data) +{ + DeviceClass *dc =3D DEVICE_CLASS(klass); + + dc->realize =3D artist_realizefn; + dc->vmsd =3D &vmstate_artist; + dc->props =3D artist_properties; + dc->reset =3D artist_reset; +} + +static const TypeInfo artist_info =3D { + .name =3D TYPE_ARTIST, + .parent =3D TYPE_SYS_BUS_DEVICE, + .instance_size =3D sizeof(ARTISTState), + .instance_init =3D artist_initfn, + .class_init =3D artist_class_init, +}; + +static void artist_register_types(void) +{ + type_register_static(&artist_info); +} + +type_init(artist_register_types) diff --git a/hw/hppa/machine.c b/hw/hppa/machine.c index c8b1830f88..a35527cfc7 100644 --- a/hw/hppa/machine.c +++ b/hw/hppa/machine.c @@ -75,6 +75,7 @@ static void machine_hppa_init(MachineState *machine) MemoryRegion *cpu_region; long i; unsigned int smp_cpus =3D machine->smp.cpus; + SysBusDevice *s; =20 ram_size =3D machine->ram_size; =20 @@ -127,6 +128,15 @@ static void machine_hppa_init(MachineState *machine) dev =3D DEVICE(pci_create_simple(pci_bus, -1, "lsi53c895a")); lsi53c8xx_handle_legacy_cmdline(dev); =20 + /* Graphics setup. */ + if (machine->enable_graphics && vga_interface_type !=3D VGA_NONE) { + dev =3D qdev_create(NULL, "artist"); + qdev_init_nofail(dev); + s =3D SYS_BUS_DEVICE(dev); + sysbus_mmio_map(s, 0, LASI_GFX_HPA); + sysbus_mmio_map(s, 1, ARTIST_FB_ADDR); + } + /* Network setup. */ for (i =3D 0; i < nb_nics; i++) { if (!enable_lasi_lan()) { diff --git a/hw/display/Kconfig b/hw/display/Kconfig index c500d1fc6d..15d59e10dc 100644 --- a/hw/display/Kconfig +++ b/hw/display/Kconfig @@ -91,6 +91,10 @@ config TCX config CG3 bool =20 +config ARTIST + bool + select FRAMEBUFFER + config VGA bool =20 diff --git a/hw/display/Makefile.objs b/hw/display/Makefile.objs index f2182e3bef..5f03dfdcc4 100644 --- a/hw/display/Makefile.objs +++ b/hw/display/Makefile.objs @@ -40,6 +40,7 @@ common-obj-$(CONFIG_SM501) +=3D sm501.o common-obj-$(CONFIG_TCX) +=3D tcx.o common-obj-$(CONFIG_CG3) +=3D cg3.o common-obj-$(CONFIG_NEXTCUBE) +=3D next-fb.o +common-obj-$(CONFIG_ARTIST) +=3D artist.o =20 obj-$(CONFIG_VGA) +=3D vga.o =20 diff --git a/hw/display/trace-events b/hw/display/trace-events index ba7787b180..e6e22bef88 100644 --- a/hw/display/trace-events +++ b/hw/display/trace-events @@ -142,3 +142,12 @@ sii9022_switch_mode(const char *mode) "mode: %s" # ati.c ati_mm_read(unsigned int size, uint64_t addr, const char *name, uint64_t v= al) "%u 0x%"PRIx64 " %s -> 0x%"PRIx64 ati_mm_write(unsigned int size, uint64_t addr, const char *name, uint64_t = val) "%u 0x%"PRIx64 " %s <- 0x%"PRIx64 + +# artist.c +artist_reg_read(unsigned int size, uint64_t addr, const char *name, uint64= _t val) "%u 0x%"PRIx64 "%s -> 0x%"PRIx64 +artist_reg_write(unsigned int size, uint64_t addr, const char *name, uint6= 4_t val) "%u 0x%"PRIx64 "%s <- 0x%"PRIx64 +artist_vram_read(unsigned int size, uint64_t addr, int posx, int posy, uin= t64_t val) "%u 0x%"PRIx64 " %ux%u-> 0x%"PRIx64 +artist_vram_write(unsigned int size, uint64_t addr, uint64_t val) "%u 0x%"= PRIx64 " <- 0x%"PRIx64 +artist_fill_window(unsigned int start_x, unsigned int start_y, unsigned in= t width, unsigned int height, uint32_t op, uint32_t ctlpln) "start=3D%ux%u = length=3D%ux%u op=3D0x%08x ctlpln=3D0x%08x" +artist_block_move(unsigned int start_x, unsigned int start_y, unsigned int= dest_x, unsigned int dest_y, unsigned int width, unsigned int height) "sou= rce %ux%u -> dest %ux%u size %ux%u" +artist_draw_line(unsigned int start_x, unsigned int start_y, unsigned int = end_x, unsigned int end_y) "%ux%u %ux%u" diff --git a/hw/hppa/Kconfig b/hw/hppa/Kconfig index 7f9be7f25c..82178c7dcb 100644 --- a/hw/hppa/Kconfig +++ b/hw/hppa/Kconfig @@ -12,3 +12,4 @@ config DINO select LSI_SCSI_PCI select LASI_82596 select LASIPS2 + select ARTIST --=20 2.20.1