|
@@ -4,6 +4,7 @@
|
|
|
#include "bootinfo.h"
|
|
#include "bootinfo.h"
|
|
|
#include "serial.h"
|
|
#include "serial.h"
|
|
|
#include "vga.h"
|
|
#include "vga.h"
|
|
|
|
|
+#include "mtrr.h"
|
|
|
|
|
|
|
|
/* One bit per 4 KB page; bit set = in use.
|
|
/* One bit per 4 KB page; bit set = in use.
|
|
|
*
|
|
*
|
|
@@ -31,6 +32,7 @@ static unsigned int bitmap_bytes; /* page-rounded size when placed in RAM */
|
|
|
static unsigned int low_words; /* bitmap words below MM_MAX_PHYS */
|
|
static unsigned int low_words; /* bitmap words below MM_MAX_PHYS */
|
|
|
static unsigned int first_free; /* lowest lowmem word with a free bit */
|
|
static unsigned int first_free; /* lowest lowmem word with a free bit */
|
|
|
static unsigned int first_free_high; /* same for highmem (>= low_words) */
|
|
static unsigned int first_free_high; /* same for highmem (>= low_words) */
|
|
|
|
|
+unsigned int mm_uncached_high_mb, mm_uncached_low_mb;
|
|
|
static unsigned int free_pages;
|
|
static unsigned int free_pages;
|
|
|
static unsigned int total_ram_kb;
|
|
static unsigned int total_ram_kb;
|
|
|
|
|
|
|
@@ -278,6 +280,50 @@ void mm_init(void)
|
|
|
if (bitmap_bytes)
|
|
if (bitmap_bytes)
|
|
|
mark_used((unsigned int)bitmap, bitmap_bytes);
|
|
mark_used((unsigned int)bitmap, bitmap_bytes);
|
|
|
|
|
|
|
|
|
|
+ /* RAM the firmware's MTRRs leave uncached. A BIOS with too few
|
|
|
|
|
+ * variable ranges for a 3-4 GB board (the ION) can leave part of the
|
|
|
|
|
+ * RAM above the PCI hole UC; ring-3 heaps come from highmem first, so
|
|
|
|
|
+ * a page load's JavaScript then ran 100x slower. Such highmem is not
|
|
|
|
|
+ * handed out at all (lowmem still serves user pages); uncached lowmem
|
|
|
|
|
+ * is only reported, the kernel cannot do without it. */
|
|
|
|
|
+ {
|
|
|
|
|
+ unsigned long long a, lim = bitmap_limit();
|
|
|
|
|
+ unsigned int high_uc = 0, low_uc = 0, w;
|
|
|
|
|
+
|
|
|
|
|
+ if (lim > MM_HIGH_LIMIT)
|
|
|
|
|
+ lim = MM_HIGH_LIMIT;
|
|
|
|
|
+ for (a = 0x100000ull; a < lim; a += 0x100000ull) {
|
|
|
|
|
+ unsigned int w0 = (unsigned int)(a >> 17);
|
|
|
|
|
+ int any = 0, t;
|
|
|
|
|
+
|
|
|
|
|
+ for (w = w0; w < w0 + 8 && w < bitmap_words; w++)
|
|
|
|
|
+ if (bitmap[w] != 0xFFFFFFFFu)
|
|
|
|
|
+ any = 1;
|
|
|
|
|
+ if (!any)
|
|
|
|
|
+ continue; /* no free RAM in this MB */
|
|
|
|
|
+ t = mtrr_mem_type((unsigned int)a);
|
|
|
|
|
+ if (t < 0)
|
|
|
|
|
+ break; /* no usable MTRRs */
|
|
|
|
|
+ if (t == 6)
|
|
|
|
|
+ continue; /* write-back */
|
|
|
|
|
+ if (a >= MM_MAX_PHYS) {
|
|
|
|
|
+ mark_used(a, 0x100000ull);
|
|
|
|
|
+ high_uc++;
|
|
|
|
|
+ } else {
|
|
|
|
|
+ low_uc++;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ if (high_uc || low_uc) {
|
|
|
|
|
+ serial_puts(SERIAL_COM1, "mm: RAM not write-back by MTRR: ");
|
|
|
|
|
+ serial_putdec(SERIAL_COM1, high_uc);
|
|
|
|
|
+ serial_puts(SERIAL_COM1, " MB highmem (not used), ");
|
|
|
|
|
+ serial_putdec(SERIAL_COM1, low_uc);
|
|
|
|
|
+ serial_puts(SERIAL_COM1, " MB lowmem\n");
|
|
|
|
|
+ }
|
|
|
|
|
+ mm_uncached_high_mb = high_uc;
|
|
|
|
|
+ mm_uncached_low_mb = low_uc;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
/* Count free pages. */
|
|
/* Count free pages. */
|
|
|
free_pages = 0;
|
|
free_pages = 0;
|
|
|
for (i = 0; i < bitmap_words; i++) {
|
|
for (i = 0; i < bitmap_words; i++) {
|