Introduce set_fail_silent() helpers.
[seabios.git] / src / util.c
1 #include "util.h" // usleep
2
3 // Sum the bytes in the specified area.
4 u8
5 checksum(u8 *far_data, u32 len)
6 {
7     u32 i;
8     u8 sum = 0;
9     for (i=0; i<len; i++)
10         sum += GET_FARPTR(far_data[i]);
11     return sum;
12 }
13
14 void *
15 memset(void *s, int c, size_t n)
16 {
17     while (n)
18         ((char *)s)[--n] = c;
19     return s;
20 }
21
22 void *
23 memcpy(void *far_d1, const void *far_s1, size_t len)
24 {
25     u8 *d = far_d1;
26     u8 *s = (u8*)far_s1;
27
28     while (len--) {
29         SET_FARPTR(*d, GET_FARPTR(*s));
30         d++;
31         s++;
32     }
33
34     return far_d1;
35 }
36
37 void
38 __set_fail(const char *fname, struct bregs *regs)
39 {
40     __debug_fail(fname, regs);
41     set_fail_silent(regs);
42 }
43
44 void
45 __set_code_fail(const char *fname, struct bregs *regs, u8 code)
46 {
47     __debug_fail(fname, regs);
48     set_code_fail_silent(regs, code);
49 }