interplane.Get Omega
Read in your language

aienux

Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately.

Brought by drakestapleton

branch main Branches Tags History

aienux / native / kernel / dev / virtio_gpu.h

55 lines · 2953 bytes Raw Blame History
1/* virtio_gpu.h -- the virtio-gpu 2D screen (virtio 1.x section 5.7), polled,
2 * for the boot sequence in a VM (QEMU virtio-gpu-pci / virtio-vga, the
3 * aienos-run window). One resource the size of scanout 0, backed by guest
4 * memory the caller draws into; a frame is shown with TRANSFER_TO_HOST_2D
5 * and RESOURCE_FLUSH. Command layouts follow the virtio spec (checked
6 * against the Linux UAPI copy, linux/virtio_gpu.h, in the host test).
7 * The command builders are pure (host tested in dev/tests/virtio_gpu_test.c);
8 * the device goes through virtio_q.h. */
9#ifndef AIENOS_CK_VIRTIO_GPU_H
10#define AIENOS_CK_VIRTIO_GPU_H
11#include <stddef.h>
12#include <stdint.h>
13#include "virtio_q.h"
14
15#define VGPU_CMD_GET_DISPLAY_INFO 0x0100u
16#define VGPU_CMD_RESOURCE_CREATE_2D 0x0101u
17#define VGPU_CMD_SET_SCANOUT 0x0103u
18#define VGPU_CMD_RESOURCE_FLUSH 0x0104u
19#define VGPU_CMD_TRANSFER_TO_HOST_2D 0x0105u
20#define VGPU_CMD_RESOURCE_ATTACH_BACKING 0x0106u
21#define VGPU_RESP_OK_NODATA 0x1100u
22#define VGPU_RESP_OK_DISPLAY_INFO 0x1101u
23#define VGPU_FORMAT_B8G8R8X8_UNORM 2u /* bytes B, G, R, X: the GOP BGRX format 1 */
24#define VGPU_MAX_SCANOUTS 16u
25#define VGPU_HDR_BYTES 24u
26#define VGPU_DISPLAY_INFO_BYTES (VGPU_HDR_BYTES + VGPU_MAX_SCANOUTS * 24u)
27#define VGPU_RESOURCE 1u
28
29/* Command builders: write the command into out (cap bytes) and return its
30 * length, 0 if cap is short. All fields little-endian. */
31size_t vgpu_cmd_display_info(uint8_t *out, size_t cap);
32size_t vgpu_cmd_create_2d(uint8_t *out, size_t cap, uint32_t res, uint32_t fmt, uint32_t w, uint32_t h);
33size_t vgpu_cmd_attach_backing(uint8_t *out, size_t cap, uint32_t res, uint64_t addr, uint32_t len);
34size_t vgpu_cmd_set_scanout(uint8_t *out, size_t cap, uint32_t scanout, uint32_t res, uint32_t w, uint32_t h);
35size_t vgpu_cmd_transfer_2d(uint8_t *out, size_t cap, uint32_t res, uint32_t x, uint32_t y, uint32_t w, uint32_t h,
36 uint64_t offset);
37size_t vgpu_cmd_flush(uint8_t *out, size_t cap, uint32_t res, uint32_t x, uint32_t y, uint32_t w, uint32_t h);
38/* The response type of a reply (0 if short). */
39uint32_t vgpu_resp_type(const uint8_t *resp, size_t len);
40/* Scanout 0's size from a display-info reply; 0 if the reply is not one or
41 * scanout 0 is disabled or empty. */
42int vgpu_display0(const uint8_t *resp, size_t len, uint32_t *w, uint32_t *h);
43
44#ifndef CK_HOSTED
45#include "pci.h"
46/* Kernel side (dev/virtio_gpu_bind.c). Finds a virtio-gpu PCI function,
47 * confines its DMA, brings it up and makes a w x h BGRX screen whose pixels
48 * are *fb (pitch = w). 0 and a line "virtio_gpu: ..." on success; < 0 with a
49 * line saying why not. At most max_w x max_h (the drawing memory budget). */
50int ck_vgpu_open(const pci_system *pci, uint32_t max_w, uint32_t max_h, volatile uint32_t **fb,
51 uint32_t *w, uint32_t *h);
52/* Shows the whole picture (transfer + flush); the boot show's present hook. */
53void ck_vgpu_present(void *ctx);
54#endif
55#endif