[PATCH] qi: load specific kernel upon button press

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

[PATCH] qi: load specific kernel upon button press

Marc Andre Tanner
Hi,

As part of my qi-bootmenu project[1] I needed a way to launch a specific
kernel upon AUX press which contains an initramfs that scans the available
partitions and presents a list of bootable systems. I therefore came up
with the following patches.

The first patch adds the basic functionality and could probably be applied
because it won't change the behaviour at all if not configured by the
board_api to do so.

The remaining 2 patches change the board_api for gta02 and gta01 respectively
to load the kernel from NAND upon AUX press. They are only useful if you
are using a kernel which provides a bootmenu and therefore porbably shouldn't
be applied to mainline.

Anyway, let me know what you think.

Thanks,
Marc

[1] http://lists.openmoko.org/pipermail/devel/2009-October/006333.html


Reply | Threaded
Open this post in threaded view
|

[PATCH 1/3] Add functionality to load a specific kernel upon button press

Marc Andre Tanner
From: Marc Andre Tanner <[hidden email]>

Signed-off-by: Marc Andre Tanner <[hidden email]>
---
 include/qi.h |    4 ++++
 src/phase2.c |   10 +++++++++-
 2 files changed, 13 insertions(+), 1 deletions(-)

diff --git a/include/qi.h b/include/qi.h
index b99695d..62130e3 100644
--- a/include/qi.h
+++ b/include/qi.h
@@ -45,6 +45,7 @@ enum filesystem {
 enum ui_actions {
  UI_ACTION_ADD_DEBUG = (1 << 0),
  UI_ACTION_SKIPKERNEL = (1 << 1),
+ UI_ACTION_UI_KERNEL = (1 << 2),
 };
 
 enum ui_indication {
@@ -110,6 +111,9 @@ struct board_api {
  void (*set_ui_indication)(enum ui_indication);
 
  struct kernel_source kernel_source[8];
+ /* index into the array above, if this is != 0 then the corresponding
+ * kernel will be loaded upon the UI_ACTION_UI_KERNEL event */
+ int kernel_ui;
 };
 
 /* this is the board we are running on */
diff --git a/src/phase2.c b/src/phase2.c
index 4a7ff18..6889503 100644
--- a/src/phase2.c
+++ b/src/phase2.c
@@ -469,8 +469,16 @@ void bootloader_second_phase(void)
  /* we try the possible kernels for this board in order */
 
  for (this_kernel = this_board->kernel_source; this_kernel->name;
-    this_kernel++)
+     this_kernel++) {
+ if (this_board->kernel_ui && this_board->get_ui_keys &&
+    this_board->get_ui_keys() & UI_ACTION_UI_KERNEL) {
+ this_kernel = &this_board->kernel_source[this_board->kernel_ui];
+ try_this_kernel();
+ puts("Failed to boot UI Kernel\n");
+ break;
+ }
  try_this_kernel();
+ }
 
  /* none of the kernels worked out */
 
--
1.6.5


Reply | Threaded
Open this post in threaded view
|

[PATCH 2/3] gta02: load NAND kernel upon AUX press

Marc Andre Tanner
In reply to this post by Marc Andre Tanner
From: Marc Andre Tanner <[hidden email]>

Signed-off-by: Marc Andre Tanner <[hidden email]>
---
 src/cpu/s3c2442/gta02.c |   14 +++++++++++---
 1 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/src/cpu/s3c2442/gta02.c b/src/cpu/s3c2442/gta02.c
index 13be2ac..32a63bf 100644
--- a/src/cpu/s3c2442/gta02.c
+++ b/src/cpu/s3c2442/gta02.c
@@ -493,18 +493,24 @@ static u8 get_ui_keys_gta02(void)
  u8 ret = 0;
  static u8 old_keys = 0; /* previous state for debounce */
  static u8 older_keys = 0; /* previous debounced output for edge detect */
+ static u8 kernel_ui = 0;
 
  /* GPF6 is AUX on GTA02, map to UI_ACTION_SKIPKERNEL, down = 1 */
  keys = !!(rGPFDAT & (1 << 6));
 
  /* edge action */
- if ((old_keys & 1) && !(older_keys & 1))
- ret |= UI_ACTION_SKIPKERNEL;
+ if ((old_keys & 1) && !(older_keys & 1)) {
+ /* only generate 1 skip event if a bootmenu kernel is configured
+ * otherwise we would probably end up skipping the ui kernel too */
+ if (!board_api_gta02.kernel_ui || !kernel_ui)
+ ret |= UI_ACTION_SKIPKERNEL;
+ kernel_ui = UI_ACTION_UI_KERNEL;
+ }
 
  older_keys = old_keys;
  old_keys = keys;
 
- return ret;
+ return ret | kernel_ui;
 }
 
 static u8 get_ui_debug_gta02(void)
@@ -737,4 +743,6 @@ const struct board_api board_api_gta02 = {
       "root=/dev/mtdblock6 ",
  },
  },
+ /* boot NAND kernel on AUX press */
+ .kernel_ui = 3,
 };
--
1.6.5


Reply | Threaded
Open this post in threaded view
|

[PATCH 3/3] gta01: load NAND kernel upon AUX press

Marc Andre Tanner
In reply to this post by Marc Andre Tanner
From: Marc Andre Tanner <[hidden email]>

Signed-off-by: Marc Andre Tanner <[hidden email]>
---
 src/cpu/s3c2410/gta01.c |   14 +++++++++++---
 1 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/src/cpu/s3c2410/gta01.c b/src/cpu/s3c2410/gta01.c
index 4686fa2..242c46f 100644
--- a/src/cpu/s3c2410/gta01.c
+++ b/src/cpu/s3c2410/gta01.c
@@ -218,18 +218,24 @@ static u8 get_ui_keys_gta01(void)
  u8 ret = 0;
  static u8 old_keys = 0; /* previous state for debounce */
  static u8 older_keys = 0; /* previous debounced output for edge detect */
+ static u8 kernel_ui = 0;
 
  /* GPF6 is AUX on GTA01, map to UI_ACTION_SKIPKERNEL, down = 0 */
  keys = ! (rGPFDAT & (1 << 6));
 
  /* edge action */
- if ((old_keys & 1) && !(older_keys & 1))
- ret |= UI_ACTION_SKIPKERNEL;
+ if ((old_keys & 1) && !(older_keys & 1)) {
+ /* only generate 1 skip event if a bootmenu kernel is configured
+ * otherwise we would probably end up skipping the ui kernel too */
+ if (!board_api_gta01.kernel_ui || !kernel_ui)
+ ret |= UI_ACTION_SKIPKERNEL;
+ kernel_ui = UI_ACTION_UI_KERNEL;
+ }
 
  older_keys = old_keys;
  old_keys = keys;
 
- return ret;
+ return ret | kernel_ui;
 }
 
 static u8 get_ui_debug_gta01(void)
@@ -309,4 +315,6 @@ const struct board_api board_api_gta01 = {
        "root=/dev/mtdblock4 ",
  },
  },
+ /* boot NAND kernel on AUX press */
+ .kernel_ui = 3,
 };
--
1.6.5


Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] qi: load specific kernel upon button press

Paul Fertser
In reply to this post by Marc Andre Tanner
Hi,

Marc Andre Tanner <[hidden email]> writes:
> As part of my qi-bootmenu project[1] I needed a way to launch a specific
> kernel upon AUX press which contains an initramfs that scans the available
> partitions and presents a list of bootable systems. I therefore came up
> with the following patches.

I'm sorry but i can't quite understand the objective. The user has a
full and easy control over uSD contents so if he wants to use the NAND
kernel he can just make sure uSD doesn't have bootable (according to
Qi's notion partitions) so the whole card will be skipped and the NAND
kernel started anyway. What advantages does your patch have over
simply skipping the card automatically?

--
Be free, use free (http://www.gnu.org/philosophy/free-sw.html) software!
mailto:[hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] qi: load specific kernel upon button press

Marc Andre Tanner
On Wed, Dec 02, 2009 at 10:24:19AM +0300, Paul Fertser wrote:

> Hi,
>
> Marc Andre Tanner <[hidden email]> writes:
> > As part of my qi-bootmenu project[1] I needed a way to launch a specific
> > kernel upon AUX press which contains an initramfs that scans the available
> > partitions and presents a list of bootable systems. I therefore came up
> > with the following patches.
>
> I'm sorry but i can't quite understand the objective. The user has a
> full and easy control over uSD contents so if he wants to use the NAND
> kernel he can just make sure uSD doesn't have bootable (according to
> Qi's notion partitions) so the whole card will be skipped and the NAND
> kernel started anyway. What advantages does your patch have over
> simply skipping the card automatically?

Fair enough. Adding a noboot-* file to every SD partition except the
default one would accomplish the same thing. The only difference is
that it should be marginally faster because it won't look into every
partition for the noboot-* file.

Marc

--
 Marc Andre Tanner >< http://www.brain-dump.org/ >< GPG key: CF7D56C0