V850 patches
Savin Zlobec
savin@torina.fe.uni-lj.si
Sun Mar 30 16:40:00 GMT 2003
Hi,
I have attached some patches for v850 hal.
Here is what they do:
v850_p1.diff - adds a CYGNUM_HAL_V85X_INITIAL_STACK_SIZE cdl option
for controlling the size of startup stack. Fixes the
CYGSEM_HAL_NEC_INLINE_INTERRUPT_FUNCTIONS <->
CYGSEM_HAL_V85X_INLINE_INTERRUPT_FUNCTIONS typo.
v850_p2.diff - fixes the __skipinst function in v850_stub (the
breakpoint inst on v850 is a "br *" and next_pc
won't skip it) and adds the 2ram section in linker
script.
v850_p3.diff - adds the hal_delay_us function and RedBoot hal options
cdl component to ceb platform (I don't have the ceb platform
so this patch is untested - but should work on any
v850SA1/v850SB1 platform).
NOTE: for RedBoot to work on ceb the size of reserved RAM should be
increased in MLT RAM files.
savin
-------------- next part --------------
Index: current/cdl/hal_v85x.cdl
===================================================================
RCS file: /cvs/ecos/ecos/packages/hal/v85x/arch/current/cdl/hal_v85x.cdl,v
retrieving revision 1.5
diff -u -5 -r1.5 hal_v85x.cdl
--- current/cdl/hal_v85x.cdl 23 May 2002 23:05:33 -0000 1.5
+++ current/cdl/hal_v85x.cdl 30 Mar 2003 15:48:37 -0000
@@ -96,10 +96,20 @@
e.g. HAL_ENABLE_INTERRUPTS() to be coded as either in-line
assembly code or real functions. The primary motivations
for the latter would be debugging, tracing, etc."
}
+ cdl_option CYGNUM_HAL_V85X_INITIAL_STACK_SIZE {
+ display "Initial stack size"
+ flavor data
+ default_value { CYGPKG_REDBOOT ? 4096 : 1024 }
+ legal_values 1024 to 1048576
+ description "
+ This configuration option specifies the initial stack size in
+ bytes."
+ }
+
cdl_interface CYGINT_HAL_V85X_ICE_DEBUG {
display "Debugging via ICE support"
description "
This interface is enabled when the underlying variant or platform
supports ICE debugging."
Index: current/include/hal_intr.h
===================================================================
RCS file: /cvs/ecos/ecos/packages/hal/v85x/arch/current/include/hal_intr.h,v
retrieving revision 1.5
diff -u -5 -r1.5 hal_intr.h
--- current/include/hal_intr.h 23 May 2002 23:05:35 -0000 1.5
+++ current/include/hal_intr.h 30 Mar 2003 15:48:40 -0000
@@ -99,11 +99,11 @@
externC cyg_uint32 hal_disable_interrupts(void);
externC void hal_enable_interrupts(void);
externC void hal_restore_interrupts(cyg_uint32);
externC cyg_uint32 hal_query_interrupts(void);
-#ifdef CYGSEM_HAL_NEC_INLINE_INTERRUPT_FUNCTIONS
+#ifdef CYGSEM_HAL_V85X_INLINE_INTERRUPT_FUNCTIONS
#define HAL_DISABLE_INTERRUPTS(_old_) \
CYG_MACRO_START \
asm volatile ( \
"stsr PSW,%0;" \
"di" \
Index: current/src/vectors.S
===================================================================
RCS file: /cvs/ecos/ecos/packages/hal/v85x/arch/current/src/vectors.S,v
retrieving revision 1.13
diff -u -5 -r1.13 vectors.S
--- current/src/vectors.S 23 May 2002 23:05:36 -0000 1.13
+++ current/src/vectors.S 30 Mar 2003 15:48:42 -0000
@@ -533,11 +533,11 @@
// Don't process NMIs
lea __allow_nmi,r1
st.w r0,0[r1]
jmp [r0] // Restart machine
-#if !defined(CYGSEM_HAL_NEC_INLINE_INTERRUPT_FUNCTIONS)
+#if !defined(CYGSEM_HAL_V85X_INLINE_INTERRUPT_FUNCTIONS)
.globl _hal_disable_interrupts
_hal_disable_interrupts:
stsr PSW,r10
di
jmp [lp]
@@ -597,11 +597,11 @@
#endif // if CYGINT_HAL_V85X_ICE_DEBUG
#endif // if defined(CYG_HAL_STARTUP_ROM) || defined(CYG_HAL_STARTUP_ROMRAM)
.data
// Initial stack
- .rept 1024
+ .rept CYGNUM_HAL_V85X_INITIAL_STACK_SIZE
.byte 0
.endr
__startup_stack:
#ifndef CYGNUM_HAL_COMMON_INTERRUPTS_STACK_SIZE
-------------- next part --------------
Index: current/src/v850_stub.c
===================================================================
RCS file: /cvs/ecos/ecos/packages/hal/v85x/v850/current/src/v850_stub.c,v
retrieving revision 1.6
diff -u -5 -r1.6 v850_stub.c
--- current/src/v850_stub.c 23 May 2002 23:05:44 -0000 1.6
+++ current/src/v850_stub.c 30 Mar 2003 15:49:01 -0000
@@ -309,16 +309,17 @@
}
/* Skip the current instruction. Since this is only called by the
stub when the PC points to a breakpoint or trap instruction,
+ we can safely just skip 1.
*/
void __skipinst (void)
{
unsigned short *pc = (unsigned short *)get_register(PC);
- pc = next_pc(pc);
+ pc++;
put_register(PC, (unsigned long)pc);
}
#endif // CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS
Index: current/src/v85x_v850.ld
===================================================================
RCS file: /cvs/ecos/ecos/packages/hal/v85x/v850/current/src/v85x_v850.ld,v
retrieving revision 1.6
diff -u -5 -r1.6 v85x_v850.ld
--- current/src/v85x_v850.ld 23 May 2002 23:05:45 -0000 1.6
+++ current/src/v85x_v850.ld 30 Mar 2003 15:49:01 -0000
@@ -124,11 +124,12 @@
_GOT2_START_ = ABSOLUTE (.); *(.got2) _GOT2_END_ = ABSOLUTE (.); \
. = ALIGN (4); \
KEEP(*( SORT (.ecos.table.*))) ; \
___CTOR_LIST__ = ABSOLUTE (.); KEEP (*(SORT (.ctors*))) ___CTOR_END__ = ABSOLUTE (.); \
___DTOR_LIST__ = ABSOLUTE (.); KEEP (*(SORT (.dtors*))) ___DTOR_END__ = ABSOLUTE (.); \
- *(.dynamic) *(.sdata*) *(.sbss*) } \
+ *(.dynamic) *(.sdata*) *(.sbss*) \
+ . = ALIGN (4); *(.2ram.*) } \
> _region_ \
___rom_data_start = LOADADDR (.data); \
___ram_data_end = .; PROVIDE (___ram_data_end = .); _edata = .; PROVIDE (edata = .); \
PROVIDE (___rom_data_end = LOADADDR (.data) + SIZEOF(.data));
-------------- next part --------------
Index: current/cdl/hal_v85x_ceb_v850.cdl
===================================================================
RCS file: /cvs/ecos/ecos/packages/hal/v85x/ceb_v850/current/cdl/hal_v85x_ceb_v850.cdl,v
retrieving revision 1.12
diff -u -5 -r1.12 hal_v85x_ceb_v850.cdl
--- current/cdl/hal_v85x_ceb_v850.cdl 23 May 2002 23:05:37 -0000 1.12
+++ current/cdl/hal_v85x_ceb_v850.cdl 30 Mar 2003 15:51:07 -0000
@@ -360,6 +360,34 @@
i.e. applications will be loaded into RAM on the board, and this
ROM monitor may process exceptions or interrupts generated from the
application. This enables features such as utilizing a separate
interrupt stack when exceptions are generated."
}
+
+ cdl_component CYGPKG_REDBOOT_HAL_OPTIONS {
+ display "Redboot HAL options"
+ flavor none
+ no_define
+ parent CYGPKG_REDBOOT
+ active_if CYGPKG_REDBOOT
+ description "
+ This option lists the target's requirements for a valid Redboot
+ configuration."
+
+ cdl_option CYGBLD_BUILD_REDBOOT_BIN {
+ display "Build Redboot ROM binary image"
+ active_if CYGBLD_BUILD_REDBOOT
+ default_value 1
+ no_define
+ description "This option enables the conversion of the Redboot ELF
+ image to a binary image suitable for ROM programming."
+
+ compile -library=libextras.a
+
+ make -priority 325 {
+ <PREFIX>/bin/redboot.srec : <PREFIX>/bin/redboot.elf
+ $(OBJCOPY) --strip-all $< $(@:.srec=.img)
+ $(OBJCOPY) -O srec $< $@
+ }
+ }
+ }
}
Index: current/include/plf_intr.h
===================================================================
RCS file: /cvs/ecos/ecos/packages/hal/v85x/ceb_v850/current/include/plf_intr.h,v
retrieving revision 1.6
diff -u -5 -r1.6 plf_intr.h
--- current/include/plf_intr.h 23 May 2002 23:05:39 -0000 1.6
+++ current/include/plf_intr.h 30 Mar 2003 15:51:07 -0000
@@ -58,10 +58,13 @@
//
//####DESCRIPTIONEND####
//
//==========================================================================
-// Nothing to do here. Handled by default variant code.
+// Microsecond delay function provided in plf_misc.c
+externC void hal_delay_us(int us);
+
+#define HAL_DELAY_US(n) hal_delay_us(n)
//--------------------------------------------------------------------------
#endif // ifndef CYGONCE_HAL_PLF_INTR_H
// End of plf_intr.h
Index: current/src/plf_misc.c
===================================================================
RCS file: /cvs/ecos/ecos/packages/hal/v85x/ceb_v850/current/src/plf_misc.c,v
retrieving revision 1.6
diff -u -5 -r1.6 plf_misc.c
--- current/src/plf_misc.c 23 May 2002 23:05:40 -0000 1.6
+++ current/src/plf_misc.c 30 Mar 2003 15:51:08 -0000
@@ -72,10 +72,18 @@
extern void show_led(int p);
void
cyg_hal_platform_hardware_init(void)
{
+
+#ifdef CYGPKG_REDBOOT
+ // Start the timer device if we are in a RedBoot
+ // configuration.
+
+ HAL_CLOCK_INITIALIZE(CYGNUM_HAL_RTC_PERIOD);
+#endif
+
hal_if_init(); // Initialize GDB[ROM]/eCos interfaces
show_led(' ');
show_led(' ');
}
@@ -300,11 +308,62 @@
{
volatile unsigned short *timer = (volatile unsigned short *)V850_REG_TM1;
return (cyg_uint32)*timer;
}
-
+//
+// Delay for a us microseconds
+//
+void
+hal_delay_us(int us)
+{
+ volatile unsigned short *timer = (volatile unsigned short *)V850_REG_TM1;
+ cyg_uint32 val1, val2;
+ int diff;
+ long usticks;
+ long ticks;
+
+ // Calculate the number of counter register ticks per microsecond.
+ usticks = (CYGNUM_HAL_RTC_PERIOD * CYGNUM_HAL_RTC_DENOMINATOR) / 1000000;
+
+ // Make sure that the value is not zero.
+ if (usticks == 0)
+ usticks = 1;
+
+ while (us > 0)
+ {
+ int us1 = us;
+
+ // Wait in bursts of less than 10000us to avoid any overflow
+ // problems in the multiply.
+ if (us1 > 10000)
+ us1 = 10000;
+
+ us -= us1;
+
+ ticks = us1 * usticks;
+
+ val1 = *timer;
+
+ while (ticks > 0)
+ {
+ do
+ {
+ val2 = *timer;
+ }
+ while (val1 == val2);
+
+ diff = val2 - val1;
+
+ if (diff < 0)
+ diff += CYGNUM_HAL_RTC_PERIOD;
+ ticks -= diff;
+ val1 = val2;
+ }
+ }
+}
+
extern void _hal_thread_load_context(HAL_SavedRegisters **to)
CYGBLD_ATTRIB_NORET;
extern void _hal_thread_switch_context(HAL_SavedRegisters **to, HAL_SavedRegisters **from);
void hal_thread_load_context(CYG_ADDRESS to)
More information about the Ecos-patches
mailing list