svn commit: r218791 - head/sys/dev/sound/usb

2011-02-17 Thread Hans Petter Selasky
Author: hselasky
Date: Fri Feb 18 07:37:30 2011
New Revision: 218791
URL: http://svn.freebsd.org/changeset/base/218791

Log:
  - Make an enum for all the umidi USB transfers.
  - Use the USB stack's builtin clear-stall feature.
  - Wrap some long lines.
  - Use memcpy() instead of bcopy().
  - Use memset() instead of bzero().
  - Tested applications:
/usr/ports/audio/fluidsynth
  
  MFC after:7 days
  Approved by:  thompsa (mentor)

Modified:
  head/sys/dev/sound/usb/uaudio.c

Modified: head/sys/dev/sound/usb/uaudio.c
==
--- head/sys/dev/sound/usb/uaudio.c Fri Feb 18 06:42:15 2011
(r218790)
+++ head/sys/dev/sound/usb/uaudio.c Fri Feb 18 07:37:30 2011
(r218791)
@@ -191,10 +191,15 @@ struct uaudio_chan {
uint8_t iface_alt_index;
 };
 
-#defineUMIDI_N_TRANSFER4   /* units */
 #defineUMIDI_CABLES_MAX   16   /* units */
 #defineUMIDI_BULK_SIZE  1024   /* bytes */
 
+enum {
+   UMIDI_TX_TRANSFER,
+   UMIDI_RX_TRANSFER,
+   UMIDI_N_TRANSFER,
+};
+
 struct umidi_sub_chan {
struct usb_fifo_sc fifo;
uint8_t *temp_cmd;
@@ -224,10 +229,6 @@ struct umidi_chan {
uint8_t iface_index;
uint8_t iface_alt_index;
 
-   uint8_t flags;
-#defineUMIDI_FLAG_READ_STALL  0x01
-#defineUMIDI_FLAG_WRITE_STALL 0x02
-
uint8_t read_open_refcount;
uint8_t write_open_refcount;
 
@@ -336,9 +337,7 @@ static device_detach_t uaudio_detach;
 static usb_callback_t uaudio_chan_play_callback;
 static usb_callback_t uaudio_chan_record_callback;
 static usb_callback_t uaudio_mixer_write_cfg_callback;
-static usb_callback_t umidi_read_clear_stall_callback;
 static usb_callback_t umidi_bulk_read_callback;
-static usb_callback_t umidi_write_clear_stall_callback;
 static usb_callback_t umidi_bulk_write_callback;
 
 static voiduaudio_chan_fill_info_sub(struct uaudio_softc *,
@@ -493,7 +492,7 @@ uint8_t umidi_cmd_to_len[16] = {
 
 static const struct usb_config
umidi_config[UMIDI_N_TRANSFER] = {
-   [0] = {
+   [UMIDI_TX_TRANSFER] = {
.type = UE_BULK,
.endpoint = UE_ADDR_ANY,
.direction = UE_DIR_OUT,
@@ -502,7 +501,7 @@ static const struct usb_config
.callback = &umidi_bulk_write_callback,
},
 
-   [1] = {
+   [UMIDI_RX_TRANSFER] = {
.type = UE_BULK,
.endpoint = UE_ADDR_ANY,
.direction = UE_DIR_IN,
@@ -510,26 +509,6 @@ static const struct usb_config
.flags = {.pipe_bof = 1,.short_xfer_ok = 1,.proxy_buffer = 1,},
.callback = &umidi_bulk_read_callback,
},
-
-   [2] = {
-   .type = UE_CONTROL,
-   .endpoint = 0x00,   /* Control pipe */
-   .direction = UE_DIR_ANY,
-   .bufsize = sizeof(struct usb_device_request),
-   .callback = &umidi_write_clear_stall_callback,
-   .timeout = 1000,/* 1 second */
-   .interval = 50, /* 50ms */
-   },
-
-   [3] = {
-   .type = UE_CONTROL,
-   .endpoint = 0x00,   /* Control pipe */
-   .direction = UE_DIR_ANY,
-   .bufsize = sizeof(struct usb_device_request),
-   .callback = &umidi_read_clear_stall_callback,
-   .timeout = 1000,/* 1 second */
-   .interval = 50, /* 50ms */
-   },
 };
 
 static devclass_t uaudio_devclass;
@@ -1577,10 +1556,10 @@ static void
 uaudio_mixer_add_ctl_sub(struct uaudio_softc *sc, struct uaudio_mixer_node *mc)
 {
struct uaudio_mixer_node *p_mc_new =
-   malloc(sizeof(*p_mc_new), M_USBDEV, M_WAITOK);
+   malloc(sizeof(*p_mc_new), M_USBDEV, M_WAITOK);
 
-   if (p_mc_new) {
-   bcopy(mc, p_mc_new, sizeof(*p_mc_new));
+   if (p_mc_new != NULL) {
+   memcpy(p_mc_new, mc, sizeof(*p_mc_new));
p_mc_new->next = sc->sc_mixer_root;
sc->sc_mixer_root = p_mc_new;
sc->sc_mixer_count++;
@@ -1722,7 +1701,7 @@ uaudio_mixer_add_mixer(struct uaudio_sof
 
DPRINTFN(3, "ichs=%d ochs=%d\n", ichs, ochs);
 
-   bzero(&mix, sizeof(mix));
+   memset(&mix, 0, sizeof(mix));
 
mix.wIndex = MAKE_WORD(d0->bUnitId, sc->sc_mixer_iface_no);
uaudio_mixer_determine_class(&iot[id], &mix);
@@ -1782,7 +1761,7 @@ uaudio_mixer_add_selector(struct uaudio_
if (d->bNrInPins == 0) {
return;
}
-   bzero(&mix, sizeof(mix));
+   memset(&mix, 0, sizeof(mix));
 
mix.wIndex = MAKE_WORD(d->bUnitId, sc->sc_mixer_iface_no);
mix.wValue[0] = MAKE_WORD(0, 0);
@@ -1852,7 +1831,7 @@ uaudio_mixer_add_feature(struct uaudio_s
if (d->bControlSize == 0) {
return;
}
-   bzero(&mix, sizeof(mix));
+   mem

svn commit: r218789 - head/sys/dev/dc

2011-02-17 Thread Pyun YongHyeon
Author: yongari
Date: Fri Feb 18 03:37:53 2011
New Revision: 218789
URL: http://svn.freebsd.org/changeset/base/218789

Log:
  Remove use case of DC_TX_ONE. It was used to limit queue just 1 TX
  frame in DM910x controllers. In r67595(more than 10 years ago) it
  was replaced to use "Store and Forward" mode and made controller
  generate TX completion interrupt for every frame.

Modified:
  head/sys/dev/dc/if_dc.c
  head/sys/dev/dc/if_dcreg.h

Modified: head/sys/dev/dc/if_dc.c
==
--- head/sys/dev/dc/if_dc.c Fri Feb 18 02:58:09 2011(r218788)
+++ head/sys/dev/dc/if_dc.c Fri Feb 18 03:37:53 2011(r218789)
@@ -3391,11 +3391,6 @@ dc_start_locked(struct ifnet *ifp)
 * to him.
 */
BPF_MTAP(ifp, m_head);
-
-   if (sc->dc_flags & DC_TX_ONE) {
-   ifp->if_drv_flags |= IFF_DRV_OACTIVE;
-   break;
-   }
}
 
if (queued > 0) {

Modified: head/sys/dev/dc/if_dcreg.h
==
--- head/sys/dev/dc/if_dcreg.h  Fri Feb 18 02:58:09 2011(r218788)
+++ head/sys/dev/dc/if_dcreg.h  Fri Feb 18 03:37:53 2011(r218789)
@@ -780,7 +780,6 @@ struct dc_softc {
 #define DC_128BIT_HASH 0x1000
 #define DC_64BIT_HASH  0x2000
 #define DC_TULIP_LEDS  0x4000
-#define DC_TX_ONE  0x8000
 #define DC_TX_ALIGN0x0001  /* align mbuf on tx */
 
 /*
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r218788 - head/sys/dev/dc

2011-02-17 Thread Pyun YongHyeon
Author: yongari
Date: Fri Feb 18 02:58:09 2011
New Revision: 218788
URL: http://svn.freebsd.org/changeset/base/218788

Log:
  Apply special PHY initialization code for 21143 controllers before
  any other media configuration. Otherwise some 21143 controller
  cannot establish a link. While I'm here remove the PHY
  initialization code in dc_setcfg(). Since dc_setcfg() is called
  whenever link state is changed, having the PHY initialization code
  in dc_setcfg() resulted in continuous link flips.
  After driver resets SIA, use default SIA transmit/receive
  configuration instead of disabling autosense/autonegotiation.
  Otherwise, controller fails to establish a link as well as losing
  auto-negotiation capability. For manual media configuration, always
  configure 21143 controller with specified media to ensure media
  change. This change makes ANA-6922 establish link with/without
  auto-negotiation.
  
  While I'm here be more strict on link UP/DOWN detection logic.
  
  Many thanks to marius who fixed several bugs in initial patch and
  even tested the patch on a couple of dc(4) controllers.
  
  PR:   kern/79262
  Reviewed by:  marius
  Tested by:marius

Modified:
  head/sys/dev/dc/if_dc.c

Modified: head/sys/dev/dc/if_dc.c
==
--- head/sys/dev/dc/if_dc.c Fri Feb 18 02:14:53 2011(r218787)
+++ head/sys/dev/dc/if_dc.c Fri Feb 18 02:58:09 2011(r218788)
@@ -944,23 +944,45 @@ static void
 dc_miibus_statchg(device_t dev)
 {
struct dc_softc *sc;
+   struct ifnet *ifp;
struct mii_data *mii;
struct ifmedia *ifm;
 
sc = device_get_softc(dev);
-   if (DC_IS_ADMTEK(sc))
-   return;
 
mii = device_get_softc(sc->dc_miibus);
+   ifp = sc->dc_ifp;
+   if (mii == NULL || ifp == NULL ||
+   (ifp->if_drv_flags & IFF_DRV_RUNNING) == 0)
+   return;
+
ifm = &mii->mii_media;
if (DC_IS_DAVICOM(sc) &&
IFM_SUBTYPE(ifm->ifm_media) == IFM_HPNA_1) {
dc_setcfg(sc, ifm->ifm_media);
sc->dc_if_media = ifm->ifm_media;
-   } else {
-   dc_setcfg(sc, mii->mii_media_active);
-   sc->dc_if_media = mii->mii_media_active;
+   return;
+   }
+
+   sc->dc_link = 0;
+   if ((mii->mii_media_status & (IFM_ACTIVE | IFM_AVALID)) ==
+   (IFM_ACTIVE | IFM_AVALID)) {
+   switch (IFM_SUBTYPE(mii->mii_media_active)) {
+   case IFM_10_T:
+   case IFM_100_TX:
+   sc->dc_link = 1;
+   break;
+   default:
+   break;
+   }
}
+   if (sc->dc_link == 0)
+   return;
+
+   sc->dc_if_media = mii->mii_media_active;
+   if (DC_IS_ADMTEK(sc))
+   return;
+   dc_setcfg(sc, mii->mii_media_active);
 }
 
 /*
@@ -1404,8 +1426,6 @@ dc_setcfg(struct dc_softc *sc, int media
if (!DC_IS_DAVICOM(sc))
DC_SETBIT(sc, DC_NETCFG, DC_NETCFG_PORTSEL);
DC_CLRBIT(sc, DC_10BTCTRL, 0x);
-   if (DC_IS_INTEL(sc))
-   dc_apply_fixup(sc, IFM_AUTO);
} else {
if (DC_IS_PNIC(sc)) {
DC_PN_GPIO_SETBIT(sc, DC_PN_GPIO_SPEEDSEL);
@@ -1415,10 +1435,6 @@ dc_setcfg(struct dc_softc *sc, int media
DC_SETBIT(sc, DC_NETCFG, DC_NETCFG_PORTSEL);
DC_SETBIT(sc, DC_NETCFG, DC_NETCFG_PCS);
DC_SETBIT(sc, DC_NETCFG, DC_NETCFG_SCRAMBLER);
-   if (DC_IS_INTEL(sc))
-   dc_apply_fixup(sc,
-   (media & IFM_GMASK) == IFM_FDX ?
-   IFM_100_TX | IFM_FDX : IFM_100_TX);
}
}
 
@@ -1442,8 +1458,6 @@ dc_setcfg(struct dc_softc *sc, int media
if (!DC_IS_DAVICOM(sc))
DC_SETBIT(sc, DC_NETCFG, DC_NETCFG_PORTSEL);
DC_CLRBIT(sc, DC_10BTCTRL, 0x);
-   if (DC_IS_INTEL(sc))
-   dc_apply_fixup(sc, IFM_AUTO);
} else {
if (DC_IS_PNIC(sc)) {
DC_PN_GPIO_CLRBIT(sc, DC_PN_GPIO_SPEEDSEL);
@@ -1463,9 +1477,6 @@ dc_setcfg(struct dc_softc *sc, int media
DC_SETBIT(sc, DC_SIARESET, DC_SIA_RESET);
DC_CLRBIT(sc, DC_10BTCTRL,
DC_TCTL_AUTONEGENBL);
-   dc_apply_fixup(sc,
-   (media & IFM_GMASK) == IFM_FDX ?
-   IFM_10_T | IFM_FDX : IFM_10_T);
DELAY(2

svn commit: r218787 - head/sys/dev/dc

2011-02-17 Thread Pyun YongHyeon
Author: yongari
Date: Fri Feb 18 02:14:53 2011
New Revision: 218787
URL: http://svn.freebsd.org/changeset/base/218787

Log:
  When driver have to use base softc due to lack of SROM on second
  port, copy SROM information from base softc as well and run SROM
  parser again.  This change is necessary for some dual port
  controllers to make dc(4) correctly detect PHY media based on first
  port configuration table.
  While I'm here add a check for validity of the base softc before
  duplicating SROM contents from base softc. If driver failed to
  attach to the first port it can access invalid area.
  
  PR:   kern/79262
  Reviewed by:  marius

Modified:
  head/sys/dev/dc/if_dc.c

Modified: head/sys/dev/dc/if_dc.c
==
--- head/sys/dev/dc/if_dc.c Fri Feb 18 01:56:25 2011(r218786)
+++ head/sys/dev/dc/if_dc.c Fri Feb 18 02:14:53 2011(r218787)
@@ -1815,6 +1815,7 @@ dc_attach(device_t dev)
u_int32_t command;
struct dc_softc *sc;
struct ifnet *ifp;
+   struct dc_mediainfo *m;
u_int32_t reg, revision;
int error, i, mac_offset, phy, rid, tmp;
u_int8_t *mac;
@@ -2108,8 +2109,24 @@ dc_attach(device_t dev)
if ((sc->dc_eaddr[0] == 0 && (sc->dc_eaddr[1] & ~0x) == 0) ||
(sc->dc_eaddr[0] == 0x &&
(sc->dc_eaddr[1] & 0x) == 0x)) {
-   if (dc_check_multiport(sc) == 0)
+   error = dc_check_multiport(sc);
+   if (error == 0) {
bcopy(sc->dc_eaddr, eaddr, sizeof(eaddr));
+   /* Extract media information. */
+   if (DC_IS_INTEL(sc) && sc->dc_srom != NULL) {
+   while (sc->dc_mi != NULL) {
+   m = sc->dc_mi->dc_next;
+   free(sc->dc_mi, M_DEVBUF);
+   sc->dc_mi = m;
+   }
+   error = dc_parse_21143_srom(sc);
+   if (error != 0)
+   goto fail;
+   }
+   } else if (error == ENOMEM)
+   goto fail;
+   else
+   error = 0;
}
 
/* Allocate a busdma tag and DMA safe memory for TX/RX descriptors. */
@@ -3875,12 +3892,30 @@ dc_check_multiport(struct dc_softc *sc)
continue;
if (unit > device_get_unit(sc->dc_dev))
continue;
+   if (device_is_attached(child) == 0)
+   continue;
dsc = device_get_softc(child);
-   device_printf(sc->dc_dev, "Using station address of %s as base",
+   device_printf(sc->dc_dev,
+   "Using station address of %s as base\n",
device_get_nameunit(child));
bcopy(dsc->dc_eaddr, sc->dc_eaddr, ETHER_ADDR_LEN);
eaddr = (uint8_t *)sc->dc_eaddr;
eaddr[5]++;
+   /* Prepare SROM to parse again. */
+   if (DC_IS_INTEL(sc) && dsc->dc_srom != NULL &&
+   sc->dc_romwidth != 0) {
+   free(sc->dc_srom, M_DEVBUF);
+   sc->dc_romwidth = dsc->dc_romwidth;
+   sc->dc_srom = malloc(DC_ROM_SIZE(sc->dc_romwidth),
+   M_DEVBUF, M_NOWAIT);
+   if (sc->dc_srom == NULL) {
+   device_printf(sc->dc_dev,
+   "Could not allocate SROM buffer\n");
+   return (ENOMEM);
+   }
+   bcopy(dsc->dc_srom, sc->dc_srom,
+   DC_ROM_SIZE(sc->dc_romwidth));
+   }
return (0);
}
return (ENOENT);
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r218786 - head/sys/dev/dc

2011-02-17 Thread Pyun YongHyeon
Author: yongari
Date: Fri Feb 18 01:56:25 2011
New Revision: 218786
URL: http://svn.freebsd.org/changeset/base/218786

Log:
  Always check memory allocation failure. If driver encounter memory
  allocation error, do not attach driver.
  
  Reviewed by:  marius

Modified:
  head/sys/dev/dc/if_dc.c
  head/sys/dev/dc/if_dcreg.h

Modified: head/sys/dev/dc/if_dc.c
==
--- head/sys/dev/dc/if_dc.c Fri Feb 18 00:02:35 2011(r218785)
+++ head/sys/dev/dc/if_dc.c Fri Feb 18 01:56:25 2011(r218786)
@@ -287,11 +287,11 @@ static void dc_reset(struct dc_softc *);
 static int dc_list_rx_init(struct dc_softc *);
 static int dc_list_tx_init(struct dc_softc *);
 
-static void dc_read_srom(struct dc_softc *, int);
-static void dc_parse_21143_srom(struct dc_softc *);
-static void dc_decode_leaf_sia(struct dc_softc *, struct dc_eblock_sia *);
-static void dc_decode_leaf_mii(struct dc_softc *, struct dc_eblock_mii *);
-static void dc_decode_leaf_sym(struct dc_softc *, struct dc_eblock_sym *);
+static int dc_read_srom(struct dc_softc *, int);
+static int dc_parse_21143_srom(struct dc_softc *);
+static int dc_decode_leaf_sia(struct dc_softc *, struct dc_eblock_sia *);
+static int dc_decode_leaf_mii(struct dc_softc *, struct dc_eblock_mii *);
+static int dc_decode_leaf_sym(struct dc_softc *, struct dc_eblock_sym *);
 static void dc_apply_fixup(struct dc_softc *, int);
 static int dc_check_multiport(struct dc_softc *);
 
@@ -1616,12 +1616,16 @@ dc_apply_fixup(struct dc_softc *sc, int 
}
 }
 
-static void
+static int
 dc_decode_leaf_sia(struct dc_softc *sc, struct dc_eblock_sia *l)
 {
struct dc_mediainfo *m;
 
m = malloc(sizeof(struct dc_mediainfo), M_DEVBUF, M_NOWAIT | M_ZERO);
+   if (m == NULL) {
+   device_printf(sc->dc_dev, "Could not allocate mediainfo\n");
+   return (ENOMEM);
+   }
switch (l->dc_sia_code & ~DC_SIA_CODE_EXT) {
case DC_SIA_CODE_10BT:
m->dc_media = IFM_10_T;
@@ -1658,14 +1662,19 @@ dc_decode_leaf_sia(struct dc_softc *sc, 
sc->dc_mi = m;
 
sc->dc_pmode = DC_PMODE_SIA;
+   return (0);
 }
 
-static void
+static int
 dc_decode_leaf_sym(struct dc_softc *sc, struct dc_eblock_sym *l)
 {
struct dc_mediainfo *m;
 
m = malloc(sizeof(struct dc_mediainfo), M_DEVBUF, M_NOWAIT | M_ZERO);
+   if (m == NULL) {
+   device_printf(sc->dc_dev, "Could not allocate mediainfo\n");
+   return (ENOMEM);
+   }
if (l->dc_sym_code == DC_SYM_CODE_100BT)
m->dc_media = IFM_100_TX;
 
@@ -1679,15 +1688,20 @@ dc_decode_leaf_sym(struct dc_softc *sc, 
sc->dc_mi = m;
 
sc->dc_pmode = DC_PMODE_SYM;
+   return (0);
 }
 
-static void
+static int
 dc_decode_leaf_mii(struct dc_softc *sc, struct dc_eblock_mii *l)
 {
struct dc_mediainfo *m;
u_int8_t *p;
 
m = malloc(sizeof(struct dc_mediainfo), M_DEVBUF, M_NOWAIT | M_ZERO);
+   if (m == NULL) {
+   device_printf(sc->dc_dev, "Could not allocate mediainfo\n");
+   return (ENOMEM);
+   }
/* We abuse IFM_AUTO to represent MII. */
m->dc_media = IFM_AUTO;
m->dc_gp_len = l->dc_gpr_len;
@@ -1702,24 +1716,30 @@ dc_decode_leaf_mii(struct dc_softc *sc, 
 
m->dc_next = sc->dc_mi;
sc->dc_mi = m;
+   return (0);
 }
 
-static void
+static int
 dc_read_srom(struct dc_softc *sc, int bits)
 {
int size;
 
-   size = 2 << bits;
+   size = DC_ROM_SIZE(bits);
sc->dc_srom = malloc(size, M_DEVBUF, M_NOWAIT);
+   if (sc->dc_srom == NULL) {
+   device_printf(sc->dc_dev, "Could not allocate SROM buffer\n");
+   return (ENOMEM);
+   }
dc_read_eeprom(sc, (caddr_t)sc->dc_srom, 0, (size / 2), 0);
+   return (0);
 }
 
-static void
+static int
 dc_parse_21143_srom(struct dc_softc *sc)
 {
struct dc_leaf_hdr *lhdr;
struct dc_eblock_hdr *hdr;
-   int have_mii, i, loff;
+   int error, have_mii, i, loff;
char *ptr;
 
have_mii = 0;
@@ -1746,20 +1766,21 @@ dc_parse_21143_srom(struct dc_softc *sc)
 */
ptr = (char *)lhdr;
ptr += sizeof(struct dc_leaf_hdr) - 1;
+   error = 0;
for (i = 0; i < lhdr->dc_mcnt; i++) {
hdr = (struct dc_eblock_hdr *)ptr;
switch (hdr->dc_type) {
case DC_EBLOCK_MII:
-   dc_decode_leaf_mii(sc, (struct dc_eblock_mii *)hdr);
+   error = dc_decode_leaf_mii(sc, (struct dc_eblock_mii 
*)hdr);
break;
case DC_EBLOCK_SIA:
if (! have_mii)
-   dc_decode_leaf_sia(sc,
+   error = dc_decode_leaf_sia(sc,
(struct dc_eblock_sia *)hdr);
break;
   

svn commit: r218780 - head/sys/arm/arm

2011-02-17 Thread Marcel Moolenaar
Author: marcel
Date: Thu Feb 17 19:31:21 2011
New Revision: 218780
URL: http://svn.freebsd.org/changeset/base/218780

Log:
  Fix the R_ARM_ABS32 relocation implementation. The memory address
  contains the addend that we need to include.
  
  Obtained from: Juniper Networks.
  Fixed by: Santhanakrishnan Balraj 

Modified:
  head/sys/arm/arm/elf_machdep.c

Modified: head/sys/arm/arm/elf_machdep.c
==
--- head/sys/arm/arm/elf_machdep.c  Thu Feb 17 17:35:09 2011
(r218779)
+++ head/sys/arm/arm/elf_machdep.c  Thu Feb 17 19:31:21 2011
(r218780)
@@ -169,9 +169,7 @@ elf_reloc_internal(linker_file_t lf, Elf
addr = lookup(lf, symidx, 1);
if (addr == 0)
return -1;
-   if (*where != addr)
-   *where = addr;
-
+   *where += addr;
break;
 
case R_ARM_COPY:/* none */
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r218779 - head/sys/dev/ath

2011-02-17 Thread Adrian Chadd
Author: adrian
Date: Thu Feb 17 17:35:09 2011
New Revision: 218779
URL: http://svn.freebsd.org/changeset/base/218779

Log:
  Just be double-sure short-gi isn't being enabled in 20mhz mode.

Modified:
  head/sys/dev/ath/if_ath_tx_ht.c

Modified: head/sys/dev/ath/if_ath_tx_ht.c
==
--- head/sys/dev/ath/if_ath_tx_ht.c Thu Feb 17 17:31:36 2011
(r218778)
+++ head/sys/dev/ath/if_ath_tx_ht.c Thu Feb 17 17:35:09 2011
(r218779)
@@ -119,8 +119,13 @@ ath_rateseries_setup(struct ath_softc *s
series[i].RateFlags |= HAL_RATESERIES_RTS_CTS;
if (ni->ni_htcap & IEEE80211_HTCAP_CHWIDTH40)
series[i].RateFlags |= HAL_RATESERIES_2040;
-   if (ni->ni_htcap & IEEE80211_HTCAP_SHORTGI20 ||
-   ni->ni_htcap & IEEE80211_HTCAP_SHORTGI40)
+
+   /*
+* The hardware only supports short-gi in 40mhz mode -
+* if later hardware supports it in 20mhz mode, be sure
+* to add the relevant check here.
+*/
+   if (ni->ni_htcap & IEEE80211_HTCAP_SHORTGI40)
series[i].RateFlags |= HAL_RATESERIES_HALFGI;
 
/* XXX should this check the short preamble value should be set 
for legacy rates? -adrian */
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r218778 - head/sys/dev/ath

2011-02-17 Thread Adrian Chadd
Author: adrian
Date: Thu Feb 17 17:31:36 2011
New Revision: 218778
URL: http://svn.freebsd.org/changeset/base/218778

Log:
  Disable short-GI in 20mhz mode - the hardware doesn't support this.

Modified:
  head/sys/dev/ath/if_ath.c

Modified: head/sys/dev/ath/if_ath.c
==
--- head/sys/dev/ath/if_ath.c   Thu Feb 17 17:03:56 2011(r218777)
+++ head/sys/dev/ath/if_ath.c   Thu Feb 17 17:31:36 2011(r218778)
@@ -635,7 +635,10 @@ ath_attach(u_int16_t devid, struct ath_s
| IEEE80211_HTC_AMPDU   /* A-MPDU tx/rx 
*/
| IEEE80211_HTC_AMSDU   /* A-MSDU tx/rx 
*/
| IEEE80211_HTCAP_MAXAMSDU_3839 /* max A-MSDU 
length */
+   /* At the present time, the hardware doesn't support short-GI 
in 20mhz mode */
+#if 0
| IEEE80211_HTCAP_SHORTGI20 /* short GI in 
20MHz */
+#endif
| IEEE80211_HTCAP_SMPS_OFF; /* SM power 
save off */
;
 
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r218777 - head/usr.sbin/nfsd

2011-02-17 Thread John Baldwin
Author: jhb
Date: Thu Feb 17 17:03:56 2011
New Revision: 218777
URL: http://svn.freebsd.org/changeset/base/218777

Log:
  Save a copy of errno before invoking syslog() if accept() or select() fail.
  syslog() can trash the errno value causing nfsd to exit for non-fatal
  errors like ECONNABORTED from accept().
  
  MFC after:1 week

Modified:
  head/usr.sbin/nfsd/nfsd.c

Modified: head/usr.sbin/nfsd/nfsd.c
==
--- head/usr.sbin/nfsd/nfsd.c   Thu Feb 17 16:33:41 2011(r218776)
+++ head/usr.sbin/nfsd/nfsd.c   Thu Feb 17 17:03:56 2011(r218777)
@@ -134,7 +134,7 @@ main(int argc, char **argv)
socklen_t len;
int on = 1, unregister, reregister, sock;
int tcp6sock, ip6flag, tcpflag, tcpsock;
-   int udpflag, ecode, s, srvcnt;
+   int udpflag, ecode, error, s, srvcnt;
int bindhostc, bindanyflag, rpcbreg, rpcbregcnt;
int stablefd, nfssvc_addsock;
char **bindhost = NULL;
@@ -738,8 +738,9 @@ main(int argc, char **argv)
if (connect_type_cnt > 1) {
if (select(maxsock + 1,
&ready, NULL, NULL, NULL) < 1) {
+   error = errno;
syslog(LOG_ERR, "select failed: %m");
-   if (errno == EINTR)
+   if (error == EINTR)
continue;
nfsd_exit(1);
}
@@ -750,9 +751,10 @@ main(int argc, char **argv)
len = sizeof(inetpeer);
if ((msgsock = accept(tcpsock,
(struct sockaddr *)&inetpeer, 
&len)) < 0) {
+   error = errno;
syslog(LOG_ERR, "accept failed: 
%m");
-   if (errno == ECONNABORTED ||
-   errno == EINTR)
+   if (error == ECONNABORTED ||
+   error == EINTR)
continue;
nfsd_exit(1);
}
@@ -772,10 +774,11 @@ main(int argc, char **argv)
if ((msgsock = accept(tcpsock,
(struct sockaddr *)&inet6peer,
&len)) < 0) {
+   error = errno;
syslog(LOG_ERR,
 "accept failed: %m");
-   if (errno == ECONNABORTED ||
-   errno == EINTR)
+   if (error == ECONNABORTED ||
+   error == EINTR)
continue;
nfsd_exit(1);
}
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r218776 - in head/usr.sbin/pc-sysinstall: backend conf examples

2011-02-17 Thread Josh Paetzel
Author: jpaetzel
Date: Thu Feb 17 16:33:41 2011
New Revision: 218776
URL: http://svn.freebsd.org/changeset/base/218776

Log:
  Add "Extract Only" functionality to pc-sysinstall.  This allows disk setup to
  be done manually, pc-sysinstall is pointed to a mount-point for installation.
  
  PR:   bin/154685
  Submitted by: kmoore
  Approved by:  kib (mentor)

Modified:
  head/usr.sbin/pc-sysinstall/backend/functions.sh
  head/usr.sbin/pc-sysinstall/backend/parseconfig.sh
  head/usr.sbin/pc-sysinstall/conf/pc-sysinstall.conf
  head/usr.sbin/pc-sysinstall/examples/README

Modified: head/usr.sbin/pc-sysinstall/backend/functions.sh
==
--- head/usr.sbin/pc-sysinstall/backend/functions.shThu Feb 17 16:21:26 
2011(r218775)
+++ head/usr.sbin/pc-sysinstall/backend/functions.shThu Feb 17 16:33:41 
2011(r218776)
@@ -409,6 +409,7 @@ write_image()
   fi
 };
 
+# Setup and install on a new disk / partition
 install_fresh()
 {
   # Lets start setting up the disk slices now
@@ -458,6 +459,39 @@ install_fresh()
   echo_log "Installation finished!"
 };
 
+# Extract the system to a pre-mounted directory
+install_extractonly()
+{
+  # We are ready to begin extraction, lets start now
+  init_extraction 
+
+  # Check if we have any optional modules to load 
+  install_components
+
+  # Check if we have any packages to install
+  install_packages
+
+  # Do any localization in configuration
+  run_localize
+
+  # Save any networking config on the installed system
+  save_networking_install
+
+  # Now add any users
+  setup_users
+
+  # Now run any commands specified
+  run_commands
+  
+  # Set a hostname on the install system
+  setup_hostname
+  
+  # Set the root_pw if it is specified
+  set_root_pw
+
+  echo_log "Installation finished!"
+};
+
 install_image()
 {
   # We are ready to begin extraction, lets start now
@@ -478,7 +512,7 @@ install_upgrade()
   # Do any localization in configuration
   run_localize
 
-  # ow run any commands specified
+  # Now run any commands specified
   run_commands
   
   # Merge any old configuration files

Modified: head/usr.sbin/pc-sysinstall/backend/parseconfig.sh
==
--- head/usr.sbin/pc-sysinstall/backend/parseconfig.sh  Thu Feb 17 16:21:26 
2011(r218775)
+++ head/usr.sbin/pc-sysinstall/backend/parseconfig.sh  Thu Feb 17 16:33:41 
2011(r218776)
@@ -67,11 +67,10 @@ fi
 export CFGF
 
 # Start by doing a sanity check, which will catch any obvious mistakes in the 
config
-file_sanity_check "installMode disk0 installType installMedium packageType"
+file_sanity_check "installMode installType installMedium packageType"
 
 # We passed the Sanity check, lets grab some of the universal config settings 
and store them
-check_value installMode "fresh upgrade"
-check_value bootManager "bsd none"
+check_value installMode "fresh upgrade extract"
 check_value installType "PCBSD FreeBSD"
 check_value installMedium "dvd usb ftp rsync image"
 check_value packageType "uzip tar rsync split"
@@ -108,6 +107,16 @@ case "${INSTALLMODE}" in
 fi
 ;;
 
+  extract)
+# Extracting only, make sure we have a valid target directory
+get_value_from_cfg installLocation
+FSMNT="${VAL}" ; export FSMNT
+if [ -z "$FSMNT" ] ; then exit_err "Missing installLocation=" ; fi
+if [ ! -d "$FSMNT" ] ; then exit_err "No such directory: $FSMNT" ; fi
+
+install_extractonly
+;;
+
   upgrade)
 install_upgrade
 ;;

Modified: head/usr.sbin/pc-sysinstall/conf/pc-sysinstall.conf
==
--- head/usr.sbin/pc-sysinstall/conf/pc-sysinstall.conf Thu Feb 17 16:21:26 
2011(r218775)
+++ head/usr.sbin/pc-sysinstall/conf/pc-sysinstall.conf Thu Feb 17 16:33:41 
2011(r218776)
@@ -36,8 +36,8 @@ RSYNCTRIES="3"
 export RSYNCTRIES
 
 # Set our mount-points
-CDMNT="/cdmnt-install"
-FSMNT="/mnt"
+CDMNT=${CDMNT-/cdmnt-install}
+FSMNT=${FSMNT-/mnt}
 UZIP_DIR="/usr"
 BOOT_PART_MOUNT="/boot-mount"
 export FSMNT CDMNT UZIP_DIR BOOT_PART_MOUNT

Modified: head/usr.sbin/pc-sysinstall/examples/README
==
--- head/usr.sbin/pc-sysinstall/examples/README Thu Feb 17 16:21:26 2011
(r218775)
+++ head/usr.sbin/pc-sysinstall/examples/README Thu Feb 17 16:33:41 2011
(r218776)
@@ -12,9 +12,9 @@ installed system
 When hostname= is not present, pc-sysinstall will auto-generate
 a hostname such as freebsd- or pcbsd-
 
-# installMode=(fresh or upgrade)
+# installMode=(fresh/upgrade/extract)
 
-Set the type of install we are doing, fresh or upgrade.
+Set the type of install we are doing.
 
 Fresh installs will format and mount the target disks before
 extracting the install images to the system. Using this mode
@@ -27,6 +27,19 @@ The conf/exclude-from-upgrade file can b

svn commit: r218773 - in head/sys: amd64/include arm/include i386/include ia64/include mips/include powerpc/include sparc64/include sun4v/include vm

2011-02-17 Thread Alan Cox
Author: alc
Date: Thu Feb 17 15:36:29 2011
New Revision: 218773
URL: http://svn.freebsd.org/changeset/base/218773

Log:
  Remove pmap fields that are either unused or not fully implemented.
  
  Discussed with:   kib

Modified:
  head/sys/amd64/include/pmap.h
  head/sys/arm/include/pmap.h
  head/sys/i386/include/pmap.h
  head/sys/ia64/include/pmap.h
  head/sys/mips/include/pmap.h
  head/sys/powerpc/include/pmap.h
  head/sys/sparc64/include/pmap.h
  head/sys/sun4v/include/pmap.h
  head/sys/vm/vm_page.c

Modified: head/sys/amd64/include/pmap.h
==
--- head/sys/amd64/include/pmap.h   Thu Feb 17 15:10:13 2011
(r218772)
+++ head/sys/amd64/include/pmap.h   Thu Feb 17 15:36:29 2011
(r218773)
@@ -251,8 +251,6 @@ struct pmap {
pml4_entry_t*pm_pml4;   /* KVA of level 4 page table */
TAILQ_HEAD(,pv_chunk)   pm_pvchunk; /* list of mappings in pmap */
cpumask_t   pm_active;  /* active on cpus */
-   uint32_tpm_gen_count;   /* generation count (pmap lock 
dropped) */
-   u_int   pm_retries;
/* spare u_int here due to padding */
struct pmap_statistics  pm_stats;   /* pmap statistics */
vm_page_t   pm_root;/* spare page table pages */

Modified: head/sys/arm/include/pmap.h
==
--- head/sys/arm/include/pmap.h Thu Feb 17 15:10:13 2011(r218772)
+++ head/sys/arm/include/pmap.h Thu Feb 17 15:36:29 2011(r218773)
@@ -134,8 +134,6 @@ struct  pmap {
struct l1_ttable*pm_l1;
struct l2_dtable*pm_l2[L2_SIZE];
pd_entry_t  *pm_pdir;   /* KVA of page directory */
-   uint32_tpm_gen_count;   /* generation count (pmap lock 
dropped) */
-   u_int   pm_retries;
cpumask_t   pm_active;  /* active on cpus */
struct pmap_statistics  pm_stats;   /* pmap statictics */
TAILQ_HEAD(,pv_entry)   pm_pvlist;  /* list of mappings in pmap */

Modified: head/sys/i386/include/pmap.h
==
--- head/sys/i386/include/pmap.hThu Feb 17 15:10:13 2011
(r218772)
+++ head/sys/i386/include/pmap.hThu Feb 17 15:36:29 2011
(r218773)
@@ -436,8 +436,6 @@ struct pmap {
cpumask_t   pm_active;  /* active on cpus */
struct pmap_statistics  pm_stats;   /* pmap statistics */
LIST_ENTRY(pmap)pm_list;/* List of all pmaps */
-   uint32_tpm_gen_count;   /* generation count (pmap lock 
dropped) */
-   u_int   pm_retries;
 #ifdef PAE
pdpt_entry_t*pm_pdpt;   /* KVA of page director pointer
   table */

Modified: head/sys/ia64/include/pmap.h
==
--- head/sys/ia64/include/pmap.hThu Feb 17 15:10:13 2011
(r218772)
+++ head/sys/ia64/include/pmap.hThu Feb 17 15:36:29 2011
(r218773)
@@ -77,8 +77,6 @@ struct pmap {
TAILQ_HEAD(,pv_entry)   pm_pvlist;  /* list of mappings in pmap */
uint32_tpm_rid[5];  /* base RID for pmap */
struct pmap_statistics  pm_stats;   /* pmap statistics */
-   uint32_tpm_gen_count;   /* generation count (pmap lock 
dropped) */
-   u_int   pm_retries;
 };
 
 typedef struct pmap*pmap_t;

Modified: head/sys/mips/include/pmap.h
==
--- head/sys/mips/include/pmap.hThu Feb 17 15:10:13 2011
(r218772)
+++ head/sys/mips/include/pmap.hThu Feb 17 15:36:29 2011
(r218773)
@@ -79,8 +79,6 @@ struct pmap {
pd_entry_t *pm_segtab;  /* KVA of segment table */
TAILQ_HEAD(, pv_entry) pm_pvlist;   /* list of mappings in
 * pmap */
-   uint32_tpm_gen_count;   /* generation count (pmap lock dropped) 
*/
-   u_int   pm_retries;
cpumask_t   pm_active;  /* active on cpus */
struct {
u_int32_t asid:ASID_BITS;   /* TLB address space tag */

Modified: head/sys/powerpc/include/pmap.h
==
--- head/sys/powerpc/include/pmap.h Thu Feb 17 15:10:13 2011
(r218772)
+++ head/sys/powerpc/include/pmap.h Thu Feb 17 15:36:29 2011
(r218773)
@@ -99,8 +99,6 @@ structpmap {
register_t  pm_sr[16];
 #endif
cpumask_t   pm_active;
-   uint32_tpm_gen_count;   /* generation count

svn commit: r218772 - in head: etc/mtree include

2011-02-17 Thread Konstantin Belousov
Author: kib
Date: Thu Feb 17 15:10:13 2011
New Revision: 218772
URL: http://svn.freebsd.org/changeset/base/218772

Log:
  Install iodev.h.
  
  Reviewed by:  attilio
  MFC after:1 week

Modified:
  head/etc/mtree/BSD.include.dist
  head/include/Makefile

Modified: head/etc/mtree/BSD.include.dist
==
--- head/etc/mtree/BSD.include.dist Thu Feb 17 12:21:14 2011
(r218771)
+++ head/etc/mtree/BSD.include.dist Thu Feb 17 15:10:13 2011
(r218772)
@@ -106,6 +106,8 @@
 ..
 iicbus
 ..
+io
+..
 lmc
 ..
 mfi

Modified: head/include/Makefile
==
--- head/include/Makefile   Thu Feb 17 12:21:14 2011(r218771)
+++ head/include/Makefile   Thu Feb 17 15:10:13 2011(r218772)
@@ -40,7 +40,7 @@ LDIRS=bsm cam geom net net80211 netatal
 
 LSUBDIRS=  cam/ata cam/scsi \
dev/acpica dev/an dev/bktr dev/firewire dev/hwpmc \
-   dev/ic dev/iicbus ${_dev_ieee488} dev/lmc dev/mfi dev/ofw \
+   dev/ic dev/iicbus ${_dev_ieee488} dev/io dev/lmc dev/mfi dev/ofw \
dev/pbio ${_dev_powermac_nvram} dev/ppbus dev/smbus \
dev/speaker dev/usb dev/utopia dev/vkbd dev/wi \
fs/devfs fs/fdescfs fs/fifofs fs/msdosfs fs/nfs fs/ntfs fs/nullfs \
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r218771 - head/usr.bin/calendar/calendars/ru_RU.KOI8-R

2011-02-17 Thread Sergey A. Osokin
Author: osa (ports committer)
Date: Thu Feb 17 12:21:14 2011
New Revision: 218771
URL: http://svn.freebsd.org/changeset/base/218771

Log:
  Fix the beginning day of the Great Lent, it starts on Monday for 7 weeks 
before Paskha.
  Fix the Exaltation of the Holy Cross day.
  Add more Twelve holidays (dvunadesyatye prazdniki).

Modified:
  head/usr.bin/calendar/calendars/ru_RU.KOI8-R/calendar.orthodox   (contents, 
props changed)

Modified: head/usr.bin/calendar/calendars/ru_RU.KOI8-R/calendar.orthodox
==
--- head/usr.bin/calendar/calendars/ru_RU.KOI8-R/calendar.orthodox  Thu Feb 
17 11:50:30 2011(r218770)
+++ head/usr.bin/calendar/calendars/ru_RU.KOI8-R/calendar.orthodox  Thu Feb 
17 12:21:14 2011(r218771)
@@ -11,13 +11,14 @@ LANG=ru_RU.KOI8-R
 Paskha=�
 
 21 ��� � � ��
-28 ��� ��� �� 
+27 ��� ��� �� 
 14 ��� �� � ��
  4 ���  ��  � ��
  7 ��� � 
+14 ��� � 
 19 ��� ��� ���  
 15 ���  
-�-46   ��� 
+�-48   ��� 
 �-7��� ���
 �-3��� ���
 �-2� ���
@@ -27,8 +28,11 @@ Paskha=�
 �+56   ��� 
 �+60     
  7 ���  � ��
+ 7 ��� � � 
+12 ���  �� �� � � � �
 19 ���  
 28 ��� ��� � ��
+11 ��� ��� � �� 
 
 #endif /* !_ru_RU_KOI8_R_orthodox_ */
 
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r218745 - head/sys/boot/i386/boot2

2011-02-17 Thread Bruce Evans

On Thu, 17 Feb 2011, Alexander Best wrote:


sorry for my crappy previous attempt to reduce boot2's size. obviously
the *.S files aren't the problem, because even with clang we're using GAS.
so working on boot2.c is the only way of reducing the size.

i've managed to do so (even with another 4 bytes to spare) with the attached
patch.

i did

otaku% grep -r bi_basemem *
sys/boot/i386/boot2/boot2.c:bootinfo.bi_basemem = 0;/* XXX will be 
filled by loader or kernel */
sys/boot/i386/boot2/machine/bootinfo.h: u_int32_t   bi_basemem;
sys/boot/i386/gptboot/gptboot.c:bootinfo.bi_basemem = 0;/* XXX 
will be filled by loader or kernel */
sys/boot/i386/libi386/bootinfo32.c:bi.bi_basemem = bios_basemem / 1024;
sys/boot/i386/loader/main.c:initial_bootinfo->bi_basemem = bios_basemem / 
1024;
sys/boot/i386/zfsboot/zfsboot.c:bootinfo.bi_basemem = bios_basemem / 1024;
sys/boot/pc98/boot2/boot2.c:bootinfo.bi_basemem = 0;/* XXX will be 
filled by loader or kernel */
sys/boot/pc98/loader/main.c:initial_bootinfo->bi_basemem = bios_basemem / 
1024;
sys/i386/include/bootinfo.h:u_int32_t   bi_basemem;
sys/mips/include/bootinfo.h:u_int32_t   bi_basemem;

which led me to the conclusion that bootinfo.bi_basemem doesn't need to
initialised, because it will always be set by the loader (as the XXX comment
says).


It isn't always set by the loader, since the loader isn't always used (I
consider its existence a bug and normally don't use it).

The XXX comment says that bootinfo.bi_basemem will be initialized by
the kernel (if not by the boot blocks or loader), but I can't find
anywhere where the kernel either sets or uses bi_basemem (the only
access in the kernel to it seems to be to copy it in locore).  It was
used in FreeBSD-3, but seems to be unused in FreeBSD-4.  Thus it seems
to be pure garbage, except for kernels older than ones that I test (I
still boot FreeBSD-4 for testing a couple of times per year, and keep
FreeBSD_3 kernels handy but haven't booted them for 5+ years).

Similarly for bootinfo.bi_extmem and bootinfo.bi_memsizes_valid.

There is also a lot of garbage is i386/locore.s to support booting
with old boot blocks.  Not just 5 years old, but almost 20 years, from
before I created bootinfo to give a fixed ABI for booting.  This garbage
probably rotted, and became pure when the kernel became ELF, since old
boot blocks only supported AOUT so they cannot boot a current kernel.

The use in FreeBSD-3 i386/machdep.c was:

% #ifdef VM86
%   initial_bioscalls(&biosbasemem, &biosextmem);
% #else
% 
% 	/* Use BIOS values stored in RTC CMOS RAM, since probing

%* breaks certain 386 AT relics.
%*/
%   biosbasemem = rtcin(RTC_BASELO)+ (rtcin(RTC_BASEHI)<<8);
%   biosextmem = rtcin(RTC_EXTLO)+ (rtcin(RTC_EXTHI)<<8);
% #endif
% 
% 	/*

%* If BIOS tells us that it has more than 640k in the basemem,
%*  don't believe it - set it to 640k.
%*/
%   if (biosbasemem > 640) {
%   printf("Preposterous RTC basemem of %uK, truncating to 640K\n",
%  biosbasemem);
%   biosbasemem = 640;
%   }
%   if (bootinfo.bi_memsizes_valid && bootinfo.bi_basemem > 640) {
%   printf("Preposterous BIOS basemem of %uK, truncating to 640K\n",
%  bootinfo.bi_basemem);
%   bootinfo.bi_basemem = 640;
%   }

I.e., optionally use VM86; otherwise use RTC values; then check the results
againts bi_basemem; later, in code not shown, use the value in bi_basemem
iff it is value.

But already in FreeBSD-4, VM86 was non-optional; the RTC values were only
used as a last resort after 3 or 4 different vm86 calls failed, and the
bootinfo values were not used at all.  At least biosboot, bi_basemem and
bi_extmem were just the result of the BIOS calls 0x12 and 0x15.  These
values were not needed in FreeBSD-4 once VM86 could be used to make the
same calls, and became useless soon after when memory sizes became too
large for them to report.

I just noticed that boot2 doesn't even make a memsize() call for bi_basemem,
so you are talking about removing less than I first thought.  It just makes
the 0x15 call for bi_extmem.  Thus it is already broken for FreeBSD-3 and
earlier kernels without VM86, and nothing would be lost by completing this
breakage.  I think all of the following can be removed:

% static uint32_t memsize(void);
% 
% static inline uint32_t

% memsize(void)
% {
% v86.addr = MEM_EXT;
% v86.eax = 0x8800;
% v86int();
% return v86.eax;
% }

Also, infrastructure like the definition of MEM_EXT.  The definition of
MEM_BASE was not removed when its use was removed.

% 
% bootinfo.bi_version = BOOTINFO_VERSION;

% bootinfo.bi_size = sizeof(bootinfo);

Can't be removed, but should probably be moved:
(1) bootinfo seems to have size 0x88.  It is allocated in the bss, so doesn't
take any space except for code to initialize it

Re: svn commit: r218745 - head/sys/boot/i386/boot2

2011-02-17 Thread Bruce Evans

On Thu, 17 Feb 2011, Alexander Best wrote:


On Wed Feb 16 11, Alexander Best wrote:

On Wed Feb 16 11, Alexander Best wrote:

On Wed Feb 16 11, Alexander Best wrote:

On Wed Feb 16 11, Warner Losh wrote:
i think without this code uint32_t x serves no purpose any longer:

/usr/git-freebsd-head/sys/boot/i386/boot2/boot2.c:322:20: warning: unused 
variable 'x' [-Wunused-variable]
uint32_t addr, x;
   ^


Removing it won't save any space, however.


also due to

/usr/git-freebsd-head/sys/boot/i386/boot2/boot2.c:631:8: warning: cast from 
'caddr_t' (aka 'char *') to 'uint32_t *' (aka 'unsigned int *') increases 
required alignment from 1 to 4 [-Wcast-align]
t1 = *(uint32_t *)PTOV(0x46c);
  ^~~

i think t0 and t1 can be turned into uint8_t's and PTOV(0x46c); can be casted
to (uint8_t *), instead of (uint32_t *).


Maybe, but further changes would be required.  The variable is a 32-bit
tick counter.  I think the tick frequency is 18.2 Hz.  This will wrap
after some time, and the code is already broken when it wraps.  This
brokenness is not too important since this code is normally used soon
after booting and the wrap occurs after 7.25 years, but if you reduce
the counts to uint8_t's then the wrap occurs after only 14 seconds,
so you should be more careful.  From an old version of boot2.c:

% static int
% keyhit(unsigned ticks)

Ticks might also be best as uint8_t, especially if t0 and t1 are changed
to uint8_t.  It always has the value 3*SECOND or 5*SECOND, where SECOND
is the tick frequency 18.2 rounded to 18 (rounding gives an error of 1
tick after 5 seconds; this can be fixed using floating point evaluated
at compile time).  I think the compiler is prevented from reducing it
to its constant value by lack of (implicit) inlining.

% {
% uint32_t t0, t1;
% 
% if (opts & 1 << RBX_NOINTR)

%   return 0;

The only change in the current verion is to obfuscate the bit test using
a macro.  Such optimizations make it hard to see where the bloat is.

% t0 = 0;
% for (;;) {
%   if (xgetc(1))
%   return 1;
%   t1 = *(uint32_t *)PTOV(0x46c);
%   if (!t0)
%   t0 = t1;

Might be able to rewrite this so it is auto-initializing without a special
case.  Try putting 't0 = *(uint32_t *)PTOV(0x46c);' outside of the loop.
I think it is intentionally not done this way since PTOV(0x46c) involves
the large address constant 0x46c (which tends to generate large code
(see below)) and the PTOV() macro makes this worse due to the bad
implementation of this macro.  (PTOV(pa) is ((caddr_t)(pa) - __base).
Subtracting the base makes no sense, and defeats the normal address
mode base+offset.  However, here the address of PTOV(0x46C) is best
calculated (with the bad PTOV()) by loading 0x46C into a register and
subtracting __base.  Then we have a pointer to it and can load t0
initially by just dereferencing this pointer.  With the better PTOV(pa)
of (__actual_base_with_the_correct_type + (pa)) the best calculation
of the address is to load the actual base into a register and not add
0x46C to that register if we are only using PTOV(0x46c) once, but when
PTOV(046c) is used twice the best code is less clear.)

%   if (t1 < t0 || t1 >= t0 + ticks)
%   return 0;

Oops, this does handle wrap, but in a slow way and sloppy way.  t1 <
t0 means that the counter has wrapped.  We then return immediately.
Not too bad if there is 1 error 7.25 years after booting.  With the
counter reduced to 8 bits, this error after 14 seconds would be
annoying.  But the usual method of handling cyclic counters takes
less code and is less sloppy:

if ((counter_size_t)(t1 - t0) >= ticks)
return 0;

We must be careful with the cast.  Then this works with a counter_size_t
of uint8_t, since the maximum value for `ticks' is 70 which fits in 8
bits.  Also, we can almost guarantee that this code isn't interrupted,
so we won't miss a single change of the counter.  With interruption,
we would have to be very unlucky to miss a counter rollover after 7.25
7.25 years or even after 14 seconds, and even if we miss we would
normally only wait at most `ticks' ticks extra; then we do a less-wrong
thing than returning early.

% }
% }


this will actually increase the size.


Maybe.  Smaller types often give larger object code due to extra prefix
bytes (in i386 code) and extra instructions to promote the types before
using them.  16-bit types in 32-bit i386 code are especially bad, since
they require prefixes.  In the above, t1 < t0 gives the same size object
code with either uint8_t or unisigned.  t1 >= t0 + ticks gives larger
object code with uint8_t.  At least 1 movl will have to become movzbl
to promote a uint8_t.  But with everything uint8_t, only 8-bit
instructions should be needed.


with this additional change the code fits when compiled with clang:

diff --git a/sys/boot/i386/boot2/sio.S b/sys/boot/i386/boot2/sio.S
index 7b8e9eb..d745129 100644

svn commit: r218766 - head/tools/tools/sysbuild

2011-02-17 Thread Poul-Henning Kamp
Author: phk
Date: Thu Feb 17 08:54:22 2011
New Revision: 218766
URL: http://svn.freebsd.org/changeset/base/218766

Log:
  Improve the check for ports which have gone missing, and just ignore
  them.  We want a run to perform as much work as possible before it
  gives up.

Modified:
  head/tools/tools/sysbuild/sysbuild.sh

Modified: head/tools/tools/sysbuild/sysbuild.sh
==
--- head/tools/tools/sysbuild/sysbuild.sh   Thu Feb 17 07:39:53 2011
(r218765)
+++ head/tools/tools/sysbuild/sysbuild.sh   Thu Feb 17 08:54:22 2011
(r218766)
@@ -178,7 +178,11 @@ ports_recurse() (
do
if [ ! -d $d ] ; then
echo "Missing port $d" 1>&2
-   exit 2
+   continue
+   fi
+   if [ ! -f $d/Makefile ] ; then
+   echo "Missing port $d" 1>&2
+   continue
fi
if [ "x$t" != "x." ] ; then
echo "\"$t\" -> \"$d\"" >> /tmp/_.plist.dot
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r218745 - head/sys/boot/i386/boot2

2011-02-17 Thread Roman Divacky
I have some more WIP patches that shrink stuff some more,
plus I have clang/llvm changes that help too.. this will
get fixed

On Thu, Feb 17, 2011 at 01:52:11AM +, Alexander Best wrote:
> On Wed Feb 16 11, Warner Losh wrote:
> > Author: imp
> > Date: Wed Feb 16 18:05:10 2011
> > New Revision: 218745
> > URL: http://svn.freebsd.org/changeset/base/218745
> > 
> > Log:
> >   Remove reading of symbols from a.out loaded files.  Since we are tight
> >   on space for clang and a.out support is only needed for /boot/loader,
> >   they are excess bytes that serve no useful purpose other than to
> >   support really old kernels (FreeBSD < 3.2 or so).  Prefer clang
> >   support over support for these old kernels and remove this code.  We
> >   gain about 100 bytes of space this way.
> 
> sorry for my crappy previous attempt to reduce boot2's size. obviously
> the *.S files aren't the problem, because even with clang we're using GAS.
> so working on boot2.c is the only way of reducing the size.
> 
> i've managed to do so (even with another 4 bytes to spare) with the attached
> patch.
> 
> i did
> 
> otaku% grep -r bi_basemem *
> sys/boot/i386/boot2/boot2.c:bootinfo.bi_basemem = 0;  /* XXX will be 
> filled by loader or kernel */
> sys/boot/i386/boot2/machine/bootinfo.h:   u_int32_t   bi_basemem;
> sys/boot/i386/gptboot/gptboot.c:  bootinfo.bi_basemem = 0;/* XXX 
> will be filled by loader or kernel */
> sys/boot/i386/libi386/bootinfo32.c:bi.bi_basemem = bios_basemem / 1024;
> sys/boot/i386/loader/main.c:  initial_bootinfo->bi_basemem = bios_basemem / 
> 1024;
> sys/boot/i386/zfsboot/zfsboot.c:bootinfo.bi_basemem = bios_basemem / 1024;
> sys/boot/pc98/boot2/boot2.c:bootinfo.bi_basemem = 0;  /* XXX will be 
> filled by loader or kernel */
> sys/boot/pc98/loader/main.c:  initial_bootinfo->bi_basemem = bios_basemem / 
> 1024;
> sys/i386/include/bootinfo.h:  u_int32_t   bi_basemem;
> sys/mips/include/bootinfo.h:  u_int32_t   bi_basemem;
> 
> which led me to the conclusion that bootinfo.bi_basemem doesn't need to
> initialised, because it will always be set by the loader (as the XXX comment
> says).
> 
> turning ioctrl from uint8_t to int also saves a few bytes for whatever 
> reason).
> removing x doesn't save any bytes, but gets rid of a warning (as noted in one
> of my messages).
> 
> cheers.
> alex
> 
> ...and sorry for the previous noise. :(
> 
> >   
> >   Reviewed by:  rdivacky@
> > 
> > Modified:
> >   head/sys/boot/i386/boot2/boot2.c
> > 
> > Modified: head/sys/boot/i386/boot2/boot2.c
> > ==
> > --- head/sys/boot/i386/boot2/boot2.cWed Feb 16 17:50:21 2011
> > (r218744)
> > +++ head/sys/boot/i386/boot2/boot2.cWed Feb 16 18:05:10 2011
> > (r218745)
> > @@ -347,23 +347,6 @@ load(void)
> > p += roundup2(hdr.ex.a_text, PAGE_SIZE);
> > if (xfsread(ino, p, hdr.ex.a_data))
> > return;
> > -   p += hdr.ex.a_data + roundup2(hdr.ex.a_bss, PAGE_SIZE);
> > -   bootinfo.bi_symtab = VTOP(p);
> > -   *(uint32_t*)p = hdr.ex.a_syms;
> > -   p += sizeof(hdr.ex.a_syms);
> > -   if (hdr.ex.a_syms) {
> > -   if (xfsread(ino, p, hdr.ex.a_syms))
> > -   return;
> > -   p += hdr.ex.a_syms;
> > -   if (xfsread(ino, p, sizeof(int)))
> > -   return;
> > -   x = *(uint32_t *)p;
> > -   p += sizeof(int);
> > -   x -= sizeof(int);
> > -   if (xfsread(ino, p, x))
> > -   return;
> > -   p += x;
> > -   }
> >  } else {
> > fs_off = hdr.eh.e_phoff;
> > for (j = i = 0; i < hdr.eh.e_phnum && j < 2; i++) {
> > @@ -395,8 +378,8 @@ load(void)
> > }
> > }
> > addr = hdr.eh.e_entry & 0xff;
> > +   bootinfo.bi_esymtab = VTOP(p);
> >  }
> > -bootinfo.bi_esymtab = VTOP(p);
> >  bootinfo.bi_kernelname = VTOP(kname);
> >  bootinfo.bi_bios_dev = dsk.drive;
> >  __exec((caddr_t)addr, RB_BOOTINFO | (opts & RBX_MASK),
> 
> -- 
> a13x

> diff --git a/sys/boot/i386/boot2/boot2.c b/sys/boot/i386/boot2/boot2.c
> index 3849725..d572700 100644
> --- a/sys/boot/i386/boot2/boot2.c
> +++ b/sys/boot/i386/boot2/boot2.c
> @@ -135,7 +135,7 @@ static char kname[1024];
>  static uint16_t opts;
>  static int comspeed = SIOSPD;
>  static struct bootinfo bootinfo;
> -static uint8_t ioctrl = IO_KEYBOARD;
> +static int ioctrl = IO_KEYBOARD;
>  
>  void exit(int);
>  static void load(void);
> @@ -245,7 +245,7 @@ main(void)
>  dsk.slice = *(uint8_t *)PTOV(ARGS + 1) + 1;
>  bootinfo.bi_version = BOOTINFO_VERSION;
>  bootinfo.bi_size = sizeof(bootinfo);
> -bootinfo.bi_basemem = 0; /* XXX will be filled by loader or kernel */
> +/* bootinfo.bi_basemem = 0;  XXX will be filled by loader or kernel 
> */
>  bootinfo.bi_extmem = memsize();
>  bootinfo.bi_memsizes_valid++;
>  
> @@ -319,7 +319,7 @@ load(void)
>  static Elf32_Shdr es[2];
>  caddr_t p;
>  ino_t ino