From 7914e90738ff37e6378b37632eb1f05bab7354d5 Mon Sep 17 00:00:00 2001 From: Michael Sevakis Date: Fri, 28 Sep 2007 10:20:02 +0000 Subject: Commit a subset of the dual core changes that have to do with cache handling, stacks, firmware startup and thread startup. Tested on e200, H10-20GB, iPod Color and 5.5G. Thread function return implemented for all targets. Some changes to plugins to follow shortly. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@14879 a1c6a512-1295-4272-9138-f99709370657 --- firmware/export/config.h | 8 +++---- firmware/export/kernel.h | 8 ------- firmware/export/pp5020.h | 25 +++++++++++---------- firmware/export/thread.h | 57 +++++++++++++++++++++++------------------------- 4 files changed, 44 insertions(+), 54 deletions(-) (limited to 'firmware/export') diff --git a/firmware/export/config.h b/firmware/export/config.h index 40d1c168a3..9346abbdc9 100644 --- a/firmware/export/config.h +++ b/firmware/export/config.h @@ -372,10 +372,10 @@ #define NOCACHEBSS_ATTR IBSS_ATTR #define NOCACHEDATA_ATTR IDATA_ATTR -#define IF_COP(empty, x, y) , x, y +#define IF_COP(...) __VA_ARGS__ -/* Defines for inter-core messaging */ -#define COP_REBOOT 1 +#define IDLE_STACK_SIZE 0x80 +#define IDLE_STACK_WORDS 0x20 #else #define NUM_CORES 1 @@ -383,7 +383,7 @@ #define NOCACHEBSS_ATTR #define NOCACHEDATA_ATTR -#define IF_COP(empty, x, y) +#define IF_COP(...) #endif /* Processor specific */ diff --git a/firmware/export/kernel.h b/firmware/export/kernel.h index 50c9bdc0ae..8d7ca95184 100644 --- a/firmware/export/kernel.h +++ b/firmware/export/kernel.h @@ -94,9 +94,6 @@ struct event_queue struct thread_entry *thread; unsigned int read; unsigned int write; -#if NUM_CORES > 1 - bool irq_safe; -#endif #ifdef HAVE_EXTENDED_MESSAGING_AND_NAME struct queue_sender_list *send; #endif @@ -153,11 +150,6 @@ void timeout_register(struct timeout *tmo, timeout_cb_type callback, void timeout_cancel(struct timeout *tmo); extern void queue_init(struct event_queue *q, bool register_queue); -#if NUM_CORES > 1 -extern void queue_set_irq_safe(struct event_queue *q, bool state); -#else -#define queue_set_irq_safe(q,state) -#endif extern void queue_delete(struct event_queue *q); extern void queue_wait(struct event_queue *q, struct event *ev); extern void queue_wait_w_tmo(struct event_queue *q, struct event *ev, int ticks); diff --git a/firmware/export/pp5020.h b/firmware/export/pp5020.h index b2c7f4d0d2..5da2061798 100644 --- a/firmware/export/pp5020.h +++ b/firmware/export/pp5020.h @@ -118,18 +118,18 @@ #define DEV_RS (*(volatile unsigned long *)(0x60006004)) #define DEV_EN (*(volatile unsigned long *)(0x6000600c)) -#define DEV_SYSTEM 0x4 -#define DEV_SER0 0x40 -#define DEV_SER1 0x80 -#define DEV_I2S 0x800 -#define DEV_I2C 0x1000 -#define DEV_ATA 0x4000 -#define DEV_OPTO 0x10000 -#define DEV_PIEZO 0x10000 -#define DEV_USB 0x400000 -#define DEV_FIREWIRE 0x800000 -#define DEV_IDE0 0x2000000 -#define DEV_LCD 0x4000000 +#define DEV_SYSTEM 0x00000004 +#define DEV_SER0 0x00000040 +#define DEV_SER1 0x00000080 +#define DEV_I2S 0x00000800 +#define DEV_I2C 0x00001000 +#define DEV_ATA 0x00004000 +#define DEV_OPTO 0x00010000 +#define DEV_PIEZO 0x00010000 +#define DEV_USB 0x00400000 +#define DEV_FIREWIRE 0x00800000 +#define DEV_IDE0 0x02000000 +#define DEV_LCD 0x04000000 /* clock control */ #define CLOCK_SOURCE (*(volatile unsigned long *)(0x60006020)) @@ -174,6 +174,7 @@ #define CACHE_DISABLE 0 #define CACHE_ENABLE 1 +#define CACHE_RUN 2 #define CACHE_INIT 4 /* GPIO Ports */ diff --git a/firmware/export/thread.h b/firmware/export/thread.h index 19bf9e12fc..e16baa2256 100644 --- a/firmware/export/thread.h +++ b/firmware/export/thread.h @@ -50,32 +50,32 @@ #ifndef SIMULATOR /* Need to keep structures inside the header file because debug_menu * needs them. */ -# ifdef CPU_COLDFIRE +#ifdef CPU_COLDFIRE struct regs { - unsigned int macsr; /* EMAC status register */ - unsigned int d[6]; /* d2-d7 */ - unsigned int a[5]; /* a2-a6 */ - void *sp; /* Stack pointer (a7) */ - void *start; /* Thread start address, or NULL when started */ -}; -# elif CONFIG_CPU == SH7034 + unsigned int macsr; /* 0 - EMAC status register */ + unsigned int d[6]; /* 4-24 - d2-d7 */ + unsigned int a[5]; /* 28-44 - a2-a6 */ + void *sp; /* 48 - Stack pointer (a7) */ + void *start; /* 52 - Thread start address, or NULL when started */ +} __attribute__((packed)); +#elif CONFIG_CPU == SH7034 struct regs { - unsigned int r[7]; /* Registers r8 thru r14 */ - void *sp; /* Stack pointer (r15) */ - void *pr; /* Procedure register */ - void *start; /* Thread start address, or NULL when started */ -}; -# elif defined(CPU_ARM) + unsigned int r[7]; /* 0-24 - Registers r8 thru r14 */ + void *sp; /* 28 - Stack pointer (r15) */ + void *pr; /* 32 - Procedure register */ + void *start; /* 36 - Thread start address, or NULL when started */ +} __attribute__((packed)); +#elif defined(CPU_ARM) struct regs { - unsigned int r[8]; /* Registers r4-r11 */ - void *sp; /* Stack pointer (r13) */ - unsigned int lr; /* r14 (lr) */ - void *start; /* Thread start address, or NULL when started */ -}; -# endif + unsigned int r[8]; /* 0-28 - Registers r4-r11 */ + void *sp; /* 32 - Stack pointer (r13) */ + unsigned int lr; /* 36 - r14 (lr) */ + void *start; /* 40 - Thread start address, or NULL when started */ +} __attribute__((packed)); +#endif /* CONFIG_CPU */ #else struct regs { @@ -140,9 +140,9 @@ struct core_entry { }; #ifdef HAVE_PRIORITY_SCHEDULING -#define IF_PRIO(empty, type) , type +#define IF_PRIO(...) __VA_ARGS__ #else -#define IF_PRIO(empty, type) +#define IF_PRIO(...) #endif /* PortalPlayer chips have 2 cores, therefore need atomic mutexes @@ -197,14 +197,6 @@ struct core_entry { }) #endif -#if NUM_CORES > 1 -inline void lock_cores(void); -inline void unlock_cores(void); -#else -#define lock_cores(...) -#define unlock_cores(...) -#endif - struct thread_entry* create_thread(void (*function)(void), void* stack, int stack_size, const char *name IF_PRIO(, int priority) @@ -239,7 +231,12 @@ void priority_yield(void); struct thread_entry * thread_get_current(void); void init_threads(void); int thread_stack_usage(const struct thread_entry *thread); +#if NUM_CORES > 1 +int idle_stack_usage(unsigned int core); +#endif int thread_get_status(const struct thread_entry *thread); +void thread_get_name(char *buffer, int size, + struct thread_entry *thread); #ifdef RB_PROFILE void profile_thread(void); #endif -- cgit v1.2.3