2 * Copyright (c) 2007, Takahide Matsutsuka.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above
11 * copyright notice, this list of conditions and the following
12 * disclaimer in the documentation and/or other materials provided
13 * with the distribution.
14 * 3. The name of the author may not be used to endorse or promote
15 * products derived from this software without specific prior
18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
19 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
22 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
24 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
26 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
27 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 * $Id: uip_arch.c,v 1.1 2009/09/08 20:07:35 zdshelby Exp $
35 * Z80 architecture-depend uip module
36 * for calculating checksums
38 * Takahide Matsutsuka <markn@markn.org>
44 static const u16_t sizeof_uip_ipaddr_t
= sizeof(uip_ipaddr_t
);
45 static const u16_t offset_tcpip_hdr_len
= offsetof(struct uip_tcpip_hdr
, len
);
46 static const u16_t offset_tcpip_hdr_srcipaddr
= offsetof(struct uip_tcpip_hdr
, srcipaddr
);
48 /*--------------------------------------------------------------------------*/
49 static void upper_layer_chksum() {
51 ;; ---------------------------------
52 ;; static u16_t
upper_layer_chksum(u8_t proto
);
56 ;; ---------------------------------
57 ;; HL
= BUF
= &uip_buf
[UIP_LLH_LEN
]
65 ld ix
, #_offset_tcpip_hdr_len
71 ;; DE
= upper layer length
80 jr nc
, _upper_layer_chksum_setlen2
82 _upper_layer_chksum_setlen2
:
84 ;; bc
= upper_leyer_len
+ proto
89 jr nc
, _upper_layer_chksum_setlen3
91 _upper_layer_chksum_setlen3
:
95 ld ix
, #_offset_tcpip_hdr_srcipaddr
101 ld ix
, #_sizeof_uip_ipaddr_t
110 call _uip_arch_chksum
; hl
= sum
114 ;; de is still stacked
121 _upper_layer_chksum_call
:
126 call _uip_arch_chksum
133 jr nz
, _upper_layer_htons
144 /*--------------------------------------------------------------------------*/
149 ;; ---------------------------------
150 ;; u16_t
uip_ipchksum(void);
154 ;; ---------------------------------
157 ;; HL
= BUF
= &uip_buf
[UIP_LLH_LEN
]
161 jp _upper_layer_chksum_call
165 /*--------------------------------------------------------------------------*/
168 uip_icmp6chksum(void)
171 ;; ---------------------------------
172 ;; u16_t
uip_icmp6chksum(void);
176 ;; ---------------------------------
177 ld c
, #UIP_PROTO_ICMP6
178 jp _upper_layer_chksum
181 #endif /* UIP_CONF_IPV6 */
183 /*--------------------------------------------------------------------------*/
188 ;; ---------------------------------
189 ;; u16_t
uip_tcpchksum(void);
193 ;; ---------------------------------
195 jp _upper_layer_chksum
199 /*--------------------------------------------------------------------------*/
205 ;; ---------------------------------
206 ;; u16_t
uip_udpchksum(void);
210 ;; ---------------------------------
212 jp _upper_layer_chksum
215 #endif /* UIP_UDP_CHKSUMS */
216 /*--------------------------------------------------------------------------*/