From ed30b2cb21c429620323a448b49d287b96eb7f3f Mon Sep 17 00:00:00 2001 From: Lephe Date: Thu, 2 Jul 2020 15:47:11 +0200 Subject: [PATCH] render-cg: allow VRAM in user stack This is currently unused and has some artifacts in gintctl for reasons I haven't understood yet. Will have to investigate later. --- configure | 8 +++++--- fxcg50.ld | 15 +++++---------- src/render-cg/dvram.c | 24 +++++++++++++++++++++--- 3 files changed, 31 insertions(+), 16 deletions(-) diff --git a/configure b/configure index e800ebb..d7d8b32 100755 --- a/configure +++ b/configure @@ -13,9 +13,9 @@ prefix= cflags= # Behavior -boot_log= no_syscalls= static_gray= +user_vram= # Size limits atexit_max= @@ -57,6 +57,7 @@ Library options (disabled by default): Only use this option if you have a good idea of which. --static-gray Allocate gray VRAMs in static RAM instead of the heap May help when --no-syscalls is on. + --user-vram Allocate VRAM in user stack; takes 350k/512k [fxcg50] Size limits: --atexit-max=NUM Number of exit handlers in atexit()'s array [16] @@ -109,12 +110,12 @@ for arg; do case "$arg" in --cflags=*) cflags=${arg#*=};; - --boot-log) - boot_log=true;; --no-syscalls) no_syscalls=true;; --static-gray) static_gray=true;; + --user-vram) + user_vram=true;; --atexit-max=*) n=${arg#*=} @@ -190,6 +191,7 @@ output_config() echo -n " -D$(echo $target | tr 'a-z' 'A-Z')" [[ "$no_syscalls" ]] && echo -n " -DGINT_NO_SYSCALLS" [[ "$static_gray" ]] && echo -n " -DGINT_STATIC_GRAY" + [[ "$user_vram" ]] && echo -n " -DGINT_USER_VRAM" [[ "$atexit_max" ]] && echo -n " -DATEXIT_MAX=$atexit_max" echo "" } diff --git a/fxcg50.ld b/fxcg50.ld index 505f2f6..8a4f2b6 100644 --- a/fxcg50.ld +++ b/fxcg50.ld @@ -68,18 +68,14 @@ SECTIONS *(.text .text.*) } > rom - /* Interrupt handlers going to ROM: - - gint's interrupt handler blocks (.gint.blocks) - - Although gint's blocks end up in VBR space, they are installed at + /* gint's interrupt handler blocks (.gint.blocks) + Although gint's blocks end up in VBR space, they are relocated at startup by the library/drivers, so we store them here for now */ .gint.blocks : { KEEP(*(.gint.blocks)); } > rom - /* Driver data going to ROM: - - Exposed driver interfaces (.gint.drivers) - + /* Exposed driver interfaces (.gint.drivers) The driver information is required to start and configure the driver, even if the symbols are not referenced */ .gint.drivers : { @@ -117,6 +113,7 @@ SECTIONS .bss (NOLOAD) : { _rbss = . ; + *(.bss.vram) *(.bss COMMON) . = ALIGN(16); @@ -183,9 +180,7 @@ SECTIONS /* - ** gint-related sections - ** 8c160000:5k VBR space - ** 8c161400:3k .gint.data and .gint.bss + ** gint-related sections (VBR space, .gint.data and .gint.bss) */ /* VBR address: let's just start at the beginning of the RAM area. diff --git a/src/render-cg/dvram.c b/src/render-cg/dvram.c index 392475f..d7f4584 100644 --- a/src/render-cg/dvram.c +++ b/src/render-cg/dvram.c @@ -1,13 +1,31 @@ #include -/* Put both VRAMs in the system stack! */ +#ifdef GINT_USER_VRAM +/* We want to put the VRAM in the user section, however we can't use the + virtualized P0 address as this will mess up the DMA. As the static RAM is + always fully mapped at a fixed place, we can use the target P1 address. We + just need to allocate the space for the linker. This special section ensures + that the first address of the user stack will be used */ +GALIGNED(4) GSECTION(".bss.vram") int8_t _gint_vram_buffers[396*224*2]; + +/* In this case, we can define pointers to our user stack directly, these will + be the physical address associated with _vram_buffers */ +static uint16_t *main = (void *)0xac161400; +static uint16_t *scnd = (void *)0xac18c900; + +/* Shared VRAM pointer, the one exposed by */ +uint16_t *gint_vram = (void *)0xac161400; + +#else + +/* Otherwise, just put both VRAMs in the system stack! */ static uint16_t *main = (void *)0xac0f0000; static uint16_t *scnd = (void *)0xac11b500; +uint16_t *gint_vram = (void *)0xac0f0000; +#endif /* On Prizm: should be: 0xa80f0000 and 0xa811b500 */ -/* Shared VRAM pointer, the one exposed by */ -uint16_t *gint_vram = (void *)0xac0f0000; /* dsetvram() - Control video RAM address and triple buffering */ void dsetvram(uint16_t *new_main, uint16_t *new_secondary)