Import changes from sc/firmware.
authorbernie <bernie@38d2e660-2303-0410-9eaa-f027e97ec537>
Sun, 3 Oct 2004 20:43:22 +0000 (20:43 +0000)
committerbernie <bernie@38d2e660-2303-0410-9eaa-f027e97ec537>
Sun, 3 Oct 2004 20:43:22 +0000 (20:43 +0000)
git-svn-id: https://src.develer.com/svnoss/bertos/trunk@232 38d2e660-2303-0410-9eaa-f027e97ec537

drv/ser_dsp56k.c
kern/proc.c
kern/proc_p.h
mware/hashtable.c
mware/hashtable.h
mware/heap.c

index a5a96fb7fb404bd106d1f5fdfbde32e34e9cec77..dccc806ae47105549c3bd0c8e76d9940f7c03827 100755 (executable)
@@ -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
  *#*
  *#*
  *#* 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 <drv/kdebug.h>
 #include <drv/irq.h>
+#include <debug.h>
 #include <hw.h>
-#include <DSP56F807.H>
+#include <DSP56F807.h>
 
 // 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.
index db3cf50dab18236ab964aec533ce10ff0b7925fc..975278b4b8192a430ef4c865e9d1c4c1d2a2e500 100755 (executable)
@@ -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 <drv/timer.h>
+
 /*!
  * Proc scheduling test subthread 1
  */
index 30189b7f34b6497b1de387811d5648c5b433dfcc..5b0bc99a28235bcba7300de15ecec9eed3ef2c50 100755 (executable)
@@ -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 */
 
index 68676ee9eacd4bb0468e36adee3530023587e1ad..5122fb587b7ee265a35729c00e84279f5ec7b11c 100755 (executable)
@@ -1,8 +1,8 @@
 /*!
  * \file
  * <!--
- * Copyright (C) 2004 Giovanni Bajo
- * Copyright (C) 2004 Develer S.r.l. (http://www.develer.com/)
+ * Copyright 2004 Develer S.r.l. (http://www.develer.com/)
+ * Copyright 2004 Giovanni Bajo
  * All Rights Reserved.
  * -->
  *
 
 /*#*
  *#* $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
  *#* Sistemata la documentazione, rimossa keycmp in favore della memcmp
  *#*
  *#*/
+
 #include "hashtable.h"
-#include <drv/kdebug.h>
+#include <debug.h>
 #include <compiler.h>
+
 #include <string.h>
 
 
@@ -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<klen;k++)
@@ -342,7 +344,7 @@ static bool single_test(void)
        for (i=0;i<NUM_ELEMENTS;i++)
        {
                char *found1, *found2;
-               
+
                found1 = (char*)ht_find_str(&test1, data[i]);
                if (strcmp(found1, data[i]) != 0)
                {
index 931917a64befa149a90d0b260c9cd01736c6d2f2..a55b3f7ab3f2904cb0e63a7b4bcbe7278d06dab1 100755 (executable)
@@ -1,8 +1,8 @@
 /*!
  * \file
  * <!--
- * Copyright (C) 2004 Giovanni Bajo
- * Copyright (C) 2004 Develer S.r.l. (http://www.develer.com/)
+ * Copyright 2004 Develer S.r.l. (http://www.develer.com/)
+ * Copyright 2004 Giovanni Bajo
  * All Rights Reserved.
  * -->
  *
 
 /*#*
  *#* $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
  *#*
  *#* 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 <compiler.h>
 #include <macros.h>
-#include <drv/kdebug.h>
+#include <debug.h>
 
-/*! 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)
 {
index 70c73c1b5d9fd5cb1757431b4a6e2d9273dc25f2..249081b593130921aa07995b8dceaf57d443a938 100755 (executable)
 
 /*#*
  *#* $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 <string.h>           // memset()
 #include <macros.h>           // IS_POW2()
-#include <drv/kdebug.h>       // ASSERT()
+#include <debug.h>            // ASSERT()
 
 /* NOTE: struct size must be a 2's power! */
 typedef struct _MemChunk