fix burn-macs to work on 32-bit machines too

This commit is contained in:
Mariano Alvira 2011-03-12 22:36:39 -05:00
parent c27e96f1e9
commit 72cb4157d9

View file

@ -5,11 +5,14 @@ my $bin = shift;
my $terms = shift; my $terms = shift;
my $addr = "0x1e000"; my $addr = "0x1e000";
my $company_id; my $iab = 0xa8c; # Redwire, LLC's IAB
my $iab = 0xabc; # Redwire, LLC's IAB
my $mac_h;
my $mac_l;
if(defined($iab)) { if(defined($iab)) {
$company_id = (0x0050C2 << 12) | $iab; $mac_h = 0x0050C200 | ($iab >> 4);
$mac_l = ($iab & 0xf) << 28;
} }
if (! $terms) { if (! $terms) {
@ -19,15 +22,17 @@ if (! $terms) {
for (my $t=0; $t<$terms; $t++) { for (my $t=0; $t<$terms; $t++) {
my $dev_num = 2 * $t + 1; my $dev_num = 2 * $t + 1;
$mac_l |= $dev_num;
#stupid 32-bit thing...
my $mac; my $mac;
if(defined($iab)) { printf("mac_h %x\n", $mac_h);
$mac = ($company_id << 28) | $dev_num; printf("mac_l %x\n", $mac_l);
} else {
$mac = ($company_id << 40) | $dev_num;
}
my @words; my @words;
for(my $i=0; $i<8; $i++) { for(my $i=0; $i<4; $i++) {
push @words, ($mac >> ($i * 8)) & 0xff; push @words, ($mac_h >> ($i * 8)) & 0xff;
}
for(my $i=0; $i<4; $i++) {
push @words, ($mac_l >> ($i * 8)) & 0xff;
} }
reverse @words; reverse @words;
foreach my $byte (@words) { foreach my $byte (@words) {