Exemplo n.º 1
0
static void process_kernel_cmdline() {
    // Don't expose the raw commandline to unprivileged processes.
    chmod("/proc/cmdline", 0440);

    // The first pass does the common stuff, and finds if we are in qemu.
    // The second pass is only necessary for qemu to export all kernel params
    // as properties.
    import_kernel_cmdline(false, import_kernel_nv);
    if (qemu[0]) import_kernel_cmdline(true, import_kernel_nv);
}
Exemplo n.º 2
0
static int set_init_properties_action(int nargs, char **args)
{
    char tmp[PROP_VALUE_MAX];

    if (qemu[0])
        import_kernel_cmdline(1, import_kernel_nv);

    if (!strcmp(bootmode,"factory"))
        property_set("ro.factorytest", "1");
    else if (!strcmp(bootmode,"factory2"))
        property_set("ro.factorytest", "2");
    else
        property_set("ro.factorytest", "0");

    property_set("ro.serialno", serialno[0] ? serialno : "");
    property_set("ro.bootmode", bootmode[0] ? bootmode : "unknown");
    property_set("ro.baseband", baseband[0] ? baseband : "unknown");
    property_set("ro.carrier", carrier[0] ? carrier : "unknown");
    property_set("ro.bootloader", bootloader[0] ? bootloader : "unknown");

    property_set("ro.hardware", hardware);
    snprintf(tmp, PROP_VALUE_MAX, "%d", revision);
    property_set("ro.revision", tmp);
    property_set("ro.emmc",emmc_boot ? "1" : "0");
    return 0;
}
static void process_kernel_cmdline(void)
{
    /* don't expose the raw commandline to nonpriv processes */
    chmod("/proc/cmdline", 0440);

    /* first pass does the common stuff, and finds if we are in qemu.
     * second pass is only necessary for qemu to export all kernel params
     * as props.
     */
    import_kernel_cmdline(0, import_kernel_nv);
    if (qemu[0])
        import_kernel_cmdline(1, import_kernel_nv);

    /* now propogate the info given on command line to internal variables
     * used by init as well as the current required properties
     */
    export_kernel_boot_props();
}
Exemplo n.º 4
0
static selinux_enforcing_status selinux_status_from_cmdline() {
    selinux_enforcing_status status = SELINUX_ENFORCING;

    import_kernel_cmdline(false, [&](const std::string& key, const std::string& value, bool in_qemu) {
        if (key == "androidboot.selinux" && value == "permissive") {
            status = SELINUX_PERMISSIVE;
        }
    });

    return status;
}
Exemplo n.º 5
0
int ueventd_main(int argc, char **argv)
{
    struct pollfd ufd;
    int nr;
    char tmp[32];

        /* Prevent fire-and-forget children from becoming zombies.
         * If we should need to wait() for some children in the future
         * (as opposed to none right now), double-forking here instead
         * of ignoring SIGCHLD may be the better solution.
         */
    signal(SIGCHLD, SIG_IGN);

    open_devnull_stdio();
    klog_init();

    INFO("starting ueventd\n");

    /* Respect hardware passed in through the kernel cmd line. Here we will look
     * for androidboot.hardware param in kernel cmdline, and save its value in
     * hardware[]. */
    import_kernel_cmdline(0, import_kernel_nv);

    get_hardware_name(hardware, &revision);

    ueventd_parse_config_file("/ueventd.rc");

    snprintf(tmp, sizeof(tmp), "/ueventd.%s.rc", hardware);
    ueventd_parse_config_file(tmp);

    device_init();

    ufd.events = POLLIN;
    ufd.fd = get_device_fd();

    while(1) {
        ufd.revents = 0;
        nr = poll(&ufd, 1, -1);
        if (nr <= 0)
            continue;
        if (ufd.revents == POLLIN)
               handle_device_fd();
    }
}
void vendor_load_properties()
{
    import_kernel_cmdline(0, import_kernel_nv);
}
Exemplo n.º 7
0
int main(int argc, char **argv)
{
    int fd_count = 0;
    struct pollfd ufds[4];
    char *tmpdev;
    char* debuggable;
    char tmp[32];
    int property_set_fd_init = 0;
    int signal_fd_init = 0;
    int keychord_fd_init = 0;

    if (!strcmp(basename(argv[0]), "ueventd"))
        return ueventd_main(argc, argv);

    /* clear the umask */
    umask(0);

        /* Get the basic filesystem setup we need put
         * together in the initramdisk on / and then we'll
         * let the rc file figure out the rest.
         */
    mkdir("/dev", 0755);
    mkdir("/proc", 0755);
    mkdir("/sys", 0755);

    mount("tmpfs", "/dev", "tmpfs", MS_NOSUID, "mode=0755");
    mkdir("/dev/pts", 0755);
    mkdir("/dev/socket", 0755);
    mount("devpts", "/dev/pts", "devpts", 0, NULL);
    mount("proc", "/proc", "proc", 0, NULL);
    mount("sysfs", "/sys", "sysfs", 0, NULL);

        /* indicate that booting is in progress to background fw loaders, etc */
    close(open("/dev/.booting", O_WRONLY | O_CREAT, 0000));

        /* We must have some place other than / to create the
         * device nodes for kmsg and null, otherwise we won't
         * be able to remount / read-only later on.
         * Now that tmpfs is mounted on /dev, we can actually
         * talk to the outside world.
         */
    open_devnull_stdio();
    klog_init();

    INFO("reading config file\n");

    if (!charging_mode_booting())
       init_parse_config_file("/init.rc");
    else
       init_parse_config_file("/lpm.rc");

    /* pull the kernel commandline and ramdisk properties file in */
    import_kernel_cmdline(0, import_kernel_nv);
    /* don't expose the raw commandline to nonpriv processes */
    chmod("/proc/cmdline", 0440);

    if (!charging_mode_booting()) {
         get_hardware_name(hardware, &revision);
         snprintf(tmp, sizeof(tmp), "/init.%s.rc", hardware);
         init_parse_config_file(tmp);
    }

    /* Check for a target specific initialisation file and read if present */
    if (access("/init.target.rc", R_OK) == 0) {
        INFO("Reading target specific config file");
            init_parse_config_file("/init.target.rc");
    }

    action_for_each_trigger("early-init", action_add_queue_tail);

    queue_builtin_action(wait_for_coldboot_done_action, "wait_for_coldboot_done");
    queue_builtin_action(property_init_action, "property_init");
    queue_builtin_action(keychord_init_action, "keychord_init");
    queue_builtin_action(console_init_action, "console_init");
    queue_builtin_action(set_init_properties_action, "set_init_properties");

    /* execute all the boot actions to get us started */
    action_for_each_trigger("init", action_add_queue_tail);

    /* skip mounting filesystems in charger mode */
    if (strcmp(bootmode, "charger") != 0 || strcmp(battchg_pause, "true") != 0) {
        action_for_each_trigger("early-fs", action_add_queue_tail);
    if(emmc_boot) {
        action_for_each_trigger("emmc-fs", action_add_queue_tail);
    } else {
        action_for_each_trigger("fs", action_add_queue_tail);
    }
        action_for_each_trigger("post-fs", action_add_queue_tail);
        action_for_each_trigger("post-fs-data", action_add_queue_tail);
    }

    queue_builtin_action(property_service_init_action, "property_service_init");
    queue_builtin_action(signal_init_action, "signal_init");
    queue_builtin_action(check_startup_action, "check_startup");

    if (!strcmp(bootmode, "charger") || !strcmp(battchg_pause, "true")) {
        action_for_each_trigger("charger", action_add_queue_tail);
    } else {
        action_for_each_trigger("early-boot", action_add_queue_tail);
        action_for_each_trigger("boot", action_add_queue_tail);
    }

        /* run all property triggers based on current state of the properties */
    queue_builtin_action(queue_property_triggers_action, "queue_propety_triggers");


#if BOOTCHART
    queue_builtin_action(bootchart_init_action, "bootchart_init");
#endif

    for(;;) {
        int nr, i, timeout = -1;

        execute_one_command();
        restart_processes();

        if (!property_set_fd_init && get_property_set_fd() > 0) {
            ufds[fd_count].fd = get_property_set_fd();
            ufds[fd_count].events = POLLIN;
            ufds[fd_count].revents = 0;
            fd_count++;
            property_set_fd_init = 1;
        }
        if (!signal_fd_init && get_signal_fd() > 0) {
            ufds[fd_count].fd = get_signal_fd();
            ufds[fd_count].events = POLLIN;
            ufds[fd_count].revents = 0;
            fd_count++;
            signal_fd_init = 1;
        }
        if (!keychord_fd_init && get_keychord_fd() > 0) {
            ufds[fd_count].fd = get_keychord_fd();
            ufds[fd_count].events = POLLIN;
            ufds[fd_count].revents = 0;
            fd_count++;
            keychord_fd_init = 1;
        }

        if (process_needs_restart) {
            timeout = (process_needs_restart - gettime()) * 1000;
            if (timeout < 0)
                timeout = 0;
        }

        if (!action_queue_empty() || cur_action)
            timeout = 0;

#if BOOTCHART
        if (bootchart_count > 0) {
            if (timeout < 0 || timeout > BOOTCHART_POLLING_MS)
                timeout = BOOTCHART_POLLING_MS;
            if (bootchart_step() < 0 || --bootchart_count == 0) {
                bootchart_finish();
                bootchart_count = 0;
            }
        }
#endif

        nr = poll(ufds, fd_count, timeout);
        if (nr <= 0)
            continue;

        for (i = 0; i < fd_count; i++) {
            if (ufds[i].revents == POLLIN) {
                if (ufds[i].fd == get_property_set_fd())
                    handle_property_set_fd();
                else if (ufds[i].fd == get_keychord_fd())
                    handle_keychord();
                else if (ufds[i].fd == get_signal_fd())
                    handle_signal();
            }
        }
    }

    return 0;
}
Exemplo n.º 8
0
int ueventd_main(int argc, char **argv)
{
    struct pollfd ufd;
    int nr;
    char tmp[32];

    /*
     * init sets the umask to 077 for forked processes. We need to
     * create files with exact permissions, without modification by
     * the umask.
     */
    umask(000);

    /* Prevent fire-and-forget children from becoming zombies.
     * If we should need to wait() for some children in the future
     * (as opposed to none right now), double-forking here instead
     * of ignoring SIGCHLD may be the better solution.
     */
    signal(SIGCHLD, SIG_IGN);

    open_devnull_stdio();
    klog_init();

    INFO("starting ueventd\n");

    /* Respect hardware passed in through the kernel cmd line. Here we will look
     * for androidboot.hardware param in kernel cmdline, and save its value in
     * hardware[]. */
    import_kernel_cmdline(0, import_kernel_nv);

    get_hardware_name(hardware, &revision);

    ueventd_parse_config_file("/ueventd.rc");

    snprintf(tmp, sizeof(tmp), "/ueventd.%s.rc", hardware);
    ueventd_parse_config_file(tmp);

    /* aosp-hybris move original ramdisk files to /android dir, so we
     * also need to parse this dirs.
     */
    ueventd_parse_config_file("/android/ueventd.rc");

    snprintf(tmp, sizeof(tmp), "/android/ueventd.%s.rc", hardware);
    ueventd_parse_config_file(tmp);

    device_init();

    ufd.events = POLLIN;
    ufd.fd = get_device_fd();

    while(1) {
        ufd.revents = 0;
        nr = poll(&ufd, 1, -1);
        if (nr <= 0)
            continue;
        if (ufd.revents & POLLERR) {
            ERROR("got POLLERR, terminating ueventd\n");
            exit(1);
        }
        if (ufd.revents == POLLIN)
            handle_device_fd();
    }
}
Exemplo n.º 9
0
int ueventd_main(int argc, char **argv)
{
    struct pollfd ufd;
    int nr;
    char tmp[32];

    /* kernel will launch a program in user space to load
     * modules, by default it is modprobe.
     * Kernel doesn't send module parameters, so we don't
     * need to support them.
     * No deferred loading in this case.
     */
    if (!strcmp(basename(argv[0]), "modprobe")) {
        if (argc >= 4
                && argv[3] != NULL
                && *argv[3] != '\0') {
            uid_t uid;

            /* We only accept requests from root user (kernel) */
            uid = getuid();
            if (uid)
                return -EPERM;

            return module_probe(argv[3]);
        } else {
            /* modprobe is called without enough arguments */
            return -EINVAL;
        }
    }

    /*
     * init sets the umask to 077 for forked processes. We need to
     * create files with exact permissions, without modification by
     * the umask.
     */
    umask(000);

    /* Prevent fire-and-forget children from becoming zombies.
     * If we should need to wait() for some children in the future
     * (as opposed to none right now), double-forking here instead
     * of ignoring SIGCHLD may be the better solution.
     */
    signal(SIGCHLD, SIG_IGN);

    open_devnull_stdio();
    klog_init();

    INFO("starting ueventd\n");

    /* Respect hardware passed in through the kernel cmd line. Here we will look
     * for androidboot.hardware param in kernel cmdline, and save its value in
     * hardware[]. */
    import_kernel_cmdline(0, import_kernel_nv);

    get_hardware_name(hardware, &revision);

    ueventd_parse_config_file("/ueventd.rc");

    snprintf(tmp, sizeof(tmp), "/ueventd.%s.rc", hardware);
    ueventd_parse_config_file(tmp);

    device_init();

    ufd.events = POLLIN;
    ufd.fd = get_device_fd();

    while(1) {
        ufd.revents = 0;
        nr = poll(&ufd, 1, -1);
        if (nr <= 0)
            continue;
        if (ufd.revents == POLLIN)
               handle_device_fd();
    }
}
Exemplo n.º 10
0
int ueventd_main(int argc, char **argv)
{
    struct pollfd ufd;
    int nr;
    char tmp[32];

    /*
     * init sets the umask to 077 for forked processes. We need to
     * create files with exact permissions, without modification by
     * the umask.
     */
    umask(000);

    /* Prevent fire-and-forget children from becoming zombies.
     * If we should need to wait() for some children in the future
     * (as opposed to none right now), double-forking here instead
     * of ignoring SIGCHLD may be the better solution.
     */
    signal(SIGCHLD, SIG_IGN);

    open_devnull_stdio();
    klog_init();
#if LOG_UEVENTS
    /* Ensure we're at a logging level that will show the events */
    if (klog_get_level() < KLOG_INFO_LEVEL) {
        klog_set_level(KLOG_INFO_LEVEL);
    }
#endif

    union selinux_callback cb;
    cb.func_log = log_callback;
    selinux_set_callback(SELINUX_CB_LOG, cb);

    INFO("starting ueventd\n");

    /* Respect hardware passed in through the kernel cmd line. Here we will look
     * for androidboot.hardware param in kernel cmdline, and save its value in
     * hardware[]. */
    import_kernel_cmdline(0, import_kernel_nv);

    get_hardware_name(hardware, &revision);

    ueventd_parse_config_file("/ueventd.rc");

    snprintf(tmp, sizeof(tmp), "/ueventd.%s.rc", hardware);
    ueventd_parse_config_file(tmp);

    device_init();

    ufd.events = POLLIN;
    ufd.fd = get_device_fd();

    while(1) {
        ufd.revents = 0;
        nr = poll(&ufd, 1, -1);
        if (nr <= 0)
            continue;
        if (ufd.revents & POLLIN)
               handle_device_fd();
    }
}
Exemplo n.º 11
0
int main(int argc, char **argv)
{
	pthread_t t_auto, t_input, t_uevent, t_sighandler;
	//Volume *vol;
	int ret;
	char *disk_conf;
	void (*ui_update)(void *) = NULL;
	sigset_t set;

	/* block signals for all theads */
	sigemptyset(&set);
	sigaddset(&set, SIGPIPE);
	sigaddset(&set, SIGALRM);
	if (pthread_sigmask(SIG_BLOCK, &set, NULL))
		pr_critial("block signal failed.\n");

	/* create a dedicate thread to handle signals */
	if (pthread_create(&t_sighandler, NULL, sig_handler, &set))
		pr_critial("create signal handler thread failed.\n");

	if (argc > 1)
		ret = load_config(argv[1]);
	else
		ret = load_config(NULL);
	/* currently, missing config file is not critical */
	if (ret)
		pr_warning("can't load tboot configuration.\n");

	if (ret = tboot_ui_init(tboot_config_get(UI_CONF_KEY)))
		pr_error("UI crashed!\n");

	tboot_config_set(UI_CONF_KEY, tboot_ui_getconfpath());

	ev_init(input_callback, NULL);

	display_sysinfo(ret);

	if (!ret) {
		ui_update = ui_callback;
	}

	pr_info(" -- preos v%s for %s --\n", preos_version, DEVICE_NAME);
	import_kernel_cmdline(parse_cmdline_option);

	disk_conf = tboot_config_get(DISK_CONFIG_KEY);
	if (!disk_conf) {
		pr_error("Invalid tboot config disk_conf.\n");
		die();
	}

	setup_disk_information(disk_conf);

	aboot_register_commands();

	register_tboot_plugins();

	if (pthread_create(&t_input, NULL, input_listener_thread,
					NULL)) {
		pr_perror("pthread_create");
		die();
	}

	lcd_state_init();

	if (pthread_create(&t_uevent, NULL, uevent_thread, ui_update)) {
		pr_perror("pthread_create t_uevent");
		die();
	}

	/*
	vol = volume_for_path(SDCARD_VOLUME);
	if (vol)
		try_update_sw(vol, 1);
	*/

	if (g_use_autoboot && !g_update_location) {
		/*
		 * Create menu items for debug boot, this is a feature for developers
		 * only.
		 *
		 * Developers (kernel developers) put kernel, cmdline,
		 * rmadisk.img(optional) to platform boot directory  in kexec enabled
		 * preos.
		 *
		 * Generally, there are two ways to do that.
		 *
		 * 1. you can put these files into /boot after the system boot
		 * into rootfs.
		 * 2. you can put these files into platform.img.gz and create a new
		 * platform.img.gz and then flash it to target device.
		 *
		 * Previous, if the system can't boot into rootfs, the only way left
		 * is flash a new platform image. Apparently, it's a huge effort.
		 *
		 * To make more choice, two kernels are supported now, so make sure
		 * there is a works kernel in /boot , you can always boot into
		 * normal system and put a new kernel by any other way, such as scp,
		 * ftp and etc.
		 */

		/*
		 * make our menu acts more like grub which more users familiar with.
		 */
		tboot_ui_menu_item("Boot: kernel", start_default_kernel);
		tboot_ui_menu_item("Boot: kernel.bak", start_backup_kernel);
		tboot_ui_menu_item("Boot: kernel/rootfs on TF/micro-SD card",
				start_mmc_kernel);
		/*
		 * boot from NFS is quite useless now because the usb network bandwidth
		 * is too narrow to satisfy the boot up sequence. It may (80%) hang at
		 * system boot up, especially at X server start up
		 *
		 * So, by default, disable it.
		 */
		if (strcasecmp(tboot_config_get(ENABLE_NFS_KEY), "yes") == 0)
			tboot_ui_menu_item("Boot: kernel/rootfs on NFS",
					start_nfs_kernel);

		tboot_ui_menu_selected(3);      // set debug boot: kernel selected

		if (pthread_create(&t_auto, NULL, autoboot_thread, NULL)) {
			pr_perror("pthread_create");
			die();
		}
	}

	/*
	 * dealy to start tboot server
	 */
	do {
		sleep(1);
	} while (autoboot_enabled || power_pressed);

	pr_info("Listening for the fastboot protocol over USB.\n");
	fastboot_init(g_scratch_size * MEGABYTE);

	/* Shouldn't get here */
	tboot_ui_exit();

	if (tboot_config)
		hashmapFree(tboot_config);
//	tboot_cmds_free();

	exit(1);
}
static void __init msm7x2x_init(void)
{
	msm7x2x_misc_init();

	/* Initialize regulators first so that other devices can use them */
	msm7x27a_init_regulators();
	msm_adsp_add_pdev();
	if (cpu_is_msm8625())
		msm8625_device_i2c_init();
	else
		msm7x27a_device_i2c_init();
	msm7x27a_init_ebi2();
	msm7x27a_uartdm_config();

#ifdef CONFIG_HUAWEI_KERNEL
    import_kernel_cmdline();
#endif

	msm7x27a_otg_gadget();
#ifndef CONFIG_HUAWEI_CAMERA
    msm7x27a_cfg_smsc911x();
#endif
#if (defined(CONFIG_HUAWEI_BT_BCM43XX) && defined(CONFIG_HUAWEI_KERNEL))
    /*before bt probe, config the bt_wake_msm gpio*/
    bt_wake_msm_config();
#endif
	msm7x27a_add_footswitch_devices();
	msm7x27a_add_platform_devices();
	/* Ensure ar6000pm device is registered before MMC/SDC */
	msm7x27a_init_ar6000pm();
	msm7627a_init_mmc();
	msm_fb_add_devices();
	msm7x2x_init_host();
	msm7x27a_pm_init();
	register_i2c_devices();
//#if (defined(HUAWEI_BT_BLUEZ_VER30) || (!defined(CONFIG_HUAWEI_KERNEL)))
	//msm7627a_bt_power_init() will check QC or BCM bt chip powers inner.
	msm7627a_bt_power_init();
//#endif
	msm7627a_camera_init();
	msm7627a_add_io_devices();
	/*7x25a kgsl initializations*/
	msm7x25a_kgsl_3d0_init();
	
#ifdef CONFIG_HUAWEI_FEATURE_OEMINFO
    rmt_oeminfo_add_device();
#endif

#ifdef CONFIG_HUAWEI_KERNEL
	virtualkeys_init();
#endif

#ifdef CONFIG_HUAWEI_KERNEL
    hw_extern_sdcard_add_device();
#endif
    
	/*8x25 kgsl initializations*/
	msm8x25_kgsl_3d0_init();

	
#ifdef CONFIG_HUAWEI_MTK6252_MODEM
	{
		unsigned smem_size;
		boot_reason = *(unsigned int *)
			(smem_get_entry(SMEM_POWER_ON_STATUS_INFO, &smem_size));
		printk(KERN_NOTICE "Boot Reason = 0x%02x\n", boot_reason);
		mtk6252_dev_init();
	}
#endif
}