Merge pull request #530 from enjoy-digital/bios-libs
BIOS: move cores' specific code to libs and cleanup.
This commit is contained in:
commit
23d43a2c23
|
@ -25,7 +25,9 @@ __all__ = ["soc_software_packages", "soc_directory",
|
||||||
soc_software_packages = [
|
soc_software_packages = [
|
||||||
"libcompiler_rt",
|
"libcompiler_rt",
|
||||||
"libbase",
|
"libbase",
|
||||||
"libnet",
|
"liblitedram",
|
||||||
|
"libliteeth",
|
||||||
|
"liblitesdcard",
|
||||||
"bios"
|
"bios"
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
|
@ -11,19 +11,17 @@ CFLAGS += -DTFTP_SERVER_PORT=$(TFTP_SERVER_PORT)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
OBJECTS = isr.o \
|
OBJECTS = isr.o \
|
||||||
sdram.o \
|
|
||||||
sdcard.o \
|
|
||||||
main.o \
|
|
||||||
boot-helper.o \
|
boot-helper.o \
|
||||||
boot.o \
|
boot.o \
|
||||||
helpers.o \
|
helpers.o \
|
||||||
cmd_bios.o \
|
cmd_bios.o \
|
||||||
|
cmd_mem.o \
|
||||||
cmd_boot.o \
|
cmd_boot.o \
|
||||||
cmd_dram.o \
|
cmd_spiflash.o \
|
||||||
cmd_mdio.o \
|
cmd_litedram.o \
|
||||||
cmd_mem_access.o \
|
cmd_liteeth.o \
|
||||||
cmd_sdcard.o \
|
cmd_litesdcard.o \
|
||||||
cmd_spi_flash.o \
|
main.o
|
||||||
|
|
||||||
ifneq "$(or $(TERM_NO_COMPLETE),$(TERM_MINI))" ""
|
ifneq "$(or $(TERM_NO_COMPLETE),$(TERM_MINI))" ""
|
||||||
CFLAGS += -DTERM_NO_COMPLETE
|
CFLAGS += -DTERM_NO_COMPLETE
|
||||||
|
@ -59,15 +57,22 @@ endif
|
||||||
bios.elf: $(BIOS_DIRECTORY)/linker.ld $(OBJECTS)
|
bios.elf: $(BIOS_DIRECTORY)/linker.ld $(OBJECTS)
|
||||||
|
|
||||||
|
|
||||||
%.elf: ../libbase/crt0-ctr.o ../libnet/libnet.a ../libbase/libbase-nofloat.a ../libcompiler_rt/libcompiler_rt.a
|
%.elf: ../libbase/crt0-ctr.o \
|
||||||
|
../libcompiler_rt/libcompiler_rt.a \
|
||||||
|
../libbase/libbase-nofloat.a \
|
||||||
|
../liblitedram/liblitedram.a \
|
||||||
|
../libliteeth/libliteeth.a \
|
||||||
|
../liblitesdcard/liblitesdcard.a
|
||||||
$(LD) $(LDFLAGS) -T $(BIOS_DIRECTORY)/linker.ld -N -o $@ \
|
$(LD) $(LDFLAGS) -T $(BIOS_DIRECTORY)/linker.ld -N -o $@ \
|
||||||
../libbase/crt0-ctr.o \
|
../libbase/crt0-ctr.o \
|
||||||
$(OBJECTS) \
|
$(OBJECTS) \
|
||||||
-L../libnet \
|
|
||||||
-L../libbase \
|
|
||||||
-L../libcompiler_rt \
|
-L../libcompiler_rt \
|
||||||
|
-L../libbase \
|
||||||
|
-L../liblitedram \
|
||||||
|
-L../libliteeth \
|
||||||
|
-L../liblitesdcard \
|
||||||
$(BP_LIBS) \
|
$(BP_LIBS) \
|
||||||
-lnet -lbase-nofloat -lcompiler_rt \
|
-lcompiler_rt -lbase-nofloat -llitedram -lliteeth -llitesdcard \
|
||||||
$(BP_FLAGS)
|
$(BP_FLAGS)
|
||||||
|
|
||||||
ifneq ($(OS),Windows_NT)
|
ifneq ($(OS),Windows_NT)
|
||||||
|
@ -80,7 +85,7 @@ endif
|
||||||
%.o: $(BIOS_DIRECTORY)/%.c
|
%.o: $(BIOS_DIRECTORY)/%.c
|
||||||
$(compile)
|
$(compile)
|
||||||
|
|
||||||
%.o: $(BIOS_DIRECTORY)/commands/%.c
|
%.o: $(BIOS_DIRECTORY)/cmds/%.c
|
||||||
$(compile)
|
$(compile)
|
||||||
|
|
||||||
%.o: $(BIOS_DIRECTORY)/%.S
|
%.o: $(BIOS_DIRECTORY)/%.S
|
||||||
|
|
|
@ -21,8 +21,8 @@
|
||||||
#include <generated/soc.h>
|
#include <generated/soc.h>
|
||||||
|
|
||||||
#ifdef CSR_ETHMAC_BASE
|
#ifdef CSR_ETHMAC_BASE
|
||||||
#include <net/microudp.h>
|
#include <udp.h>
|
||||||
#include <net/tftp.h>
|
#include <tftp.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef CSR_SPIFLASH_BASE
|
#ifdef CSR_SPIFLASH_BASE
|
||||||
|
@ -340,7 +340,7 @@ void netboot(void)
|
||||||
|
|
||||||
ip = IPTOINT(REMOTEIP1, REMOTEIP2, REMOTEIP3, REMOTEIP4);
|
ip = IPTOINT(REMOTEIP1, REMOTEIP2, REMOTEIP3, REMOTEIP4);
|
||||||
|
|
||||||
microudp_start(macadr, IPTOINT(LOCALIP1, LOCALIP2, LOCALIP3, LOCALIP4));
|
udp_start(macadr, IPTOINT(LOCALIP1, LOCALIP2, LOCALIP3, LOCALIP4));
|
||||||
|
|
||||||
tftp_port = TFTP_SERVER_PORT;
|
tftp_port = TFTP_SERVER_PORT;
|
||||||
printf("Fetching from: UDP/%d\n", tftp_port);
|
printf("Fetching from: UDP/%d\n", tftp_port);
|
||||||
|
@ -497,7 +497,7 @@ void romboot(void)
|
||||||
|
|
||||||
// SPI HARDWARE BITBANG
|
// SPI HARDWARE BITBANG
|
||||||
#ifdef CSR_SPISDCARD_BASE
|
#ifdef CSR_SPISDCARD_BASE
|
||||||
#include <spisdcard.h>
|
#include "spisdcard.h"
|
||||||
|
|
||||||
void spisdcardboot(void)
|
void spisdcardboot(void)
|
||||||
{
|
{
|
||||||
|
|
|
@ -5,9 +5,10 @@
|
||||||
|
|
||||||
#include <generated/csr.h>
|
#include <generated/csr.h>
|
||||||
|
|
||||||
|
#include "sdram.h"
|
||||||
|
|
||||||
#include "../command.h"
|
#include "../command.h"
|
||||||
#include "../helpers.h"
|
#include "../helpers.h"
|
||||||
#include "../sdram.h"
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Command "sdrrow"
|
* Command "sdrrow"
|
||||||
|
@ -25,7 +26,7 @@ static void sdrrow_handler(int nb_params, char **params)
|
||||||
sdrrow(0);
|
sdrrow(0);
|
||||||
printf("Precharged");
|
printf("Precharged");
|
||||||
}
|
}
|
||||||
|
|
||||||
row = strtoul(params[0], &c, 0);
|
row = strtoul(params[0], &c, 0);
|
||||||
if (*c != 0) {
|
if (*c != 0) {
|
||||||
printf("Incorrect row");
|
printf("Incorrect row");
|
||||||
|
@ -35,7 +36,7 @@ static void sdrrow_handler(int nb_params, char **params)
|
||||||
sdrrow(row);
|
sdrrow(row);
|
||||||
printf("Activated row %d", row);
|
printf("Activated row %d", row);
|
||||||
}
|
}
|
||||||
define_command(sdrrow, sdrrow_handler, "Precharge/Activate row", DRAM_CMDS);
|
define_command(sdrrow, sdrrow_handler, "Precharge/Activate row", LITEDRAM_CMDS);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -45,7 +46,7 @@ define_command(sdrrow, sdrrow_handler, "Precharge/Activate row", DRAM_CMDS);
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
#ifdef CSR_SDRAM_BASE
|
#ifdef CSR_SDRAM_BASE
|
||||||
define_command(sdrsw, sdrsw, "Gives SDRAM control to SW", DRAM_CMDS);
|
define_command(sdrsw, sdrsw, "Gives SDRAM control to SW", LITEDRAM_CMDS);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -55,7 +56,7 @@ define_command(sdrsw, sdrsw, "Gives SDRAM control to SW", DRAM_CMDS);
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
#ifdef CSR_SDRAM_BASE
|
#ifdef CSR_SDRAM_BASE
|
||||||
define_command(sdrhw, sdrhw, "Gives SDRAM control to HW", DRAM_CMDS);
|
define_command(sdrhw, sdrhw, "Gives SDRAM control to HW", LITEDRAM_CMDS);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -70,7 +71,7 @@ static void sdrrdbuf_handler(int nb_params, char **params)
|
||||||
sdrrdbuf(-1);
|
sdrrdbuf(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
define_command(sdrrdbuf, sdrrdbuf_handler, "Dump SDRAM read buffer", DRAM_CMDS);
|
define_command(sdrrdbuf, sdrrdbuf_handler, "Dump SDRAM read buffer", LITEDRAM_CMDS);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -110,7 +111,7 @@ static void sdrrd_handler(int nb_params, char **params)
|
||||||
sdrrd(addr, dq);
|
sdrrd(addr, dq);
|
||||||
}
|
}
|
||||||
|
|
||||||
define_command(sdrrd, sdrrd_handler, "Read SDRAM data", DRAM_CMDS);
|
define_command(sdrrd, sdrrd_handler, "Read SDRAM data", LITEDRAM_CMDS);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -139,7 +140,7 @@ static void sdrrderr_handler(int nb_params, char **params)
|
||||||
sdrrderr(count);
|
sdrrderr(count);
|
||||||
}
|
}
|
||||||
|
|
||||||
define_command(sdrrderr, sdrrderr_handler, "Print SDRAM read errors", DRAM_CMDS);
|
define_command(sdrrderr, sdrrderr_handler, "Print SDRAM read errors", LITEDRAM_CMDS);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -168,7 +169,7 @@ static void sdrwr_handler(int nb_params, char **params)
|
||||||
sdrwr(addr);
|
sdrwr(addr);
|
||||||
}
|
}
|
||||||
|
|
||||||
define_command(sdrwr, sdrwr_handler, "Write SDRAM test data", DRAM_CMDS);
|
define_command(sdrwr, sdrwr_handler, "Write SDRAM test data", LITEDRAM_CMDS);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -178,7 +179,7 @@ define_command(sdrwr, sdrwr_handler, "Write SDRAM test data", DRAM_CMDS);
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
#if defined(CSR_SDRAM_BASE) && defined(CSR_DDRPHY_BASE)
|
#if defined(CSR_SDRAM_BASE) && defined(CSR_DDRPHY_BASE)
|
||||||
define_command(sdrinit, sdrinit, "Start SDRAM initialisation", DRAM_CMDS);
|
define_command(sdrinit, sdrinit, "Start SDRAM initialisation", LITEDRAM_CMDS);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -188,7 +189,7 @@ define_command(sdrinit, sdrinit, "Start SDRAM initialisation", DRAM_CMDS);
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
#if defined(CSR_DDRPHY_BASE) && defined(SDRAM_PHY_WRITE_LEVELING_CAPABLE) && defined(CSR_SDRAM_BASE)
|
#if defined(CSR_DDRPHY_BASE) && defined(SDRAM_PHY_WRITE_LEVELING_CAPABLE) && defined(CSR_SDRAM_BASE)
|
||||||
define_command(sdrwlon, sdrwlon, "Enable write leveling", DRAM_CMDS);
|
define_command(sdrwlon, sdrwlon, "Enable write leveling", LITEDRAM_CMDS);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -198,7 +199,7 @@ define_command(sdrwlon, sdrwlon, "Enable write leveling", DRAM_CMDS);
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
#if defined(CSR_DDRPHY_BASE) && defined(SDRAM_PHY_WRITE_LEVELING_CAPABLE) && defined(CSR_SDRAM_BASE)
|
#if defined(CSR_DDRPHY_BASE) && defined(SDRAM_PHY_WRITE_LEVELING_CAPABLE) && defined(CSR_SDRAM_BASE)
|
||||||
define_command(sdrwloff, sdrwloff, "Disable write leveling", DRAM_CMDS);
|
define_command(sdrwloff, sdrwloff, "Disable write leveling", LITEDRAM_CMDS);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -208,7 +209,7 @@ define_command(sdrwloff, sdrwloff, "Disable write leveling", DRAM_CMDS);
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
#if defined(CSR_DDRPHY_BASE) && defined(CSR_SDRAM_BASE)
|
#if defined(CSR_DDRPHY_BASE) && defined(CSR_SDRAM_BASE)
|
||||||
define_command(sdrlevel, sdrlevel, "Perform read/write leveling", DRAM_CMDS);
|
define_command(sdrlevel, sdrlevel, "Perform read/write leveling", LITEDRAM_CMDS);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -218,5 +219,5 @@ define_command(sdrlevel, sdrlevel, "Perform read/write leveling", DRAM_CMDS);
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
#ifdef CSR_SDRAM_BASE
|
#ifdef CSR_SDRAM_BASE
|
||||||
define_command(memtest, memtest, "Run a memory test", DRAM_CMDS);
|
define_command(memtest, memtest, "Run a memory test", LITEDRAM_CMDS);
|
||||||
#endif
|
#endif
|
|
@ -5,7 +5,7 @@
|
||||||
|
|
||||||
#include <generated/csr.h>
|
#include <generated/csr.h>
|
||||||
|
|
||||||
#include <base/mdio.h>
|
#include "mdio.h"
|
||||||
|
|
||||||
#include "../command.h"
|
#include "../command.h"
|
||||||
#include "../helpers.h"
|
#include "../helpers.h"
|
||||||
|
@ -50,7 +50,7 @@ static void mdiow(int nb_params, char **params)
|
||||||
mdio_write(phyadr2, reg2, val2);
|
mdio_write(phyadr2, reg2, val2);
|
||||||
}
|
}
|
||||||
|
|
||||||
define_command(mdiow, mdiow, "Write MDIO register", MDIO_CMDS);
|
define_command(mdiow, mdiow, "Write MDIO register", LITEETH_CMDS);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -88,7 +88,7 @@ static void mdior(int nb_params, char **params)
|
||||||
printf("Reg %d: 0x%04x", reg2, val);
|
printf("Reg %d: 0x%04x", reg2, val);
|
||||||
}
|
}
|
||||||
|
|
||||||
define_command(mdior, mdior, "Read MDIO register", MDIO_CMDS);
|
define_command(mdior, mdior, "Read MDIO register", LITEETH_CMDS);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -130,5 +130,5 @@ static void mdiod(int nb_params, char **params)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
define_command(mdiod, mdiod, "Dump MDIO registers", MDIO_CMDS);
|
define_command(mdiod, mdiod, "Dump MDIO registers", LITEETH_CMDS);
|
||||||
#endif
|
#endif
|
|
@ -5,9 +5,10 @@
|
||||||
|
|
||||||
#include <generated/csr.h>
|
#include <generated/csr.h>
|
||||||
|
|
||||||
|
#include "sdcard.h"
|
||||||
|
|
||||||
#include "../command.h"
|
#include "../command.h"
|
||||||
#include "../helpers.h"
|
#include "../helpers.h"
|
||||||
#include "../sdcard.h"
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Command "sdclk"
|
* Command "sdclk"
|
||||||
|
@ -42,7 +43,7 @@ struct command_struct cmd_sdclk =
|
||||||
.help = "SDCard set clk frequency (Mhz)",
|
.help = "SDCard set clk frequency (Mhz)",
|
||||||
};
|
};
|
||||||
|
|
||||||
define_command(sdclk, sdclk, "SDCard set clk frequency (Mhz)", SD_CMDS);
|
define_command(sdclk, sdclk, "SDCard set clk frequency (Mhz)", LITESDCARD_CMDS);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -52,7 +53,7 @@ define_command(sdclk, sdclk, "SDCard set clk frequency (Mhz)", SD_CMDS);
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
#ifdef CSR_SDCORE_BASE
|
#ifdef CSR_SDCORE_BASE
|
||||||
define_command(sdinit, sdcard_init, "SDCard initialization", SD_CMDS);
|
define_command(sdinit, sdcard_init, "SDCard initialization", LITESDCARD_CMDS);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -81,7 +82,7 @@ static void sdtest(int nb_params, char **params)
|
||||||
sdcard_test(blocks);
|
sdcard_test(blocks);
|
||||||
}
|
}
|
||||||
|
|
||||||
define_command(sdtest, sdtest, "SDCard test", SD_CMDS);
|
define_command(sdtest, sdtest, "SDCard test", LITESDCARD_CMDS);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -110,7 +111,7 @@ static void sdtestread(int nb_params, char **params)
|
||||||
sdcard_test_read(block);
|
sdcard_test_read(block);
|
||||||
}
|
}
|
||||||
|
|
||||||
define_command(sdtestread, sdtestread, "SDCard test read", SD_CMDS);
|
define_command(sdtestread, sdtestread, "SDCard test read", LITESDCARD_CMDS);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -139,5 +140,5 @@ static void sdtestwrite(int nb_params, char **params)
|
||||||
sdcard_test_write(block, params[1]);
|
sdcard_test_write(block, params[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
define_command(sdtestwrite, sdtestwrite, "SDCard test write", SD_CMDS);
|
define_command(sdtestwrite, sdtestwrite, "SDCard test write", LITESDCARD_CMDS);
|
||||||
#endif
|
#endif
|
|
@ -9,17 +9,16 @@
|
||||||
|
|
||||||
#define HIST_DEPTH 10 /* Used in string list, complete.c */
|
#define HIST_DEPTH 10 /* Used in string list, complete.c */
|
||||||
|
|
||||||
#define MISC_CMDS 0
|
#define MISC_CMDS 0
|
||||||
#define SYSTEM_CMDS 1
|
#define SYSTEM_CMDS 1
|
||||||
#define CACHE_CMDS 2
|
#define CACHE_CMDS 2
|
||||||
#define BOOT_CMDS 3
|
#define MEM_CMDS 3
|
||||||
#define DRAM_CMDS 4
|
#define BOOT_CMDS 3
|
||||||
#define MDIO_CMDS 5
|
#define SPIFLASH_CMDS 4
|
||||||
#define MEM_CMDS 6
|
#define LITEDRAM_CMDS 4
|
||||||
#define SD_CMDS 7
|
#define LITEETH_CMDS 5
|
||||||
#define SPIFLASH_CMDS 8
|
#define LITESDCARD_CMDS 7
|
||||||
#define DDR_CMDS 9
|
#define NB_OF_GROUPS 8
|
||||||
#define NB_OF_GROUPS 10
|
|
||||||
|
|
||||||
typedef void (*cmd_handler)(int nb_params, char **params);
|
typedef void (*cmd_handler)(int nb_params, char **params);
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,7 @@
|
||||||
#include <generated/git.h>
|
#include <generated/git.h>
|
||||||
|
|
||||||
#ifdef CSR_ETHMAC_BASE
|
#ifdef CSR_ETHMAC_BASE
|
||||||
#include <net/microudp.h>
|
#include "udp.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef CSR_SPIFLASH_BASE
|
#ifdef CSR_SPIFLASH_BASE
|
||||||
|
@ -38,7 +38,7 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef CSR_ETHPHY_MDIO_W_ADDR
|
#ifdef CSR_ETHPHY_MDIO_W_ADDR
|
||||||
#include <mdio.h>
|
#include "mdio.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "sdram.h"
|
#include "sdram.h"
|
||||||
|
|
|
@ -45,7 +45,14 @@ DEPFLAGS += -MD -MP
|
||||||
|
|
||||||
# Toolchain options
|
# Toolchain options
|
||||||
#
|
#
|
||||||
INCLUDES = -I$(SOC_DIRECTORY)/software/include/base -I$(SOC_DIRECTORY)/software/include -I$(SOC_DIRECTORY)/common -I$(BUILDINC_DIRECTORY) -I$(CPU_DIRECTORY)
|
INCLUDES = -I$(SOC_DIRECTORY)/software/include/base \
|
||||||
|
-I$(SOC_DIRECTORY)/software/include \
|
||||||
|
-I$(SOC_DIRECTORY)/common \
|
||||||
|
-I$(BUILDINC_DIRECTORY) \
|
||||||
|
-I$(CPU_DIRECTORY) \
|
||||||
|
-I$(SOC_DIRECTORY)/software/liblitedram \
|
||||||
|
-I$(SOC_DIRECTORY)/software/libliteeth \
|
||||||
|
-I$(SOC_DIRECTORY)/software/liblitesdcard
|
||||||
COMMONFLAGS = $(DEPFLAGS) -Os $(CPUFLAGS) -g3 -fomit-frame-pointer -Wall -fno-builtin -nostdinc $(INCLUDES)
|
COMMONFLAGS = $(DEPFLAGS) -Os $(CPUFLAGS) -g3 -fomit-frame-pointer -Wall -fno-builtin -nostdinc $(INCLUDES)
|
||||||
CFLAGS = $(COMMONFLAGS) -fexceptions -Wstrict-prototypes -Wold-style-definition -Wmissing-prototypes
|
CFLAGS = $(COMMONFLAGS) -fexceptions -Wstrict-prototypes -Wold-style-definition -Wmissing-prototypes
|
||||||
CXXFLAGS = $(COMMONFLAGS) -std=c++11 -I$(SOC_DIRECTORY)/software/include/basec++ -fexceptions -fno-rtti -ffreestanding
|
CXXFLAGS = $(COMMONFLAGS) -std=c++11 -I$(SOC_DIRECTORY)/software/include/basec++ -fexceptions -fno-rtti -ffreestanding
|
||||||
|
|
|
@ -5,6 +5,9 @@
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define UART_EV_TX 0x1
|
||||||
|
#define UART_EV_RX 0x2
|
||||||
|
|
||||||
void uart_init(void);
|
void uart_init(void);
|
||||||
void uart_isr(void);
|
void uart_isr(void);
|
||||||
void uart_sync(void);
|
void uart_sync(void);
|
||||||
|
|
|
@ -1,40 +0,0 @@
|
||||||
#ifndef __HW_FLAGS_H
|
|
||||||
#define __HW_FLAGS_H
|
|
||||||
|
|
||||||
#define UART_EV_TX 0x1
|
|
||||||
#define UART_EV_RX 0x2
|
|
||||||
|
|
||||||
#define DFII_CONTROL_SEL 0x01
|
|
||||||
#define DFII_CONTROL_CKE 0x02
|
|
||||||
#define DFII_CONTROL_ODT 0x04
|
|
||||||
#define DFII_CONTROL_RESET_N 0x08
|
|
||||||
|
|
||||||
#define DFII_COMMAND_CS 0x01
|
|
||||||
#define DFII_COMMAND_WE 0x02
|
|
||||||
#define DFII_COMMAND_CAS 0x04
|
|
||||||
#define DFII_COMMAND_RAS 0x08
|
|
||||||
#define DFII_COMMAND_WRDATA 0x10
|
|
||||||
#define DFII_COMMAND_RDDATA 0x20
|
|
||||||
|
|
||||||
#define ETHMAC_EV_SRAM_WRITER 0x1
|
|
||||||
#define ETHMAC_EV_SRAM_READER 0x1
|
|
||||||
|
|
||||||
#define CLKGEN_STATUS_BUSY 0x1
|
|
||||||
#define CLKGEN_STATUS_PROGDONE 0x2
|
|
||||||
#define CLKGEN_STATUS_LOCKED 0x4
|
|
||||||
|
|
||||||
#define DVISAMPLER_TOO_LATE 0x1
|
|
||||||
#define DVISAMPLER_TOO_EARLY 0x2
|
|
||||||
|
|
||||||
#define DVISAMPLER_DELAY_MASTER_CAL 0x01
|
|
||||||
#define DVISAMPLER_DELAY_MASTER_RST 0x02
|
|
||||||
#define DVISAMPLER_DELAY_SLAVE_CAL 0x04
|
|
||||||
#define DVISAMPLER_DELAY_SLAVE_RST 0x08
|
|
||||||
#define DVISAMPLER_DELAY_INC 0x10
|
|
||||||
#define DVISAMPLER_DELAY_DEC 0x20
|
|
||||||
|
|
||||||
#define DVISAMPLER_SLOT_EMPTY 0
|
|
||||||
#define DVISAMPLER_SLOT_LOADED 1
|
|
||||||
#define DVISAMPLER_SLOT_PENDING 2
|
|
||||||
|
|
||||||
#endif /* __HW_FLAGS_H */
|
|
|
@ -1,20 +0,0 @@
|
||||||
#ifndef __MICROUDP_H
|
|
||||||
#define __MICROUDP_H
|
|
||||||
|
|
||||||
#define IPTOINT(a, b, c, d) ((a << 24)|(b << 16)|(c << 8)|d)
|
|
||||||
|
|
||||||
#define MICROUDP_BUFSIZE (5*1532)
|
|
||||||
|
|
||||||
typedef void (*udp_callback)(unsigned int src_ip, unsigned short src_port, unsigned short dst_port, void *data, unsigned int length);
|
|
||||||
|
|
||||||
void microudp_start(const unsigned char *macaddr, unsigned int ip);
|
|
||||||
int microudp_arp_resolve(unsigned int ip);
|
|
||||||
void *microudp_get_tx_buffer(void);
|
|
||||||
int microudp_send(unsigned short src_port, unsigned short dst_port, unsigned int length);
|
|
||||||
void microudp_set_callback(udp_callback callback);
|
|
||||||
void microudp_service(void);
|
|
||||||
|
|
||||||
void eth_init(void);
|
|
||||||
void eth_mode(void);
|
|
||||||
|
|
||||||
#endif /* __MICROUDP_H */
|
|
|
@ -2,7 +2,7 @@ include ../include/generated/variables.mak
|
||||||
include $(SOC_DIRECTORY)/software/common.mak
|
include $(SOC_DIRECTORY)/software/common.mak
|
||||||
|
|
||||||
OBJECTS=exception.o libc.o errno.o crc16.o crc32.o console.o \
|
OBJECTS=exception.o libc.o errno.o crc16.o crc32.o console.o \
|
||||||
system.o id.o uart.o time.o qsort.o strtod.o spiflash.o spisdcard.o strcasecmp.o mdio.o
|
system.o id.o uart.o time.o qsort.o strtod.o spiflash.o strcasecmp.o
|
||||||
|
|
||||||
all: crt0-ctr.o crt0-xip.o libbase.a libbase-nofloat.a
|
all: crt0-ctr.o crt0-xip.o libbase.a libbase-nofloat.a
|
||||||
|
|
||||||
|
|
|
@ -6,8 +6,6 @@ void isr(void);
|
||||||
|
|
||||||
#ifdef __or1k__
|
#ifdef __or1k__
|
||||||
|
|
||||||
#include <hw/flags.h>
|
|
||||||
|
|
||||||
#define EXTERNAL_IRQ 0x8
|
#define EXTERNAL_IRQ 0x8
|
||||||
|
|
||||||
static void emerg_printf(const char *fmt, ...)
|
static void emerg_printf(const char *fmt, ...)
|
||||||
|
|
|
@ -1,64 +0,0 @@
|
||||||
INCLUDE generated/output_format.ld
|
|
||||||
ENTRY(_start)
|
|
||||||
|
|
||||||
__DYNAMIC = 0;
|
|
||||||
|
|
||||||
INCLUDE generated/regions.ld
|
|
||||||
|
|
||||||
SECTIONS
|
|
||||||
{
|
|
||||||
.text :
|
|
||||||
{
|
|
||||||
_ftext = .;
|
|
||||||
*(.text .stub .text.* .gnu.linkonce.t.*)
|
|
||||||
_etext = .;
|
|
||||||
} > main_ram
|
|
||||||
|
|
||||||
.got :
|
|
||||||
{
|
|
||||||
_GLOBAL_OFFSET_TABLE_ = .;
|
|
||||||
*(.got)
|
|
||||||
} > main_ram
|
|
||||||
|
|
||||||
.got.plt :
|
|
||||||
{
|
|
||||||
*(.got.plt)
|
|
||||||
} > main_ram
|
|
||||||
|
|
||||||
.rodata :
|
|
||||||
{
|
|
||||||
. = ALIGN(4);
|
|
||||||
_frodata = .;
|
|
||||||
*(.rodata .rodata.* .gnu.linkonce.r.*)
|
|
||||||
*(.rodata1)
|
|
||||||
_erodata = .;
|
|
||||||
} > main_ram
|
|
||||||
|
|
||||||
.data :
|
|
||||||
{
|
|
||||||
. = ALIGN(4);
|
|
||||||
_fdata = .;
|
|
||||||
*(.data .data.* .gnu.linkonce.d.*)
|
|
||||||
*(.data1)
|
|
||||||
*(.sdata .sdata.* .gnu.linkonce.s.*)
|
|
||||||
_edata = .;
|
|
||||||
} > main_ram
|
|
||||||
|
|
||||||
.bss :
|
|
||||||
{
|
|
||||||
. = ALIGN(4);
|
|
||||||
_fbss = .;
|
|
||||||
*(.dynsbss)
|
|
||||||
*(.sbss .sbss.* .gnu.linkonce.sb.*)
|
|
||||||
*(.scommon)
|
|
||||||
*(.dynbss)
|
|
||||||
*(.bss .bss.* .gnu.linkonce.b.*)
|
|
||||||
*(COMMON)
|
|
||||||
. = ALIGN(4);
|
|
||||||
_ebss = .;
|
|
||||||
. = ALIGN(8);
|
|
||||||
_heapstart = .;
|
|
||||||
} > main_ram
|
|
||||||
}
|
|
||||||
|
|
||||||
PROVIDE(_fstack = ORIGIN(main_ram) + LENGTH(main_ram) - 4);
|
|
|
@ -1,7 +1,6 @@
|
||||||
#include <uart.h>
|
#include <uart.h>
|
||||||
#include <irq.h>
|
#include <irq.h>
|
||||||
#include <generated/csr.h>
|
#include <generated/csr.h>
|
||||||
#include <hw/flags.h>
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Buffer sizes must be a power of 2 so that modulos can be computed
|
* Buffer sizes must be a power of 2 so that modulos can be computed
|
||||||
|
|
|
@ -1,17 +1,17 @@
|
||||||
include ../include/generated/variables.mak
|
include ../include/generated/variables.mak
|
||||||
include $(SOC_DIRECTORY)/software/common.mak
|
include $(SOC_DIRECTORY)/software/common.mak
|
||||||
|
|
||||||
OBJECTS=microudp.o tftp.o
|
OBJECTS=sdram.o
|
||||||
|
|
||||||
all: libnet.a
|
all: liblitedram.a
|
||||||
|
|
||||||
libnet.a: $(OBJECTS)
|
liblitedram.a: $(OBJECTS)
|
||||||
$(AR) crs libnet.a $(OBJECTS)
|
$(AR) crs liblitedram.a $(OBJECTS)
|
||||||
|
|
||||||
# pull in dependency info for *existing* .o files
|
# pull in dependency info for *existing* .o files
|
||||||
-include $(OBJECTS:.o=.d)
|
-include $(OBJECTS:.o=.d)
|
||||||
|
|
||||||
%.o: $(LIBNET_DIRECTORY)/%.c
|
%.o: $(LIBLITEDRAM_DIRECTORY)/%.c
|
||||||
$(compile)
|
$(compile)
|
||||||
|
|
||||||
%.o: %.S
|
%.o: %.S
|
||||||
|
@ -20,4 +20,4 @@ libnet.a: $(OBJECTS)
|
||||||
.PHONY: all clean
|
.PHONY: all clean
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
$(RM) $(OBJECTS) libnet.a .*~ *~
|
$(RM) $(OBJECTS) liblitedram.a .*~ *~
|
|
@ -17,7 +17,6 @@
|
||||||
#include <generated/sdram_phy.h>
|
#include <generated/sdram_phy.h>
|
||||||
#endif
|
#endif
|
||||||
#include <generated/mem.h>
|
#include <generated/mem.h>
|
||||||
#include <hw/flags.h>
|
|
||||||
#include <system.h>
|
#include <system.h>
|
||||||
|
|
||||||
#include "sdram.h"
|
#include "sdram.h"
|
|
@ -0,0 +1,23 @@
|
||||||
|
include ../include/generated/variables.mak
|
||||||
|
include $(SOC_DIRECTORY)/software/common.mak
|
||||||
|
|
||||||
|
OBJECTS=udp.o tftp.o mdio.o
|
||||||
|
|
||||||
|
all: libliteeth.a
|
||||||
|
|
||||||
|
libliteeth.a: $(OBJECTS)
|
||||||
|
$(AR) crs libliteeth.a $(OBJECTS)
|
||||||
|
|
||||||
|
# pull in dependency info for *existing* .o files
|
||||||
|
-include $(OBJECTS:.o=.d)
|
||||||
|
|
||||||
|
%.o: $(LIBLITEETH_DIRECTORY)/%.c
|
||||||
|
$(compile)
|
||||||
|
|
||||||
|
%.o: %.S
|
||||||
|
$(assemble)
|
||||||
|
|
||||||
|
.PHONY: all clean
|
||||||
|
|
||||||
|
clean:
|
||||||
|
$(RM) $(OBJECTS) libliteeth.a .*~ *~
|
|
@ -10,8 +10,8 @@
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include <net/microudp.h>
|
#include "udp.h"
|
||||||
#include <net/tftp.h>
|
#include "tftp.h"
|
||||||
|
|
||||||
/* Local TFTP client port (arbitrary) */
|
/* Local TFTP client port (arbitrary) */
|
||||||
#define PORT_IN 7642
|
#define PORT_IN 7642
|
||||||
|
@ -99,9 +99,9 @@ static void rx_callback(uint32_t src_ip, uint16_t src_port,
|
||||||
if(length < BLOCK_SIZE)
|
if(length < BLOCK_SIZE)
|
||||||
transfer_finished = 1;
|
transfer_finished = 1;
|
||||||
|
|
||||||
packet_data = microudp_get_tx_buffer();
|
packet_data = udp_get_tx_buffer();
|
||||||
length = format_ack(packet_data, block);
|
length = format_ack(packet_data, block);
|
||||||
microudp_send(PORT_IN, src_port, length);
|
udp_send(PORT_IN, src_port, length);
|
||||||
}
|
}
|
||||||
if(opcode == TFTP_ERROR) { /* Error */
|
if(opcode == TFTP_ERROR) { /* Error */
|
||||||
total_length = -1;
|
total_length = -1;
|
||||||
|
@ -118,10 +118,10 @@ int tftp_get(uint32_t ip, uint16_t server_port, const char *filename,
|
||||||
int length_before;
|
int length_before;
|
||||||
int spin = 0;
|
int spin = 0;
|
||||||
|
|
||||||
if(!microudp_arp_resolve(ip))
|
if(!udp_arp_resolve(ip))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
microudp_set_callback(rx_callback);
|
udp_set_callback(rx_callback);
|
||||||
|
|
||||||
dst_buffer = buffer;
|
dst_buffer = buffer;
|
||||||
|
|
||||||
|
@ -129,17 +129,17 @@ int tftp_get(uint32_t ip, uint16_t server_port, const char *filename,
|
||||||
transfer_finished = 0;
|
transfer_finished = 0;
|
||||||
tries = 5;
|
tries = 5;
|
||||||
while(1) {
|
while(1) {
|
||||||
packet_data = microudp_get_tx_buffer();
|
packet_data = udp_get_tx_buffer();
|
||||||
len = format_request(packet_data, TFTP_RRQ, filename);
|
len = format_request(packet_data, TFTP_RRQ, filename);
|
||||||
microudp_send(PORT_IN, server_port, len);
|
udp_send(PORT_IN, server_port, len);
|
||||||
for(i=0;i<2000000;i++) {
|
for(i=0;i<2000000;i++) {
|
||||||
microudp_service();
|
udp_service();
|
||||||
if((total_length > 0) || transfer_finished) break;
|
if((total_length > 0) || transfer_finished) break;
|
||||||
}
|
}
|
||||||
if((total_length > 0) || transfer_finished) break;
|
if((total_length > 0) || transfer_finished) break;
|
||||||
tries--;
|
tries--;
|
||||||
if(tries == 0) {
|
if(tries == 0) {
|
||||||
microudp_set_callback(NULL);
|
udp_set_callback(NULL);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -156,13 +156,13 @@ int tftp_get(uint32_t ip, uint16_t server_port, const char *filename,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(i-- == 0) {
|
if(i-- == 0) {
|
||||||
microudp_set_callback(NULL);
|
udp_set_callback(NULL);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
microudp_service();
|
udp_service();
|
||||||
}
|
}
|
||||||
|
|
||||||
microudp_set_callback(NULL);
|
udp_set_callback(NULL);
|
||||||
|
|
||||||
return total_length;
|
return total_length;
|
||||||
}
|
}
|
||||||
|
@ -175,23 +175,23 @@ int tftp_put(uint32_t ip, uint16_t server_port, const char *filename,
|
||||||
int i;
|
int i;
|
||||||
int block = 0, sent = 0;
|
int block = 0, sent = 0;
|
||||||
|
|
||||||
if(!microudp_arp_resolve(ip))
|
if(!udp_arp_resolve(ip))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
microudp_set_callback(rx_callback);
|
udp_set_callback(rx_callback);
|
||||||
|
|
||||||
packet_data = microudp_get_tx_buffer();
|
packet_data = udp_get_tx_buffer();
|
||||||
|
|
||||||
total_length = 0;
|
total_length = 0;
|
||||||
transfer_finished = 0;
|
transfer_finished = 0;
|
||||||
tries = 5;
|
tries = 5;
|
||||||
while(1) {
|
while(1) {
|
||||||
packet_data = microudp_get_tx_buffer();
|
packet_data = udp_get_tx_buffer();
|
||||||
len = format_request(packet_data, TFTP_WRQ, filename);
|
len = format_request(packet_data, TFTP_WRQ, filename);
|
||||||
microudp_send(PORT_IN, server_port, len);
|
udp_send(PORT_IN, server_port, len);
|
||||||
for(i=0;i<2000000;i++) {
|
for(i=0;i<2000000;i++) {
|
||||||
last_ack = -1;
|
last_ack = -1;
|
||||||
microudp_service();
|
udp_service();
|
||||||
if(last_ack == block)
|
if(last_ack == block)
|
||||||
goto send_data;
|
goto send_data;
|
||||||
if(transfer_finished)
|
if(transfer_finished)
|
||||||
|
@ -208,11 +208,11 @@ send_data:
|
||||||
send = sent+BLOCK_SIZE > size ? size-sent : BLOCK_SIZE;
|
send = sent+BLOCK_SIZE > size ? size-sent : BLOCK_SIZE;
|
||||||
tries = 5;
|
tries = 5;
|
||||||
while(1) {
|
while(1) {
|
||||||
packet_data = microudp_get_tx_buffer();
|
packet_data = udp_get_tx_buffer();
|
||||||
len = format_data(packet_data, block, buffer, send);
|
len = format_data(packet_data, block, buffer, send);
|
||||||
microudp_send(PORT_IN, data_port, len);
|
udp_send(PORT_IN, data_port, len);
|
||||||
for(i=0;i<12000000;i++) {
|
for(i=0;i<12000000;i++) {
|
||||||
microudp_service();
|
udp_service();
|
||||||
if(transfer_finished)
|
if(transfer_finished)
|
||||||
goto fail;
|
goto fail;
|
||||||
if(last_ack == block)
|
if(last_ack == block)
|
||||||
|
@ -226,11 +226,11 @@ next:
|
||||||
buffer += send;
|
buffer += send;
|
||||||
} while (send == BLOCK_SIZE);
|
} while (send == BLOCK_SIZE);
|
||||||
|
|
||||||
microudp_set_callback(NULL);
|
udp_set_callback(NULL);
|
||||||
|
|
||||||
return sent;
|
return sent;
|
||||||
|
|
||||||
fail:
|
fail:
|
||||||
microudp_set_callback(NULL);
|
udp_set_callback(NULL);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
|
@ -14,12 +14,11 @@
|
||||||
#include <inet.h>
|
#include <inet.h>
|
||||||
#include <system.h>
|
#include <system.h>
|
||||||
#include <crc.h>
|
#include <crc.h>
|
||||||
#include <hw/flags.h>
|
|
||||||
|
|
||||||
#include <net/microudp.h>
|
#include "udp.h"
|
||||||
|
|
||||||
//#define DEBUG_MICROUDP_TX
|
//#define DEBUG_UDP_TX
|
||||||
//#define DEBUG_MICROUDP_RX
|
//#define DEBUG_UDP_RX
|
||||||
|
|
||||||
#define ETHERTYPE_ARP 0x0806
|
#define ETHERTYPE_ARP 0x0806
|
||||||
#define ETHERTYPE_IP 0x0800
|
#define ETHERTYPE_IP 0x0800
|
||||||
|
@ -145,7 +144,7 @@ static void send_packet(void)
|
||||||
txlen += 4;
|
txlen += 4;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef DEBUG_MICROUDP_TX
|
#ifdef DEBUG_LITEETH_UDP_TX
|
||||||
int j;
|
int j;
|
||||||
printf(">>>> txlen : %d\n", txlen);
|
printf(">>>> txlen : %d\n", txlen);
|
||||||
for(j=0;j<txlen;j++)
|
for(j=0;j<txlen;j++)
|
||||||
|
@ -217,7 +216,7 @@ static void process_arp(void)
|
||||||
|
|
||||||
static const unsigned char broadcast[6] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
|
static const unsigned char broadcast[6] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
|
||||||
|
|
||||||
int microudp_arp_resolve(unsigned int ip)
|
int udp_arp_resolve(unsigned int ip)
|
||||||
{
|
{
|
||||||
struct arp_frame *arp;
|
struct arp_frame *arp;
|
||||||
int i;
|
int i;
|
||||||
|
@ -256,7 +255,7 @@ int microudp_arp_resolve(unsigned int ip)
|
||||||
|
|
||||||
/* Do we get a reply ? */
|
/* Do we get a reply ? */
|
||||||
for(timeout=0;timeout<100000;timeout++) {
|
for(timeout=0;timeout<100000;timeout++) {
|
||||||
microudp_service();
|
udp_service();
|
||||||
for(i=0;i<6;i++)
|
for(i=0;i<6;i++)
|
||||||
if(cached_mac[i]) return 1;
|
if(cached_mac[i]) return 1;
|
||||||
}
|
}
|
||||||
|
@ -288,7 +287,7 @@ static unsigned short ip_checksum(unsigned int r, void *buffer, unsigned int len
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
void *microudp_get_tx_buffer(void)
|
void *udp_get_tx_buffer(void)
|
||||||
{
|
{
|
||||||
return txbuffer->frame.contents.udp.payload;
|
return txbuffer->frame.contents.udp.payload;
|
||||||
}
|
}
|
||||||
|
@ -301,7 +300,7 @@ struct pseudo_header {
|
||||||
unsigned short length;
|
unsigned short length;
|
||||||
} __attribute__((packed));
|
} __attribute__((packed));
|
||||||
|
|
||||||
int microudp_send(unsigned short src_port, unsigned short dst_port, unsigned int length)
|
int udp_send(unsigned short src_port, unsigned short dst_port, unsigned int length)
|
||||||
{
|
{
|
||||||
struct pseudo_header h;
|
struct pseudo_header h;
|
||||||
unsigned int r;
|
unsigned int r;
|
||||||
|
@ -373,7 +372,7 @@ static void process_ip(void)
|
||||||
udp_ip->payload, ntohs(udp_ip->udp.length)-sizeof(struct udp_header));
|
udp_ip->payload, ntohs(udp_ip->udp.length)-sizeof(struct udp_header));
|
||||||
}
|
}
|
||||||
|
|
||||||
void microudp_set_callback(udp_callback callback)
|
void udp_set_callback(udp_callback callback)
|
||||||
{
|
{
|
||||||
rx_callback = callback;
|
rx_callback = callback;
|
||||||
}
|
}
|
||||||
|
@ -382,7 +381,7 @@ static void process_frame(void)
|
||||||
{
|
{
|
||||||
flush_cpu_dcache();
|
flush_cpu_dcache();
|
||||||
|
|
||||||
#ifdef DEBUG_MICROUDP_RX
|
#ifdef DEBUG_LITEETH_UDP_RX
|
||||||
int j;
|
int j;
|
||||||
printf("<<< rxlen : %d\n", rxlen);
|
printf("<<< rxlen : %d\n", rxlen);
|
||||||
for(j=0;j<rxlen;j++)
|
for(j=0;j<rxlen;j++)
|
||||||
|
@ -414,7 +413,7 @@ static void process_frame(void)
|
||||||
else if(ntohs(rxbuffer->frame.eth_header.ethertype) == ETHERTYPE_IP) process_ip();
|
else if(ntohs(rxbuffer->frame.eth_header.ethertype) == ETHERTYPE_IP) process_ip();
|
||||||
}
|
}
|
||||||
|
|
||||||
void microudp_start(const unsigned char *macaddr, unsigned int ip)
|
void udp_start(const unsigned char *macaddr, unsigned int ip)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
ethmac_sram_reader_ev_pending_write(ETHMAC_EV_SRAM_READER);
|
ethmac_sram_reader_ev_pending_write(ETHMAC_EV_SRAM_READER);
|
||||||
|
@ -437,7 +436,7 @@ void microudp_start(const unsigned char *macaddr, unsigned int ip)
|
||||||
rx_callback = (udp_callback)0;
|
rx_callback = (udp_callback)0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void microudp_service(void)
|
void udp_service(void)
|
||||||
{
|
{
|
||||||
if(ethmac_sram_writer_ev_pending_read() & ETHMAC_EV_SRAM_WRITER) {
|
if(ethmac_sram_writer_ev_pending_read() & ETHMAC_EV_SRAM_WRITER) {
|
||||||
rxslot = ethmac_sram_writer_slot_read();
|
rxslot = ethmac_sram_writer_slot_read();
|
|
@ -0,0 +1,23 @@
|
||||||
|
#ifndef __UDP_H
|
||||||
|
#define __UDP_H
|
||||||
|
|
||||||
|
#define ETHMAC_EV_SRAM_WRITER 0x1
|
||||||
|
#define ETHMAC_EV_SRAM_READER 0x1
|
||||||
|
|
||||||
|
#define IPTOINT(a, b, c, d) ((a << 24)|(b << 16)|(c << 8)|d)
|
||||||
|
|
||||||
|
#define UDP_BUFSIZE (5*1532)
|
||||||
|
|
||||||
|
typedef void (*udp_callback)(unsigned int src_ip, unsigned short src_port, unsigned short dst_port, void *data, unsigned int length);
|
||||||
|
|
||||||
|
void udp_start(const unsigned char *macaddr, unsigned int ip);
|
||||||
|
int udp_arp_resolve(unsigned int ip);
|
||||||
|
void *udp_get_tx_buffer(void);
|
||||||
|
int udp_send(unsigned short src_port, unsigned short dst_port, unsigned int length);
|
||||||
|
void udp_set_callback(udp_callback callback);
|
||||||
|
void udp_service(void);
|
||||||
|
|
||||||
|
void eth_init(void);
|
||||||
|
void eth_mode(void);
|
||||||
|
|
||||||
|
#endif /* __UDP_H */
|
|
@ -0,0 +1,23 @@
|
||||||
|
include ../include/generated/variables.mak
|
||||||
|
include $(SOC_DIRECTORY)/software/common.mak
|
||||||
|
|
||||||
|
OBJECTS=sdcard.o spisdcard.o
|
||||||
|
|
||||||
|
all: liblitesdcard.a
|
||||||
|
|
||||||
|
liblitesdcard.a: $(OBJECTS)
|
||||||
|
$(AR) crs liblitesdcard.a $(OBJECTS)
|
||||||
|
|
||||||
|
# pull in dependency info for *existing* .o files
|
||||||
|
-include $(OBJECTS:.o=.d)
|
||||||
|
|
||||||
|
%.o: $(LIBLITESDCARD_DIRECTORY)/%.c
|
||||||
|
$(compile)
|
||||||
|
|
||||||
|
%.o: %.S
|
||||||
|
$(assemble)
|
||||||
|
|
||||||
|
.PHONY: all clean
|
||||||
|
|
||||||
|
clean:
|
||||||
|
$(RM) $(OBJECTS) liblitesdcard.a .*~ *~
|
|
@ -10,7 +10,6 @@
|
||||||
|
|
||||||
#include <generated/csr.h>
|
#include <generated/csr.h>
|
||||||
#include <generated/mem.h>
|
#include <generated/mem.h>
|
||||||
#include <hw/flags.h>
|
|
||||||
#include <system.h>
|
#include <system.h>
|
||||||
|
|
||||||
#include "sdcard.h"
|
#include "sdcard.h"
|
|
@ -6,6 +6,10 @@
|
||||||
|
|
||||||
#include <generated/csr.h>
|
#include <generated/csr.h>
|
||||||
|
|
||||||
|
#define CLKGEN_STATUS_BUSY 0x1
|
||||||
|
#define CLKGEN_STATUS_PROGDONE 0x2
|
||||||
|
#define CLKGEN_STATUS_LOCKED 0x4
|
||||||
|
|
||||||
#ifdef CSR_SDCORE_BASE
|
#ifdef CSR_SDCORE_BASE
|
||||||
|
|
||||||
#define SD_OK 0
|
#define SD_OK 0
|
|
@ -26,7 +26,7 @@
|
||||||
|
|
||||||
#ifdef CSR_SPISDCARD_BASE
|
#ifdef CSR_SPISDCARD_BASE
|
||||||
// Import prototypes for the functions
|
// Import prototypes for the functions
|
||||||
#include <spisdcard.h>
|
#include "spisdcard.h"
|
||||||
|
|
||||||
// SPI
|
// SPI
|
||||||
// cs line - high to indicate DESELECT
|
// cs line - high to indicate DESELECT
|
Loading…
Reference in New Issue