Skip to content
Snippets Groups Projects
Verified Commit 3e49770a authored by Recolic Keghart's avatar Recolic Keghart
Browse files

> Manual commit: keyboard code added

U201614531
recolic
Linux RECOLICPC 5.4.6-arch3-1 #1 SMP PREEMPT Tue, 24 Dec 2019 04:36:53 +0000 x86_64 GNU/Linux
 21:40:17 up 2 days,  3:14,  1 user,  load average: 1.44, 1.18, 1.20
d16509ce8e6331f2ee1532bdbaa64200261c37f3
parent a6c4f29f
No related branches found
No related tags found
1 merge request!2Performance tune
......@@ -15,4 +15,7 @@
#define RLIB_MACRO_DEBUG_ASSERT(expr)
#endif
#define RLIB_MACRO_LIKELY(x) __builtin_expect((x),1)
#define RLIB_MACRO_UNLIKELY(x) __builtin_expect((x),0)
#endif
......@@ -33,7 +33,7 @@ void* add_mmio_map(paddr_t addr, int len, mmio_callback_t callback) {
}
/* bus interface */
int is_mmio(paddr_t addr) {
__attribute__((hot)) int is_mmio(paddr_t addr) {
int i;
for (i = 0; i < nr_map; i ++) {
if (addr >= maps[i].low && addr <= maps[i].high) {
......
#include "nemu.h"
#include "device/mmio.h"
#define PMEM_SIZE (128 * 1024 * 1024)
......@@ -13,21 +14,25 @@ uint8_t pmem[PMEM_SIZE];
__attribute__((hot)) uint32_t paddr_read(paddr_t addr, int len) {
static const uint32_t niddle[] = {0, 0xff, 0xffff, 0xffffff, 0xffffffff};
return pmem_rw(addr, uint32_t) & niddle[len];
// switch(len) {
// case 4: return pmem_rw(addr, uint32_t);
// case 2: return pmem_rw(addr, uint32_t) & 0x0000ffff;
// case 1: return pmem_rw(addr, uint32_t) & 0x000000ff;
// case 3: return pmem_rw(addr, uint32_t) & 0x00ffffff;
// case 0: return 0;
// }
// return pmem_rw(addr, uint32_t) & (~0u >> ((4 - len) << 3));
if(const auto mmio_id = is_mmio(addr);(-1 == mmio_id)) {
return pmem_rw(addr, uint32_t) & niddle[len];
}
else {
return mmio_read(addr, len, mmio_id);
}
}
void paddr_write(paddr_t addr, uint32_t data, int len) {
memcpy(guest_to_host(addr), &data, len);
if(const auto mmio_id = is_mmio(addr);(-1 == mmio_id)) {
memcpy(guest_to_host(addr), &data, len);
}
else {
mmio_write(addr, len, data, mmio_id);
}
}
// len is Bytes.
uint32_t vaddr_read(vaddr_t addr, int len) {
return paddr_read(addr, len);
......
......@@ -3,11 +3,15 @@
#include <amdev.h>
size_t input_read(uintptr_t reg, void *buf, size_t size) {
const uint32_t I8042_DATA_PORT = 0x60;
switch (reg) {
case _DEVREG_INPUT_KBD: {
_KbdReg *kbd = (_KbdReg *)buf;
kbd->keydown = 0;
kbd->keycode = _KEY_NONE;
uint32_t press = inl(I8042_DATA_PORT);
kbd->keycode = press;
if(press != _KEY_NONE){
kbd->keydown = !(kbd->keydown);
}
return sizeof(_KbdReg);
}
}
......
......@@ -6,11 +6,13 @@
static uint32_t* const fb __attribute__((used)) = (uint32_t *)0x40000;
size_t video_read(uintptr_t reg, void *buf, size_t size) {
const uint32_t SCREEN_PORT = 0x100;
switch (reg) {
case _DEVREG_VIDEO_INFO: {
_VideoInfoReg *info = (_VideoInfoReg *)buf;
info->width = 0;
info->height = 0;
uint32_t screen = inl(SCREEN_PORT);
info->width = screen >> 16;
info->height = screen << 16 >> 16;
return sizeof(_VideoInfoReg);
}
}
......@@ -21,7 +23,13 @@ size_t video_write(uintptr_t reg, void *buf, size_t size) {
switch (reg) {
case _DEVREG_VIDEO_FBCTL: {
_FBCtlReg *ctl = (_FBCtlReg *)buf;
int i;
int size = screen_width() * screen_height();
for (i = 0; i < size; i ++) fb[i] = i;
// for(int i = 0; i < ctl->h; ++i)
// {
// memcpy(fb+(ctl->y+i)*screen_width()+ctl->x,ctl->pixels+i*ctl->w,ctl->w*4);
// }
if (ctl->sync) {
// do nothing, hardware syncs.
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment