2013-08-23 02:57:00 +02:00
|
|
|
/* $Id: s3c2410_memc.c,v 1.4 2008/12/11 12:18:17 ecd Exp $
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <fcntl.h>
|
|
|
|
#include <sys/mman.h>
|
|
|
|
#include <errno.h>
|
|
|
|
|
|
|
|
#include <x49gp.h>
|
|
|
|
#include <s3c2410.h>
|
|
|
|
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
uint32_t bwscon;
|
|
|
|
uint32_t bankcon0;
|
|
|
|
uint32_t bankcon1;
|
|
|
|
uint32_t bankcon2;
|
|
|
|
uint32_t bankcon3;
|
|
|
|
uint32_t bankcon4;
|
|
|
|
uint32_t bankcon5;
|
|
|
|
uint32_t bankcon6;
|
|
|
|
uint32_t bankcon7;
|
|
|
|
uint32_t refresh;
|
|
|
|
uint32_t banksize;
|
|
|
|
uint32_t mrsrb6;
|
|
|
|
uint32_t mrsrb7;
|
|
|
|
|
|
|
|
unsigned int nr_regs;
|
|
|
|
s3c2410_offset_t *regs;
|
|
|
|
|
|
|
|
x49gp_t *x49gp;
|
|
|
|
} s3c2410_memc_t;
|
|
|
|
|
|
|
|
static int
|
|
|
|
s3c2410_memc_data_init(s3c2410_memc_t *memc)
|
|
|
|
{
|
|
|
|
s3c2410_offset_t regs[] = {
|
|
|
|
S3C2410_OFFSET(MEMC, BWSCON, 0x00000000, memc->bwscon),
|
|
|
|
S3C2410_OFFSET(MEMC, BANKCON0, 0x00000700, memc->bankcon0),
|
|
|
|
S3C2410_OFFSET(MEMC, BANKCON1, 0x00000700, memc->bankcon1),
|
|
|
|
S3C2410_OFFSET(MEMC, BANKCON2, 0x00000700, memc->bankcon2),
|
|
|
|
S3C2410_OFFSET(MEMC, BANKCON3, 0x00000700, memc->bankcon3),
|
|
|
|
S3C2410_OFFSET(MEMC, BANKCON4, 0x00000700, memc->bankcon4),
|
|
|
|
S3C2410_OFFSET(MEMC, BANKCON5, 0x00000700, memc->bankcon5),
|
|
|
|
S3C2410_OFFSET(MEMC, BANKCON6, 0x00018008, memc->bankcon6),
|
|
|
|
S3C2410_OFFSET(MEMC, BANKCON7, 0x00018008, memc->bankcon7),
|
|
|
|
S3C2410_OFFSET(MEMC, REFRESH, 0x00ac0000, memc->refresh),
|
|
|
|
S3C2410_OFFSET(MEMC, BANKSIZE, 0x00000000, memc->banksize),
|
|
|
|
S3C2410_OFFSET(MEMC, MRSRB6, 0, memc->mrsrb6),
|
|
|
|
S3C2410_OFFSET(MEMC, MRSRB7, 0, memc->mrsrb7),
|
|
|
|
};
|
|
|
|
|
|
|
|
memset(memc, 0, sizeof(s3c2410_memc_t));
|
|
|
|
|
|
|
|
memc->regs = malloc(sizeof(regs));
|
|
|
|
if (NULL == memc->regs) {
|
|
|
|
fprintf(stderr, "%s:%u: Out of memory\n",
|
|
|
|
__FUNCTION__, __LINE__);
|
|
|
|
return -ENOMEM;
|
|
|
|
}
|
|
|
|
|
|
|
|
memcpy(memc->regs, regs, sizeof(regs));
|
|
|
|
memc->nr_regs = sizeof(regs) / sizeof(regs[0]);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static uint32_t
|
|
|
|
s3c2410_memc_read(void *opaque, target_phys_addr_t offset)
|
|
|
|
{
|
|
|
|
s3c2410_memc_t *memc = opaque;
|
|
|
|
s3c2410_offset_t *reg;
|
|
|
|
|
|
|
|
#ifdef QEMU_OLD
|
|
|
|
offset -= S3C2410_MEMC_BASE;
|
|
|
|
#endif
|
|
|
|
if (! S3C2410_OFFSET_OK(memc, offset)) {
|
|
|
|
return ~(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
reg = S3C2410_OFFSET_ENTRY(memc, offset);
|
|
|
|
|
|
|
|
#ifdef DEBUG_S3C2410_MEMC
|
2017-10-26 14:30:39 +02:00
|
|
|
printf("read %s [%08x] %s [%08lx] data %08x\n",
|
2013-08-23 02:57:00 +02:00
|
|
|
"s3c2410-memc", S3C2410_MEMC_BASE,
|
2017-10-26 14:30:39 +02:00
|
|
|
reg->name, (unsigned long) offset, *(reg->datap));
|
2013-08-23 02:57:00 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
return *(reg->datap);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
s3c2410_memc_write(void *opaque, target_phys_addr_t offset, uint32_t data)
|
|
|
|
{
|
|
|
|
s3c2410_memc_t *memc = opaque;
|
|
|
|
s3c2410_offset_t *reg;
|
|
|
|
|
|
|
|
#ifdef QEMU_OLD
|
|
|
|
offset -= S3C2410_MEMC_BASE;
|
|
|
|
#endif
|
|
|
|
if (! S3C2410_OFFSET_OK(memc, offset)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
reg = S3C2410_OFFSET_ENTRY(memc, offset);
|
|
|
|
|
|
|
|
#ifdef DEBUG_S3C2410_MEMC
|
2017-10-26 14:30:39 +02:00
|
|
|
printf("write %s [%08x] %s [%08lx] data %08x\n",
|
2013-08-23 02:57:00 +02:00
|
|
|
"s3c2410-memc", S3C2410_MEMC_BASE,
|
2017-10-26 14:30:39 +02:00
|
|
|
reg->name, (unsigned long) offset, data);
|
2013-08-23 02:57:00 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
*(reg->datap) = data;
|
|
|
|
|
|
|
|
#ifdef DEBUG_S3C2410_MEMC
|
|
|
|
printf("%s:%u: env %p\n", __FUNCTION__, __LINE__, memc->x49gp->env);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
s3c2410_memc_load(x49gp_module_t *module, GKeyFile *key)
|
|
|
|
{
|
|
|
|
s3c2410_memc_t *memc = module->user_data;
|
|
|
|
s3c2410_offset_t *reg;
|
|
|
|
int error = 0;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
#ifdef DEBUG_X49GP_MODULES
|
|
|
|
printf("%s: %s:%u\n", module->name, __FUNCTION__, __LINE__);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
for (i = 0; i < memc->nr_regs; i++) {
|
|
|
|
reg = &memc->regs[i];
|
|
|
|
|
|
|
|
if (NULL == reg->name)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (x49gp_module_get_u32(module, key, reg->name,
|
|
|
|
reg->reset, reg->datap))
|
|
|
|
error = -EAGAIN;
|
|
|
|
}
|
|
|
|
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
s3c2410_memc_save(x49gp_module_t *module, GKeyFile *key)
|
|
|
|
{
|
|
|
|
s3c2410_memc_t *memc = module->user_data;
|
|
|
|
s3c2410_offset_t *reg;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
#ifdef DEBUG_X49GP_MODULES
|
|
|
|
printf("%s: %s:%u\n", module->name, __FUNCTION__, __LINE__);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
for (i = 0; i < memc->nr_regs; i++) {
|
|
|
|
reg = &memc->regs[i];
|
|
|
|
|
|
|
|
if (NULL == reg->name)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
x49gp_module_set_u32(module, key, reg->name, *(reg->datap));
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
s3c2410_memc_reset(x49gp_module_t *module, x49gp_reset_t reset)
|
|
|
|
{
|
|
|
|
s3c2410_memc_t *memc = module->user_data;
|
|
|
|
s3c2410_offset_t *reg;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
#ifdef DEBUG_X49GP_MODULES
|
|
|
|
printf("%s: %s:%u\n", module->name, __FUNCTION__, __LINE__);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
for (i = 0; i < memc->nr_regs; i++) {
|
|
|
|
reg = &memc->regs[i];
|
|
|
|
|
|
|
|
if (NULL == reg->name)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
*(reg->datap) = reg->reset;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static CPUReadMemoryFunc *s3c2410_memc_readfn[] =
|
|
|
|
{
|
|
|
|
s3c2410_memc_read,
|
|
|
|
s3c2410_memc_read,
|
|
|
|
s3c2410_memc_read
|
|
|
|
};
|
|
|
|
|
|
|
|
static CPUWriteMemoryFunc *s3c2410_memc_writefn[] =
|
|
|
|
{
|
|
|
|
s3c2410_memc_write,
|
|
|
|
s3c2410_memc_write,
|
|
|
|
s3c2410_memc_write
|
|
|
|
};
|
|
|
|
|
|
|
|
static int
|
|
|
|
s3c2410_memc_init(x49gp_module_t *module)
|
|
|
|
{
|
|
|
|
s3c2410_memc_t *memc;
|
|
|
|
int iotype;
|
|
|
|
|
|
|
|
#ifdef DEBUG_X49GP_MODULES
|
|
|
|
printf("%s: %s:%u\n", module->name, __FUNCTION__, __LINE__);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
memc = malloc(sizeof(s3c2410_memc_t));
|
|
|
|
if (NULL == memc) {
|
|
|
|
fprintf(stderr, "%s:%u: Out of memory\n",
|
|
|
|
__FUNCTION__, __LINE__);
|
|
|
|
return -ENOMEM;
|
|
|
|
}
|
|
|
|
if (s3c2410_memc_data_init(memc)) {
|
|
|
|
free(memc);
|
|
|
|
return -ENOMEM;
|
|
|
|
}
|
|
|
|
|
|
|
|
module->user_data = memc;
|
|
|
|
memc->x49gp = module->x49gp;
|
|
|
|
|
|
|
|
#ifdef QEMU_OLD
|
|
|
|
iotype = cpu_register_io_memory(0, s3c2410_memc_readfn,
|
|
|
|
s3c2410_memc_writefn, memc);
|
|
|
|
#else
|
|
|
|
iotype = cpu_register_io_memory(s3c2410_memc_readfn,
|
|
|
|
s3c2410_memc_writefn, memc);
|
|
|
|
#endif
|
On behalf of: 3298 - Applied 23 patches by 3298:
Misc changes, mostly fixes:
- fix ./newconfig systems other than OSX (broke in c8b823f)
- fix palette usage in 2-bit color mode (was broken ever since grayscale was implemented in 18e1003 and its improperly attributed copy f7913eb)
- fix continuing from breakpoints in the debugger (never worked, was exposed when the debugger was enabled in 9c1f2ed)
- restore the printf statements commented out in 9c1f2ed and hide them with #ifdefs instead
- close the server socket after accepting a debugger connection to allow another simultaneous debug session to be started using the same TCP port
- use the symbolic constant DEFAULT_GDBSTUB_PORT (already defined in gdb_stub.h as 1234) when starting the gdb server in main.c in place of the raw number 1234
- change Makefile to read the name of the firmware file from the file update.scp instead of hardcoding it; this allows users to switch to another firmware
by simply pasting it along with its accompanying update.scp into the x49gp directory
- Enhance port G (keyboard) handling to remember the value of output bits across periods with these bits configured as input
This fixes interaction with HPGCC3 keyboard routines, and it also fixes keys with eint==7 (assuming the stock firmware is in use)
needing a double-tap to work unless pressed very shortly after another keypress (the latter broke in b5f93ed)
- Get rid of the deprecated function warning by switching from gdk_pixbuf_new_from_inline to gdk_pixbuf_new_from_data (based on code by chwdt)
- Delete remaining now-redundant CVS files
- Don't release all buttons anymore if there are still physical keys and/or the left mouse button are holding some down
On the other hand, forcibly release all buttons when losing focus to avoid getting stuck in a state with buttons down
when they are not held down by anything; this would happen due to missed events while not in focus
- Add a context menu to the screen, containing only "Reset" and "Quit" items for now
- Ensure that the files backing flash, sram, and s3c2410-sram exist and have the correct size when opening them
Note that if the flash file does not exist, this will not fill it with the code that's supposed to be in there, obviously causing the calculator to crash. That's an improvement for later.
- Allow the config system to fill not only numbers, but also strings (including filenames) with default values
basename is excluded, but it's planned to be dropped entirely.
- Add an "install" target to the Makefile
- Implement a more generic command-line parser for substantially improved flexibility
- Also adds a proper help option, though the manual referenced in the corresponding output (a manpage, hopefully) does not exist yet.
- Drop the "basename" config property in favor of interpreting relative paths in the config as relative to the config file's location
- Retire the "image" config property in favor of simply loading the image from next to the binary or from the install directory
- Split the UI name property into name (affecting only the window title) and type (affecting the UI image and in the future also the default bootcode) properties
- Change the default calculator type to the 50g everywhere, which probably matches today's user expectations better than the 49g+.
- Create a flash file from the calculator model's appropriate boot file if it does not exist, relying on the bootcode to detect the absence of a firmware
The bootcode will complain about the missing firmware and enter update mode, so the user needs to supply their favorite firmware version and point the bootcode's updater to it.
The easiest way is probably pointing the emulated SD card at a directory containing the firmware and its accompanying update.scp file, and then starting the SD-based update.
- Add SD mount / unmount options to the right-click / menu-key popup menu
- Remove most of the old script-based config-generating system since the binary now has these capabilities as well
- Add an applications menu item for installing
- Keep some debug output on stderr and a huge vvfat.log file from showing up when not debugging x49gp itself
- Allow (re-)connecting a debugger to a running session
This is done through the right-click / menu-key popup menu.
To avoid confusion due to the accidental clicks leading to an unresponsive interface (caused by waiting for the debugger to connect),
this option is hidden unless option -d or its new companion -D (same as -d, but does not start the debug interface right away) is present.
- Improved support for hardware keyboards
- Update README.md, add manpage, rename other README files to TODO to reflect their contents
2018-05-07 23:32:14 +02:00
|
|
|
#ifdef DEBUG_S3C2410_MEMC
|
|
|
|
printf("%s: iotype %08x\n", __FUNCTION__, iotype);
|
|
|
|
#endif
|
2013-08-23 02:57:00 +02:00
|
|
|
cpu_register_physical_memory(S3C2410_MEMC_BASE, S3C2410_MAP_SIZE, iotype);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
s3c2410_memc_exit(x49gp_module_t *module)
|
|
|
|
{
|
|
|
|
s3c2410_memc_t *memc;
|
|
|
|
|
|
|
|
#ifdef DEBUG_X49GP_MODULES
|
|
|
|
printf("%s: %s:%u\n", module->name, __FUNCTION__, __LINE__);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if (module->user_data) {
|
|
|
|
memc = module->user_data;
|
|
|
|
if (memc->regs)
|
|
|
|
free(memc->regs);
|
|
|
|
free(memc);
|
|
|
|
}
|
|
|
|
|
|
|
|
x49gp_module_unregister(module);
|
|
|
|
free(module);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
x49gp_s3c2410_memc_init(x49gp_t *x49gp)
|
|
|
|
{
|
|
|
|
x49gp_module_t *module;
|
|
|
|
|
|
|
|
if (x49gp_module_init(x49gp, "s3c2410-memc",
|
|
|
|
s3c2410_memc_init,
|
|
|
|
s3c2410_memc_exit,
|
|
|
|
s3c2410_memc_reset,
|
|
|
|
s3c2410_memc_load,
|
|
|
|
s3c2410_memc_save,
|
|
|
|
NULL, &module)) {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return x49gp_module_register(module);
|
|
|
|
}
|