mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Ole André Vadla Ravnås" <oleavr-lkml@jblinux.net>
To: Steve Mickeler <steve@neptune.ca>
Cc: linux-kernel@vger.kernel.org
Subject: Re: Virtual to physical address mapping
Date: 18 Sep 2002 10:07:07 +0200	[thread overview]
Message-ID: <1032336427.5812.25.camel@zole.jblinux.net> (raw)
In-Reply-To: <Pine.LNX.4.44.0209180204380.2876-100000@triton.neptune.on.ca>

Thanks, but the address specified there is certainly not the same as the
base address ifconfig reports. I made a simple program to verify this:

# ./ioctl_test eth0
mem_start: 0x0
mem_end:   0x0
base_addr: 0xa000
irq:       10
dma:       0
port:      0

And /proc/pci tells me, for that device:
  Bus  0, device  15, function  0:
    Ethernet controller: Realtek Semiconductor Co., Ltd. RTL-8139/8139C
(rev 16).
      IRQ 10.
      Master Capable.  Latency=32.  Min Gnt=32.Max Lat=64.
      I/O at 0xd800 [0xd8ff].
      Non-prefetchable 32 bit memory at 0xe4005000 [0xe40050ff].

Is there any way I can map this 0xa000 address, which I assume is
virtual, to its physical address? I guess I'm very limited in userspace,
but are there any options or do I have to go about modifying the kernel?

The source for my test program is here for clarity's sake:
#include <stdio.h>
#include <errno.h>
#include <net/if.h>
#include <sys/ioctl.h>

int main(int argc, char *argv[])
{
	int fd;
	struct ifreq ifr;
	
	if (!argv[1]) {
		fprintf(stderr, "usage: %s [devname]\n", argv[0]);
		return 1;
	}
	
	fd = socket(AF_INET, SOCK_DGRAM, 0);
	
	if (fd < 0) {
		perror("failed to open socket");
		return 1;
	}

	memset(&ifr, 0, sizeof(struct ifreq));
	strcpy(ifr.ifr_name, argv[1]);
	
	if (ioctl(fd, SIOCGIFMAP, &ifr) < 0) {
		perror("ioctl failed");
		close(fd);
		return 1;
	}

	printf("mem_start: 0x%lx\n", ifr.ifr_map.mem_start);
	printf("mem_end:   0x%lx\n", ifr.ifr_map.mem_end);
	printf("base_addr: 0x%hx\n", ifr.ifr_map.base_addr);
	printf("irq:       %d\n", ifr.ifr_map.irq);
	printf("dma:       %d\n", ifr.ifr_map.dma);
	printf("port:      %d\n", ifr.ifr_map.port);
	
	close(fd);
	
	return 0;
}


Ole André

On Wed, 2002-09-18 at 08:05, Steve Mickeler wrote:
> 
> That info will be in /proc/pci
> 
> 
> On 18 Sep 2002, Ole André Vadla Ravnås wrote:
> 
> > Hi
> >
> > I've noticed that ifconfig shows a base address and an interrupt
> > number.. However, I can't get that base address to correspond to
> > anything in /proc/iomem, which means that I can't determine which PCI
> > device (in this case) it corresponds to (guess the base address is
> > virtual). What I want is to find a way to get the PCI bus and device no
> > for the network device, but is this at all possible without altering the
> > kernel?
> >
> > Ole André
> >
> >
> > -
> > To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> > the body of a message to majordomo@vger.kernel.org
> > More majordomo info at  http://vger.kernel.org/majordomo-info.html
> > Please read the FAQ at  http://www.tux.org/lkml/
> >
> 
> 
> 
> [-] Steve Mickeler [ steve@neptune.ca ]
> 
> [|] Todays root password is brought to you by /dev/random
> 
> [+] 1024D/9AA80CDF = 4103 9E35 2713 D432 924F  3C2E A7B9 A0FE 9AA8 0CDF
> 
> -
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/
> 



  reply	other threads:[~2002-09-18  7:58 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-09-18  5:54 Ole André Vadla Ravnås
2002-09-18  6:05 ` Steve Mickeler
2002-09-18  8:07   ` Ole André Vadla Ravnås [this message]
2002-09-18 12:06     ` Richard B. Johnson
2002-09-18 16:04       ` Ole André Vadla Ravnås
2002-09-18 11:47 ` Brian Gerst
2002-09-18 16:10   ` Ole André Vadla Ravnås
2002-09-18 14:46 ` Jonathan Lundell
2002-09-18 16:05   ` Ole André Vadla Ravnås

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1032336427.5812.25.camel@zole.jblinux.net \
    --to=oleavr-lkml@jblinux.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=steve@neptune.ca \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®