Exemple #1
0
int load_565rle_image(char *fn)
{
    struct FB fb;
    struct stat s;
    unsigned short *data, *bits, *ptr;
    unsigned count, max;
    int fd;

    if (vt_set_mode(1))
        return -1;

    fd = open(fn, O_RDONLY);
    if (fd < 0) {
        ERROR("cannot open '%s'\n", fn);
        goto fail_restore_text;
    }

    if (fstat(fd, &s) < 0) {
        goto fail_close_file;
    }

    data = mmap(0, s.st_size, PROT_READ, MAP_SHARED, fd, 0);
    if (data == MAP_FAILED)
        goto fail_close_file;

    if (fb_open(&fb))
        goto fail_unmap_data;

    max = fb_width(&fb) * fb_height(&fb);
    ptr = data;
    count = s.st_size;
    bits = fb.bits;
    while (count > 3) {
        unsigned n = ptr[0];
        if (n > max)
            break;
        android_memset16(bits, ptr[1], n << 1);
        bits += n;
        max -= n;
        ptr += 2;
        count -= 4;
    }

    munmap(data, s.st_size);
    fb_update(&fb);
    fb_close(&fb);
    close(fd);
    unlink(fn);
    return 0;

fail_unmap_data:
    munmap(data, s.st_size);
fail_close_file:
    close(fd);
fail_restore_text:
    vt_set_mode(0);
    return -1;
}
static int fb_open(struct FB *fb)
{
    /* Switch to graphics mode */
    vt_set_mode(1);

    fb->fd = open("/dev/graphics/fb0", O_RDWR);
    if (fb->fd < 0)
    {
    ALOGD("fb open failed!\n");
        return -1;
    }
    if (ioctl(fb->fd, FBIOGET_FSCREENINFO, &fb->fi) < 0)
    {
    ALOGD("fb ioctl FBIOGET_FSCREENINFO failed \n");
        goto err1;
    }
    if (ioctl(fb->fd, FBIOGET_VSCREENINFO, &fb->vi) < 0)
    {
    ALOGD("fb ioctl FBIOGET_VSCREENINFO failed \n");
        goto err1;
    }

    fb->bits = mmap(0, fb->fi.smem_len, PROT_READ | PROT_WRITE,
                    MAP_SHARED, fb->fd, 0);
    if (fb->bits == MAP_FAILED)
    {
        ALOGD("fb mapping failed!\n");
            goto err1;
    }
    return 0;

err1:
    close(fb->fd);
    return -1;
}
Exemple #3
0
int main(int argc, char *argv[])
{
    int i;
    for(i = 1; i < argc; ++i)
    {
        if(strcmp(argv[i], "-v") == 0)
        {
            printf("%d%s\n", VERSION_MULTIROM, VERSION_DEV_FIX);
            return 0;
        }
    }

    srand(time(0));
    klog_init();

    // output all messages to dmesg,
    // but it is possible to filter out INFO messages
    klog_set_level(6);

    ERROR("Running MultiROM v%d%s\n", VERSION_MULTIROM, VERSION_DEV_FIX);

    int exit = multirom();

    if(exit >= 0)
    {
        if(exit & EXIT_REBOOT_MASK)
        {
            do_reboot(exit);
            return 0;
        }

        if(exit & EXIT_KEXEC)
        {
            do_kexec();
            return 0;
        }

        // indicates trampoline to keep /realdata mounted
        if(!(exit & EXIT_UMOUNT))
            close(open(KEEP_REALDATA, O_WRONLY | O_CREAT, 0000));
    }

    vt_set_mode(0);

    return 0;
}
Exemple #4
0
int main(int argc, const char *argv[])
{
    int i;
    const char *rom_to_boot = NULL;

    for(i = 1; i < argc; ++i)
    {
        if(strcmp(argv[i], "-v") == 0)
        {
            printf("%d%s\n", VERSION_MULTIROM, VERSION_DEV_FIX);
            fflush(stdout);
            return 0;
        }
        else if(strncmp(argv[i], "--boot-rom=", sizeof("--boot-rom")) == 0)
        {
            rom_to_boot = argv[i] + sizeof("--boot-rom");
        }
    }

    srand(time(0));
    klog_init();

    // output all messages to dmesg,
    // but it is possible to filter out INFO messages
    klog_set_level(6);

    mrom_set_log_tag("multirom");

    ERROR("Running MultiROM v%d%s\n", VERSION_MULTIROM, VERSION_DEV_FIX);

    // root is mounted read only in android and MultiROM uses
    // it to store some temp files, so remount it.
    // Yes, there is better solution to this.
    if(rom_to_boot)
        mount(NULL, "/", NULL, MS_REMOUNT, NULL);

    int exit = multirom(rom_to_boot);

    if(rom_to_boot)
        mount(NULL, "/", NULL, MS_RDONLY | MS_REMOUNT, NULL);

    if(exit >= 0)
    {
        if(exit & EXIT_REBOOT_RECOVERY)
            do_reboot(REBOOT_RECOVERY);
        else if(exit & EXIT_REBOOT_BOOTLOADER)
            do_reboot(REBOOT_BOOTLOADER);
        else if(exit & EXIT_SHUTDOWN)
            do_reboot(REBOOT_SHUTDOWN);
        else if(exit & EXIT_REBOOT)
            do_reboot(REBOOT_SYSTEM);

        if(exit & EXIT_KEXEC)
        {
            do_kexec();
            return 0;
        }

        // indicates trampoline to keep /realdata mounted
        if(!(exit & EXIT_UMOUNT))
            close(open(KEEP_REALDATA, O_WRONLY | O_CREAT, 0000));
    }

    vt_set_mode(0);

    return 0;
}
int main(int argc, char **argv)
{
	int fd;
	char *fb_buf;
	FILE *fp;
	struct fb_fix_screeninfo finfo;
	struct fb_var_screeninfo vinfo;
	BITMAPFILEHEADER bmp_head;
	BITMAPINFOHEADER bmp_info;
	unsigned int     bmp_rgb_mask[4];
	
	if (argc!=2)
	{
		printf("%s /dev/fb0\n", argv[0]);
		exit(1);
	}

	fd = open(argv[1], O_RDWR);
	if (fd<0) {
		perror("open:");
		return -1;
	}

	ioctl(fd, FBIOGET_VSCREENINFO, &vinfo);
	ioctl(fd, FBIOGET_FSCREENINFO, &finfo);
	printf("[FB]x:%d y:%d\n", vinfo.xres, vinfo.yres);
	fb_buf = (char*)mmap(NULL, finfo.smem_len, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0);
	vt_set_mode(1);

	// prepare bmp
	if (access(BMP_PATH, 0)==0)
		remove(BMP_PATH);

	fp = fopen(BMP_PATH, "w+");
	if (fp<0)
		return -1;

	CLEAR(bmp_head);
	CLEAR(bmp_info);
	CLEAR(bmp_rgb_mask);

	bmp_head.bfType = 'B' | 'M' <<8;
	bmp_head.bfSize = sizeof(bmp_info) + sizeof(bmp_head) + finfo.smem_len + sizeof(int)*4;
	bmp_head.bfOffBits = sizeof(bmp_info) + sizeof(bmp_head) + sizeof(int)*4;

	bmp_info.biSize  = sizeof(bmp_info);
	bmp_info.biWidth = vinfo.xres;
	bmp_info.biHeight = vinfo.yres;
	bmp_info.biBitCount = 16;
	bmp_info.biCompression =  BI_BITFIELDS;
	bmp_info.biSizeImage = finfo.smem_len;

	fwrite(&bmp_head, sizeof(bmp_head), 1, fp);
	fwrite(&bmp_info, sizeof(bmp_info), 1, fp);

	// 565 mask
	bmp_rgb_mask[0] = 0xF800;
	bmp_rgb_mask[1] = 0x07E0;
	bmp_rgb_mask[2] = 0x001F;
	fwrite(bmp_rgb_mask, sizeof(bmp_rgb_mask), 1, fp);

	// write image data
	for (int i=0; i<bmp_info.biHeight; i++)
		fwrite(fb_buf+(bmp_info.biHeight-i)*bmp_info.biWidth*2, 
		bmp_info.biWidth*2, 1, fp);



	if (fb_buf)
		munmap(fb_buf, finfo.smem_len);
	close(fd);
	fclose(fp);
	return 0;
}