blob: 581c7d8c27650f11790b589e0f0f0e6685cfc6fe [file] [log] [blame]
Kevin O'Connora4d35762008-03-08 15:43:03 -05001#include "util.h" // usleep
2
Kevin O'Connor2e7ab8b2008-03-29 14:29:35 -04003// Sum the bytes in the specified area.
4u8
5checksum(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
Kevin O'Connor5e4235f2008-04-12 09:00:04 -040014void *
Kevin O'Connor567e4e32008-04-05 11:37:51 -040015memset(void *s, int c, size_t n)
16{
17 while (n)
18 ((char *)s)[--n] = c;
Kevin O'Connor5e4235f2008-04-12 09:00:04 -040019 return s;
Kevin O'Connor567e4e32008-04-05 11:37:51 -040020}
21
22void *
Kevin O'Connore0113c92008-04-05 15:51:12 -040023memcpy(void *far_d1, const void *far_s1, size_t len)
Kevin O'Connor567e4e32008-04-05 11:37:51 -040024{
Kevin O'Connore0113c92008-04-05 15:51:12 -040025 u8 *d = far_d1;
26 u8 *s = (u8*)far_s1;
Kevin O'Connor567e4e32008-04-05 11:37:51 -040027
Kevin O'Connore0113c92008-04-05 15:51:12 -040028 while (len--) {
29 SET_FARPTR(*d, GET_FARPTR(*s));
30 d++;
31 s++;
32 }
Kevin O'Connor567e4e32008-04-05 11:37:51 -040033
Kevin O'Connore0113c92008-04-05 15:51:12 -040034 return far_d1;
Kevin O'Connor567e4e32008-04-05 11:37:51 -040035}
36
37void
38__set_fail(const char *fname, struct bregs *regs)
39{
40 __debug_fail(fname, regs);
Kevin O'Connordb9e65e2008-06-07 14:41:21 -040041 set_fail_silent(regs);
Kevin O'Connor567e4e32008-04-05 11:37:51 -040042}
43
44void
45__set_code_fail(const char *fname, struct bregs *regs, u8 code)
46{
Kevin O'Connordb9e65e2008-06-07 14:41:21 -040047 __debug_fail(fname, regs);
48 set_code_fail_silent(regs, code);
Kevin O'Connor567e4e32008-04-05 11:37:51 -040049}