From fb52ab82d24eed15878194318124697dd373ff53 Mon Sep 17 00:00:00 2001 From: Augustin Cavalier Date: Tue, 26 Mar 2019 19:50:13 -0400 Subject: [PATCH] Minor tweaks to fix the build after the last commit. * firewire and freebsd_network expect the macros come from sys/param.h, as this is one of the places FreeBSD defines them * All others are Haiku-native and can use Be-style macros. --- headers/private/firewire/firewire.h | 9 ++- .../drivers/disk/usb/usb_disk/usb_disk.cpp | 5 +- .../kernel/drivers/network/pegasus/if_aue.c | 36 +++++------ .../kernel/drivers/network/wb840/interface.c | 62 +++++++++---------- src/add-ons/translators/raw/RAW.cpp | 3 +- .../compat/freebsd_network/compat/sys/param.h | 9 +++ 6 files changed, 70 insertions(+), 54 deletions(-) diff --git a/headers/private/firewire/firewire.h b/headers/private/firewire/firewire.h index d02ab1146a..36a02daa58 100644 --- a/headers/private/firewire/firewire.h +++ b/headers/private/firewire/firewire.h @@ -30,7 +30,7 @@ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. - * + * * $FreeBSD: src/sys/dev/firewire/firewire.h,v 1.21 2007/04/24 12:15:05 simokawa Exp $ * */ @@ -458,6 +458,13 @@ struct fw_crom_buf { #define FWMAXNDMA 0x100 /* 8 bits DMA channel id. in device No. */ +#ifndef htonl +# define htonl(x) B_HOST_TO_BENDIAN_INT32(x) +# define ntohl(x) B_BENDIAN_TO_HOST_INT32(x) +# define htons(x) B_HOST_TO_BENDIAN_INT16(x) +# define ntohs(x) B_BENDIAN_TO_HOST_INT16(x) +#endif + #ifndef __HAIKU__ #if defined(__DragonFly__) || __FreeBSD_version < 500000 #define dev2unit(x) ((minor(x) & 0xff) | (minor(x) >> 8)) diff --git a/src/add-ons/kernel/drivers/disk/usb/usb_disk/usb_disk.cpp b/src/add-ons/kernel/drivers/disk/usb/usb_disk/usb_disk.cpp index dd26443288..e76fb8e388 100644 --- a/src/add-ons/kernel/drivers/disk/usb/usb_disk/usb_disk.cpp +++ b/src/add-ons/kernel/drivers/disk/usb/usb_disk/usb_disk.cpp @@ -1195,8 +1195,9 @@ usb_disk_update_capacity(device_lun *lun) lun->media_present = true; lun->media_changed = false; - lun->block_size = ntohl(parameter.logical_block_length); - lun->block_count = ntohl(parameter.last_logical_block_address) + 1; + lun->block_size = B_BENDIAN_TO_HOST_INT32(parameter.logical_block_length); + lun->block_count = + B_BENDIAN_TO_HOST_INT32(parameter.last_logical_block_address) + 1; return B_OK; } diff --git a/src/add-ons/kernel/drivers/network/pegasus/if_aue.c b/src/add-ons/kernel/drivers/network/pegasus/if_aue.c index 4f8432b139..1ec8ace1fb 100644 --- a/src/add-ons/kernel/drivers/network/pegasus/if_aue.c +++ b/src/add-ons/kernel/drivers/network/pegasus/if_aue.c @@ -1,6 +1,6 @@ /* * Pegasus BeOS Driver - * + * * Copyright 2006, Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. * @@ -64,7 +64,7 @@ aue_csr_read_1(pegasus_dev *sc, int reg) AUE_LOCK(sc); - err = usb->send_request(sc->dev, USB_REQTYPE_VENDOR | USB_REQTYPE_DEVICE_IN, + err = usb->send_request(sc->dev, USB_REQTYPE_VENDOR | USB_REQTYPE_DEVICE_IN, AUE_UR_READREG, 0, reg, 1, &val, &length); AUE_UNLOCK(sc); @@ -87,9 +87,9 @@ aue_csr_read_2(pegasus_dev *sc, int reg) AUE_LOCK(sc); - err = usb->send_request(sc->dev, USB_REQTYPE_VENDOR | USB_REQTYPE_DEVICE_IN, + err = usb->send_request(sc->dev, USB_REQTYPE_VENDOR | USB_REQTYPE_DEVICE_IN, AUE_UR_READREG, 0, reg, 2, &val, &length); - + AUE_UNLOCK(sc); if (err) { @@ -110,9 +110,9 @@ aue_csr_write_1(pegasus_dev *sc, int reg, int val) AUE_LOCK(sc); - err = usb->send_request(sc->dev, USB_REQTYPE_VENDOR | USB_REQTYPE_DEVICE_OUT, + err = usb->send_request(sc->dev, USB_REQTYPE_VENDOR | USB_REQTYPE_DEVICE_OUT, AUE_UR_WRITEREG, val, reg, 1, &val, &length); - + AUE_UNLOCK(sc); if (err) { @@ -127,15 +127,15 @@ aue_csr_write_2(pegasus_dev *sc, int reg, int val) { status_t err; size_t length = 2; - + if (sc->aue_dying) return (0); AUE_LOCK(sc); - err = usb->send_request(sc->dev, USB_REQTYPE_VENDOR | USB_REQTYPE_DEVICE_OUT, + err = usb->send_request(sc->dev, USB_REQTYPE_VENDOR | USB_REQTYPE_DEVICE_OUT, AUE_UR_WRITEREG, val, reg, 2, &val, &length); - + AUE_UNLOCK(sc); if (err) { @@ -189,7 +189,7 @@ aue_read_eeprom(pegasus_dev *sc, caddr_t dest, int off, int cnt, int swap) aue_eeprom_getword(sc, off + i, &word); ptr = (u_int16_t *)(dest + (i * 2)); if (swap) - *ptr = ntohs(word); + *ptr = B_BENDIAN_TO_HOST_INT16(word); else *ptr = word; } @@ -268,14 +268,14 @@ aue_miibus_writereg(pegasus_dev *sc, int phy, int reg, int data) } -static uint16 +static uint16 aue_miibus_read(pegasus_dev *dev, uint16 reg) { return aue_miibus_readreg(dev, dev->phy, reg); } -static void +static void aue_miibus_write(pegasus_dev *dev, uint16 reg, uint16 value) { aue_miibus_writereg(dev, dev->phy, reg, value); @@ -309,7 +309,7 @@ aue_init_phy(pegasus_dev *dev) { uint16 phy, status; int i; - + dev->phy = 255; // search for total of 32 possible MII PHY addresses @@ -329,7 +329,7 @@ aue_init_phy(pegasus_dev *dev) return B_ENTRY_NOT_FOUND; } DPRINTF_INFO("aue_init_phy MII PHY found at %d\n", dev->phy); - + status = aue_miibus_read(dev, MII_CONTROL); status &= ~MII_CONTROL_ISOLATE; @@ -341,7 +341,7 @@ aue_init_phy(pegasus_dev *dev) break; DELAY(1000); } - + dev->link = aue_miibus_status(dev) & MII_STATUS_LINK; return B_OK; @@ -408,7 +408,7 @@ aue_reset(pegasus_dev *sc) /* - * Attach + * Attach */ void aue_attach(pegasus_dev *sc) @@ -426,10 +426,10 @@ aue_attach(pegasus_dev *sc) aue_read_eeprom(sc, (caddr_t)&eaddr, 0, 3, 0); memcpy(sc->macaddr, eaddr, ETHER_ADDRESS_LENGTH); - + if (aue_init_phy(sc) != B_OK) goto done; - + sc->aue_dying = 0; done: diff --git a/src/add-ons/kernel/drivers/network/wb840/interface.c b/src/add-ons/kernel/drivers/network/wb840/interface.c index 324185f953..514195bc73 100644 --- a/src/add-ons/kernel/drivers/network/wb840/interface.c +++ b/src/add-ons/kernel/drivers/network/wb840/interface.c @@ -51,22 +51,22 @@ read32(device->reg_base + WB_SIO) & ~x) #define MII_DELAY(x) read32(x->reg_base + WB_SIO) - + static void mii_sync(struct wb_device *device) { // Set data bit and strobe the clock 32 times int bits = 32; - + SIO_SET(WB_SIO_MII_DIR|WB_SIO_MII_DATAIN); - while (--bits >= 0) { - SIO_SET(WB_SIO_MII_CLK); + while (--bits >= 0) { + SIO_SET(WB_SIO_MII_CLK); MII_DELAY(device); SIO_CLR(WB_SIO_MII_CLK); - MII_DELAY(device); - } + MII_DELAY(device); + } } @@ -93,7 +93,7 @@ mii_send(wb_device *device, uint32 bits, int count) * Read an PHY register through the MII. */ static int -wb_mii_readreg(wb_device *device, wb_mii_frame *frame) +wb_mii_readreg(wb_device *device, wb_mii_frame *frame) { int i, ack; @@ -104,7 +104,7 @@ wb_mii_readreg(wb_device *device, wb_mii_frame *frame) frame->mii_opcode = WB_MII_READOP; frame->mii_turnaround = 0; frame->mii_data = 0; - + write32(device->reg_base + WB_SIO, 0); /* @@ -192,7 +192,7 @@ wb_mii_writereg(wb_device *device, wb_mii_frame *frame) frame->mii_stdelim = WB_MII_STARTDELIM; frame->mii_opcode = WB_MII_WRITEOP; frame->mii_turnaround = WB_MII_TURNAROUND; - + /* * Turn on data output. */ @@ -212,7 +212,7 @@ wb_mii_writereg(wb_device *device, wb_mii_frame *frame) MII_DELAY(device); SIO_CLR(WB_SIO_MII_CLK); MII_DELAY(device); - + /* * Turn off xmit. */ @@ -262,7 +262,7 @@ wb_eeprom_putbyte(wb_device *device, int addr) { int d, i; int delay; - + d = addr | WB_EECMD_READ; /* @@ -276,41 +276,41 @@ wb_eeprom_putbyte(wb_device *device, int addr) } for (delay = 0; delay < 100; delay++) MII_DELAY(device); - + SIO_SET(WB_SIO_EE_CLK); - + for (delay = 0; delay < 150; delay++) - MII_DELAY(device); - + MII_DELAY(device); + SIO_CLR(WB_SIO_EE_CLK); - + for (delay = 0; delay < 100; delay++) MII_DELAY(device); - + } return; } #endif - + static void wb_eeprom_askdata(wb_device *device, int addr) { int command, i; int delay; - + command = addr | WB_EECMD_READ; - - /* Feed in each bit and strobe the clock. */ + + /* Feed in each bit and strobe the clock. */ for(i = 0x400; i; i >>= 1) { - if (command & i) + if (command & i) SIO_SET(WB_SIO_EE_DATAIN); else SIO_CLR(WB_SIO_EE_DATAIN); - + SIO_SET(WB_SIO_EE_CLK); - + SIO_CLR(WB_SIO_EE_CLK); for (delay = 0; delay < 100; delay++) EEPROM_DELAY(device); @@ -327,12 +327,12 @@ wb_eeprom_getword(wb_device *device, int addr, uint16 *dest) /* Enter EEPROM access mode */ write32(device->reg_base + WB_SIO, WB_SIO_EESEL|WB_SIO_EE_CS); - + /* Send address of word we want to read. */ wb_eeprom_askdata(device, addr); - + write32(device->reg_base + WB_SIO, WB_SIO_EESEL|WB_SIO_EE_CS); - + /* Start reading bits from EEPROM */ for (i = 0x8000; i > 0; i >>= 1) { SIO_SET(WB_SIO_EE_CLK); @@ -340,10 +340,10 @@ wb_eeprom_getword(wb_device *device, int addr, uint16 *dest) word |= i; SIO_CLR(WB_SIO_EE_CLK); } - + /* Turn off EEPROM access mode */ write32(device->reg_base + WB_SIO, 0); - + *dest = word; } @@ -354,12 +354,12 @@ wb_read_eeprom(wb_device *device, void* dest, { int i; uint16 word = 0, *ptr; - + for (i = 0; i < count; i++) { wb_eeprom_getword(device, offset + i, &word); ptr = (uint16 *)((uint8 *)dest + (i * 2)); if (swap) - *ptr = ntohs(word); + *ptr = B_BENDIAN_TO_HOST_INT16(word); else *ptr = word; } diff --git a/src/add-ons/translators/raw/RAW.cpp b/src/add-ons/translators/raw/RAW.cpp index d0bec25724..6fd6e8b911 100644 --- a/src/add-ons/translators/raw/RAW.cpp +++ b/src/add-ons/translators/raw/RAW.cpp @@ -19,7 +19,6 @@ #include #include #include -#include //#define TRACE(x) printf x @@ -2022,7 +2021,7 @@ DCRaw::_ConvertToRGB() } } for (i = 0; i < phead[0]/4; i++) { - fOutputProfile[i] = htonl(fOutputProfile[i]); + fOutputProfile[i] = B_HOST_TO_BENDIAN_INT32(fOutputProfile[i]); } strcpy((char *)fOutputProfile + pbody[2] + 8, "auto-generated by dcraw"); diff --git a/src/libs/compat/freebsd_network/compat/sys/param.h b/src/libs/compat/freebsd_network/compat/sys/param.h index 83e47ad205..90f768d238 100644 --- a/src/libs/compat/freebsd_network/compat/sys/param.h +++ b/src/libs/compat/freebsd_network/compat/sys/param.h @@ -8,6 +8,7 @@ #include +#include #include #include @@ -94,4 +95,12 @@ #define isclr(a,i) \ ((((const unsigned char *)(a))[(i)/NBBY] & (1<<((i)%NBBY))) == 0) +/* byteswap macros */ +#ifndef htonl +# define htonl(x) B_HOST_TO_BENDIAN_INT32(x) +# define ntohl(x) B_BENDIAN_TO_HOST_INT32(x) +# define htons(x) B_HOST_TO_BENDIAN_INT16(x) +# define ntohs(x) B_BENDIAN_TO_HOST_INT16(x) +#endif + #endif /* _FBSD_COMPAT_SYS_PARAM_H_ */