aboutsummaryrefslogtreecommitdiffstats
path: root/tools/padjffs2/src/padjffs2.c
blob: 58d99140d926741a789310174514ad3db318e926 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
/*
 * Copyright (C) 2011 Gabor Juhos <juhosg@openwrt.org>
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License version 2 as published
 * by the Free Software Foundation.
 *
 */

#include <errno.h>
#include <fcntl.h>
#include <libgen.h>
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>

static char *progname;
static unsigned char eof_mark[4] = {0xde, 0xad, 0xc0, 0xde};

#define ERR(fmt, ...) do { \
	fflush(0); \
	fprintf(stderr, "[%s] *** error: " fmt "\n", \
			progname, ## __VA_ARGS__ ); \
} while (0)

#define ERRS(fmt, ...) do { \
	int save = errno; \
	fflush(0); \
	fprintf(stderr, "[%s] *** error: " fmt ", %s\n", \
			progname, ## __VA_ARGS__, strerror(save)); \
} while (0)

#define BUF_SIZE	(64 * 1024)
#define ALIGN(_x,_y)	(((_x) + ((_y) - 1)) & ~((_y) - 1))

static int pad_image(char *name, uint32_t pad_mask)
{
	char *buf;
	int fd;
	ssize_t in_len;
	ssize_t out_len;
	int ret = -1;

	buf = malloc(BUF_SIZE);
	if (!buf) {
		ERR("No memory for buffer");
		goto out;
	}

	fd = open(name, O_RDWR);
	if (fd < 0) {
		ERRS("Unable to open %s", name);
		goto free_buf;
	}

	in_len = lseek(fd, 0, SEEK_END);
	if (in_len < 0)
		goto close;

	memset(buf, '\xff', BUF_SIZE);

	out_len = in_len;
	while (pad_mask) {
		uint32_t mask;
		ssize_t t;
		int i;

		for (i = 10; i < 32; i++) {
			mask = 1UL << i;
			if (pad_mask & mask)
				break;
		}

		in_len = ALIGN(in_len, mask);

		for (i = 10; i < 32; i++) {
			mask = 1UL << i;
			if ((in_len & (mask - 1)) == 0)
				pad_mask &= ~mask;
		}

		printf("padding image to %08x\n", (unsigned int) in_len);

		while (out_len < in_len) {
			ssize_t len;

			len = in_len - out_len;
			if (len > BUF_SIZE)
				len = BUF_SIZE;

			t = write(fd, buf, len);
			if (t != len) {
				ERRS("Unable to write to %s", name);
				goto close;
			}

			out_len += len;
		}

		/* write out the JFFS end-of-filesystem marker */
		t = write(fd, eof_mark, 4);
		if (t != 4) {
			ERRS("Unable to write to %s", name);
			goto close;
		}
		out_len += 4;
	}

	ret = 0;

close:
	close(fd);
free_buf:
	free(buf);
out:
	return ret;
}

int main(int argc, char* argv[])
{
	uint32_t pad_mask;
	int ret = EXIT_FAILURE;
	int err;
	int i;

	progname = basename(argv[0]);

	if (argc < 2) {
		fprintf(stderr,
			"Usage: %s file [pad0] [pad1] [padN]\n",
			progname);
		goto out;
	}

	pad_mask = 0;
	for (i = 2; i < argc; i++)
		pad_mask |= strtoul(argv[i], NULL, 0) * 1024;

	if (pad_mask == 0)
		pad_mask = (4 * 1024) | (8 * 1024) | (64 * 1024) |
			   (128 * 1024);

	err = pad_image(argv[1], pad_mask);
	if (err)
		goto out;

	ret = EXIT_SUCCESS;

out:
	return ret;
}
{ color: #336699; font-style: italic } /* Name.Label */ .highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */ .highlight .py { color: #336699; font-weight: bold } /* Name.Property */ .highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */ .highlight .nv { color: #336699 } /* Name.Variable */ .highlight .ow { color: #008800 } /* Operator.Word */ .highlight .w { color: #bbbbbb } /* Text.Whitespace */ .highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */ .highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */ .highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */ .highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */ .highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */ .highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */ .highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */ .highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */ .highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
--- a/tn7atm.c
+++ b/tn7atm.c
@@ -95,6 +95,146 @@
 MODULE_LICENSE("GPL");
 MODULE_DESCRIPTION ("Tnetd73xx ATM Device Driver");
 MODULE_AUTHOR ("Zhicheng Tang");
+
+int mp_sar_ipacemax = -1;
+module_param_named(ipacemax, mp_sar_ipacemax, int, 0);
+MODULE_PARM_DESC(ipacemax, "Interrupt pacing");
+
+char *mp_macc = NULL;
+module_param_named(macc, mp_macc, charp, 0);
+MODULE_PARM_DESC(macc, "MAC address");
+
+int mp_dsp_noboost = -1;
+module_param_named(dsp_noboost, mp_dsp_noboost, int, 0);
+MODULE_PARM_DESC(dsp_noboost, "Suppress DSP frequency boost");
+
+int mp_dsp_freq = -1;
+module_param_named(dsp_freq, mp_dsp_freq, int, 0);
+MODULE_PARM_DESC(dsp_freq, "Frequency to boost the DSP to");
+
+char *mp_featctl0 = NULL;
+module_param_named(featctl0, mp_featctl0, charp, 0);
+MODULE_PARM_DESC(featctl0, "DSL feature control 0");
+
+char *mp_featctl1 = NULL;
+module_param_named(featctl1, mp_featctl1, charp, 0);
+MODULE_PARM_DESC(featctl1, "DSL feature control 1");
+
+char *mp_phyctl0 = NULL;
+module_param_named(phyctl0, mp_phyctl0, charp, 0);
+MODULE_PARM_DESC(phyctl0, "DSL PHY control 0");
+
+char *mp_phyctl1 = NULL;
+module_param_named(phyctl1, mp_phyctl1, charp, 0);
+MODULE_PARM_DESC(phyctl1, "DSL PHY control 1");
+
+int mp_turbodsl = -1;
+module_param_named(turbodsl, mp_turbodsl, int, 0);
+MODULE_PARM_DESC(turbodsl, "Enable TurboDSL");
+
+int mp_sar_rxbuf = -1;
+module_param_named(sar_rxbuf, mp_sar_rxbuf, int, 0);
+MODULE_PARM_DESC(sar_rxbuf, "SAR RxBuf size");
+
+int mp_sar_rxmax = -1;
+module_param_named(sar_rxmax, mp_sar_rxmax, int, 0);
+MODULE_PARM_DESC(sar_rxmax, "SAR RxMax size");
+
+int mp_sar_txbuf = -1;
+module_param_named(sar_txbuf, mp_sar_txbuf, int, 0);
+MODULE_PARM_DESC(sar_txbuf, "SAR TxBuf size");
+
+int mp_sar_txmax = -1;
+module_param_named(sar_txmax, mp_sar_txmax, int, 0);
+MODULE_PARM_DESC(sar_txmax, "SAR TxMax size");
+
+char *mp_modulation = NULL;
+module_param_named(modulation, mp_modulation, charp, 0);
+MODULE_PARM_DESC(modulation, "Modulation");
+
+int mp_fine_gain_control = -1;
+module_param_named(fine_gain_control, mp_fine_gain_control, int, 0);
+MODULE_PARM_DESC(fine_gain_control, "Fine gain control");
+
+int mp_fine_gain_value = -1;
+module_param_named(fine_gain_value, mp_fine_gain_value, int, 0);
+MODULE_PARM_DESC(fine_gain_value, "Fine gain value");
+
+int mp_enable_margin_retrain = -1;
+module_param_named(enable_margin_retrain, mp_enable_margin_retrain, int, 0);
+MODULE_PARM_DESC(enable_margin_retrain, "Enable margin retrain");
+
+int mp_margin_threshold = -1;
+module_param_named(margin_threshold, mp_margin_threshold, int, 0);
+MODULE_PARM_DESC(margin_threshold, "Margin retrain treshold");
+
+int mp_enable_rate_adapt = -1;
+module_param_named(enable_rate_adapt, mp_enable_rate_adapt, int, 0);
+MODULE_PARM_DESC(enable_rate_adapt, "Enable rate adaption");
+
+int mp_powercutback = -1;
+module_param_named(powercutback, mp_powercutback, int, 0);
+MODULE_PARM_DESC(powercutback, "Enable / disable powercutback");
+
+int mp_trellis = -1;
+module_param_named(trellis, mp_trellis, int, 0);
+MODULE_PARM_DESC(trellis, "Enable / disable trellis coding");
+
+int mp_bitswap = -1;
+module_param_named(bitswap, mp_bitswap, int, 0);
+MODULE_PARM_DESC(bitswap, "Enable / disable bitswap");
+
+int mp_maximum_bits_per_carrier = -1;
+module_param_named(maximum_bits_per_carrier, mp_maximum_bits_per_carrier, int, 0);
+MODULE_PARM_DESC(maximum_bits_per_carrier, "Maximum bits per carrier");
+
+int mp_maximum_interleave_depth = -1;
+module_param_named(maximum_interleave_depth, mp_maximum_interleave_depth, int, 0);
+MODULE_PARM_DESC(maximum_interleave_depth, "Maximum interleave depth");
+
+int mp_pair_selection = -1;
+module_param_named(pair_selection, mp_pair_selection, int, 0);
+MODULE_PARM_DESC(pair_selection, "Pair selection");
+
+int mp_dgas_polarity = -1;
+module_param_named(dgas_polarity, mp_dgas_polarity, int, 0);
+MODULE_PARM_DESC(dgas_polarity, "DGAS polarity");
+
+int mp_los_alarm = -1;
+module_param_named(los_alarm, mp_los_alarm, int, 0);
+MODULE_PARM_DESC(los_alarm, "LOS alarm");
+
+char *mp_eoc_vendor_id = NULL;
+module_param_named(eoc_vendor_id, mp_eoc_vendor_id, charp, 0);
+MODULE_PARM_DESC(eoc_vendor_id, "EOC vendor id");
+
+int mp_eoc_vendor_revision = -1;
+module_param_named(eoc_vendor_revision, mp_eoc_vendor_revision, int, 0);
+MODULE_PARM_DESC(eoc_vendor_revision, "EOC vendor revision");
+
+char *mp_eoc_vendor_serialnum = NULL;
+module_param_named(eoc_vendor_serialnum, mp_eoc_vendor_serialnum, charp, 0);
+MODULE_PARM_DESC(eoc_vendor_serialnum, "EOC vendor serial number");
+
+char *mp_invntry_vernum = NULL;
+module_param_named(invntry_vernum, mp_invntry_vernum, charp, 0);
+MODULE_PARM_DESC(invntry_vernum, "Inventory revision number");
+
+int mp_dsl_bit_tmode = -1;
+module_param_named(dsl_bit_tmode, mp_dsl_bit_tmode, int, 0);
+MODULE_PARM_DESC(dsl_bit_tmode, "DSL bit training mode");
+
+int mp_high_precision = -1;
+module_param_named(high_precision, mp_high_precision, int, 0);
+MODULE_PARM_DESC(high_precision, "High precision");
+
+int mp_autopvc_enable = -1;
+module_param_named(autopvc_enable, mp_autopvc_enable, int, 0);
+MODULE_PARM_DESC(autopvc_enable, "Enable / disable automatic PVC");
+
+int mp_oam_lb_timeout = -1;
+module_param_named(oam_lb_timeout, mp_oam_lb_timeout, int, 0);
+MODULE_PARM_DESC(oam_lb_timeout, "OAM LB timeout");
 #endif
 
 #ifndef TRUE
@@ -728,9 +868,9 @@ static int __init tn7atm_irq_request (st
    * interrupt pacing
    */
   ptr = prom_getenv ("sar_ipacemax");
-  if (ptr)
+  if (ptr || mp_sar_ipacemax != -1)
   {
-    def_sar_inter_pace = os_atoi (ptr);
+    def_sar_inter_pace = mp_sar_ipacemax == -1 ? os_atoi (ptr) : mp_sar_ipacemax;
   }
   /* avalanche_request_pacing (priv->sar_irq, ATM_SAR_INT_PACING_BLOCK_NUM,
                             def_sar_inter_pace); */
@@ -878,9 +1018,18 @@ static int __init tn7atm_get_ESI (struct
 {
   int i;
   char esi_addr[ESI_LEN] = { 0x00, 0x00, 0x11, 0x22, 0x33, 0x44 };
-  char *esiaddr_str = NULL;
+  char *esiaddr_str = mp_macc;
 
-  esiaddr_str = prom_getenv ("macc");
+  if (esiaddr_str == NULL)
+    esiaddr_str = prom_getenv ("macdsl");
+  if (esiaddr_str == NULL)
+    esiaddr_str = prom_getenv ("macc");
+  if (esiaddr_str == NULL)
+    esiaddr_str = prom_getenv ("HWA_1");
+  if (esiaddr_str == NULL)
+    esiaddr_str = prom_getenv ("macb");
+  if (esiaddr_str == NULL)
+    esiaddr_str = prom_getenv ("maca");
 
   if (!esiaddr_str)
   {
@@ -2139,15 +2288,15 @@ static int tn7atm_autoDetectDspBoost (vo
 //UR8_MERGE_END   CQ10450*
 
   cp = prom_getenv ("dsp_noboost");
-  if (cp)
+  if (cp || mp_dsp_noboost != -1)
   {
-    dsp_noboost = os_atoi (cp);
+    dsp_noboost = mp_dsp_noboost == -1 ? os_atoi (cp) : mp_dsp_noboost;
   }
 
   cp = (char *) prom_getenv ("dsp_freq");
-  if (cp)
+  if (cp || mp_dsp_freq != -1)
   {
-    dspfreq = os_atoi (cp);
+    dspfreq = mp_dsp_freq == -1 ? os_atoi (cp) : mp_dsp_freq;
     if (dspfreq == 250)
     {
       boostDsp = 1;
@@ -2396,15 +2545,17 @@ static int __init tn7atm_init (struct at
   // Inter-Op DSL phy Control
   // Note the setting of _dsl_Feature_0 and _dsl_Feature_1 must before
   // dslhal_api_dslStartup (in tn7dsl_init()).
-  if ((ptr = prom_getenv ("DSL_FEATURE_CNTL_0")) != NULL)
+  if ((ptr = prom_getenv ("DSL_FEATURE_CNTL_0")) != NULL || mp_featctl0 != NULL)
   {
-    _dsl_Feature_0 = os_atoih (ptr);
+    if (mp_featctl0 != NULL) ptr = mp_featctl0;
+    _dsl_Feature_0 = os_atoh (ptr);
     _dsl_Feature_0_defined = 1;
   }
 
-  if ((ptr = prom_getenv ("DSL_FEATURE_CNTL_1")) != NULL)
+  if ((ptr = prom_getenv ("DSL_FEATURE_CNTL_1")) != NULL || mp_featctl1 != NULL)
   {
-    _dsl_Feature_1 = os_atoih (ptr);
+    if (mp_featctl1 != NULL) ptr = mp_featctl1;
+    _dsl_Feature_1 = os_atoh (ptr);
     _dsl_Feature_1_defined = 1;
   }
 
@@ -2412,15 +2563,17 @@ static int __init tn7atm_init (struct at
   // DSL phy Feature Control
   // Note the setting of _dsl_PhyControl_0 and _dsl_PhyControl_1 must before
   // dslhal_api_dslStartup (in tn7dsl_init()).
-  if ((ptr = prom_getenv ("DSL_PHY_CNTL_0")) != NULL)
+  if ((ptr = prom_getenv ("DSL_PHY_CNTL_0")) != NULL || mp_phyctl0 != NULL)
   {
-    _dsl_PhyControl_0 = os_atoih (ptr);
+    if (mp_phyctl0 != NULL) ptr = mp_phyctl0;
+    _dsl_PhyControl_0 = os_atoh (ptr);
     _dsl_PhyControl_0_defined = 1;
   }
 
-  if ((ptr = prom_getenv ("DSL_PHY_CNTL_1")) != NULL)
+  if ((ptr = prom_getenv ("DSL_PHY_CNTL_1")) != NULL || mp_phyctl1 != NULL)
   {
-    _dsl_PhyControl_1 = os_atoih (ptr);
+    if (mp_phyctl1 != NULL) ptr = mp_phyctl1;
+    _dsl_PhyControl_1 = os_atoh (ptr);
     _dsl_PhyControl_1_defined = 1;
   }
 
@@ -2440,12 +2593,12 @@ static int __init tn7atm_init (struct at
   // read config for turbo dsl
    
   ptr = prom_getenv ("TurboDSL");
-  if (ptr)
+  if (ptr || mp_turbodsl != -1)
   {
     #if 1 //[KT]
     bTurboDsl = os_atoi (ptr);
     #else
-    priv->bTurboDsl = os_atoi (ptr);
+    priv->bTurboDsl = mp_turbodsl == -1 ? os_atoi (ptr) : mp_turbodsl;
     #endif
   }
    else
@@ -2459,33 +2612,33 @@ static int __init tn7atm_init (struct at
   priv->sarRxBuf = RX_BUFFER_NUM;
   ptr = NULL;
   ptr = prom_getenv ("SarRxBuf");
-  if (ptr)
+  if (ptr || mp_sar_rxbuf != -1)
   {
-    priv->sarRxBuf = os_atoi (ptr);
+    priv->sarRxBuf = mp_sar_rxbuf == -1 ? os_atoi (ptr) : mp_sar_rxbuf;
   }
 
   priv->sarRxMax = RX_SERVICE_MAX;
   ptr = NULL;
   ptr = prom_getenv ("SarRxMax");
-  if (ptr)
+  if (ptr || mp_sar_rxmax != -1)
   {
-    priv->sarRxMax = os_atoi (ptr);
+    priv->sarRxMax = mp_sar_rxmax == -1 ? os_atoi (ptr) : mp_sar_rxmax;
   }
 
   priv->sarTxBuf = TX_BUFFER_NUM;
   ptr = NULL;
   ptr = prom_getenv ("SarTxBuf");
-  if (ptr)
+  if (ptr || mp_sar_txbuf != -1)
   {
-    priv->sarTxBuf = os_atoi (ptr);
+    priv->sarTxBuf = mp_sar_txbuf == -1 ? os_atoi (ptr) : mp_sar_txbuf;
   }
 
   priv->sarTxMax = TX_SERVICE_MAX;
   ptr = NULL;
   ptr = prom_getenv ("SarTxMax");
-  if (ptr)
+  if (ptr || mp_sar_txmax != -1)
   {
-    priv->sarTxMax = os_atoi (ptr);
+    priv->sarTxMax = mp_sar_txmax == -1 ? os_atoi (ptr) : mp_sar_txmax;
   }
 
 #ifdef AR7_EFM
--- a/tn7dsl.c
+++ b/tn7dsl.c
@@ -148,6 +148,27 @@
 #define NEW_TRAINING_VAL_T1413  128
 #define NEW_TRAINING_VAL_MMODE  255
 
+extern char *mp_modulation;
+extern int mp_fine_gain_control;
+extern int mp_fine_gain_value;
+extern int mp_enable_margin_retrain;
+extern int mp_margin_threshold;
+extern int mp_enable_rate_adapt;
+extern int mp_powercutback;
+extern int mp_trellis;
+extern int mp_bitswap;
+extern int mp_maximum_bits_per_carrier;
+extern int mp_maximum_interleave_depth;
+extern int mp_pair_selection;
+extern int mp_dgas_polarity;
+extern int mp_los_alarm;
+extern char *mp_eoc_vendor_id;
+extern int mp_eoc_vendor_revision;
+extern char *mp_eoc_vendor_serialnum;
+extern char *mp_invntry_vernum;
+extern int mp_dsl_bit_tmode;
+extern int mp_high_precision;
+
 int testflag1 = 0;
 extern int  __guDbgLevel;
 extern sar_stat_t sarStat;
@@ -2933,24 +2954,24 @@ static int tn7dsl_set_dsl(void)
                                 (unsigned char *) &oamFeature, 4);
 	
   ptr = prom_getenv("DSL_FEATURE_CNTL_0"); 
-  if(!ptr)
-    prom_setenv("DSL_FEATURE_CNTL_0", "0x00004000");
+  //if(!ptr)
+    //prom_setenv("DSL_FEATURE_CNTL_0", "0x00004000");
 
   ptr = prom_getenv("DSL_FEATURE_CNTL_1"); 
-  if(!ptr)   
-	prom_setenv("DSL_FEATURE_CNTL_1", "0x00000000");
+  //if(!ptr)   
+	//prom_setenv("DSL_FEATURE_CNTL_1", "0x00000000");
 
   ptr = prom_getenv("DSL_PHY_CNTL_0"); 
-  if(!ptr)   
-	prom_setenv("DSL_PHY_CNTL_0", "0x00000400");
+  //if(!ptr)   
+	//prom_setenv("DSL_PHY_CNTL_0", "0x00000400");
 	
   ptr = prom_getenv("enable_margin_retrain"); 
-  if(!ptr)   
-	prom_setenv("enable_margin_retrain", "0");
+  //if(!ptr)   
+	//prom_setenv("enable_margin_retrain", "0");
 	
   ptr = prom_getenv("modulation");
-  if(!ptr)
-    prom_setenv("modulation", "0xbf");
+  //if(!ptr)
+    //prom_setenv("modulation", "0xbf");
   
 #define EOC_VENDOR_ID "4200534153000000"
 #define EOC_VENDOR_REVISION "FW370090708b1_55"
@@ -2959,25 +2980,25 @@ static int tn7dsl_set_dsl(void)
   ptr = prom_getenv("eoc_vendor_id");
   if(!ptr || strcmp(ptr,EOC_VENDOR_ID) != 0 || strlen(ptr) != strlen(EOC_VENDOR_ID))
   {
-      if(ptr)      	
-         prom_unsetenv("eoc_vendor_id");
-      prom_setenv("eoc_vendor_id",EOC_VENDOR_ID);
+      //if(ptr)      	
+         //prom_unsetenv("eoc_vendor_id");
+      //prom_setenv("eoc_vendor_id",EOC_VENDOR_ID);
   }
       
   ptr = prom_getenv("eoc_vendor_revision");
   if(!ptr || strcmp(ptr,EOC_VENDOR_REVISION) != 0 || strlen(ptr) != strlen(EOC_VENDOR_REVISION))
   {  
-      if(ptr)      	
-         prom_unsetenv("eoc_vendor_revision");
-      prom_setenv("eoc_vendor_revision",EOC_VENDOR_REVISION);
+      //if(ptr)      	
+         //prom_unsetenv("eoc_vendor_revision");
+      //prom_setenv("eoc_vendor_revision",EOC_VENDOR_REVISION);
   }
       
   ptr = prom_getenv("eoc_vendor_serialnum");
   if(!ptr || strcmp(ptr,EOC_VENDOR_SERIALNUM) != 0 || strlen(ptr) != strlen(EOC_VENDOR_SERIALNUM))
   {
-      if(ptr)      	
-         prom_unsetenv("eoc_vendor_serialnum");
-      prom_setenv("eoc_vendor_serialnum",EOC_VENDOR_SERIALNUM);
+      //if(ptr)      	
+        // prom_unsetenv("eoc_vendor_serialnum");
+      //prom_setenv("eoc_vendor_serialnum",EOC_VENDOR_SERIALNUM);
   }
 
   /* Do only if we are in the new Base PSP 7.4.*/
@@ -2994,92 +3015,88 @@ static int tn7dsl_set_dsl(void)
              we clear the modulation environment variable, as this could potentially
              not have the same meaning in the new mode.
           */
-         prom_unsetenv("modulation");
-         prom_setenv("DSL_UPG_DONE", "1");
+         //prom_unsetenv("modulation");
+         //prom_setenv("DSL_UPG_DONE", "1");
       }
   }
   #endif
 
   // modulation
   ptr = prom_getenv("modulation");
-  if (ptr)
+  if (ptr || mp_modulation != NULL)
   {
-    tn7dsl_set_modulation(ptr, FALSE);
+    tn7dsl_set_modulation(mp_modulation == NULL ? ptr : mp_modulation, FALSE);
   }
 
   // Fine Gains
   ptr = prom_getenv("fine_gain_control");
-  if (ptr)
+  if (ptr || mp_fine_gain_control != -1)
   {
-    value = os_atoi(ptr);
+    value = mp_fine_gain_control == -1 ? os_atoi(ptr) : mp_fine_gain_control;
     tn7dsl_ctrl_fineGain(value);
   }
   ptr = NULL;
   ptr = prom_getenv("fine_gain_value");
-  if(ptr)
-    tn7dsl_set_fineGainValue(os_atoh(ptr));
+  if(ptr || mp_fine_gain_value != -1)
+    tn7dsl_set_fineGainValue(mp_fine_gain_value == -1 ? os_atoh(ptr) : mp_fine_gain_value);
 
   // margin retrain
   ptr = NULL;
   ptr = prom_getenv("enable_margin_retrain");
-  if(ptr)
+  value = mp_enable_margin_retrain == -1 ? (ptr ? os_atoi(ptr) : 0) : mp_enable_margin_retrain;
+
+  if (value == 1)
   {
-    value = os_atoi(ptr);
-    if(value == 1)
+    dslhal_api_setMarginMonitorFlags(pIhw, 0, 1);
+    bMarginRetrainEnable = 1;
+    //printk("enable showtime margin monitor.\n");
+
+    ptr = NULL;
+    ptr = prom_getenv("margin_threshold");
+    value = mp_margin_threshold == -1 ? (ptr ? os_atoi(ptr) : 0) : mp_margin_threshold;
+
+    if(value >= 0)
     {
-      dslhal_api_setMarginMonitorFlags(pIhw, 0, 1);
-      bMarginRetrainEnable = 1;
-      //printk("enable showtime margin monitor.\n");
-      ptr = NULL;
-      ptr = prom_getenv("margin_threshold");
-      if(ptr)
-      {
-        value = os_atoi(ptr);
-        //printk("Set margin threshold to %d x 0.5 db\n",value);
-        if(value >= 0)
-        {
-          dslhal_api_setMarginThreshold(pIhw, value);
-          bMarginThConfig=1;
-        }
-      }
+      dslhal_api_setMarginThreshold(pIhw, value);
+      bMarginThConfig=1;
     }
   }
 
   // rate adapt
   ptr = NULL;
   ptr = prom_getenv("enable_rate_adapt");
-  if(ptr)
+  if(ptr || mp_enable_rate_adapt != -1)
   {
-    dslhal_api_setRateAdaptFlag(pIhw, os_atoi(ptr));
+    dslhal_api_setRateAdaptFlag(pIhw, mp_enable_rate_adapt == -1 ? os_atoi(ptr) : mp_enable_rate_adapt);
   }
 
   // set powercutback
   ptr = NULL;
   ptr = prom_getenv("powercutback");
-  if(ptr)
+  if(ptr || mp_powercutback != -1)
   {
-    dslhal_advcfg_onOffPcb(pIhw, os_atoi(ptr));
+    dslhal_advcfg_onOffPcb(pIhw, mp_powercutback == -1 ? os_atoi(ptr) : mp_powercutback);
   }
 
   // trellis
   ptr = NULL;
   ptr = prom_getenv("trellis");
-  if(ptr)
+  if(ptr || mp_trellis != -1)
   {
-    dslhal_api_setTrellisFlag(pIhw, os_atoi(ptr));
-    trellis = os_atoi(ptr);
+    trellis = mp_trellis == -1 ? os_atoi(ptr) : mp_trellis;
+    dslhal_api_setTrellisFlag(pIhw, trellis);
     //printk("trellis=%d\n");
   }
 
   // bitswap
   ptr = NULL;
   ptr = prom_getenv("bitswap");
-  if(ptr)
+  if(ptr || mp_bitswap != -1)
   {
     int offset[2] = {33, 0};
     unsigned int bitswap;
 
-    bitswap = os_atoi(ptr);
+    bitswap = mp_bitswap == -1 ? os_atoi(ptr) : mp_bitswap;
 
     tn7dsl_generic_read(2, offset);
     dslReg &= dslhal_support_byteSwap32(0xFFFFFF00);
@@ -3097,46 +3114,47 @@ static int tn7dsl_set_dsl(void)
   // maximum bits per carrier
   ptr = NULL;
   ptr = prom_getenv("maximum_bits_per_carrier");
-  if(ptr)
+  if(ptr || mp_maximum_bits_per_carrier != -1)
   {
-    dslhal_api_setMaxBitsPerCarrierUpstream(pIhw, os_atoi(ptr));
+    dslhal_api_setMaxBitsPerCarrierUpstream(pIhw, mp_maximum_bits_per_carrier == -1 ? os_atoi(ptr) : mp_maximum_bits_per_carrier);
   }
 
   // maximum interleave depth
   ptr = NULL;
   ptr = prom_getenv("maximum_interleave_depth");
-  if(ptr)
+  if(ptr || mp_maximum_interleave_depth != -1)
   {
-    dslhal_api_setMaxInterleaverDepth(pIhw, os_atoi(ptr));
+    dslhal_api_setMaxInterleaverDepth(pIhw, mp_maximum_interleave_depth == -1 ? os_atoi(ptr) : mp_maximum_interleave_depth);
   }
 
   // inner and outer pairs
   ptr = NULL;
   ptr = prom_getenv("pair_selection");
-  if(ptr)
+  if(ptr || mp_pair_selection != -1)
   {
-    dslhal_api_selectInnerOuterPair(pIhw, os_atoi(ptr));
+    dslhal_api_selectInnerOuterPair(pIhw, mp_pair_selection == -1 ? os_atoi(ptr) : mp_pair_selection);
   }
 
   ptr = NULL;
   ptr = prom_getenv("dgas_polarity");
-  if(ptr)
+  if(ptr || mp_dgas_polarity != -1)
   {
     dslhal_api_configureDgaspLpr(pIhw, 1, 1);
-    dslhal_api_configureDgaspLpr(pIhw, 0, os_atoi(ptr));
+    dslhal_api_configureDgaspLpr(pIhw, 0, mp_dgas_polarity == -1 ? os_atoi(ptr) : mp_dgas_polarity);
   }
 
   ptr = NULL;
   ptr = prom_getenv("los_alarm");
-  if(ptr)
+  if(ptr || mp_los_alarm != -1)
   {
-    dslhal_api_disableLosAlarm(pIhw, os_atoi(ptr));
+    dslhal_api_disableLosAlarm(pIhw, mp_los_alarm == -1 ? os_atoi(ptr) : mp_los_alarm);
   }
 
   ptr = NULL;
   ptr = prom_getenv("eoc_vendor_id");
-  if(ptr)
+  if(ptr || mp_eoc_vendor_id != NULL)
   {
+    ptr = mp_eoc_vendor_id == NULL ? ptr : mp_eoc_vendor_id;
     for(i=0;i<8;i++)
     {
       tmp[0]=ptr[i*2];
@@ -3161,26 +3179,26 @@ static int tn7dsl_set_dsl(void)
   }
   ptr = NULL;
   ptr = prom_getenv("eoc_vendor_revision");
-  if(ptr)
+  if(ptr || mp_eoc_vendor_revision != -1)
   {
-    value = os_atoi(ptr);
+    value = mp_eoc_vendor_revision == -1 ? os_atoi(ptr) : mp_eoc_vendor_revision;
     //printk("eoc rev=%d\n", os_atoi(ptr));
     dslhal_api_setEocRevisionNumber(pIhw, (char *)&value);
 
   }
   ptr = NULL;
   ptr = prom_getenv("eoc_vendor_serialnum");
-  if(ptr)
+  if(ptr || mp_eoc_vendor_serialnum != NULL)
   {
-    dslhal_api_setEocSerialNumber(pIhw, ptr);
+    dslhal_api_setEocSerialNumber(pIhw, mp_eoc_vendor_serialnum == NULL ? ptr : mp_eoc_vendor_serialnum);
   }
 
   // CQ10037 Added invntry_vernum environment variable to be able to set version number in ADSL2, ADSL2+ modes.
   ptr = NULL;
   ptr = prom_getenv("invntry_vernum");
-  if(ptr)
+  if(ptr || mp_invntry_vernum != NULL)
   {
-    dslhal_api_setEocRevisionNumber(pIhw, ptr);
+    dslhal_api_setEocRevisionNumber(pIhw, mp_invntry_vernum == NULL ? ptr : mp_invntry_vernum);
   }
 
   return 0;
@@ -3225,7 +3243,7 @@ int tn7dsl_init(void *priv)
    * backward compatibility.
    */
   cp = prom_getenv("DSL_BIT_TMODE");
-  if (cp)
+  if (cp || mp_dsl_bit_tmode != -1)
   {
     printk("%s : env var DSL_BIT_TMODE is set\n", __FUNCTION__);
     /*
@@ -3254,9 +3272,9 @@ int tn7dsl_init(void *priv)
 
 //  UR8_MERGE_START CQ11054   Jack Zhang
   cp = prom_getenv("high_precision");
-  if (cp)
+  if (cp || mp_high_precision != -1)
   {
-    high_precision_selected = os_atoi(cp);
+    high_precision_selected = mp_high_precision == -1 ? os_atoi(cp) : mp_high_precision;
   }
   if ( high_precision_selected)
   {
--- a/tn7sar.c
+++ b/tn7sar.c
@@ -76,6 +76,8 @@ typedef void OS_SETUP;
 #include "tn7atm.h"
 #include "tn7api.h"
 
+extern int mp_oam_lb_timeout;
+extern int mp_autopvc_enable;
 
 /* PDSP Firmware files */
 #include "tnetd7300_sar_firm.h"
@@ -932,9 +934,9 @@ int tn7sar_setup_oam_channel(Tn7AtmPriva
   pHalDev  = (HAL_DEVICE *)priv->pSarHalDev;
 
   pauto_pvc = prom_getenv("autopvc_enable");
-  if(pauto_pvc)  //CQ10273
+  if(pauto_pvc || mp_autopvc_enable != -1)  //CQ10273
   {
-    auto_pvc =tn7sar_strtoul(pauto_pvc, NULL, 10);
+    auto_pvc = mp_autopvc_enable == -1 ? tn7sar_strtoul(pauto_pvc, NULL, 10) : mp_autopvc_enable;
   }
 
   memset(&chInfo, 0xff, sizeof(chInfo));
@@ -1133,9 +1135,9 @@ int tn7sar_init(struct atm_dev *dev, Tn7
 
   /* read in oam lb timeout value */
   pLbTimeout = prom_getenv("oam_lb_timeout");
-  if(pLbTimeout)
+  if(pLbTimeout || mp_oam_lb_timeout != -1)
   {
-    lbTimeout =tn7sar_strtoul(pLbTimeout, NULL, 10);
+    lbTimeout = mp_oam_lb_timeout == -1 ? tn7sar_strtoul(pLbTimeout, NULL, 10) : mp_oam_lb_timeout;
     oamLbTimeout = lbTimeout;
     pHalFunc->Control(pHalDev,"OamLbTimeout", "Set", &lbTimeout);
   }