Beispiel #1
0
heap *create_heap(UINT start, UINT end, UINT memend, UINT pageflags)
{
	heap *newheap = (heap *)_kmalloc(sizeof(heap));
	mm_header *initholestart;
	mm_footer *initholeend;

	ASSERT_ALIGN(start);
	ASSERT_ALIGN(end);
	ASSERT_ALIGN(memend);
	newheap->entries = (mm_header **)start;
	start += MM_INDEX_COUNT * sizeof(mm_header *);
	ASSERT_ALIGN(start);
	newheap->start = start;
	newheap->end = end;
	newheap->memend = memend;
	newheap->pageflags = pageflags;

	initholestart = (mm_header *) start;
	initholestart->magic = MM_MAGIC;
	initholestart->size = end - start;
	initholestart->flag = MM_FLAG_HOLE;
	newheap->entries[0] = initholestart;

	initholeend = (mm_footer *) (end - sizeof(mm_footer));
	initholeend->magic = MM_MAGIC;
	initholeend->header = newheap->entries[0];

	newheap->entrycount = 1;
	newheap->maxentries = MM_INDEX_COUNT;

	return newheap;
}
Beispiel #2
0
int pdc_chassis_info(void *pdc_result, void *chassis_info, unsigned long len)
{
	ASSERT_ALIGN(pdc_result, 4);
	ASSERT_ALIGN(chassis_info, 4);
	return mem_pdc_call(PDC_CHASSIS,PDC_RETURN_CHASSIS_INFO, 
	        __pa(pdc_result), __pa(chassis_info), len);
}
Beispiel #3
0
int pdc_iodc_read(void *address, void * hpa, unsigned int index,
	void * iodc_data, unsigned int iodc_data_size)
{
	ASSERT_ALIGN(address, 4);
	ASSERT_ALIGN(iodc_data, 8);
	return mem_pdc_call(PDC_IODC, PDC_IODC_READ, 
		__pa(address), hpa, index, __pa(iodc_data), iodc_data_size);
}
Beispiel #4
0
int pdc_hpa_processor(void *address)
{
	/* We're using 0 for the last parameter just to make sure.
	   It's actually HVERSION dependant.  And remember, life is
	   hard without a backspace. */
	ASSERT_ALIGN(address, 4);

	return mem_pdc_call(PDC_HPA, PDC_HPA_PROCESSOR, __pa(address),0);
}
Beispiel #5
0
/* get system model name from PDC ROM (e.g. 9000/715 or 9000/778/B160L) */ 
int pdc_model_sysmodel(char * name)
{
	struct pdc_model_sysmodel sys_model;
	int retval;
	
	ASSERT_ALIGN(&sys_model, 8);
	ASSERT_ALIGN(name, 4);

	sys_model.mod_len = 0;
	retval = mem_pdc_call(PDC_MODEL,PDC_MODEL_SYSMODEL,__pa(&sys_model),
		    OS_ID_HPUX,__pa(name));
	
	if (retval == PDC_RET_OK) 
	    name[sys_model.mod_len] = '\0'; /* add trailing '\0' */
	else
	    name[0] = 0;
	
	return retval;
}
Beispiel #6
0
static void expand_heap(UINT new_size, heap *aheap)
{
	UINT i;

	if (new_size <= aheap->end - aheap->start) return;
	ASSERT_ALIGN(new_size);
	if (aheap->start + new_size > aheap->memend) return;
	for (i = aheap->end - aheap->start; i < new_size; i += FRAME_SIZE)
		make_page(aheap->start + i, aheap->pageflags, kernel_directory, 1);
	aheap->end = aheap->start + new_size;
}
Beispiel #7
0
static UINT contract_heap(UINT new_size, heap *aheap)
{
	UINT i;

	if (new_size >= aheap->end - aheap->start) return aheap->end - aheap->start;
	ASSERT_ALIGN(new_size);
	if (new_size < MM_KHEAP_MIN) new_size = MM_KHEAP_MIN;
	for (i = aheap->end - aheap->start - FRAME_SIZE; new_size < i; i -= FRAME_SIZE)
		free_page(aheap->start + i, kernel_directory);
	aheap->end = aheap->start + new_size;
	return new_size;
}
Beispiel #8
0
static UINT _kmalloc_base(UINT sz, UINT *phys, UCHAR align)
{
	UINT res;

	if (kheap) {
		res = (UINT)heap_malloc(sz, align, kheap);
		if (phys) {
			page *apage = get_page(res, 0, kernel_directory);
			*phys = (apage->frame * FRAME_SIZE) + (res & 0xFFF);
		}
	} else {
		if (align) ASSERT_ALIGN(kmalloc_pos);
		if (phys) *phys = kmalloc_pos;
		res = kmalloc_pos;
		kmalloc_pos += sz;
	}
	return res;
}
Beispiel #9
0
static void read_multiboot_info(multiboot_info_t* mbd)
{
	int i;
	multiboot_module_info_t *mod_infos;

	/* According to http://www.gnu.org/software/grub/manual/multiboot/multiboot.html
	   GRUB can store its values anywhere
	   I've discovered there are all in the first 640K, but I don't want to risk anything */
	if (mbd->flags & 0x01) memory_end = mbd->mem_upper * 1024; //TODO: A map would be nicer
	else memory_end = ASSUMED_WORKING_MEMEND;
	if (mbd->flags & 0x04) {
		strncpy(kernel_cmdline, (char *)mbd->cmdline, 256);
		kernel_cmdline[255] = 0;
	}
	if (mbd->flags & 0x08) {
		memset(boot_modules, 0, NR_BOOT_MODULES * sizeof(boot_module));
		boot_modules_count = mbd->mods_count;
		if (boot_modules_count > NR_BOOT_MODULES)
			boot_modules_count = NR_BOOT_MODULES;
		mod_infos = (multiboot_module_info_t *)mbd->mods_addr;
		for (i = 0; i < boot_modules_count; i++) {
			boot_modules[i].addr = mod_infos[i].mod_start;
			boot_modules[i].size = mod_infos[i].mod_end - mod_infos[i].mod_start;
			memset(boot_modules[i].string, 0, BOOT_MODULE_STRLEN);
			strncpy(boot_modules[i].string, (char*)mod_infos[i].string, BOOT_MODULE_STRLEN);
			boot_modules[i].string[BOOT_MODULE_STRLEN-1] = 0;
			if (*((UINT*)boot_modules[i].addr) == INITRD_MAGIC)
				initrd_location = boot_modules[i].addr;
		}
	}
	if (boot_modules_count)
		__working_memstart = boot_modules[boot_modules_count-1].addr + boot_modules[boot_modules_count-1].size;
	else __working_memstart = (UINT) &kernel_end;
	ASSERT_ALIGN(__working_memstart);
	kmalloc_pos = WORKING_MEMSTART + IPC_MEMSIZE;
}
Beispiel #10
0
int pdc_chassis_warn(struct pdc_chassis_warn *address)
{
	ASSERT_ALIGN(address, 4);

	return mem_pdc_call(PDC_CHASSIS, PDC_CHASSIS_WARN, __pa(address), 0);
}
Beispiel #11
0
/* verify address can be accessed without an HPMC */
int pdc_add_valid(void *address)
{
	ASSERT_ALIGN(address, 4);

	return mem_pdc_call(PDC_ADD_VALID, PDC_ADD_VALID_VERIFY, (unsigned long)address);
}
Beispiel #12
0
/* access the TOD clock */
int pdc_tod_read(struct pdc_tod *tod)
{
	ASSERT_ALIGN(tod, 8);
	return mem_pdc_call(PDC_TOD, PDC_TOD_READ, __pa(tod), 0);
}
Beispiel #13
0
int pdc_cache_info(struct pdc_cache_info *cache_info) {
	ASSERT_ALIGN(cache_info, 8);

	return mem_pdc_call(PDC_CACHE,PDC_CACHE_INFO,__pa(cache_info),0);
}
Beispiel #14
0
int pdc_model_info(struct pdc_model *model) {
	ASSERT_ALIGN(model, 8);
	return mem_pdc_call(PDC_MODEL,PDC_MODEL_INFO,__pa(model),0);
}