syslinux-3.08-2 sources from FC4
[bootcd.git] / syslinux / memdisk / memdisk.h
1 #ident "$Id: memdisk.h,v 1.9 2005/03/08 18:39:32 hpa Exp $"
2 /* ----------------------------------------------------------------------- *
3  *   
4  *   Copyright 2001-2003 H. Peter Anvin - All Rights Reserved
5  *
6  *   This program is free software; you can redistribute it and/or modify
7  *   it under the terms of the GNU General Public License as published by
8  *   the Free Software Foundation, Inc., 53 Temple Place Ste 330,
9  *   Boston MA 02111-1307, USA; either version 2 of the License, or
10  *   (at your option) any later version; incorporated herein by reference.
11  *
12  * ----------------------------------------------------------------------- */
13
14 /*
15  * memdisk.h
16  *
17  * Miscellaneous header definitions
18  */
19
20 #ifndef MEMDISK_H
21 #define MEMDISK_H
22
23 /* We use the com32 interface for calling 16-bit code */
24 #include <com32.h>
25
26 /* The real-mode segment */
27 #define LOW_SEG 0x0800
28
29 typedef void (*syscall_t)(uint8_t, com32sys_t *, com32sys_t *);
30 extern syscall_t syscall;
31 extern void *sys_bounce;
32
33 /* What to call when we're dead */
34 extern void __attribute__((noreturn)) die(void);
35
36 /* Standard routines */
37 #define memcpy(a,b,c) __builtin_memcpy(a,b,c)
38 #define memset(a,b,c) __builtin_memset(a,b,c)
39 #define strcpy(a,b)   __builtin_strcpy(a,b)
40 #define strlen(a)     __builtin_strlen(a)
41
42 /* memcpy() but returns a pointer to end of buffer */
43 static inline void *
44 memcpy_endptr(void *__d, const void *__s, unsigned int __n)
45 {
46   memcpy(__d, __s, __n);
47   return (void *)((char *)__d + __n);
48 }
49
50 /* memcmp() */
51 static inline int
52 memcmp(const void *__a, const void *__b, unsigned int __n)
53 {
54   const unsigned char *__aa = __a;
55   const unsigned char *__bb = __b;
56   int __d;
57
58   while ( __n ) {
59     __d = *__bb++ - *__aa++;
60     if ( __d )
61       return __d;
62   }
63
64   return 0;
65 }
66
67 /* Decompression */
68 extern int check_zip(void *indata, uint32_t size, uint32_t *zbytes_p,
69                      uint32_t *dbytes_p, uint32_t *orig_crc,
70                      uint32_t *offset_p);
71 extern void *unzip(void *indata, uint32_t zbytes, uint32_t dbytes,
72                    uint32_t orig_crc, void *target);
73
74 #endif