]> rtime.felk.cvut.cz Git - sysless.git/commitdiff
Provide alternative memory reservation from USB RAM on LPC17xx.
authorPavel Pisa <pisa@cmp.felk.cvut.cz>
Sun, 26 Sep 2010 08:38:18 +0000 (10:38 +0200)
committerPavel Pisa <pisa@cmp.felk.cvut.cz>
Sun, 26 Sep 2010 08:38:18 +0000 (10:38 +0200)
The lpc_reserve_usb_ram() serves to runtime reserve
memory in USB RAM area after linker allocated variables.
There is no mechanism to release memory allocated
by by lpc_reserve_usb_ram(). Mechanism is provided
for one time reservation at application startup.

The uLAN driver and DOGXL display drivers can
be instructed to use this kind of allocation
by inclussion of next lines in application program.

  #include <hal_machperiph.h>

  void *(* const gr_driver_reserve_ram)(size_t size) =
lpc_reserve_usb_ram;

  void *(* const ul_drv_reserve_ram)(size_t size) =
lpc_reserve_usb_ram;

Signed-off-by: Pavel Pisa <pisa@cmp.felk.cvut.cz>
arch/arm/mach-lpc17xx/libs/hal/Makefile.omk
arch/arm/mach-lpc17xx/libs/hal/hal_machperiph.h
arch/arm/mach-lpc17xx/libs/hal/hal_reserve_usb_ram.c [new file with mode: 0644]
board/arm/lpc17xx-common/defines/system_def-lmc1.h
board/arm/lpc17xx-common/libs/ldscripts/lpc17xx-base.ld-app
board/arm/lpc17xx-common/libs/ldscripts/lpc17xx-base.ld-boot

index 3ccd3147be74cb2516afcfde306af4e5a14fe35e..7d210f0dfed9608837736c7a7c50f0b811c5fa69 100644 (file)
@@ -4,7 +4,7 @@ lib_LIBRARIES = mach_hal
 
 include_HEADERS = hal_machperiph.h
 
-mach_hal_SOURCES = hal.c startup.c hal_machperiph.c
+mach_hal_SOURCES = hal.c startup.c hal_machperiph.c hal_reserve_usb_ram.c
 
 
 
index 0b7c5af12f14121b88ecd7dbff9a2a5bc1b6b9d4..aadc41d24bf4dbbbd3a577482e058e20c25a0d12 100644 (file)
@@ -8,6 +8,7 @@ void system_clock_init(void);
 
 void lpc_watchdog_init(int on,int timeout_ms);
 void lpc_watchdog_feed();
+void *lpc_reserve_usb_ram(unsigned long size);
 
 #endif /* _HAL_MACHPERIPH_H */
 
diff --git a/arch/arm/mach-lpc17xx/libs/hal/hal_reserve_usb_ram.c b/arch/arm/mach-lpc17xx/libs/hal/hal_reserve_usb_ram.c
new file mode 100644 (file)
index 0000000..43ce840
--- /dev/null
@@ -0,0 +1,21 @@
+#include <stdint.h>
+#include <string.h>
+#include <hal_machperiph.h>
+
+extern char _eusbram;
+
+void *lpc_reserve_usb_ram(unsigned long size)
+{
+  static char *usb_ram_avail=&_eusbram;
+  char *prev_avail;
+
+  /*printf("usb reserve %lu at 0x%lx\n",size,(unsigned long)usb_ram_avail);*/
+
+  if(!usb_ram_avail)
+    return NULL;
+
+  prev_avail=(char *)(((uintptr_t)usb_ram_avail+3)&~3);
+  usb_ram_avail=prev_avail+size;
+
+  return prev_avail;
+}
\ No newline at end of file
index 873ca5a7670062c259354baa4fb01e40372e927e..ccc51baa1e8a8eef6bee3ab75af5afcfa1a7bd34 100644 (file)
 
 #ifdef ULD_DEFAULT_BUFFER_SIZE
   #undef ULD_DEFAULT_BUFFER_SIZE
-  #define ULD_DEFAULT_BUFFER_SIZE 0x0800
+  #define ULD_DEFAULT_BUFFER_SIZE 0x2000
 #endif
 
 #define UL_DRV_SYSLESS_PORT UART1_BASE
index 91b4571c0be44c6178b9a848fc9f0e3b4b93cdd4..d3b7bb4f0ed9ce36f41167c983266c0ef961d4dc 100644 (file)
@@ -94,9 +94,13 @@ SECTIONS
 
        /******************************************/
        /* This used for USB RAM section */
-       .usb_ram (NOLOAD):
+       .usbram (NOLOAD):
        {
-               *.o (USB_RAM)
+               _usbram = . ;
+               *(.usbram)
+               . = ALIGN(4);
+               _eusbram = . ;
+               _usbram_end = . ;
        } > IRAM1
 
         /******************************************/
index 601b4a1921c9cb09e77ff3e44867e26b17273922..b2c64fa863fba493dfc23aa3a6604851b73e1770 100644 (file)
@@ -94,9 +94,13 @@ SECTIONS
 
        /******************************************/
        /* This used for USB RAM section */
-       .usb_ram (NOLOAD):
+       .usbram (NOLOAD):
        {
-               *.o (USB_RAM)
+               _usbram = . ;
+               *(.usbram)
+               . = ALIGN(4);
+               _eusbram = . ;
+               _usbram_end = . ;
        } > IRAM1
 
         /******************************************/