ia64/xen-unstable

view tools/firmware/hvmloader/util.h @ 12651:9164f836943d

[HVMLOADER] Fix CFLAGS.
Signed-off-by: Keir Fraser <keir@xensource.com>
author kfraser@localhost.localdomain
date Wed Nov 29 11:38:17 2006 +0000 (2006-11-29)
parents 514ed4f0e5da
children 480436ef6255
line source
1 #ifndef __HVMLOADER_UTIL_H__
2 #define __HVMLOADER_UTIL_H__
4 #include <stdarg.h>
6 #undef offsetof
7 #define offsetof(t, m) ((unsigned long)&((t *)0)->m)
9 #undef NULL
10 #define NULL ((void*)0)
12 extern void __assert_failed(char *assertion, char *file, int line)
13 __attribute__((noreturn));
14 #define ASSERT(p) \
15 do { if (!(p)) __assert_failed(#p, __FILE__, __LINE__); } while (0)
16 extern void __bug(char *file, int line) __attribute__((noreturn));
17 #define BUG() __bug()
19 /* I/O output */
20 void outb(uint16_t addr, uint8_t val);
21 void outw(uint16_t addr, uint16_t val);
22 void outl(uint16_t addr, uint32_t val);
24 /* I/O input */
25 uint8_t inb(uint16_t addr);
26 uint16_t inw(uint16_t addr);
27 uint32_t inl(uint16_t addr);
29 /* APIC access */
30 uint32_t ioapic_read(uint32_t reg);
31 void ioapic_write(uint32_t reg, uint32_t val);
32 uint32_t lapic_read(uint32_t reg);
33 void lapic_write(uint32_t reg, uint32_t val);
35 /* PCI access */
36 uint32_t pci_read(uint32_t devfn, uint32_t reg, uint32_t len);
37 #define pci_readb(devfn, reg) ((uint8_t) pci_read(devfn, reg, 1))
38 #define pci_readw(devfn, reg) ((uint16_t)pci_read(devfn, reg, 2))
39 #define pci_readl(devfn, reg) ((uint32_t)pci_read(devfn, reg, 4))
40 void pci_write(uint32_t devfn, uint32_t reg, uint32_t len, uint32_t val);
41 #define pci_writeb(devfn, reg, val) (pci_write(devfn, reg, 1, (uint8_t) val))
42 #define pci_writew(devfn, reg, val) (pci_write(devfn, reg, 2, (uint16_t)val))
43 #define pci_writel(devfn, reg, val) (pci_write(devfn, reg, 4, (uint32_t)val))
45 /* Do cpuid instruction, with operation 'idx' */
46 void cpuid(uint32_t idx, uint32_t *eax, uint32_t *ebx,
47 uint32_t *ecx, uint32_t *edx);
49 /* HVM-builder info. */
50 int get_vcpu_nr(void);
51 int get_acpi_enabled(void);
52 int get_apic_mode(void);
54 /* String and memory functions */
55 int strcmp(const char *cs, const char *ct);
56 char *strcpy(char *dest, const char *src);
57 char *strncpy(char *dest, const char *src, unsigned n);
58 unsigned strlen(const char *s);
59 int memcmp(const void *s1, const void *s2, unsigned n);
60 void *memcpy(void *dest, const void *src, unsigned n);
61 void *memmove(void *dest, const void *src, unsigned n);
62 void *memset(void *s, int c, unsigned n);
63 char *itoa(char *a, unsigned int i);
65 /* convert a byte to two lowercase hex digits, with no terminating NUL
66 character. digits[] must have at least two elements. */
67 void byte_to_hex(char *digits, uint8_t byte);
69 /* Convert an array of 16 unsigned bytes to a DCE/OSF formatted UUID
70 string. Pre-condition: sizeof(dest) >= 37 */
71 void uuid_to_string(char *dest, uint8_t *uuid);
73 /* Debug output */
74 int printf(const char *fmt, ...) __attribute__ ((format (printf, 1, 2)));
75 int vprintf(const char *fmt, va_list ap);
77 /* Allocate region of specified type in the e820 table. */
78 uint64_t e820_malloc(uint64_t size, uint32_t type, uint64_t mask);
80 #define isdigit(c) ((c) >= '0' && (c) <= '9')
82 #endif /* __HVMLOADER_UTIL_H__ */