1 // Misc utility functions.
3 // Copyright (C) 2008 Kevin O'Connor <kevin@koconnor.net>
5 // This file may be distributed under the terms of the GNU GPLv3 license.
7 #include "util.h" // usleep
8 #include "bregs.h" // struct bregs
9 #include "config.h" // SEG_BIOS
10 #include "farptr.h" // GET_FARPTR
12 // Call a function with a specified register state. Note that on
13 // return, the interrupt enable/disable flag may be altered.
15 call16(struct bregs *callregs)
21 "calll __call16_from32\n"
23 : "+a" (callregs), "+m" (*callregs)
25 : "ebx", "ecx", "edx", "esi", "edi", "ebp", "cc");
29 __call16_int(struct bregs *callregs, u16 offset)
31 callregs->cs = SEG_BIOS;
32 callregs->ip = offset;
36 // Sum the bytes in the specified area.
38 checksum(u8 *far_data, u32 len)
43 sum += GET_FARPTR(far_data[i]);
48 memset(void *s, int c, size_t n)
56 memcpy(void *far_d1, const void *far_s1, size_t len)
62 SET_FARPTR(*d, GET_FARPTR(*s));
71 memmove(void *d, const void *s, size_t len)
74 return memcpy(d, s, len);
79 *(char*)d = *(char*)s;