Root/target/linux/adm5120/files/arch/mips/adm5120/prom/prom_read.h

1/*
2 * Generic prom definitions
3 *
4 * Copyright (C) 2007-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#ifndef _ADM5120_PROM_H_
13#define _ADM5120_PROM_H_
14
15/*
16 * Helper routines
17 */
18static inline u16 prom_read_le16(void *buf)
19{
20    u8 *p = buf;
21
22    return ((u16)p[0] + ((u16)p[1] << 8));
23}
24
25static inline u32 prom_read_le32(void *buf)
26{
27    u8 *p = buf;
28
29    return ((u32)p[0] + ((u32)p[1] << 8) + ((u32)p[2] << 16) +
30        ((u32)p[3] << 24));
31}
32
33static inline u16 prom_read_be16(void *buf)
34{
35    u8 *p = buf;
36
37    return (((u16)p[0] << 8) + (u16)p[1]);
38}
39
40static inline u32 prom_read_be32(void *buf)
41{
42    u8 *p = buf;
43
44    return (((u32)p[0] << 24) + ((u32)p[1] << 16) + ((u32)p[2] << 8) +
45        ((u32)p[3]));
46}
47
48#endif /* _ADM5120_PROM_H_ */
49
50
51

Archive Download this file



interactive