diff options
author | Peter Mikkelsen <petermikkelsen10@gmail.com> | 2025-07-27 15:33:22 +0200 |
---|---|---|
committer | Peter Mikkelsen <petermikkelsen10@gmail.com> | 2025-07-27 15:33:22 +0200 |
commit | efb1cf0895d6c5019f5a88fa14b59afd030fefca (patch) | |
tree | 24fe5d99faad9eeed625d0ef1a6edea65482e246 /src/util.c | |
parent | b5a24778844f41e38168d97761d72cf0d5b400b3 (diff) |
Setup descriptor tables, and enable interrupts
Diffstat (limited to 'src/util.c')
-rw-r--r-- | src/util.c | 34 |
1 files changed, 34 insertions, 0 deletions
@@ -18,6 +18,32 @@ read_uint32_le(const uint8_t *p) return p[0] | (p[1] << 8) | (p[2] << 16) | (p[3] << 24); } +void write_uint16_le(uint8_t *p, uint16_t v) +{ + p[0] = v & 0xFF; + p[1] = (v >> 8) & 0xFF; +} + +void write_uint32_le(uint8_t *p, uint32_t v) +{ + p[0] = v & 0xFF; + p[1] = (v >> 8) & 0xFF; + p[2] = (v >> 16) & 0xFF; + p[3] = (v >> 24) & 0xFF; +} + +void write_uint64_le(uint8_t *p, uint64_t v) +{ + p[0] = v & 0xFF; + p[1] = (v >> 8) & 0xFF; + p[2] = (v >> 16) & 0xFF; + p[3] = (v >> 24) & 0xFF; + p[4] = (v >> 32) & 0xFF; + p[5] = (v >> 40) & 0xFF; + p[6] = (v >> 48) & 0xFF; + p[7] = (v >> 56) & 0xFF; +} + int memcmp(const void *p1, const void *p2, size_t n) { @@ -31,3 +57,11 @@ memcmp(const void *p1, const void *p2, size_t n) } return 0; } + +void +memset(void *v, uint8_t b, size_t n) +{ + uint8_t *p = v; + for(size_t i = 0; i < n; i++) + p[i] = b; +} |