From owner-freebsd-hackers Fri Aug 9 15:53:58 2002 Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 8679037B400 for ; Fri, 9 Aug 2002 15:53:46 -0700 (PDT) Received: from ash.drims.net (dom15-209.menta.net [62.57.118.209]) by mx1.FreeBSD.org (Postfix) with ESMTP id 1AF9C43E6E for ; Fri, 9 Aug 2002 15:51:57 -0700 (PDT) (envelope-from hal@telefonica.net) Received: from amavis by ash.drims.net with scanned-ok (Exim 3.35 #1 (Debian)) id 17dIbl-0000Wt-00 for ; Sat, 10 Aug 2002 00:51:49 +0200 Received: from [127.0.0.1] by ash.drims.net with smtp (Exim 3.35 #1 (Debian)) id 17dIaT-0000Wi-00 for ; Sat, 10 Aug 2002 00:50:58 +0200 Subject: Memory below 1 MB To: freebsd-hackers@freebsd.org Message-Id: From: hal@telefonica.net Date: Sat, 10 Aug 2002 00:50:58 +0200 X-Virus-Scanned: by AMaViS perl-11 Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG Hello, As I explained in another message, I am writing some graphics code (both for fun and educational purposes) and need to access memory below 1 MB. I have tried it by opening /dev/mem, calling mmap, i386_vm86 and even opening /dev/io to change permission levels. However, the program (and actually the physical terminal) hangs when doing the interruption call. I attach the test program within this mail. If attachments are not part of this list's etiquette, sorry, it will not happen again. Compile with "gcc -o whatever vesainfo.c" if you want to have a look (you will need root privileges to execute it). Well, I am completely desperate. I tried everything I could, but for some magical reasons, this low-level access does not work. Any ideas? Thank you in advance, Alex vesastructs.h: #ifndef __VESASTRUCTS_H #define __VESASTRUCTS_H typedef unsigned char byte; typedef unsigned short word; typedef unsigned int dword; struct VesaInfo { byte signature[4]; word version; char *oemName; dword capabilities; word *suppModes; word total64kBlocks; word oemSoftVersion; byte *vendorName; byte *productName; byte *productRev; word VBEAFVersion; word *accelSuppModes; byte reserved[216]; byte oemStrings[256]; }; #endif vesainfo.c: #include #include #include #include #include #include #include #include #include "vesastructs.h" int main (void) { struct vm86_init_args vm86init; struct vm86_intcall_args intargs; struct VesaInfo *vbeInfo; char c; int f, io; unsigned int len=0x400; int ioperm=0; f=open("/dev/mem", O_RDWR); if (f==-1) { printf("Could Not Access Memory\n"); return -1; } vbeInfo=(struct VesaInfo*)mmap((void*)0x10000, 0x1000, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_FIXED|MAP_SHARED, f, 0x10000); if (vbeInfo==MAP_FAILED) { printf("Peta mmap\n"); return -1; } memset(&vm86init, 0, sizeof(struct vm86_init_args)); memset(&intargs, 0, sizeof(struct vm86_intcall_args)); memset(vbeInfo, 0, sizeof(struct VesaInfo)); printf("vbeInfo = %p\n", vbeInfo); vbeInfo->signature[0]='V'; vbeInfo->signature[1]='B'; vbeInfo->signature[2]='E'; vbeInfo->signature[3]='2'; printf("vbeSig = %c%c%c%c\n", vbeInfo->signature[0], vbeInfo->signature[1], vbeInfo->signature[2], vbeInfo->signature[3]); // sleep(1); if (!i386_vm86(VM86_INIT, &vm86init)) { printf("VM86_INIT successful\n"); } intargs.intnum=0x10; intargs.vmf.vmf_ax=0x4f00; intargs.vmf.vmf_es=(((dword)vbeInfo)&0xf0000)>>4; /*0x1000;*/ intargs.vmf.vmf_di=((dword)vbeInfo)&0xffff; /*0x0000;*/ i386_set_ioperm(0, 0x400, 1); i386_get_ioperm(0, &len, &ioperm); printf("len=%x perm=%x\n", len, ioperm); // return -1; io=open("/dev/io", 0); if (io==-1) { printf("io pef\n"); return -1; } // sleep(1); printf("INTCALL (0x%x, ax=0x%.04x, es:di=%.04x:%.04x)\n", intargs.intnum, intargs.vmf.vmf_ax, intargs.vmf.vmf_es, intargs.vmf.edi.r_ex); if (!i386_vm86(VM86_INTCALL, &intargs)) { printf("VM86_INTCALL successful (ax=%.04x)\n", intargs.vmf.vmf_ax); } // sleep(1); printf("vbeVer\n"); // sleep(1); printf("VESA signature: %c%c%c%c\nVESA Version: 0x%.04x\n", vbeInfo->signature[0], vbeInfo->signature[1], vbeInfo->signature[2], vbeInfo->signature[3], vbeInfo->version); return 0; } To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message