Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(926)

Side by Side Diff: data_layout.c

Issue 6611009: Add the nand device support for cbootimage tool. (Closed) Base URL: http://git.chromium.org/git/cbootimage.git@master
Patch Set: Created 9 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« cbootimage.c ('K') | « data_layout.h ('k') | nvbctlib.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /** 1 /**
2 * Copyright (c) 2011 NVIDIA Corporation. All rights reserved. 2 * Copyright (c) 2011 NVIDIA Corporation. All rights reserved.
3 * 3 *
4 * See file CREDITS for list of people who contributed to this 4 * See file CREDITS for list of people who contributed to this
5 * project. 5 * project.
6 * 6 *
7 * This program is free software; you can redistribute it and/or 7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License as 8 * modify it under the terms of the GNU General Public License as
9 * published by the Free Software Foundation; either version 2 of 9 * published by the Free Software Foundation; either version 2 of
10 * the License, or (at your option) any later version. 10 * the License, or (at your option) any later version.
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 static void 72 static void
73 set_bl_data(build_image_context *context, 73 set_bl_data(build_image_context *context,
74 u_int32_t instance, 74 u_int32_t instance,
75 u_int32_t start_blk, 75 u_int32_t start_blk,
76 u_int32_t start_page, 76 u_int32_t start_page,
77 u_int32_t length); 77 u_int32_t length);
78 78
79 static int write_bootloaders(build_image_context *context); 79 static int write_bootloaders(build_image_context *context);
80 80
81 static void find_new_journal_blk(build_image_context *context); 81 static void find_new_journal_blk(build_image_context *context);
82 static int begin_update (build_image_context *context);
83 static int finish_update(build_image_context *context); 82 static int finish_update(build_image_context *context);
84 static u_int32_t 83 static u_int32_t
85 iceil_log2(u_int32_t a, u_int32_t b) 84 iceil_log2(u_int32_t a, u_int32_t b)
86 { 85 {
87 return (a + (1 << b) - 1) >> b; 86 return (a + (1 << b) - 1) >> b;
88 } 87 }
89 88
90 static block_data *new_block(u_int32_t blk_number, u_int32_t block_size) 89 static block_data *new_block(u_int32_t blk_number, u_int32_t block_size)
91 { 90 {
92 block_data *new_block = malloc(sizeof(block_data)); 91 block_data *new_block = malloc(sizeof(block_data));
(...skipping 771 matching lines...) Expand 10 before | Expand all | Expand 10 after
864 * - Erase the new journal block 863 * - Erase the new journal block
865 * - Write the good BCT to slot 0 of the new journal block. 864 * - Write the good BCT to slot 0 of the new journal block.
866 * - If the journal block is full: 865 * - If the journal block is full:
867 * - Erase block 0 866 * - Erase block 0
868 * - Write 0's to BCT slot 0. 867 * - Write 0's to BCT slot 0.
869 * - Write the good BCT to slot 1. 868 * - Write the good BCT to slot 1.
870 * - Erase the journal block. 869 * - Erase the journal block.
871 * - Write the good BCT to slot 0 of the journal block. 870 * - Write the good BCT to slot 0 of the journal block.
872 * - Erase block 0 871 * - Erase block 0
873 */ 872 */
874 static int 873 int
875 begin_update(build_image_context *context) 874 begin_update(build_image_context *context)
876 { 875 {
877 u_int32_t pages_per_bct; 876 u_int32_t pages_per_bct;
878 u_int32_t pages_per_blk; 877 u_int32_t pages_per_blk;
879 u_int32_t bct_size; 878 u_int32_t bct_size;
880 u_int32_t hash_size; 879 u_int32_t hash_size;
881 u_int32_t reserved_size; 880 u_int32_t reserved_size;
882 u_int32_t reserved_offset; 881 u_int32_t reserved_offset;
883 int e = 0; 882 int e = 0;
884 883
885 assert(context); 884 assert(context);
886 885
887 /* Ensure that the BCT block & page data is current. */ 886 /* Ensure that the BCT block & page data is current. */
888 if (enable_debug) { 887 if (enable_debug) {
889 u_int32_t block_size_log2; 888 u_int32_t block_size_log2;
890 u_int32_t page_size_log2; 889 u_int32_t page_size_log2;
891 890
892 GET_VALUE(block_size_log2, &block_size_log2); 891 GET_VALUE(block_size_log2, &block_size_log2);
893 GET_VALUE(page_size_log2, &page_size_log2); 892 GET_VALUE(page_size_log2, &page_size_log2);
894 893
895 printf("begin_update(): bct data: b=%d p=%d\n", 894 printf("begin_update(): bct data: b=%d p=%d\n",
896 block_size_log2, page_size_log2); 895 block_size_log2, page_size_log2);
897 } 896 }
898 897
898 SET_VALUE(boot_data_version, NVBOOT_BOOTDATA_VERSION(2, 1));
robotboy 2011/03/03 18:08:46 Similarly here, is this just a bug fix?
899 GET_VALUE(bct_size, &bct_size); 899 GET_VALUE(bct_size, &bct_size);
900 GET_VALUE(hash_size, &hash_size); 900 GET_VALUE(hash_size, &hash_size);
901 GET_VALUE(reserved_size, &reserved_size); 901 GET_VALUE(reserved_size, &reserved_size);
902 GET_VALUE(reserved_offset, &reserved_offset); 902 GET_VALUE(reserved_offset, &reserved_offset);
903 903
904 pages_per_bct = iceil_log2(bct_size, context->page_size_log2); 904 pages_per_bct = iceil_log2(bct_size, context->page_size_log2);
905 pages_per_blk = (1 << (context->block_size_log2 905 pages_per_blk = (1 << (context->block_size_log2
906 - context->page_size_log2)); 906 - context->page_size_log2));
907 907
908 /* Fill the reserved data w/the padding pattern. */ 908 /* Fill the reserved data w/the padding pattern. */
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
1021 size_t bytes = pages_to_write * context->page_size; 1021 size_t bytes = pages_to_write * context->page_size;
1022 1022
1023 if (fwrite(data, 1, bytes, context->raw_file) != bytes) 1023 if (fwrite(data, 1, bytes, context->raw_file) != bytes)
1024 return -1; 1024 return -1;
1025 } 1025 }
1026 } 1026 }
1027 1027
1028 free(empty_blk); 1028 free(empty_blk);
1029 return 0; 1029 return 0;
1030 } 1030 }
OLDNEW
« cbootimage.c ('K') | « data_layout.h ('k') | nvbctlib.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698