Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 16 Jul 1996 12:32:16 -0600 (MDT)
From:      Nate Williams <nate@mt.sri.com>
To:        mobile@freebsd.org
Cc:        bde@freebsd.org, davidg@freebsd.org
Subject:   Possible fix for APM_DSVALUE_BUG
Message-ID:  <199607161832.MAA25236@rocky.mt.sri.com>

next in thread | raw e-mail | index | archive | help
OK, I lied about not getting to this this week. ;)

Based on a comment David Greenman made, I tried out the following code
and it seems to work.  At least, I can now run the APM commands on my
laptop w/out a kernel panic, although suspend/resume doesn't work
because the hardware suspend/resume on my box has been disabled for a
different project.

Again, this code is probably not going to be exactly the same as the
code in the final version, but functionally it should be similar.

Can ThinkPad owners please apply this to /sys/i386/i386/machdep.c, and
build a new kernel with it.  If it works (it should work fine), remove
the APM_DSVALUE_BUG option from the config file and see if it still
works.  (It should).

I'll be around today and tomorrow, but I'm leaving on my mini-vacation
Weds. night and won't be back until early next week.

For a description of the problem, see my previous article.


Nate
------
ps. To Bruce and David, can you review this patch and give me any
feedback/suggestions.  As it stands now this should work fine in
-current in spite of the bootblock differences, since the code is never
executed unless the bootblocks return valid information.  Also, please
note the code inside '#ifdef unsure_if_needed'.  Should the mapping have
to occur on page boundaries?  I am using it fine w/out the rounding down
right now.

--------
Index: machdep.c
===================================================================
RCS file: /home/CVS/src/sys/i386/i386/machdep.c,v
retrieving revision 1.195
diff -u -r1.195 machdep.c
--- machdep.c	1996/07/12 06:09:49	1.195
+++ machdep.c	1996/07/16 18:21:19
@@ -1239,9 +1239,39 @@
 	 * the official interface should be used.
 	 */
 	if (bootinfo.bi_memsizes_valid) {
-		if (bootinfo.bi_basemem != biosbasemem)
-			printf("BIOS basemem (%ldK) != RTC basemem (%dK)\n",
+		vm_offset_t pa, va,  tmpva;
+		vm_size_t size;
+		unsigned *pte;
+
+		if (bootinfo.bi_basemem != biosbasemem) {
+			printf("BIOS basemem (%ldK) != RTC basemem (%dK),",
 			       bootinfo.bi_basemem, biosbasemem);
+			printf(" setting to BIOS basemem\n");
+			biosbasemem = bootinfo.bi_basemem;
+			/*
+			 * XXX - Map this 'hole' of memory in the same manner
+			 * as the ISA_HOLE (read/write/non-cacheable), since
+			 * the BIOS 'fudges' it to become part of the ISA_HOLE.
+			 * This code is similar to the code used in
+			 * pmap_mapdev, but since no memory needs to be
+			 * allocated we simply change the mapping.
+			 */
+#ifdef unsure_if_needed
+			/* Round it down to the nearest page */
+			pa = rounddown(biosbasemem * 1024, PAGE_SIZE);
+#else
+			pa = biosbasemem * 1024;
+#endif
+			va = pa + KERNBASE;
+			size = roundup(ISA_HOLE_START - pa, PAGE_SIZE);
+			for (tmpva = va; size > 0;) {
+				pte = (unsigned *)vtopte(tmpva);
+				*pte = pa | PG_RW | PG_V | PG_N;
+				size -= PAGE_SIZE;
+				tmpva += PAGE_SIZE;
+				pa += PAGE_SIZE;
+			}
+		}
 		if (bootinfo.bi_extmem != biosextmem)
 			printf("BIOS extmem (%ldK) != RTC extmem (%dK)\n",
 			       bootinfo.bi_extmem, biosextmem);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199607161832.MAA25236>