Browse Source

add firewall code and fixup each i2c codes

master
root 16 years ago
parent
commit
ccd39ce97b
  1. 1
      Targets/Bonito2edev/conf/Bonito
  2. 1
      Targets/Bonito2fdev/Bonito/i2c.S
  3. 43
      Targets/Bonito2fdev/Bonito/i2ccfgddr.S
  4. 188
      Targets/Bonito2fdev/Bonito/mycmd.c
  5. 1
      Targets/Bonito2fdev/Bonito/start.S
  6. 2
      Targets/Bonito2fdev/Bonito/start_cs5536.S
  7. 2182
      Targets/Bonito2fdev/Bonito/start_firewall.S
  8. 1
      Targets/Bonito2fdev/Bonito/start_sm502.S
  9. 88
      Targets/Bonito2fdev/Bonito/tgt_machdep.c
  10. 1
      Targets/Bonito2fdev/conf/Bonito.2fdev.cs5536
  11. 178
      Targets/Bonito2fdev/conf/Bonito.2fdev.firewall
  12. 1
      Targets/Bonito2fdev/conf/Bonito.2fdev.via
  13. 1
      Targets/Bonito2fdev/conf/Bonito.2feva
  14. 18
      Targets/Bonito2fdev/include/firewall.h
  15. 2
      Targets/Bonito2fdev/pci/pci_machdep.c
  16. 1
      sys/dev/pci/em/e1000_hw.c
  17. 1
      sys/dev/pci/em/e1000_hw.h
  18. 1
      sys/dev/pci/em/e1000_main.c
  19. 1
      zloader.2fdev.firewall
  20. 6
      zloader/Makefile.2fdev.firewall

1
Targets/Bonito2edev/conf/Bonito

@ -166,6 +166,7 @@ option USE_ENVMAC
#option LOOKLIKE_PC
#select cmd_lwdhcp
#select cmd_bootp
option WDC_NORESET
option FOR_GXEMUL
select fatfs
option FLOATINGPT

1
Targets/Bonito2fdev/Bonito/i2c.S

@ -1,4 +1,5 @@
LEAF(i2cread)
addu a0,a0,1
/* set device address */
li v0, 0xbfd00000 + SMBUS_HOST_ADDRESS

43
Targets/Bonito2fdev/Bonito/i2ccfgddr.S

@ -4,7 +4,7 @@
PRINTSTR("DIMM read\r\n")
li a1, 0x0
li a0,0xa1
li a0,0xa0
bal i2cread
nop
beq v0,0xff,1f
@ -12,18 +12,18 @@
beq v0,0x80,1f
nop
move a0,v0
bal hexserial
// bal hexserial
nop
PRINTSTR ("\r\nNo DIMM in slot 0 \r\n");
b 2f
nop
1:
li a0,0xa1
li a0,0xa0
bal ii2c_cfg
nop
2:
li a1, 0x0
li a0,0xa3
li a0,0xa2
bal i2cread
nop
li a1,0x0
@ -32,13 +32,13 @@
beq v0,0x80,1f
nop
move a0,v0
bal hexserial
// bal hexserial
nop
PRINTSTR ("\r\nNo DIMM in slot 1 \r\n");
b 2f
nop
1:
li a0,0xa3
li a0,0xa2
bal ii2c_cfg
nop
@ -49,8 +49,9 @@
b 211f
nop
/*ic2 cfg
* a0=0xa1 for slot 0,a0=0xa3 for slot 1
* a0=0xa0 for slot 0,a0=0xa2 for slot 1
* t5 used for save i2c addr a0,t6 save ra.
* use t1
*/
LEAF(ii2c_cfg)
move t6,ra
@ -93,7 +94,7 @@ LEAF(ii2c_cfg)
bgtu v0, 2,.nodimm1
nop
move t1, v0
PRINTSTR("read number of rows\r\n")
PRINTSTR("read number of rows :");
move a0,s6
bal hexserial
nop
@ -290,7 +291,7 @@ LEAF(ii2c_cfg)
nop
2:
PRINTSTR("number of ranks ,package and height\r\n") ;
PRINTSTR("\r\nnumber of ranks ,package and height\r\n") ;
PRINTSTR("k1 to save cs_map filed valule\r\n") ;
move a0,t5
li a1,5
@ -305,7 +306,7 @@ LEAF(ii2c_cfg)
nop
//************
bne t5,0xa1,123f
bne t5,0xa0,123f
nop
ori k1,k1,0x3
b 124f
@ -318,7 +319,7 @@ LEAF(ii2c_cfg)
2: bne t5,0xa1,123f
2: bne t5,0xa0,123f
nop
ori k1,k1,0x1
b 124f
@ -429,12 +430,14 @@ END(ii2c_cfg)
sw v1,0(v0)
nop
PRINTSTR ("cs map : ");
move a0,k1
bal hexserial
nop
PRINTSTR("\r\n")
PRINTSTR("config bank if bank 8\r\n")
PRINTSTR("\r\nconfig bank if bank 8: ")
li v0,0xaffffe10
ld v1,0(v0)
nop
@ -450,7 +453,7 @@ PRINTSTR("config bank if bank 8\r\n")
bal hexserial
nop
PRINTSTR("cols rows:\r\n")
PRINTSTR("\r\ncols rows: ")
//row addr numbers
li v0,0xffffffff
@ -478,17 +481,23 @@ PRINTSTR("cols rows:\r\n")
or v1,v1,a1
sw v1,0(v0)
nop
// PRINTSTR("cols rows:\r\n")
move a0,v1
bal hexserial
nop
PRINTSTR("\r\n")
sll msize,20
// sll msize,20
b 213f
nop
212:
.nodimm:
li msize,0x10000000
li msize,0x100
PRINTSTR ("\r\nNo DIMM in all slots,use default configure\r\n")
213:
PRINTSTR ("\r\nDIMM size :")
move a0,msize
bal hexserial
nop
PRINTSTR ("\r\n")

188
Targets/Bonito2fdev/Bonito/mycmd.c

@ -735,6 +735,192 @@ void i2c_test()
}
#endif
#ifdef DEVBD2F_FIREWALL
#define I2C_NACK 0x80
#define I2C_RD 0x20
#define I2C_WR 0x10
#define I2C_START 0x80
#define I2C_STOP 0x40
unsigned char atp8620_i2c_read(unsigned char slave_addr,unsigned char sub_addr,unsigned char* buf ,int count)
{
pcitag_t tag;
int i;
volatile unsigned int * iog;
volatile unsigned int tmp;
tag = _pci_make_tag(0,9,0);
iog = _pci_conf_readn(tag,0x10,4);
iog =(unsigned int )iog|0xbfd00000|0xb0;
for(i=0;i<count;i++)
{
tmp = *iog;
while(tmp&0x1)
tmp = *iog;
tmp = (slave_addr&0xff)<<8;
tmp = tmp|I2C_WR|I2C_START|I2C_NACK;
*iog = tmp;
if(!getenv("spd_op"))
{
tmp = *iog;
while(tmp&0x1)
tmp = *iog;
tmp = 0;
tmp = tmp|I2C_WR|I2C_NACK;
*iog = tmp;
}
tmp = *iog;
while(tmp&0x1)
tmp = *iog;
tmp = (sub_addr&0xff)<<8;
tmp = tmp|I2C_WR|I2C_NACK;
*iog = tmp;
tmp = *iog;
while(tmp&0x1)
tmp = *iog;
tmp = ((slave_addr&0xff)+1)<<8;
tmp = tmp|I2C_WR|I2C_START|I2C_NACK;
*iog = tmp;
tmp = *iog;
while(tmp&0x1)
tmp = *iog;
tmp = *iog;
tmp = tmp&0xffff;
tmp = tmp>>16;
buf[i] = tmp&0xff;
tmp = I2C_STOP;
*iog = tmp;
}
return 0;
}
unsigned char atp8620_i2c_write(unsigned char slave_addr,unsigned char sub_addr,unsigned char * buf ,int count)
{
pcitag_t tag;
int i;
volatile unsigned int * iog;
volatile unsigned int tmp;
tag = _pci_make_tag(0,9,0);
iog = _pci_conf_readn(tag,0x10,4);
iog = (unsigned int )iog|0xbfd00000|0xb0;
for(i=0;i<count;i++)
{
tmp = *iog;
while(tmp&0x1)
tmp = *iog;
tmp = (slave_addr&0xff)<<8;
tmp = tmp|I2C_WR|I2C_START|I2C_NACK;
*iog = tmp;
if(!getenv("spd_op"))
{
tmp = *iog;
while(tmp&0x1)
tmp = *iog;
tmp = 0;
tmp = tmp|I2C_WR|I2C_NACK;
*iog = tmp;
}
tmp = *iog;
while(tmp&0x1)
tmp = *iog;
tmp = (sub_addr&0xff)<<8;
tmp = tmp|I2C_WR|I2C_NACK;
*iog = tmp;
tmp = *iog;
while(tmp&0x1)
tmp = *iog;
tmp = buf[i]<<8;
tmp = tmp|I2C_WR|I2C_NACK;
*iog = tmp;
tmp = *iog;
while(tmp&0x1)
tmp = *iog;
tmp = I2C_STOP;
*iog = tmp;
}
return 0;
}
static int firewall_i2c_read(int type,long long addr,union commondata *mydata)
{
char c;
switch(type)
{
case 1:
atp8620_i2c_read((unsigned char)slave_addr,(unsigned char)addr,&c,1);
memcpy(&mydata->data1,&c,1);
return 0;
default:
return -1;
}
}
static int firewall_i2c_write(int type,long long addr,union commondata *mydata)
{
char c;
switch(type)
{
case 1:
memcpy(&c,&mydata->data1,1);
atp8620_i2c_write((unsigned char)slave_addr,(unsigned char)addr,&c,1);
return 0;
default :
return -1;
}
}
static int i2cs(int argc,char *argv[])
{
if(argc<2)
return -1;
i2cslot=strtoul(argv[1],0,0);
switch(i2cslot)
{
case 0:
syscall1 = (void *)firewall_i2c_read;
syscall2 = (void *)firewall_i2c_write;
break;
default:
return -1;
}
return 0;
}
#else
static int i2cs(int argc,char **argv)
{
pcitag_t tag;
@ -809,6 +995,8 @@ return 0;
}
#endif
static const Cmd Cmds[] =
{
{"MyCmds"},

1
Targets/Bonito2fdev/Bonito/start.S

@ -1051,7 +1051,6 @@ zhb:
addu a2,a2,s0
move a0,msize
srl a0,20
la v0, initmips
jalr v0

2
Targets/Bonito2fdev/Bonito/start_cs5536.S

@ -1141,10 +1141,8 @@ zhb:
or a0,a0,0x3
mtc0 a0,COP_0_CONFIG
#endif
// li msize,(512<<20)
move a0,msize
srl a0,20
/* pass pointer to kseg1 tgt_putchar */
la a1, tgt_putchar

2182
Targets/Bonito2fdev/Bonito/start_firewall.S

File diff suppressed because it is too large

1
Targets/Bonito2fdev/Bonito/start_sm502.S

@ -1065,7 +1065,6 @@ zhb:
addu a2,a2,s0
move a0,msize
srl a0,20
la v0, initmips
jalr v0

88
Targets/Bonito2fdev/Bonito/tgt_machdep.c

@ -79,6 +79,7 @@ tgt_printf (const char *fmt, ...)
#include "include/bonito.h"
#include <pmon/dev/gt64240reg.h>
#include <pmon/dev/ns16550.h>
#include "target/firewall.h"
#include <pmon.h>
@ -308,16 +309,22 @@ ppns16550 (int op, struct DevEntry *dev, unsigned long param, int data)
//end modification by zhanghualiang
#endif
ConfigEntry ConfigTable[] =
{
#ifdef HAVE_NB_SERIAL
{ (char *)COM3_BASE_ADDR, 0, ns16550, 256, CONS_BAUD, NS16550HZ/2 },
#ifdef DEVBD2F_FIREWALL
{ (char *)LS2F_COMA_ADDR, 0, ns16550, 256, CONS_BAUD, NS16550HZ/2 },
#else
{ (char *)COM3_BASE_ADDR, 0, ns16550, 256, CONS_BAUD, NS16550HZ },
#endif
#elif defined(USE_SM502_UART0)
{ (char *)0xb6030000, 0, ns16550, 256, CONS_BAUD, NS16550HZ/2 },
#elif defined(USE_GPIO_SERIAL)
{ (char *)COM1_BASE_ADDR, 0,ppns16550, 256, CONS_BAUD, NS16550HZ },
#else
{ (char *)COM1_BASE_ADDR, 0, ns16550, 256, CONS_BAUD, NS16550HZ },
{ (char *)COM1_BASE_ADDR, 0, ns16550, 256, CONS_BAUD, NS16550HZ/2 },
#endif
#if NMOD_VGACON >0
#if NMOD_FRAMEBUFFER >0
@ -785,10 +792,10 @@ static inline unsigned char CMOS_READ(unsigned char addr)
volatile int tmp;
// unsigned char and_char;
#ifndef DEVBD2F_SM502
#if defined(DEVBD2F_VIA)||defined(DEVBD2F_CS5536)||defined(DEVBD2F_EVA)
linux_outb_p(addr, 0x70);
val = linux_inb_p(0x71);
#else
#elif defined(DEVBD2f_SM502)
pcitag_t tag;
unsigned char value;
@ -835,16 +842,51 @@ static inline unsigned char CMOS_READ(unsigned char addr)
tmp2 = val&0x0f;
val = tmp1 + tmp2;
#elif defined(DEVBD2F_FIREWALL)
if(addr >= 0x0a)
return 0;
switch(addr)
{
case 0:
addr= 0x30;
break;
case 2:
addr = 0x31;
break;
case 4:
addr = 0x32;
break;
case 6:
addr = 0x36;
break;
case 7:
addr = 0x33;
break;
case 8:
addr = 0x34;
break;
case 9:
addr = 0x35;
break;
}
atp8620_i2c_read(0xde,addr,&tmp,1);
val = ((tmp>>4)&0x0f)*10;
val = val + (tmp&0x0f);
#endif
return val;
}
static inline void CMOS_WRITE(unsigned char val, unsigned char addr)
{
#ifndef DEVBD2F_SM502
#if defined(DEVBD2F_VIA)||defined(DEVBD2F_CS5536)||defined(DEVBD2F_EVA)
linux_outb_p(addr, 0x70);
linux_outb_p(val, 0x71);
#else
#elif defined(DEVBD2f_SM502)
unsigned char tmp1,tmp2;
volatile int tmp;
@ -893,6 +935,40 @@ static inline void CMOS_WRITE(unsigned char val, unsigned char addr)
i2c_send_s((unsigned char)0x64,0xe<<4,&value,1);
i2c_send_s((unsigned char)0x64,addr<<4,&val,1);
}
#elif defined(DEVBD2F_FIREWALL)
unsigned char tmp;
if(addr >= 0x0a)
return 0;
switch(addr)
{
case 0:
addr= 0x30;
break;
case 2:
addr = 0x31;
break;
case 4:
addr = 0x32;
break;
case 6:
addr = 0x36;
break;
case 7:
addr = 0x33;
break;
case 8:
addr = 0x34;
break;
case 9:
addr = 0x35;
break;
}
tmp = (val/10)<<4;
val = tmp|(val%10);
atp8620_i2c_write(0xde,addr,&val,1);
#endif
}

1
Targets/Bonito2fdev/conf/Bonito.2fdev.cs5536

@ -176,6 +176,7 @@ option COM3_BASE_ADDR=0xbff003f8
#option WDC_NORESET
select cs5536
option CONFIG_VIDEO_SM501_16BPP
option DEVBD2F_CS5536
select gzip
option INPUT_FROM_BOTH
option OUTPUT_TO_BOTH

178
Targets/Bonito2fdev/conf/Bonito.2fdev.firewall

@ -0,0 +1,178 @@
# $Id: Bonito,v 1.1.1.1 2006/09/14 01:59:09 root Exp $ # # GENERIC configuration for Galileo EV64240 # # This file is supposed to be included by target file after # endian has been defined.
#
machine Bonito2fdev mips # CPU Architecture, Platform
config pmon
option VGAROM_IN_BIOS
#
# Define target endian
#
makeoptions ENDIAN=EL # Little endian version.
#include "conf/GENERIC_ALL"
#
# System Name and Target Name
#
option SYSTYPE="\"Bonito\""
option TARGETNAME="\"Bonito\""
#
# Platform options
#
option BONITOEL
option DEVBD2F
option MIPS
option INET
select mod_flash_amd # AMD flash device programming
select mod_flash_intel # intel flash device programming
select mod_flash_sst # intel flash device programming
select mod_debugger # Debugging module
select mod_symbols # Symbol table handling
select mod_s3load # Srecord loading
#select mod_fastload # LSI Fastload
select mod_elfload # ELF loading
#
# Command selection. Selects pmon commands
#
select cmd_newmt
select cmd_setup
select cmd_about # Display info about PMON
select cmd_boot # Boot wrapper
select cmd_mycmd
select cmd_newmt
select cmd_cache # Cache enabling
#select cmd_call # Call a function command
select cmd_date # Time of day command
select cmd_env # Full blown environment command set
select cmd_flash # Flash programming cmds
select cmd_hist # Command history
select cmd_ifaddr # Interface address command
select cmd_l # Disassemble
select cmd_mem # Memory manipulation commands
select cmd_more # More paginator
select cmd_mt # Simple memory test command
select cmd_misc # Reboot & Flush etc.
#select cmd_stty # TTY setings command
select cmd_tr # Host port-through command
select cmd_devls # Device list
select cmd_set # As cmd_env but not req. cmd_hist
select cmd_testdisk
#
select cmd_shell # Shell commands, vers, help, eval
#
#
# Platform options
#
select mod_uart_ns16550 # Standard UART driver
#option CONS_BAUD=B9600
option CONS_BAUD=B115200
select ext2
select fatfs
select mod_x86emu # X86 emulation for VGA
option MY40IO
#select mod_x86emu_int10
select mod_vgacon
option NOPCINAMES # Save some space for x86emu
#option FASTBOOT
select vt82c686 #via686a/b code
#
# Functional options.
#
option NOSNOOP # Caches are no-snooping
#
# HAVE options. What tgt level provide
#
option HAVE_TOD # Time-Of-Day clock
option HAVE_NVENV # Platform has non-volatile env mem
option HAVE_LOGO # Output splash logo
option USE_SUPERIO_UART
#option USE_LEGACY_RTC
#option GODSONEV2A
#option LINUX_PC
#option LONGMENG
#option RADEON7000
#option DEBUG_EMU_VGA
option AUTOLOAD
#option CONFIG_PCI0_LARGE_MEM
#option CONFIG_PCI0_HUGE_MEM
#option CONFIG_PCI0_GAINT_MEM
option CONFIG_CACHE_64K_4WAY
option NVRAM_IN_FLASH
#
# Now the Machine specification
#
mainbus0 at root
localbus0 at mainbus0
loopdev0 at mainbus0
#fd0 at mainbus0
pcibr0 at mainbus0
#pcibr1 at mainbus0
pci* at pcibr?
#ppb* at pci? dev ? function ? # PCI-PCI bridges
#pci* at ppb? bus ?
#### USB
#uhci* at pci? dev ? function ?
#### SCSI support
#siop* at pci? dev ? function ? # Symbios/NCR 53c...
#scsibus* at siop?
#sd* at scsibus? target ? lun ?
#cd* at scsibus? target ? lun ?
#### Networking Devices
#gt0 at localbus? base 4
#gt1 at localbus? base 5
#gt2 at localbus? base 6
# fxp normally only used for debugging (enable/disable both)
fxp0 at pci? dev ? function ? # Intel 82559 Device
inphy* at mii? phy ? # Intel 82555 PHYs
rtl* at pci? dev ? function ?
em* at pci? dev ? function ?
#uhci* at pci? dev ? function ?
#ohci0 at pci? dev ? function ?
#usb* at usbbus ?
#ohci1 at pci? dev ? function ?
#select mod_usb
#select mod_usb_storage
#select mod_usb_uhci
#select mod_usb_ohci
#select mod_usb_kbd
#### IDE controllers
pciide* at pci ? dev ? function ? flags 0x0000
#### IDE hard drives
wd* at pciide? channel ? drive ? flags 0x0000
#### Pseudo devices
pseudo-device loop 1 # network loopback
ide_cd* at pciide? channel ? drive ? flags 0x0001
select iso9660
select ramfiles
select cmd_xyzmodem
option IDECD
option HAVE_NB_SERIAL
#option USE_ENVMAC
#option LOOKLIKE_PC
#select cmd_lwdhcp
#select cmd_bootp
option FOR_GXEMUL
select fatfs
option FLOATINGPT
option WDC_NORESET
option DEVBD2F_FIREWALL
select gzip
option INPUT_FROM_BOTH
option OUTPUT_TO_BOTH
option LS2F_FIREWALL
#option USE_GPIO_SERIAL

1
Targets/Bonito2fdev/conf/Bonito.2fdev.via

@ -134,6 +134,7 @@ pci* at pcibr?
fxp0 at pci? dev ? function ? # Intel 82559 Device
#inphy* at mii? phy ? # Intel 82555 PHYs
rtl* at pci? dev ? function ?
em* at pci? dev ? function ?
#uhci* at pci? dev ? function ?
#ohci0 at pci? dev ? function ?
#usb* at usbbus ?

1
Targets/Bonito2fdev/conf/Bonito.2feva

@ -164,6 +164,7 @@ option HAVE_NB_SERIAL
#select cmd_bootp
option FOR_GXEMUL
select fatfs
option DEVBD2F_EVA
option FLOATINGPT
option PCI_IDSEL_VIA686B=6
option COM3_BASE_ADDR=0xbff003f8

18
Targets/Bonito2fdev/include/firewall.h

@ -0,0 +1,18 @@
#ifndef FIREWALL_H
#define FIREWALL_H
#define PCI_IDSEL_ATP8260 9
#define IOG 0x4000
#define I2CREG_ADDR (0xbfd00000|(IOG)|0xB0)
#define I2C_NACK 0x80
#define I2C_RD 0x20
#define I2C_WR 0x10
#define I2C_START 0x80
#define I2C_STOP 0x40
#define LS2F_COMA_ADDR 0xbe000000
#define LS2F_COMB_ADDR 0xbe000020
#define LS2F_PP_ADDR 0xbe000040
#define LS2F_COM_CLK 1843200
#endif

2
Targets/Bonito2fdev/pci/pci_machdep.c

@ -204,7 +204,7 @@ _pci_dmamap(va, len)
}
#if 0
#if 1
/*
* Map the PCI address of an area of local memory to a CPU physical
* address.

1
sys/dev/pci/em/e1000_hw.c

@ -232,6 +232,7 @@ e1000_set_mac_type(struct e1000_hw *hw)
break;
case E1000_DEV_ID_82541EI:
case E1000_DEV_ID_82541EP:
case E1000_DEV_ID_82541PI:
hw->mac_type = e1000_82541;
break;
case E1000_DEV_ID_82547EI:

1
sys/dev/pci/em/e1000_hw.h

@ -329,6 +329,7 @@ void e1000_write_reg_io(struct e1000_hw *hw, uint32_t offset, uint32_t value);
#define E1000_DEV_ID_82546GB_QUAD_COPPER 0x1099
#define E1000_DEV_ID_82541EI 0x1013
#define E1000_DEV_ID_82541EP 0x1018
#define E1000_DEV_ID_82541PI 0x107c
#define E1000_DEV_ID_82547EI 0x1019
#define NUM_DEV_IDS 20

1
sys/dev/pci/em/e1000_main.c

@ -81,6 +81,7 @@ static struct pci_device_id e1000_pci_tbl[] __devinitdata = {
{0x8086, 0x1013, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
{0x8086, 0x1019, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
{0x8086, 0x1079, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
{0x8086, 0x107C, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
/* required last entry */
{0,}
};

1
zloader.2fdev.firewall

@ -0,0 +1 @@
zloader

6
zloader/Makefile.2fdev.firewall

@ -0,0 +1,6 @@
TARGET=Bonito2fdev
TARGETEL=Bonito.2fdev.firewall
export START=start_firewall.o
MEMSIZE=128
include Makefile.inc
Loading…
Cancel
Save