src/utils.h

Fri, 04 Mar 2011 01:36:30 +0000

author
Philip Pemberton <philpem@philpem.me.uk>
date
Fri, 04 Mar 2011 01:36:30 +0000
changeset 104
b12651d8a0ab
parent 98
d1af20db5f02
child 143
0fa6f5a480a6
permissions
-rw-r--r--

fix issue with WE+ bit becoming unset, fix pagefault:not-mapped-in logic

- The WE+ (page write enable) bit was becoming unset when the Page Status bits were being set.
A stupid mistake in an AND expression was unsetting the write-enable, thus making S4TEST 12,2 and 12,3 fail spectacularly.

- Pagefaults were not being generated correctly for pages which were not mapped in. Even Supervisor code accessing unmapped pages should get a PF.

     1 #ifndef _UTILS_H
     2 #define _UTILS_H
     4 #include <stdio.h>
     6 #ifndef NDEBUG
     7 /// Log a message to stderr
     8 #  define LOG(x, ...) do { fprintf(stderr, "%s:%d:%s(): " x "\n", __FILE__, __LINE__, __PRETTY_FUNCTION__, ##__VA_ARGS__); } while (0)
     9 #  define LOGS(x) do { fprintf(stderr, "%s:%d:%s(): " x "\n", __FILE__, __LINE__, __PRETTY_FUNCTION__); } while (0)
    10 /// Log a message to stderr if 'cond' is true
    11 #  define LOG_IF(cond, x, ...) do { if (cond) fprintf(stderr, "%s:%d:%s(): " x "\n", __FILE__, __LINE__, __PRETTY_FUNCTION__, ##__VA_ARGS__); } while (0)
    12 #  define LOG_IFS(cond, x) do { if (cond) fprintf(stderr, "%s:%d:%s(): " x "\n", __FILE__, __LINE__, __PRETTY_FUNCTION__); } while (0)
    13 #else
    14 #define LOG(x, ...)
    15 #define LOGS(x)
    16 #define LOG_IF(cond, x, ...)
    17 #define LOG_IFS(cond, x)
    18 #endif
    20 /// Get the number of elements in an array
    21 #define NELEMS(x) (sizeof(x)/sizeof(x[0]))
    23 #endif // _H_UTILS