From owner-freebsd-hackers@FreeBSD.ORG Sat Jul 10 00:11:29 2004 Return-Path: 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 8EF1D16A4CE for ; Sat, 10 Jul 2004 00:11:29 +0000 (GMT) Received: from ms006msg.fastweb.it (ms006msg.fastweb.it [213.140.2.54]) by mx1.FreeBSD.org (Postfix) with ESMTP id 309CB43D2D for ; Sat, 10 Jul 2004 00:11:29 +0000 (GMT) (envelope-from thefly@acaro.org) Received: from tyler (1.10.185.81) by ms006msg.fastweb.it (7.0.028) id 40D855CC0023385B for freebsd-hackers@freebsd.org; Sat, 10 Jul 2004 02:11:27 +0200 Received: by tyler (Postfix, from userid 1000) id 532431AB494; Sat, 10 Jul 2004 02:15:12 +0200 (CEST) Date: Sat, 10 Jul 2004 02:15:12 +0200 From: thefly To: freebsd-hackers@freebsd.org Message-ID: <20040710001512.GA13356@tyler> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="YiEDa0DAkWCtVeE4" Content-Disposition: inline X-Editor: VIM - Vi IMproved 6.2 (2003 Jun 1, compiled May 20 2004 09:35:32) X-OS: Debian GNU/Linux 2.6.6 i686 User-Agent: Mutt/1.5.6+20040523i Subject: mmap() implementation X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 10 Jul 2004 00:11:29 -0000 --YiEDa0DAkWCtVeE4 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hello everybody, i'm implementing the mmap part of my nodegraph. At the moment i'm actually stuck at a point where the process can't actually access the memory allocation: this is the mmap() function: static int ng_counter_mmap(dev_t dev, vm_offset_t offset, vm_paddr_t *paddr, int nprot) { if (nprot !=3D VM_PROT_READ) return (-1); =20 *paddr =3D (vm_paddr_t) (ng_counters.B_array + offset / sizeof(u_in= t32_t)); =20 return (0); } ng_couters.B_array is u_int32_t *, and the memory is allocated via : counters->B_array =3D (u_int32_t*) contigmalloc((65536*2*sizeof(u_int32_t)= )+(65536*2*sizeof(u_int16_t)), M_NG_COUNTER, M_WAITOK | M_ZERO, 0, ~0, PAGE= _SIZE, 0); I actually need 2 u_int32_t arrays and two u_int16_t arrays, and need to ex= port all of them at the same time. I don't know if i need anything like vtophys() inside of that. The app in userspace does this: array =3D (unsigned int *) mmap(0, (65536*2*sizeof(u_int32_t))+(655= 36*2*sizeof(u_int16_t)), PROT_READ, 0, fd, 0); if(array =3D=3D (void *) -1){ printf("mmap failed\n"); return -1; } for(i=3D0; i<65536; i++){ printf("array[%d]=3D%u\n", i, *(array+i)); } i'm trying to print the values of the first array, but what i get is a lot of: array[484]=3D4294967295 array[485]=3D4294967295 array[486]=3D4294967295 array[487]=3D4294967295 array[488]=3D4294967295 array[489]=3D4294967295 Thanks in advance --=20 Claudio "thefly" Martella thefly@acaro.org GNU/PG keyid: 0x8EA95625 --YiEDa0DAkWCtVeE4 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.4 (GNU/Linux) iD8DBQFA7zUPygeBqo6pViURAsA/AKDA7Gwp0rbrZ0L1CmcneXc62OmsNACdEM+w FL8+9wPfiTP0+cUMpH9dRyI= =VrLK -----END PGP SIGNATURE----- --YiEDa0DAkWCtVeE4--