M7350v1_en_gpl

This commit is contained in:
T
2024-09-09 08:52:07 +00:00
commit f9cc65cfda
65988 changed files with 26357421 additions and 0 deletions

View File

@@ -0,0 +1,89 @@
/* Copyright (c) 2009-2010, The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of The Linux Foundation nor
* the names of its contributors may be used to endorse or promote
* products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#include <reg.h>
#include <debug.h>
#include <smem.h>
#define SIZE_1M 0x00100000
unsigned round_to_mb(unsigned size)
{
unsigned size_in_mb = 0;
size_in_mb = size >> 20;
size_in_mb = size_in_mb << 20;
return size_in_mb;
}
unsigned* target_atag_mem(unsigned* ptr)
{
struct smem_ram_ptable ram_ptable;
unsigned i = 0;
unsigned size_in_mb = 0;
if (smem_ram_ptable_init(&ram_ptable))
{
for (i = 0; i < ram_ptable.len; i++)
{
/* Round down to align to Mega byte size */
size_in_mb = round_to_mb(ram_ptable.parts[i].size);
if ((ram_ptable.parts[i].attr == READWRITE)
&& (ram_ptable.parts[i].domain == APPS_DOMAIN)
&& (ram_ptable.parts[i].start != 0x0)
&& (!(size_in_mb <= SIZE_1M)))
{
/* ATAG_MEM */
*ptr++ = 4;
*ptr++ = 0x54410002;
/* RAM parition for Emmc boot are reported correctly by modem
* Use the size passed from modem directly after rounding down
* to MB as kernel expects a megabyte aligned size.
*/
if (target_is_emmc_boot()) {
*ptr++ = size_in_mb;
}
else
*ptr++ = ram_ptable.parts[i].size;
*ptr++ = ram_ptable.parts[i].start;
}
}
}
else
{
dprintf(CRITICAL, "ERROR: Unable to read RAM partition\n");
ASSERT(0);
}
return ptr;
}
unsigned target_get_max_flash_size(void)
{
return (180 * 1024 * 1024);
}

View File

@@ -0,0 +1,47 @@
/* Copyright (c) 2010, The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of The Linux Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#ifndef _TARGET_MSM7627_SURF_DISPLAY_H
#define _TARGET_MSM7627_SURF_DISPLAY_H
#define TARGET_XRES 800
#define TARGET_YRES 480
#define LCDC_FB_WIDTH 800
#define LCDC_FB_HEIGHT 480
#define LCDC_HSYNC_PULSE_WIDTH_DCLK 60
#define LCDC_HSYNC_BACK_PORCH_DCLK 81
#define LCDC_HSYNC_FRONT_PORCH_DCLK 81
#define LCDC_HSYNC_SKEW_DCLK 0
#define LCDC_VSYNC_PULSE_WIDTH_LINES 2
#define LCDC_VSYNC_BACK_PORCH_LINES 20
#define LCDC_VSYNC_FRONT_PORCH_LINES 27
#endif

View File

@@ -0,0 +1,298 @@
/*
* Copyright (c) 2009, Google Inc.
* All rights reserved.
* Copyright (c) 2009-2011, The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Google, Inc. nor the names of its contributors
* may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include <reg.h>
#include <debug.h>
#include <dev/keys.h>
#include <lib/ptable.h>
#include <dev/flash.h>
#include <smem.h>
#include <mmc.h>
#include <platform/iomap.h>
#include <platform.h>
#define LINUX_MACHTYPE_7x27_SURF 2705
#define LINUX_MACHTYPE_7x27_FFA 2706
#define VARIABLE_LENGTH 0x10101010
#define DIFF_START_ADDR 0xF0F0F0F0
#define NUM_PAGES_PER_BLOCK 0x40
static struct ptable flash_ptable;
static unsigned mmc_sdc_base[] = { MSM_SDC1_BASE, MSM_SDC2_BASE, MSM_SDC3_BASE, MSM_SDC4_BASE};
static int hw_platform_type = -1;
/* for these partitions, start will be offset by either what we get from
* smem, or from the above offset if smem is not useful. Also, we should
* probably have smem_ptable code populate our flash_ptable.
*
* When smem provides us with a full partition table, we can get rid of
* this altogether.
*
*/
static struct ptentry board_part_list[] = {
{
.start = 0,
.length = 5 /* In MB */,
.name = "boot",
},
{
.start = DIFF_START_ADDR,
.length = 180 /* In MB */,
.name = "system",
},
{
.start = DIFF_START_ADDR,
.length = 4 /* In MB */,
.name = "cache",
},
{
.start = DIFF_START_ADDR,
.length = 4 /* In MB */,
.name = "misc",
},
{
.start = DIFF_START_ADDR,
.length = VARIABLE_LENGTH,
.name = "userdata",
},
{
.start = DIFF_START_ADDR,
.length = 2 /* In MB */,
.name = "persist",
},
{
.start = DIFF_START_ADDR,
.length = 5 /* In MB */,
.name = "recovery",
},
};
static int num_parts = sizeof(board_part_list)/sizeof(struct ptentry);
void smem_ptable_init(void);
unsigned smem_get_apps_flash_start(void);
void keypad_init(void);
int target_is_emmc_boot(void);
void target_init(void)
{
unsigned offset;
struct flash_info *flash_info;
unsigned total_num_of_blocks;
unsigned next_ptr_start_adr = 0;
unsigned blocks_per_1MB = 8; /* Default value of 2k page size on 256MB flash drive*/
unsigned char slot;
unsigned int base_addr;
int i;
dprintf(INFO, "target_init()\n");
/* Display splash screen if enabled */
#if DISPLAY_SPLASH_SCREEN
display_init();
dprintf(SPEW, "Diplay initialized\n");
display_image_on_screen();
#endif
#if (!ENABLE_NANDWRITE)
keys_init();
keypad_init();
#endif
if (target_is_emmc_boot())
{
/* Must wait for modem-up before we can intialize MMC.
*/
while (readl(MSM_SHARED_BASE + 0x14) != 1);
/* Trying SDC3 first */
slot = 3;
base_addr = mmc_sdc_base[slot - 1];
if(mmc_boot_main(slot, base_addr))
{
/* Trying SDC1 next */
slot = 1;
base_addr = mmc_sdc_base[slot - 1];
if(mmc_boot_main(slot, base_addr))
{
dprintf(CRITICAL, "mmc init failed!");
ASSERT(0);
}
}
return;
}
ptable_init(&flash_ptable);
smem_ptable_init();
flash_init();
flash_info = flash_get_info();
ASSERT(flash_info);
offset = smem_get_apps_flash_start();
if (offset == 0xffffffff)
while(1);
total_num_of_blocks = flash_info->num_blocks;
blocks_per_1MB = (1 << 20) / (flash_info->block_size);
for (i = 0; i < num_parts; i++) {
struct ptentry *ptn = &board_part_list[i];
unsigned len = ((ptn->length) * blocks_per_1MB);
if(ptn->start != 0)
ASSERT(ptn->start == DIFF_START_ADDR);
ptn->start = next_ptr_start_adr;
if(ptn->length == VARIABLE_LENGTH)
{
unsigned length_for_prt = 0;
unsigned j;
for (j = i+1; j < num_parts; j++)
{
struct ptentry *temp_ptn = &board_part_list[j];
ASSERT(temp_ptn->length != VARIABLE_LENGTH);
length_for_prt += ((temp_ptn->length) * blocks_per_1MB);
}
len = total_num_of_blocks - (offset + ptn->start + length_for_prt);
ASSERT(len >= 0);
}
next_ptr_start_adr = ptn->start + len;
ptable_add(&flash_ptable, ptn->name, offset + ptn->start,
len, ptn->flags, TYPE_APPS_PARTITION, PERM_WRITEABLE);
}
smem_add_modem_partitions(&flash_ptable);
ptable_dump(&flash_ptable);
flash_set_ptable(&flash_ptable);
}
unsigned board_machtype(void)
{
struct smem_board_info_v2 board_info_v2;
unsigned int board_info_len = 0;
enum platform platform_type = 0;
unsigned smem_status;
unsigned format = 0;
if(hw_platform_type != -1)
return hw_platform_type;
smem_status = smem_read_alloc_entry_offset(SMEM_BOARD_INFO_LOCATION,
&format, sizeof(format), 0);
if(!smem_status)
{
if(format == 2)
{
board_info_len = sizeof(board_info_v2);
smem_status = smem_read_alloc_entry(SMEM_BOARD_INFO_LOCATION,
&board_info_v2, board_info_len);
if(!smem_status)
{
char *build_type = (char *)(board_info_v2.build_id)+ 12;
switch (*build_type)
{
case 'F':
hw_platform_type = LINUX_MACHTYPE_7x27_FFA; break;
case 'S':
hw_platform_type = LINUX_MACHTYPE_7x27_SURF; break;
default:
hw_platform_type = LINUX_MACHTYPE_7x27_SURF; break;
}
}
}
} else {
hw_platform_type = LINUX_MACHTYPE_7x27_SURF;
}
return hw_platform_type;
}
void reboot_device(unsigned reboot_reason)
{
reboot(reboot_reason);
}
unsigned check_reboot_mode(void)
{
unsigned mode[2] = {0, 0};
unsigned int mode_len = sizeof(mode);
unsigned smem_status;
smem_status = smem_read_alloc_entry(SMEM_APPS_BOOT_MODE,
&mode, mode_len );
if(smem_status)
{
dprintf(CRITICAL, "ERROR: unable to read shared memory for reboot mode\n");
return 0;
}
return mode[0];
}
static unsigned target_check_power_on_reason(void)
{
unsigned power_on_status = 0;
unsigned int status_len = sizeof(power_on_status);
unsigned smem_status;
smem_status = smem_read_alloc_entry(SMEM_POWER_ON_STATUS_INFO,
&power_on_status, status_len);
if (smem_status)
{
dprintf(CRITICAL, "ERROR: unable to read shared memory for power on reason\n");
}
return power_on_status;
}
#if _EMMC_BOOT
void target_serialno(unsigned char *buf)
{
unsigned int serialno;
serialno = mmc_get_psn();
sprintf(buf,"%x",serialno);
}
int emmc_recovery_init(void)
{
int rc;
rc = _emmc_recovery_init();
return rc;
}
#endif

View File

@@ -0,0 +1,172 @@
/*
* Copyright (c) 2009, Google Inc.
* All rights reserved.
* Copyright (c) 2009, The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Google, Inc. nor the names of its contributors
* may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include <dev/keys.h>
#include <dev/ssbi.h>
#include <dev/gpio_keypad.h>
#define ARRAY_SIZE(x) (sizeof(x)/sizeof((x)[0]))
/* don't turn this on without updating the ffa support */
#define SCAN_FUNCTION_KEYS 0
#define LINUX_MACHTYPE_7x27_SURF 2705
static unsigned int halibut_row_gpios[] = {
31, 32, 33, 34, 35, 41
#if SCAN_FUNCTION_KEYS
, 42
#endif
};
static unsigned int halibut_col_gpios[] = { 36, 37, 38, 39, 40 };
#define KEYMAP_INDEX(row, col) ((row)*ARRAY_SIZE(halibut_col_gpios) + (col))
static const unsigned short halibut_keymap_surf[ARRAY_SIZE(halibut_col_gpios) * ARRAY_SIZE(halibut_row_gpios)] = {
[KEYMAP_INDEX(0, 0)] = KEY_5,
[KEYMAP_INDEX(0, 1)] = KEY_9,
[KEYMAP_INDEX(0, 2)] = KEY_SOFT1,
[KEYMAP_INDEX(0, 3)] = KEY_6,
[KEYMAP_INDEX(0, 4)] = KEY_LEFT,
[KEYMAP_INDEX(1, 0)] = KEY_0,
[KEYMAP_INDEX(1, 1)] = KEY_RIGHT,
[KEYMAP_INDEX(1, 2)] = KEY_1,
[KEYMAP_INDEX(1, 3)] = KEY_SHARP,
[KEYMAP_INDEX(1, 4)] = KEY_SEND,
[KEYMAP_INDEX(2, 0)] = KEY_VOLUMEUP,
[KEYMAP_INDEX(2, 1)] = KEY_HOME, /* FA */
[KEYMAP_INDEX(2, 2)] = KEY_F8, /* QCHT */
[KEYMAP_INDEX(2, 3)] = KEY_F6, /* R+ */
[KEYMAP_INDEX(2, 4)] = KEY_F7, /* R- */
[KEYMAP_INDEX(3, 0)] = KEY_UP,
[KEYMAP_INDEX(3, 1)] = KEY_CLEAR,
[KEYMAP_INDEX(3, 2)] = KEY_4,
[KEYMAP_INDEX(3, 3)] = KEY_MUTE, /* SPKR */
[KEYMAP_INDEX(3, 4)] = KEY_2,
[KEYMAP_INDEX(4, 0)] = KEY_SOFT2, /* SOFT2 */
[KEYMAP_INDEX(4, 1)] = KEY_CENTER, /* KEY_CENTER */
[KEYMAP_INDEX(4, 2)] = KEY_DOWN,
[KEYMAP_INDEX(4, 3)] = KEY_BACK, /* FB */
[KEYMAP_INDEX(4, 4)] = KEY_8,
[KEYMAP_INDEX(5, 0)] = KEY_VOLUMEDOWN,
[KEYMAP_INDEX(5, 1)] = KEY_STAR, /* KEY_STAR */
[KEYMAP_INDEX(5, 2)] = KEY_MAIL, /* MESG */
[KEYMAP_INDEX(5, 3)] = KEY_3,
[KEYMAP_INDEX(5, 4)] = KEY_7,
#if SCAN_FUNCTION_KEYS
[KEYMAP_INDEX(6, 0)] = KEY_F5,
[KEYMAP_INDEX(6, 1)] = KEY_F4,
[KEYMAP_INDEX(6, 2)] = KEY_F3,
[KEYMAP_INDEX(6, 3)] = KEY_F2,
[KEYMAP_INDEX(6, 4)] = KEY_F1
#endif
};
static const unsigned short halibut_keymap_ffa[ARRAY_SIZE(halibut_col_gpios) * ARRAY_SIZE(halibut_row_gpios)] = {
[KEYMAP_INDEX(0, 2)] = KEY_1,
[KEYMAP_INDEX(0, 3)] = KEY_SEND,
[KEYMAP_INDEX(0, 4)] = KEY_LEFT,
[KEYMAP_INDEX(1, 0)] = KEY_3,
[KEYMAP_INDEX(1, 1)] = KEY_RIGHT,
[KEYMAP_INDEX(1, 2)] = KEY_VOLUMEUP,
[KEYMAP_INDEX(1, 4)] = KEY_6,
[KEYMAP_INDEX(2, 0)] = KEY_HOME, /* A */
[KEYMAP_INDEX(2, 1)] = KEY_BACK, /* B */
[KEYMAP_INDEX(2, 2)] = KEY_0,
[KEYMAP_INDEX(2, 3)] = KEY_SHARP,
[KEYMAP_INDEX(2, 4)] = KEY_9,
[KEYMAP_INDEX(3, 0)] = KEY_UP,
[KEYMAP_INDEX(3, 1)] = KEY_CENTER,
[KEYMAP_INDEX(3, 2)] = KEY_4,
[KEYMAP_INDEX(3, 4)] = KEY_2,
[KEYMAP_INDEX(4, 0)] = KEY_VOLUMEDOWN,
[KEYMAP_INDEX(4, 1)] = KEY_SOUND,
[KEYMAP_INDEX(4, 2)] = KEY_DOWN,
[KEYMAP_INDEX(4, 3)] = KEY_8,
[KEYMAP_INDEX(4, 4)] = KEY_5,
[KEYMAP_INDEX(5, 1)] = KEY_STAR,
[KEYMAP_INDEX(5, 2)] = KEY_SOFT2,
[KEYMAP_INDEX(5, 3)] = KEY_MENU,
[KEYMAP_INDEX(5, 4)] = KEY_7,
#if SCAN_FUNCTION_KEYS
[KEYMAP_INDEX(6, 0)] = KEY_F5,
[KEYMAP_INDEX(6, 1)] = KEY_F4,
[KEYMAP_INDEX(6, 2)] = KEY_F3,
[KEYMAP_INDEX(6, 3)] = KEY_F2,
[KEYMAP_INDEX(6, 4)] = KEY_F1
#endif
};
static struct gpio_keypad_info halibut_keypad_info_surf = {
.keymap = halibut_keymap_surf,
.output_gpios = halibut_row_gpios,
.input_gpios = halibut_col_gpios,
.noutputs = ARRAY_SIZE(halibut_row_gpios),
.ninputs = ARRAY_SIZE(halibut_col_gpios),
.settle_time = 5 /* msec */,
.poll_time = 20 /* msec */,
.flags = GPIOKPF_DRIVE_INACTIVE,
};
static struct gpio_keypad_info halibut_keypad_info_ffa = {
.keymap = halibut_keymap_ffa,
.output_gpios = halibut_row_gpios,
.input_gpios = halibut_col_gpios,
.noutputs = ARRAY_SIZE(halibut_row_gpios),
.ninputs = ARRAY_SIZE(halibut_col_gpios),
.settle_time = 5 /* msec */,
.poll_time = 20 /* msec */,
.flags = GPIOKPF_DRIVE_INACTIVE,
};
void keypad_init(void)
{
unsigned int mach_id;
mach_id = board_machtype();
if (mach_id == LINUX_MACHTYPE_7x27_SURF)
gpio_keypad_init(&halibut_keypad_info_surf);
else
gpio_keypad_init(&halibut_keypad_info_ffa);
}

View File

@@ -0,0 +1,44 @@
LOCAL_DIR := $(GET_LOCAL_DIR)
INCLUDES += -I$(LOCAL_DIR)/include -I$(LK_TOP_DIR)/platform/msm_shared
PLATFORM := msm7k
MEMBASE := 0x00000000 # SMI
MEMSIZE := 0x00100000 # 1MB
BASE_ADDR := 0x00200000
TAGS_ADDR := BASE_ADDR+0x00000100
KERNEL_ADDR := BASE_ADDR+0x00008000
RAMDISK_ADDR := BASE_ADDR+0x01000000
SCRATCH_ADDR := BASE_ADDR+0xA00000
LCDC_FB_ADDR := 0x0D300000
KEYS_USE_GPIO_KEYPAD := 1
DEFINES += DISPLAY_TYPE_MDDI=0
DEFINES += DISPLAY_TYPE_LCDC=1
DEFINES += DISPLAY_SPLASH_SCREEN=1
DEFINES += MDDI_MULTI_WRITE=1
MODULES += \
dev/keys \
dev/ssbi \
lib/ptable
DEFINES += \
SDRAM_SIZE=$(MEMSIZE) \
MEMBASE=$(MEMBASE) \
BASE_ADDR=$(BASE_ADDR) \
TAGS_ADDR=$(TAGS_ADDR) \
KERNEL_ADDR=$(KERNEL_ADDR) \
RAMDISK_ADDR=$(RAMDISK_ADDR) \
SCRATCH_ADDR=$(SCRATCH_ADDR) \
LCDC_FB_ADDR=$(LCDC_FB_ADDR)
OBJS += \
$(LOCAL_DIR)/init.o \
$(LOCAL_DIR)/keypad.o \
$(LOCAL_DIR)/atags.o

View File

@@ -0,0 +1,41 @@
#Makefile to generate appsboot.mbn
ifeq ($(BOOTLOADER_OUT),.)
APPSBOOTHEADER_DIR := $(BUILDDIR)
else
APPSBOOTHEADER_DIR := $(BOOTLOADER_OUT)/../..
endif
SRC_DIR := target/$(TARGET)/tools
COMPILER := gcc
ifeq ($(EMMC_BOOT), 1)
APPSBOOTHDR_FILES := EMMCBOOT.MBN emmc_appsboothd.mbn
else
ifeq ($(BUILD_NANDWRITE), 1)
APPSBOOTHDR_FILES :=
else
APPSBOOTHDR_FILES := appsboot.mbn appsboothd.mbn
endif
endif
APPSBOOTHEADER: $(APPSBOOTHDR_FILES)
appsboot.mbn: $(OUTBIN)
cp $(OUTBIN) $(APPSBOOTHEADER_DIR)/appsboot.raw
cp -f $(OUTBIN) $(APPSBOOTHEADER_DIR)/appsboot.mbn
appsboothd.mbn: mkheader $(OUTBIN)
$(BUILDDIR)/mkheader $(OUTBIN) $(APPSBOOTHEADER_DIR)/appsboothd.mbn
EMMCBOOT.MBN: $(OUTBIN)
cp $(OUTBIN) $(APPSBOOTHEADER_DIR)/emmc_appsboot.raw
cp -f $(OUTBIN) $(APPSBOOTHEADER_DIR)/EMMCBOOT.MBN
cp -f $(OUTBIN) $(APPSBOOTHEADER_DIR)/emmc_appsboot.mbn
emmc_appsboothd.mbn: mkheader $(OUTBIN)
$(BUILDDIR)/mkheader $(OUTBIN) $(APPSBOOTHEADER_DIR)/emmc_appsboothd.mbn unified-boot
mkheader: $(SRC_DIR)/mkheader.c
@mkdir -p $(BUILDDIR)
${COMPILER} -DMEMBASE=$(MEMBASE) $(SRC_DIR)/mkheader.c -o $(BUILDDIR)/mkheader

View File

@@ -0,0 +1,297 @@
/*
* Copyright (c) 2007, Google Inc.
* All rights reserved.
*
* Copyright (c) 2009-2011, The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Google, Inc. nor the names of its contributors
* may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>
#include <sys/stat.h>
int print_usage(){
fprintf(stderr,"usage: mkheader <bin> <hdr> <none|unified-boot>\n");
fprintf(stderr," mkheader <bin> <hdr> <unsecure-boot> <outbin>\n");
fprintf(stderr," mkheader <bin> <hdr> <secure-boot> <outbin> <maxsize>\n");
fprintf(stderr," mkheader <bin> <hdr> <secure-boot> <outbin> <maxsize> <certchain> <files...>\n\n");
fprintf(stderr,"bin: Input raw appsbl binary\n");
fprintf(stderr,"hdr: Output of appsbl header location\n");
fprintf(stderr,"outbin: Output of the signed or unsigned apps boot location\n");
fprintf(stderr,"maxsize: Maximum size for certificate chain\n");
fprintf(stderr,"certchain: Output of the certchain location\n");
fprintf(stderr,"files: Input format <bin signature> <certifcate file(s) for certificate chain>...\n");
fprintf(stderr,"certificate chain: Files will be concatenated in order to create the certificate chain\n\n");
return -1;
}
int cat(FILE * in, FILE * out, unsigned size, unsigned buff_size){
unsigned bytes_left = size;
char buf[buff_size];
int ret = 0;
while(bytes_left){
fread(buf, sizeof(char), buff_size, in);
if(!feof(in)){
bytes_left -= fwrite(buf, sizeof(char), buff_size, out);
}else
bytes_left = 0;
}
ret = ferror(in) | ferror(out);
if(ret)
fprintf(stderr, "ERROR: Occured during file concatenation\n");
return ret;
}
int main(int argc, char *argv[])
{
struct stat s;
unsigned size, base;
int unified_boot = 0;
unsigned unified_boot_magic[20];
unsigned non_unified_boot_magic[10];
unsigned magic_len = 0;
unsigned *magic;
unsigned cert_chain_size = 0;
unsigned signature_size = 0;
int secure_boot = 0;
int fd;
if(argc < 3) {
return print_usage();
}
if (argc == 4) {
if(!strcmp("unified-boot",argv[3])) {
unified_boot = 1;
}else if(!strcmp("secure-boot",argv[3])){
fprintf(stderr,
"ERROR: Missing arguments: [outbin maxsize] | [outbin, maxsize, certchain, signature + certifcate(s)]\n");
return print_usage();
}else if(!strcmp("unsecure-boot",argv[3])){
fprintf(stderr,"ERROR: Missing arguments: outbin directory\n");
return print_usage();
}
}
if (argc > 4) {
if(!strcmp("secure-boot",argv[3])) {
if(argc < 9 && argc != 6){
fprintf(stderr,
"ERROR: Missing argument(s): [outbin maxsize] | [outbin, maxsize, certchain, signature + certifcate(s)]\n");
return print_usage();
}
secure_boot = 1;
signature_size = 256; //Support SHA 256
cert_chain_size = atoi(argv[5]);
}
}
if(stat(argv[1], &s)) {
perror("cannot stat binary");
return -1;
}
if(unified_boot) {
magic = unified_boot_magic;
magic_len = sizeof(unified_boot_magic);
} else {
magic = non_unified_boot_magic;
magic_len = sizeof(non_unified_boot_magic);
}
size = s.st_size;
base = 0;
magic[0] = 0x00000005; /* appsbl */
magic[1] = 0x00000003; //Flash_partition_version /* nand */
magic[2] = 0x00000000; //image source pointer
magic[3] = base; //image destination pointer
magic[4] = size + cert_chain_size + signature_size; //image size
magic[5] = size; //code size
magic[6] = base + size;
magic[7] = signature_size;
magic[8] = size + base + signature_size;
magic[9] = cert_chain_size;
if (unified_boot == 1)
{
magic[10] = 0x33836685; /* cookie magic number */
magic[11] = 0x00000001; /* cookie version */
magic[12] = 0x00000002; /* file formats */
magic[13] = 0x00000000;
magic[14] = 0x00000000; /* not setting size for boot.img */
magic[15] = 0x00000000;
magic[16] = 0x00000000;
magic[17] = 0x00000000;
magic[18] = 0x00000000;
magic[19] = 0x00000000;
}
fd = open(argv[2], O_WRONLY | O_CREAT | O_TRUNC, 0644);
if(fd < 0) {
perror("cannot open header for writing");
return -1;
}
if(write(fd, magic, magic_len) != magic_len) {
perror("cannot write header");
close(fd);
unlink(argv[2]);
return -1;
}
close(fd);
if (secure_boot && argc > 6){
FILE * input_file;
FILE * output_file;
unsigned buff_size = 1;
char buf[buff_size];
unsigned bytes_left;
unsigned current_cert_chain_size = 0;
int padding_size = 0;
int i;
if((output_file = fopen(argv[6], "wb"))==NULL){
perror("ERROR: Occured during fopen");
return -1;
}
for (i = 8; i < argc; i++){
if((input_file = fopen(argv[i], "rb"))==NULL){
perror("ERROR: Occured during fopen");
return -1;
}
stat(argv[i], &s);
bytes_left = s.st_size;
current_cert_chain_size += bytes_left;
if (cat(input_file, output_file, bytes_left, buff_size))
return -1;
fclose(input_file);
}
//Pad certifcate chain to the max expected size from input
memset(buf, 0xFF, sizeof(buf));
padding_size = cert_chain_size - current_cert_chain_size;
bytes_left = (padding_size > 0) ? padding_size : 0;
while(bytes_left){
if(!ferror(output_file))
bytes_left -= fwrite(buf, sizeof(buf), buff_size, output_file);
else{
fprintf(stderr, "ERROR: Occured during certifcate chain padding\n");
return -1;
}
}
fclose(output_file);
//Concat and combine to signed image. Format [HDR][RAW APPSBOOT][PADDED CERT CHAIN]
if((output_file = fopen(argv[4], "wb"))==NULL){
perror("ERROR: Occured during fopen");
return -1;
}
//Header
if((input_file = fopen(argv[2], "rb"))==NULL){
perror("ERROR: Occured during fopen");
return -1;
}
stat(argv[2], &s);
if (cat(input_file, output_file, s.st_size, buff_size))
return -1;
fclose(input_file);
//Raw Appsbl
if((input_file = fopen(argv[1], "rb"))==NULL){
perror("ERROR: Occured during fopen");
return -1;
}
stat(argv[1], &s);
if(cat(input_file, output_file, s.st_size, buff_size))
return -1;
fclose(input_file);
//Signature
if((input_file = fopen(argv[7], "rb"))==NULL){
perror("ERROR: Occured during fopen");
return -1;
}
stat(argv[7], &s);
if(cat(input_file, output_file, s.st_size, buff_size))
return -1;
fclose(input_file);
//Certifcate Chain
if((input_file = fopen(argv[6], "rb"))==NULL){
perror("ERROR: Occured during fopen");
return -1;
}
if(cat(input_file, output_file, (current_cert_chain_size + padding_size), buff_size))
return -1;
fclose(input_file);
fclose(output_file);
}else if(argc == 5 || argc == 6){
FILE * input_file;
FILE * output_file;
unsigned buff_size = 1;
char buf[buff_size];
//Concat and combine to unsigned image. Format [HDR][RAW APPSBOOT]
if((output_file = fopen(argv[4], "wb"))==NULL){
perror("ERROR: Occured during fopen");
return -1;
}
//Header
if((input_file = fopen(argv[2], "rb"))==NULL){
perror("ERROR: Occured during fopen");
return -1;
}
stat(argv[2], &s);
if (cat(input_file, output_file, s.st_size, buff_size))
return -1;
fclose(input_file);
//Raw Appsbl
if((input_file = fopen(argv[1], "rb"))==NULL){
perror("ERROR: Occured during fopen");
return -1;
}
stat(argv[1], &s);
if(cat(input_file, output_file, s.st_size, buff_size))
return -1;
fclose(input_file);
fclose(output_file);
}
return 0;
}