sync code with last improvements from OpenBSD
This commit is contained in:
parent
81d24aa0e0
commit
361861c7dd
@ -1,4 +1,4 @@
|
|||||||
/* $OpenBSD: p_lib.c,v 1.34 2023/07/07 19:37:54 beck Exp $ */
|
/* $OpenBSD: p_lib.c,v 1.35 2023/09/01 17:12:19 tb Exp $ */
|
||||||
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
@ -439,11 +439,11 @@ EVP_PKEY_get0_hmac(const EVP_PKEY *pkey, size_t *len)
|
|||||||
RSA *
|
RSA *
|
||||||
EVP_PKEY_get0_RSA(EVP_PKEY *pkey)
|
EVP_PKEY_get0_RSA(EVP_PKEY *pkey)
|
||||||
{
|
{
|
||||||
if (pkey->type != EVP_PKEY_RSA) {
|
if (pkey->type == EVP_PKEY_RSA || pkey->type == EVP_PKEY_RSA_PSS)
|
||||||
EVPerror(EVP_R_EXPECTING_AN_RSA_KEY);
|
return pkey->pkey.rsa;
|
||||||
return NULL;
|
|
||||||
}
|
EVPerror(EVP_R_EXPECTING_AN_RSA_KEY);
|
||||||
return pkey->pkey.rsa;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
RSA *
|
RSA *
|
||||||
|
@ -1,10 +1,11 @@
|
|||||||
.\" $OpenBSD: EVP_CIPHER_nid.3,v 1.1 2023/08/31 17:27:41 schwarze Exp $
|
.\" $OpenBSD: EVP_CIPHER_nid.3,v 1.2 2023/09/01 17:28:21 schwarze Exp $
|
||||||
.\" full merge up to: OpenSSL 5211e094 Nov 11 14:39:11 2014 -0800
|
.\" full merge up to: OpenSSL man3/EVP_EncryptInit.pod
|
||||||
|
.\" 0874d7f2 Oct 11 13:13:47 2022 +0100
|
||||||
.\"
|
.\"
|
||||||
.\" This file is a derived work.
|
.\" This file is a derived work.
|
||||||
.\" The changes are covered by the following Copyright and license:
|
.\" The changes are covered by the following Copyright and license:
|
||||||
.\"
|
.\"
|
||||||
.\" Copyright (c) 2018 Ingo Schwarze <schwarze@openbsd.org>
|
.\" Copyright (c) 2018, 2023 Ingo Schwarze <schwarze@openbsd.org>
|
||||||
.\"
|
.\"
|
||||||
.\" Permission to use, copy, modify, and distribute this software for any
|
.\" Permission to use, copy, modify, and distribute this software for any
|
||||||
.\" purpose with or without fee is hereby granted, provided that the above
|
.\" purpose with or without fee is hereby granted, provided that the above
|
||||||
@ -65,7 +66,7 @@
|
|||||||
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||||
.\" OF THE POSSIBILITY OF SUCH DAMAGE.
|
.\" OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
.\"
|
.\"
|
||||||
.Dd $Mdocdate: August 31 2023 $
|
.Dd $Mdocdate: September 1 2023 $
|
||||||
.Dt EVP_CIPHER_NID 3
|
.Dt EVP_CIPHER_NID 3
|
||||||
.Os
|
.Os
|
||||||
.Sh NAME
|
.Sh NAME
|
||||||
@ -84,7 +85,7 @@
|
|||||||
.In openssl/evp.h
|
.In openssl/evp.h
|
||||||
.Ft int
|
.Ft int
|
||||||
.Fo EVP_CIPHER_nid
|
.Fo EVP_CIPHER_nid
|
||||||
.Fa "const EVP_CIPHER *e"
|
.Fa "const EVP_CIPHER *cipher"
|
||||||
.Fc
|
.Fc
|
||||||
.Ft int
|
.Ft int
|
||||||
.Fo EVP_CIPHER_CTX_nid
|
.Fo EVP_CIPHER_CTX_nid
|
||||||
@ -100,7 +101,7 @@
|
|||||||
.Fc
|
.Fc
|
||||||
.Ft int
|
.Ft int
|
||||||
.Fo EVP_CIPHER_block_size
|
.Fo EVP_CIPHER_block_size
|
||||||
.Fa "const EVP_CIPHER *e"
|
.Fa "const EVP_CIPHER *cipher"
|
||||||
.Fc
|
.Fc
|
||||||
.Ft int
|
.Ft int
|
||||||
.Fo EVP_CIPHER_CTX_block_size
|
.Fo EVP_CIPHER_CTX_block_size
|
||||||
@ -108,7 +109,7 @@
|
|||||||
.Fc
|
.Fc
|
||||||
.Ft unsigned long
|
.Ft unsigned long
|
||||||
.Fo EVP_CIPHER_flags
|
.Fo EVP_CIPHER_flags
|
||||||
.Fa "const EVP_CIPHER *e"
|
.Fa "const EVP_CIPHER *cipher"
|
||||||
.Fc
|
.Fc
|
||||||
.Ft unsigned long
|
.Ft unsigned long
|
||||||
.Fo EVP_CIPHER_CTX_flags
|
.Fo EVP_CIPHER_CTX_flags
|
||||||
@ -116,7 +117,7 @@
|
|||||||
.Fc
|
.Fc
|
||||||
.Ft unsigned long
|
.Ft unsigned long
|
||||||
.Fo EVP_CIPHER_mode
|
.Fo EVP_CIPHER_mode
|
||||||
.Fa "const EVP_CIPHER *e"
|
.Fa "const EVP_CIPHER *cipher"
|
||||||
.Fc
|
.Fc
|
||||||
.Ft unsigned long
|
.Ft unsigned long
|
||||||
.Fo EVP_CIPHER_CTX_mode
|
.Fo EVP_CIPHER_CTX_mode
|
||||||
@ -124,74 +125,124 @@
|
|||||||
.Fc
|
.Fc
|
||||||
.Sh DESCRIPTION
|
.Sh DESCRIPTION
|
||||||
.Fn EVP_CIPHER_nid
|
.Fn EVP_CIPHER_nid
|
||||||
and
|
returns the numerical identifier (NID) of the
|
||||||
|
.Fa cipher .
|
||||||
|
The NID is an internal value which may or may not have a corresponding
|
||||||
|
ASN.1 OBJECT IDENTIFIER; see
|
||||||
|
.Xr OBJ_nid2obj 3
|
||||||
|
for details.
|
||||||
|
.Pp
|
||||||
.Fn EVP_CIPHER_CTX_nid
|
.Fn EVP_CIPHER_CTX_nid
|
||||||
return the NID of a cipher when passed an
|
returns the NID of the cipher that
|
||||||
.Vt EVP_CIPHER
|
.Fa ctx
|
||||||
or
|
is configured to use.
|
||||||
.Vt EVP_CIPHER_CTX
|
|
||||||
structure.
|
|
||||||
The actual NID value is an internal value which may not have a
|
|
||||||
corresponding OBJECT IDENTIFIER.
|
|
||||||
.Pp
|
.Pp
|
||||||
.Fn EVP_CIPHER_type
|
.Fn EVP_CIPHER_type
|
||||||
|
returns the NID associated with the ASN.1 OBJECT IDENTIFIER of the
|
||||||
|
.Fa cipher ,
|
||||||
|
ignoring the cipher parameters.
|
||||||
|
For example,
|
||||||
|
.Xr EVP_aes_256_cfb1 3 ,
|
||||||
|
.Xr EVP_aes_256_cfb8 3 ,
|
||||||
and
|
and
|
||||||
|
.Xr EVP_aes_256_cfb128 3
|
||||||
|
all return the same NID,
|
||||||
|
.Dv NID_aes_256_cfb128 .
|
||||||
|
.Pp
|
||||||
.Fn EVP_CIPHER_CTX_type
|
.Fn EVP_CIPHER_CTX_type
|
||||||
return the type of the passed cipher or context.
|
returns the NID associated with the ASN.1 OBJECT IDENTIFIER of the cipher that
|
||||||
This "type" is the actual NID of the cipher OBJECT IDENTIFIER as such it
|
.Fa ctx
|
||||||
ignores the cipher parameters and 40-bit RC2 and 128-bit RC2 have the
|
is configured to use.
|
||||||
same NID.
|
|
||||||
If the cipher does not have an object identifier or does not
|
|
||||||
have ASN.1 support, this function will return
|
|
||||||
.Dv NID_undef .
|
|
||||||
.Pp
|
.Pp
|
||||||
.Fn EVP_CIPHER_block_size
|
.Fn EVP_CIPHER_block_size
|
||||||
and
|
returns the block size of the
|
||||||
|
.Fa cipher
|
||||||
|
in bytes.
|
||||||
.Fn EVP_CIPHER_CTX_block_size
|
.Fn EVP_CIPHER_CTX_block_size
|
||||||
return the block size of a cipher when passed an
|
returns the block size of the cipher that
|
||||||
.Vt EVP_CIPHER
|
.Fa ctx
|
||||||
or
|
is configured to use.
|
||||||
.Vt EVP_CIPHER_CTX
|
Block sizes are guaranteed to be less than or equal to the constant
|
||||||
structure.
|
.Dv EVP_MAX_BLOCK_LENGTH .
|
||||||
The constant
|
Currently,
|
||||||
.Dv EVP_MAX_BLOCK_LENGTH
|
.Xr EVP_CipherInit_ex 3
|
||||||
is also the maximum block length for all ciphers.
|
and the other functions documented in the same manual page
|
||||||
|
only support block sizes of 1, 8, and 16 bytes.
|
||||||
|
.Pp
|
||||||
|
.Fn EVP_CIPHER_flags
|
||||||
|
returns the cipher flags used by the
|
||||||
|
.Fa cipher .
|
||||||
|
The meaning of the flags is described in the
|
||||||
|
.Xr EVP_CIPHER_meth_set_flags 3
|
||||||
|
manual page.
|
||||||
|
.Pp
|
||||||
|
.Fn EVP_CIPHER_CTX_flags
|
||||||
|
returns the cipher flags of the cipher that
|
||||||
|
.Fa ctx
|
||||||
|
is configured to use.
|
||||||
|
Be careful to not confuse these with the unrelated cipher context flags
|
||||||
|
that can be inspected with
|
||||||
|
.Xr EVP_CIPHER_CTX_test_flags 3 .
|
||||||
.Pp
|
.Pp
|
||||||
.Fn EVP_CIPHER_mode
|
.Fn EVP_CIPHER_mode
|
||||||
and
|
returns the
|
||||||
|
.Fa cipher
|
||||||
|
mode, which is the logical AND of the constant
|
||||||
|
.Dv EVP_CIPH_MODE
|
||||||
|
and the return value of
|
||||||
|
.Fn EVP_CIPHER_flags .
|
||||||
|
.Pp
|
||||||
.Fn EVP_CIPHER_CTX_mode
|
.Fn EVP_CIPHER_CTX_mode
|
||||||
return the block cipher mode:
|
returns the cipher mode of the cipher that
|
||||||
.Dv EVP_CIPH_ECB_MODE ,
|
.Fa ctx
|
||||||
.Dv EVP_CIPH_CBC_MODE ,
|
is configured to use.
|
||||||
.Dv EVP_CIPH_CFB_MODE ,
|
|
||||||
.Dv EVP_CIPH_OFB_MODE ,
|
|
||||||
.Dv EVP_CIPH_CTR_MODE ,
|
|
||||||
or
|
|
||||||
.Dv EVP_CIPH_XTS_MODE .
|
|
||||||
If the cipher is a stream cipher then
|
|
||||||
.Dv EVP_CIPH_STREAM_CIPHER
|
|
||||||
is returned.
|
|
||||||
.Sh RETURN VALUES
|
.Sh RETURN VALUES
|
||||||
.Fn EVP_CIPHER_nid
|
.Fn EVP_CIPHER_nid
|
||||||
and
|
and
|
||||||
.Fn EVP_CIPHER_CTX_nid
|
.Fn EVP_CIPHER_CTX_nid
|
||||||
return a NID.
|
return an NID.
|
||||||
.Pp
|
.Pp
|
||||||
.Fn EVP_CIPHER_type
|
.Fn EVP_CIPHER_type
|
||||||
and
|
and
|
||||||
.Fn EVP_CIPHER_CTX_type
|
.Fn EVP_CIPHER_CTX_type
|
||||||
return the NID of the cipher's OBJECT IDENTIFIER or
|
return the NID of the cipher's OBJECT IDENTIFIER or
|
||||||
.Dv NID_undef
|
.Dv NID_undef
|
||||||
if it has no defined OBJECT IDENTIFIER.
|
if it is not associated with an OBJECT IDENTIFIER.
|
||||||
.Pp
|
.Pp
|
||||||
.Fn EVP_CIPHER_block_size
|
.Fn EVP_CIPHER_block_size
|
||||||
and
|
and
|
||||||
.Fn EVP_CIPHER_CTX_block_size
|
.Fn EVP_CIPHER_CTX_block_size
|
||||||
return the block size.
|
return the block size in bytes.
|
||||||
|
.Pp
|
||||||
|
.Fn EVP_CIPHER_flags
|
||||||
|
and
|
||||||
|
.Fn EVP_CIPHER_CTX_flags
|
||||||
|
return one or more
|
||||||
|
.Dv EVP_CIPH_*
|
||||||
|
flag bits OR'ed together.
|
||||||
|
.Pp
|
||||||
|
.Fn EVP_CIPHER_mode
|
||||||
|
and
|
||||||
|
.Fn EVP_CIPHER_CTX_mode
|
||||||
|
return one of the constants
|
||||||
|
.Dv EVP_CIPH_ECB_MODE ,
|
||||||
|
.Dv EVP_CIPH_CBC_MODE ,
|
||||||
|
.Dv EVP_CIPH_CFB_MODE ,
|
||||||
|
.Dv EVP_CIPH_OFB_MODE ,
|
||||||
|
.Dv EVP_CIPH_CTR_MODE ,
|
||||||
|
.Dv EVP_CIPH_GCM_MODE ,
|
||||||
|
.Dv EVP_CIPH_CCM_MODE ,
|
||||||
|
.Dv EVP_CIPH_XTS_MODE ,
|
||||||
|
or
|
||||||
|
.Dv EVP_CIPH_WRAP_MODE
|
||||||
|
to indicate a block cipher or
|
||||||
|
.Dv EVP_CIPH_STREAM_CIPHER
|
||||||
|
to indicate a stream cipher.
|
||||||
.Sh SEE ALSO
|
.Sh SEE ALSO
|
||||||
.Xr evp 3 ,
|
.Xr evp 3 ,
|
||||||
.Xr EVP_CIPHER_CTX_ctrl 3 ,
|
.Xr EVP_CIPHER_CTX_ctrl 3 ,
|
||||||
.Xr EVP_EncryptInit 3
|
.Xr EVP_EncryptInit 3 ,
|
||||||
|
.Xr OBJ_nid2obj 3
|
||||||
.Sh HISTORY
|
.Sh HISTORY
|
||||||
.Fn EVP_CIPHER_type ,
|
.Fn EVP_CIPHER_type ,
|
||||||
.Fn EVP_CIPHER_CTX_type ,
|
.Fn EVP_CIPHER_CTX_type ,
|
||||||
@ -213,3 +264,13 @@ and
|
|||||||
.Fn EVP_CIPHER_CTX_mode
|
.Fn EVP_CIPHER_CTX_mode
|
||||||
first appeared in OpenSSL 0.9.6 and have been available since
|
first appeared in OpenSSL 0.9.6 and have been available since
|
||||||
.Ox 2.9 .
|
.Ox 2.9 .
|
||||||
|
.Sh CAVEATS
|
||||||
|
The behaviour of the functions taking an
|
||||||
|
.Vt EVP_CIPHER_CTX
|
||||||
|
argument is undefined if they are called on a
|
||||||
|
.Fa ctx
|
||||||
|
that has no cipher configured yet, for example one freshly returned from
|
||||||
|
.Xr EVP_CIPHER_CTX_new 3 .
|
||||||
|
In that case, the program may for example be terminated by a
|
||||||
|
.Dv NULL
|
||||||
|
pointer access.
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $OpenBSD: ytphy.c,v 1.3 2023/07/08 08:18:30 kettenis Exp $ */
|
/* $OpenBSD: ytphy.c,v 1.4 2023/09/01 20:35:31 kettenis Exp $ */
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2001 Theo de Raadt
|
* Copyright (c) 2001 Theo de Raadt
|
||||||
* Copyright (c) 2023 Mark Kettenis <kettenis@openbsd.org>
|
* Copyright (c) 2023 Mark Kettenis <kettenis@openbsd.org>
|
||||||
@ -57,12 +57,22 @@
|
|||||||
|
|
||||||
#define YT8521_EXT_CHIP_CONFIG 0xa001
|
#define YT8521_EXT_CHIP_CONFIG 0xa001
|
||||||
#define YT8521_RXC_DLY_EN (1 << 8)
|
#define YT8521_RXC_DLY_EN (1 << 8)
|
||||||
|
#define YT8521_CFG_LDO_MASK (0x3 << 4)
|
||||||
|
#define YT8521_CFG_LDO_3V3 0x0
|
||||||
|
#define YT8521_CFG_LDO_2V5 0x1
|
||||||
|
#define YT8521_CFG_LDO_1V8 0x2 /* or 0x3 */
|
||||||
#define YT8521_EXT_RGMII_CONFIG1 0xa003
|
#define YT8521_EXT_RGMII_CONFIG1 0xa003
|
||||||
#define YT8521_TX_CLK_SEL (1 << 14)
|
#define YT8521_TX_CLK_SEL (1 << 14)
|
||||||
#define YT8521_RX_DELAY_SEL_MASK (0xf << 10)
|
#define YT8521_RX_DELAY_SEL_MASK (0xf << 10)
|
||||||
#define YT8521_RX_DELAY_SEL_SHIFT 10
|
#define YT8521_RX_DELAY_SEL_SHIFT 10
|
||||||
#define YT8521_TX_DELAY_SEL_MASK (0xf << 0)
|
#define YT8521_TX_DELAY_SEL_MASK (0xf << 0)
|
||||||
#define YT8521_TX_DELAY_SEL_SHIFT 0
|
#define YT8521_TX_DELAY_SEL_SHIFT 0
|
||||||
|
#define YT8521_EXT_PAD_DRIVE_STRENGTH 0xa010
|
||||||
|
#define YT8531_RGMII_RXC_DS_MASK (0x7 << 13)
|
||||||
|
#define YT8531_RGMII_RXC_DS_SHIFT 13
|
||||||
|
#define YT8531_RGMII_RXD_DS_MASK ((0x1 << 12) | (0x3 << 4))
|
||||||
|
#define YT8531_RGMII_RXD_DS_LOW(x) (((x) & 0x3) << 4)
|
||||||
|
#define YT8531_RGMII_RXD_DS_HIGH(x) (((x) >> 2) << 12)
|
||||||
|
|
||||||
int ytphy_match(struct device *, void *, void *);
|
int ytphy_match(struct device *, void *, void *);
|
||||||
void ytphy_attach(struct device *, struct device *, void *);
|
void ytphy_attach(struct device *, struct device *, void *);
|
||||||
@ -79,6 +89,7 @@ int ytphy_service(struct mii_softc *, struct mii_data *, int);
|
|||||||
void ytphy_yt8511_init(struct mii_softc *);
|
void ytphy_yt8511_init(struct mii_softc *);
|
||||||
void ytphy_yt8521_init(struct mii_softc *);
|
void ytphy_yt8521_init(struct mii_softc *);
|
||||||
void ytphy_yt8521_update(struct mii_softc *);
|
void ytphy_yt8521_update(struct mii_softc *);
|
||||||
|
void ytphy_yt8531_init(struct mii_softc *);
|
||||||
|
|
||||||
const struct mii_phy_funcs ytphy_funcs = {
|
const struct mii_phy_funcs ytphy_funcs = {
|
||||||
ytphy_service, ukphy_status, mii_phy_reset,
|
ytphy_service, ukphy_status, mii_phy_reset,
|
||||||
@ -138,8 +149,10 @@ ytphy_attach(struct device *parent, struct device *self, void *aux)
|
|||||||
|
|
||||||
if (ma->mii_id1 == 0x0000 && ma->mii_id2 == 0x010a)
|
if (ma->mii_id1 == 0x0000 && ma->mii_id2 == 0x010a)
|
||||||
ytphy_yt8511_init(sc);
|
ytphy_yt8511_init(sc);
|
||||||
else
|
else if (ma->mii_id1 == 0x0000 && ma->mii_id2 == 0x011a)
|
||||||
ytphy_yt8521_init(sc);
|
ytphy_yt8521_init(sc);
|
||||||
|
else
|
||||||
|
ytphy_yt8531_init(sc);
|
||||||
|
|
||||||
sc->mii_capabilities =
|
sc->mii_capabilities =
|
||||||
PHY_READ(sc, MII_BMSR) & ma->mii_capmask;
|
PHY_READ(sc, MII_BMSR) & ma->mii_capmask;
|
||||||
@ -362,3 +375,97 @@ ytphy_yt8521_update(struct mii_softc *sc)
|
|||||||
PHY_WRITE(sc, YT8511_REG_ADDR, addr);
|
PHY_WRITE(sc, YT8511_REG_ADDR, addr);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* The RGMII drive strength depends on the voltage level. */
|
||||||
|
|
||||||
|
struct ytphy_ds_map {
|
||||||
|
uint32_t volt; /* mV */
|
||||||
|
uint16_t amp; /* uA */
|
||||||
|
uint16_t ds;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct ytphy_ds_map ytphy_yt8531_ds_map[] = {
|
||||||
|
{ 1800, 1200, 0 },
|
||||||
|
{ 1800, 2100, 1 },
|
||||||
|
{ 1800, 2700, 2 },
|
||||||
|
{ 1800, 2910, 3 },
|
||||||
|
{ 1800, 3110, 4 },
|
||||||
|
{ 1800, 3600, 5 },
|
||||||
|
{ 1800, 3970, 6 },
|
||||||
|
{ 1800, 4350, 7 },
|
||||||
|
{ 3300, 3070, 0 },
|
||||||
|
{ 3300, 4080, 1 },
|
||||||
|
{ 3300, 4370, 2 },
|
||||||
|
{ 3300, 4680, 3 },
|
||||||
|
{ 3300, 5020, 4 },
|
||||||
|
{ 3300, 5450, 5 },
|
||||||
|
{ 3300, 5740, 6 },
|
||||||
|
{ 3300, 6140, 7 },
|
||||||
|
};
|
||||||
|
|
||||||
|
uint32_t
|
||||||
|
ytphy_yt8531_ds(struct mii_softc *sc, uint32_t volt, uint32_t amp)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i = 0; i < nitems(ytphy_yt8531_ds_map); i++) {
|
||||||
|
if (ytphy_yt8531_ds_map[i].volt == volt &&
|
||||||
|
ytphy_yt8531_ds_map[i].amp == amp)
|
||||||
|
return ytphy_yt8531_ds_map[i].ds;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (amp) {
|
||||||
|
printf("%s: unknown drive strength (%d uA at %d mV)\n",
|
||||||
|
sc->mii_dev.dv_xname, amp, volt);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Default drive strength. */
|
||||||
|
return 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
ytphy_yt8531_init(struct mii_softc *sc)
|
||||||
|
{
|
||||||
|
uint32_t rx_clk_drv = 0;
|
||||||
|
uint32_t rx_data_drv = 0;
|
||||||
|
uint16_t addr, data;
|
||||||
|
uint16_t volt;
|
||||||
|
|
||||||
|
ytphy_yt8521_init(sc);
|
||||||
|
|
||||||
|
#ifdef __HAVE_FDT
|
||||||
|
if (sc->mii_pdata->mii_node) {
|
||||||
|
rx_clk_drv = OF_getpropint(sc->mii_pdata->mii_node,
|
||||||
|
"motorcomm,rx-clk-drv-microamp", 0);
|
||||||
|
rx_data_drv = OF_getpropint(sc->mii_pdata->mii_node,
|
||||||
|
"motorcomm,rx-data-drv-microamp", 0);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Save address register. */
|
||||||
|
addr = PHY_READ(sc, YT8511_REG_ADDR);
|
||||||
|
|
||||||
|
PHY_WRITE(sc, YT8511_REG_ADDR, YT8521_EXT_CHIP_CONFIG);
|
||||||
|
data = PHY_READ(sc, YT8511_REG_DATA);
|
||||||
|
if ((data & YT8521_CFG_LDO_MASK) == YT8521_CFG_LDO_3V3)
|
||||||
|
volt = 3300;
|
||||||
|
else if ((data & YT8521_CFG_LDO_MASK) == YT8521_CFG_LDO_2V5)
|
||||||
|
volt = 2500;
|
||||||
|
else
|
||||||
|
volt = 1800;
|
||||||
|
|
||||||
|
rx_clk_drv = ytphy_yt8531_ds(sc, volt, rx_clk_drv);
|
||||||
|
rx_data_drv = ytphy_yt8531_ds(sc, volt, rx_data_drv);
|
||||||
|
|
||||||
|
PHY_WRITE(sc, YT8511_REG_ADDR, YT8521_EXT_PAD_DRIVE_STRENGTH);
|
||||||
|
data = PHY_READ(sc, YT8511_REG_DATA);
|
||||||
|
data &= ~YT8531_RGMII_RXC_DS_MASK;
|
||||||
|
data |= rx_clk_drv << YT8531_RGMII_RXC_DS_SHIFT;
|
||||||
|
data &= ~YT8531_RGMII_RXD_DS_MASK;
|
||||||
|
data |= YT8531_RGMII_RXD_DS_LOW(rx_data_drv);
|
||||||
|
data |= YT8531_RGMII_RXD_DS_HIGH(rx_data_drv);
|
||||||
|
PHY_WRITE(sc, YT8511_REG_DATA, data);
|
||||||
|
|
||||||
|
/* Restore address register. */
|
||||||
|
PHY_WRITE(sc, YT8511_REG_ADDR, addr);
|
||||||
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $OpenBSD: if_umb.c,v 1.54 2023/08/29 23:28:38 dlg Exp $ */
|
/* $OpenBSD: if_umb.c,v 1.55 2023/09/01 20:24:29 mvs Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2016 genua mbH
|
* Copyright (c) 2016 genua mbH
|
||||||
@ -1851,7 +1851,6 @@ umb_add_inet_config(struct umb_softc *sc, struct in_addr ip, u_int prefixlen,
|
|||||||
info.rti_info[RTAX_GATEWAY] = sintosa(&ifra.ifra_dstaddr);
|
info.rti_info[RTAX_GATEWAY] = sintosa(&ifra.ifra_dstaddr);
|
||||||
|
|
||||||
rv = rtrequest(RTM_ADD, &info, 0, &rt, ifp->if_rdomain);
|
rv = rtrequest(RTM_ADD, &info, 0, &rt, ifp->if_rdomain);
|
||||||
NET_UNLOCK();
|
|
||||||
if (rv) {
|
if (rv) {
|
||||||
printf("%s: unable to set IPv4 default route, "
|
printf("%s: unable to set IPv4 default route, "
|
||||||
"error %d\n", DEVNAM(ifp->if_softc), rv);
|
"error %d\n", DEVNAM(ifp->if_softc), rv);
|
||||||
@ -1862,6 +1861,7 @@ umb_add_inet_config(struct umb_softc *sc, struct in_addr ip, u_int prefixlen,
|
|||||||
rtm_send(rt, RTM_ADD, rv, ifp->if_rdomain);
|
rtm_send(rt, RTM_ADD, rv, ifp->if_rdomain);
|
||||||
rtfree(rt);
|
rtfree(rt);
|
||||||
}
|
}
|
||||||
|
NET_UNLOCK();
|
||||||
|
|
||||||
if (ifp->if_flags & IFF_DEBUG) {
|
if (ifp->if_flags & IFF_DEBUG) {
|
||||||
char str[3][INET_ADDRSTRLEN];
|
char str[3][INET_ADDRSTRLEN];
|
||||||
@ -1932,7 +1932,6 @@ umb_add_inet6_config(struct umb_softc *sc, struct in6_addr *ip, u_int prefixlen,
|
|||||||
info.rti_info[RTAX_GATEWAY] = sin6tosa(&ifra.ifra_dstaddr);
|
info.rti_info[RTAX_GATEWAY] = sin6tosa(&ifra.ifra_dstaddr);
|
||||||
|
|
||||||
rv = rtrequest(RTM_ADD, &info, 0, &rt, ifp->if_rdomain);
|
rv = rtrequest(RTM_ADD, &info, 0, &rt, ifp->if_rdomain);
|
||||||
NET_UNLOCK();
|
|
||||||
if (rv) {
|
if (rv) {
|
||||||
printf("%s: unable to set IPv6 default route, "
|
printf("%s: unable to set IPv6 default route, "
|
||||||
"error %d\n", DEVNAM(ifp->if_softc), rv);
|
"error %d\n", DEVNAM(ifp->if_softc), rv);
|
||||||
@ -1943,6 +1942,7 @@ umb_add_inet6_config(struct umb_softc *sc, struct in6_addr *ip, u_int prefixlen,
|
|||||||
rtm_send(rt, RTM_ADD, rv, ifp->if_rdomain);
|
rtm_send(rt, RTM_ADD, rv, ifp->if_rdomain);
|
||||||
rtfree(rt);
|
rtfree(rt);
|
||||||
}
|
}
|
||||||
|
NET_UNLOCK();
|
||||||
|
|
||||||
if (ifp->if_flags & IFF_DEBUG) {
|
if (ifp->if_flags & IFF_DEBUG) {
|
||||||
char str[3][INET6_ADDRSTRLEN];
|
char str[3][INET6_ADDRSTRLEN];
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $OpenBSD: utf8-combined.c,v 1.1 2023/09/01 14:29:11 nicm Exp $ */
|
/* $OpenBSD: utf8-combined.c,v 1.2 2023/09/01 18:43:54 nicm Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2023 Nicholas Marriott <nicholas.marriott@gmail.com>
|
* Copyright (c) 2023 Nicholas Marriott <nicholas.marriott@gmail.com>
|
||||||
@ -962,7 +962,7 @@ utf8_combined_first_cmp(struct utf8_combined_first *uf1,
|
|||||||
return (-1);
|
return (-1);
|
||||||
if (ud1->size > ud2->size)
|
if (ud1->size > ud2->size)
|
||||||
return (1);
|
return (1);
|
||||||
return (memcmp(ud1->data, ud2->data, sizeof *ud1->data));
|
return (memcmp(ud1->data, ud2->data, ud1->size));
|
||||||
}
|
}
|
||||||
RB_HEAD(utf8_combined_tree, utf8_combined_first);
|
RB_HEAD(utf8_combined_tree, utf8_combined_first);
|
||||||
RB_GENERATE_STATIC(utf8_combined_tree, utf8_combined_first, entry,
|
RB_GENERATE_STATIC(utf8_combined_tree, utf8_combined_first, entry,
|
||||||
@ -979,7 +979,7 @@ utf8_combined_second_cmp(const void *vp1, const void *vp2)
|
|||||||
return (-1);
|
return (-1);
|
||||||
if (ud1->size > ud2->size)
|
if (ud1->size > ud2->size)
|
||||||
return (1);
|
return (1);
|
||||||
return (memcmp(ud1->data, ud2->data, sizeof *ud1->data));
|
return (memcmp(ud1->data, ud2->data, ud1->size));
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
@ -1035,7 +1035,7 @@ utf8_build_combined(void)
|
|||||||
wc = utf8_combined_table[i].first;
|
wc = utf8_combined_table[i].first;
|
||||||
mlen = wctomb(first.data, wc);
|
mlen = wctomb(first.data, wc);
|
||||||
if (mlen <= 0 || mlen > UTF8_SIZE) {
|
if (mlen <= 0 || mlen > UTF8_SIZE) {
|
||||||
log_debug("invalid combined character %08X", wc);
|
log_debug("invalid combined character %05X", wc);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
first.size = mlen;
|
first.size = mlen;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $OpenBSD: i8259.c,v 1.21 2022/11/10 18:58:02 mbuhl Exp $ */
|
/* $OpenBSD: i8259.c,v 1.22 2023/09/01 19:42:26 dv Exp $ */
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2016 Mike Larkin <mlarkin@openbsd.org>
|
* Copyright (c) 2016 Mike Larkin <mlarkin@openbsd.org>
|
||||||
*
|
*
|
||||||
@ -222,20 +222,16 @@ i8259_assert_irq(uint8_t irq)
|
|||||||
{
|
{
|
||||||
mutex_lock(&pic_mtx);
|
mutex_lock(&pic_mtx);
|
||||||
if (irq <= 7) {
|
if (irq <= 7) {
|
||||||
if (!ISSET(pics[MASTER].imr, 1 << irq)) {
|
SET(pics[MASTER].irr, 1 << irq);
|
||||||
SET(pics[MASTER].irr, 1 << irq);
|
pics[MASTER].asserted = 1;
|
||||||
pics[MASTER].asserted = 1;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
irq -= 8;
|
irq -= 8;
|
||||||
if (!ISSET(pics[SLAVE].imr, 1 << irq)) {
|
SET(pics[SLAVE].irr, 1 << irq);
|
||||||
SET(pics[SLAVE].irr, 1 << irq);
|
pics[SLAVE].asserted = 1;
|
||||||
pics[SLAVE].asserted = 1;
|
|
||||||
|
|
||||||
/* Assert cascade IRQ on master PIC */
|
/* Assert cascade IRQ on master PIC */
|
||||||
SET(pics[MASTER].irr, 1 << 2);
|
SET(pics[MASTER].irr, 1 << 2);
|
||||||
pics[MASTER].asserted = 1;
|
pics[MASTER].asserted = 1;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
mutex_unlock(&pic_mtx);
|
mutex_unlock(&pic_mtx);
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $OpenBSD: vioblk.c,v 1.4 2023/05/28 05:28:50 asou Exp $ */
|
/* $OpenBSD: vioblk.c,v 1.5 2023/09/01 19:42:26 dv Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2023 Dave Voutila <dv@openbsd.org>
|
* Copyright (c) 2023 Dave Voutila <dv@openbsd.org>
|
||||||
@ -39,7 +39,8 @@ extern char *__progname;
|
|||||||
extern struct vmd_vm *current_vm;
|
extern struct vmd_vm *current_vm;
|
||||||
|
|
||||||
static const char *disk_type(int);
|
static const char *disk_type(int);
|
||||||
static uint32_t handle_io_read(struct viodev_msg *, struct virtio_dev *);
|
static uint32_t handle_io_read(struct viodev_msg *, struct virtio_dev *,
|
||||||
|
int8_t *);
|
||||||
static int handle_io_write(struct viodev_msg *, struct virtio_dev *);
|
static int handle_io_write(struct viodev_msg *, struct virtio_dev *);
|
||||||
void vioblk_notify_rx(struct vioblk_dev *);
|
void vioblk_notify_rx(struct vioblk_dev *);
|
||||||
int vioblk_notifyq(struct vioblk_dev *);
|
int vioblk_notifyq(struct vioblk_dev *);
|
||||||
@ -723,6 +724,7 @@ handle_sync_io(int fd, short event, void *arg)
|
|||||||
struct viodev_msg msg;
|
struct viodev_msg msg;
|
||||||
struct imsg imsg;
|
struct imsg imsg;
|
||||||
ssize_t n;
|
ssize_t n;
|
||||||
|
int8_t intr = INTR_STATE_NOOP;
|
||||||
|
|
||||||
if (event & EV_READ) {
|
if (event & EV_READ) {
|
||||||
if ((n = imsg_read(ibuf)) == -1 && errno != EAGAIN)
|
if ((n = imsg_read(ibuf)) == -1 && errno != EAGAIN)
|
||||||
@ -770,8 +772,9 @@ handle_sync_io(int fd, short event, void *arg)
|
|||||||
}
|
}
|
||||||
case VIODEV_MSG_IO_READ:
|
case VIODEV_MSG_IO_READ:
|
||||||
/* Read IO: make sure to send a reply */
|
/* Read IO: make sure to send a reply */
|
||||||
msg.data = handle_io_read(&msg, dev);
|
msg.data = handle_io_read(&msg, dev, &intr);
|
||||||
msg.data_valid = 1;
|
msg.data_valid = 1;
|
||||||
|
msg.state = intr;
|
||||||
imsg_compose_event(iev, IMSG_DEVOP_MSG, 0, 0, -1, &msg,
|
imsg_compose_event(iev, IMSG_DEVOP_MSG, 0, 0, -1, &msg,
|
||||||
sizeof(msg));
|
sizeof(msg));
|
||||||
break;
|
break;
|
||||||
@ -844,7 +847,7 @@ handle_io_write(struct viodev_msg *msg, struct virtio_dev *dev)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static uint32_t
|
static uint32_t
|
||||||
handle_io_read(struct viodev_msg *msg, struct virtio_dev *dev)
|
handle_io_read(struct viodev_msg *msg, struct virtio_dev *dev, int8_t *intr)
|
||||||
{
|
{
|
||||||
struct vioblk_dev *vioblk = &dev->vioblk;
|
struct vioblk_dev *vioblk = &dev->vioblk;
|
||||||
uint8_t sz = msg->io_sz;
|
uint8_t sz = msg->io_sz;
|
||||||
@ -1001,7 +1004,8 @@ handle_io_read(struct viodev_msg *msg, struct virtio_dev *dev)
|
|||||||
case VIRTIO_CONFIG_ISR_STATUS:
|
case VIRTIO_CONFIG_ISR_STATUS:
|
||||||
data = vioblk->cfg.isr_status;
|
data = vioblk->cfg.isr_status;
|
||||||
vioblk->cfg.isr_status = 0;
|
vioblk->cfg.isr_status = 0;
|
||||||
virtio_deassert_pic_irq(dev, 0);
|
if (intr != NULL)
|
||||||
|
*intr = INTR_STATE_DEASSERT;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return (0xFFFFFFFF);
|
return (0xFFFFFFFF);
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $OpenBSD: vionet.c,v 1.3 2023/05/13 23:15:28 dv Exp $ */
|
/* $OpenBSD: vionet.c,v 1.4 2023/09/01 19:42:26 dv Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2023 Dave Voutila <dv@openbsd.org>
|
* Copyright (c) 2023 Dave Voutila <dv@openbsd.org>
|
||||||
@ -52,7 +52,8 @@ struct event ev_tap;
|
|||||||
|
|
||||||
static int vionet_rx(struct vionet_dev *);
|
static int vionet_rx(struct vionet_dev *);
|
||||||
static void vionet_rx_event(int, short, void *);
|
static void vionet_rx_event(int, short, void *);
|
||||||
static uint32_t handle_io_read(struct viodev_msg *, struct virtio_dev *);
|
static uint32_t handle_io_read(struct viodev_msg *, struct virtio_dev *,
|
||||||
|
int8_t *);
|
||||||
static int handle_io_write(struct viodev_msg *, struct virtio_dev *);
|
static int handle_io_write(struct viodev_msg *, struct virtio_dev *);
|
||||||
void vionet_notify_rx(struct virtio_dev *);
|
void vionet_notify_rx(struct virtio_dev *);
|
||||||
int vionet_notifyq(struct virtio_dev *);
|
int vionet_notifyq(struct virtio_dev *);
|
||||||
@ -757,6 +758,7 @@ handle_sync_io(int fd, short event, void *arg)
|
|||||||
struct viodev_msg msg;
|
struct viodev_msg msg;
|
||||||
struct imsg imsg;
|
struct imsg imsg;
|
||||||
ssize_t n;
|
ssize_t n;
|
||||||
|
int8_t intr = INTR_STATE_NOOP;
|
||||||
|
|
||||||
if (event & EV_READ) {
|
if (event & EV_READ) {
|
||||||
if ((n = imsg_read(ibuf)) == -1 && errno != EAGAIN)
|
if ((n = imsg_read(ibuf)) == -1 && errno != EAGAIN)
|
||||||
@ -804,8 +806,9 @@ handle_sync_io(int fd, short event, void *arg)
|
|||||||
}
|
}
|
||||||
case VIODEV_MSG_IO_READ:
|
case VIODEV_MSG_IO_READ:
|
||||||
/* Read IO: make sure to send a reply */
|
/* Read IO: make sure to send a reply */
|
||||||
msg.data = handle_io_read(&msg, dev);
|
msg.data = handle_io_read(&msg, dev, &intr);
|
||||||
msg.data_valid = 1;
|
msg.data_valid = 1;
|
||||||
|
msg.state = intr;
|
||||||
imsg_compose_event(iev, IMSG_DEVOP_MSG, 0, 0, -1, &msg,
|
imsg_compose_event(iev, IMSG_DEVOP_MSG, 0, 0, -1, &msg,
|
||||||
sizeof(msg));
|
sizeof(msg));
|
||||||
break;
|
break;
|
||||||
@ -891,7 +894,7 @@ handle_io_write(struct viodev_msg *msg, struct virtio_dev *dev)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static uint32_t
|
static uint32_t
|
||||||
handle_io_read(struct viodev_msg *msg, struct virtio_dev *dev)
|
handle_io_read(struct viodev_msg *msg, struct virtio_dev *dev, int8_t *intr)
|
||||||
{
|
{
|
||||||
struct vionet_dev *vionet = &dev->vionet;
|
struct vionet_dev *vionet = &dev->vionet;
|
||||||
uint32_t data;
|
uint32_t data;
|
||||||
@ -930,7 +933,8 @@ handle_io_read(struct viodev_msg *msg, struct virtio_dev *dev)
|
|||||||
case VIRTIO_CONFIG_ISR_STATUS:
|
case VIRTIO_CONFIG_ISR_STATUS:
|
||||||
data = vionet->cfg.isr_status;
|
data = vionet->cfg.isr_status;
|
||||||
vionet->cfg.isr_status = 0;
|
vionet->cfg.isr_status = 0;
|
||||||
virtio_deassert_pic_irq(dev, 0);
|
if (intr != NULL)
|
||||||
|
*intr = INTR_STATE_DEASSERT;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return (0xFFFFFFFF);
|
return (0xFFFFFFFF);
|
||||||
|
Loading…
Reference in New Issue
Block a user