Compare commits
2 Commits
71be9c5fb3
...
c4c26e0e19
Author | SHA1 | Date | |
---|---|---|---|
c4c26e0e19 | |||
3b42abc027 |
@ -201,13 +201,15 @@ void intr_handleintr(IntrStackFrame *frame) {
|
|||||||
break;
|
break;
|
||||||
case INTR_IRQBASE+1:
|
case INTR_IRQBASE+1:
|
||||||
int32_t c = ps2kb_intr();
|
int32_t c = ps2kb_intr();
|
||||||
intr_eoi(frame->trapnum - INTR_IRQBASE);
|
if (c >= 0) {
|
||||||
uint8_t *bytes = (uint8_t *)&c;
|
uint8_t *bytes = (uint8_t *)&c;
|
||||||
spinlock_acquire(&PS2KB_BUF.spinlock);
|
spinlock_acquire(&PS2KB_BUF.spinlock);
|
||||||
for (size_t i = 0; i < sizeof(c); i++) {
|
for (size_t i = 0; i < sizeof(c); i++) {
|
||||||
rbuf_push(&PS2KB_BUF.rbuf, bytes[i]);
|
rbuf_push(&PS2KB_BUF.rbuf, bytes[i]);
|
||||||
}
|
}
|
||||||
spinlock_release(&PS2KB_BUF.spinlock);
|
spinlock_release(&PS2KB_BUF.spinlock);
|
||||||
|
}
|
||||||
|
intr_eoi(frame->trapnum - INTR_IRQBASE);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else if (frame->trapnum == 0x80) {
|
} else if (frame->trapnum == 0x80) {
|
||||||
|
@ -22,17 +22,18 @@ void ps2kbproc_init(Proc *proc) {
|
|||||||
|
|
||||||
void ps2kbproc_fn(void) {
|
void ps2kbproc_fn(void) {
|
||||||
for (;;) {
|
for (;;) {
|
||||||
int32_t kbchr;
|
int32_t kbchr = 0;
|
||||||
uint8_t *buf = (uint8_t *)&kbchr;
|
uint8_t *buf = (uint8_t *)&kbchr;
|
||||||
size_t i = 0;
|
size_t total = 0;
|
||||||
spinlock_acquire(&PS2KB_BUF.spinlock);
|
spinlock_acquire(&PS2KB_BUF.spinlock);
|
||||||
for (; i < sizeof(kbchr); i++) {
|
for (size_t i = 0; i < sizeof(kbchr); i++) {
|
||||||
if (rbuf_pop(&PS2KB_BUF.rbuf, &buf[i]) < 0) {
|
if (rbuf_pop(&PS2KB_BUF.rbuf, &buf[i]) < 0) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
total++;
|
||||||
}
|
}
|
||||||
spinlock_release(&PS2KB_BUF.spinlock);
|
spinlock_release(&PS2KB_BUF.spinlock);
|
||||||
if (i > 0) {
|
if (total == sizeof(kbchr)) {
|
||||||
spinlock_acquire(&PS2KBPROC->bcast_pipes.spinlock);
|
spinlock_acquire(&PS2KBPROC->bcast_pipes.spinlock);
|
||||||
IpcPipe *head = PS2KBPROC->bcast_pipes.list;
|
IpcPipe *head = PS2KBPROC->bcast_pipes.list;
|
||||||
while (head != NULL) {
|
while (head != NULL) {
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
|
|
||||||
VfsTable VFS_TABLE;
|
VfsTable VFS_TABLE;
|
||||||
|
|
||||||
void vfs_init_littlefs(VfsMountPoint *mp) {
|
void vfs_init_littlefs(VfsMountPoint *mp, bool format) {
|
||||||
struct lfs_config *cfg = dlmalloc(sizeof(*cfg));
|
struct lfs_config *cfg = dlmalloc(sizeof(*cfg));
|
||||||
hal_memset(cfg, 0, sizeof(*cfg));
|
hal_memset(cfg, 0, sizeof(*cfg));
|
||||||
cfg->context = mp;
|
cfg->context = mp;
|
||||||
@ -36,16 +36,19 @@ void vfs_init_littlefs(VfsMountPoint *mp) {
|
|||||||
cfg->name_max = 0;
|
cfg->name_max = 0;
|
||||||
cfg->file_max = 0;
|
cfg->file_max = 0;
|
||||||
cfg->attr_max = 0;
|
cfg->attr_max = 0;
|
||||||
|
if (format) {
|
||||||
|
lfs_format(&mp->fs.littlefs.instance, cfg);
|
||||||
|
}
|
||||||
int err = lfs_mount(&mp->fs.littlefs.instance, cfg);
|
int err = lfs_mount(&mp->fs.littlefs.instance, cfg);
|
||||||
if (err < 0) {
|
if (err < 0) {
|
||||||
ERR("vfs", "Little FS mount failed\n");
|
ERR("vfs", "Little FS mount failed %d\n", err);
|
||||||
}
|
}
|
||||||
|
|
||||||
mp->cleanup = &littlefs_cleanup;
|
mp->cleanup = &littlefs_cleanup;
|
||||||
mp->open = &littlefs_open;
|
mp->open = &littlefs_open;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t vfs_mount(char *mountpoint, int32_t fstype, StoreDev *backingsd) {
|
int32_t vfs_mount(char *mountpoint, int32_t fstype, StoreDev *backingsd, bool format) {
|
||||||
VfsMountPoint *mp = NULL;
|
VfsMountPoint *mp = NULL;
|
||||||
|
|
||||||
spinlock_acquire(&VFS_TABLE.spinlock);
|
spinlock_acquire(&VFS_TABLE.spinlock);
|
||||||
@ -61,7 +64,7 @@ int32_t vfs_mount(char *mountpoint, int32_t fstype, StoreDev *backingsd) {
|
|||||||
mp->fstype = fstype;
|
mp->fstype = fstype;
|
||||||
switch (fstype) {
|
switch (fstype) {
|
||||||
case VFS_LITTLEFS:
|
case VFS_LITTLEFS:
|
||||||
vfs_init_littlefs(mp);
|
vfs_init_littlefs(mp, format);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return E_UNKNOWN_FSTYPE;
|
return E_UNKNOWN_FSTYPE;
|
||||||
@ -114,13 +117,23 @@ void vfs_init(void) {
|
|||||||
hal_memset(&VFS_TABLE, 0, sizeof(VFS_TABLE));
|
hal_memset(&VFS_TABLE, 0, sizeof(VFS_TABLE));
|
||||||
spinlock_init(&VFS_TABLE.spinlock);
|
spinlock_init(&VFS_TABLE.spinlock);
|
||||||
|
|
||||||
|
{
|
||||||
RamSdInitExtra extra = { .capacity = baseimg_getsize(), .preallocbuffer = (uint8_t *)baseimg_getaddr() };
|
RamSdInitExtra extra = { .capacity = baseimg_getsize(), .preallocbuffer = (uint8_t *)baseimg_getaddr() };
|
||||||
StoreDev *backingsd = storedev_create(STOREDEV_RAMSD, &extra);
|
StoreDev *backingsd = storedev_create(STOREDEV_RAMSD, &extra);
|
||||||
if (backingsd == NULL) {
|
if (backingsd == NULL) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
vfs_mount("base", VFS_LITTLEFS, backingsd, false);
|
||||||
|
}
|
||||||
|
|
||||||
vfs_mount("base", VFS_LITTLEFS, backingsd);
|
{
|
||||||
|
RamSdInitExtra extra = { .capacity = (1024*1024*10) };
|
||||||
|
StoreDev *backingsd = storedev_create(STOREDEV_RAMSD, &extra);
|
||||||
|
if (backingsd == NULL) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
vfs_mount("temp", VFS_LITTLEFS, backingsd, true);
|
||||||
|
}
|
||||||
|
|
||||||
LOG("vfs", "init\n");
|
LOG("vfs", "init\n");
|
||||||
|
|
||||||
|
@ -74,7 +74,7 @@ extern VfsTable VFS_TABLE;
|
|||||||
|
|
||||||
void vfs_init(void);
|
void vfs_init(void);
|
||||||
int32_t vfs_unmount(char *mountpoint);
|
int32_t vfs_unmount(char *mountpoint);
|
||||||
int32_t vfs_mount(char *mountpoint, int32_t fstype, StoreDev *backingsd);
|
int32_t vfs_mount(char *mountpoint, int32_t fstype, StoreDev *backingsd, bool format);
|
||||||
void vfs_close(VfsObj *vobj);
|
void vfs_close(VfsObj *vobj);
|
||||||
VfsObj *vfs_open(char *mountpoint, const char *path, uint32_t flags);
|
VfsObj *vfs_open(char *mountpoint, const char *path, uint32_t flags);
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@ void main(void) {
|
|||||||
|
|
||||||
int32_t ioh = ioctl(IOCTL_NOHANDLE,
|
int32_t ioh = ioctl(IOCTL_NOHANDLE,
|
||||||
IOCTL_OPENF,
|
IOCTL_OPENF,
|
||||||
(uint64_t)"base:/hello.txt",
|
(uint64_t)"temp:/hello.txt",
|
||||||
IOCTL_F_WRITE | IOCTL_F_READ | IOCTL_F_MAKE,
|
IOCTL_F_WRITE | IOCTL_F_READ | IOCTL_F_MAKE,
|
||||||
0
|
0
|
||||||
);
|
);
|
||||||
|
Reference in New Issue
Block a user