[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [MiNT] PATCH] FreeMiNT MMU usage define
Vincent Rivière wrote:
If everyone agrees, I'm going to add -DUSE_MMU in the KERNELDEFS for all the
kernels except 68000 and ColdFire, then test that define in the sources.
Finally, I did the things a bit differently.
I have created a new define named WITH_MMU_SUPPORT. It is included by
default in KERNELDEFAULTDEFS, as it is part of a normal kernel. Then I
removed it explicitly for lightened kernels (68000, 68020, ColdFire).
As a result, mintv4e.prg now uses the fake mprot000.c (until someone writes
mprotv4e.c). As a side effect, mint000.prg is a bit smaller, since
WITH_MMU_SUPPORT is tested at a few more places than the previous M68000.
Important: this patch requires the previous info.patch about kernel_nocflags
usage.
Alan, please commit !
mmusupport.patch
New define WITH_MMU_SUPPORT to include MMU support. Contributed by Vincent
Riviere.
--
Vincent Rivière
diff -x CVS -aurN freemint.definitions/sys/KERNELDEFS freemint.work/sys/KERNELDEFS
--- freemint.definitions/sys/KERNELDEFS 2011-05-02 22:00:50.000000000 +0200
+++ freemint.work/sys/KERNELDEFS 2011-06-14 22:15:41.234375000 +0200
@@ -7,6 +7,7 @@
# -DSOFT_UNITABLE loadable unicode tables
# -DBUILTIN_SHELL include the built-in minimal shell
# -DC_ONLY replace some assembly function by C compatible one
+# -DWITH_MMU_SUPPORT include MMU support
#
# machine flags
@@ -46,6 +47,7 @@
KERNELDEFAULTDEFS = -D__KERNEL__
KERNELDEFAULTDEFS += -DLANG_ENGLISH
KERNELDEFAULTDEFS += -DVERBOSE_BOOT
+KERNELDEFAULTDEFS += -DWITH_MMU_SUPPORT
# added this to default-options for test-purpose for now
KERNELDEFAULTDEFS += -DWITH_SINGLE_TASK_SUPPORT
@@ -60,6 +62,7 @@
MINT = mint000.prg
CPU = 000
KERNELDEFS = -DM68000 -DNO_RAMFS -DNO_FAKE_SUPER
+kernel_nocflags = -DWITH_MMU_SUPPORT
endif
ifeq ($(kernel),030)
@@ -84,6 +87,7 @@
MINT = mint020.prg
CPU = 020
KERNELDEFS = -DM68000
+kernel_nocflags = -DWITH_MMU_SUPPORT
endif
ifeq ($(kernel),deb)
@@ -96,6 +100,7 @@
MINT = mintv4e.prg
CPU = v4e
KERNELDEFS = -DDEBUG_INFO -DM68040 -DNO_FAKE_SUPER -DCOLDFIRE -DC_ONLY
+kernel_nocflags = -DWITH_MMU_SUPPORT
endif
ifeq ($(kernel),mil)
diff -x CVS -aurN freemint.definitions/sys/arch/context.S freemint.work/sys/arch/context.S
--- freemint.definitions/sys/arch/context.S 2011-06-03 10:56:48.000000000 +0200
+++ freemint.work/sys/arch/context.S 2011-06-14 20:51:35.296875000 +0200
@@ -65,7 +65,9 @@
.globl _fpu
.globl _framesizes
.globl _new_trace // from intr.s
+#ifdef WITH_MMU_SUPPORT
.globl _no_mem_prot
+#endif
.text
@@ -75,7 +77,7 @@
movem.l d0-d7/a0-a6,(a0) // save registers D0-D7/A0-A6
-#ifndef M68000
+#ifdef WITH_MMU_SUPPORT
tst.w _no_mem_prot // is there memory protection?
bne.s noprot1
#if defined (M68040) || defined (M68060)
@@ -200,7 +202,7 @@
movem.l d0-d7/a0-a6,(a0) // save D0-D7/A0-A6
-#ifndef M68000
+#ifdef WITH_MMU_SUPPORT
tst.w _no_mem_prot
bne.s noprot2
move.w sr,d1
@@ -424,7 +426,7 @@
move.l C_TERM(a0),(0x408).w // restore GEMDOS terminate vector
#endif
-#ifndef M68000
+#ifdef WITH_MMU_SUPPORT
// Set memory context now
tst.w _no_mem_prot
bne.s noprot4
diff -x CVS -aurN freemint.definitions/sys/arch/init_mach.c freemint.work/sys/arch/init_mach.c
--- freemint.definitions/sys/arch/init_mach.c 2010-11-20 13:09:40.000000000 +0100
+++ freemint.work/sys/arch/init_mach.c 2011-06-14 20:54:18.921875000 +0200
@@ -140,6 +140,7 @@
break;
}
+#ifdef WITH_MMU_SUPPORT
case COOKIE_PMMU:
{
/* jr: if PMMU cookie exists, someone else is
@@ -149,6 +150,7 @@
no_mem_prot = 1;
break;
}
+#endif
case COOKIE_HADES:
{
diff -x CVS -aurN freemint.definitions/sys/arch/mprot.h freemint.work/sys/arch/mprot.h
--- freemint.definitions/sys/arch/mprot.h 2010-01-13 18:13:49.000000000 +0100
+++ freemint.work/sys/arch/mprot.h 2011-06-14 22:26:16.625000000 +0200
@@ -13,12 +13,14 @@
# include "mint/proc.h"
+#ifdef WITH_MMU_SUPPORT
extern int no_mem_prot;
extern long page_table_size;
extern ulong mem_prot_flags;
extern ulong mint_top_st;
extern ulong mint_top_tt;
+#endif
void init_tables (void);
int get_prot_mode (MEMREGION *);
diff -x CVS -aurN freemint.definitions/sys/arch/mprot000.c freemint.work/sys/arch/mprot000.c
--- freemint.definitions/sys/arch/mprot000.c 2007-07-13 23:32:49.000000000 +0200
+++ freemint.work/sys/arch/mprot000.c 2011-06-14 22:24:02.156250000 +0200
@@ -35,10 +35,7 @@
# include "memory.h"
-#ifdef M68000
-
-int no_mem_prot = 1;
-ulong mem_prot_flags = 0L; /* Bitvector, currently only bit 0 is used */
+#ifndef WITH_MMU_SUPPORT
void
init_tables(void)
@@ -110,4 +107,4 @@
return -1;
}
-#endif /* M68000 */
+#endif
diff -x CVS -aurN freemint.definitions/sys/arch/mprot030.c freemint.work/sys/arch/mprot030.c
--- freemint.definitions/sys/arch/mprot030.c 2010-01-13 18:13:49.000000000 +0100
+++ freemint.work/sys/arch/mprot030.c 2011-06-15 23:09:00.265625000 +0200
@@ -96,7 +96,7 @@
# include "cookie.h"
-#ifdef M68030
+#if defined(WITH_MMU_SUPPORT) && defined(M68030)
#if 0
#define MP_DEBUG(x) DEBUG(x)
@@ -1258,4 +1258,4 @@
return prot_temp(start, nbytes, -1);
}
-#endif /* M68030 */
+#endif
diff -x CVS -aurN freemint.definitions/sys/arch/mprot040.c freemint.work/sys/arch/mprot040.c
--- freemint.definitions/sys/arch/mprot040.c 2010-01-04 23:22:11.000000000 +0100
+++ freemint.work/sys/arch/mprot040.c 2011-06-15 23:10:16.343750000 +0200
@@ -133,7 +133,7 @@
# include "mmu.h"
-#if defined(M68040) || defined(M68060)
+#if defined(WITH_MMU_SUPPORT) && (defined(M68040) || defined(M68060))
#define MP_DEBUG_INFO DEBUG_INFO
@@ -1774,4 +1774,4 @@
# endif /* DEBUG_INFO */
}
-# endif /* M68040 || M68060 */
+#endif
diff -x CVS -aurN freemint.definitions/sys/arch/sig_mach.c freemint.work/sys/arch/sig_mach.c
--- freemint.definitions/sys/arch/sig_mach.c 2010-01-13 18:13:49.000000000 +0100
+++ freemint.work/sys/arch/sig_mach.c 2011-06-14 21:41:49.843750000 +0200
@@ -408,11 +408,13 @@
}
else if (signames[sig])
{
+# ifdef WITH_MMU_SUPPORT
if (!no_mem_prot && sig == SIGBUS)
{
/* already reported by report_buserr */
}
else
+# endif
{
/* uk: give some more information in case of a crash, so that a
* progam which shared text can be debugged better.
diff -x CVS -aurN freemint.definitions/sys/bootmenu.c freemint.work/sys/bootmenu.c
--- freemint.definitions/sys/bootmenu.c 2010-01-08 23:23:18.000000000 +0100
+++ freemint.work/sys/bootmenu.c 2011-06-15 22:49:43.703125000 +0200
@@ -192,7 +192,7 @@
static void
do_mem_prot(char *arg)
{
-# ifndef M68000
+# ifdef WITH_MMU_SUPPORT
no_mem_prot = (strncmp(arg, "YES", 3) == 0) ? 0 : 1; /* reversed */
# endif
}
@@ -200,7 +200,7 @@
static long
emit_mem_prot(short fd)
{
-# ifndef M68000
+# ifdef WITH_MMU_SUPPORT
char line[MAX_CMD_LEN];
ksprintf(line, sizeof(line), "MEM_PROT=%s\n", no_mem_prot ? "NO" : "YES");
@@ -572,7 +572,9 @@
option[1] = load_xfs_f; /* Load XFS or not */
option[2] = load_xdd_f; /* Load XDD or not */
option[3] = load_auto; /* Load AUTO or not */
+# ifdef WITH_MMU_SUPPORT
option[4] = !no_mem_prot; /* Use memprot or not */
+# endif
option[5] = step_by_step; /* Enter stepper mode */
option[6] = debug_level;
option[7] = out_device;
@@ -589,7 +591,7 @@
option[1] ? MSG_init_menu_yesrn : MSG_init_menu_norn,
option[2] ? MSG_init_menu_yesrn : MSG_init_menu_norn,
option[3] ? MSG_init_menu_yesrn : MSG_init_menu_norn,
-# ifndef M68000
+# ifdef WITH_MMU_SUPPORT
option[4] ? MSG_init_menu_yesrn : MSG_init_menu_norn,
# endif
( option[5] == -1 ) ? MSG_init_menu_yesrn : MSG_init_menu_norn,
@@ -614,7 +616,9 @@
load_xfs_f = option[1];
load_xdd_f = option[2];
load_auto = option[3];
+# ifdef WITH_MMU_SUPPORT
no_mem_prot = !option[4];
+# endif
step_by_step = option[5];
debug_level = option[6];
out_device = option[7];
@@ -633,7 +637,13 @@
modified = 1;
break;
}
- case '1' ... '5':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+# ifdef WITH_MMU_SUPPORT
+ case '5':
+# endif
{
int off;
diff -x CVS -aurN freemint.definitions/sys/cnf_mint.c freemint.work/sys/cnf_mint.c
--- freemint.definitions/sys/cnf_mint.c 2011-05-01 16:43:19.000000000 +0200
+++ freemint.work/sys/cnf_mint.c 2011-06-14 22:20:07.281250000 +0200
@@ -214,7 +214,9 @@
{ "KERN_BIOSBUF", PI_V_B, pCB_biosbuf },
{ "KERN_DEBUG_DEVNO", PI_R_S, & out_device, Range(0, 9) },
{ "KERN_DEBUG_LEVEL", PI_R_S, & debug_level, Range(0, 9) },
+# ifdef WITH_MMU_SUPPORT
{ "KERN_MPFLAGS", PI_R_L, & mem_prot_flags },
+# endif
{ "KERN_SECURITY_LEVEL", PI_V_L, pCL_securelevel, Range(0, 2) },
{ "KERN_SLICES", PI_R_S, & time_slice },
{ "PROC_MAXMEM", PI_V_L, pCB_maxmem },
@@ -243,7 +245,9 @@
{ "HIDE_B", PI_V_B, pCB_hide_b },
{ "INITIALMEM", PI_R_L, & initialmem },
{ "MAXMEM", PI_V_L, pCB_maxmem },
+# ifdef WITH_MMU_SUPPORT
{ "MPFLAGS", PI_R_L, & mem_prot_flags },
+# endif
{ "PRN", PI_V_T, pCB_prn },
{ "SECURELEVEL", PI_V_L, pCL_securelevel, Range(0, 2) },
{ "SLICES", PI_R_S, & time_slice },
diff -x CVS -aurN freemint.definitions/sys/cookie.c freemint.work/sys/cookie.c
--- freemint.definitions/sys/cookie.c 2010-09-25 16:30:13.000000000 +0200
+++ freemint.work/sys/cookie.c 2011-06-14 21:15:50.625000000 +0200
@@ -321,7 +321,7 @@
/* jr: install PMMU cookie if memory protection is used
*/
-# ifndef M68000
+# ifdef WITH_MMU_SUPPORT
if (!no_mem_prot)
{
TRACE(("PMMU cookie = %08lx", (long)0L));
diff -x CVS -aurN freemint.definitions/sys/dosmem.c freemint.work/sys/dosmem.c
--- freemint.definitions/sys/dosmem.c 2007-07-13 23:32:48.000000000 +0200
+++ freemint.work/sys/dosmem.c 2011-06-14 21:16:51.156250000 +0200
@@ -46,9 +46,11 @@
if (!suser (p->p_cred->ucr))
return EPERM;
+# ifdef WITH_MMU_SUPPORT
if (!no_mem_prot)
/* pretend to succeed */
return E_OK;
+# endif
for (x = 0; x < size; x += 0x2000)
{
diff -x CVS -aurN freemint.definitions/sys/info.c freemint.work/sys/info.c
--- freemint.definitions/sys/info.c 2010-01-04 23:22:11.000000000 +0100
+++ freemint.work/sys/info.c 2011-06-15 00:19:29.109375000 +0200
@@ -242,7 +242,7 @@
"<2> Load external XFS: %s"
"<3> Load external XDD: %s"
"<4> Execute AUTO PRGs: %s"
-# ifndef M68000
+# ifdef WITH_MMU_SUPPORT
"<5> Memory protection: %s"
# endif
"<6> Init step by step: %s"
diff -x CVS -aurN freemint.definitions/sys/init.c freemint.work/sys/init.c
--- freemint.definitions/sys/init.c 2011-03-21 09:33:04.000000000 +0100
+++ freemint.work/sys/init.c 2011-06-14 21:17:52.437500000 +0200
@@ -281,7 +281,7 @@
get_my_name();
-# ifndef M68000
+# ifdef WITH_MMU_SUPPORT
# ifdef VERBOSE_BOOT
boot_printf(MSG_init_mp, no_mem_prot ? MSG_init_mp_disabled : MSG_init_mp_enabled);
# endif
@@ -323,7 +323,7 @@
boot_printf(MSG_init_sysdrv_is, sysdrv + 'a');
# endif
-# ifndef M68000
+# ifdef WITH_MMU_SUPPORT
# ifdef VERBOSE_BOOT
boot_print(MSG_init_saving_mmu);
# endif
@@ -602,14 +602,12 @@
}
/* print the warning message if MP is turned off */
-# ifndef COLDFIRE
-# ifndef M68000
+# ifdef WITH_MMU_SUPPORT
if (no_mem_prot && mcpu > 20)
boot_print(memprot_warning);
stop_and_ask();
# endif
-# endif
/* initialize delay */
boot_print(MSG_init_delay_loop);
diff -x CVS -aurN freemint.definitions/sys/k_exec.c freemint.work/sys/k_exec.c
--- freemint.definitions/sys/k_exec.c 2011-05-01 17:05:06.000000000 +0200
+++ freemint.work/sys/k_exec.c 2011-06-14 22:22:15.265625000 +0200
@@ -751,6 +751,7 @@
}
else
{
+# ifdef WITH_MMU_SUPPORT
/* Update curproc's mmu table, but not
* for basepage and environment */
if ((m->loc != (unsigned long) b) &&
@@ -759,6 +760,7 @@
{
mark_proc_region(p->p_mem, m, PROT_I, p->pid);
}
+# endif
}
}
}
diff -x CVS -aurN freemint.definitions/sys/kernget.c freemint.work/sys/kernget.c
--- freemint.definitions/sys/kernget.c 2010-01-13 18:13:49.000000000 +0100
+++ freemint.work/sys/kernget.c 2011-06-14 21:18:54.390625000 +0200
@@ -621,7 +621,7 @@
{
greet1,
greet2,
-# ifndef M68000
+# ifdef WITH_MMU_SUPPORT
no_mem_prot ? memprot_warning : "",
# endif
# ifdef CRYPTO_CODE
diff -x CVS -aurN freemint.definitions/sys/kmemory.c freemint.work/sys/kmemory.c
--- freemint.definitions/sys/kmemory.c 2007-07-14 00:48:36.000000000 +0200
+++ freemint.work/sys/kmemory.c 2011-06-14 21:24:50.109375000 +0200
@@ -1583,7 +1583,11 @@
MEMREGION *m;
/* we can't support cmode if memory protection is disabled */
- if (cmode && no_mem_prot)
+ if (cmode
+# ifdef WITH_MMU_SUPPORT
+ && no_mem_prot
+# endif
+ )
return NULL;
m = kmr_get();
diff -x CVS -aurN freemint.definitions/sys/memory.c freemint.work/sys/memory.c
--- freemint.definitions/sys/memory.c 2010-01-13 18:13:49.000000000 +0100
+++ freemint.work/sys/memory.c 2011-06-15 23:06:39.843750000 +0200
@@ -2374,6 +2374,7 @@
DEBUG (("%lu: Contiguous memory regions not merged!", line));
DEBUG ((" m %lx, loc %lx, len %lx, links %u, next %lx", m, m->loc, m->len, m->links, m->next));
}
+# ifdef WITH_MMU_SUPPORT
else if (!no_mem_prot && (m->loc != ROUND(m->loc)))
{
ALERT ("%lu: Memory region unaligned", line);
@@ -2384,6 +2385,7 @@
ALERT ("%lu: Memory region length unaligned", line);
DEBUG (("%lu: Memory region length unaligned", line));
}
+# endif
if (m->save && !(m->mflags & M_FSAVED) && !m->shadow)
{
diff -x CVS -aurN freemint.definitions/sys/proc_help.c freemint.work/sys/proc_help.c
--- freemint.definitions/sys/proc_help.c 2010-01-13 18:13:49.000000000 +0100
+++ freemint.work/sys/proc_help.c 2011-06-15 22:59:35.531250000 +0200
@@ -57,7 +57,7 @@
void
init_page_table_ptr (struct memspace *m)
{
-# ifdef M68000
+# ifndef WITH_MMU_SUPPORT
m->page_table = NULL;
m->pt_mem = NULL;
# else
@@ -103,7 +103,7 @@
static void
free_page_table_ptr (struct memspace *m)
{
-# ifndef M68000
+# ifdef WITH_MMU_SUPPORT
if (!no_mem_prot)
{
# if defined(M68040) || defined(M68060)
@@ -176,9 +176,15 @@
if (!m->tp_reg)
m->tp_reg = get_region(core, user_things.len + PRIV_JAR_SIZE, PROT_P);
- TRACE(("copy_mem: ptr=%lx, m->pt_mem = %lx, m->tp_reg = %lx, mp=%s", ptr, m->pt_mem, m->tp_reg, no_mem_prot ? "off":"on"));
+ TRACE(("copy_mem: ptr=%lx, m->pt_mem = %lx, m->tp_reg = %lx, mp=%s", ptr, m->pt_mem, m->tp_reg,
+#ifdef WITH_MMU_SUPPORT
+ no_mem_prot
+#else
+ true
+#endif
+ ? "off":"on"));
-#ifdef M68000
+#ifndef WITH_MMU_SUPPORT
if (!ptr.c || !m->tp_reg)
#else
if ((!no_mem_prot && !m->pt_mem) || !ptr.c || !m->tp_reg)
diff -x CVS -aurN freemint.definitions/sys/ssystem.c freemint.work/sys/ssystem.c
--- freemint.definitions/sys/ssystem.c 2007-07-13 23:32:49.000000000 +0200
+++ freemint.work/sys/ssystem.c 2011-06-16 00:15:35.468750000 +0200
@@ -162,10 +162,14 @@
*/
case S_OSFEATURES:
{
+ r = 0;
+
+# ifdef WITH_MMU_SUPPORT
+ if (!no_mem_prot)
+ r |= 0x01;
+# endif
# ifdef CRYPTO_CODE
- r = ((!no_mem_prot) & 0x01) | 0x04;
-# else
- r = ((!no_mem_prot) & 0x01);
+ r |= 0x04;
# endif
break;
}
diff -x CVS -aurN freemint.definitions/sys/xbios.c freemint.work/sys/xbios.c
--- freemint.definitions/sys/xbios.c 2010-01-13 18:13:49.000000000 +0100
+++ freemint.work/sys/xbios.c 2011-06-14 21:39:31.843750000 +0200
@@ -427,6 +427,7 @@
sys_b_dosound (const char *p)
{
union { volatile char *vc; const char *cc; long l; } ptr; ptr.cc = p;
+# ifdef WITH_MMU_SUPPORT
if (!no_mem_prot && ptr.l >= 0)
{
MEMREGION *r;
@@ -447,6 +448,7 @@
mark_region (r, PROT_S, 0);
}
}
+# endif
ROM_Dosound (ptr.cc);