1
0
Fork 0
forked from len0rd/rockbox

Gigabeat S: Reclaim about 800K of memory that was laying unused. Get rid of DEVBSS_ATTR for this target and implement as NOCACHEBSS_ATTR. Plugin and codec buffers move so all that is now incompatible (do full update). No version increase for plugins/codecs because the loader will reject them.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@25895 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Michael Sevakis 2010-05-08 07:45:34 +00:00
parent 7f3b3494a6
commit a420561bf8
9 changed files with 119 additions and 69 deletions

View file

@ -30,17 +30,16 @@ OUTPUT_FORMAT(elf32-littlemips)
#define CACHEALIGN_SIZE 16 #define CACHEALIGN_SIZE 16
#endif /* CPU_PP */ #endif /* CPU_PP */
#ifndef NOCACHE_BASE #if CONFIG_CPU==IMX31L
/* Default to no offset if target doesn't define this */ /* No fudges! */
#define NOCACHE_BASE 0x00000000 #include "imx31l.h"
#endif #define DRAMSIZE ((MEMORYSIZE * 0x100000) - STUBOFFSET - PLUGIN_BUFFER_SIZE \
- CODEC_SIZE - QHARRAY_SIZE - FRAME_SIZE - TTB_SIZE)
#if CONFIG_CPU==DM320 || CONFIG_CPU==IMX31L #elif CONFIG_CPU==DM320
/* Give this 1 meg to allow it to align to the MMU boundary */ /* Give this 1 meg to allow it to align to the MMU boundary */
#if CONFIG_CPU==DM320
#ifndef LCD_NATIVE_WIDTH #ifndef LCD_NATIVE_WIDTH
#define LCD_NATIVE_WIDTH LCD_WIDTH #define LCD_NATIVE_WIDTH LCD_WIDTH
#endif
#ifndef LCD_NATIVE_HEIGHT #ifndef LCD_NATIVE_HEIGHT
#define LCD_NATIVE_HEIGHT LCD_HEIGHT #define LCD_NATIVE_HEIGHT LCD_HEIGHT
@ -156,6 +155,11 @@ OUTPUT_FORMAT(elf32-littlemips)
#define DRAMORIG 0x09000000 + STUBOFFSET #define DRAMORIG 0x09000000 + STUBOFFSET
#endif #endif
#ifndef NOCACHE_BASE
/* Default to no offset if target doesn't define this */
#define NOCACHE_BASE 0x00000000
#endif
#define PLUGIN_LENGTH PLUGIN_BUFFER_SIZE #define PLUGIN_LENGTH PLUGIN_BUFFER_SIZE

View file

@ -826,6 +826,11 @@ Lyre prototype 1 */
#endif /* CPU_PP */ #endif /* CPU_PP */
#if CONFIG_CPU == IMX31L
#define NOCACHEBSS_ATTR __attribute__((section(".ncbss"),nocommon))
#define NOCACHEDATA_ATTR __attribute__((section(".ncdata"),nocommon))
#endif
#ifndef CONFIG_CORELOCK #ifndef CONFIG_CORELOCK
#define CONFIG_CORELOCK CORELOCK_NONE #define CONFIG_CORELOCK CORELOCK_NONE
#endif #endif

View file

@ -35,14 +35,18 @@
#define FRAME_SIZE (240*320*2) #define FRAME_SIZE (240*320*2)
/* Rockbox framebuffer address, not retail OS */ /* Rockbox framebuffer address, not retail OS */
#define FRAME_PHYS_ADDR (TTB_BASE_ADDR - FRAME_SIZE) #define FRAME_PHYS_ADDR (TTB_BASE_ADDR - FRAME_SIZE)
#define FRAME ((void *)(FRAME_PHYS_ADDR-CSD0_BASE_ADDR)) #define FRAME ((void *)(FRAME_PHYS_ADDR+0x100000-CSD0_BASE_ADDR))
#define CACHEALIGN_SIZE 32
#define NOCACHE_BASE CSD0_BASE_ADDR
#define DEVBSS_ATTR __attribute__((section(".devbss"),nocommon))
/* USBOTG */ /* USBOTG */
#define USB_QHARRAY_ATTR __attribute__((section(".qharray"),nocommon,aligned(2048))) #define USB_QHARRAY_ATTR __attribute__((section(".qharray"),nocommon,aligned(2048)))
#define USB_NUM_ENDPOINTS 8 #define USB_NUM_ENDPOINTS 8
#define USB_DEVBSS_ATTR DEVBSS_ATTR #define USB_DEVBSS_ATTR NOCACHEBSS_ATTR
#define USB_BASE OTG_BASE_ADDR #define USB_BASE OTG_BASE_ADDR
#define QHARRAY_SIZE ((64*USB_NUM_ENDPOINTS*2 + 2047) & (0xffffffff - 2047))
#define QHARRAY_PHYS_ADDR ((FRAME_PHYS_ADDR - QHARRAY_SIZE) & (0xffffffff - 2047))
/* /*
* AIPS 1 * AIPS 1

View file

@ -17,7 +17,8 @@ STARTUP(target/arm/imx31/crt0.o)
#include "imx31l.h" #include "imx31l.h"
/* Subtract 1MB for the FRAME/TTB section */ /* Subtract 1MB for the FRAME/TTB section */
#define DRAMSIZE (MEMORYSIZE * 0x100000 - 0x100000) - PLUGINSIZE - STUBOFFSET - CODECSIZE #define DRAMSIZE ((MEMORYSIZE * 0x100000) - STUBOFFSET - CODECSIZE - \
PLUGINSIZE - QHARRAY_SIZE - FRAME_SIZE - TTB_SIZE)
#define DRAMORIG (0x0 + STUBOFFSET) #define DRAMORIG (0x0 + STUBOFFSET)
/* #define IRAMORIG 0x1FFFC000 */ /* #define IRAMORIG 0x1FFFC000 */
@ -34,8 +35,7 @@ STARTUP(target/arm/imx31/crt0.o)
MEMORY MEMORY
{ {
DRAM : ORIGIN = DRAMORIG, LENGTH = DRAMSIZE DRAM : ORIGIN = DRAMORIG, LENGTH = DRAMSIZE
DEVBSS : ORIGIN = CSD0_BASE_ADDR + (MEMORYSIZE * 0x100000 - 0x100000), \ QHARRAY : ORIGIN = QHARRAY_PHYS_ADDR, LENGTH = QHARRAY_SIZE
LENGTH = 0x100000 - FRAME_SIZE - TTB_SIZE
} }
SECTIONS SECTIONS
@ -78,6 +78,17 @@ SECTIONS
_dataend = .; _dataend = .;
} > DRAM } > DRAM
#if 0 /* Unneeded at the moment */
/* .ncdata section is placed at uncached physical alias address and is
* loaded at the proper cached virtual address - no copying is
* performed in the init code */
.ncdata . + NOCACHE_BASE :
{
. = ALIGN(CACHEALIGN_SIZE); /* >= Cache line boundary */
*(.ncdata*)
. = ALIGN(CACHEALIGN_SIZE); /* >= Cache line boundary */
} AT> DRAM
#endif
/DISCARD/ : /DISCARD/ :
{ {
*(.eh_frame) *(.eh_frame)
@ -109,12 +120,22 @@ SECTIONS
*(.ibss) *(.ibss)
*(COMMON) *(COMMON)
. = ALIGN(0x4); . = ALIGN(0x4);
_end = .; } > DRAM
.ncbss . + NOCACHE_BASE (NOLOAD) :
{
. = ALIGN(CACHEALIGN_SIZE); /* >= Cache line boundary */
*(.ncbss*)
. = ALIGN(CACHEALIGN_SIZE); /* >= Cache line boundary */
} AT> DRAM
.endaddr . - NOCACHE_BASE (NOLOAD) :
{
_end = .;
} > DRAM } > DRAM
.audiobuf (NOLOAD) : .audiobuf (NOLOAD) :
{ {
. = ALIGN(0x4);
_audiobuffer = .; _audiobuffer = .;
audiobuffer = .; audiobuffer = .;
} > DRAM } > DRAM
@ -144,12 +165,11 @@ SECTIONS
_sdmacodeend = .; _sdmacodeend = .;
} }
.devbss (NOLOAD) : .qharray (NOLOAD) :
{ {
_devbssdata = .; _qharray = .;
*(.qharray) *(.qharray)
*(.devbss*) _qharrayend = .;
_devbssend = .; } > QHARRAY
} > DEVBSS
} }

View file

@ -249,17 +249,17 @@ static struct wakeup ata_dma_wakeup;
/** SDMA **/ /** SDMA **/
/* Array of buffer descriptors for large transfers and alignnment */ /* Array of buffer descriptors for large transfers and alignnment */
static struct buffer_descriptor ata_bda[ATA_BD_COUNT] DEVBSS_ATTR; static struct buffer_descriptor ata_bda[ATA_BD_COUNT] NOCACHEBSS_ATTR;
/* ATA channel descriptors */ /* ATA channel descriptors */
static struct channel_descriptor ata_cd_rd DEVBSS_ATTR; /* read channel */ static struct channel_descriptor ata_cd_rd NOCACHEBSS_ATTR; /* read channel */
static struct channel_descriptor ata_cd_wr DEVBSS_ATTR; /* write channel */ static struct channel_descriptor ata_cd_wr NOCACHEBSS_ATTR; /* write channel */
/* DMA channel to be started for transfer */ /* DMA channel to be started for transfer */
static unsigned int current_channel = 0; static unsigned int current_channel = 0;
/** Buffers **/ /** Buffers **/
/* Scatter buffer for first and last 32 bytes of a non cache-aligned transfer /* Scatter buffer for first and last 32 bytes of a non cache-aligned transfer
* to cached RAM. */ * to cached RAM. */
static uint32_t scatter_buffer[32/4*2] DEVBSS_ATTR; static uint32_t scatter_buffer[32/4*2] NOCACHEBSS_ATTR;
/* Address of ends in destination buffer for unaligned reads - copied after /* Address of ends in destination buffer for unaligned reads - copied after
* DMA completes. */ * DMA completes. */
static void *sb_dst[2] = { NULL, NULL }; static void *sb_dst[2] = { NULL, NULL };

View file

@ -19,8 +19,7 @@ STARTUP(target/arm/imx31/crt0.o)
MEMORY MEMORY
{ {
DRAM : ORIGIN = DRAMORIG, LENGTH = DRAMSIZE DRAM : ORIGIN = DRAMORIG, LENGTH = DRAMSIZE
DEVBSS : ORIGIN = CSD0_BASE_ADDR + (MEMORYSIZE*0x100000 - 0x100000), \ QHARRAY : ORIGIN = QHARRAY_PHYS_ADDR, LENGTH = QHARRAY_SIZE
LENGTH = 0x100000 - FRAME_SIZE - TTB_SIZE
} }
SECTIONS SECTIONS
@ -60,6 +59,18 @@ SECTIONS
_dataend = . ; _dataend = . ;
} > DRAM } > DRAM
#if 0 /* Unneeded at the moment */
/* .ncdata section is placed at uncached physical alias address and is
* loaded at the proper cached virtual address - no copying is
* performed in the init code */
.ncdata . + NOCACHE_BASE :
{
. = ALIGN(CACHEALIGN_SIZE); /* >= Cache line boundary */
*(.ncdata*)
. = ALIGN(CACHEALIGN_SIZE); /* >= Cache line boundary */
} AT> DRAM
#endif
.vectors 0x0 : .vectors 0x0 :
{ {
_vectorsstart = .; _vectorsstart = .;
@ -79,20 +90,33 @@ SECTIONS
stackend = .; stackend = .;
} > IRAM } > IRAM
/* .bss and .ncbss are treated as a single section to use one init loop to
* zero it - note "_edata" and "_end" */
.bss (NOLOAD) : .bss (NOLOAD) :
{ {
_edata = .; _edata = .;
*(.bss*); *(.bss*);
*(.ibss); *(.ibss);
*(COMMON) *(COMMON)
_end = .; . = ALIGN(0x4);
} > DRAM } > DRAM
.devbss (NOLOAD) : .ncbss . + NOCACHE_BASE (NOLOAD) :
{ {
_devbssdata = .; . = ALIGN(CACHEALIGN_SIZE); /* >= Cache line boundary */
*(.qharray) *(.ncbss*)
*(.devbss*) . = ALIGN(CACHEALIGN_SIZE); /* >= Cache line boundary */
_devbssend = .; } AT> DRAM
} > DEVBSS
.endaddr . - NOCACHE_BASE (NOLOAD) :
{
_end = .;
} > DRAM
.qharray (NOLOAD) :
{
_qharray = .;
*(.qharray)
_qharrayend = .;
} > QHARRAY
} }

View file

@ -134,7 +134,8 @@ remap_start:
/* Set page tables */ /* Set page tables */
/* Map each memory loc to itself, no cache */ /* Map each memory loc to itself
* not cached, not buffered */
/* Physical address = 0x0 */ /* Physical address = 0x0 */
mov r1, #(1 << 10) /* superuser - r/w, user - no access */ mov r1, #(1 << 10) /* superuser - r/w, user - no access */
orr r1, r1, #((0 << 5) | /* domain 0th */ \ orr r1, r1, #((0 << 5) | /* domain 0th */ \
@ -148,26 +149,27 @@ remap_start:
cmp r2, r3 cmp r2, r3
blo 1b blo 1b
bic r1, r1, #0x0ff00000 /* Back up */ /* Bits 31:20 of r1 will be 0 due to wraparound in previous loop */
/* Map 0x80000000 -> 0x0, cached */ /* Map PA:0x80000000-0x83ffffff to VA:0x00000000-0x03f00000
mov r2, r5 /* TTB pointer */ * cached, buffered */
add r3, r5, #64*4 /* End position */ mov r2, r5 /* TTB pointer */
orr r1, r1, #0x80000000 /* Physical address */ add r3, r5, #64*4 /* End position */
orr r1, r1, #((1 << 3) | /* cache flag */ \ orr r1, r1, #(0x80000000 | /* Physical address */ \
(1 << 2)) /* buffer flag */ (1 << 3) | /* cache flag */ \
(1 << 2)) /* buffer flag */
1: 1:
str r1, [r2], #4 str r1, [r2], #4
add r1, r1, #(1 << 20) add r1, r1, #(1 << 20)
cmp r2, r3 cmp r2, r3
blo 1b blo 1b
/* Map device section 0x83f00000 to 0x03f00000 - buffered, not cached */ /* Map TTB, FRAME and QHARRAY section PA:0x83f00000-0x83ffffff to
bic r1, r1, #0x0ff00000 * VA:0x04000000-0x040fffff
orr r1, r1, #0x03f00000 * not cache, buffered */
bic r1, r1, #(1 << 3) sub r1, r1, #0x00100000
add r2, r5, #63*4 bic r1, r1, #(1 << 3) /* clear cache flag */
str r1, [r2] str r1, [r5, #64*4]
/* Enable MMU */ /* Enable MMU */
mov r0, #0 mov r0, #0
@ -249,7 +251,7 @@ remap_end:
bl clean_dcache_range bl clean_dcache_range
#endif /* BOOTLOADER */ #endif /* BOOTLOADER */
/* Initialise bss section to zero */ /* Initialise bss and ncbss sections to zero */
ldr r2, =_edata ldr r2, =_edata
ldr r3, =_end ldr r3, =_end
mov r4, #0 mov r4, #0
@ -258,15 +260,6 @@ remap_end:
strhi r4, [r2], #4 strhi r4, [r2], #4
bhi 1b bhi 1b
/* Initialise the device bss section to zero */
ldr r2, =_devbssdata
ldr r3, =_devbssend
mov r4, #0
1:
cmp r3, r2
strhi r4, [r2], #4
bhi 1b
/* Set up some stack and munge it with 0xdeadbeef */ /* Set up some stack and munge it with 0xdeadbeef */
ldr sp, =stackend ldr sp, =stackend
ldr r2, =stackbegin ldr r2, =stackbegin

View file

@ -32,8 +32,8 @@
#define DMA_PLAY_CH_PRIORITY 6 #define DMA_PLAY_CH_PRIORITY 6
#define DMA_REC_CH_PRIORITY 6 #define DMA_REC_CH_PRIORITY 6
static struct buffer_descriptor dma_play_bd DEVBSS_ATTR; static struct buffer_descriptor dma_play_bd NOCACHEBSS_ATTR;
static struct channel_descriptor dma_play_cd DEVBSS_ATTR; static struct channel_descriptor dma_play_cd NOCACHEBSS_ATTR;
struct dma_data struct dma_data
{ {
@ -315,7 +315,7 @@ void pcm_play_dma_pause(bool pause)
/* Return the number of bytes waiting - full L-R sample pairs only */ /* Return the number of bytes waiting - full L-R sample pairs only */
size_t pcm_get_bytes_waiting(void) size_t pcm_get_bytes_waiting(void)
{ {
static unsigned long dsa DEVBSS_ATTR; static unsigned long dsa NOCACHEBSS_ATTR;
long offs, size; long offs, size;
int oldstatus; int oldstatus;
@ -339,7 +339,7 @@ size_t pcm_get_bytes_waiting(void)
/* Return a pointer to the samples and the number of them in *count */ /* Return a pointer to the samples and the number of them in *count */
const void * pcm_play_dma_get_peak_buffer(int *count) const void * pcm_play_dma_get_peak_buffer(int *count)
{ {
static unsigned long dsa DEVBSS_ATTR; static unsigned long dsa NOCACHEBSS_ATTR;
unsigned long addr; unsigned long addr;
long offs, size; long offs, size;
int oldstatus; int oldstatus;
@ -370,8 +370,8 @@ void * pcm_dma_addr(void *addr)
} }
#ifdef HAVE_RECORDING #ifdef HAVE_RECORDING
static struct buffer_descriptor dma_rec_bd DEVBSS_ATTR; static struct buffer_descriptor dma_rec_bd NOCACHEBSS_ATTR;
static struct channel_descriptor dma_rec_cd DEVBSS_ATTR; static struct channel_descriptor dma_rec_cd NOCACHEBSS_ATTR;
static struct dma_data dma_rec_data = static struct dma_data dma_rec_data =
{ {
@ -526,7 +526,7 @@ void pcm_rec_dma_init(void)
const void * pcm_rec_dma_get_peak_buffer(int *count) const void * pcm_rec_dma_get_peak_buffer(int *count)
{ {
static unsigned long pda DEVBSS_ATTR; static unsigned long pda NOCACHEBSS_ATTR;
unsigned long buf, addr, end, bufend; unsigned long buf, addr, end, bufend;
int oldstatus; int oldstatus;

View file

@ -40,9 +40,9 @@ static struct sdma_script_start_addrs script_info;
/* Mask of channels with callback enabled */ /* Mask of channels with callback enabled */
static unsigned long sdma_enabled_ints = 0; static unsigned long sdma_enabled_ints = 0;
/* One channel control block per channel in physically mapped device RAM */ /* One channel control block per channel in physically mapped device RAM */
static struct channel_control_block ccb_array[CH_NUM] DEVBSS_ATTR; static struct channel_control_block ccb_array[CH_NUM] NOCACHEBSS_ATTR;
/* Channel 0 (command channel) data */ /* Channel 0 (command channel) data */
static struct buffer_descriptor_extd c0_buffer_desc DEVBSS_ATTR; static struct buffer_descriptor_extd c0_buffer_desc NOCACHEBSS_ATTR;
/* All SDMA channel interrupts are handled here. /* All SDMA channel interrupts are handled here.
* Dispatches lower channel numbers first (prioritized by SDMA API callers * Dispatches lower channel numbers first (prioritized by SDMA API callers