Fix zd1211rw typo and call (#1241)
[openwrt.git] / package / broadcom-wl / src / kmod / patchtable.pl
1 #!/usr/bin/perl
2 #
3 # Copyright (C) 2006 OpenWrt.org
4 # Copyright (C) 2006 Felix Fietkau
5 #
6 # This is free software, licensed under the GNU General Public License v2.
7 # See /LICENSE for more information.
8 #
9 use strict;
10
11 my $TABLE = pack("V", 0xbadc0ded);
12 my $TABLE_SIZE = 512;
13 my $SLT1 = "\x01\x00\x00\x00";
14 my $SLT2 = "\x02\x00\x00\x00";
15 my $ACKW = "\x03\x00\x00\x00";
16 my $PTABLE_END = "\xff\xff\xff\xff";
17
18 my $addr = "";
19 my $opcode = "";
20 my $function = "";
21
22 sub add_entry {
23 my $key = shift;
24 my $value = shift;
25 my $default = shift;
26
27 $TABLE .= $key;
28 $TABLE .= pack("V", $value);
29 $TABLE .= pack("V", $default);
30 }
31
32 while (<>) {
33 $addr = $opcode = "";
34 /^\w{8}\s*<(.*)>:$/ and $function = $1;
35 /^\s*(\w+):\s*(\w{8})\s*/ and do {
36 $addr = $1;
37 $opcode = $2;
38 };
39
40 ($function eq 'wlc_update_slot_timing') and do {
41 # li a2,9 -- short slot time
42 ($opcode eq '24060009') and add_entry($SLT1, hex($addr), hex($opcode));
43 # li v0,519 -- 510 + short slot time
44 ($opcode eq '24020207') and add_entry($SLT2, hex($addr), hex($opcode));
45
46 # li a2,20 -- long slot time
47 ($opcode eq '24060014') and add_entry($SLT1, hex($addr), hex($opcode));
48 # li v0,530 -- 510 + long slot time
49 ($opcode eq '24020212') and add_entry($SLT2, hex($addr), hex($opcode));
50 };
51 ($function eq 'wlc_d11hdrs') and do {
52 # ori s6,s6,0x1 -- ack flag (new)
53 ($opcode eq '36d60001') and add_entry($ACKW, hex($addr), hex($opcode));
54 # ori s3,s3,0x1 -- ack flag (old)
55 ($opcode eq '36730001') and add_entry($ACKW, hex($addr), hex($opcode));
56 }
57 }
58
59 $TABLE .= $PTABLE_END;
60 $TABLE .= ("\x00" x ($TABLE_SIZE - length($TABLE)));
61 print $TABLE;
This page took 0.047036 seconds and 5 git commands to generate.