From owner-freebsd-amd64@FreeBSD.ORG Thu Oct 30 06:02:18 2014 Return-Path: Delivered-To: freebsd-amd64@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 0DF2060B for ; Thu, 30 Oct 2014 06:02:18 +0000 (UTC) Received: from mail-ie0-f182.google.com (mail-ie0-f182.google.com [209.85.223.182]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id D01DA6B4 for ; Thu, 30 Oct 2014 06:02:17 +0000 (UTC) Received: by mail-ie0-f182.google.com with SMTP id rd18so4577042iec.27 for ; Wed, 29 Oct 2014 23:02:11 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=nmOESFwRXsAMfElKnrQEVLCTy3txkyd0PM4s/fLdKFM=; b=RWvuA2tUp1LdmpP3CIJ6A3P3EuMU0JQ3fVZJQCs87WE2H6sxZKtah+ueVliD78jtil bSfyURsB4pJWHdUULyW3pBdz0qmLpLvvKebeDkldtDlN/+yiIIjnEOSz/bdkM8xSss1N ZJy2hxnFMPlupi2jWuGZBKePP9c5dztmJ1q+Dh+vpEqF/zwp+V45B+KKYa9OjoS+lGVf s2jtui8rIkPO8DFOEw5bhjL7FkFMbj86X/xJiyx513/ZCXIdhCMDJ4+0+EV8aShpb2f1 vWklRT0VWj0QP8V6koAHayhEUU4mhUTkNaHMXFEUKj6P83ttOcdiv7BFmuhcGqVbCpcF lhJA== X-Gm-Message-State: ALoCoQkYyEOoOZlM/sETLLRQ1vw/Dnl0CPOkgttFiK1H/VnzJwU2k4TP19DZHgfLPa8F2AVHU9F1 MIME-Version: 1.0 X-Received: by 10.107.163.142 with SMTP id m136mr16755587ioe.32.1414648560530; Wed, 29 Oct 2014 22:56:00 -0700 (PDT) Received: by 10.107.34.202 with HTTP; Wed, 29 Oct 2014 22:56:00 -0700 (PDT) In-Reply-To: <201410071050.34285.jhb@freebsd.org> References: <201410071050.34285.jhb@freebsd.org> Date: Thu, 30 Oct 2014 11:26:00 +0530 Message-ID: Subject: Re: memory type e820 From: Sourish Mazumder To: John Baldwin Content-Type: text/plain; charset=UTF-8 X-Content-Filtered-By: Mailman/MimeDel 2.1.18-1 Cc: freebsd-amd64@freebsd.org X-BeenThere: freebsd-amd64@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Porting FreeBSD to the AMD64 platform List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 30 Oct 2014 06:02:18 -0000 I have nvram device in my system. I am able to detect the nvram device address by scanning the bios_smap. How do I add this new found nvram memory into kernel address space? On Tue, Oct 7, 2014 at 8:20 PM, John Baldwin wrote: > On Wednesday, September 24, 2014 5:12:37 am Sourish Mazumder wrote: > > Hi, > > > > Does freebsd has a linux equivalent of the function e820_any_mapped() ? > > This function is used to scan the system memory for a specific type. > > > > How to scan the system memory in freebsd? > > There is not an equivalent function, no. There is phys_avail[] (memory > pages > available for the VM system to use, doesn't include some early allocations > such as the message buffer) and dump_avail[] (all memory pages). > > What are you trying to scan for? > > -- > John Baldwin > -- Sourish Mazumder 9986309755 From owner-freebsd-amd64@FreeBSD.ORG Thu Oct 30 15:49:05 2014 Return-Path: Delivered-To: freebsd-amd64@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 1F4BB4F7 for ; Thu, 30 Oct 2014 15:49:05 +0000 (UTC) Received: from mail-ie0-f181.google.com (mail-ie0-f181.google.com [209.85.223.181]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id E45F3B9E for ; Thu, 30 Oct 2014 15:49:04 +0000 (UTC) Received: by mail-ie0-f181.google.com with SMTP id rp18so3799250iec.12 for ; Thu, 30 Oct 2014 08:48:58 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:date:message-id:subject:from:to :content-type; bh=m9fGHWisObTw4yIJb/40riT72YWrQtDosb9bO8/RhOg=; b=BF7Fy5qisIRWrzGqPMLbgGhtmTLCcP45FTlEc2VhUT6Qdb/9IaPeJ2GpYK8bYuNZTK i3l5GO2KOWw5rsbkq4eK0KM8SG7Y+vKnEHOvczYCX1ktCo1d6QAkYb3CObSZCLoleq8U e1Bn6yzF11O8UKZXdOiPlDOW72JI61CB2Y1sFoK88oW6aExWjLukmKZKb2lwlXv9MxX8 /iFmlc9rUi2q5bDqtdIM8SPjGk3miZ2g0mpK9FahBkgI+XWFsrCjF54j/AtkmLkFCWZh wNWLdezkr5/taG2/2Xn8zDZxCaebncD0JBR/04KSwk0tvzxe7jrT4U9+OUHSUUmxdjbf iHwA== X-Gm-Message-State: ALoCoQnmFfy7NQLL3efkrYSulMTBssjZ9KhUep6097LxFLm21pCl75T+TuNIkv+TLaHpx7UUHlqJ MIME-Version: 1.0 X-Received: by 10.42.8.70 with SMTP id h6mr2714844ich.85.1414684138053; Thu, 30 Oct 2014 08:48:58 -0700 (PDT) Received: by 10.107.34.202 with HTTP; Thu, 30 Oct 2014 08:48:57 -0700 (PDT) Date: Thu, 30 Oct 2014 21:18:57 +0530 Message-ID: Subject: Detecting and using nvram memory From: Sourish Mazumder To: freebsd-amd64@freebsd.org Content-Type: text/plain; charset=UTF-8 X-Content-Filtered-By: Mailman/MimeDel 2.1.18-1 X-BeenThere: freebsd-amd64@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Porting FreeBSD to the AMD64 platform List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 30 Oct 2014 15:49:05 -0000 Hi, I have a nvram module in my system. I am able to detect the nvram memory address via the bios_smap. Now I want to be able to access this nvram memory for operations like memcpy(). What do I need to do for able to access this nvram memory? I went over the hammer_time() function defined in sys/amd64/amd64/machdep.c file. Here we call the getmemsize() function where we create the phys_avail[] array and call the PHYS_TO_DMAP to map the message buffers. Finally we call msgbufinit() function. Is anything more needed to be done for physical memory to be accessed? -- Sourish Mazumder From owner-freebsd-amd64@FreeBSD.ORG Thu Oct 30 16:11:14 2014 Return-Path: Delivered-To: freebsd-amd64@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 2849FC7B for ; Thu, 30 Oct 2014 16:11:14 +0000 (UTC) Received: from bigwig.baldwin.cx (bigwig.baldwin.cx [IPv6:2001:470:1f11:75::1]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 00490DC5 for ; Thu, 30 Oct 2014 16:11:13 +0000 (UTC) Received: from jhbbsd.localnet (unknown [209.249.190.124]) by bigwig.baldwin.cx (Postfix) with ESMTPSA id C1389B923; Thu, 30 Oct 2014 12:11:11 -0400 (EDT) From: John Baldwin To: Sourish Mazumder Subject: Re: memory type e820 Date: Thu, 30 Oct 2014 12:08:49 -0400 User-Agent: KMail/1.13.5 (FreeBSD/8.4-CBSD-20140415; KDE/4.5.5; amd64; ; ) References: <201410071050.34285.jhb@freebsd.org> In-Reply-To: MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-15" Content-Transfer-Encoding: 7bit Message-Id: <201410301208.50164.jhb@freebsd.org> X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.2.7 (bigwig.baldwin.cx); Thu, 30 Oct 2014 12:11:11 -0400 (EDT) Cc: freebsd-amd64@freebsd.org X-BeenThere: freebsd-amd64@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Porting FreeBSD to the AMD64 platform List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 30 Oct 2014 16:11:14 -0000 On Thursday, October 30, 2014 1:56:00 am Sourish Mazumder wrote: > I have nvram device in my system. I am able to detect the nvram device > address by scanning the bios_smap. > How do I add this new found nvram memory into kernel address space? Do you just want to map it so you can get a valid pointer or do you want it to be treated as normal memory by the VM system (i.e. available for use as pages in the VM page cache)? -- John Baldwin From owner-freebsd-amd64@FreeBSD.ORG Thu Oct 30 16:39:28 2014 Return-Path: Delivered-To: freebsd-amd64@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id CA359A0C for ; Thu, 30 Oct 2014 16:39:28 +0000 (UTC) Received: from mail-ie0-f169.google.com (mail-ie0-f169.google.com [209.85.223.169]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 9729F150 for ; Thu, 30 Oct 2014 16:39:28 +0000 (UTC) Received: by mail-ie0-f169.google.com with SMTP id tr6so5673173ieb.14 for ; Thu, 30 Oct 2014 09:39:27 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=2SJbDyjz24vHpy+hM9seR+s+UfeG21B28/XxEFoitjI=; b=bCCFtE9JLn/n5p2qq8Z2edd4cLaLPm3QVY3eOc+Bvpx/rg0EQBMgW5Sbm9WpYRSP89 ggFMZBJEWK1N87sHCBeLlAYOxg6OCgUjYgIkM1JQmZm0L3K8ReNjBKqouKxhEoiZPAND DaXk7wgguDsnmavwNTHPf/amsWj90nuMJXgXPYsg5cdlrcFaplJWS53pPwcbCwKmWPvQ d8QprcXufl7GIsPoQQAUuZpFrRg+zvTNlixXklTZN+9moQm/RB4CXoSCSc8nLL2CVESm mAwO8VbFhII5cmyPZIXnB0Ee0cM4F08AaR7/KkVqzWiA6SS79sFder44JbQSP5vc4opS SojA== X-Gm-Message-State: ALoCoQmSJwKC6RAB63Vz1Xr06mgVfvF6G7Fo28tgRxzV5hpNC4ZVsa/QqlMJ71idQks4P/vEzFAO MIME-Version: 1.0 X-Received: by 10.50.119.195 with SMTP id kw3mr21794380igb.5.1414687167201; Thu, 30 Oct 2014 09:39:27 -0700 (PDT) Received: by 10.107.34.202 with HTTP; Thu, 30 Oct 2014 09:39:27 -0700 (PDT) In-Reply-To: <201410301208.50164.jhb@freebsd.org> References: <201410071050.34285.jhb@freebsd.org> <201410301208.50164.jhb@freebsd.org> Date: Thu, 30 Oct 2014 22:09:27 +0530 Message-ID: Subject: Re: memory type e820 From: Sourish Mazumder To: John Baldwin Content-Type: text/plain; charset=UTF-8 X-Content-Filtered-By: Mailman/MimeDel 2.1.18-1 Cc: freebsd-amd64@freebsd.org X-BeenThere: freebsd-amd64@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Porting FreeBSD to the AMD64 platform List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 30 Oct 2014 16:39:29 -0000 Hi John, I want to make a block device out of this nvram memory. So, I will need to perform memcpy() operation into this memory. Do I need to add this memory into the vm system, if I need to do operations like memcpy(). On Thu, Oct 30, 2014 at 9:38 PM, John Baldwin wrote: > On Thursday, October 30, 2014 1:56:00 am Sourish Mazumder wrote: > > I have nvram device in my system. I am able to detect the nvram device > > address by scanning the bios_smap. > > How do I add this new found nvram memory into kernel address space? > > Do you just want to map it so you can get a valid pointer or do you want it > to be treated as normal memory by the VM system (i.e. available for use as > pages in the VM page cache)? > > -- > John Baldwin > -- Sourish Mazumder 9986309755 From owner-freebsd-amd64@FreeBSD.ORG Thu Oct 30 17:59:19 2014 Return-Path: Delivered-To: freebsd-amd64@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 141E5C73 for ; Thu, 30 Oct 2014 17:59:19 +0000 (UTC) Received: from bigwig.baldwin.cx (bigwig.baldwin.cx [IPv6:2001:470:1f11:75::1]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id E11BDCDC for ; Thu, 30 Oct 2014 17:59:18 +0000 (UTC) Received: from jhbbsd.localnet (unknown [209.249.190.124]) by bigwig.baldwin.cx (Postfix) with ESMTPSA id 8795DB926; Thu, 30 Oct 2014 13:59:17 -0400 (EDT) From: John Baldwin To: Sourish Mazumder Subject: Re: memory type e820 Date: Thu, 30 Oct 2014 13:53:05 -0400 User-Agent: KMail/1.13.5 (FreeBSD/8.4-CBSD-20140415; KDE/4.5.5; amd64; ; ) References: <201410301208.50164.jhb@freebsd.org> In-Reply-To: MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-15" Content-Transfer-Encoding: 7bit Message-Id: <201410301353.05185.jhb@freebsd.org> X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.2.7 (bigwig.baldwin.cx); Thu, 30 Oct 2014 13:59:17 -0400 (EDT) Cc: freebsd-amd64@freebsd.org X-BeenThere: freebsd-amd64@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Porting FreeBSD to the AMD64 platform List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 30 Oct 2014 17:59:19 -0000 On Thursday, October 30, 2014 12:39:27 pm Sourish Mazumder wrote: > Hi John, > > I want to make a block device out of this nvram memory. So, I will need to > perform memcpy() operation into this memory. > Do I need to add this memory into the vm system, if I need to do operations > like memcpy(). Ah, so you just need to map it. The most expedient thing you can do for this is: void *p; p = pmap_mapdev(physaddr, len); (This uses an uncached mapping). When you are finished (e.g during a detach routine if you need to unload the driver) you can do: pmap_unmapdev((vm_offset_t)p, len); Note that for a PCI BAR you would do something different, but for a resource you discover via the SMAP and is x86 specific this is ok. -- John Baldwin From owner-freebsd-amd64@FreeBSD.ORG Sat Nov 1 13:33:53 2014 Return-Path: Delivered-To: freebsd-amd64@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 0A12F2FC for ; Sat, 1 Nov 2014 13:33:53 +0000 (UTC) Received: from mail-ie0-f171.google.com (mail-ie0-f171.google.com [209.85.223.171]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id CB1AC865 for ; Sat, 1 Nov 2014 13:33:52 +0000 (UTC) Received: by mail-ie0-f171.google.com with SMTP id x19so2928906ier.30 for ; Sat, 01 Nov 2014 06:33:46 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=rdVz7viikNKteZ4c0IAMLA8mBg4AYbjYFF4/wUVTfWs=; b=P2rXQp0CBnpgwH/r9k+aiMEQ4szAVNqNTaWS8Bvsi86Ohw9y8UZw+3p67LkCG97oXW ioWb7//eKLjxSQwaawYLKVy0I6pNMq6+AJq99iHnxYENRmS3bxeByKi9I0KNsWeJN5/4 +aw2YVh/uEtqwrLQxVoJOFeHQ7vGPmad2Rq1zfUH+uhHOpJDNLD2oWM0Q90D2lok419x g5+wHvUkwtpJwP8QW6LiHdwx2Y5ud54n3Shf/mVu0KVCrf37i5AWz7psPZ924yDv5T7F y83QKuyPRWDAEPM1+tMAwbThUFX6Xmams4NrygE+qgSgxDF1u21BAAjRZ4usqRs70bnz onHA== X-Gm-Message-State: ALoCoQm7Vv5SIoFYQuj19iKIeJi8IbtH8eqyaT6PJ1S7+tVqJ/ciiC/H2yt6npeHZiUkXvVaTg93 MIME-Version: 1.0 X-Received: by 10.43.87.79 with SMTP id av15mr30142591icc.44.1414848353643; Sat, 01 Nov 2014 06:25:53 -0700 (PDT) Received: by 10.107.39.129 with HTTP; Sat, 1 Nov 2014 06:25:53 -0700 (PDT) In-Reply-To: <201410301353.05185.jhb@freebsd.org> References: <201410301208.50164.jhb@freebsd.org> <201410301353.05185.jhb@freebsd.org> Date: Sat, 1 Nov 2014 18:55:53 +0530 Message-ID: Subject: Re: memory type e820 From: Sourish Mazumder To: John Baldwin Content-Type: text/plain; charset=UTF-8 X-Content-Filtered-By: Mailman/MimeDel 2.1.18-1 Cc: freebsd-amd64@freebsd.org X-BeenThere: freebsd-amd64@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Porting FreeBSD to the AMD64 platform List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 01 Nov 2014 13:33:53 -0000 Hi John, I tried the pmap_mapdev() as suggested by you. Works perfectly. Thanks for the information. What is required, If I want to add this nvram memory to VM pages? On Thu, Oct 30, 2014 at 11:23 PM, John Baldwin wrote: > On Thursday, October 30, 2014 12:39:27 pm Sourish Mazumder wrote: > > Hi John, > > > > I want to make a block device out of this nvram memory. So, I will need > to > > perform memcpy() operation into this memory. > > Do I need to add this memory into the vm system, if I need to do > operations > > like memcpy(). > > Ah, so you just need to map it. The most expedient thing you can do for > this > is: > > void *p; > > p = pmap_mapdev(physaddr, len); > > (This uses an uncached mapping). > > When you are finished (e.g during a detach routine if you need to unload > the > driver) you can do: > > pmap_unmapdev((vm_offset_t)p, len); > > Note that for a PCI BAR you would do something different, but for a > resource > you discover via the SMAP and is x86 specific this is ok. > > -- > John Baldwin > -- Sourish Mazumder 9986309755