diff options
author | Javier <dev.git@javispedro.com> | 2022-04-11 04:36:49 +0200 |
---|---|---|
committer | Javier <dev.git@javispedro.com> | 2022-04-11 04:36:49 +0200 |
commit | 19231982b2f374aed286f4697aebd3fb9fda05d8 (patch) | |
tree | 1922eaf34af3d904ce0f75c0e812e8da8e0d38d4 /utils.h | |
parent | 970f90228a6978712c28529437721caffec76202 (diff) | |
download | vbados-19231982b2f374aed286f4697aebd3fb9fda05d8.tar.gz vbados-19231982b2f374aed286f4697aebd3fb9fda05d8.zip |
add new virtualbox shared folders client
Diffstat (limited to 'utils.h')
-rw-r--r-- | utils.h | 10 |
1 files changed, 10 insertions, 0 deletions
@@ -2,6 +2,9 @@ #define UTILS_H #include <stdint.h> +#include <i86.h> + +#define STATIC_ASSERT(expr) typedef int STATIC_ASSERT_FAILED[(expr) ? 1 : -1] #define MIN(a,b) (((a) < (b)) ? (a) : (b)) #define MAX(a,b) (((a) > (b)) ? (a) : (b)) @@ -17,6 +20,13 @@ static inline __segment get_cs(void); static inline __segment get_ds(void); #pragma aux get_ds = "mov ax, ds" value [ax] modify exact []; +/** Converts a far pointer into equivalent linear address. + * Note that under protected mode linear != physical (for that, need VDS). */ +static inline uint32_t linear_addr(const void __far * ptr) +{ + return ((uint32_t)(FP_SEG(ptr)) << 4) + FP_OFF(ptr); +} + /** Map x linearly from range [0, srcmax] to [0, dstmax]. * Equivalent of (x * dstmax) / srcmax but with 32-bit unsigned precision. */ static unsigned scaleu(unsigned x, unsigned srcmax, unsigned dstmax); |