Hello all,
Some time ago I wrote some handy tool to dump the K8 memory map.
I'm attaching the tool as a patch.
Sample output: debian:/home/ruik/Moje_dilna/LinuxBIOSv2/util/k8resdump# ./k8resdump DRAM map: #0 0x0000000000 - 0x003fffffff Access: R/W IntlvEN:0x0 IntlvSEL:0x0 Dstnode:0 DRAM map: #1 0x0000000000 - 0x0000ffffff Access: / IntlvEN:0x0 IntlvSEL:0x0 Dstnode:1 DRAM map: #2 0x0000000000 - 0x0000ffffff Access: / IntlvEN:0x0 IntlvSEL:0x0 Dstnode:2 DRAM map: #3 0x0000000000 - 0x0000ffffff Access: / IntlvEN:0x0 IntlvSEL:0x0 Dstnode:3 DRAM map: #4 0x0000000000 - 0x0000ffffff Access: / IntlvEN:0x0 IntlvSEL:0x0 Dstnode:4 DRAM map: #5 0x0000000000 - 0x0000ffffff Access: / IntlvEN:0x0 IntlvSEL:0x0 Dstnode:5 DRAM map: #6 0x0000000000 - 0x0000ffffff Access: / IntlvEN:0x0 IntlvSEL:0x0 Dstnode:6 DRAM map: #7 0x0000000000 - 0x0000ffffff Access: / IntlvEN:0x0 IntlvSEL:0x0 Dstnode:7 MMIO map: #0 0x0000000000 - 0x000000ffff Access: / Dstnode:0 DstLink 0 MMIO map: #1 0x0000000000 - 0x000000ffff Access: / Dstnode:0 DstLink 0 MMIO map: #2 0x0000000000 - 0x000000ffff Access: / Dstnode:0 DstLink 0 MMIO map: #3 0x0000000000 - 0x000000ffff Access: / Dstnode:0 DstLink 0 MMIO map: #4 0x0000000000 - 0x000000ffff Access: / Dstnode:0 DstLink 0 MMIO map: #5 0x0000000000 - 0x000000ffff Access: / Dstnode:0 DstLink 0 MMIO map: #6 0x00000a0000 - 0x00000bffff Access: R/W Dstnode:0 DstLink 0 MMIO map: #7 0x0040000000 - 0x00ff70ffff Access: R/W Dstnode:0 DstLink 0 IO map: #0 0x000000 - 0x000fff Access: / Dstnode:0 DstLink 0 IO map: #1 0x001000 - 0x0fffff Access: R/W VGA Dstnode:0 DstLink 0 IO map: #2 0x000000 - 0x000fff Access: / Dstnode:0 DstLink 0 IO map: #3 0x000000 - 0x000fff Access: / Dstnode:0 DstLink 0
Signed-off-by: Rudolf Marek r.marek@assembler.cz
Rudolf
On Mon, Oct 29, 2007 at 11:09:18PM +0100, Rudolf Marek wrote:
Signed-off-by: Rudolf Marek r.marek@assembler.cz
OK, why not, let's add it to util/, might be useful more often.
A few minor issues (mostly to make the code look "familiar", i.e. similar to the rest of LinuxBIOS):
Index: util/k8resdump/k8resdump.c
--- util/k8resdump/k8resdump.c (revision 0) +++ util/k8resdump/k8resdump.c (revision 0) @@ -0,0 +1,117 @@ +/*
- This file is part of the LinuxBIOS project.
- Copyright (C) 2007 Rudolf Marek r.marek@assembler.cz
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License v2 as published by
- the Free Software Foundation.
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
+/* This program will dump the IO/memory/PCI resources from the K8
- memory controller
- */
+#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> +#include <sys/types.h> +#include <pci/pci.h>
+#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
+static unsigned char dram_bases[] =
uint8_t please (for all 'unsigned char' occurences in the code).
- { 0x40, 0x48, 0x50, 0x58, 0x60, 0x68, 0x70, 0x78 };
+static unsigned char dram_limits[] =
- { 0x44, 0x4C, 0x54, 0x5C, 0x64, 0x6C, 0x74, 0x7C };
+static unsigned char iomem_bases[] =
- { 0x80, 0x88, 0x90, 0x98, 0xA0, 0xA8, 0xB0, 0xB8 };
+static unsigned char iomem_limits[] =
- { 0x84, 0x8C, 0x94, 0x9C, 0xA4, 0xAC, 0xB4, 0xBC };
+static unsigned char pciio_bases[] = { 0xC0, 0xC8, 0xD0, 0xD8 }; +static unsigned char pciio_limits[] = { 0xC4, 0xCC, 0xD4, 0xDC };
+void print_info(struct pci_dev *dev) +{
- int i;
- unsigned int regb, regl;
uint32_t?
- for (i = 0; i < ARRAY_SIZE(dram_bases); i++) {
regb = pci_read_long(dev, dram_bases[i]);
regl = pci_read_long(dev, dram_limits[i]);
printf
("DRAM map: #%d 0x%04x000000 - 0x%04xffffff Access: %s/%s"
" IntlvEN:0x%x IntlvSEL:0x%x Dstnode:%d\n",
i, regb >> 16, regl >> 16, regb & 1 ? "R" : "",
regb & 2 ? "W" : "", (regb & 0x700) >> 8,
(regl & 0x700) >> 8, (regl & 0x7));
- }
- for (i = 0; i < ARRAY_SIZE(iomem_bases); i++) {
regb = pci_read_long(dev, iomem_bases[i]);
regl = pci_read_long(dev, iomem_limits[i]);
printf
("MMIO map: #%d 0x%06x0000 - 0x%06xffff Access: %s/%s %s %s"
" %s Dstnode:%d DstLink %d\n",
i, regb >> 8, regl >> 8, regb & 1 ? "R" : "",
regb & 2 ? "W" : "", regb & 4 ? "CPU Dis" : "",
regb & 8 ? "Locked" : "",
regl & 0x80 ? "NonPosted" : "", regl & 0x7,
(regl & 0x30) >> 4);
- }
- for (i = 0; i < ARRAY_SIZE(pciio_bases); i++) {
regb = pci_read_long(dev, pciio_bases[i]);
regl = pci_read_long(dev, pciio_limits[i]);
printf
(" IO map: #%d 0x%03x000 - 0x%03xfff Access: %s/%s %s %s"
" Dstnode:%d DstLink %d\n",
i, (regb & ~0xff000000) >> 12,
(regl & ~0xff000000) >> 12, regb & 1 ? "R" : "",
regb & 2 ? "W" : "", regb & 0x20 ? "ISA" : "",
regb & 0x10 ? "VGA" : "", regl & 0x7,
(regl & 0x30) >> 4);
- }
+}
+int main(void) +{
- struct pci_access *pacc;
- struct pci_dev *dev;
- if (getuid()) {
fprintf(stderr, "Please run me root, need access to all"
" PCI regs!\n");
exit(1);
- }
- pacc = pci_alloc();
- pci_init(pacc);
- pci_scan_bus(pacc);
- for (dev = pacc->devices; dev; dev = dev->next) {
pci_fill_info(dev, PCI_FILL_IDENT | PCI_FILL_BASES |
PCI_FILL_CLASS);
if ((dev->vendor_id == 0x1022) /* AMD */
&& (dev->device_id == 0x1101)) { /* Address MAP */
print_info(dev);
}
- }
- pci_cleanup(pacc);
- return 0;
+} Index: util/k8resdump/Makefile =================================================================== --- util/k8resdump/Makefile (revision 0) +++ util/k8resdump/Makefile (revision 0) @@ -0,0 +1,56 @@ +# +# Makefile for k8redump utility +# +# Original from Stefan Reinauer stepan@openbios.org
Yeah well, more or less a standard Makefile. Either (C) Stefan Reinauer or (C) Rudolf Marek, doesn't really matter much, but please add a license header.
+#
+PROGRAM = k8resdump
+CC = gcc +STRIP = strip +INSTALL = /usr/bin/install +PREFIX = /usr/local +#CFLAGS = -O2 -g -Wall -Werror +CFLAGS = -Os -Wall -Werror +OS_ARCH = $(shell uname) +ifeq ($(OS_ARCH), SunOS) +LDFLAGS = -lpci +else +LDFLAGS = -lpci -static +STRIP_ARGS = -s +endif
+OBJS = k8resdump.o
+all: pciutils dep $(PROGRAM)
+$(PROGRAM): $(OBJS)
- $(CC) -o $(PROGRAM) $(OBJS) $(LDFLAGS)
- $(STRIP) $(STRIP_ARGS) $(PROGRAM)
+clean:
- rm -f *.o *~
+distclean: clean
- rm -f $(PROGRAM) .dependencies
+dep:
- @$(CC) -MM *.c > .dependencies
+pciutils:
- @echo; echo -n "Checking for pciutils and zlib... "
- @$(shell ( echo "#include <pci/pci.h>"; \
echo "struct pci_access *pacc;"; \
echo "int main(int argc, char **argv)"; \
echo "{ pacc = pci_alloc(); return 0; }"; ) > .test.c )
- @$(CC) $(CFLAGS) .test.c -o .test $(LDFLAGS) &>/dev/null && \
echo "found." || ( echo "not found."; echo; \
echo "Please install pciutils-devel and zlib-devel."; \
echo "See README for more information."; echo; \
rm -f .test.c .test; exit 1)
- @rm -f .test.c .test
+.PHONY: all clean distclean dep pciutils
+-include .dependencies
Uwe.
* Rudolf Marek r.marek@assembler.cz [071029 23:09]:
Hello all,
Some time ago I wrote some handy tool to dump the K8 memory map.
I'm attaching the tool as a patch.
r2904
I incorporated Uwe's suggestions except the license header.
On 30/10/07 02:13 +0100, Stefan Reinauer wrote:
- Rudolf Marek r.marek@assembler.cz [071029 23:09]:
Hello all,
Some time ago I wrote some handy tool to dump the K8 memory map.
I'm attaching the tool as a patch.
r2904
I incorporated Uwe's suggestions except the license header.
Whoever was making the ebuilds for the tools - this is another good candidate.
Jordan