1
0
mirror of git://projects.qi-hardware.com/xburst-tools.git synced 2024-11-01 18:22:28 +02:00

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 <fercerpav@gmail.com>
This commit is contained in:
Paul Fertser 2009-05-28 20:01:20 -03:00 committed by Nelson Castillo
parent 8089e8de8b
commit 141b2bedfc

View File

@ -558,6 +558,22 @@ void post_serial_init_gta02(void)
puts("BATTERY CONDITION LOW\n"); 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 * 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) char * append_device_specific_cmdline_gta02(char * cmdline)
{ {
int n = 0; int n = 0;
int i;
int len; int len;
static char mac[64]; static char mac[64];
struct kernel_source const * real_kernel = this_kernel; struct kernel_source const * real_kernel = this_kernel;
@ -632,10 +649,17 @@ char * append_device_specific_cmdline_gta02(char * cmdline)
mac[len] = '\0'; 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, &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 += strlen(strcpy(cmdline, &mac[2]));
*cmdline++ = ' ' ; *cmdline++ = ' ' ;
bail: bail: