mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] DMI/APIC updates 2 of 4: boot-time-ioremap
@ 2002-01-02 19:08 Mikael Pettersson
  0 siblings, 0 replies; only message in thread
From: Mikael Pettersson @ 2002-01-02 19:08 UTC (permalink / raw)
  To: torvalds; +Cc: linux-kernel

Linus,

This is part 2 of 4 of a patch set for 2.5.2-pre6 to move the
x86 DMI scan to an earlier point in the boot sequence. This is
motivated by the UP APIC code, which must be disabled on some
machines with broken BIOSen, but there are also other cases that
would benefit from it. Tested. Please apply.

This second patch (patch-boot-time-ioremap) implements bt_ioremap(),
a clone of ioremap() which works early in the boot process. It
requires the boot-time-fixmaps patch I posted previously.

/Mikael

diff -ruN linux-2.5.2-pre6/arch/i386/mm/ioremap.c linux-2.5.2-pre6.boot-time-ioremap/arch/i386/mm/ioremap.c
--- linux-2.5.2-pre6/arch/i386/mm/ioremap.c	Tue Mar 20 17:13:33 2001
+++ linux-2.5.2-pre6.boot-time-ioremap/arch/i386/mm/ioremap.c	Wed Jan  2 00:56:14 2002
@@ -161,3 +161,68 @@
 	if (addr > high_memory)
 		return vfree((void *) (PAGE_MASK & (unsigned long) addr));
 }
+
+void __init *bt_ioremap(unsigned long phys_addr, unsigned long size)
+{
+	unsigned long offset, last_addr;
+	unsigned int nrpages;
+	enum fixed_addresses idx;
+
+	/* Don't allow wraparound or zero size */
+	last_addr = phys_addr + size - 1;
+	if (!size || last_addr < phys_addr)
+		return NULL;
+
+	/*
+	 * Don't remap the low PCI/ISA area, it's always mapped..
+	 */
+	if (phys_addr >= 0xA0000 && last_addr < 0x100000)
+		return phys_to_virt(phys_addr);
+
+	/*
+	 * Mappings have to be page-aligned
+	 */
+	offset = phys_addr & ~PAGE_MASK;
+	phys_addr &= PAGE_MASK;
+	size = PAGE_ALIGN(last_addr) - phys_addr;
+
+	/*
+	 * Mappings have to fit in the FIX_BTMAP area.
+	 */
+	nrpages = size >> PAGE_SHIFT;
+	if (nrpages > NR_FIX_BTMAPS)
+		return NULL;
+
+	/*
+	 * Ok, go for it..
+	 */
+	idx = FIX_BTMAP_BEGIN;
+	while (nrpages > 0) {
+		set_fixmap(idx, phys_addr);
+		phys_addr += PAGE_SIZE;
+		--idx;
+		--nrpages;
+	}
+	return (void*) (offset + fix_to_virt(FIX_BTMAP_BEGIN));
+}
+
+void __init bt_iounmap(void *addr, unsigned long size)
+{
+	unsigned long virt_addr;
+	unsigned long offset;
+	unsigned int nrpages;
+	enum fixed_addresses idx;
+
+	virt_addr = (unsigned long)addr;
+	if (virt_addr < fix_to_virt(FIX_BTMAP_BEGIN))
+		return;
+	offset = virt_addr & ~PAGE_MASK;
+	nrpages = PAGE_ALIGN(offset + size - 1) >> PAGE_SHIFT;
+
+	idx = FIX_BTMAP_BEGIN;
+	while (nrpages > 0) {
+		__set_fixmap(idx, 0, __pgprot(0));
+		--idx;
+		--nrpages;
+	}
+}
diff -ruN linux-2.5.2-pre6/include/asm-i386/io.h linux-2.5.2-pre6.boot-time-ioremap/include/asm-i386/io.h
--- linux-2.5.2-pre6/include/asm-i386/io.h	Tue Dec 18 00:40:12 2001
+++ linux-2.5.2-pre6.boot-time-ioremap/include/asm-i386/io.h	Wed Jan  2 00:56:14 2002
@@ -95,6 +95,14 @@
 extern void iounmap(void *addr);
 
 /*
+ * bt_ioremap() and bt_iounmap() are for temporary early boot-time
+ * mappings, before the real ioremap() is functional.
+ * A boot-time mapping is currently limited to at most 16 pages.
+ */
+extern void *bt_ioremap(unsigned long offset, unsigned long size);
+extern void bt_iounmap(void *addr, unsigned long size);
+
+/*
  * IO bus memory addresses are also 1:1 with the physical address
  */
 #define virt_to_bus virt_to_phys

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2002-01-02 19:09 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-01-02 19:08 [PATCH] DMI/APIC updates 2 of 4: boot-time-ioremap Mikael Pettersson

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®