diff options
author | Simon Glass <sjg@chromium.org> | 2011-07-01 22:59:28 -0700 |
---|---|---|
committer | Simon Glass <sjg@chromium.org> | 2011-08-29 10:58:43 -0700 |
commit | d6d1abd8ee1f61e30be8d716b258ed9fbc191691 (patch) | |
tree | 9d0074149bba4590301716702aea125cd9f3780e /lib/chromeos | |
parent | ee884aac39b754470bfa87d507f307eee372f98e (diff) |
CHROMIUM: Add os_storage prefix onto os_storage. functions
BUG=chromium-os:17279
TEST=Build U-Boot
Change-Id: I0cdd8f6e4cc586301a3b1ce32a388f936a877829
Reviewed-on: http://gerrit.chromium.org/gerrit/3605
Reviewed-by: Che-Liang Chiou <clchiou@chromium.org>
Tested-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'lib/chromeos')
-rw-r--r-- | lib/chromeos/load_kernel_helper.c | 6 | ||||
-rw-r--r-- | lib/chromeos/os_storage.c | 60 |
2 files changed, 43 insertions, 23 deletions
diff --git a/lib/chromeos/load_kernel_helper.c b/lib/chromeos/load_kernel_helper.c index 1b456eb1d5..971dcc1ca4 100644 --- a/lib/chromeos/load_kernel_helper.c +++ b/lib/chromeos/load_kernel_helper.c @@ -51,8 +51,8 @@ static int load_kernel_wrapper(LoadKernelParams *params, uint64_t boot_flags, params->shared_data_blob = vbshared_data; params->shared_data_size = vbshared_size; - params->bytes_per_lba = get_bytes_per_lba(); - params->ending_lba = get_ending_lba(); + params->bytes_per_lba = os_storage_get_bytes_per_lba(); + params->ending_lba = os_storage_get_ending_lba(); params->kernel_buffer = (void*)CONFIG_CHROMEOS_KERNEL_LOADADDR; params->kernel_buffer_size = CONFIG_CHROMEOS_KERNEL_BUFSIZE; @@ -255,7 +255,7 @@ static int boot_kernel_helper(LoadKernelParams *params) strcat(cmdline_buf, cmdline); VBDEBUG(PREFIX "cmdline before update: %s\n", cmdline_buf); - update_cmdline(cmdline_buf, get_device_number(), + update_cmdline(cmdline_buf, os_storage_get_device_number(), params->partition_number + 1, params->partition_guid, cmdline_out); diff --git a/lib/chromeos/os_storage.c b/lib/chromeos/os_storage.c index 336d333b04..cea323f25c 100644 --- a/lib/chromeos/os_storage.c +++ b/lib/chromeos/os_storage.c @@ -29,27 +29,33 @@ static struct os_storage bootdev_config = { .limit = 0u }; -block_dev_desc_t *get_bootdev(void) +static int os_storage_BootDeviceReadLBA(uint64_t lba_start, uint64_t lba_count, + void *buffer); +static int os_storage_BootDeviceWriteLBA(uint64_t lba_start, uint64_t lba_count, + const void *buffer); + + +block_dev_desc_t *os_storage_get_bootdev(void) { return bootdev_config.dev_desc; } -int get_device_number(void) +int os_storage_get_device_number(void) { return bootdev_config.dev_desc->dev; } -ulong get_offset(void) +ulong os_storage_get_offset(void) { return bootdev_config.offset; } -ulong get_limit(void) +ulong os_storage_get_limit(void) { return bootdev_config.limit; } -uint64_t get_bytes_per_lba(void) +uint64_t os_storage_get_bytes_per_lba(void) { if (!bootdev_config.dev_desc) { VBDEBUG(PREFIX "get_bytes_per_lba: not dev_desc set\n"); @@ -59,13 +65,13 @@ uint64_t get_bytes_per_lba(void) return (uint64_t) bootdev_config.dev_desc->blksz; } -uint64_t get_ending_lba(void) +uint64_t os_storage_get_ending_lba(void) { uint8_t static_buf[512]; uint8_t *buf = NULL; uint64_t ret = ~0ULL, bytes_per_lba = ~0ULL; - bytes_per_lba = get_bytes_per_lba(); + bytes_per_lba = os_storage_get_bytes_per_lba(); if (bytes_per_lba == ~0ULL) { VBDEBUG(PREFIX "get_ending_lba: get bytes_per_lba fail\n"); goto EXIT; @@ -76,7 +82,7 @@ uint64_t get_ending_lba(void) else buf = static_buf; - if (BootDeviceReadLBA(1, 1, buf)) { + if (os_storage_BootDeviceReadLBA(1, 1, buf)) { VBDEBUG(PREFIX "get_ending_lba: read primary GPT header fail\n"); goto EXIT; } @@ -90,7 +96,7 @@ EXIT: return ret; } -int set_bootdev(char *ifname, int dev, int part) +int os_storage_set_bootdev(char *ifname, int dev, int part) { disk_partition_t part_info; @@ -122,7 +128,8 @@ cleanup: return 1; } -int BootDeviceReadLBA(uint64_t lba_start, uint64_t lba_count, void *buffer) +static int os_storage_BootDeviceReadLBA(uint64_t lba_start, uint64_t lba_count, + void *buffer) { block_dev_desc_t *dev_desc; @@ -140,7 +147,7 @@ int BootDeviceReadLBA(uint64_t lba_start, uint64_t lba_count, void *buffer) return 0; } -int BootDeviceWriteLBA(uint64_t lba_start, uint64_t lba_count, +static int os_storage_BootDeviceWriteLBA(uint64_t lba_start, uint64_t lba_count, const void *buffer) { block_dev_desc_t *dev_desc; @@ -159,7 +166,7 @@ int BootDeviceWriteLBA(uint64_t lba_start, uint64_t lba_count, return 0; } -int initialize_mmc_device(int dev) +int os_storage_initialize_mmc_device(int dev) { struct mmc *mmc; int err; @@ -178,7 +185,19 @@ int initialize_mmc_device(int dev) return 0; } -int is_mmc_storage_present(int mmc_device_number) +/* For vboot (pre re-factor) */ +int BootDeviceReadLBA(uint64_t lba_start, uint64_t lba_count, void *buffer) +{ + return os_storage_BootDeviceReadLBA(lba_start, lba_count, buffer); +} + +int BootDeviceWriteLBA(uint64_t lba_start, uint64_t lba_count, + const void *buffer) +{ + return os_storage_BootDeviceWriteLBA(lba_start, lba_count, buffer); +} + +int os_storage_is_mmc_storage_present(int mmc_device_number) { /* * mmc_init tests the SD card's version and tries its operating @@ -189,7 +208,7 @@ int is_mmc_storage_present(int mmc_device_number) return mmc != NULL && mmc_init(mmc) == 0; } -int is_usb_storage_present(void) +int os_storage_is_usb_storage_present(void) { /* TODO(waihong): Better way to probe USB than restart it */ usb_stop(); @@ -201,32 +220,33 @@ int is_usb_storage_present(void) return 1; } -int is_any_storage_device_plugged(int boot_probed_device) +int os_storage_is_any_storage_device_plugged(int boot_probed_device) { VBDEBUG(PREFIX "probe external mmc\n"); - if (is_mmc_storage_present(MMC_EXTERNAL_DEVICE)) { + if (os_storage_is_mmc_storage_present(MMC_EXTERNAL_DEVICE)) { if (boot_probed_device == NOT_BOOT_PROBED_DEVICE) { VBDEBUG(PREFIX "probed external mmc\n"); return 1; } VBDEBUG(PREFIX "try to set boot device to external mmc\n"); - if (!initialize_mmc_device(MMC_EXTERNAL_DEVICE) && - !set_bootdev("mmc", MMC_EXTERNAL_DEVICE, 0)) { + if (!os_storage_initialize_mmc_device(MMC_EXTERNAL_DEVICE) && + !os_storage_set_bootdev("mmc", + MMC_EXTERNAL_DEVICE, 0)) { VBDEBUG(PREFIX "set external mmc as boot device\n"); return 1; } } VBDEBUG(PREFIX "probe usb\n"); - if (is_usb_storage_present()) { + if (os_storage_is_usb_storage_present()) { if (boot_probed_device == NOT_BOOT_PROBED_DEVICE) { VBDEBUG(PREFIX "probed usb\n"); return 1; } VBDEBUG(PREFIX "try to set boot device to usb\n"); - if (!set_bootdev("usb", 0, 0)) { + if (!os_storage_set_bootdev("usb", 0, 0)) { VBDEBUG(PREFIX "set usb as boot device\n"); return 1; } |