1#!/bin/sh 2 3# 4# $FreeBSD$ 5# 6 7# Test scenario by Michiel Boland <michiel@boland.org> 8 9# panic: pmap_remove_all: page 0xc491f000 is fictitious 10 11[ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 12 13. ../default.cfg 14 15odir=`pwd` 16cd /tmp 17sed '1,/^EOF/d' < $odir/$0 > mmap.c 18cc -o mmap -Wall mmap.c 19rm -f mmap.c 20 21./mmap 22rm -f ./mmap 23exit 24 25EOF 26#include <sys/types.h> 27#include <sys/mman.h> 28#include <fcntl.h> 29#include <stdio.h> 30#include <unistd.h> 31 32static const off_t map_address = 0xa0000; 33static const size_t map_size = 0x1000; 34 35static int testit(int fd) 36{ 37 void *p; 38 int rv; 39 40 p = mmap(NULL, 2 * map_size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 41 map_address); 42 if (p == MAP_FAILED) { 43 perror("mmap"); 44 return -1; 45 } 46 rv = *(char *) p; 47 if (munmap(p, map_size) == -1) { 48 perror("munmap"); 49 return -1; 50 } 51 return rv; 52} 53 54int main(void) 55{ 56 int fd, rv; 57 58 fd = open("/dev/mem", O_RDWR); 59 if (fd == -1) { 60 perror("open"); 61 return 1; 62 } 63 rv = testit(fd); 64 close(fd); 65 return rv; 66} 67