This is a necessary step to make minios build on NetBSD.
Signed-off-by: Christoph Egger <Christoph.Egger@amd.com>
void
-ia64_write_itr_i(ia64_pte_t* pteP, u32 reg, uint64_t vAddr,
+ia64_write_itr_i(ia64_pte_t* pteP, uint32_t reg, uint64_t vAddr,
uint64_t ps, uint64_t pk)
{
/* The virtual address. */
/*
* monotonic_clock(): returns # of nanoseconds passed since time_init()
*/
-u64
+uint64_t
monotonic_clock(void)
{
uint64_t delta;
/* These are peridically updated in shared_info, and then copied here. */
struct shadow_time_info {
- u64 tsc_timestamp; /* TSC at last update of time vals. */
- u64 system_timestamp; /* Time, in nanosecs, since boot. */
- u32 tsc_to_nsec_mul;
- u32 tsc_to_usec_mul;
+ uint64_t tsc_timestamp; /* TSC at last update of time vals. */
+ uint64_t system_timestamp; /* Time, in nanosecs, since boot. */
+ uint32_t tsc_to_nsec_mul;
+ uint32_t tsc_to_usec_mul;
int tsc_shift;
- u32 version;
+ uint32_t version;
};
static struct timespec shadow_ts;
-static u32 shadow_ts_version;
+static uint32_t shadow_ts_version;
static struct shadow_time_info shadow;
* Scale a 64-bit delta by scaling and multiplying by a 32-bit fraction,
* yielding a 64-bit result.
*/
-static inline u64 scale_delta(u64 delta, u32 mul_frac, int shift)
+static inline uint64_t scale_delta(uint64_t delta, uint32_t mul_frac, int shift)
{
- u64 product;
+ uint64_t product;
#ifdef __i386__
- u32 tmp1, tmp2;
+ uint32_t tmp1, tmp2;
#endif
if ( shift < 0 )
"xor %5,%5 ; "
"adc %5,%%edx ; "
: "=A" (product), "=r" (tmp1), "=r" (tmp2)
- : "a" ((u32)delta), "1" ((u32)(delta >> 32)), "2" (mul_frac) );
+ : "a" ((uint32_t)delta), "1" ((uint32_t)(delta >> 32)), "2" (mul_frac) );
#else
__asm__ (
"mul %%rdx ; shrd $32,%%rdx,%%rax"
- : "=a" (product) : "0" (delta), "d" ((u64)mul_frac) );
+ : "=a" (product) : "0" (delta), "d" ((uint64_t)mul_frac) );
#endif
return product;
static unsigned long get_nsec_offset(void)
{
- u64 now, delta;
+ uint64_t now, delta;
rdtscll(now);
delta = now - shadow.tsc_timestamp;
return scale_delta(delta, shadow.tsc_to_nsec_mul, shadow.tsc_shift);
* Note: This function is required to return accurate
* time even in the absence of multiple timer ticks.
*/
-u64 monotonic_clock(void)
+uint64_t monotonic_clock(void)
{
- u64 time;
- u32 local_time_version;
+ uint64_t time;
+ uint32_t local_time_version;
do {
local_time_version = shadow.version;
int gettimeofday(struct timeval *tv, void *tz)
{
- u64 nsec = monotonic_clock();
+ uint64_t nsec = monotonic_clock();
nsec += shadow_ts.tv_nsec;
typedef struct _ev_action_t {
evtchn_handler_t handler;
void *data;
- u32 count;
+ uint32_t count;
} ev_action_t;
static ev_action_t ev_actions[NR_EVS];
int
gnttab_end_access(grant_ref_t ref)
{
- u16 flags, nflags;
+ uint16_t flags, nflags;
BUG_ON(ref >= NR_GRANT_ENTRIES || ref < NR_RESERVED_ENTRIES);
gnttab_end_transfer(grant_ref_t ref)
{
unsigned long frame;
- u16 flags;
+ uint16_t flags;
BUG_ON(ref >= NR_GRANT_ENTRIES || ref < NR_RESERVED_ENTRIES);
};
}
-inline void mask_evtchn(u32 port)
+inline void mask_evtchn(uint32_t port)
{
shared_info_t *s = HYPERVISOR_shared_info;
synch_set_bit(port, &s->evtchn_mask[0]);
}
-inline void unmask_evtchn(u32 port)
+inline void unmask_evtchn(uint32_t port)
{
shared_info_t *s = HYPERVISOR_shared_info;
vcpu_info_t *vcpu_info = &s->vcpu_info[smp_processor_id()];
}
}
-inline void clear_evtchn(u32 port)
+inline void clear_evtchn(uint32_t port)
{
shared_info_t *s = HYPERVISOR_shared_info;
synch_clear_bit(port, &s->evtchn_pending[0]);
#include <mini-os/os.h>
#include <mini-os/types.h>
#include <time.h>
-typedef u8 u8_t;
-typedef s8 s8_t;
-typedef u16 u16_t;
-typedef s16 s16_t;
-typedef u32 u32_t;
-typedef s32 s32_t;
-typedef u64 u64_t;
-typedef s64 s64_t;
+typedef uint8_t u8_t;
+typedef int8_t s8_t;
+typedef uint16_t u16_t;
+typedef int16_t s16_t;
+typedef uint32_t u32_t;
+typedef int32_t s32_t;
+typedef uint64_t u64_t;
+typedef int64_t s64_t;
typedef uintptr_t mem_ptr_t;
-typedef u16 u_short;
+typedef uint16_t u_short;
/* Compiler hints for packing lwip's structures - */
#define PACK_STRUCT_FIELD(_x) _x
struct fs_import
{
domid_t dom_id; /* dom id of the exporting domain */
- u16 export_id; /* export id (exporting dom specific) */
- u16 import_id; /* import id (specific to this domain) */
+ uint16_t export_id; /* export id (exporting dom specific) */
+ uint16_t import_id; /* import id (specific to this domain) */
struct minios_list_head list; /* list of all imports */
unsigned int nr_entries; /* Number of entries in rings & request
array */
struct fsif_front_ring ring; /* frontend ring (contains shared ring) */
- u32 gnt_refs[FSIF_RING_SIZE_PAGES]; /* grant references to the shared ring */
+ uint32_t gnt_refs[FSIF_RING_SIZE_PAGES]; /* grant references to the shared ring */
evtchn_port_t local_port; /* local event channel port */
char *backend; /* XenBus location of the backend */
struct fs_request *requests; /* Table of requests */
/* hypervisor.c */
void force_evtchn_callback(void);
void do_hypervisor_callback(struct pt_regs *regs);
-void mask_evtchn(u32 port);
-void unmask_evtchn(u32 port);
-void clear_evtchn(u32 port);
+void mask_evtchn(uint32_t port);
+void unmask_evtchn(uint32_t port);
+void clear_evtchn(uint32_t port);
extern int in_callback;
#ifndef _LINUX_TYPES_H_
#define _LINUX_TYPES_H_
#include <mini-os/types.h>
-typedef u64 __u64;
+typedef uint64_t __u64;
#endif /* _LINUX_TYPES_H_ */
thread_regs_t regs;
#endif /* !defined(__ia64__) */
struct minios_list_head thread_list;
- u32 flags;
+ uint32_t flags;
s_time_t wakeup_time;
#ifdef HAVE_LIBC
struct _reent reent;
void wake(struct thread *thread);
void block(struct thread *thread);
-void msleep(u32 millisecs);
+void msleep(uint32_t millisecs);
#endif /* __SCHED_H__ */
* The other macros are for convenience to approximate short intervals
* of real time into system time
*/
-typedef s64 s_time_t;
+typedef int64_t s_time_t;
#define NOW() ((s_time_t)monotonic_clock())
#define SECONDS(_s) (((s_time_t)(_s)) * 1000000000UL )
#define TENTHS(_ts) (((s_time_t)(_ts)) * 100000000UL )
void fini_time(void);
s_time_t get_s_time(void);
s_time_t get_v_time(void);
-u64 monotonic_clock(void);
+uint64_t monotonic_clock(void);
void block_domain(s_time_t until);
#endif /* _MINIOS_TIME_H_ */
#define _TYPES_H_
#include <stddef.h>
-typedef signed char s8;
-typedef unsigned char u8;
-typedef signed short s16;
-typedef unsigned short u16;
-typedef signed int s32;
-typedef unsigned int u32;
-#ifdef __i386__
-typedef signed long long s64;
-typedef unsigned long long u64;
-#elif defined(__x86_64__) || defined(__ia64__)
-typedef signed long s64;
-typedef unsigned long u64;
-#endif
-
/* FreeBSD compat types */
#ifndef HAVE_LIBC
typedef unsigned char u_char;
typedef unsigned long uintptr_t;
typedef long intptr_t;
#endif /* __i386__ || __x86_64__ */
-typedef u8 uint8_t;
-typedef s8 int8_t;
-typedef u16 uint16_t;
-typedef s16 int16_t;
-typedef u32 uint32_t;
-typedef s32 int32_t;
-typedef u64 uint64_t, uintmax_t;
-typedef s64 int64_t, intmax_t;
-typedef u64 off_t;
+typedef unsigned char uint8_t;
+typedef signed char int8_t;
+typedef unsigned short uint16_t;
+typedef signed short int16_t;
+typedef unsigned int uint32_t;
+typedef signed int int32_t;
+#ifdef __i386__
+typedef signed long long int64_t;
+typedef unsigned long long uint64_t;
+#elif defined(__x86_64__) || defined(__ia64__)
+typedef signed long int64_t;
+typedef unsigned long uint64_t;
+#endif
+typedef uint64_t uintmax_t;
+typedef int64_t intmax_t;
+typedef uint64_t off_t;
#endif
typedef intptr_t ptrdiff_t;
: /* no outputs */ \
: "c" (msr), "a" (val1), "d" (val2))
-#define wrmsrl(msr,val) wrmsr(msr,(u32)((u64)(val)),((u64)(val))>>32)
+#define wrmsrl(msr,val) wrmsr(msr,(uint32_t)((uint64_t)(val)),((uint64_t)(val))>>32)
#else /* ifdef __x86_64__ */
static inline long
HYPERVISOR_set_timer_op(
- u64 timeout)
+ uint64_t timeout)
{
unsigned long timeout_hi = (unsigned long)(timeout>>32);
unsigned long timeout_lo = (unsigned long)timeout;
static inline int
HYPERVISOR_update_descriptor(
- u64 ma, u64 desc)
+ uint64_t ma, uint64_t desc)
{
return _hypercall4(int, update_descriptor, ma, ma>>32, desc, desc>>32);
}
static inline long
HYPERVISOR_set_timer_op(
- u64 timeout)
+ uint64_t timeout)
{
return _hypercall1(long, set_timer_op, timeout);
}
static struct netfront_dev *net_dev;
-u8 xen_features[XENFEAT_NR_SUBMAPS * 32];
+uint8_t xen_features[XENFEAT_NR_SUBMAPS * 32];
void setup_xen_features(void)
{
* one or more of the following formats.
*/
union uu {
- s64 q; /* as a (signed) quad */
- s64 uq; /* as an unsigned quad */
+ int64_t q; /* as a (signed) quad */
+ int64_t uq; /* as an unsigned quad */
long sl[2]; /* as two signed longs */
unsigned long ul[2]; /* as two unsigned longs */
};
#ifndef HAVE_LIBC
#define CHAR_BIT 8 /* number of bits in a char */
#endif
-#define QUAD_BITS (sizeof(s64) * CHAR_BIT)
+#define QUAD_BITS (sizeof(int64_t) * CHAR_BIT)
#define LONG_BITS (sizeof(long) * CHAR_BIT)
#define HALF_BITS (sizeof(long) * CHAR_BIT / 2)
* divisor are 4 `digits' in this base (they are shorter if they have
* leading zeros).
*/
-u64
-__qdivrem(u64 uq, u64 vq, u64 *arq)
+uint64_t
+__qdivrem(uint64_t uq, uint64_t vq, uint64_t *arq)
{
union uu tmp;
digit *u, *v, *q;
* Divide two signed quads.
* ??? if -1/2 should produce -1 on this machine, this code is wrong
*/
-s64
-__divdi3(s64 a, s64 b)
+int64_t
+__divdi3(int64_t a, int64_t b)
{
- u64 ua, ub, uq;
+ uint64_t ua, ub, uq;
int neg;
if (a < 0)
- ua = -(u64)a, neg = 1;
+ ua = -(uint64_t)a, neg = 1;
else
ua = a, neg = 0;
if (b < 0)
- ub = -(u64)b, neg ^= 1;
+ ub = -(uint64_t)b, neg ^= 1;
else
ub = b;
- uq = __qdivrem(ua, ub, (u64 *)0);
+ uq = __qdivrem(ua, ub, (uint64_t *)0);
return (neg ? -uq : uq);
}
/*
* Divide two unsigned quads.
*/
-u64
-__udivdi3(u64 a, u64 b)
+uint64_t
+__udivdi3(uint64_t a, uint64_t b)
{
- return (__qdivrem(a, b, (u64 *)0));
+ return (__qdivrem(a, b, (uint64_t *)0));
}
}
case CLOCK_REALTIME:
{
- u64 nsec = monotonic_clock();
+ uint64_t nsec = monotonic_clock();
tp->tv_sec = nsec / 1000000000ULL;
tp->tv_nsec = nsec % 1000000000ULL;
/* Creates and returns a new semaphore. The "count" argument specifies
* the initial state of the semaphore. */
-sys_sem_t sys_sem_new(u8_t count)
+sys_sem_t sys_sem_new(uint8_t count)
{
struct semaphore *sem = xmalloc(struct semaphore);
sem->count = count;
* semaphore wasn't signaled within the specified time, the return value is
* SYS_ARCH_TIMEOUT. If the thread didn't have to wait for the semaphore
* (i.e., it was already signaled), the function may return zero. */
-u32_t sys_arch_sem_wait(sys_sem_t sem, u32_t timeout)
+uint32_t sys_arch_sem_wait(sys_sem_t sem, uint32_t timeout)
{
/* Slightly more complicated than the normal minios semaphore:
* need to wake on timeout *or* signal */
sys_prot_t prot;
- s64_t then = NOW();
- s64_t deadline;
+ int64_t then = NOW();
+ int64_t deadline;
if (timeout == 0)
deadline = 0;
* The return values are the same as for the sys_arch_sem_wait() function:
* Number of milliseconds spent waiting or SYS_ARCH_TIMEOUT if there was a
* timeout. */
-u32_t sys_arch_mbox_fetch(sys_mbox_t mbox, void **msg, u32_t timeout)
+uint32_t sys_arch_mbox_fetch(sys_mbox_t mbox, void **msg, uint32_t timeout)
{
- u32 rv;
+ uint32_t rv;
if (mbox == SYS_MBOX_NULL)
return SYS_ARCH_TIMEOUT;
* sys_arch_mbox_fetch(mbox,msg,1)
* although this would introduce unnecessary delays. */
-u32_t sys_arch_mbox_tryfetch(sys_mbox_t mbox, void **msg) {
+uint32_t sys_arch_mbox_tryfetch(sys_mbox_t mbox, void **msg) {
if (mbox == SYS_MBOX_NULL)
return SYS_ARCH_TIMEOUT;
etharp_ip_input(netif, p);
#endif
/* skip Ethernet header */
- pbuf_header(p, -(s16)sizeof(struct eth_hdr));
+ pbuf_header(p, -(int16_t)sizeof(struct eth_hdr));
/* pass to network layer */
if (tcpip_input(p, netif) == ERR_MEM)
/* Could not store it, drop */
clear_runnable(thread);
}
-void msleep(u32 millisecs)
+void msleep(uint32_t millisecs)
{
struct thread *thread = get_current();
thread->wakeup_time = NOW() + MILLISECS(millisecs);