ready for ics2021
This commit is contained in:
parent
3cf0ee6d42
commit
30e5cd0c7e
72 changed files with 252 additions and 339 deletions
|
@ -8,6 +8,7 @@ void __am_timer_init();
|
|||
void __am_gpu_init();
|
||||
void __am_input_init();
|
||||
void __am_audio_init();
|
||||
void __am_disk_init();
|
||||
void __am_input_config(AM_INPUT_CONFIG_T *);
|
||||
void __am_timer_config(AM_TIMER_CONFIG_T *);
|
||||
void __am_timer_rtc(AM_TIMER_RTC_T *);
|
||||
|
@ -20,8 +21,10 @@ void __am_audio_config(AM_AUDIO_CONFIG_T *);
|
|||
void __am_audio_ctrl(AM_AUDIO_CTRL_T *);
|
||||
void __am_audio_status(AM_AUDIO_STATUS_T *);
|
||||
void __am_audio_play(AM_AUDIO_PLAY_T *);
|
||||
void __am_disk_config(AM_DISK_CONFIG_T *cfg);
|
||||
void __am_disk_status(AM_DISK_STATUS_T *stat);
|
||||
void __am_disk_blkio(AM_DISK_BLKIO_T *io);
|
||||
static void __am_uart_config(AM_UART_CONFIG_T *cfg) { cfg->present = false; }
|
||||
static void __am_disk_config(AM_DISK_CONFIG_T *cfg) { cfg->present = false; }
|
||||
static void __am_net_config (AM_NET_CONFIG_T *cfg) { cfg->present = false; }
|
||||
|
||||
typedef void (*handler_t)(void *buf);
|
||||
|
@ -40,6 +43,8 @@ static void *lut[128] = {
|
|||
[AM_AUDIO_STATUS] = __am_audio_status,
|
||||
[AM_AUDIO_PLAY ] = __am_audio_play,
|
||||
[AM_DISK_CONFIG ] = __am_disk_config,
|
||||
[AM_DISK_STATUS ] = __am_disk_status,
|
||||
[AM_DISK_BLKIO ] = __am_disk_blkio,
|
||||
[AM_NET_CONFIG ] = __am_net_config,
|
||||
};
|
||||
|
||||
|
@ -59,6 +64,7 @@ void __am_ioe_init() {
|
|||
__am_gpu_init();
|
||||
__am_input_init();
|
||||
__am_audio_init();
|
||||
__am_disk_init();
|
||||
ioe_init_done = true;
|
||||
}
|
||||
|
||||
|
|
41
am/src/native/ioe/disk.c
Normal file
41
am/src/native/ioe/disk.c
Normal file
|
@ -0,0 +1,41 @@
|
|||
#include <am.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <assert.h>
|
||||
|
||||
#define BLKSZ 512
|
||||
|
||||
static int disk_size = 0;
|
||||
static FILE *fp = NULL;
|
||||
|
||||
void __am_disk_init() {
|
||||
const char *diskimg = getenv("diskimg");
|
||||
if (diskimg) {
|
||||
fp = fopen(diskimg, "r+");
|
||||
if (fp) {
|
||||
fseek(fp, 0, SEEK_END);
|
||||
disk_size = (ftell(fp) + 511) / 512;
|
||||
rewind(fp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void __am_disk_config(AM_DISK_CONFIG_T *cfg) {
|
||||
cfg->present = (fp != NULL);
|
||||
cfg->blksz = BLKSZ;
|
||||
cfg->blkcnt = disk_size;
|
||||
}
|
||||
|
||||
void __am_disk_status(AM_DISK_STATUS_T *stat) {
|
||||
stat->ready = 1;
|
||||
}
|
||||
|
||||
void __am_disk_blkio(AM_DISK_BLKIO_T *io) {
|
||||
if (fp) {
|
||||
fseek(fp, io->blkno * BLKSZ, SEEK_SET);
|
||||
int ret;
|
||||
if (io->write) ret = fwrite(io->buf, io->blkcnt * BLKSZ, 1, fp);
|
||||
else ret = fread(io->buf, io->blkcnt * BLKSZ, 1, fp);
|
||||
assert(ret == 1);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue