From 141b2bedfc9bdbd40d15c306f104174a9da2b47b Mon Sep 17 00:00:00 2001 From: Paul Fertser Date: Thu, 28 May 2009 20:01:20 -0300 Subject: [PATCH] Use different MACs for the host and for the device ends of usb link This makes Qi consistent with current SHR boot script. It assigns the MAC specified on the identity partition to the device and the next address to the host, ie: from "g_ether.dev_addr=00:1F:11:01:58:67" generate "g_ether.host_addr=00:1F:11:01:58:68". Signed-off-by: Paul Fertser --- qiboot/src/cpu/s3c2442/gta02.c | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/qiboot/src/cpu/s3c2442/gta02.c b/qiboot/src/cpu/s3c2442/gta02.c index e9bc0a3..1a31274 100644 --- a/qiboot/src/cpu/s3c2442/gta02.c +++ b/qiboot/src/cpu/s3c2442/gta02.c @@ -558,6 +558,22 @@ void post_serial_init_gta02(void) puts("BATTERY CONDITION LOW\n"); } +/* + * Increment a hexadecimal digit represented by a char and + * return 1 if an overflow occured. + */ +static char inc_hexchar(char * p) +{ + if (*p == '9') + *p = 'A'; + else if (*p != 'F') + (*p)++; + else { + *p = '0'; + return 1; + } + return 0; +} /* * create and append device-specific Linux kernel commandline @@ -569,6 +585,7 @@ void post_serial_init_gta02(void) char * append_device_specific_cmdline_gta02(char * cmdline) { int n = 0; + int i; int len; static char mac[64]; struct kernel_source const * real_kernel = this_kernel; @@ -632,10 +649,17 @@ char * append_device_specific_cmdline_gta02(char * cmdline) mac[len] = '\0'; - cmdline += strlen(strcpy(cmdline, " g_ether.host_addr=")); + cmdline += strlen(strcpy(cmdline, " g_ether.dev_addr=")); cmdline += strlen(strcpy(cmdline, &mac[2])); - cmdline += strlen(strcpy(cmdline, " g_ether.dev_addr=")); + for (i = 0; i != 10; i++) { + if ((i % 3) == 2) + continue; + if (!inc_hexchar(mac + 18 - i)) + break; /* Carry not needed. */ + } + + cmdline += strlen(strcpy(cmdline, " g_ether.host_addr=")); cmdline += strlen(strcpy(cmdline, &mac[2])); *cmdline++ = ' ' ; bail: