Root/target/linux/adm5120/files/arch/mips/adm5120/prom/admboot.c

1/*
2 * ADMBoot specific prom routines
3 *
4 * Copyright (C) 2008 Gabor Juhos <juhosg@openwrt.org>
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License version 2 as published
8 * by the Free Software Foundation.
9 *
10 */
11
12#include <linux/types.h>
13#include <linux/init.h>
14#include <linux/errno.h>
15
16#include <asm/addrspace.h>
17#include <asm/byteorder.h>
18
19#include <asm/mach-adm5120/adm5120_defs.h>
20#include <prom/admboot.h>
21#include "prom_read.h"
22
23#define ADMBOOT_MAGIC_MAC_BASE 0x636D676D /* 'mgmc' */
24
25int __init admboot_get_mac_base(u32 offset, u32 len, u8 *mac)
26{
27    u8 *cfg;
28    int i;
29
30    cfg = (u8 *) KSEG1ADDR(ADM5120_SRAM0_BASE + offset);
31    for (i = 0; i < len; i += 4) {
32        u32 magic;
33
34        magic = prom_read_le32(cfg + i);
35        if (magic == ADMBOOT_MAGIC_MAC_BASE) {
36            int j;
37
38            for (j = 0; j < 6; j++)
39                mac[j] = cfg[i + 4 + j];
40
41            return 0;
42        }
43    }
44
45    return -ENXIO;
46}
47

Archive Download this file



interactive