From 2f962fd45c7350188698858b1302628cb5c9c3b0 Mon Sep 17 00:00:00 2001 From: jmcmullan Date: Thu, 6 Oct 2011 22:28:25 +0000 Subject: [PATCH] arch/m68k-amiga: Small CHIP memory changes for AROSBootstrap AROSBootstrap now works properly on an A2000 with 1M CHIP and 8M Expansion Fast Signed-off-by: Jason S. McMullan git-svn-id: https://svn.aros.org/svn/aros/trunk/AROS@41774 fb15a70f-31f2-0310-bbcc-cdcc74a49acc --- arch/m68k-amiga/boot/aros-ram.ld | 9 +++- arch/m68k-amiga/boot/mmakefile.src | 16 +++--- arch/m68k-amiga/c/AROSBootstrap.c | 100 +++++++++++++++++++++---------------- 3 files changed, 72 insertions(+), 53 deletions(-) diff --git a/arch/m68k-amiga/boot/aros-ram.ld b/arch/m68k-amiga/boot/aros-ram.ld index b4e569f352..96f95ad97e 100755 --- a/arch/m68k-amiga/boot/aros-ram.ld +++ b/arch/m68k-amiga/boot/aros-ram.ld @@ -5,9 +5,12 @@ MEMORY { SECTIONS { - .ext : { _ext_start = .; + .start.MEMF_LOCAL : { +INCLUDE ../../../bin/amiga-m68k/gen/start_objs.ld + } >valid + .kick : { _kick_start = .; INCLUDE ../../../bin/amiga-m68k/gen/any_objs.ld - _ext_end = .; + _kick_end = .; } >valid .rom.MEMF_LOCAL : { _rom_start = .; INCLUDE ../../../bin/amiga-m68k/gen/local_objs.ld @@ -15,6 +18,8 @@ INCLUDE ../../../bin/amiga-m68k/gen/local_objs.ld *(.text .rodata .rodata.*) *(.eh_frame) _rom_end = .; + _ext_start = .; + _ext_end = .; } >valid /* SS, typically at 0x800-0x1000. Since MEMF_CHIP RAM starts at * 0x1000, this is a good place for it. Only used until after diff --git a/arch/m68k-amiga/boot/mmakefile.src b/arch/m68k-amiga/boot/mmakefile.src index 1fdc237b2b..7b125a3d25 100644 --- a/arch/m68k-amiga/boot/mmakefile.src +++ b/arch/m68k-amiga/boot/mmakefile.src @@ -233,7 +233,7 @@ KLIBS := exec expansion KDEVS := KHNDLRS := KHIDDS := -KRSRCS := kernel +KRSRCS := kernel FileSystem KHOOKS := KOBJS_local := $(addprefix $(KOBJSDIR)/,$(addsuffix _library.ko ,$(KLIBS))) \ @@ -247,17 +247,21 @@ KOBJS_local := $(addprefix $(KOBJSDIR)/,$(addsuffix _library.ko ,$(KLIBS))) \ OBJS_local:= $(addprefix $(KOBJSDIR)/,$(addsuffix .o,$(AFILES))) \ $(addprefix $(KOBJSDIR)/,$(addsuffix .o,$(FILES))) +OBJS_start := $(addprefix $(KOBJSDIR)/,$(addsuffix .o,$(AFILES))) \ + $(addprefix $(KOBJSDIR)/,$(addsuffix .o,$(FILES))) + + # Everything else. Can live in MEMF_ANY FILES := -AFILES := ext_entry +AFILES := -KLIBS := aros dos utility oop mathffp mathieeesingbas partition \ +KLIBS := aros utility dos oop mathffp mathieeesingbas partition \ keymap graphics layers intuition gadtools icon workbench 680x0 KDEVS := timer input keyboard console trackdisk gameport audio ata KHNDLRS := cdrom con afs amberram KHIDDS := hiddclass graphics keyboard mouse amigakbd amigamouse amigavideo uaegfx KRSRCS := battclock processor lddemon dosboot cia potgo disk \ - FileSystem misc shell shellcommands workbook wbtag cardres + misc shell shellcommands workbook wbtag cardres KHOOKS := alert KOBJS_any := \ @@ -269,13 +273,11 @@ KOBJS_any := \ $(addprefix $(KOBJSDIR)/,$(addsuffix _driver.ko ,$(KDRVRS) )) \ $(addprefix $(KOBJSDIR)/,$(addsuffix _hook.ko ,$(KHOOKS) )) -OBJS_any := $(addprefix $(KOBJSDIR)/,$(addsuffix .o,$(AFILES))) \ - $(addprefix $(KOBJSDIR)/,$(addsuffix .o,$(FILES))) - $(DISTDIR)/aros-amiga-m68k-ram.elf : $(DEPLIBS) $(SRCDIR)/$(CURDIR)/mmakefile.src \ $(OBJS_local) $(KOBJS_local) \ $(OBJS_any) $(KOBJS_any) \ $(SRCDIR)/$(CURDIR)/aros-ram.ld \ + $(GENDIR)/start_objs.ld \ $(GENDIR)/local_objs.ld \ $(GENDIR)/any_objs.ld @$(MKDIR) $(DISTDIR) diff --git a/arch/m68k-amiga/c/AROSBootstrap.c b/arch/m68k-amiga/c/AROSBootstrap.c index e8238deac9..3a29c88c9e 100644 --- a/arch/m68k-amiga/c/AROSBootstrap.c +++ b/arch/m68k-amiga/c/AROSBootstrap.c @@ -31,7 +31,7 @@ #include /* memcpy, memset */ #include -#define DEFAULT_KERNEL_CMDLINE "sysdebug=InitCode" +#define DEFAULT_KERNEL_CMDLINE "sysdebug=InitCode mungwall" #define PROTO_KERNEL_H /* Don't pick up AROS kernel hooks */ #define NO_SYSBASE_REMAP @@ -555,53 +555,66 @@ static void RTGPatch(struct Resident *r, BPTR seg) WriteF("Library path patched\n"); } -static struct Resident *LoadFindResident(BPTR seg) +#define RESLIST_CHUNK 100 +#define LRF_NOPATCH (1 << 0) /* If set, don't patch the struct Resident */ + +static struct Resident **LoadResident(BPTR seg, struct Resident **reslist, ULONG *resleft, ULONG flags) { - BPTR seglist = seg; - while (seglist) { - ULONG *ptr = BADDR(seglist); - UWORD *res; - LONG len = ptr[-1] - sizeof(BPTR); - - res = (UWORD*)(ptr + 1); - while (len >= offsetof(struct Resident, rt_Init) + sizeof(APTR)) { - if (*res == RTC_MATCHWORD && ((ULONG*)(res + 1))[0] == (ULONG)res) { - struct Resident *r = (struct Resident*)res; - /* Set RTF_COLDSTART if no initialization flags set */ - if (!(r->rt_Flags & (RTF_COLDSTART | RTF_SINGLETASK | RTF_AFTERDOS))) - r->rt_Flags |= RTF_COLDSTART; - if (r->rt_Pri < 10) - r->rt_Pri = 10; - RTGPatch(r, seg); - return r; - } - res++; - len -= 2; - } - seglist = *((BPTR*)BADDR(seglist)); + ULONG *ptr = BADDR(seg); + UWORD *res; + LONG len = ptr[-1] - sizeof(BPTR); + + res = (UWORD*)(ptr + 1); + while (len >= offsetof(struct Resident, rt_Init) + sizeof(APTR)) { + if (*res == RTC_MATCHWORD && ((ULONG*)(res + 1))[0] == (ULONG)res) { + struct Resident *r = (struct Resident*)res; + if (!(flags & LRF_NOPATCH)) { + /* Set RTF_COLDSTART if no initialization flags set */ + if (!(r->rt_Flags & (RTF_COLDSTART | RTF_SINGLETASK | RTF_AFTERDOS))) + r->rt_Flags |= RTF_COLDSTART; + if (r->rt_Pri < 10) + r->rt_Pri = 10; + RTGPatch(r, seg); + } + + if (*resleft == 0) { + struct Resident **resnew; + resnew = aosAllocMem(RESLIST_CHUNK * sizeof(struct Resident*), MEMF_CLEAR, SysBase); + if (!resnew) + return 0; + + *reslist = (APTR)((IPTR)resnew | RESLIST_NEXT); + reslist = resnew; + *resleft = RESLIST_CHUNK - 1; + } + WriteF("Resident structure found @%X8\n", r); + *(reslist++) = r; + (*resleft)--; + } + res++; + len -= 2; } - return NULL; + + return reslist; } -static struct Resident **LoadResidents(BPTR *namearray) +static struct Resident **LoadResidents(BPTR *namearray, struct Resident **resnext, ULONG *resleft) { - UBYTE rescnt, i; - struct Resident **reslist = NULL; + UBYTE i; SIPTR funcarray[] = { (SIPTR)aosRead, (SIPTR)aosAlloc, (SIPTR)aosFree, (SIPTR)aosSeek, }; - rescnt = 0; + for (i = 0; namearray[i]; i++) { - struct Resident *resident; LONG stack; BPTR handle; BPTR seglist = BNULL; BPTR bname; UBYTE *name; - + bname = namearray[i]; name = ConvertBSTR(bname); if (name) { @@ -611,25 +624,18 @@ static struct Resident **LoadResidents(BPTR *namearray) Close(handle); } if (seglist) { + BPTR seg; WriteF("Loaded '%S'\n", bname); - resident = LoadFindResident(seglist); - if (resident) { - if (!reslist) { - reslist = aosAllocMem(100 * sizeof(struct Resident*), MEMF_CLEAR, SysBase); - if (!reslist) - return NULL; - } - WriteF("Resident structure found @%X8\n", resident); - reslist[rescnt++] = resident; - } + for (seg = seglist; seg != BNULL; seg = *((BPTR*)BADDR(seg))) + resnext = LoadResident(seg, resnext, resleft, 0); } else { WriteF("Failed to load '%S', error %N\n", bname, IoErr()); } FreeString(name); } } - reslist[rescnt] = 0; - return reslist; + + return resnext; } #define FAKEBASE 0x200 @@ -985,17 +991,23 @@ __startup static AROS_ENTRY(int, startup, ROMSegList = ROMLoad(args[ARG_ROM]); if (ROMSegList != BNULL) { + ULONG resleft = 0; struct Resident **ResidentList; struct TagItem *KernelTags; WriteF("Successfully loaded ROM\n"); ROM_Loaded = TRUE; + struct Resident **resnext, *reshead = NULL; - ResidentList = LoadResidents(&args[ARG_MODULES]); + resnext = &reshead; + /* Only scan the 2nd section of the ROM segment */ + resnext = LoadResident(*((BPTR *)BADDR(ROMSegList)), resnext, &resleft, LRF_NOPATCH); + resnext = LoadResidents(&args[ARG_MODULES], resnext, &resleft); KernelTags = AllocKernelTags(BADDR(args[ARG_CMD])); WriteF("Booting...\n"); Delay(50); + ResidentList = (APTR)((IPTR)reshead & ~RESLIST_NEXT); BootROM(ROMSegList, ResidentList, KernelTags); UnLoadSeg(ROMSegList); -- 2.11.4.GIT