一、源代码
1、头文件
./arch/arm/include/asm/arch-rockchip/hotkey.h :
#ifndef _ROCKCHIP_HOTKEY_H_
#define _ROCKCHIP_HOTKEY_H_
enum hotkey_t {
HK_INVAL,
HK_BROM_DNL,
HK_CLI_OS_PRE,
HK_CLI_OS_GO,
HK_CMDLINE,
HK_FASTBOOT,
HK_FDT,
HK_INITCALL,
HK_REGULATOR,
HK_ROCKUSB_DNL,
HK_SYSMEM,
};
bool is_hotkey(enum hotkey_t id);
void hotkey_run(enum hotkey_t id);
#endif
2、C文件
./arch/arm/mach-rockchip/hotkey.c :
#include <common.h>
#include <bidram.h>
#include <cli.h>
#include <console.h>
#include <sysmem.h>
#include <asm/arch/hotkey.h>
DECLARE_GLOBAL_DATA_PTR;
#define CTRL_A 0x01
#define CTRL_B 0x02
#define CTRL_D 0x04
#define CTRL_F 0x06
#define CTRL_I 0x09
#define CTRL_M 0x0d
#define CTRL_P 0x10
#define CTRL_R 0x12
#define CTRL_S 0x13
#define CTRL_T 0x14
bool is_hotkey(enum hotkey_t id)
{
switch (id) {
case HK_CMDLINE:
return gd->console_evt == CTRL_P;
case HK_INITCALL:
return gd->console_evt == CTRL_I;
case HK_REGULATOR:
return gd->console_evt == CTRL_R;
case HK_SYSMEM:
return gd->console_evt == CTRL_M;
case HK_BROM_DNL:
return gd->console_evt == CTRL_B;
#ifndef CONFIG_CONSOLE_DISABLE_CLI
case HK_ROCKUSB_DNL:
return gd->console_evt == CTRL_D;
case HK_FASTBOOT:
return gd->console_evt == CTRL_F;
#endif
default:
break;
}
return false;
}
void hotkey_run(enum hotkey_t id)
{
switch ((id)) {
case HK_SYSMEM:
if (gd->console_evt == CTRL_M) {
bidram_dump();
sysmem_dump();
}
break;
case HK_CMDLINE:
if (gd->console_evt == CTRL_P)
printf("cmdline: %s\n", env_get("bootargs"));
break;
case HK_INITCALL:
if (gd->console_evt == CTRL_I)
env_update("bootargs", "initcall_debug debug");
break;
case HK_FDT:
if (gd->console_evt == CTRL_T)
run_command("fdt print", 0);
break;
case HK_CLI_OS_PRE:
if (gd->console_evt == CTRL_A)
cli_loop();
break;
case HK_CLI_OS_GO:
if (gd->console_evt == CTRL_S)
cli_loop();
break;
default:
break;
}
}
二、各热键操作
操作 | 热键 |
---|
CTRL_A | HK_CLI_OS_PRE | CTRL_B | HK_BROM_DNL | CTRL_D | HK_ROCKUSB_DNL | CTRL_F | HK_FASTBOOT | CTRL_I | HK_INITCALL | CTRL_M | HK_SYSMEM | CTRL_P | HK_CMDLINE | CTRL_R | HK_REGULATOR | CTRL_S | HK_CLI_OS_GO | CTRL_T | HK_FDT |
|