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 modify it
10 * under the terms of the GNU General Public License version 2 as published
11 * by the Free Software Foundation.
15 #include <linux/types.h>
16 #include <linux/autoconf.h>
17 #include <linux/kernel.h>
18 #include <linux/init.h>
19 #include <linux/string.h>
20 #include <linux/module.h>
22 #include <asm/bootinfo.h>
23 #include <asm/addrspace.h>
25 #include <adm5120_defs.h>
26 #include <prom/routerboot.h>
27 #include "prom_read.h"
29 struct rb_hard_settings rb_hs
;
32 static int __init
routerboot_load_hs(u8
*buf
, u16 buflen
)
36 memset(&rb_hs
, 0, sizeof(rb_hs
));
41 if (prom_read_le32(buf
) != RB_MAGIC_HARD
)
44 /* skip magic value */
49 id
= prom_read_le16(buf
);
52 if (id
== RB_ID_TERMINATOR
|| buflen
< 2)
55 len
= prom_read_le16(buf
);
63 case RB_ID_BIOS_VERSION
:
64 rb_hs
.bios_ver
= (char *)buf
;
66 case RB_ID_BOARD_NAME
:
67 rb_hs
.name
= (char *)buf
;
69 case RB_ID_MEMORY_SIZE
:
70 rb_hs
.mem_size
= prom_read_le32(buf
);
72 case RB_ID_MAC_ADDRESS_COUNT
:
73 rb_hs
.mac_count
= prom_read_le32(buf
);
75 case RB_ID_MAC_ADDRESS_PACK
:
76 if ((len
/ RB_MAC_SIZE
) > 0)
89 #define RB_BS_OFFS 0x14
90 #define RB_OFFS_MAX (128*1024)
92 int __init
routerboot_present(void)
94 struct rb_bios_settings
*bs
;
101 base
= (u8
*)KSEG1ADDR(ADM5120_SRAM0_BASE
);
102 bs
= (struct rb_bios_settings
*)(base
+ RB_BS_OFFS
);
104 off
= prom_read_le32(&bs
->hs_offs
);
105 len
= prom_read_le32(&bs
->hs_size
);
106 if (off
> RB_OFFS_MAX
)
109 if (routerboot_load_hs(base
+off
, len
) != 0)
118 char *routerboot_get_boardname(void)