直接贴代码:
#include <sys/types.h>
#include <stdio.h>
#include <sys/ioctl.h>
#include <sys/mman.h>
#include <fcntl.h>
#include <memory.h>
#include <cutils/log.h>
#define AMLOGIC_NORMAL_BOOT 0x0
#define AMLOGIC_FACTORY_RESET_REBOOT 0x01010101
#define AMLOGIC_UPDATE_REBOOT 0x02020202
#define AMLOGIC_CHARGING_REBOOT 0x03030303
#define AMLOGIC_CRASH_REBOOT 0x04040404
#define AMLOGIC_FACTORY_TEST_REBOOT 0x05050505
#define AMLOGIC_SYSTEM_SWITCH_REBOOT 0x06060606
#define AMLOGIC_SAFE_REBOOT 0x07070707
#define AMLOGIC_LOCK_REBOOT 0x08080808
#define MESON_USB_BURNER_REBOOT 0x09090909
#define SRAM_SIZE 127*1024 + 512
#define SRAM_GRANULARITY 512
#define REBOOT_MODE_OFFSET (SRAM_SIZE + SRAM_GRANULARITY - 4)
#define BOOT_MODE_SRAM_BASE (0xC9000000)
int main(int argc,char *argv[])
{
int fd=-1;
if((fd=open("/dev/mem",O_RDWR|O_SYNC)) < 0)
{
return -