Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/epoc32 Support boot argument for kernel.



details:   https://anonhg.NetBSD.org/src/rev/3123ef2c3eec
branches:  trunk
changeset: 787485:3123ef2c3eec
user:      kiyohara <kiyohara%NetBSD.org@localhost>
date:      Thu Jun 20 13:36:48 2013 +0000

description:
Support boot argument for kernel.

diffstat:

 sys/arch/epoc32/include/bootinfo.h             |   8 ++++-
 sys/arch/epoc32/stand/e32boot/exe/e32boot.cpp  |  42 +++++++++++++++++++++----
 sys/arch/epoc32/stand/e32boot/exe/netbsd.cpp   |  12 ++++++-
 sys/arch/epoc32/stand/e32boot/exe/version      |   3 +-
 sys/arch/epoc32/stand/e32boot/include/netbsd.h |  12 ++++--
 5 files changed, 63 insertions(+), 14 deletions(-)

diffs (214 lines):

diff -r 1bde8d60aa62 -r 3123ef2c3eec sys/arch/epoc32/include/bootinfo.h
--- a/sys/arch/epoc32/include/bootinfo.h        Thu Jun 20 12:26:34 2013 +0000
+++ b/sys/arch/epoc32/include/bootinfo.h        Thu Jun 20 13:36:48 2013 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: bootinfo.h,v 1.1 2013/04/28 12:11:25 kiyohara Exp $    */
+/*     $NetBSD: bootinfo.h,v 1.2 2013/06/20 13:38:03 kiyohara Exp $    */
 /*
  * Copyright (c) 2012 KIYOHARA Takashi
  * All rights reserved.
@@ -40,6 +40,7 @@
 #define BTINFO_MODEL   1
 #define BTINFO_MEMORY  2
 #define BTINFO_VIDEO   3
+#define BTINFO_BOOTARGS        4
 
 #define BTINFO_MAX_SIZE        512
 
@@ -60,6 +61,11 @@
        int width;
        int height;
 };
+
+struct btinfo_bootargs {
+       struct btinfo_common common;
+       char bootargs[256];
+};
 #endif /* _LOCORE */
 
 #endif /* _EPOC32_BOOTINFO_H_ */
diff -r 1bde8d60aa62 -r 3123ef2c3eec sys/arch/epoc32/stand/e32boot/exe/e32boot.cpp
--- a/sys/arch/epoc32/stand/e32boot/exe/e32boot.cpp     Thu Jun 20 12:26:34 2013 +0000
+++ b/sys/arch/epoc32/stand/e32boot/exe/e32boot.cpp     Thu Jun 20 13:36:48 2013 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: e32boot.cpp,v 1.1 2013/04/28 12:11:26 kiyohara Exp $   */
+/*     $NetBSD: e32boot.cpp,v 1.2 2013/06/20 13:36:48 kiyohara Exp $   */
 /*
  * Copyright (c) 2012, 2013 KIYOHARA Takashi
  * All rights reserved.
@@ -131,6 +131,7 @@
        struct btinfo_common *bootinfo;
        struct btinfo_model *model;
        struct btinfo_video *video;
+       struct btinfo_bootargs *bootargs;
 
        console =
            Console::NewL(E32BootName, TSize(KConsFullScreen, KConsFullScreen));
@@ -160,6 +161,8 @@
 
        console->Printf(_L("\n"));
 
+       bootargs =
+           (struct btinfo_bootargs *)FindBootInfoL(bootinfo, BTINFO_BOOTARGS);
        TRAP(err, netbsd = LoadNetBSDL());
        if (err != KErrNone)
                User::Leave(err);
@@ -167,6 +170,12 @@
                return;
        console->Printf(_L("\nLoaded\n"));
 
+       int n, m;
+       n = sizeof(bootargs->bootargs);
+       m = (*netbsd->GetArgs()).Length();
+       Mem::Copy(bootargs->bootargs, &(*netbsd->GetArgs())[0], n < m ? n : m);
+       bootargs->bootargs[n < m ? n - 1 : m] = '\0';
+
        netbsd->ParseHeader();
 
        /* Load logical device(kernel part of e32boot). */
@@ -220,13 +229,15 @@
 LoadNetBSDL(void)
 {
        NetBSD *netbsd = NULL;
-       TBuf<KMaxCommandLine> input;
+       TBuf<KMaxCommandLine> input, *args;
        TPtrC Default = _L("C:\\netbsd");
        TPtrC Prompt = _L("Boot: ");
        TInt pos, err;
        TBool retry;
 
        input.Zero();
+       args = new TBuf<KMaxCommandLine>;
+       args->Zero();
        retry = false;
        console->Printf(Prompt);
        console->Printf(_L("["));
@@ -264,19 +275,29 @@
                        break;
                }
                if (gChar == EKeyEnter) {
-                       if (input.Length() > 0) {
-                               TBufC<KMaxCommandLine> kernel =
-                                   TBufC<KMaxCommandLine>(input);
+                       input.TrimAll();
+                       if (input[0] == '-')
+                               input.Swap(*args);
+                       for (int i = 0; i < input.Length(); i++)
+                               if (input[i] == ' ') {
+                                       args->Copy(input);
+                                       input.SetLength(i);
+                                       args->Delete(0, i + 1);
+                                       break;
+                               }
+                       args->ZeroTerminate();
 
-                               TRAP(err, netbsd = NetBSD::New(kernel));
+                       if (input.Length() > 0) {
+                               TRAP(err, netbsd = NetBSD::New(input, *args));
                        } else {
-                               TRAP(err, netbsd = NetBSD::New(Default));
+                               TRAP(err, netbsd = NetBSD::New(Default, *args));
                        }
                        if (err == 0 && netbsd != NULL)
                                break;
                        console->Printf(_L("\nLoad failed: %d\n"), err);
 
                        input.Zero();
+                       args->Zero();
                        console->Printf(Prompt);
                        pos = 0;
                        retry = true;
@@ -306,6 +327,7 @@
        struct btinfo_model *model;
        struct btinfo_memory *memory;
        struct btinfo_video *video;
+       struct btinfo_bootargs *bootargs;
        struct memmap *memmap;
        TUint memsize;
        TUint i;
@@ -361,6 +383,12 @@
                common = &(memory + 1)->common;
        }
 
+       common->len = sizeof(struct btinfo_bootargs);
+       common->type = BTINFO_BOOTARGS;
+       bootargs = (struct btinfo_bootargs *)common;
+       bootargs->bootargs[0] = '\0';
+       common = &(bootargs + 1)->common;
+
        common->len = 0;
        common->type = BTINFO_NONE;
 
diff -r 1bde8d60aa62 -r 3123ef2c3eec sys/arch/epoc32/stand/e32boot/exe/netbsd.cpp
--- a/sys/arch/epoc32/stand/e32boot/exe/netbsd.cpp      Thu Jun 20 12:26:34 2013 +0000
+++ b/sys/arch/epoc32/stand/e32boot/exe/netbsd.cpp      Thu Jun 20 13:36:48 2013 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: netbsd.cpp,v 1.1 2013/04/28 12:11:26 kiyohara Exp $    */
+/*     $NetBSD: netbsd.cpp,v 1.2 2013/06/20 13:36:48 kiyohara Exp $    */
 /*
  * Copyright (c) 2012 KIYOHARA Takashi
  * All rights reserved.
@@ -76,6 +76,16 @@
        return netbsd;
 }
 
+NetBSD *
+NetBSD::New(const TDesC &aFilename, const TDesC &aArgs)
+{
+       NetBSD *netbsd = New(aFilename);
+
+       netbsd->Args = &aArgs;
+
+       return netbsd;
+}
+
 
 void
 ELF::ParseHeader(void)
diff -r 1bde8d60aa62 -r 3123ef2c3eec sys/arch/epoc32/stand/e32boot/exe/version
--- a/sys/arch/epoc32/stand/e32boot/exe/version Thu Jun 20 12:26:34 2013 +0000
+++ b/sys/arch/epoc32/stand/e32boot/exe/version Thu Jun 20 13:36:48 2013 +0000
@@ -1,4 +1,4 @@
-$NetBSD: version,v 1.1 2013/04/28 12:11:26 kiyohara Exp $
+$NetBSD: version,v 1.2 2013/06/20 13:36:48 kiyohara Exp $
 
 NOTE ANY CHANGES YOU MAKE TO THE BOOTBLOCKS HERE.  The format of this
 file is important - make sure the entries are appended on end, last item
@@ -8,3 +8,4 @@
 0.2:           Load specific kernel.
 0.3:           Support SERIES5.
 1.0:           Initial release version.
+1.1:           Support boot argument for kernel.
diff -r 1bde8d60aa62 -r 3123ef2c3eec sys/arch/epoc32/stand/e32boot/include/netbsd.h
--- a/sys/arch/epoc32/stand/e32boot/include/netbsd.h    Thu Jun 20 12:26:34 2013 +0000
+++ b/sys/arch/epoc32/stand/e32boot/include/netbsd.h    Thu Jun 20 13:36:48 2013 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: netbsd.h,v 1.1 2013/04/28 12:11:27 kiyohara Exp $      */
+/*     $NetBSD: netbsd.h,v 1.2 2013/06/20 13:36:48 kiyohara Exp $      */
 /*
  * Copyright (c) 2012 KIYOHARA Takashi
  * All rights reserved.
@@ -43,16 +43,20 @@
 class NetBSD {
 public:
        static NetBSD *New(const TDesC &);
+       static NetBSD *New(const TDesC &, const TDesC &);
 
        virtual void ParseHeader(void);
-       TUint8 *getBuffer(void) { return Buffer; };
-       Elf32_Off getEntryPoint(void) { return EntryPoint; };
-       struct loaddesc *getLoadDescriptor(void) { return LoadDescriptor; };
+       TUint8 *GetBuffer(void) { return Buffer; };
+       Elf32_Off GetEntryPoint(void) { return EntryPoint; };
+       struct loaddesc *GetLoadDescriptor(void) { return LoadDescriptor; };
+       const TDesC *GetArgs(void) { return Args; };
 
 protected:
        TUint8 *Buffer;
        struct loaddesc *LoadDescriptor;        /* Must page aligned */
        Elf32_Off EntryPoint;
+
+       const TDesC *Args; 
 };
 
 class ELF : public NetBSD {



Home | Main Index | Thread Index | Old Index