Files
OpenCellular/chip/g/loader/rom_flash.h
Vadim Bendebury 725bef1b3b cr50: RO Loader implementation
This code is a port of the sample loader application included in the
FPGA update. Only the pieces relevant to straight verification and
boot were ported.

The loader generates a hash, inputs to which are the image body, state
of fuses and state of flash INFO region, and the output is the value,
which will unlock the region for execution, if it is correct.

Only one image load is attempted, the image is supposed to be located
in the flash at the offset of CONFIG_RW_MEM_OFF.

BRANCH=none
BUG=chrome-os-partner:43025
TEST=with the rest of the patches applied the RO image successfully
     verifies and starts up the RW image.

Change-Id: I26e1fbdaeb8b23d519c1a328526a3422231bb322
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/311316
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2015-11-10 06:54:43 -08:00

60 lines
1.7 KiB
C

/* Copyright 2015 The Chromium OS Authors. All rights reserved.
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifndef __EC_CHIP_G_LOADER_ROM_FLASH_H
#define __EC_CHIP_G_LOADER_ROM_FLASH_H
#include "registers.h"
#define FSH_OP_BULKERASE GC_CONST_FSH_PE_CONTROL_BULKERASE
#define FSH_OP_ENABLE GC_CONST_FSH_PE_EN
#define FSH_OP_ERASE GC_CONST_FSH_PE_CONTROL_ERASE
#define FSH_OP_PROGRAM GC_CONST_FSH_PE_CONTROL_PROGRAM
#define FSH_OP_READ GC_CONST_FSH_PE_CONTROL_READ
#if 0
#define num_flashes 2
/*
* FIX ME: words_per_row = m.get_flash_param("FlashWordsPerRow")
* FIX ME: rows_per_page = m.get_flash_param("FlashRowsPerPage")
* FIX ME: words_per_page = int(words_per_row)*int(rows_per_page)
*/
#define words_per_page 512
/* This is BAD... This number is based on the TSMC spec Nmp=Tprog/Tsmp */
#define _max_prog_cycles 9
/* This is BAD... This number is based on the TSMC spec Nme=Terase/Tsme */
#define _max_erase_cycles 45
/* This is BAD... This number is based on the TSMC spec Nme=Terase/Tsme */
#define _max_bulkerase_cycles 45
#define _debug_flash 0
/* write words to flash */
int flash_write(uint32_t fidx, uint32_t offset,
const uint32_t *data, uint32_t size);
/* erase one page */
int flash_erase(uint32_t fidx, uint32_t page);
/* erase entire bank */
int flash_wipe(uint32_t fidx);
#endif
#define E_FL_NOT_AWAKE 1
#define E_FL_TIMEOUT 2
#define E_FL_BAD_MAINB 3
#define E_FL_BAD_SIZE 4
#define E_FL_BAD_PTR 5
#define E_FL_BAD_BANK 6
#define E_FL_WRITE_FAIL 7
#define E_FL_ERASE_FAIL 8
#define E_FL_WIPE_FAIL 9
#define E_FL_ERROR 10
/* read single word from info block */
int flash_info_read(uint32_t offset, uint32_t *dst);
#endif /* __EC_CHIP_G_LOADER_ROM_FLASH_H */