Skip to content

Commit

Permalink
software: put network code in a library
Browse files Browse the repository at this point in the history
  • Loading branch information
Sebastien Bourdeauducq committed Apr 30, 2013
1 parent 8222ee7 commit 2e3c261
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 8 deletions.
6 changes: 4 additions & 2 deletions software/bios/Makefile
@@ -1,7 +1,7 @@
M2DIR=../..
include $(M2DIR)/software/common.mak

OBJECTS=crt0.o isr.o sdram.o main.o microudp.o tftp.o boot-helper.o boot.o dataflow.o
OBJECTS=crt0.o isr.o sdram.o main.o boot-helper.o boot.o dataflow.o

all: bios.bin

Expand All @@ -19,9 +19,10 @@ bios-rescue.elf: linker-rescue.ld $(OBJECTS) libs

%.elf:
$(LD) $(LDFLAGS) -T $< -N -o $@ $(OBJECTS) \
-L$(M2DIR)/software/libnet \
-L$(M2DIR)/software/libbase \
-L$(M2DIR)/software/libcompiler-rt \
-lbase -lcompiler-rt
-lnet -lbase -lcompiler-rt
chmod -x $@

main.o: main.c
Expand All @@ -36,6 +37,7 @@ main.o: main.c
libs:
make -C $(M2DIR)/software/libcompiler-rt
make -C $(M2DIR)/software/libbase
make -C $(M2DIR)/software/libnet

flash: bios.bin
m1nor bios.bin
Expand Down
4 changes: 2 additions & 2 deletions software/bios/boot.c
Expand Up @@ -11,8 +11,8 @@

#include <hw/mem.h>

#include "microudp.h"
#include "tftp.h"
#include <net/microudp.h>
#include <net/tftp.h>
#include "boot.h"

extern int rescue;
Expand Down
2 changes: 1 addition & 1 deletion software/bios/main.c
Expand Up @@ -11,11 +11,11 @@
#include <timer.h>

#include <hw/mem.h>
#include <net/microudp.h>

#include "sdram.h"
#include "dataflow.h"
#include "boot.h"
#include "microudp.h"

enum {
CSR_IE = 1, CSR_IM, CSR_IP, CSR_ICC, CSR_DCC, CSR_CC, CSR_CFG, CSR_EBA,
Expand Down
File renamed without changes.
File renamed without changes.
24 changes: 24 additions & 0 deletions software/libnet/Makefile
@@ -0,0 +1,24 @@
M2DIR=../..
include $(M2DIR)/software/common.mak

OBJECTS=microudp.o tftp.o

all: libnet.a

# pull in dependency info for *existing* .o files
-include $(OBJECTS:.o=.d)

libnet.a: $(OBJECTS)
$(AR) clr libnet.a $(OBJECTS)
$(RANLIB) libnet.a

%.o: %.c
$(compile-dep)

%.o: %.S
$(assemble)

.PHONY: clean

clean:
rm -f $(OBJECTS) $(OBJECTS:.o=.ts) $(OBJECTS:.o=.d) libnet.a .*~ *~
2 changes: 1 addition & 1 deletion software/bios/microudp.c → software/libnet/microudp.c
Expand Up @@ -6,7 +6,7 @@
#include <hw/flags.h>
#include <hw/mem.h>

#include "microudp.h"
#include <net/microudp.h>

#define ETHERTYPE_ARP 0x0806
#define ETHERTYPE_IP 0x0800
Expand Down
4 changes: 2 additions & 2 deletions software/bios/tftp.c → software/libnet/tftp.c
@@ -1,8 +1,8 @@
#include <stdint.h>
#include <string.h>

#include "microudp.h"
#include "tftp.h"
#include <net/microudp.h>
#include <net/tftp.h>

#define PORT_OUT 69
#define PORT_IN 7642
Expand Down

0 comments on commit 2e3c261

Please sign in to comment.