From owner-svn-src-user@FreeBSD.ORG Fri Jan 18 12:58:11 2013 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 51FB171A; Fri, 18 Jan 2013 12:58:11 +0000 (UTC) (envelope-from sbruno@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 34B1B71B; Fri, 18 Jan 2013 12:58:11 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.5/8.14.5) with ESMTP id r0ICwB61095932; Fri, 18 Jan 2013 12:58:11 GMT (envelope-from sbruno@svn.freebsd.org) Received: (from sbruno@localhost) by svn.freebsd.org (8.14.5/8.14.5/Submit) id r0ICwAsu095930; Fri, 18 Jan 2013 12:58:10 GMT (envelope-from sbruno@svn.freebsd.org) Message-Id: <201301181258.r0ICwAsu095930@svn.freebsd.org> From: Sean Bruno Date: Fri, 18 Jan 2013 12:58:10 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r245602 - user/sbruno/pxestuff/sys/boot/i386/libi386 X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 18 Jan 2013 12:58:11 -0000 Author: sbruno Date: Fri Jan 18 12:58:10 2013 New Revision: 245602 URL: http://svnweb.freebsd.org/changeset/base/245602 Log: Adjust Makefile for my arbitrary rename of pxe_http -> pxehttp. Add more more merges from SOC pxe_http project into libi386 - this adds the theoretical ability to use pxehttp for the packet driver parts in libstand if the user does not want all of the wonderous http goodness. Modified: user/sbruno/pxestuff/sys/boot/i386/libi386/Makefile user/sbruno/pxestuff/sys/boot/i386/libi386/pxe.c Modified: user/sbruno/pxestuff/sys/boot/i386/libi386/Makefile ============================================================================== --- user/sbruno/pxestuff/sys/boot/i386/libi386/Makefile Fri Jan 18 11:45:14 2013 (r245601) +++ user/sbruno/pxestuff/sys/boot/i386/libi386/Makefile Fri Jan 18 12:58:10 2013 (r245602) @@ -42,13 +42,21 @@ CFLAGS+= -DSMBIOS_LITTLE_ENDIAN_UUID # Include simple terminal emulation (cons25-compatible) CFLAGS+= -DTERM_EMU +# Enable PXE debugging +#CDLAGS+= -DPXE_DEBUG + +# Allow pxe_http perform udpread/udpwrite +.if defined(PXEHTTP_UDP_FOR_LIBSTAND) +CFLAGS+= -DPXEHTTP_UDP_FOR_LIBSTAND +.endif + # XXX: make alloca() useable CFLAGS+= -Dalloca=__builtin_alloca CFLAGS+= -I${.CURDIR}/../../common -I${.CURDIR}/../common \ -I${.CURDIR}/../btx/lib \ -I${.CURDIR}/../../../contrib/dev/acpica/include \ - -I${.CURDIR}/../../.. -I. -I${.CURDIR}/../pxe_http/ + -I${.CURDIR}/../../.. -I. -I${.CURDIR}/../pxehttp/ # the location of libstand CFLAGS+= -I${.CURDIR}/../../../../lib/libstand/ Modified: user/sbruno/pxestuff/sys/boot/i386/libi386/pxe.c ============================================================================== --- user/sbruno/pxestuff/sys/boot/i386/libi386/pxe.c Fri Jan 18 11:45:14 2013 (r245601) +++ user/sbruno/pxestuff/sys/boot/i386/libi386/pxe.c Fri Jan 18 12:58:10 2013 (r245602) @@ -39,23 +39,32 @@ __FBSDID("$FreeBSD$"); #include #include +#ifdef LOADER_NFS_SUPPORT #include +#endif #include #include #include #include "btxv86.h" #include "pxe.h" +#include "pxe_core.h" +#include "pxe_dhcp.h" +#include "pxe_isr.h" +#include "pxe_ip.h" +#include "pxe_udp.h" +#define PXE_TFTP_BUFFER_SIZE 512 +#ifdef PXEHTTP_UDP_FOR_LIBSTAND /* * Allocate the PXE buffers statically instead of sticking grimy fingers into * BTX's private data area. The scratch buffer is used to send information to * the PXE BIOS, and the data buffer is used to receive data from the PXE BIOS. */ #define PXE_BUFFER_SIZE 0x2000 -#define PXE_TFTP_BUFFER_SIZE 512 static char scratch_buffer[PXE_BUFFER_SIZE]; static char data_buffer[PXE_BUFFER_SIZE]; +#endif static pxenv_t *pxenv_p = NULL; /* PXENV+ */ static pxe_t *pxe_p = NULL; /* !PXE */ @@ -159,6 +168,12 @@ pxe_enable(void *pxeinfo) static int pxe_init(void) { +#ifdef PXEHTTP_UDP_FOR_LIBSTAND + if (__pxe_nic_irq != 0) + return (2); + + return pxe_core_init(pxenv_p, pxe_p); +#else t_PXENV_GET_CACHED_INFO *gci_p; int counter; uint8_t checksum; @@ -243,6 +258,7 @@ pxe_init(void) bcopy(PTOV((gci_p->Buffer.segment << 4) + gci_p->Buffer.offset), &bootplayer, gci_p->BufferSize); return (1); +#endif } @@ -279,6 +295,13 @@ pxe_open(struct open_file *f, ...) printf("pxe_open: netif_open() succeeded\n"); } if (rootip.s_addr == 0) { +#ifdef PXEHTTP_UDP_FOR_LIBSTAND + gateip.s_addr = pxe_get_ip(PXE_IP_GATEWAY)->ip; + rootip.s_addr = pxe_get_ip(PXE_IP_ROOT)->ip; + netmask = pxe_get_ip(PXE_IP_NETMASK)->ip; + myip.s_addr = pxe_get_ip(PXE_IP_MY)->ip; + nameip.s_addr = pxe_get_ip(PXE_IP_NAMESERVER)->ip; +#else /* * Do a bootp/dhcp request to find out where our * NFS/TFTP server is. Even if we dont get back @@ -286,6 +309,7 @@ pxe_open(struct open_file *f, ...) * which brought us to life and a default rootpath. */ bootp(pxe_sock, BOOTP_PXE); +#endif if (rootip.s_addr == 0) rootip.s_addr = bootplayer.sip; if (!rootpath[0]) @@ -633,6 +657,27 @@ pxe_netif_put(struct iodesc *desc, void ssize_t sendudp(struct iodesc *h, void *pkt, size_t len) { +#ifdef PXEHTTP_UDP_FOR_LIBSTAND +#ifdef PXE_DEBUG_HELL + printf("sendudp(): sending %u bytes from me:%u -> %s:%u\n", + len, ntohs(h->myport), + inet_ntoa(h->destip), ntohs(h->destport)); +#endif /* PXE_DEBUG_HELL */ + void *ipdata = pkt - sizeof(PXE_UDP_PACKET); + + PXE_IPADDR dst; + dst.ip = h->destip.s_addr; + + if (!pxe_udp_send(ipdata, &dst, ntohs(h->destport), + ntohs(h->myport), len + sizeof(PXE_UDP_PACKET))) + { + printf("sendudp(): failed\n"); + return (-1); + } + + return (len); + +#else /* PXEHTTP_UDP_FOR_LIBSTAND */ t_PXENV_UDP_WRITE *udpwrite_p = (t_PXENV_UDP_WRITE *)scratch_buffer; bzero(udpwrite_p, sizeof(*udpwrite_p)); @@ -661,11 +706,34 @@ sendudp(struct iodesc *h, void *pkt, siz return -1; } return len; +#endif /* PXEHTTP_UDP_FOR_LIBSTATND */ } ssize_t readudp(struct iodesc *h, void *pkt, size_t len, time_t timeout) { +#ifdef PXEHTTP_UDP_FOR_LIBSTAND + PXE_UDP_DGRAM dgram; + struct udphdr *uh = (struct udphdr *) pkt - 1; + + /* process any queued incoming packets */ + pxe_core_recv_packets(); + + /* reading from default socket */ + int recv = pxe_udp_read(NULL, pkt, len, &dgram); + + if (recv == -1) { + printf("readudp(): failed\n"); + return (-1); + } +#ifdef PXE_DEBUG_HELL + printf("readudp(): received %d(%u/%u) bytes from %u port\n", + recv, len, dgram.size, dgram.src_port); +#endif + uh->uh_sport = htons(dgram.src_port); + + return (recv); +#else /* PXEHTTP_UDP_FOR_LIBSTAND */ t_PXENV_UDP_READ *udpread_p = (t_PXENV_UDP_READ *)scratch_buffer; struct udphdr *uh = NULL; @@ -693,4 +761,5 @@ readudp(struct iodesc *h, void *pkt, siz bcopy(data_buffer, pkt, udpread_p->buffer_size); uh->uh_sport = udpread_p->s_port; return udpread_p->buffer_size; +#endif /* PXEHTTP_UDP_FOR_LIBSTAND */ }