home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / unix / wizards / 3905 < prev    next >
Encoding:
Internet Message Format  |  1992-09-14  |  2.5 KB

  1. Path: sparky!uunet!mcsun!uknet!axion!hgreenho
  2. From: hgreenho@axion.bt.co.uk (Hilary Greenhow)
  3. Newsgroups: comp.unix.wizards
  4. Subject: Memory mapping to VMEbus
  5. Keywords: vme SunOS
  6. Message-ID: <1992Sep14.180808.26146@axion.bt.co.uk>
  7. Date: 14 Sep 92 18:08:08 GMT
  8. Sender: news@axion.bt.co.uk
  9. Organization: BT Laboratories
  10. Lines: 60
  11.  
  12. I am modifying a VME device driver for a SPARC 1E card running SunOS 4.1e 
  13. and am having problems mapping physical VME addresses to virtual addresses. 
  14.  
  15. For the simple case when I let the kernel do the mapping at config time I 
  16. get no problems. This method is not sufficient when I want to address the
  17. shared memory of other VME cards.
  18.  
  19. Ideally, for each card that I want to look at, I would like to be able
  20. to map 4Mbytes of shared memory into my virtual address space.  If
  21. this consumes too many resources I could live with mapping more
  22. smaller chunks (a total of about 250kBytes per card as 2 small bits and
  23. 1 big lump)
  24.  
  25. I believe that there are two approaches.
  26.     1) Using rmalloc and mapin (see below for my current suspect code)
  27.     2) Using segkmem_mapin
  28.  
  29. I have some documentation and an example for method 1 so may eventually
  30. get it to work. I am currently having problems. When I try to rmalloc
  31. enough clicks for 4Mbytes it fails. When I use a smaller number (1) the
  32. mapping appears to work but when I dereference any data I get a PAGE FAULT
  33. and panic.
  34.  
  35. I have failed to find documentation for method 2. Any examples would
  36. be appreciated
  37.  
  38. -- 
  39. E-Mail:       HGreenhow@axion.bt.co.uk (...mcvax!ukc!axion!hgreenhow)
  40. Organisation: BT Laboratories (Software Technology Division)
  41. Snail Mail:   BTL, Rm 306 SSTF, Martlesham Heath, IPSWICH IP5 7RE, UK
  42. Telephone:    +44 473 645573
  43.  
  44. *********************************
  45. Extract of code for method 1
  46.  
  47. /*
  48.    When SIZE_IN_BYTES 4Mbytes then rmalloc fails
  49.    When smaller then the mapping apparently works but I get a PAGE FAULT
  50.    and panic even when I think that I am accessing a valid address
  51. */
  52.   char *vaddr;        /* virtual address */
  53.   int kmx;            /* kernel map index */
  54.   int numClicks;
  55.   int addrOffset;
  56.  
  57.       numClicks = btoc ( SIZE_IN_BYTES);
  58.       addrOffset = (int)(addr - 
  59.              ptob (btop ((unsigned int) addr & 0xffffff)));
  60.       if ((kmx = rmalloc (kernelmap, numClicks)) == 0)
  61.     {
  62.       printf ("bp: no kernelmap for slave memory\n");
  63.       panic ("bpMapSlave");
  64.     }
  65.       vaddr = (char *)kmxtob (kmx);
  66.      
  67.       mapin (&Usrptmap [kmx], btop (vaddr), 
  68.          btop (pCpu->cd_pSlvAnchor) | PGT_VME_D32,
  69.          numClicks, PG_V | PG_KW);
  70.  
  71.       vaddr += addrOffset;
  72.