All of lore.kernel.org
 help / color / mirror / Atom feed
* [Linux-ia64] Oops, here is the test program
@ 2001-04-20 16:47 Michael Madore
  0 siblings, 0 replies; only message in thread
From: Michael Madore @ 2001-04-20 16:47 UTC (permalink / raw)
  To: linux-ia64

[-- Attachment #1: Type: text/plain, Size: 93 bytes --]

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

-- 
Mike Madore
Software Engineer
TurboLinux, Inc.

[-- Attachment #2: test.c --]
[-- Type: text/plain, Size: 1134 bytes --]

#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;
}


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2001-04-20 16:47 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2001-04-20 16:47 [Linux-ia64] Oops, here is the test program Michael Madore

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.