OSDN Git Service

armadillo: setenv/clearenv command support
authorSakae OTAKI <takinoya@users.sourceforge.jp>
Sat, 6 Mar 2010 02:23:25 +0000 (11:23 +0900)
committerSakae OTAKI <takinoya@users.sourceforge.jp>
Sat, 6 Mar 2010 02:23:25 +0000 (11:23 +0900)
setenv/clearenv commnad was ported from armadillo-9 code.
These are required to execute linux-2.6.x kernel test.

src/target/armadillo/linux.c
src/target/armadillo/loader.c
src/target/armadillo/memregions.h

index 0616536..31a11d0 100644 (file)
@@ -14,6 +14,8 @@
 #include "memmap.h"
 #include <target/memzero.h>
 
+#include <target/setenv.h>
+
 /* for setting the root device */
 #define MINORBITS       8
 #define MKDEV(ma,mi)    (((ma) << MINORBITS) | (mi))
@@ -340,6 +342,8 @@ static int boot_cmdfunc(int argc, char *argv[])
        ext2_inode       *pinode;
        ext2_dir_entry   *pde = 0;
        addr_t           load_address;
+       int              o_argc;
+       int              need_default_args = 0;
 
        char *flash_option[] = {
          0,
@@ -358,11 +362,41 @@ static int boot_cmdfunc(int argc, char *argv[])
 #endif
        };
 
+       if (argc > 1) {
+         o_argc = argc;
+       }
+       else {
+         o_argc = get_option_count ();
+       }
+
+       {
+       char *o_argv[o_argc + 3];
+       if (argc > 1) {
+         for (i = 0; i < argc; i++) {
+           o_argv[i] = argv[i];
+         }
+       }
+       else {
+         if (o_argc <= 1) {
+           need_default_args = 1;
+         }
+         else {
+           get_options(o_argv);
+         }
+       }
+
        if (!argc) {
          if (*(volatile unsigned char *)(0x80000000 + PDDR) &
              PDDR_FLASHBOOT) {
-           argc = sizeof (flash_option) / sizeof (char *);
-           argv = flash_option;
+               if (need_default_args) {
+                       o_argc = sizeof (flash_option) / sizeof (char *);
+                       for (i = 0; i < o_argc; i++) {
+                               o_argv[i] = flash_option[i];
+                       }
+               } else {
+                       get_options(o_argv);
+               }
+
          } else {
            if (ide_detect_devices ()) {
              return 0;
@@ -624,11 +658,17 @@ static int boot_cmdfunc(int argc, char *argv[])
                (" kernel", INITRD_LOAD_ADDRESS, LINUX_LOAD_ADDRESS);
              boost_off ();
            }
-           argc = sizeof (cf_option) / sizeof (char *);
            root[sizeof (root) - 2] = '1' + i;
-           argv = cf_option;
+           if (need_default_args) {
+             o_argc = sizeof (cf_option) / sizeof (char *);
+                 for (i = 0; i < o_argc; i++) {
+                       o_argv[i] = cf_option[i];
+                 }
+               }
          }
        }
+       argc = o_argc;
+       argv = o_argv;
 
        if (argc < 1)
                return -H_EUSAGE;
@@ -655,6 +695,8 @@ static int boot_cmdfunc(int argc, char *argv[])
 
        linux_cmdfunc (argc, argv);
 
+       }
+
        return 0;
 }
 
index 32201da..ead4ad1 100644 (file)
@@ -14,6 +14,8 @@
 #include "linux.h"
 #include "memmap.h"
 
+#include <target/setenv.h>
+
 /* timeout for auto-boot, in seconds */
 #define BOOT_TIMEOUT 5
 
@@ -22,6 +24,7 @@ char *target_profile = TARGET_PROFILE;
 static const command_t *commands[] = {
        &help_command,
        &boot_command,
+       &clearenv_command,
        &download_command,
        &flash_erase_command,
        &ether_mac_command,
@@ -31,6 +34,7 @@ static const command_t *commands[] = {
        &medium_command,
        &memmap_command,
        &flash_program_command,
+       &setenv_command,
        &unzip_command,
        &upload_command,
        &version_command,
index cece5c0..23a79ad 100644 (file)
@@ -17,6 +17,9 @@
 #define FLASH_CONFIG_START      (FLASH_USERLAND_START + FLASH_USERLAND_SIZE)
 #define FLASH_CONFIG_SIZE       (FLASH_BANK1_START + FLASH_BANK1_SIZE - FLASH_CONFIG_START)
 
+#define FLASH_OPTION_SIZE      0x2000
+#define FLASH_OPTION_START     (FLASH_KERNEL_START - FLASH_OPTION_SIZE)
+
 #define FLASH_BOOTLOADER_NAME   "bootloader"
 #define FLASH_KERNEL_NAME       "kernel"
 #define FLASH_USERLAND_NAME     "userland"