4 * Mikrotik's RouterBOOT specific prom routines
6 * Copyright (C) 2007 OpenWrt.org
7 * Copyright (C) 2007 Gabor Juhos <juhosg at openwrt.org>
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version 2
12 * of the License, or (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the
21 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
22 * Boston, MA 02110-1301, USA.
25 #include <linux/types.h>
26 #include <linux/autoconf.h>
27 #include <linux/kernel.h>
28 #include <linux/init.h>
29 #include <linux/string.h>
30 #include <linux/module.h>
32 #include <asm/bootinfo.h>
33 #include <asm/addrspace.h>
35 #include <adm5120_defs.h>
36 #include <prom/routerboot.h>
37 #include "prom_read.h"
39 struct rb_hard_settings rb_hs
;
42 static int __init
routerboot_load_hs(u8
*buf
, u16 buflen
)
46 memset(&rb_hs
, 0, sizeof(rb_hs
));
51 if (prom_read_le32(buf
) != RB_MAGIC_HARD
)
54 /* skip magic value */
59 id
= prom_read_le16(buf
);
62 if (id
== RB_ID_TERMINATOR
|| buflen
< 2)
65 len
= prom_read_le16(buf
);
73 case RB_ID_BIOS_VERSION
:
74 rb_hs
.bios_ver
= (char *)buf
;
76 case RB_ID_BOARD_NAME
:
77 rb_hs
.name
= (char *)buf
;
79 case RB_ID_MEMORY_SIZE
:
80 rb_hs
.mem_size
= prom_read_le32(buf
);
82 case RB_ID_MAC_ADDRESS_COUNT
:
83 rb_hs
.mac_count
= prom_read_le32(buf
);
85 case RB_ID_MAC_ADDRESS_PACK
:
86 if ((len
/ RB_MAC_SIZE
) > 0)
99 #define RB_BS_OFFS 0x14
100 #define RB_OFFS_MAX (128*1024)
102 int __init
routerboot_present(void)
104 struct rb_bios_settings
*bs
;
111 base
= (u8
*)KSEG1ADDR(ADM5120_SRAM0_BASE
);
112 bs
= (struct rb_bios_settings
*)(base
+ RB_BS_OFFS
);
114 off
= prom_read_le32(&bs
->hs_offs
);
115 len
= prom_read_le32(&bs
->hs_size
);
116 if (off
> RB_OFFS_MAX
)
119 if (routerboot_load_hs(base
+off
, len
) != 0)
128 char *routerboot_get_boardname(void)