summaryrefslogtreecommitdiffstats
path: root/app/Makefile
blob: dd4b6e7e608b3f3252a361c016d787c86a8aa307 (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
##
## This file is part of the libopencm3 project.
##
## Copyright (C) 2009 Uwe Hermann <uwe@hermann-uwe.de>
##
## This library is free software: you can redistribute it and/or modify
## it under the terms of the GNU Lesser General Public License as published by
## the Free Software Foundation, either version 3 of the License, or
## (at your option) any later version.
##
## This library is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
## GNU Lesser General Public License for more details.
##
## You should have received a copy of the GNU Lesser General Public License
## along with this library.  If not, see <http://www.gnu.org/licenses/>.
##

LDSCRIPT = ../arch_max.ld

CPROTO=cproto
PROG=msf

V=1
default: ${PROG}.elf

CSRCS=led.c ticker.c ring.c usart.c stdio.c lwip_glue.c steth.c msf.c abs.c pll.c main.c time_fn.c ntp.c dcf77.c util.c stats.c gps.c hexdump.c bits.c debug_eth.c
HSRCS=project.h ring.h pins.h gps.h ubx.h




LWIP=lwip/lwip-1.4.1
LWIP_PATH=..

VPATH=${LWIP_PATH}

LWIP_API=#${LWIP}/src/api/err.c ${LWIP}/src/api/netdb.c ${LWIP}/src/api/api_msg.c ${LWIP}/src/api/tcpip.c ${LWIP}/src/api/sockets.c ${LWIP}/src/api/api_lib.c ${LWIP}/src/api/netbuf.c ${LWIP}/src/api/netifapi.c
LWIP_CORE=${LWIP}/src/core/memp.c ${LWIP}/src/core/sys.c ${LWIP}/src/core/init.c ${LWIP}/src/core/pbuf.c ${LWIP}/src/core/dhcp.c ${LWIP}/src/core/ipv4/ip_addr.c ${LWIP}/src/core/ipv4/ip.c ${LWIP}/src/core/ipv4/ip_frag.c ${LWIP}/src/core/ipv4/inet.c ${LWIP}/src/core/ipv4/autoip.c ${LWIP}/src/core/ipv4/icmp.c ${LWIP}/src/core/ipv4/inet_chksum.c ${LWIP}/src/core/timers.c ${LWIP}/src/core/def.c  ${LWIP}/src/core/netif.c  ${LWIP}/src/netif/etharp.c ${LWIP}/src/core/raw.c ${LWIP}/src/core/mem.c  ${LWIP}/src/core/udp.c

DEFINES=#
#${LWIP}/src/core/tcp.c ${LWIP}/src/core/tcp_out.c #${LWIP}/src/core/tcp_in.c 

# ${LWIP}/src/core/snmp/asn1_enc.c ${LWIP}/src/core/snmp/msg_in.c ${LWIP}/src/core/snmp/mib_structs.c ${LWIP}/src/core/snmp/mib2.c ${LWIP}/src/core/snmp/asn1_dec.c ${LWIP}/src/core/snmp/msg_out.c ${LWIP}/src/core/ipv6/icmp6.c ${LWIP}/src/core/ipv6/ip6.c ${LWIP}/src/core/ipv6/ip6_addr.c ${LWIP}/src/core/ipv6/inet6.c 
# ${LWIP}/src/core/dns.c ${LWIP}/src/core/stats.c ${LWIP}/src/core/ipv4/igmp.c 


LWIP_INC=${LWIP_PATH}/${LWIP}
LWIP_LOCAL=${LWIP_PATH}/lwip/lwip-local


LWIP_CSRCS=${LWIP_API} ${LWIP_CORE}
EXTRA_CLEAN=${LWIP}


BINARY = ${PROG}
MYOBJS = ${CSRCS:%.c=%.o} 
LWIP_OBJS = ${LWIP_CSRCS:%.c=%.o}

objs:${OBJS} 

${MYOBJS}: project.h prototypes.h
${LWIP_OBJS}: lwip/lwipopts.h

OBJS=${MYOBJS} ${LWIP_OBJS} almanac.o

include ../Makefile.include

CFLAGS+=-Wno-redundant-decls -Wno-unused-parameter
CPPFLAGS        += -I../libopencm3-local  -I${LWIP_PATH}/${LWIP}/src/include -Ilwip -I${LWIP_PATH}/${LWIP}/src/include/ipv4 -I${LWIP_LOCAL}/port/stm32f4x7 -I.

fish: ${OBJS}
	echo ${OBJS}

program: ${PROG}.hex
	echo init | nc -t localhost 4444
	echo reset init | nc -t localhost 4444
	echo flash write_image erase ${PWD}/$< | nc -t localhost 4444
	echo reset run | nc -t localhost 4444

ds:
	$(Q)$(OOCD) -f ../oocd/interface/$(OOCD_INTERFACE).cfg \
		-f ../oocd/board/$(OOCD_BOARD).cfg

debug: ${PROG}.elf
	${PREFIX}-gdb -x gdb.script ${PROG}.elf 

#	openocd

protos: ${CSRCS} 
	echo -n > prototypes.h
	${CPROTO} -E "${CPP} $(CPPFLAGS)" -e -v ${CSRCS} > prototypes.h.tmp
	mv -f prototypes.h.tmp prototypes.h

almanac.c:almanac.alp
	echo const > $@
	xxd -i $< >> $@

almanac.alp: almanac

almanac:
	wget -O almanac.alp http://alp.u-blox.com/current_7d.alp


EXTRA_CLEAN=${OBJS} ${LWIP_OBJS:%.o=%.d} almanac.c

tidy:
	astyle -A3 -s2 --attach-extern-c -L -c -w -Y -m0 -f -p  -H -U -k3 -xj -xd ${CSRCS} ${HSRCS} 
t gnttab_setup_table *setup; struct gnttab_transfer *xfer; struct gnttab_copy *copy; } nat; union { struct compat_gnttab_setup_table setup; struct compat_gnttab_transfer xfer; struct compat_gnttab_copy copy; } cmp; set_xen_guest_handle(nat.uop, (void *)COMPAT_ARG_XLAT_VIRT_START(current->vcpu_id)); switch ( cmd ) { case GNTTABOP_setup_table: if ( unlikely(count > 1) ) rc = -EINVAL; else if ( unlikely(__copy_from_guest(&cmp.setup, cmp_uop, 1)) ) rc = -EFAULT; else if ( unlikely(!compat_handle_okay(cmp.setup.frame_list, cmp.setup.nr_frames)) ) rc = -EFAULT; else { BUG_ON((COMPAT_ARG_XLAT_SIZE - sizeof(*nat.setup)) / sizeof(*nat.setup->frame_list.p) < max_nr_grant_frames); #define XLAT_gnttab_setup_table_HNDL_frame_list(_d_, _s_) \ set_xen_guest_handle((_d_)->frame_list, (unsigned long *)(nat.setup + 1)) XLAT_gnttab_setup_table(nat.setup, &cmp.setup); #undef XLAT_gnttab_setup_table_HNDL_frame_list rc = gnttab_setup_table(guest_handle_cast(nat.uop, gnttab_setup_table_t), 1); } if ( rc == 0 ) { #define XLAT_gnttab_setup_table_HNDL_frame_list(_d_, _s_) \ do \ { \ if ( (_s_)->status == GNTST_okay ) \ { \ for ( i = 0; i < (_s_)->nr_frames; ++i ) \ { \ unsigned int frame = (_s_)->frame_list.p[i]; \ BUG_ON(frame != (_s_)->frame_list.p[i]); \ (void)__copy_to_compat_offset((_d_)->frame_list, i, &frame, 1); \ } \ } \ } while (0) XLAT_gnttab_setup_table(&cmp.setup, nat.setup); #undef XLAT_gnttab_setup_table_HNDL_frame_list if ( unlikely(__copy_to_guest(cmp_uop, &cmp.setup, 1)) ) rc = -EFAULT; else i = 1; } break; case GNTTABOP_transfer: for ( n = 0; n < COMPAT_ARG_XLAT_SIZE / sizeof(*nat.xfer) && i < count && rc == 0; ++i, ++n ) { if ( unlikely(__copy_from_guest_offset(&cmp.xfer, cmp_uop, i, 1)) ) rc = -EFAULT; else { XLAT_gnttab_transfer(nat.xfer + n, &cmp.xfer); } } if ( rc == 0 ) rc = gnttab_transfer(guest_handle_cast(nat.uop, gnttab_transfer_t), n); if ( rc == 0 ) { XEN_GUEST_HANDLE(gnttab_transfer_compat_t) xfer; xfer = guest_handle_cast(cmp_uop, gnttab_transfer_compat_t); guest_handle_add_offset(xfer, i); while ( n-- ) { guest_handle_add_offset(xfer, -1); if ( __copy_field_to_guest(xfer, nat.xfer, status) ) rc = -EFAULT; } } break; case GNTTABOP_copy: for ( n = 0; n < COMPAT_ARG_XLAT_SIZE / sizeof(*nat.copy) && i < count && rc == 0; ++i, ++n ) { if ( unlikely(__copy_from_guest_offset(&cmp.copy, cmp_uop, i, 1)) ) rc = -EFAULT; else { enum XLAT_gnttab_copy_source_u source_u; enum XLAT_gnttab_copy_dest_u dest_u; if ( cmp.copy.flags & GNTCOPY_source_gref ) source_u = XLAT_gnttab_copy_source_u_ref; else source_u = XLAT_gnttab_copy_source_u_gmfn; if ( cmp.copy.flags & GNTCOPY_dest_gref ) dest_u = XLAT_gnttab_copy_dest_u_ref; else dest_u = XLAT_gnttab_copy_dest_u_gmfn; XLAT_gnttab_copy(nat.copy + n, &cmp.copy); } } if ( rc == 0 ) rc = gnttab_copy(guest_handle_cast(nat.uop, gnttab_copy_t), n); if ( rc == 0 ) { XEN_GUEST_HANDLE(gnttab_copy_compat_t) copy; copy = guest_handle_cast(cmp_uop, gnttab_copy_compat_t); guest_handle_add_offset(copy, i); while ( n-- ) { guest_handle_add_offset(copy, -1); if ( __copy_field_to_guest(copy, nat.copy, status) ) rc = -EFAULT; } } break; default: domain_crash(current->domain); break; } } return rc; } /* * Local variables: * mode: C * c-set-style: "BSD" * c-basic-offset: 4 * tab-width: 4 * indent-tabs-mode: nil * End: */