From: huber@vxcrna.cern.ch (Sepp Huber, CERN -4439,-6712)
Subject: Re: global section PFN mapped
News-Software: VAX/VMS VNEWS 1.41    
Keywords: VMS , PFNMAP , GSD
Organization: European Organization for Nuclear Research, CERN
Date: Fri, 9 Oct 1992 19:58:00 GMT

In article <8OCT199216121138@srzts212>, sy_bodenmann@srzts212 (1.446 Bodenmann Roland) writes...
>Has anyone a code example to set up a PFNMAP global section.
>Preferable not in I/O Space. I need such a section to
>ensure the contents is never write to disk.
> 
Well to show how it's done (fairly simple), I addan example mapping a piece of 
uVAXII Q22 I/O space.
What You really ask for (and I haven't an example) is:
 * how to allocate memory
 * how to lock the pages in physical memory

-
Joseph "Sepp" Huber        | At present in CERN, phone -4439/-6712
Max-Planck-Institut Physik | Internet: huber@vxcern.cern.ch
Munich, Germany            | HEPnet:   VXCERN::HUBER

-------------------- cut here --------------------------------------
*   89/05/19 16:09:00 MEMBER NAME  MAPKS3912 FOR      JSH191 FORTRAN77
* Created 19-May-89 J.Huber MPI Muenchen -VAX version-
* Creates and/or maps to the Q22 I/O page to access the KS3912 CAMAC controller
      Logical Function MAP$KS3912( Create )
      Logical Create
* Input: Create: .true. => create Page-Frame global section, then map
*                .false. => map to existing PF global section 'GBL_KS3912'
* Output: function value .true. => success, .false. => system service error
      Include '($SSDEF)'
      Include '($SECDEF)'
      Include 'KS3912.CMN'
* IOUV2$AL_QB0SP is defined in macro $IOUV2DEF, not in Forsysdef !
      Integer IOUV2$AL_QB0SP
      Integer Q22$KS3912
*     Physical address format is
*    |--|--|-------------------------------------------|----------------------|
*    |31|30|29                                       9 |8                    0|
*    |  |  |        Page frame number PFN              |  byte within page    |
*    |--|--|-------------------------------------------|----------------------|
      Parameter (IOUV2$AL_QB0SP='20000000'X)	!Q22 space base address
						!bit 29 set -> Q22 I/O page
!      Parameter (Q22$KS3912='762000'O)       !'UNIBUS' address of KS3912 
      Parameter (Q22$KS3912='2000'O) !offset of KS3912 interface to Q22 base
      Integer Inadr(2),pagecount,pfn,flags
      Character*10 gsdnam
      Logical SYS$CRMPSC,SYS$MGBLSC            !system service functions
      Data gsdnam/'GBL_KS3912'/                !name of global section mapping K
*     Flag bits for create section: system-global,r/w,Page-Frame section,permane
      Flags = SEC$M_GBL.or.SEC$M_SYSGBL.or.SEC$M_WRT.or.SEC$M_PFNMAP
     &        .or.SEC$M_PERM
!!! test phase: make it a privat section:
!      Flags = SEC$M_WRT.or.SEC$M_PFNMAP
      pagecount = 2	!2 pages long
		!i.e. fortran common KS3912 should be of length 512 words	
*     extract PFN from KS3912 physical Q22 address for CRMPSC/MGBLSC service:
      PFN = 0
      Call MVBITS(IOUV2$AL_QB0SP+Q22$KS3912,9,21,PFN,0)
*     virtual (program-)address range to be mapped to Q22:
      Inadr(1) = %LOC(KS3912(0))          !start address of common KS3912
      Inadr(2) = %LOC(KS3912(24*16-1))    !highest address of common KS3912
*     create and/or map global section:
      If (create) Then
       MAP$KS3912 = SYS$CRMPSC(Inadr,,,%VAL(Flags),gsdnam,0,,%VAL(0),
     &                         %VAL(pagecount),%VAL(PFN),,)
      Else
       MAP$KS3912 = SYS$MGBLSC(Inadr,,,%VAL(Flags),gsdnam,0,)
      EndIf
      Return
      End
--------------- and KS3912.CMN --------------------------
* KS3912.CMN
!! VAX Version !!
C KS3912 CAMAC interface Q-bus addresses
!	CAMAC interface register addresses (KS3912 type controllers)
!	The CAMAC dataway is mapped to the UNIBUS (or LSI Q-bus) via a
!	block of 1400 (octal) addresses starting at a switch selectable base .
!	The first 6 addresses are controller internal data and status 
!	registers.
!
*	Minimal and maximal byte indizes for user addresses:
	Integer KSBMIN,KSBMAX
	Parameter (KSBMIN = 32)	     !N1.A0
	Parameter (KSBMAX = 24*32-2) !N23.A15
!	Integer*2 KS3912(0:24*16-1)
	Integer*2 KS3912(0:511)
	Common /KS3912/KS3912		!one crate
	Byte KSmodB(0:24*32-2)	!seen as bytes
	Integer*2 CCbase(0:5)
	Integer*2 CCadlo,CCadhi,CCallo,CCalhi,CCasr1,CCasr2
	Equivalence (KS3912(0),KSmodB(0),CCbase(0))
	Equivalence (CCbase(0),CCadlo)
	Equivalence (CCbase(1),CCadhi)
	Equivalence (CCbase(2),CCallo)
	Equivalence (CCbase(3),CCalhi)
	Equivalence (CCbase(4),CCasr1)
	Equivalence (CCbase(5),CCasr2)
c	CCBASE	= 160000	!base address of 1st KS3912 crate controller
c	CCadlo	= +0	!	0	!data low register
c	CCadhi	= +2	!	2	!data high register
c	CCallo	= +4	!	4	!LAM mask low 16 bits
c	CCalhi	= +6	!	6	!LAM mask high 6 bits
c	CCasr1	= +8.	!	8.	!control & status 1
c	CCasr2	= +10.	!	10.	!control & status 2
c	CCveca	= 400	!	KS3912 ITR vector base 1st crate
c


Newsgroups: comp.os.vms