<html><head></head><body><div style="color:#000; background-color:#fff; font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, Sans-Serif;font-size:16px"><div id="yui_3_16_0_ym19_1_1462972442414_3775" dir="ltr"> Add optional commandline argument to override dtb max size. Used for platforms which uses large amount of device tree source codes.</div><div id="yui_3_16_0_ym19_1_1462972442414_6096" dir="ltr"><br></div><div id="yui_3_16_0_ym19_1_1462972442414_6087" dir="ltr"><em id="yui_3_16_0_ym19_1_1462972442414_3822">diff --git a/tools/patch-image/src/patch-cmdline.c b/tools/patch-image/src/patch-cmdline.c<br id="yui_3_16_0_ym19_1_1462972442414_5970">--- a/tools/patch-image/src/patch-cmdline.c<br id="yui_3_16_0_ym19_1_1462972442414_5971">+++ b/tools/patch-image/src/patch-cmdline.c<br id="yui_3_16_0_ym19_1_1462972442414_5972">@@ -35,11 +35,18 @@ int main(int argc, char **argv)<br id="yui_3_16_0_ym19_1_1462972442414_5973"> {<br id="yui_3_16_0_ym19_1_1462972442414_5974"> int fd, found = 0, len, ret = -1;<br id="yui_3_16_0_ym19_1_1462972442414_5975"> char *ptr, *p;<br id="yui_3_16_0_ym19_1_1462972442414_5976">+ unsigned int search_space;<br id="yui_3_16_0_ym19_1_1462972442414_5977"> <br id="yui_3_16_0_ym19_1_1462972442414_5978">- if (argc != 3) {<br id="yui_3_16_0_ym19_1_1462972442414_5979">- fprintf(stderr, "Usage: %s <file> <cmdline>\n", argv[0]);<br id="yui_3_16_0_ym19_1_1462972442414_5980">+ if (argc <= 2 || argc > 4) {<br id="yui_3_16_0_ym19_1_1462972442414_5981">+ fprintf(stderr, "Usage: %s <file> <cmdline> [dtb max size]\n", argv[0]);<br id="yui_3_16_0_ym19_1_1462972442414_5982"> goto err1;<br id="yui_3_16_0_ym19_1_1462972442414_5983">+ } else if (argc == 3) {<br id="yui_3_16_0_ym19_1_1462972442414_5984">+ fprintf(stdout, "DTB max size set to defaults (16KB). You can also override it by passing a size (in bytes) as an additional argument.\n");<br id="yui_3_16_0_ym19_1_1462972442414_5985">+ search_space = SEARCH_SPACE;<br id="yui_3_16_0_ym19_1_1462972442414_5986">+ } else {<br id="yui_3_16_0_ym19_1_1462972442414_5987">+ search_space = atoi(argv[3]);<br id="yui_3_16_0_ym19_1_1462972442414_5988"> }<br id="yui_3_16_0_ym19_1_1462972442414_5989">+<br id="yui_3_16_0_ym19_1_1462972442414_5990"> len = strlen(argv[2]);<br id="yui_3_16_0_ym19_1_1462972442414_5991"> if (len + 9 > CMDLINE_MAX) {<br id="yui_3_16_0_ym19_1_1462972442414_5992"> fprintf(stderr, "Command line string too long\n");<br id="yui_3_16_0_ym19_1_1462972442414_5993">@@ -47,12 +54,12 @@ int main(int argc, char **argv)<br id="yui_3_16_0_ym19_1_1462972442414_5994"> }<br id="yui_3_16_0_ym19_1_1462972442414_5995"> <br id="yui_3_16_0_ym19_1_1462972442414_5996"> if (((fd = open(argv[1], O_RDWR)) < 0) ||<br id="yui_3_16_0_ym19_1_1462972442414_5997">- (ptr = (char *) mmap(0, SEARCH_SPACE + CMDLINE_MAX, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0)) == (void *) (-1)) {<br id="yui_3_16_0_ym19_1_1462972442414_5998">+ (ptr = (char *) mmap(0, search_space + CMDLINE_MAX, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0)) == (void *) (-1)) {<br id="yui_3_16_0_ym19_1_1462972442414_5999"> fprintf(stderr, "Could not open kernel image");<br id="yui_3_16_0_ym19_1_1462972442414_6000"> goto err2;<br id="yui_3_16_0_ym19_1_1462972442414_6001"> }<br id="yui_3_16_0_ym19_1_1462972442414_6002"> <br id="yui_3_16_0_ym19_1_1462972442414_6003">- for (p = ptr; p < (ptr + SEARCH_SPACE); p += 4) {<br id="yui_3_16_0_ym19_1_1462972442414_6004">+ for (p = ptr; p < (ptr + search_space); p += 4) {<br id="yui_3_16_0_ym19_1_1462972442414_6005"> if (memcmp(p, "CMDLINE:", 8) == 0) {<br id="yui_3_16_0_ym19_1_1462972442414_6006"> found = 1;<br id="yui_3_16_0_ym19_1_1462972442414_6007"> p += 8;<br id="yui_3_16_0_ym19_1_1462972442414_6008">diff --git a/tools/patch-image/src/patch-dtb.c b/tools/patch-image/src/patch-dtb.c<br id="yui_3_16_0_ym19_1_1462972442414_6009">--- a/tools/patch-image/src/patch-dtb.c<br id="yui_3_16_0_ym19_1_1462972442414_6010">+++ b/tools/patch-image/src/patch-dtb.c<br id="yui_3_16_0_ym19_1_1462972442414_6011">@@ -38,11 +38,19 @@ int main(int argc, char **argv)<br id="yui_3_16_0_ym19_1_1462972442414_6012"> int fd, fddtb, found = 0, len, ret = -1;<br id="yui_3_16_0_ym19_1_1462972442414_6013"> char *ptr, *ptrdtb, *p;<br id="yui_3_16_0_ym19_1_1462972442414_6014"> struct stat s;<br id="yui_3_16_0_ym19_1_1462972442414_6015">+ unsigned int search_space, dtb_max_size;<br id="yui_3_16_0_ym19_1_1462972442414_6016"> <br id="yui_3_16_0_ym19_1_1462972442414_6017">- if (argc != 3) {<br id="yui_3_16_0_ym19_1_1462972442414_6018">- fprintf(stderr, "Usage: %s <file> <dtb>\n", argv[0]);<br id="yui_3_16_0_ym19_1_1462972442414_6019">+ if (argc <= 2 || argc > 4) {<br id="yui_3_16_0_ym19_1_1462972442414_6020">+ fprintf(stderr, "Usage: %s <file> <dtb> [dtb max size]\n", argv[0]);<br id="yui_3_16_0_ym19_1_1462972442414_6021"> goto err1;<br id="yui_3_16_0_ym19_1_1462972442414_6022">+ } else if (argc == 3) {<br id="yui_3_16_0_ym19_1_1462972442414_6023">+ fprintf(stdout, "DTB max size set to defaults (16KB). You can also override it by passing a size (in bytes) as an additional argument.\n");<br id="yui_3_16_0_ym19_1_1462972442414_6024">+ search_space = SEARCH_SPACE;<br id="yui_3_16_0_ym19_1_1462972442414_6025">+ dtb_max_size = DTB_MAX;<br id="yui_3_16_0_ym19_1_1462972442414_6026">+ } else {<br id="yui_3_16_0_ym19_1_1462972442414_6027">+ search_space = dtb_max_size = atoi(argv[3]);<br id="yui_3_16_0_ym19_1_1462972442414_6028"> }<br id="yui_3_16_0_ym19_1_1462972442414_6029">+<br id="yui_3_16_0_ym19_1_1462972442414_6030"> fddtb = open(argv[1], O_RDONLY);<br id="yui_3_16_0_ym19_1_1462972442414_6031"> if (!fddtb)<br id="yui_3_16_0_ym19_1_1462972442414_6032"> goto err1;<br id="yui_3_16_0_ym19_1_1462972442414_6033">@@ -53,24 +61,24 @@ int main(int argc, char **argv)<br id="yui_3_16_0_ym19_1_1462972442414_6034"> }<br id="yui_3_16_0_ym19_1_1462972442414_6035"> <br id="yui_3_16_0_ym19_1_1462972442414_6036"> len = s.st_size;<br id="yui_3_16_0_ym19_1_1462972442414_6037">- if (len + 8 > DTB_MAX) {<br id="yui_3_16_0_ym19_1_1462972442414_6038">+ if (len + 8 > dtb_max_size) {<br id="yui_3_16_0_ym19_1_1462972442414_6039"> fprintf(stderr, "DTB too big\n");<br id="yui_3_16_0_ym19_1_1462972442414_6040"> goto err1;<br id="yui_3_16_0_ym19_1_1462972442414_6041"> }<br id="yui_3_16_0_ym19_1_1462972442414_6042"> <br id="yui_3_16_0_ym19_1_1462972442414_6043"> if (((fddtb = open(argv[2], O_RDONLY)) < 0) ||<br id="yui_3_16_0_ym19_1_1462972442414_6044">- (ptrdtb = (char *) mmap(0, DTB_MAX, PROT_READ, MAP_SHARED, fddtb, 0)) == (void *) (-1)) {<br id="yui_3_16_0_ym19_1_1462972442414_6045">+ (ptrdtb = (char *) mmap(0, dtb_max_size, PROT_READ, MAP_SHARED, fddtb, 0)) == (void *) (-1)) {<br id="yui_3_16_0_ym19_1_1462972442414_6046"> fprintf(stderr, "Could not open DTB");<br id="yui_3_16_0_ym19_1_1462972442414_6047"> goto err2;<br id="yui_3_16_0_ym19_1_1462972442414_6048"> }<br id="yui_3_16_0_ym19_1_1462972442414_6049"> <br id="yui_3_16_0_ym19_1_1462972442414_6050"> if (((fd = open(argv[1], O_RDWR)) < 0) ||<br id="yui_3_16_0_ym19_1_1462972442414_6051">- (ptr = (char *) mmap(0, SEARCH_SPACE + DTB_MAX, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0)) == (void *) (-1)) {<br id="yui_3_16_0_ym19_1_1462972442414_6052">+ (ptr = (char *) mmap(0, search_space + dtb_max_size, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0)) == (void *) (-1)) {<br id="yui_3_16_0_ym19_1_1462972442414_6053"> fprintf(stderr, "Could not open kernel image");<br id="yui_3_16_0_ym19_1_1462972442414_6054"> goto err3;<br id="yui_3_16_0_ym19_1_1462972442414_6055"> }<br id="yui_3_16_0_ym19_1_1462972442414_6056"> <br id="yui_3_16_0_ym19_1_1462972442414_6057">- for (p = ptr; p < (ptr + SEARCH_SPACE); p += 4) {<br id="yui_3_16_0_ym19_1_1462972442414_6058">+ for (p = ptr; p < (ptr + search_space); p += 4) {<br id="yui_3_16_0_ym19_1_1462972442414_6059"> if (memcmp(p, "OWRTDTB:", 8) == 0) {<br id="yui_3_16_0_ym19_1_1462972442414_6060"> found = 1;<br id="yui_3_16_0_ym19_1_1462972442414_6061"> p += 8;<br id="yui_3_16_0_ym19_1_1462972442414_6062">@@ -82,7 +90,7 @@ int main(int argc, char **argv)<br id="yui_3_16_0_ym19_1_1462972442414_6063"> goto err4;<br id="yui_3_16_0_ym19_1_1462972442414_6064"> }<br id="yui_3_16_0_ym19_1_1462972442414_6065"> <br id="yui_3_16_0_ym19_1_1462972442414_6066">- memset(p, 0, DTB_MAX - 8);<br id="yui_3_16_0_ym19_1_1462972442414_6067">+ memset(p, 0, dtb_max_size - 8);<br id="yui_3_16_0_ym19_1_1462972442414_6068"> memcpy(p, ptrdtb, len);<br id="yui_3_16_0_ym19_1_1462972442414_6069"> msync(p, len, MS_SYNC|MS_INVALIDATE);<br id="yui_3_16_0_ym19_1_1462972442414_6070"> ret = 0;</em></div><div dir="ltr"><em></em><br></div><div id="yui_3_16_0_ym19_1_1462972442414_5784" dir="ltr"><em id="yui_3_16_0_ym19_1_1462972442414_5783">Signed-off-by: Swaroop Sarma < duddu.swaroop@intel.com </em><em id="yui_3_16_0_ym19_1_1462972442414_3826">>
</em></div></div></body></html>