home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!mcsun!uknet!axion!hgreenho
- From: hgreenho@axion.bt.co.uk (Hilary Greenhow)
- Newsgroups: comp.unix.wizards
- Subject: Memory mapping to VMEbus
- Keywords: vme SunOS
- Message-ID: <1992Sep14.180808.26146@axion.bt.co.uk>
- Date: 14 Sep 92 18:08:08 GMT
- Sender: news@axion.bt.co.uk
- Organization: BT Laboratories
- Lines: 60
-
- I am modifying a VME device driver for a SPARC 1E card running SunOS 4.1e
- and am having problems mapping physical VME addresses to virtual addresses.
-
- For the simple case when I let the kernel do the mapping at config time I
- get no problems. This method is not sufficient when I want to address the
- shared memory of other VME cards.
-
- Ideally, for each card that I want to look at, I would like to be able
- to map 4Mbytes of shared memory into my virtual address space. If
- this consumes too many resources I could live with mapping more
- smaller chunks (a total of about 250kBytes per card as 2 small bits and
- 1 big lump)
-
- I believe that there are two approaches.
- 1) Using rmalloc and mapin (see below for my current suspect code)
- 2) Using segkmem_mapin
-
- I have some documentation and an example for method 1 so may eventually
- get it to work. I am currently having problems. When I try to rmalloc
- enough clicks for 4Mbytes it fails. When I use a smaller number (1) the
- mapping appears to work but when I dereference any data I get a PAGE FAULT
- and panic.
-
- I have failed to find documentation for method 2. Any examples would
- be appreciated
-
- --
- E-Mail: HGreenhow@axion.bt.co.uk (...mcvax!ukc!axion!hgreenhow)
- Organisation: BT Laboratories (Software Technology Division)
- Snail Mail: BTL, Rm 306 SSTF, Martlesham Heath, IPSWICH IP5 7RE, UK
- Telephone: +44 473 645573
-
- *********************************
- Extract of code for method 1
-
- /*
- When SIZE_IN_BYTES 4Mbytes then rmalloc fails
- When smaller then the mapping apparently works but I get a PAGE FAULT
- and panic even when I think that I am accessing a valid address
- */
- char *vaddr; /* virtual address */
- int kmx; /* kernel map index */
- int numClicks;
- int addrOffset;
-
- numClicks = btoc ( SIZE_IN_BYTES);
- addrOffset = (int)(addr -
- ptob (btop ((unsigned int) addr & 0xffffff)));
- if ((kmx = rmalloc (kernelmap, numClicks)) == 0)
- {
- printf ("bp: no kernelmap for slave memory\n");
- panic ("bpMapSlave");
- }
- vaddr = (char *)kmxtob (kmx);
-
- mapin (&Usrptmap [kmx], btop (vaddr),
- btop (pCpu->cd_pSlvAnchor) | PGT_VME_D32,
- numClicks, PG_V | PG_KW);
-
- vaddr += addrOffset;
-