From owner-freebsd-hackers Sun Jun 22 19:09:29 1997 Return-Path: Received: (from root@localhost) by hub.freebsd.org (8.8.5/8.8.5) id TAA04721 for hackers-outgoing; Sun, 22 Jun 1997 19:09:29 -0700 (PDT) Received: from genesis.atrad.adelaide.edu.au (genesis.atrad.adelaide.edu.au [129.127.96.120]) by hub.freebsd.org (8.8.5/8.8.5) with ESMTP id TAA04715 for ; Sun, 22 Jun 1997 19:09:19 -0700 (PDT) Received: (from msmith@localhost) by genesis.atrad.adelaide.edu.au (8.8.5/8.7.3) id LAA14132; Mon, 23 Jun 1997 11:39:08 +0930 (CST) From: Michael Smith Message-Id: <199706230209.LAA14132@genesis.atrad.adelaide.edu.au> Subject: Re: direct access In-Reply-To: from Steve Howe at "Jun 22, 97 03:43:36 pm" To: un_x@anchorage.net (Steve Howe) Date: Mon, 23 Jun 1997 11:39:07 +0930 (CST) Cc: hackers@FreeBSD.ORG X-Mailer: ELM [version 2.4ME+ PL28 (25)] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: owner-hackers@FreeBSD.ORG X-Loop: FreeBSD.org Precedence: bulk Steve Howe stands accused of saying: > > i wanted to port a hex/block editor from DOS. This is not a very useful thing to do. There are several quite good hex editors already in the ports collection. I use 'beav' more often than not. > it can read/write 1 RAM blocks > 2 Port Addresses > 3 Hard/Floppy Drives > 4 Files A user process on any Unix system cannot easily edit 1, 2 or 3. > > however, i am finding even simple things like ... > ///////////////////////////////////////////////// > int main (void) { > > unsigned char * p = (unsigned char *)0x000b8000; > > while ( 1 ) { printf("%c", *p++); getch(); } return 0; > } > ///////////////////////////////////////////////// > where i try to read the CGA/VGA screen, bomb with > "segmentation violation" errors. > > is the kernel examining op codes on the run, or what? No. You need to come to grips with the difference between physical and virtual addressing. Your process runs in a "virtual" address space, where the virtual address 0x000b8000 may be mapped to some physical address (but probably isn't). You cannot directly access the physical address 0x000b8000. This virtual:physical mapping provides numerous benefits - processes can be moved around in memory with impunity simply by changing their mappings and copying the physical pages. The mapping process also allows for virtual addresses not to be mapped to a physical address, and when an access occurs, the kernel catches the trap and can take such steps as copying the page in from disk, or performing a mapping as required. > is it at all possible to write Device editors? What is a "device editor"? You don't want to edit display memory; that will make the console driver unhappy. With the appropriate level of privilege you can use a binary editor on the disk devices in /dev and thus edit raw disk data. "editing" device ports doesn't seem to be terribly useful to me. -- ]] Mike Smith, Software Engineer msmith@gsoft.com.au [[ ]] Genesis Software genesis@gsoft.com.au [[ ]] High-speed data acquisition and (GSM mobile) 0411-222-496 [[ ]] realtime instrument control. (ph) +61-8-8267-3493 [[ ]] Unix hardware collector. "Where are your PEZ?" The Tick [[