From b47e0c9f48378f4eef28115ad57862a5570c9d4b Mon Sep 17 00:00:00 2001 From: nbd Date: Mon, 27 Apr 2009 15:47:46 +0000 Subject: brcm47xx: remove 2.6.25 support git-svn-id: svn://svn.openwrt.org/openwrt/trunk@15448 3c298f89-4303-0410-b956-a3cf2f4a3e73 --- .../files-2.6.25/arch/mips/bcm47xx/cfe_env.c | 229 --------------------- .../files-2.6.25/arch/mips/bcm47xx/include/nvram.h | 37 ---- .../files-2.6.25/arch/mips/bcm47xx/nvram.c | 125 ----------- 3 files changed, 391 deletions(-) delete mode 100644 target/linux/brcm47xx/files-2.6.25/arch/mips/bcm47xx/cfe_env.c delete mode 100644 target/linux/brcm47xx/files-2.6.25/arch/mips/bcm47xx/include/nvram.h delete mode 100644 target/linux/brcm47xx/files-2.6.25/arch/mips/bcm47xx/nvram.c (limited to 'target/linux/brcm47xx/files-2.6.25/arch/mips/bcm47xx') diff --git a/target/linux/brcm47xx/files-2.6.25/arch/mips/bcm47xx/cfe_env.c b/target/linux/brcm47xx/files-2.6.25/arch/mips/bcm47xx/cfe_env.c deleted file mode 100644 index c1d5eeef5..000000000 --- a/target/linux/brcm47xx/files-2.6.25/arch/mips/bcm47xx/cfe_env.c +++ /dev/null @@ -1,229 +0,0 @@ -/* - * CFE environment variable access - * - * Copyright 2001-2003, Broadcom Corporation - * Copyright 2006, Felix Fietkau - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - */ - -#include -#include -#include -#include -#include -#include - -#define NVRAM_SIZE (0x1ff0) -static char _nvdata[NVRAM_SIZE]; -static char _valuestr[256]; - -/* - * TLV types. These codes are used in the "type-length-value" - * encoding of the items stored in the NVRAM device (flash or EEPROM) - * - * The layout of the flash/nvram is as follows: - * - * - * - * The type code of "ENV_TLV_TYPE_END" marks the end of the list. - * The "length" field marks the length of the data section, not - * including the type and length fields. - * - * Environment variables are stored as follows: - * - * = - * - * If bit 0 (low bit) is set, the length is an 8-bit value. - * If bit 0 (low bit) is clear, the length is a 16-bit value - * - * Bit 7 set indicates "user" TLVs. In this case, bit 0 still - * indicates the size of the length field. - * - * Flags are from the constants below: - * - */ -#define ENV_LENGTH_16BITS 0x00 /* for low bit */ -#define ENV_LENGTH_8BITS 0x01 - -#define ENV_TYPE_USER 0x80 - -#define ENV_CODE_SYS(n,l) (((n)<<1)|(l)) -#define ENV_CODE_USER(n,l) ((((n)<<1)|(l)) | ENV_TYPE_USER) - -/* - * The actual TLV types we support - */ - -#define ENV_TLV_TYPE_END 0x00 -#define ENV_TLV_TYPE_ENV ENV_CODE_SYS(0,ENV_LENGTH_8BITS) - -/* - * Environment variable flags - */ - -#define ENV_FLG_NORMAL 0x00 /* normal read/write */ -#define ENV_FLG_BUILTIN 0x01 /* builtin - not stored in flash */ -#define ENV_FLG_READONLY 0x02 /* read-only - cannot be changed */ - -#define ENV_FLG_MASK 0xFF /* mask of attributes we keep */ -#define ENV_FLG_ADMIN 0x100 /* lets us internally override permissions */ - - -/* ********************************************************************* - * _nvram_read(buffer,offset,length) - * - * Read data from the NVRAM device - * - * Input parameters: - * buffer - destination buffer - * offset - offset of data to read - * length - number of bytes to read - * - * Return value: - * number of bytes read, or <0 if error occured - ********************************************************************* */ -static int -_nvram_read(unsigned char *nv_buf, unsigned char *buffer, int offset, int length) -{ - int i; - if (offset > NVRAM_SIZE) - return -1; - - for ( i = 0; i < length; i++) { - buffer[i] = ((volatile unsigned char*)nv_buf)[offset + i]; - } - return length; -} - - -static char* -_strnchr(const char *dest,int c,size_t cnt) -{ - while (*dest && (cnt > 0)) { - if (*dest == c) return (char *) dest; - dest++; - cnt--; - } - return NULL; -} - - - -/* - * Core support API: Externally visible. - */ - -/* - * Get the value of an NVRAM variable - * @param name name of variable to get - * @return value of variable or NULL if undefined - */ - -char* -cfe_env_get(unsigned char *nv_buf, char* name) -{ - int size; - unsigned char *buffer; - unsigned char *ptr; - unsigned char *envval; - unsigned int reclen; - unsigned int rectype; - int offset; - int flg; - - if (!strcmp(name, "nvram_type")) - return "cfe"; - - size = NVRAM_SIZE; - buffer = &_nvdata[0]; - - ptr = buffer; - offset = 0; - - /* Read the record type and length */ - if (_nvram_read(nv_buf, ptr,offset,1) != 1) { - goto error; - } - - while ((*ptr != ENV_TLV_TYPE_END) && (size > 1)) { - - /* Adjust pointer for TLV type */ - rectype = *(ptr); - offset++; - size--; - - /* - * Read the length. It can be either 1 or 2 bytes - * depending on the code - */ - if (rectype & ENV_LENGTH_8BITS) { - /* Read the record type and length - 8 bits */ - if (_nvram_read(nv_buf, ptr,offset,1) != 1) { - goto error; - } - reclen = *(ptr); - size--; - offset++; - } - else { - /* Read the record type and length - 16 bits, MSB first */ - if (_nvram_read(nv_buf, ptr,offset,2) != 2) { - goto error; - } - reclen = (((unsigned int) *(ptr)) << 8) + (unsigned int) *(ptr+1); - size -= 2; - offset += 2; - } - - if (reclen > size) - break; /* should not happen, bad NVRAM */ - - switch (rectype) { - case ENV_TLV_TYPE_ENV: - /* Read the TLV data */ - if (_nvram_read(nv_buf, ptr,offset,reclen) != reclen) - goto error; - flg = *ptr++; - envval = (unsigned char *) _strnchr(ptr,'=',(reclen-1)); - if (envval) { - *envval++ = '\0'; - memcpy(_valuestr,envval,(reclen-1)-(envval-ptr)); - _valuestr[(reclen-1)-(envval-ptr)] = '\0'; -#if 0 - printk(KERN_INFO "NVRAM:%s=%s\n", ptr, _valuestr); -#endif - if(!strcmp(ptr, name)){ - return _valuestr; - } - if((strlen(ptr) > 1) && !strcmp(&ptr[1], name)) - return _valuestr; - } - break; - - default: - /* Unknown TLV type, skip it. */ - break; - } - - /* - * Advance to next TLV - */ - - size -= (int)reclen; - offset += reclen; - - /* Read the next record type */ - ptr = buffer; - if (_nvram_read(nv_buf, ptr,offset,1) != 1) - goto error; - } - -error: - return NULL; - -} - diff --git a/target/linux/brcm47xx/files-2.6.25/arch/mips/bcm47xx/include/nvram.h b/target/linux/brcm47xx/files-2.6.25/arch/mips/bcm47xx/include/nvram.h deleted file mode 100644 index 6bb18e8e5..000000000 --- a/target/linux/brcm47xx/files-2.6.25/arch/mips/bcm47xx/include/nvram.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (C) 2006 Felix Fietkau - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - */ - -#ifndef __NVRAM_H -#define __NVRAM_H - -struct nvram_header { - u32 magic; - u32 len; - u32 crc_ver_init; /* 0:7 crc, 8:15 ver, 16:31 sdram_init */ - u32 config_refresh; /* 0:15 sdram_config, 16:31 sdram_refresh */ - u32 config_ncdl; /* ncdl values for memc */ -}; - -struct nvram_tuple { - char *name; - char *value; - struct nvram_tuple *next; -}; - -#define NVRAM_HEADER 0x48534C46 /* 'FLSH' */ -#define NVRAM_VERSION 1 -#define NVRAM_HEADER_SIZE 20 -#define NVRAM_SPACE 0x8000 - -#define NVRAM_MAX_VALUE_LEN 255 -#define NVRAM_MAX_PARAM_LEN 64 - -char *nvram_get(const char *name); - -#endif diff --git a/target/linux/brcm47xx/files-2.6.25/arch/mips/bcm47xx/nvram.c b/target/linux/brcm47xx/files-2.6.25/arch/mips/bcm47xx/nvram.c deleted file mode 100644 index 3f32ad9d6..000000000 --- a/target/linux/brcm47xx/files-2.6.25/arch/mips/bcm47xx/nvram.c +++ /dev/null @@ -1,125 +0,0 @@ -/* - * BCM947xx nvram variable access - * - * Copyright 2005, Broadcom Corporation - * Copyright 2006, Felix Fietkau - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#define MB * 1048576 -extern struct ssb_bus ssb; - -static char nvram_buf[NVRAM_SPACE]; -static int cfe_env; -extern char *cfe_env_get(char *nv_buf, const char *name); - -/* Probe for NVRAM header */ -static void __init early_nvram_init(void) -{ - struct ssb_mipscore *mcore = &ssb.mipscore; - struct nvram_header *header; - int i; - u32 base, lim, off; - u32 *src, *dst; - - base = mcore->flash_window; - lim = mcore->flash_window_size; - cfe_env = 0; - - - /* XXX: hack for supporting the CFE environment stuff on WGT634U */ - if (lim >= 8 MB) { - src = (u32 *) KSEG1ADDR(base + 8 MB - 0x2000); - dst = (u32 *) nvram_buf; - - if ((*src & 0xff00ff) == 0x000001) { - printk("early_nvram_init: WGT634U NVRAM found.\n"); - - for (i = 0; i < 0x1ff0; i++) { - if (*src == 0xFFFFFFFF) - break; - *dst++ = *src++; - } - cfe_env = 1; - return; - } - } - - off = 0x20000; - while (off <= lim) { - /* Windowed flash access */ - header = (struct nvram_header *) KSEG1ADDR(base + off - NVRAM_SPACE); - if (header->magic == NVRAM_HEADER) - goto found; - off <<= 1; - } - - /* Try embedded NVRAM at 4 KB and 1 KB as last resorts */ - header = (struct nvram_header *) KSEG1ADDR(base + 4096); - if (header->magic == NVRAM_HEADER) - goto found; - - header = (struct nvram_header *) KSEG1ADDR(base + 1024); - if (header->magic == NVRAM_HEADER) - goto found; - - return; - -found: - src = (u32 *) header; - dst = (u32 *) nvram_buf; - for (i = 0; i < sizeof(struct nvram_header); i += 4) - *dst++ = *src++; - for (; i < header->len && i < NVRAM_SPACE; i += 4) - *dst++ = le32_to_cpu(*src++); -} - -char *nvram_get(const char *name) -{ - char *var, *value, *end, *eq; - - if (!name) - return NULL; - - if (!nvram_buf[0]) - early_nvram_init(); - - if (cfe_env) - return cfe_env_get(nvram_buf, name); - - /* Look for name=value and return value */ - var = &nvram_buf[sizeof(struct nvram_header)]; - end = nvram_buf + sizeof(nvram_buf) - 2; - end[0] = end[1] = '\0'; - for (; *var; var = value + strlen(value) + 1) { - if (!(eq = strchr(var, '='))) - break; - value = eq + 1; - if ((eq - var) == strlen(name) && strncmp(var, name, (eq - var)) == 0) - return value; - } - - return NULL; -} - -EXPORT_SYMBOL(nvram_get); -- cgit v1.2.3