Use one lock in console.c and re-Deputized i386/page_alloc.c
authorZach Anderson <zra@zra-intrepid.(none)>
Thu, 10 Sep 2009 17:35:10 +0000 (10:35 -0700)
committerZach Anderson <zra@zra-intrepid.(none)>
Thu, 10 Sep 2009 17:35:10 +0000 (10:35 -0700)
kern/arch/i386/console.c
kern/arch/i386/page_alloc.c
kern/include/colored_page_alloc.h
kern/src/pmap.c

index 0dc36aa..8cd339b 100644 (file)
@@ -400,12 +400,8 @@ static uint8_t * COUNT(256) (SREADONLY charcode)[4] = {
  * Get data from the keyboard.  If we finish a character, return it.  Else 0.
  * Return -1 if no data.
  */
-#ifdef __IVY__
-#pragma cilnoremove("cons_lock")
-#endif
-static volatile uint32_t SRACY cons_lock = 0;
-static uint32_t SLOCKED(&cons_lock) shift;
-static bool SLOCKED(&cons_lock) crt_scrolled = FALSE;
+static uint32_t SLOCKED(&lock) shift;
+static bool SLOCKED(&lock) crt_scrolled = FALSE;
 
 static int
 kbd_proc_data(void)
@@ -505,7 +501,7 @@ struct cons {
        uint32_t wpos;
 };
 
-static struct cons SLOCKED(&cons_lock) cons;
+static struct cons SLOCKED(&lock) cons;
 
 // called by device interrupt routines to feed input characters
 // into the circular console input buffer.
@@ -529,7 +525,7 @@ cons_getc(void)
 {
        int c;
 
-       spin_lock_irqsave(&cons_lock);
+       spin_lock_irqsave(&lock);
 
        // poll for any pending input characters,
        // so that this function works even when interrupts are disabled
@@ -544,10 +540,10 @@ cons_getc(void)
                c = cons.buf[cons.rpos++];
                if (cons.rpos == CONSBUFSIZE)
                        cons.rpos = 0;
-               spin_unlock_irqsave(&cons_lock);
+               spin_unlock_irqsave(&lock);
                return c;
        }
-       spin_unlock_irqsave(&cons_lock);
+       spin_unlock_irqsave(&lock);
        return 0;
 }
 
index 7687463..71fb695 100644 (file)
@@ -10,7 +10,7 @@
 #endif
 
 #ifdef __DEPUTY__
-#pragma nodeputy
+//#pragma nodeputy
 #endif
 
 #include <sys/queue.h>
@@ -43,7 +43,8 @@ void page_alloc_init()
        //  4) Then extended memory [EXTPHYSMEM, ...).
        //     Some of it is in use, some is free.
        int i;
-       physaddr_t physaddr_after_kernel = PADDR(ROUNDUP(boot_freemem, PGSIZE));
+       extern char (SNT end)[];
+       physaddr_t physaddr_after_kernel = PADDR(PTRROUNDUP(boot_freemem, PGSIZE));
 
        pages[0].page_ref = 1;
        // alloc the second page, since we will need it later to init the other cores
index 4fce9d1..865c405 100644 (file)
        page_list_entry_t _cache##_cache_colored_page_link;
        
 #define DECLARE_CACHE_COLORED_PAGE_FREE_LIST(_cache)                          \
-       page_list_t *COUNT(npages) _cache##_cache_colored_page_list = NULL;
+       uint8_t _cache##_num_colors = 0;                                          \
+       page_list_t *COUNT(_cache##_num_colors) _cache##_cache_colored_page_list = NULL;
        
 #define DECLARE_EXTERN_CACHE_COLORED_PAGE_FREE_LIST(_cache)                   \
-       extern page_list_t *COUNT(npages) _cache##_cache_colored_page_list;
+    extern uint8_t _cache##_num_colors;                                       \
+       extern page_list_t *COUNT(_cache##_num_colors) _cache##_cache_colored_page_list;
        
 #define DECLARE_CACHE_COLORED_PAGE_ALLOC_FUNCTION(_cache)                     \
 error_t _cache##_page_alloc(page_t** page, size_t color)                      \
@@ -40,11 +42,11 @@ error_t _cache##_page_alloc(page_t** page, size_t color)                      \
 #define INIT_CACHE_COLORED_PAGE_FREE_LIST(_cache)                             \
 {                                                                             \
        if(available_caches._cache == TRUE) {                                     \
-           uint8_t num_colors = get_cache_num_page_colors(&(_cache));            \
-           size_t list_size = num_colors*sizeof(page_list_t);                    \
+           _cache##_num_colors = get_cache_num_page_colors(&(_cache));           \
+           size_t list_size = _cache##_num_colors*sizeof(page_list_t);            \
            _cache##_cache_colored_page_list                                      \
               = (page_list_t*) boot_alloc(list_size, PGSIZE);                    \
-               for(int i=0; i<num_colors; i++) {                                     \
+               for(int i=0; i<_cache##_num_colors; i++) {                            \
                        LIST_INIT(&(_cache##_cache_colored_page_list[i]));                \
                }                                                                     \
        }                                                                         \
index 871774e..5cb5939 100644 (file)
@@ -314,12 +314,13 @@ void* user_mem_check(env_t *env, const void *DANGEROUS va, size_t len, int perm)
  * @return LEN the length of the new buffer copied into 'dst'
  */
 size_t
-user_mem_strlcpy(env_t *env, char *dst, const char *DANGEROUS va,
+user_mem_strlcpy(env_t *env, char *_dst, const char *DANGEROUS va,
                  size_t _len, int perm)
 {
        const char *DANGEROUS src = va;
        size_t len = _len;
-       char *NT COUNT(_len-1) dst_in = dst;
+       char *NT COUNT(_len-1) dst_in = _dst;
+       char *NT BND(_dst,_dst + _len - 1) dst = _dst;
 
        if (len > 0) {
                while (1) {