Skip to contentSkip to conversation

Oops, here is the test program

Linux-ia64 Michael Madore 1 participant 1 message Apr 20, 2001

lore
Share & tools
lore
#0 lore raw

Haven't had my morning caffeine yet. ;-)

Signature · 3 lines
Mike Madore
Software Engineer
TurboLinux, Inc.

#include <stdio.h>
#include <string.h>
#include <sys/io.h>
#include <asm/vm86.h>

#ifdef USE_LIBC_VM86
#include <sys/vm86.h>
#endif

#include <sys/types.h>
#include <sys/stat.h>
#include <sys/mman.h>
#include <unistd.h>
#include <fcntl.h>

#define REAL_MEM_BASE ((void *)0x10000)
#define REAL_MEM_SIZE 0x10000
#define REAL_MEM_BLOCKS 0x100

struct mem_block

	{
	unsigned int size : 20;
	unsigned int free : 1;
	};

static struct

	{
	int ready;
	int count;
	struct mem_block blocks[REAL_MEM_BLOCKS];
	} mem_info = { 0 };

static int
real_mem_init(void)

	{
	void *m;
	int fd_zero;

	if (mem_info.ready)
		return 1;

	fd_zero = open("/dev/zero", O_RDONLY);
	if (fd_zero == -1)
		{
		perror("open /dev/zero");
		return 0;
		}

	m = mmap((void *)REAL_MEM_BASE, REAL_MEM_SIZE,
	 PROT_READ | PROT_WRITE | PROT_EXEC,
	 MAP_FIXED | MAP_PRIVATE, fd_zero, 0);

	if (m == (void *)-1)
		{
		perror("mmap /dev/zero");
		close(fd_zero);
		return 0;
		}

	mem_info.ready = 1;
	mem_info.count = 1;
	mem_info.blocks[0].size = REAL_MEM_SIZE;
	mem_info.blocks[0].free = 1;
        
	return 1;
	}

int main( void )

{
	real_mem_init();
	return 0;
}