#include <mach_assert.h>
#include <string.h>
#include <mach/boolean.h>
#include <mach/i386/vm_types.h>
#include <mach/i386/vm_param.h>
#include <kern/kern_types.h>
#include <kern/misc_protos.h>
#include <i386/misc_protos.h>
kern_return_t copyp2p(vm_offset_t source, vm_offset_t dest, unsigned int size, unsigned int flush_action) {
switch(flush_action) {
case 1:
flush_dcache(source, size, 1);
break;
case 2:
flush_dcache(dest, size, 1);
break;
case 3:
flush_dcache(source, size, 1);
flush_dcache(dest, size, 1);
break;
}
bcopy_phys((char *)source, (char *)dest, size);
switch(flush_action) {
case 1:
flush_dcache(source, size, 1);
break;
case 2:
flush_dcache(dest, size, 1);
break;
case 3:
flush_dcache(source, size, 1);
flush_dcache(dest, size, 1);
break;
}
}
kern_return_t
copyp2v(char *from, char *to, unsigned int size) {
return(copyout(phystokv(from), to, size));
}
void
bcopy_phys(const char *from, char *to, vm_size_t bytes)
{
bcopy((char *)phystokv(from), (char *)phystokv(to), bytes);
}
void
ovbcopy(
const char *from,
char *to,
vm_size_t bytes)
{
if (from + bytes <= to || to + bytes <= from || to == from)
bcopy_no_overwrite(from, to, bytes);
else if (from > to)
bcopy_no_overwrite(from, to, bytes);
else {
from += bytes - 1;
to += bytes - 1;
while (bytes-- > 0)
*to-- = *from--;
}
}
void
bcopy(
const char *from,
char *to,
vm_size_t bytes)
{
ovbcopy(from, to, bytes);
}
int bcmp(
const char *a,
const char *b,
vm_size_t len)
{
if (len == 0)
return 0;
do
if (*a++ != *b++)
break;
while (--len);
return len;
}
int
memcmp(s1, s2, n)
register char *s1, *s2;
register n;
{
while (--n >= 0)
if (*s1++ != *s2++)
return (*--s1 - *--s2);
return (0);
}
size_t
strlen(
register const char *string)
{
register const char *ret = string;
while (*string++ != '\0')
continue;
return string - 1 - ret;
}
#include <libkern/OSAtomic.h>
uint32_t
hw_atomic_add(
uint32_t *dest,
uint32_t delt)
{
uint32_t oldValue;
uint32_t newValue;
do {
oldValue = *dest;
newValue = (oldValue + delt);
} while (!OSCompareAndSwap((UInt32)oldValue,
(UInt32)newValue, (UInt32 *)dest));
return newValue;
}
uint32_t
hw_atomic_sub(
uint32_t *dest,
uint32_t delt)
{
uint32_t oldValue;
uint32_t newValue;
do {
oldValue = *dest;
newValue = (oldValue - delt);
} while (!OSCompareAndSwap((UInt32)oldValue,
(UInt32)newValue, (UInt32 *)dest));
return newValue;
}
uint32_t
hw_atomic_or(
uint32_t *dest,
uint32_t mask)
{
uint32_t oldValue;
uint32_t newValue;
do {
oldValue = *dest;
newValue = (oldValue | mask);
} while (!OSCompareAndSwap((UInt32)oldValue,
(UInt32)newValue, (UInt32 *)dest));
return newValue;
}
uint32_t
hw_atomic_and(
uint32_t *dest,
uint32_t mask)
{
uint32_t oldValue;
uint32_t newValue;
do {
oldValue = *dest;
newValue = (oldValue & mask);
} while (!OSCompareAndSwap((UInt32)oldValue,
(UInt32)newValue, (UInt32 *)dest));
return newValue;
}
uint32_t
hw_compare_and_store(
uint32_t oldval,
uint32_t newval,
uint32_t *dest)
{
return OSCompareAndSwap((UInt32)oldval, (UInt32)newval, (UInt32 *)dest);
}
#if MACH_ASSERT
void machine_callstack(
natural_t *buf,
vm_size_t callstack_max)
{
}
#endif
void fillPage(ppnum_t pa, unsigned int fill)
{
}
uint64_t max_mem;
uint64_t sane_size;
#include <vm/pmap.h>
ppnum_t pmap_find_phys(pmap_t pmap, addr64_t va)
{
return 0;
}
kern_return_t copypv(addr64_t source, addr64_t sink, unsigned int size, int which)
{
return KERN_SUCCESS;
}
void mapping_set_mod(ppnum_t pa)
{
}
void flush_dcache64(addr64_t addr, unsigned count, int phys)
{
}
void invalidate_icache64(addr64_t addr, unsigned cnt, int phys)
{
}