From: bernie Date: Sun, 3 Oct 2004 20:43:22 +0000 (+0000) Subject: Import changes from sc/firmware. X-Git-Tag: 1.0.0~1009 X-Git-Url: https://codewiz.org/gitweb?a=commitdiff_plain;h=0d0eaf2e43aff60f23a662b9ea32525a1eb9fb79;p=bertos.git Import changes from sc/firmware. git-svn-id: https://src.develer.com/svnoss/bertos/trunk@232 38d2e660-2303-0410-9eaa-f027e97ec537 --- diff --git a/drv/ser_dsp56k.c b/drv/ser_dsp56k.c index a5a96fb7..dccc806a 100755 --- a/drv/ser_dsp56k.c +++ b/drv/ser_dsp56k.c @@ -15,6 +15,9 @@ /*#* *#* $Log$ + *#* Revision 1.6 2004/10/03 20:43:22 bernie + *#* Import changes from sc/firmware. + *#* *#* Revision 1.5 2004/08/25 14:12:08 rasky *#* Aggiornato il comment block dei log RCS *#* @@ -26,15 +29,14 @@ *#* *#* Revision 1.2 2004/05/23 18:21:53 bernie *#* Trim CVS logs and cleanup header info. - *#* *#*/ #include "ser.h" #include "ser_p.h" -#include #include +#include #include -#include +#include // GPIO E is shared with SPI (in DSP56807). Pins 0&1 are TXD0 and RXD0. To use // the serial, we need to disable the GPIO functions on them. diff --git a/kern/proc.c b/kern/proc.c index db3cf50d..975278b4 100755 --- a/kern/proc.c +++ b/kern/proc.c @@ -17,6 +17,9 @@ /*#* *#* $Log$ + *#* Revision 1.16 2004/10/03 20:39:28 bernie + *#* Import changes from sc/firmware. + *#* *#* Revision 1.15 2004/09/20 03:29:39 bernie *#* C++ fixes. *#* @@ -110,96 +113,6 @@ extern List StackFreeList; struct Process MainProcess; -#if CONFIG_KERN_MONITOR -List MonitorProcs; - -static void monitor_init(void) -{ - INITLIST(&MonitorProcs); -} - -static void monitor_add(Process* proc, const char* name, cpustack_t* stack_base, size_t stack_size) -{ - proc->monitor.name = name; - proc->monitor.stack_base = stack_base; - proc->monitor.stack_size = stack_size; - - ADDTAIL(&MonitorProcs, &proc->monitor.link); -} - -static void monitor_remove(Process* proc) -{ - REMOVE(&proc->monitor.link); -} - -#define MONITOR_NODE_TO_PROCESS(node) \ - (struct Process*)((char*)(node) - offsetof(struct Process, monitor.link)) - -size_t monitor_check_stack(cpustack_t* stack_base, size_t stack_size) -{ - cpustack_t* beg; - cpustack_t* cur; - cpustack_t* end; - size_t sp_free; - - beg = stack_base; - end = stack_base + stack_size / sizeof(cpustack_t) - 1; - - if (CPU_STACK_GROWS_UPWARD) - { - cur = beg; - beg = end; - end = cur; - } - - cur = beg; - while (cur != end) - { - if (*cur != CONFIG_KERN_STACKFILLCODE) - break; - - if (CPU_STACK_GROWS_UPWARD) - cur--; - else - cur++; - } - - sp_free = ABS(cur - beg) * sizeof(cpustack_t); - return sp_free; -} - -#if CONFIG_KERN_MONITOR - -void monitor_debug_stacks(void) -{ - struct Process* p; - int i; - - if (ISLISTEMPTY(&MonitorProcs)) - { - kputs("No stacks registered in the monitor\n"); - return; - } - - kprintf("%-24s %-6s%-8s%-8s%-8s\n", "Process name", "TCB", "SPbase", "SPsize", "SPfree"); - for (i=0;i<56;i++) - kputchar('-'); - kputchar('\n'); - - for (p = MONITOR_NODE_TO_PROCESS(MonitorProcs.head); - p->monitor.link.succ; - p = MONITOR_NODE_TO_PROCESS(p->monitor.link.succ)) - { - size_t free = monitor_check_stack(p->monitor.stack_base, p->monitor.stack_size); - kprintf("%-24s %04x %04x %4x %4x\n", p->monitor.name, (uint16_t)p, (uint16_t)p->monitor.stack_base, (uint16_t)p->monitor.stack_size, (uint16_t)free); - } -} - -#endif /* CONFIG_KERN_MONITOR */ - -#endif - - static void proc_init_struct(Process* proc) { /* Avoid warning for unused argument */ @@ -469,6 +382,8 @@ IPTR proc_current_user_data(void) #if 0 /* Simple testcase for the scheduler */ +#include + /*! * Proc scheduling test subthread 1 */ diff --git a/kern/proc_p.h b/kern/proc_p.h index 30189b7f..5b0bc99a 100755 --- a/kern/proc_p.h +++ b/kern/proc_p.h @@ -15,6 +15,9 @@ /*#* *#* $Log$ + *#* Revision 1.8 2004/10/03 20:39:28 bernie + *#* Import changes from sc/firmware. + *#* *#* Revision 1.7 2004/08/25 14:12:09 rasky *#* Aggiornato il comment block dei log RCS *#* @@ -112,5 +115,16 @@ extern REGISTER List ProcReadyList; /*! Schedule to another process *without* adding the current to the ready list */ void proc_schedule(void); +#if CONFIG_KERN_MONITOR + /*! Initialize the monitor */ + void monitor_init(void); + + /*! Register a process into the monitor */ + void monitor_add(Process *proc, const char *name, cpustack_t *stack, size_t stacksize); + + /*! Deregister a process from the monitor */ + void monitor_remove(Process *proc); +#endif /* CONFIG_KERN_MONITOR */ + #endif /* KERN_PROC_P_H */ diff --git a/mware/hashtable.c b/mware/hashtable.c index 68676ee9..5122fb58 100755 --- a/mware/hashtable.c +++ b/mware/hashtable.c @@ -1,8 +1,8 @@ /*! * \file * * @@ -61,16 +61,8 @@ /*#* *#* $Log$ - *#* Revision 1.2 2004/08/25 14:12:09 rasky - *#* Aggiornato il comment block dei log RCS - *#* - *#* Revision 1.1 2004/07/14 14:08:16 rasky - *#* Implementazione di una tabella hash - *#* - *#* Revision 1.13 2004/07/12 16:33:36 rasky - *#* Aggiunta nuova ASSERT2, con stringa di descrizione del problema (disabilitabile tramite una macro di configurazione) - *#* Modificato il codice del firmware per utilizzare ASSERT2 - *#* Modificato il progetto in modo da disabilitare le stringhe di errore nel target xROM-xRAM + *#* Revision 1.3 2004/10/03 20:43:22 bernie + *#* Import changes from sc/firmware. *#* *#* Revision 1.12 2004/06/14 15:15:24 rasky *#* Cambiato key_data in un union invece di castare @@ -98,9 +90,11 @@ *#* Sistemata la documentazione, rimossa keycmp in favore della memcmp *#* *#*/ + #include "hashtable.h" -#include +#include #include + #include @@ -140,6 +134,7 @@ INLINE void node_get_key(struct HashTable* ht, HashNodePtr node, const void** ke *key = ht->key_data.hook(*node, key_length); } + INLINE bool node_key_match(struct HashTable* ht, HashNodePtr node, const void* key, uint8_t key_length) { const void* key2; @@ -150,6 +145,7 @@ INLINE bool node_key_match(struct HashTable* ht, HashNodePtr node, const void* k return (key_length == key2_length && memcmp(key, key2, key_length) == 0); } + static uint16_t calc_hash(const void* _key, uint8_t key_length) { const char* key = (const char*)_key; @@ -163,6 +159,7 @@ static uint16_t calc_hash(const void* _key, uint8_t key_length) return hash ^ (hash >> 6) ^ (hash >> 13); } + static HashNodePtr perform_lookup(struct HashTable* ht, const void* key, uint8_t key_length) { @@ -184,9 +181,9 @@ static HashNodePtr perform_lookup(struct HashTable* ht, // Increment while going through the hash table in case of collision. // This implements the double-hash technique: we use the higher part // of the hash as a step increment instead of just going to the next - // element, to minimize the collisions. + // element, to minimize the collisions. // Notice that the number must be odd to be sure that the whole table - // is traversed. Actually MCD(table_size, step) must be 1, but + // is traversed. Actually MCD(table_size, step) must be 1, but // table_size is always a power of 2, so we just ensure that step is // never a multiple of 2. step = (ROTATE_RIGHT_16(hash, ht->max_elts_log2) & mask) | 1; @@ -212,11 +209,13 @@ static HashNodePtr perform_lookup(struct HashTable* ht, return NULL; } + void ht_init(struct HashTable* ht) { memset(ht->mem, 0, sizeof(ht->mem[0]) * (1 << ht->max_elts_log2)); } + static bool insert(struct HashTable* ht, const void* key, uint8_t key_length, const void* data) { HashNodePtr node; @@ -242,6 +241,7 @@ static bool insert(struct HashTable* ht, const void* key, uint8_t key_length, co return true; } + bool ht_insert_with_key(struct HashTable* ht, const void* key, uint8_t key_length, const void* data) { #ifdef _DEBUG @@ -260,6 +260,7 @@ bool ht_insert_with_key(struct HashTable* ht, const void* key, uint8_t key_lengt return insert(ht, key, key_length, data); } + bool ht_insert(struct HashTable* ht, const void* data) { const void* key; @@ -279,10 +280,11 @@ bool ht_insert(struct HashTable* ht, const void* data) return insert(ht, key, key_length, data); } + const void* ht_find(struct HashTable* ht, const void* key, uint8_t key_length) { HashNodePtr node; - + if (HT_HAS_INTERNAL_KEY(ht)) key_length = MIN(key_length, INTERNAL_KEY_MAX_LENGTH); @@ -326,8 +328,8 @@ static bool single_test(void) { int k; int klen; - - do + + do { klen = (rand() % 8) + 1; for (k=0;k * @@ -31,20 +31,8 @@ /*#* *#* $Log$ - *#* Revision 1.4 2004/08/25 14:12:09 rasky - *#* Aggiornato il comment block dei log RCS - *#* - *#* Revision 1.3 2004/08/14 19:37:57 rasky - *#* Merge da SC: macros.h, pool.h, BIT_CHANGE, nome dei processi, etc. - *#* - *#* Revision 1.2 2004/08/04 15:52:54 rasky - *#* Merge da SC: fixato namespace dell'include guard - *#* - *#* Revision 1.1 2004/07/14 14:08:16 rasky - *#* Implementazione di una tabella hash - *#* - *#* Revision 1.10 2004/06/14 15:17:15 rasky - *#* Qualche fix alla documentazione Doxygen + *#* Revision 1.5 2004/10/03 20:43:22 bernie + *#* Import changes from sc/firmware. *#* *#* Revision 1.9 2004/06/14 15:15:24 rasky *#* Cambiato key_data in un union invece di castare @@ -64,37 +52,39 @@ *#* *#* Revision 1.4 2004/05/24 15:28:20 rasky *#* Sistemata la documentazione, rimossa keycmp in favore della memcmp - *#* *#*/ - #ifndef MWARE_HASHTABLE_H #define MWARE_HASHTABLE_H #include #include -#include +#include -/*! Enable/disable support to declare special hash tables which maintain a copy of - * the key internally instead of relying on the hook to extract it from the data. +/*! + * Enable/disable support to declare special hash tables which maintain a copy of + * the key internally instead of relying on the hook to extract it from the data. */ #define CONFIG_HT_OPTIONAL_INTERNAL_KEY 1 //! Maximum length of the internal key (use (2^n)-1 for slight speedup) #define INTERNAL_KEY_MAX_LENGTH 15 -/*! Hook to get the key from \a data, which is an element of the hash table. The - * key must be returned together with \a key_length (in words). +/*! + * Hook to get the key from \a data, which is an element of the hash table. The + * key must be returned together with \a key_length (in words). */ typedef const void* (*hook_get_key)(const void* data, uint8_t* key_length); -/*! Hash table description + +/*! + * Hash table description * * \note This structures MUST NOT be accessed directly. Its definition is * provided in the header file only for optimization purposes (see the rationale * in hashtable.c). * - * \note If new elements must be added to this list, please double check + * \note If new elements must be added to this list, please double check * \c DECLARE_HASHTABLE, which requires the existing elements to be at the top. */ struct HashTable @@ -110,6 +100,7 @@ struct HashTable } key_data; }; + //! Iterator to walk the hash table typedef struct { @@ -117,7 +108,9 @@ typedef struct const void** end; } HashIterator; -/*! Declare a hash table in the current scope + +/*! + * Declare a hash table in the current scope * * \param name Variable name * \param size Number of elements @@ -154,7 +147,8 @@ typedef struct static struct HashTable name = { name##_nodes, UINT32_LOG2(size), { true }, name##_keys } #endif -/*! Initialize (and clear) a hash table in a memory buffer. +/*! + * Initialize (and clear) a hash table in a memory buffer. * * \param ht Hash table declared with \c DECLARE_HASHTABLE * @@ -164,7 +158,8 @@ typedef struct */ void ht_init(struct HashTable* ht); -/*! Insert an element into the hash table +/*! + * Insert an element into the hash table * * \param ht Handle of the hash table * \param data Data to be inserted into the table @@ -182,7 +177,8 @@ void ht_init(struct HashTable* ht); */ bool ht_insert(struct HashTable* ht, const void* data); -/*! Insert an element into the hash table +/*! + * Insert an element into the hash table * * \param ht Handle of the hash table * \param key Key of the element @@ -202,7 +198,8 @@ bool ht_insert(struct HashTable* ht, const void* data); */ bool ht_insert_with_key(struct HashTable* ht, const void* key, uint8_t key_length, const void* data); -/*! Find an element in the hash table +/*! + * Find an element in the hash table * * \param ht Handle of the hash table * \param key Key of the element @@ -231,11 +228,12 @@ INLINE HashIterator ht_iter_begin(struct HashTable* ht) return h; } -/*! Get an iterator to the (exclusive) end of the hash table \a ht +/*! + * Get an iterator to the (exclusive) end of the hash table \a ht * - * \note Like in STL, the end iterator is not a valid iterator (you - * cannot call \c ht_iter_get() on it), and it must be used only to - * detect if we reached the end of the iteration (through \c ht_iter_cmp()). + * \note Like in STL, the end iterator is not a valid iterator (you + * cannot call \c ht_iter_get() on it), and it must be used only to + * detect if we reached the end of the iteration (through \c ht_iter_cmp()). */ INLINE HashIterator ht_iter_end(struct HashTable* ht) { diff --git a/mware/heap.c b/mware/heap.c index 70c73c1b..249081b5 100755 --- a/mware/heap.c +++ b/mware/heap.c @@ -15,14 +15,8 @@ /*#* *#* $Log$ - *#* Revision 1.4 2004/08/25 14:12:09 rasky - *#* Aggiornato il comment block dei log RCS - *#* - *#* Revision 1.3 2004/08/14 19:37:57 rasky - *#* Merge da SC: macros.h, pool.h, BIT_CHANGE, nome dei processi, etc. - *#* - *#* Revision 1.2 2004/08/04 15:54:18 rasky - *#* Merge da SC: prima versione veramente funzionante + *#* Revision 1.5 2004/10/03 20:43:22 bernie + *#* Import changes from sc/firmware. *#* *#* Revision 1.1 2004/07/31 16:33:58 rasky *#* Spostato lo heap da kern/ a mware/ @@ -38,7 +32,7 @@ #include "heap.h" #include // memset() #include // IS_POW2() -#include // ASSERT() +#include // ASSERT() /* NOTE: struct size must be a 2's power! */ typedef struct _MemChunk