int hieth_mdio_read(struct hieth_mdio_local *ld, int phy_addr, int regnum) { int val = 0; hieth_assert((!(phy_addr & (~0x1F))) && (!(regnum & (~0x1F)))); local_lock(ld); if (!wait_mdio_ready(ld)) { hieth_error("mdio busy"); goto error_exit; } mdio_start_phyread(ld, phy_addr, regnum); if (wait_mdio_ready(ld)) val = mdio_get_phyread_val(ld); else hieth_error("read timeout"); error_exit: local_unlock(ld); hieth_trace(4, "phy_addr = %d, regnum = %d, val = 0x%04x", phy_addr, regnum, val); return val; }
int hieth_mdio_write( struct hieth_mdio_local *ld, int phy_addr, int regnum, int val) { int ret = 0; hieth_assert((!(phy_addr & (~0x1F))) && (!(regnum & (~0x1F)))); hieth_trace(4, "phy_addr = %d, regnum = %d", phy_addr, regnum); local_lock(ld); if (!wait_mdio_ready(ld)) { hieth_error("mdio busy"); ret = -1; goto error_exit; } mdio_phywrite(ld, phy_addr, regnum, val); error_exit: local_unlock(ld); return val; }
static int hieth_net_set_mac_address(struct net_device *dev, void *p) { struct hieth_netdev_local *ld = netdev_priv(dev); struct sockaddr *skaddr = p; if (netif_running(dev)) return -EBUSY; if (!is_valid_ether_addr(skaddr->sa_data)) return -EADDRNOTAVAIL; local_lock(ld); if (hieth_devs_save[UP_PORT]) memcpy(hieth_devs_save[UP_PORT]->dev_addr, skaddr->sa_data, dev->addr_len); if (hieth_devs_save[DOWN_PORT]) memcpy(hieth_devs_save[DOWN_PORT]->dev_addr, skaddr->sa_data, dev->addr_len); local_unlock(ld); hieth_hw_set_macaddress(ld, 1, dev->dev_addr); return 0; }
static void purge_pid(pid_t pid) { DPF((stderr, "purge locks for %ld\n", pid)); unqueue_lock(NULL, pid); if (the_lock.type != LOCK_NOTLOCKED) local_unlock(pid, 0, FORCE_UNLOCK); }
int hieth_get_linkstat(struct hieth_netdev_local *ld) { unsigned long old; local_lock(ld); old = hieth_readl_bits(ld, UD_REG_NAME(MAC_RO_STAT), BITS_MACSTAT); local_unlock(ld); return old; }
int hieth_set_linkstat(struct hieth_netdev_local *ld, int mode) { unsigned long old; local_lock(ld); old = _set_linkstat(ld, mode); local_unlock(ld); return old; }
int hieth_read_raw_irqstatus(struct hieth_netdev_local *ld) { int status; local_lock(ld); status = hieth_readl(ld, GLB_RO_IRQ_STAT); local_unlock(ld); return status; }
int hieth_set_negmode(struct hieth_netdev_local *ld, int mode) { int old; local_lock(ld); old = _set_negmode(ld, mode); local_unlock(ld); return old; }
int hieth_get_negmode(struct hieth_netdev_local *ld) { int old; local_lock(ld); old = _get_negmode(ld); local_unlock(ld); return old; }
int hieth_read_irqstatus(struct hieth_netdev_local *ld) { int status; local_lock(ld); status = _hieth_read_irqstatus(ld); local_unlock(ld); return status; }
int hieth_irq_disable(struct hieth_netdev_local *ld, int irqs) { int old; local_lock(ld); old = _hieth_irq_disable(ld, irqs); local_unlock(ld); return old; }
int hieth_set_mii_mode(struct hieth_netdev_local *ld, int mode) { int old; local_lock(ld); old = hieth_readl_bits(ld, UD_REG_NAME(MAC_PORTSEL), BITS_MII_MODE); hieth_writel_bits(ld, mode, UD_REG_NAME(MAC_PORTSEL), BITS_MII_MODE); local_unlock(ld); return old; }
int hieth_set_mac_fc_interval(struct hieth_netdev_local *ld, int para) { int old; local_lock(ld); old = hieth_readl_bits(ld, UD_REG_NAME(MAC_TX_IPGCTRL), BITS_FC_INTER); hieth_writel_bits(ld, para, UD_REG_NAME(MAC_TX_IPGCTRL), BITS_FC_INTER); local_unlock(ld); return old; }
int hieth_clear_irqstatus(struct hieth_netdev_local *ld, int irqs) { int status; local_lock(ld); hieth_writel(ld, irqs, GLB_RW_IRQ_RAW); status = _hieth_read_irqstatus(ld); local_unlock(ld); return status; }
int hieth_set_endian_mode(struct hieth_netdev_local *ld, int mode) { int old; local_lock(ld); old = hieth_readl_bits(ld, GLB_ENDIAN_MOD, BITS_ENDIAN); hieth_writel_bits(ld, mode, GLB_ENDIAN_MOD, BITS_ENDIAN); local_unlock(ld); return old; }
PHPAPI char *php_asctime_r(const struct tm *tm, char *buf) { char *tmp; local_lock(ASCTIME_R); tmp = asctime(tm); strcpy(buf, tmp); local_unlock(ASCTIME_R); return buf; }
PHPAPI char *php_ctime_r(const time_t *clock, char *buf) { char *tmp; local_lock(CTIME_R); tmp = ctime(clock); strcpy(buf, tmp); local_unlock(CTIME_R); return buf; }
int hieth_set_mac_leadcode_cnt_limit(struct hieth_netdev_local *ld, int cnt) { int old; local_lock(ld); old = hieth_readl_bits(ld, UD_REG_NAME(MAC_TX_IPGCTRL), BITS_PRE_CNT_LIMIT); hieth_writel_bits(ld, cnt, UD_REG_NAME(MAC_TX_IPGCTRL), BITS_PRE_CNT_LIMIT); local_unlock(ld); return old; }
PHPAPI struct tm *php_gmtime_r(const time_t *const timep, struct tm *p_tm) { struct tm *tmp; local_lock(GMTIME_R); tmp = gmtime(timep); if (tmp) { memcpy(p_tm, tmp, sizeof(struct tm)); tmp = p_tm; } local_unlock(GMTIME_R); return tmp; }
PHPAPI int php_readdir_r(DIR *dirp, struct dirent *entry, struct dirent **result) { #if defined(HAVE_OLD_READDIR_R) int ret = 0; /* We cannot rely on the return value of readdir_r as it differs between various platforms (HPUX returns 0 on success whereas Solaris returns non-zero) */ entry->d_name[0] = '\0'; readdir_r(dirp, entry); if (entry->d_name[0] == '\0') { *result = NULL; ret = errno; } else { *result = entry; } return ret; #else struct dirent *ptr; int ret = 0; local_lock(READDIR_R); errno = 0; ptr = readdir(dirp); if (!ptr && errno != 0) ret = errno; if (ptr) memcpy(entry, ptr, sizeof(*ptr)); *result = ptr; local_unlock(READDIR_R); return ret; #endif }
static int hieth_net_set_mac_address(struct net_device *dev, void *p) { struct hieth_netdev_local *ld = netdev_priv(dev); struct sockaddr *skaddr = p; local_lock(ld); if (hieth_devs_save[UP_PORT]) memcpy(hieth_devs_save[UP_PORT]->dev_addr, skaddr->sa_data, dev->addr_len); if (hieth_devs_save[DOWN_PORT]) memcpy(hieth_devs_save[DOWN_PORT]->dev_addr, skaddr->sa_data, dev->addr_len); local_unlock(ld); hieth_hw_set_macaddress(ld, 1, dev->dev_addr); return 0; }
int hieth_set_mac_trans_interval_bits(struct hieth_netdev_local *ld, int nbits) { int old; int linkstat, negmode; local_lock(ld); negmode = _set_negmode(ld, HIETH_NEGMODE_CPUSET); linkstat = _set_linkstat(ld, 0); udelay(1000); old = hieth_readl_bits(ld, UD_REG_NAME(MAC_TX_IPGCTRL), BITS_IPG); hieth_writel_bits(ld, nbits, UD_REG_NAME(MAC_TX_IPGCTRL), BITS_IPG); udelay(100); _set_negmode(ld, negmode); _set_linkstat(ld, linkstat); local_unlock(ld); return old; }
static void dispatch(struct lock_msg *mp, daemonaddr_t *host) { int message = mp->message; int localhost; localhost = islocalhost(host); if (msgtrace && debugfile) { time_t t = time(0); if (localhost) { (void) fprintf(debugfile, "%19.19s recv %-9.9s from %s (%ld)\n", ctime(&t), lockd_msg(message), dp_addr(host), mp->pid); } else { (void) fprintf(debugfile, "%19.19s recv %-9.9s from %s order %d (%ld)\n", ctime(&t), lockd_msg(message), dp_addr(host), mp->order, mp->pid); } } DPF((stderr, "received message %d\n", message)); DPF((stderr, "from %s port %hu\n", dp_addr(host), host->sin_port)); if (!localhost) daemon_alive(host, mp->order); else mp->order = order; switch (message) { case ALIVE: DPF((stderr, "received ALIVE %s\n", dp_addr(host))); /* do nothing, general "not localhost" code above does this */ break; case UNLOCK: DPF((stderr, "received UNLOCK\n")); remote_unlock(mp->order, host); break; case GRANTED: DPF((stderr, "received GRANTED\n")); lock_granted(host); break; case WRITE_LOCK: DPF((stderr, "received WRITE_LOCK\n")); assert(!localhost); remote_lock(host, mp); break; case READ_LOCK: case LOCK_READ: DPF((stderr, "received READ_LOCK\n")); assert(localhost); local_lock(LOCK_READ, mp, host); break; case LOCK_WRITE: DPF((stderr, "received LOCK_WRITE\n")); assert(localhost); local_lock(LOCK_WRITE, mp, host); break; case LOCK_NOTLOCKED: DPF((stderr, "received LOCK_NOTLOCKED\n")); send_lockmsg(LOCK_ACK, (pid_t)0, host, mp->seq); if (the_lock.type != LOCK_NOTLOCKED) { local_unlock(mp->pid, mp->seq, NORMAL_UNLOCK); } break; case LOCK_LOCKEDBY: lockedby(host, mp->seq); break; case LOCK_STAT: lock_stat(); break; case LOCK_ACK: /* throw message away -- this is an error to receive */ break; } }