Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,11 @@ agency/rootfs/target/**


# except the followings:
!.gitignore #Don't ignore the ignore file ;-)
!.github
!*.tmpl #TaMPLate files for the man documentation
#Don't ignore the ignore file ;-)
!.gitignore
!.github
#TaMPLate files for the man documentation
!*.tmpl
!.clang-format
!buildroot/**
!buildroot/docs/manual/*.mk
Expand Down
46 changes: 46 additions & 0 deletions so3/arch/arm64/rpi4_64/include/mach/ipamap.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,52 @@ ipamap_t agency_ipamap[] = {
.size = 0x04000000,
},

/* VC memory*/
{
.ipa_addr = 0x3ea00000,
.phys_addr = 0x3ea00000,
.size = 0x600000,
},

/* HDMI 0 memory spaces */
{
.ipa_addr = 0x7ef00000,
.phys_addr = 0x7ef00000,
.size = 0x3000,
},
{
.ipa_addr = 0x7ef04000,
.phys_addr = 0x7ef04000,
.size = 0x1000,
},
{
.ipa_addr = 0x7ef20000,
.phys_addr = 0x7ef20000,
.size = 0x1000,
},
{
.ipa_addr = 0x7e206000,
.phys_addr = 0x7e206000,
.size = 0x1000,
},
{
.ipa_addr = 0xf0000000,
.phys_addr = 0xf0000000,
.size = 0x10000000,
},

/* PCI */
{
.ipa_addr = 0x7d500000,
.phys_addr = 0x7d500000,
.size = 0x10000,
},
{
.ipa_addr = 0x600000000,
.phys_addr = 0x600000000,
.size = 0x40000000,
},

/* Null pointer exception */
{
.ipa_addr = 0x0,
Expand Down
3 changes: 2 additions & 1 deletion so3/configs/virt64_capsule_defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ CONFIG_IO_MAPPING_BASE=0xffff900000000000
# CONFIG_I2C is not set
# CONFIG_NET is not set
# CONFIG_FB is not set
# CONFIG_INPUT is not set
CONFIG_INPUT=y
# CONFIG_NS16550 is not set
CONFIG_UART_LL_PADDR=0x09000000
CONFIG_SOO_SERIAL=y
Expand Down Expand Up @@ -105,3 +105,4 @@ CONFIG_VUART_FRONTEND=y
# CONFIG_VSENSEJ_FRONTEND is not set
CONFIG_VLOGS_FRONTEND=y
CONFIG_VFBDEV_FRONTEND=y
CONFIG_VINPUT_FRONTEND=y
7 changes: 6 additions & 1 deletion so3/devices/fb/pl111.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@

#define HRES 1024
#define VRES 768
#define BPP 32 /* assume 32bpp */

/* Register address offsets */
#define CLCD_TIM0 0x000
Expand Down Expand Up @@ -120,8 +121,12 @@ int fb_ioctl(int fd, unsigned long cmd, unsigned long args)
*((uint32_t *) args) = VRES;
return 0;

case IOCTL_FB_BPP:
*((uint32_t *) args) = BPP;
return 0;

case IOCTL_FB_SIZE:
*((uint32_t *) args) = HRES * VRES * 4; /* assume 24bpp */
*((uint32_t *) args) = HRES * VRES * BPP / 8;
return 0;

default:
Expand Down
4 changes: 4 additions & 0 deletions so3/devices/fb/ramfb.c
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,10 @@ int fb_ioctl(int fd, unsigned long cmd, unsigned long args)
*((uint32_t *) args) = RAMFB_DRIVER_VIDEO_HEIGHT;
return 0;

case IOCTL_FB_BPP:
*((uint32_t *) args) = __fbi->mode.bpp;
return 0;

case IOCTL_FB_SIZE:
*((uint32_t *) args) =
RAMFB_DRIVER_VIDEO_HEIGHT * RAMFB_DRIVER_VIDEO_WIDTH * __fbi->mode.bpp / 8; /* assume 32bpp */
Expand Down
8 changes: 7 additions & 1 deletion so3/devices/fb/virtfb.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@

#include <device/driver.h>

#define BPP 32 /* assume 32bpp */

typedef struct {
void *vaddr;
uint32_t hres, vres;
Expand All @@ -48,7 +50,11 @@ static int fb_ioctl(int fd, unsigned long cmd, unsigned long args)
return 0;

case IOCTL_FB_SIZE:
*((uint32_t *) args) = priv->hres * priv->vres * 4; /* assume 24bpp */
*((uint32_t *) args) = priv->hres * priv->vres * BPP / 8;
return 0;

case IOCTL_FB_BPP:
*((uint32_t *) args) = BPP;
return 0;

case IOCTL_FB_IS_REAL:
Expand Down
32 changes: 17 additions & 15 deletions so3/devices/input/soo_kbd.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,15 @@

#include <uapi/linux/input-event-codes.h>

#include <soo/dev/vinput.h>

/* Value of the last pressed key. */
struct ps2_key last_key = { .value = 0, .state = 0 };

/* ioctl commands. */

#define GET_KEY 0
int ioctl_keyboard(int fd, unsigned long cmd, unsigned long args);
static int ioctl_keyboard(int fd, unsigned long cmd, unsigned long args);

/* Device info. */

Expand Down Expand Up @@ -97,24 +99,24 @@ void soo_input_event(unsigned int type, unsigned int code, int value)
return;
}

/*
* Ignore "key released" events. A key is released in the ioctl so the
* client can read it.
*/
if (!value) {
return;
}

if (last_key.state & KEY_ST_SHIFT) {
last_key.value = s_eta[code];
if (code <= sizeof(s_eta)) {
last_key.value = s_eta[code];
}
} else {
last_key.value = eta[code];
if (code <= sizeof(eta)) {
last_key.value = eta[code];
}
}

last_key.state |= KEY_ST_PRESSED;
if (value == 1) {
last_key.state |= KEY_ST_PRESSED;
} else if (value == 0) {
last_key.state &= ~KEY_ST_PRESSED;
}
}

int ioctl_keyboard(int fd, unsigned long cmd, unsigned long args)
static int ioctl_keyboard(int fd, unsigned long cmd, unsigned long args)
{
switch (cmd) {
case GET_KEY:
Expand All @@ -131,11 +133,11 @@ int ioctl_keyboard(int fd, unsigned long cmd, unsigned long args)
return 0;
}

int init_keyboard(dev_t *dev)
static int init_keyboard(dev_t *dev, int fdt_offset)
{
/* Register the input device so it can be accessed from user space. */
devclass_register(dev, &vkbd_cdev);
return 0;
}

REGISTER_DRIVER_POSTCORE("keyboard,soo_input", init_keyboard);
REGISTER_DRIVER_POSTCORE("soo-input,keyboard", init_keyboard);
31 changes: 11 additions & 20 deletions so3/devices/input/soo_mse.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@

#include <uapi/linux/input-event-codes.h>

#include <soo/dev/vinput.h>

/*
* Maximal horizontal and vertical resolution of the display.
* To be set via the ioctl SET_SIZE command.
Expand All @@ -54,7 +56,7 @@ struct ps2_mouse state = { .x = 0, .y = 0, .left = 0, .right = 0, .middle = 0 };
#define GET_STATE 0
#define SET_SIZE 1

int ioctl_mouse(int fd, unsigned long cmd, unsigned long args);
static int ioctl_mouse(int fd, unsigned long cmd, unsigned long args);

/* Device info. */

Expand All @@ -66,7 +68,7 @@ struct devclass vmse_cdev = {
.fops = &vmse_fops,
};

void so3virt_mse_event(unsigned int type, unsigned int code, int value)
void soo_mse_event(unsigned int type, unsigned int code, int value)
{
DBG("Input event: %u %u %d\n", type, code, value);

Expand All @@ -83,36 +85,25 @@ void so3virt_mse_event(unsigned int type, unsigned int code, int value)
state.y = value * res.v / 10000;
}
} else if (type == EV_KEY) {
/*
* Here we only set the button states to "pressed". Their state
* will be changed to "released" once the state has been read,
* e.g. in the ioctl. So the client has the time to read the
* button states.
*/
if ((code == BTN_LEFT || code == BTN_TOUCH) && value) {
if ((code == BTN_LEFT || code == BTN_TOUCH)) {
state.left = value;
} else if (code == BTN_MIDDLE && value) {
} else if (code == BTN_MIDDLE) {
state.middle = value;
} else if (code == BTN_RIGHT && value) {
} else if (code == BTN_RIGHT) {
state.right = value;
}
}

DBG("xy[%04d, %04d]; %03s %03s %03s\n", state.x, state.y, state.left ? "LFT" : "", state.middle ? "MID" : "",
DBG("xy[%04d, %04d]; %3s %3s %3s\n", state.x, state.y, state.left ? "LFT" : "", state.middle ? "MID" : "",
state.right ? "RGT" : "");
}

int ioctl_mouse(int fd, unsigned long cmd, unsigned long args)
static int ioctl_mouse(int fd, unsigned long cmd, unsigned long args)
{
switch (cmd) {
case GET_STATE:
/* Return the mouse coordinates and button states. */
*((struct ps2_mouse *) args) = state;

/* Reset the button states. */
state.left = 0;
state.right = 0;
state.middle = 0;
break;

case SET_SIZE:
Expand All @@ -128,11 +119,11 @@ int ioctl_mouse(int fd, unsigned long cmd, unsigned long args)
return 0;
}

int init_mouse(dev_t *dev)
static int init_mouse(dev_t *dev, int fdt_offset)
{
/* Register the input device so it can be accessed from user space. */
devclass_register(dev, &vmse_cdev);
return 0;
}

REGISTER_DRIVER_POSTCORE("mouse,so3virt", init_mouse);
REGISTER_DRIVER_POSTCORE("soo-input,mouse", init_mouse);
23 changes: 23 additions & 0 deletions so3/dts/rpi4_64_capsule.dts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,16 @@
status = "ok";
};

soo-keyboard {
compatible = "soo-input,keyboard";
status = "ok";
};

soo-mouse {
compatible = "soo-input,mouse";
status = "ok";
};

/*
* GIC interrupt controller - BCM2711 GIC-400 addresses.
* GICD at 0xFF841000: stage-2 fault -> AVZ MMIO emulation.
Expand Down Expand Up @@ -118,6 +128,19 @@
compatible = "vlogs,frontend";
status = "ok";
};

/* Enabling framebuffer support */
vfbdev {
compatible = "vfbdev,frontend";
status = "ok";
};


/* Enabling vinput support */
vinput {
compatible = "vinput,frontend";
status = "ok";
};
};
};

Expand Down
16 changes: 16 additions & 0 deletions so3/dts/virt64_capsule.dts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,16 @@
status = "ok";
};

soo-keyboard {
compatible = "soo-input,keyboard";
status = "ok";
};

soo-mouse {
compatible = "soo-input,mouse";
status = "ok";
};

/* GIC interrupt controller */
gic: interrupt-controller@0x08000000 {
compatible = "intc,gic";
Expand Down Expand Up @@ -120,6 +130,12 @@
compatible = "vfbdev,frontend";
status = "ok";
};

/* Enabling input support */
vinput {
compatible = "vinput,frontend";
status = "ok";
};
};
};

Expand Down
15 changes: 15 additions & 0 deletions so3/fs/vfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -1096,6 +1096,21 @@ SYSCALL_DEFINE3(readv, unsigned long, fd, const struct iovec *, vec, unsigned lo
return total;
}

/**
* TODO: implement the function, currently only used to mask message
* when the flags CLOEXEC is set due to user-space function opendir
* calling fcntl with CLOEXEC flag (used by ls).
*/
SYSCALL_DEFINE3(fcntl, unsigned int, fd, unsigned int, cmd, unsigned long, arg)
{
if ((cmd == F_SETFD) && (arg == FD_CLOEXEC)) {
return 0;
}

printk("%s: unsupported command and args %x - %lx\n", __func__, cmd, arg);
return -ENOSYS;
}

static void vfs_gfd_init(void)
{
memset(open_fds, 0, MAX_FDS * sizeof(struct fd *));
Expand Down
2 changes: 2 additions & 0 deletions so3/include/fb.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,6 @@
*/
#define IOCTL_FB_IS_REAL 4

#define IOCTL_FB_BPP 5 /* Bit per pixel. */

#endif /* FB_H */
Loading
Loading