static void memcpy_from_ring(const void *Ring, void *Dest, int off, int len) { int c1, c2; const char *ring = Ring; char *dest = Dest; c1 = min(len, XENSTORE_RING_SIZE - off); c2 = len - c1; bmk_memcpy(dest, ring + off, c1); bmk_memcpy(dest + c1, ring, c2); }
void arch_init(start_info_t *si) { /* Copy the start_info struct to a globally-accessible area. */ /* WARN: don't do printk before here, it uses information from shared_info. Use xprintk instead. */ bmk_memcpy(&start_info, si, sizeof(*si)); /* set up minimal memory infos */ _minios_phys_to_machine_mapping = (unsigned long *)start_info.mfn_list; /* Grab the shared_info pointer and put it in a safe place. */ HYPERVISOR_shared_info = map_shared_info(start_info.shared_info); /* Set up event and failsafe callback addresses. */ #ifdef __i386__ gdtinit32(); HYPERVISOR_set_callbacks( __KERNEL_CS, (unsigned long)_minios_entry_hypervisor_callback, __KERNEL_CS, (unsigned long)_minios_entry_failsafe_callback); #else HYPERVISOR_set_callbacks( (unsigned long)_minios_entry_hypervisor_callback, (unsigned long)_minios_entry_failsafe_callback, 0); #endif }
/* * don't do any of "storage compaction" nonsense, "just" the three modes: * + cp == NULL ==> malloc * + nbytes == 0 ==> free * + else ==> realloc */ void * bmk_memrealloc(void *cp, size_t nbytes) { union overhead *op; size_t size; size_t alignpad; void *np; if (cp == NULL) return bmk_memalloc(nbytes, MINALIGN); if (nbytes == 0) { bmk_memfree(cp); return NULL; } op = ((union overhead *)cp)-1; size = op->ov_index; alignpad = op->ov_alignpad; /* don't bother "compacting". don't like it? don't use realloc! */ if (((1<<(size+MINSHIFT)) - alignpad) >= nbytes) return cp; /* we're gonna need a bigger bucket */ np = bmk_memalloc(nbytes, 8); if (np == NULL) return NULL; bmk_memcpy(np, cp, (1<<(size+MINSHIFT)) - alignpad); bmk_memfree(cp); return np; }