Date: Thu, 9 Mar 2017 05:13:08 +0000 (UTC) From: Mariusz Zaborski <oshogbo@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r314945 - head/sys/boot/i386/libi386 Message-ID: <201703090513.v295D8QT061407@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: oshogbo Date: Thu Mar 9 05:13:07 2017 New Revision: 314945 URL: https://svnweb.freebsd.org/changeset/base/314945 Log: Some style(9) fixes. No functional changes. Submitted by: kczekirda Sponsored by: Oktawave MFC after: 3 weeks Differential Revision: https://reviews.freebsd.org/D9395 Modified: head/sys/boot/i386/libi386/pxe.c Modified: head/sys/boot/i386/libi386/pxe.c ============================================================================== --- head/sys/boot/i386/libi386/pxe.c Thu Mar 9 04:20:00 2017 (r314944) +++ head/sys/boot/i386/libi386/pxe.c Thu Mar 9 05:13:07 2017 (r314945) @@ -49,7 +49,7 @@ __FBSDID("$FreeBSD$"); /* * 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 + * 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 @@ -57,11 +57,11 @@ __FBSDID("$FreeBSD$"); static char scratch_buffer[PXE_BUFFER_SIZE]; static char data_buffer[PXE_BUFFER_SIZE]; -static pxenv_t *pxenv_p = NULL; /* PXENV+ */ -static pxe_t *pxe_p = NULL; /* !PXE */ -static BOOTPLAYER bootplayer; /* PXE Cached information. */ +static pxenv_t *pxenv_p = NULL; /* PXENV+ */ +static pxe_t *pxe_p = NULL; /* !PXE */ +static BOOTPLAYER bootplayer; /* PXE Cached information. */ -static int pxe_debug = 0; +static int pxe_debug = 0; static int pxe_sock = -1; static int pxe_opens = 0; @@ -72,7 +72,7 @@ static void bangpxe_call(int func); static int pxe_init(void); static int pxe_strategy(void *devdata, int flag, daddr_t dblk, - size_t size, char *buf, size_t *rsize); + size_t size, char *buf, size_t *rsize); static int pxe_open(struct open_file *f, ...); static int pxe_close(struct open_file *f); static int pxe_print(int verbose); @@ -84,7 +84,7 @@ static int pxe_netif_match(struct netif static int pxe_netif_probe(struct netif *nif, void *machdep_hint); static void pxe_netif_init(struct iodesc *desc, void *machdep_hint); static int pxe_netif_get(struct iodesc *desc, void *pkt, size_t len, - time_t timeout); + time_t timeout); static int pxe_netif_put(struct iodesc *desc, void *pkt, size_t len); static void pxe_netif_end(struct netif *nif); @@ -103,7 +103,7 @@ extern u_int16_t __pxenvoff; extern void __pxenventry(void); struct netif_dif pxe_ifs[] = { -/* dif_unit dif_nsel dif_stats dif_private */ +/* dif_unit dif_nsel dif_stats dif_private */ {0, 1, &pxe_st[0], 0} }; @@ -127,12 +127,12 @@ struct netif_driver *netif_drivers[] = { }; struct devsw pxedisk = { - "pxe", + "pxe", DEVT_NET, pxe_init, - pxe_strategy, - pxe_open, - pxe_close, + pxe_strategy, + pxe_open, + pxe_close, noioctl, pxe_print, pxe_cleanup @@ -140,8 +140,8 @@ struct devsw pxedisk = { /* * This function is called by the loader to enable PXE support if we - * are booted by PXE. The passed in pointer is a pointer to the - * PXENV+ structure. + * are booted by PXE. The passed in pointer is a pointer to the PXENV+ + * structure. */ void pxe_enable(void *pxeinfo) @@ -152,22 +152,22 @@ pxe_enable(void *pxeinfo) pxe_call = NULL; } -/* +/* * return true if pxe structures are found/initialized, - * also figures out our IP information via the pxe cached info struct + * also figures out our IP information via the pxe cached info struct */ static int pxe_init(void) { - t_PXENV_GET_CACHED_INFO *gci_p; - int counter; + t_PXENV_GET_CACHED_INFO *gci_p; + int counter; uint8_t checksum; uint8_t *checkptr; - - if(pxenv_p == NULL) + + if (pxenv_p == NULL) return (0); - /* look for "PXENV+" */ + /* look for "PXENV+" */ if (bcmp((void *)pxenv_p->Signature, S_SIZE("PXENV+"))) { pxenv_p = NULL; return (0); @@ -175,16 +175,16 @@ pxe_init(void) /* make sure the size is something we can handle */ if (pxenv_p->Length > sizeof(*pxenv_p)) { - printf("PXENV+ structure too large, ignoring\n"); + printf("PXENV+ structure too large, ignoring\n"); pxenv_p = NULL; return (0); } - - /* + + /* * do byte checksum: * add up each byte in the structure, the total should be 0 */ - checksum = 0; + checksum = 0; checkptr = (uint8_t *) pxenv_p; for (counter = 0; counter < pxenv_p->Length; counter++) checksum += *checkptr++; @@ -194,7 +194,6 @@ pxe_init(void) return (0); } - /* * PXENV+ passed, so use that if !PXE is not available or * the checksum fails. @@ -209,7 +208,7 @@ pxe_init(void) checksum = 0; checkptr = (uint8_t *)pxe_p; for (counter = 0; counter < pxe_p->StructLength; - counter++) + counter++) checksum += *checkptr++; if (checksum != 0) { pxe_p = NULL; @@ -221,19 +220,19 @@ pxe_init(void) } printf("\nPXE version %d.%d, real mode entry point ", - (uint8_t) (pxenv_p->Version >> 8), - (uint8_t) (pxenv_p->Version & 0xFF)); + (uint8_t) (pxenv_p->Version >> 8), + (uint8_t) (pxenv_p->Version & 0xFF)); if (pxe_call == bangpxe_call) printf("@%04x:%04x\n", - pxe_p->EntryPointSP.segment, - pxe_p->EntryPointSP.offset); + pxe_p->EntryPointSP.segment, + pxe_p->EntryPointSP.offset); else printf("@%04x:%04x\n", - pxenv_p->RMEntry.segment, pxenv_p->RMEntry.offset); + pxenv_p->RMEntry.segment, pxenv_p->RMEntry.offset); gci_p = (t_PXENV_GET_CACHED_INFO *) scratch_buffer; bzero(gci_p, sizeof(*gci_p)); - gci_p->PacketType = PXENV_PACKET_TYPE_BINL_REPLY; + gci_p->PacketType = PXENV_PACKET_TYPE_BINL_REPLY; pxe_call(PXENV_GET_CACHED_INFO); if (gci_p->Status != 0) { pxe_perror(gci_p->Status); @@ -241,7 +240,7 @@ pxe_init(void) return (0); } bcopy(PTOV((gci_p->Buffer.segment << 4) + gci_p->Buffer.offset), - &bootplayer, gci_p->BufferSize); + &bootplayer, gci_p->BufferSize); return (1); } @@ -256,94 +255,94 @@ pxe_strategy(void *devdata, int flag, da static int pxe_open(struct open_file *f, ...) { - va_list args; - char *devname; /* Device part of file name (or NULL). */ - char temp[FNAME_SIZE]; - int error = 0; - int i; - - va_start(args, f); - devname = va_arg(args, char*); - va_end(args); - - /* On first open, do netif open, mount, etc. */ - if (pxe_opens == 0) { - /* Find network interface. */ - if (pxe_sock < 0) { - pxe_sock = netif_open(devname); - if (pxe_sock < 0) { - printf("pxe_open: netif_open() failed\n"); - return (ENXIO); - } - if (pxe_debug) - printf("pxe_open: netif_open() succeeded\n"); - } - if (rootip.s_addr == 0) { - /* - * Do a bootp/dhcp request to find out where our - * NFS/TFTP server is. Even if we dont get back - * the proper information, fall back to the server - * which brought us to life and a default rootpath. - */ - bootp(pxe_sock, BOOTP_PXE); - if (rootip.s_addr == 0) - rootip.s_addr = bootplayer.sip; - - netproto = NET_NFS; - if (tftpip.s_addr != 0) { - netproto = NET_TFTP; - rootip.s_addr = tftpip.s_addr; + va_list args; + char *devname; /* Device part of file name (or NULL). */ + char temp[FNAME_SIZE]; + int error = 0; + int i; + + va_start(args, f); + devname = va_arg(args, char*); + va_end(args); + + /* On first open, do netif open, mount, etc. */ + if (pxe_opens == 0) { + /* Find network interface. */ + if (pxe_sock < 0) { + pxe_sock = netif_open(devname); + if (pxe_sock < 0) { + printf("pxe_open: netif_open() failed\n"); + return (ENXIO); + } + if (pxe_debug) + printf("pxe_open: netif_open() succeeded\n"); } + if (rootip.s_addr == 0) { + /* + * Do a bootp/dhcp request to find out where our + * NFS/TFTP server is. Even if we dont get back + * the proper information, fall back to the server + * which brought us to life and a default rootpath. + */ + bootp(pxe_sock, BOOTP_PXE); + if (rootip.s_addr == 0) + rootip.s_addr = bootplayer.sip; + + netproto = NET_NFS; + if (tftpip.s_addr != 0) { + netproto = NET_TFTP; + rootip.s_addr = tftpip.s_addr; + } - if (netproto == NET_NFS && !rootpath[0]) - strcpy(rootpath, PXENFSROOTPATH); + if (netproto == NET_NFS && !rootpath[0]) + strcpy(rootpath, PXENFSROOTPATH); - for (i = 0; rootpath[i] != '\0' && i < FNAME_SIZE; i++) - if (rootpath[i] == ':') - break; - if (i && i != FNAME_SIZE && rootpath[i] == ':') { - rootpath[i++] = '\0'; - if (inet_addr(&rootpath[0]) != INADDR_NONE) - rootip.s_addr = inet_addr(&rootpath[0]); - bcopy(&rootpath[i], &temp[0], strlen(&rootpath[i])+1); - bcopy(&temp[0], &rootpath[0], strlen(&rootpath[i])+1); - } - setenv("boot.netif.ip", inet_ntoa(myip), 1); - setenv("boot.netif.netmask", intoa(netmask), 1); - setenv("boot.netif.gateway", inet_ntoa(gateip), 1); - setenv("boot.netif.server", inet_ntoa(rootip), 1); - if (bootplayer.Hardware == ETHER_TYPE) { - sprintf(temp, "%6D", bootplayer.CAddr, ":"); - setenv("boot.netif.hwaddr", temp, 1); - } - if (intf_mtu != 0) { - char mtu[16]; - sprintf(mtu, "%u", intf_mtu); - setenv("boot.netif.mtu", mtu, 1); - } - printf("pxe_open: server addr: %s\n", inet_ntoa(rootip)); - printf("pxe_open: server path: %s\n", rootpath); - printf("pxe_open: gateway ip: %s\n", inet_ntoa(gateip)); - - if (netproto == NET_TFTP) { - setenv("boot.tftproot.server", inet_ntoa(rootip), 1); - setenv("boot.tftproot.path", rootpath, 1); - } else if (netproto == NET_NFS) { - setenv("boot.nfsroot.server", inet_ntoa(rootip), 1); - setenv("boot.nfsroot.path", rootpath, 1); - } - setenv("dhcp.host-name", hostname, 1); + for (i = 0; rootpath[i] != '\0' && i < FNAME_SIZE; i++) + if (rootpath[i] == ':') + break; + if (i && i != FNAME_SIZE && rootpath[i] == ':') { + rootpath[i++] = '\0'; + if (inet_addr(&rootpath[0]) != INADDR_NONE) + rootip.s_addr = inet_addr(&rootpath[0]); + bcopy(&rootpath[i], &temp[0], strlen(&rootpath[i]) + 1); + bcopy(&temp[0], &rootpath[0], strlen(&rootpath[i]) + 1); + } + setenv("boot.netif.ip", inet_ntoa(myip), 1); + setenv("boot.netif.netmask", intoa(netmask), 1); + setenv("boot.netif.gateway", inet_ntoa(gateip), 1); + setenv("boot.netif.server", inet_ntoa(rootip), 1); + if (bootplayer.Hardware == ETHER_TYPE) { + sprintf(temp, "%6D", bootplayer.CAddr, ":"); + setenv("boot.netif.hwaddr", temp, 1); + } + if (intf_mtu != 0) { + char mtu[16]; + sprintf(mtu, "%u", intf_mtu); + setenv("boot.netif.mtu", mtu, 1); + } + printf("pxe_open: server addr: %s\n", inet_ntoa(rootip)); + printf("pxe_open: server path: %s\n", rootpath); + printf("pxe_open: gateway ip: %s\n", inet_ntoa(gateip)); + + if (netproto == NET_TFTP) { + setenv("boot.tftproot.server", inet_ntoa(rootip), 1); + setenv("boot.tftproot.path", rootpath, 1); + } else if (netproto == NET_NFS) { + setenv("boot.nfsroot.server", inet_ntoa(rootip), 1); + setenv("boot.nfsroot.path", rootpath, 1); + } + setenv("dhcp.host-name", hostname, 1); - setenv("pxeboot.ip", inet_ntoa(myip), 1); - if (bootplayer.Hardware == ETHER_TYPE) { - sprintf(temp, "%6D", bootplayer.CAddr, ":"); - setenv("pxeboot.hwaddr", temp, 1); + setenv("pxeboot.ip", inet_ntoa(myip), 1); + if (bootplayer.Hardware == ETHER_TYPE) { + sprintf(temp, "%6D", bootplayer.CAddr, ":"); + setenv("pxeboot.hwaddr", temp, 1); + } } } - } - pxe_opens++; - f->f_devdata = &pxe_sock; - return (error); + pxe_opens++; + f->f_devdata = &pxe_sock; + return (error); } static int @@ -351,35 +350,35 @@ pxe_close(struct open_file *f) { #ifdef PXE_DEBUG - if (pxe_debug) - printf("pxe_close: opens=%d\n", pxe_opens); + if (pxe_debug) + printf("pxe_close: opens=%d\n", pxe_opens); #endif - /* On last close, do netif close, etc. */ - f->f_devdata = NULL; - /* Extra close call? */ - if (pxe_opens <= 0) - return (0); - pxe_opens--; - /* Not last close? */ - if (pxe_opens > 0) - return(0); - - if (netproto == NET_NFS) { - /* get an NFS filehandle for our root filesystem */ - pxe_setnfshandle(rootpath); - } + /* On last close, do netif close, etc. */ + f->f_devdata = NULL; + /* Extra close call? */ + if (pxe_opens <= 0) + return (0); + pxe_opens--; + /* Not last close? */ + if (pxe_opens > 0) + return (0); + + if (netproto == NET_NFS) { + /* get an NFS filehandle for our root filesystem */ + pxe_setnfshandle(rootpath); + } - if (pxe_sock >= 0) { + if (pxe_sock >= 0) { #ifdef PXE_DEBUG if (pxe_debug) - printf("pxe_close: calling netif_close()\n"); + printf("pxe_close: calling netif_close()\n"); #endif netif_close(pxe_sock); pxe_sock = -1; - } - return (0); + } + return (0); } static int @@ -406,9 +405,9 @@ pxe_cleanup(void) { #ifdef PXE_DEBUG t_PXENV_UNLOAD_STACK *unload_stack_p = - (t_PXENV_UNLOAD_STACK *)scratch_buffer; + (t_PXENV_UNLOAD_STACK *)scratch_buffer; t_PXENV_UNDI_SHUTDOWN *undi_shutdown_p = - (t_PXENV_UNDI_SHUTDOWN *)scratch_buffer; + (t_PXENV_UNDI_SHUTDOWN *)scratch_buffer; #endif if (pxe_call == NULL) @@ -419,12 +418,12 @@ pxe_cleanup(void) #ifdef PXE_DEBUG if (pxe_debug && undi_shutdown_p->Status != 0) printf("pxe_cleanup: UNDI_SHUTDOWN failed %x\n", - undi_shutdown_p->Status); + undi_shutdown_p->Status); #endif pxe_call(PXENV_UNLOAD_STACK); -#ifdef PXE_DEBUG +#ifdef PXE_DEBUG if (pxe_debug && unload_stack_p->Status != 0) printf("pxe_cleanup: UNLOAD_STACK failed %x\n", unload_stack_p->Status); @@ -449,19 +448,19 @@ struct nfs_iodesc { /* structure truncated here */ }; extern struct nfs_iodesc nfs_root_node; -extern int rpc_port; +extern int rpc_port; static void pxe_rpcmountcall() { struct iodesc *d; - int error; + int error; if (!(d = socktodesc(pxe_sock))) return; - d->myport = htons(--rpc_port); - d->destip = rootip; - if ((error = nfs_getrootfh(d, rootpath, nfs_root_node.fh)) != 0) + d->myport = htons(--rpc_port); + d->destip = rootip; + if ((error = nfs_getrootfh(d, rootpath, nfs_root_node.fh)) != 0) printf("NFS MOUNT RPC error: %d\n", error); nfs_root_node.iodesc = d; } @@ -511,10 +510,10 @@ pxe_rpcmountcall() if (!(d = socktodesc(pxe_sock))) return; - d->myport = htons(--rpc_port); - d->destip = rootip; + d->myport = htons(--rpc_port); + d->destip = rootip; if ((error = nfs_getrootfh(d, rootpath, &nfs_root_node.fhsize, - nfs_root_node.fh)) != 0) { + nfs_root_node.fh)) != 0) { printf("NFS MOUNT RPC error: %d\n", error); nfs_root_node.fhsize = 0; } @@ -578,13 +577,13 @@ bangpxe_call(int func) if (pxe_debug) printf("bangpxe_call %x\n", func); #endif - + bzero(&v86, sizeof(v86)); bzero(data_buffer, sizeof(data_buffer)); __bangpxeseg = pxe_p->EntryPointSP.segment; __bangpxeoff = pxe_p->EntryPointSP.offset; - + v86.ctl = V86_ADDR | V86_CALLF | V86_FLAGS; v86.edx = VTOPSEG(scratch_buffer); v86.eax = VTOPOFF(scratch_buffer); @@ -594,7 +593,6 @@ bangpxe_call(int func) v86.ctl = V86_FLAGS; } - time_t getsecs(void) { @@ -609,7 +607,6 @@ pxe_netif_match(struct netif *nif, void return 1; } - static int pxe_netif_probe(struct netif *nif, void *machdep_hint) { @@ -666,7 +663,7 @@ sendudp(struct iodesc *h, void *pkt, siz { t_PXENV_UDP_WRITE *udpwrite_p = (t_PXENV_UDP_WRITE *)scratch_buffer; bzero(udpwrite_p, sizeof(*udpwrite_p)); - + udpwrite_p->ip = h->destip.s_addr; udpwrite_p->dst_port = h->destport; udpwrite_p->src_port = h->myport; @@ -686,7 +683,7 @@ sendudp(struct iodesc *h, void *pkt, siz delay(1000); #endif if (udpwrite_p->status != 0) { - /* XXX: This happens a lot. It shouldn't. */ + /* XXX: This happens a lot. It shouldn't. */ if (udpwrite_p->status != 1) printf("sendudp failed %x\n", udpwrite_p->status); return -1; @@ -699,10 +696,10 @@ readudp(struct iodesc *h, void *pkt, siz { t_PXENV_UDP_READ *udpread_p = (t_PXENV_UDP_READ *)scratch_buffer; struct udphdr *uh = NULL; - + uh = (struct udphdr *) pkt - 1; bzero(udpread_p, sizeof(*udpread_p)); - + udpread_p->dest_ip = h->myip.s_addr; udpread_p->d_port = h->myport; udpread_p->buffer_size = len; @@ -716,7 +713,7 @@ readudp(struct iodesc *h, void *pkt, siz delay(1000); #endif if (udpread_p->status != 0) { - /* XXX: This happens a lot. It shouldn't. */ + /* XXX: This happens a lot. It shouldn't. */ if (udpread_p->status != 1) printf("readudp failed %x\n", udpread_p->status); return -1;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201703090513.v295D8QT061407>