Annotation of qemu/roms/SLOF/lib/libnvram/nvram.h, revision 1.1.1.1

1.1       root        1: /******************************************************************************
                      2:  * Copyright (c) 2004, 2008 IBM Corporation
                      3:  * All rights reserved.
                      4:  * This program and the accompanying materials
                      5:  * are made available under the terms of the BSD License
                      6:  * which accompanies this distribution, and is available at
                      7:  * http://www.opensource.org/licenses/bsd-license.php
                      8:  *
                      9:  * Contributors:
                     10:  *     IBM Corporation - initial implementation
                     11:  *****************************************************************************/
                     12: 
                     13: #ifndef __NVRAM_H
                     14: #define __NVRAM_H 1
                     15: 
                     16: /* data structures */
                     17: 
                     18: typedef struct {
                     19:        unsigned long addr;
                     20:        long len;
                     21: } partition_t;
                     22: 
                     23: /* macros */
                     24: 
                     25: #define DEBUG(x...)
                     26: // #define DEBUG(x...) printf(x);
                     27: 
                     28: #ifndef ALIGN
                     29: #define ALIGN(x, a) (((x) + ((a) - 1)) & ~((a) - 1))
                     30: #endif
                     31: 
                     32: #define NULL ((void *)0)
                     33: 
                     34: #define PARTITION_HEADER_SIZE 16
                     35: 
                     36: /* FIXME this should be done complete and in a more prominent place */
                     37: #define        __LITTLE_ENDIAN 1234
                     38: #define        __BIG_ENDIAN    4321
                     39: #ifdef __i386__
                     40: #define __BYTE_ORDER __LITTLE_ENDIAN
                     41: #else
                     42: #define __BYTE_ORDER __BIG_ENDIAN
                     43: #endif
                     44: #if __BYTE_ORDER == __BIG_ENDIAN
                     45: #define cpu_to_be64(x)  (x)
                     46: #define be64_to_cpu(x)  (x)
                     47: #define cpu_to_be32(x)  (x)
                     48: #define be32_to_cpu(x)  (x)
                     49: #else
                     50: #include <byteswap.h>
                     51: #define cpu_to_be64(x)  bswap_64(x)
                     52: #define be64_to_cpu(x)  bswap_64(x)
                     53: #define cpu_to_be32(x)  bswap_32(x)
                     54: #define be32_to_cpu(x)  bswap_32(x)
                     55: #endif
                     56: 
                     57: /* exported functions */
                     58: 
                     59: #define nvram_access_proto(type,name)                  \
                     60:        type nvram_read_##name(unsigned int offset);            \
                     61:        void nvram_write_##name(unsigned int offset, type data);
                     62: 
                     63: nvram_access_proto(uint8_t,  byte)
                     64: nvram_access_proto(uint16_t, word)
                     65: nvram_access_proto(uint32_t, dword)
                     66: nvram_access_proto(uint64_t, qword)
                     67: 
                     68: /* nvram.c */
                     69: 
                     70: char *get_nvram_buffer(int len);
                     71: void free_nvram_buffer(char *buffer);
                     72: int nvramlog_printf(const char* fmt, ...);
                     73: partition_t get_partition(unsigned int type, char *name);
                     74: void erase_nvram(int offset, int len);
                     75: int wipe_partition(partition_t partition, int header_only);
                     76: partition_t new_nvram_partition(int type, char *name, int len);
                     77: int increase_nvram_partition_size(partition_t partition, int newsize);
                     78: int clear_nvram_partition(partition_t part);
                     79: int delete_nvram_partition(partition_t part);
                     80: void reset_nvram(void);
                     81: void wipe_nvram(void);
                     82: void nvram_debug(void);
                     83: 
                     84: /* envvar.c */
                     85: char *get_env(partition_t part, char *envvar);
                     86: int add_env(partition_t part, char *envvar, char *value);
                     87: int del_env(partition_t part, char *envvar);
                     88: int set_env(partition_t part, char *envvar, char *value);
                     89: 
                     90: #endif

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.