sync with OpenBSD -current

This commit is contained in:
purplerain 2024-01-08 00:39:27 +00:00
parent a2b5593ce1
commit 19c768bf4f
Signed by: purplerain
GPG Key ID: F42C07F07E2E35B7
67 changed files with 1526 additions and 522 deletions

View File

@ -1 +1 @@
# SecBSD 1.4-407f8e0: Tue Jan 2 04:11:30 UTC 2024 (Mictlantecuhtli) # SecBSD 1.4-77e4830: Sun Jan 7 19:44:17 UTC 2024 (Mictlantecuhtli)

View File

@ -1,4 +1,4 @@
# $SecBSD: dot.xsession,v 0.3 2023/10/02 03:12:22 purplerain Exp $ # $SecBSD: dot.xsession,v 0.4 2024/01/07 19:32:27 purplerain Exp $
# #
# This file is for testing purposes only. # This file is for testing purposes only.
@ -8,34 +8,57 @@ if [ -x /usr/local/bin/dbus-launch -a -z "${DBUS_SESSION_BUS_ADDRESS}" ]; then
eval `dbus-launch --sh-syntax --exit-with-x11` eval `dbus-launch --sh-syntax --exit-with-x11`
fi fi
# cwm + xenodm + termbar #cwm + xenodm + termbar
# vi ~/.cwmrc to create default cwm configuration file #vi ~/.cwmrc to create default cwm configuration file
# configure according to your needs and save :wq! #configure according to your needs and save :wq!
# manual: https://man.openbsd.org/cwm.1 #manual: https://man.openbsd.org/cwm.1
# uncomment the next line to the line exec cwm #uncomment lines below
#exec xterm -geometry 320x1+0+0 -fa "Spleen:size=16" -bg "black" \ #xterm -geometry 320x1+0+0 -fa "Spleen:size=16" -bg "black" \
# -fg grey -fs 12 -name termbar -class termbar \ # -fg grey -fs 12 -name termbar -class termbar \
# -T termbar -e ~/.termbar & # -T termbar -e ~/.termbar &
# #
#exec cwm #cwm
# rcctl enable xenodm #rcctl enable xenodm
# rcctl start xenodm #rcctl start xenodm
# reboot #reboot
# MATE Desktop + xenodm #XFCE Desktop + xenodm
# pkg_add -v mate #pkg_add -v xfce xfce-extras consolekit2
# uncomment line below #uncomment line below
#exec mate-session #/usr/local/bin/startxfce4 --with-ck-launch
# rcctl enable messagebus xenodm #rcctl enable messagebus xenodm
# rcctl start messagebus xenodm #rcctl start messagebus xenodm
# reboot #reboot
# XFCE Desktop + xenodm #KDE Plasma + xenodm
# pkg_add -v xfce xfce-extras consolekit2 #pkg_add -v kde-plasma
# uncomment line below #uncomment lines below
#exec /usr/local/bin/startxfce4 --with-ck-launch #export XDG_RUNTIME_DIR=/tmp/run/$(id -u)
# rcctl enable messagebus xenodm #if [ ! -d $XDG_RUNTIME_DIR ]; then
# rcctl start messagebus xenodm # mkdir -m 700 -p $XDG_RUNTIME_DIR
# reboot #fi
#
#export QT_FORCE_STDERR_LOGGING=1
#export XDG_CURRENT_DESKTOP=KDE
#export DESKTOP_SESSION=plasma
#export QT_FORCE_STDERR_LOGGING=1
#/usr/local/bin/startplasma-x11 > ~/.startplasma-x11.log 2>&1
#rcctl enable messagebus xenodm
#rcctl start messagebus xenodm
#reboot
#Known issues
#
#The KDE compositor does not seem to run properly by default. It is recommended
#to deactivate this under: "System Setting" -> "Display Configuration" ->
#"Compositor"
#No compositor seem to run by default.
#You can't unlock your session when the screensaver has locked it. I get the
#graphical message "Something wrong happened. Run # ck-unlock-session ...".
#So you will end up with a freezen session that you have to completely kill.
#It is recommended to disable KDE screen locking for now.
#The first start may take a little longer.
#The sound mixer Kmix works only on the main channel.

View File

@ -1,4 +1,4 @@
/* $OpenBSD: asn1_local.h,v 1.5 2023/12/29 10:59:00 tb Exp $ */ /* $OpenBSD: asn1_local.h,v 1.7 2024/01/06 20:47:01 tb Exp $ */
/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
* project 2006. * project 2006.
*/ */
@ -89,24 +89,6 @@ struct asn1_pctx_st {
unsigned long str_flags; unsigned long str_flags;
} /* ASN1_PCTX */; } /* ASN1_PCTX */;
/* Method to handle CRL access.
* In general a CRL could be very large (several Mb) and can consume large
* amounts of resources if stored in memory by multiple processes.
* This method allows general CRL operations to be redirected to more
* efficient callbacks: for example a CRL entry database.
*/
#define X509_CRL_METHOD_DYNAMIC 1
struct x509_crl_method_st {
int flags;
int (*crl_init)(X509_CRL *crl);
int (*crl_free)(X509_CRL *crl);
int (*crl_lookup)(X509_CRL *crl, X509_REVOKED **ret,
ASN1_INTEGER *ser, X509_NAME *issuer);
int (*crl_verify)(X509_CRL *crl, EVP_PKEY *pk);
};
int asn1_get_choice_selector(ASN1_VALUE **pval, const ASN1_ITEM *it); int asn1_get_choice_selector(ASN1_VALUE **pval, const ASN1_ITEM *it);
int asn1_set_choice_selector(ASN1_VALUE **pval, int value, const ASN1_ITEM *it); int asn1_set_choice_selector(ASN1_VALUE **pval, int value, const ASN1_ITEM *it);

View File

@ -1,4 +1,4 @@
/* $OpenBSD: x_crl.c,v 1.41 2023/07/07 19:37:52 beck Exp $ */ /* $OpenBSD: x_crl.c,v 1.42 2024/01/06 17:37:23 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.
* *
@ -100,17 +100,6 @@ const ASN1_ITEM X509_REVOKED_it = {
.sname = "X509_REVOKED", .sname = "X509_REVOKED",
}; };
static int def_crl_verify(X509_CRL *crl, EVP_PKEY *r);
static int def_crl_lookup(X509_CRL *crl, X509_REVOKED **ret,
ASN1_INTEGER *serial, X509_NAME *issuer);
static X509_CRL_METHOD int_crl_meth = {
.crl_lookup = def_crl_lookup,
.crl_verify = def_crl_verify
};
static const X509_CRL_METHOD *default_crl_method = &int_crl_meth;
/* The X509_CRL_INFO structure needs a bit of customisation. /* The X509_CRL_INFO structure needs a bit of customisation.
* Since we cache the original encoding the signature wont be affected by * Since we cache the original encoding the signature wont be affected by
* reordering of the revoked field. * reordering of the revoked field.
@ -280,8 +269,6 @@ crl_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it, void *exarg)
crl->flags = 0; crl->flags = 0;
crl->idp_flags = 0; crl->idp_flags = 0;
crl->idp_reasons = CRLDP_ALL_REASONS; crl->idp_reasons = CRLDP_ALL_REASONS;
crl->meth = default_crl_method;
crl->meth_data = NULL;
crl->issuers = NULL; crl->issuers = NULL;
crl->crl_number = NULL; crl->crl_number = NULL;
crl->base_crl_number = NULL; crl->base_crl_number = NULL;
@ -335,18 +322,9 @@ crl_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it, void *exarg)
if (!crl_set_issuers(crl)) if (!crl_set_issuers(crl))
return 0; return 0;
if (crl->meth->crl_init) {
if (crl->meth->crl_init(crl) == 0)
return 0;
}
break; break;
case ASN1_OP_FREE_POST: case ASN1_OP_FREE_POST:
if (crl->meth->crl_free) {
if (!crl->meth->crl_free(crl))
rc = 0;
}
if (crl->akid) if (crl->akid)
AUTHORITY_KEYID_free(crl->akid); AUTHORITY_KEYID_free(crl->akid);
if (crl->idp) if (crl->idp)
@ -546,36 +524,10 @@ X509_CRL_add0_revoked(X509_CRL *crl, X509_REVOKED *rev)
} }
int int
X509_CRL_verify(X509_CRL *crl, EVP_PKEY *r) X509_CRL_verify(X509_CRL *crl, EVP_PKEY *pkey)
{ {
if (crl->meth->crl_verify) return ASN1_item_verify(&X509_CRL_INFO_it, crl->sig_alg, crl->signature,
return crl->meth->crl_verify(crl, r); crl->crl, pkey);
return 0;
}
int
X509_CRL_get0_by_serial(X509_CRL *crl, X509_REVOKED **ret,
ASN1_INTEGER *serial)
{
if (crl->meth->crl_lookup)
return crl->meth->crl_lookup(crl, ret, serial, NULL);
return 0;
}
int
X509_CRL_get0_by_cert(X509_CRL *crl, X509_REVOKED **ret, X509 *x)
{
if (crl->meth->crl_lookup)
return crl->meth->crl_lookup(crl, ret,
X509_get_serialNumber(x), X509_get_issuer_name(x));
return 0;
}
static int
def_crl_verify(X509_CRL *crl, EVP_PKEY *r)
{
return(ASN1_item_verify(&X509_CRL_INFO_it,
crl->sig_alg, crl->signature, crl->crl, r));
} }
static int static int
@ -606,16 +558,13 @@ crl_revoked_issuer_match(X509_CRL *crl, X509_NAME *nm, X509_REVOKED *rev)
} }
static int static int
def_crl_lookup(X509_CRL *crl, X509_REVOKED **ret, ASN1_INTEGER *serial, crl_lookup(X509_CRL *crl, X509_REVOKED **ret, ASN1_INTEGER *serial,
X509_NAME *issuer) X509_NAME *issuer)
{ {
X509_REVOKED rtmp, *rev; X509_REVOKED rtmp, *rev;
int idx; int idx;
rtmp.serialNumber = serial; rtmp.serialNumber = serial;
/* Sort revoked into serial number order if not already sorted.
* Do this under a lock to avoid race condition.
*/
if (!sk_X509_REVOKED_is_sorted(crl->crl->revoked)) { if (!sk_X509_REVOKED_is_sorted(crl->crl->revoked)) {
CRYPTO_w_lock(CRYPTO_LOCK_X509_CRL); CRYPTO_w_lock(CRYPTO_LOCK_X509_CRL);
sk_X509_REVOKED_sort(crl->crl->revoked); sk_X509_REVOKED_sort(crl->crl->revoked);
@ -640,13 +589,23 @@ def_crl_lookup(X509_CRL *crl, X509_REVOKED **ret, ASN1_INTEGER *serial,
return 0; return 0;
} }
int
X509_CRL_get0_by_serial(X509_CRL *crl, X509_REVOKED **ret,
ASN1_INTEGER *serial)
{
return crl_lookup(crl, ret, serial, NULL);
}
int
X509_CRL_get0_by_cert(X509_CRL *crl, X509_REVOKED **ret, X509 *x)
{
return crl_lookup(crl, ret, X509_get_serialNumber(x),
X509_get_issuer_name(x));
}
void void
X509_CRL_set_default_method(const X509_CRL_METHOD *meth) X509_CRL_set_default_method(const X509_CRL_METHOD *meth)
{ {
if (meth == NULL)
default_crl_method = &int_crl_meth;
else
default_crl_method = meth;
} }
X509_CRL_METHOD * X509_CRL_METHOD *
@ -656,40 +615,25 @@ X509_CRL_METHOD_new(int (*crl_init)(X509_CRL *crl),
ASN1_INTEGER *ser, X509_NAME *issuer), ASN1_INTEGER *ser, X509_NAME *issuer),
int (*crl_verify)(X509_CRL *crl, EVP_PKEY *pk)) int (*crl_verify)(X509_CRL *crl, EVP_PKEY *pk))
{ {
X509_CRL_METHOD *m; X509error(ERR_R_DISABLED);
if ((m = calloc(1, sizeof(X509_CRL_METHOD))) == NULL)
return NULL; return NULL;
m->crl_init = crl_init;
m->crl_free = crl_free;
m->crl_lookup = crl_lookup;
m->crl_verify = crl_verify;
m->flags = X509_CRL_METHOD_DYNAMIC;
return m;
} }
void void
X509_CRL_METHOD_free(X509_CRL_METHOD *m) X509_CRL_METHOD_free(X509_CRL_METHOD *m)
{ {
if (m == NULL)
return;
if (!(m->flags & X509_CRL_METHOD_DYNAMIC))
return;
free(m);
} }
void void
X509_CRL_set_meth_data(X509_CRL *crl, void *dat) X509_CRL_set_meth_data(X509_CRL *crl, void *dat)
{ {
crl->meth_data = dat;
} }
void * void *
X509_CRL_get_meth_data(X509_CRL *crl) X509_CRL_get_meth_data(X509_CRL *crl)
{ {
return crl->meth_data; X509error(ERR_R_DISABLED);
return NULL;
} }
int int

View File

@ -1,4 +1,4 @@
/* $OpenBSD: crypto_init.c,v 1.13 2023/12/16 12:36:14 tb Exp $ */ /* $OpenBSD: crypto_init.c,v 1.14 2024/01/06 17:43:39 tb Exp $ */
/* /*
* Copyright (c) 2018 Bob Beck <beck@openbsd.org> * Copyright (c) 2018 Bob Beck <beck@openbsd.org>
* *
@ -84,7 +84,6 @@ OPENSSL_cleanup(void)
EVP_cleanup(); EVP_cleanup();
X509V3_EXT_cleanup(); X509V3_EXT_cleanup();
X509_PURPOSE_cleanup();
X509_TRUST_cleanup(); X509_TRUST_cleanup();
X509_VERIFY_PARAM_table_cleanup(); X509_VERIFY_PARAM_table_cleanup();

View File

@ -1,4 +1,4 @@
/* $OpenBSD: evp_key.c,v 1.30 2023/07/07 19:37:53 beck Exp $ */ /* $OpenBSD: evp_key.c,v 1.33 2024/01/05 10:18:52 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.
* *
@ -75,18 +75,17 @@ EVP_set_pw_prompt(const char *prompt)
{ {
if (prompt == NULL) if (prompt == NULL)
prompt_string[0] = '\0'; prompt_string[0] = '\0';
else { else
strlcpy(prompt_string, prompt, sizeof(prompt_string)); strlcpy(prompt_string, prompt, sizeof(prompt_string));
}
} }
char * char *
EVP_get_pw_prompt(void) EVP_get_pw_prompt(void)
{ {
if (prompt_string[0] == '\0') if (prompt_string[0] == '\0')
return (NULL); return NULL;
else
return (prompt_string); return prompt_string;
} }
int int
@ -99,30 +98,35 @@ int
EVP_read_pw_string_min(char *buf, int min, int len, const char *prompt, EVP_read_pw_string_min(char *buf, int min, int len, const char *prompt,
int verify) int verify)
{ {
int ret; UI *ui = NULL;
char buff[BUFSIZ]; char buff[BUFSIZ];
UI *ui; int ret = -1;
if (len > BUFSIZ) if (len > BUFSIZ)
len = BUFSIZ; len = BUFSIZ;
/* Ensure that 0 <= min <= len - 1. In particular, 1 <= len. */ /* Ensure that 0 <= min <= len - 1. In particular, 1 <= len. */
if (min < 0 || len - 1 < min) if (min < 0 || len - 1 < min)
return -1; goto err;
if ((prompt == NULL) && (prompt_string[0] != '\0'))
if (prompt == NULL && prompt_string[0] != '\0')
prompt = prompt_string; prompt = prompt_string;
ui = UI_new();
if (ui == NULL) if ((ui = UI_new()) == NULL)
return -1; goto err;
if (UI_add_input_string(ui, prompt, 0, buf, min, len - 1) < 0) if (UI_add_input_string(ui, prompt, 0, buf, min, len - 1) < 0)
return -1; goto err;
if (verify) { if (verify) {
if (UI_add_verify_string(ui, prompt, 0, buff, min, len - 1, buf) if (UI_add_verify_string(ui, prompt, 0, buff, min, len - 1,
< 0) buf) < 0)
return -1; goto err;
} }
ret = UI_process(ui); ret = UI_process(ui);
err:
UI_free(ui); UI_free(ui);
explicit_bzero(buff, BUFSIZ); explicit_bzero(buff, BUFSIZ);
return ret; return ret;
} }
@ -150,7 +154,7 @@ EVP_BytesToKey(const EVP_CIPHER *type, const EVP_MD *md,
} }
if (data == NULL) if (data == NULL)
return (nkey); return nkey;
EVP_MD_CTX_init(&c); EVP_MD_CTX_init(&c);
for (;;) { for (;;) {

View File

@ -1,4 +1,4 @@
/* $OpenBSD: p_lib.c,v 1.57 2024/01/04 17:22:29 tb Exp $ */ /* $OpenBSD: p_lib.c,v 1.58 2024/01/05 21:22:01 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.
* *
@ -208,8 +208,7 @@ const EVP_PKEY_ASN1_METHOD *
EVP_PKEY_asn1_find_str(ENGINE **engine, const char *str, int len) EVP_PKEY_asn1_find_str(ENGINE **engine, const char *str, int len)
{ {
const EVP_PKEY_ASN1_METHOD *ameth; const EVP_PKEY_ASN1_METHOD *ameth;
size_t str_len; size_t i, str_len;
int i;
if (engine != NULL) if (engine != NULL)
*engine = NULL; *engine = NULL;
@ -223,7 +222,7 @@ EVP_PKEY_asn1_find_str(ENGINE **engine, const char *str, int len)
for (i = 0; i < N_ASN1_METHODS; i++) { for (i = 0; i < N_ASN1_METHODS; i++) {
ameth = asn1_methods[i]; ameth = asn1_methods[i];
if (ameth->pkey_flags & ASN1_PKEY_ALIAS) if ((ameth->pkey_flags & ASN1_PKEY_ALIAS) != 0)
continue; continue;
if (strlen(ameth->pem_str) != str_len) if (strlen(ameth->pem_str) != str_len)
continue; continue;

View File

@ -1,4 +1,4 @@
/* $OpenBSD: x509_local.h,v 1.17 2023/12/29 05:33:32 tb Exp $ */ /* $OpenBSD: x509_local.h,v 1.18 2024/01/06 17:37:23 tb Exp $ */
/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
* project 2013. * project 2013.
*/ */
@ -224,8 +224,6 @@ struct X509_crl_st {
ASN1_INTEGER *base_crl_number; ASN1_INTEGER *base_crl_number;
unsigned char hash[X509_CRL_HASH_LEN]; unsigned char hash[X509_CRL_HASH_LEN];
STACK_OF(GENERAL_NAMES) *issuers; STACK_OF(GENERAL_NAMES) *issuers;
const X509_CRL_METHOD *meth;
void *meth_data;
} /* X509_CRL */; } /* X509_CRL */;
struct pkcs8_priv_key_info_st { struct pkcs8_priv_key_info_st {

View File

@ -1,4 +1,4 @@
/* $OpenBSD: x509_purp.c,v 1.33 2023/12/31 07:19:13 tb Exp $ */ /* $OpenBSD: x509_purp.c,v 1.34 2024/01/06 17:17:08 tb Exp $ */
/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
* project 2001. * project 2001.
*/ */
@ -95,9 +95,6 @@ static int check_purpose_timestamp_sign(const X509_PURPOSE *xp, const X509 *x,
static int no_check(const X509_PURPOSE *xp, const X509 *x, int ca); static int no_check(const X509_PURPOSE *xp, const X509 *x, int ca);
static int ocsp_helper(const X509_PURPOSE *xp, const X509 *x, int ca); static int ocsp_helper(const X509_PURPOSE *xp, const X509 *x, int ca);
static int xp_cmp(const X509_PURPOSE * const *a, const X509_PURPOSE * const *b);
static void xptable_free(X509_PURPOSE *p);
static X509_PURPOSE xstandard[] = { static X509_PURPOSE xstandard[] = {
{ {
.purpose = X509_PURPOSE_SSL_CLIENT, .purpose = X509_PURPOSE_SSL_CLIENT,
@ -166,14 +163,6 @@ static X509_PURPOSE xstandard[] = {
#define X509_PURPOSE_COUNT (sizeof(xstandard) / sizeof(xstandard[0])) #define X509_PURPOSE_COUNT (sizeof(xstandard) / sizeof(xstandard[0]))
static STACK_OF(X509_PURPOSE) *xptable = NULL;
static int
xp_cmp(const X509_PURPOSE * const *a, const X509_PURPOSE * const *b)
{
return (*a)->purpose - (*b)->purpose;
}
/* As much as I'd like to make X509_check_purpose use a "const" X509* /* As much as I'd like to make X509_check_purpose use a "const" X509*
* I really can't because it does recalculate hashes and do other non-const * I really can't because it does recalculate hashes and do other non-const
* things. */ * things. */
@ -211,20 +200,17 @@ LCRYPTO_ALIAS(X509_PURPOSE_set);
int int
X509_PURPOSE_get_count(void) X509_PURPOSE_get_count(void)
{ {
if (!xptable)
return X509_PURPOSE_COUNT; return X509_PURPOSE_COUNT;
return sk_X509_PURPOSE_num(xptable) + X509_PURPOSE_COUNT;
} }
LCRYPTO_ALIAS(X509_PURPOSE_get_count); LCRYPTO_ALIAS(X509_PURPOSE_get_count);
X509_PURPOSE * X509_PURPOSE *
X509_PURPOSE_get0(int idx) X509_PURPOSE_get0(int idx)
{ {
if (idx < 0) if (idx < 0 || (size_t)idx >= X509_PURPOSE_COUNT)
return NULL; return NULL;
if (idx < (int)X509_PURPOSE_COUNT)
return xstandard + idx; return &xstandard[idx];
return sk_X509_PURPOSE_value(xptable, idx - X509_PURPOSE_COUNT);
} }
LCRYPTO_ALIAS(X509_PURPOSE_get0); LCRYPTO_ALIAS(X509_PURPOSE_get0);
@ -246,18 +232,11 @@ LCRYPTO_ALIAS(X509_PURPOSE_get_by_sname);
int int
X509_PURPOSE_get_by_id(int purpose) X509_PURPOSE_get_by_id(int purpose)
{ {
X509_PURPOSE tmp; /* X509_PURPOSE_MIN == 1, so the bounds are correct. */
int idx; if (purpose < X509_PURPOSE_MIN || purpose > X509_PURPOSE_MAX)
return -1;
if ((purpose >= X509_PURPOSE_MIN) && (purpose <= X509_PURPOSE_MAX))
return purpose - X509_PURPOSE_MIN; return purpose - X509_PURPOSE_MIN;
tmp.purpose = purpose;
if (!xptable)
return -1;
idx = sk_X509_PURPOSE_find(xptable, &tmp);
if (idx == -1)
return -1;
return idx + X509_PURPOSE_COUNT;
} }
LCRYPTO_ALIAS(X509_PURPOSE_get_by_id); LCRYPTO_ALIAS(X509_PURPOSE_get_by_id);
@ -266,95 +245,14 @@ X509_PURPOSE_add(int id, int trust, int flags,
int (*ck)(const X509_PURPOSE *, const X509 *, int), const char *name, int (*ck)(const X509_PURPOSE *, const X509 *, int), const char *name,
const char *sname, void *arg) const char *sname, void *arg)
{ {
int idx; X509error(ERR_R_DISABLED);
X509_PURPOSE *ptmp;
char *name_dup, *sname_dup;
name_dup = sname_dup = NULL;
if (name == NULL || sname == NULL) {
X509V3error(X509V3_R_INVALID_NULL_ARGUMENT);
return 0;
}
/* This is set according to what we change: application can't set it */
flags &= ~X509_PURPOSE_DYNAMIC;
/* This will always be set for application modified trust entries */
flags |= X509_PURPOSE_DYNAMIC_NAME;
/* Get existing entry if any */
idx = X509_PURPOSE_get_by_id(id);
/* Need a new entry */
if (idx == -1) {
if ((ptmp = malloc(sizeof(X509_PURPOSE))) == NULL) {
X509V3error(ERR_R_MALLOC_FAILURE);
return 0;
}
ptmp->flags = X509_PURPOSE_DYNAMIC;
} else
ptmp = X509_PURPOSE_get0(idx);
if ((name_dup = strdup(name)) == NULL)
goto err;
if ((sname_dup = strdup(sname)) == NULL)
goto err;
/* free existing name if dynamic */
if (ptmp->flags & X509_PURPOSE_DYNAMIC_NAME) {
free(ptmp->name);
free(ptmp->sname);
}
/* dup supplied name */
ptmp->name = name_dup;
ptmp->sname = sname_dup;
/* Keep the dynamic flag of existing entry */
ptmp->flags &= X509_PURPOSE_DYNAMIC;
/* Set all other flags */
ptmp->flags |= flags;
ptmp->purpose = id;
ptmp->trust = trust;
ptmp->check_purpose = ck;
ptmp->usr_data = arg;
/* If its a new entry manage the dynamic table */
if (idx == -1) {
if (xptable == NULL &&
(xptable = sk_X509_PURPOSE_new(xp_cmp)) == NULL)
goto err;
if (sk_X509_PURPOSE_push(xptable, ptmp) == 0)
goto err;
}
return 1;
err:
free(name_dup);
free(sname_dup);
if (idx == -1)
free(ptmp);
X509V3error(ERR_R_MALLOC_FAILURE);
return 0; return 0;
} }
LCRYPTO_ALIAS(X509_PURPOSE_add); LCRYPTO_ALIAS(X509_PURPOSE_add);
static void
xptable_free(X509_PURPOSE *p)
{
if (!p)
return;
if (p->flags & X509_PURPOSE_DYNAMIC) {
if (p->flags & X509_PURPOSE_DYNAMIC_NAME) {
free(p->name);
free(p->sname);
}
free(p);
}
}
void void
X509_PURPOSE_cleanup(void) X509_PURPOSE_cleanup(void)
{ {
sk_X509_PURPOSE_pop_free(xptable, xptable_free);
xptable = NULL;
} }
LCRYPTO_ALIAS(X509_PURPOSE_cleanup); LCRYPTO_ALIAS(X509_PURPOSE_cleanup);

View File

@ -1,5 +1,5 @@
#!/bin/ksh #!/bin/ksh
# $OpenBSD: carp_1.sh,v 1.2 2023/10/19 18:36:41 anton Exp $ # $OpenBSD: carp_1.sh,v 1.3 2024/01/05 10:37:54 anton Exp $
cleanup() cleanup()
@ -78,13 +78,13 @@ ifconfig carp$IFNO2 rdomain $RD2 192.168.0.1/24 \
# #
# IFNO1 must become master # IFNO1 must become master
sleep 3.1 # need 3 seconds to become master wait_until "ifconfig carp$IFNO1 | grep -q 'status: master'"
test sh -c "ifconfig carp$IFNO1 | grep -q 'status: master'" test sh -c "ifconfig carp$IFNO1 | grep -q 'status: master'"
test sh -c "ifconfig carp$IFNO2 | grep -q 'status: backup'" test sh -c "ifconfig carp$IFNO2 | grep -q 'status: backup'"
# carpdemote must work # carpdemote must work
ifconfig -g ${IFGPREFIX}a carpdemote ifconfig -g ${IFGPREFIX}a carpdemote
sleep 0.1 wait_until "ifconfig carp$IFNO1 | grep -q 'status: backup'"
test sh -c "ifconfig carp$IFNO1 | grep -q 'status: backup'" test sh -c "ifconfig carp$IFNO1 | grep -q 'status: backup'"
test sh -c "ifconfig carp$IFNO2 | grep -q 'status: master'" test sh -c "ifconfig carp$IFNO2 | grep -q 'status: master'"

View File

@ -1,5 +1,5 @@
#!/bin/ksh #!/bin/ksh
# $OpenBSD: carp_2.sh,v 1.2 2023/10/19 18:36:41 anton Exp $ # $OpenBSD: carp_2.sh,v 1.3 2024/01/05 10:37:54 anton Exp $
cleanup() cleanup()
@ -81,13 +81,13 @@ ifconfig carp$IFNO2 rdomain $RD2 lladdr $lladdr2 192.168.0.1/24 \
# #
# IFNO1 must become master # IFNO1 must become master
sleep 3.1 # need 3 seconds to become master wait_until "ifconfig carp$IFNO1 | grep -q 'status: master'"
test sh -c "ifconfig carp$IFNO1 | grep -q 'status: master'" test sh -c "ifconfig carp$IFNO1 | grep -q 'status: master'"
test sh -c "ifconfig carp$IFNO2 | grep -q 'status: backup'" test sh -c "ifconfig carp$IFNO2 | grep -q 'status: backup'"
# carpdemote must work # carpdemote must work
ifconfig -g ${IFGPREFIX}a carpdemote ifconfig -g ${IFGPREFIX}a carpdemote
sleep 0.1 wait_until "ifconfig carp$IFNO1 | grep -q 'status: backup'"
test sh -c "ifconfig carp$IFNO1 | grep -q 'status: backup'" test sh -c "ifconfig carp$IFNO1 | grep -q 'status: backup'"
test sh -c "ifconfig carp$IFNO2 | grep -q 'status: master'" test sh -c "ifconfig carp$IFNO2 | grep -q 'status: master'"

View File

@ -1,5 +1,5 @@
#!/bin/ksh #!/bin/ksh
# $OpenBSD: carp_3.sh,v 1.2 2023/10/19 18:36:41 anton Exp $ # $OpenBSD: carp_3.sh,v 1.3 2024/01/05 10:37:54 anton Exp $
cleanup() cleanup()
@ -78,13 +78,13 @@ ifconfig carp$IFNO2 rdomain $RD2 192.168.0.1/24 \
# #
# IFNO1 must become master # IFNO1 must become master
sleep 3.1 # need 3 seconds to become master wait_until "ifconfig carp$IFNO1 | grep -q 'status: master'"
test sh -c "ifconfig carp$IFNO1 | grep -q 'status: master'" test sh -c "ifconfig carp$IFNO1 | grep -q 'status: master'"
test sh -c "ifconfig carp$IFNO2 | grep -q 'status: backup'" test sh -c "ifconfig carp$IFNO2 | grep -q 'status: backup'"
# carpdemote must work # carpdemote must work
ifconfig -g ${IFGPREFIX}a carpdemote ifconfig -g ${IFGPREFIX}a carpdemote
sleep 0.1 wait_until "ifconfig carp$IFNO1 | grep -q 'status: backup'"
test sh -c "ifconfig carp$IFNO1 | grep -q 'status: backup'" test sh -c "ifconfig carp$IFNO1 | grep -q 'status: backup'"
test sh -c "ifconfig carp$IFNO2 | grep -q 'status: master'" test sh -c "ifconfig carp$IFNO2 | grep -q 'status: master'"

View File

@ -1,5 +1,5 @@
#!/bin/ksh #!/bin/ksh
# $OpenBSD: carp_4.sh,v 1.2 2023/10/19 18:36:41 anton Exp $ # $OpenBSD: carp_4.sh,v 1.3 2024/01/05 10:37:54 anton Exp $
cleanup() cleanup()
@ -81,13 +81,13 @@ ifconfig carp$IFNO2 rdomain $RD2 lladdr $lladdr2 192.168.0.1/24 \
# #
# IFNO1 must become master # IFNO1 must become master
sleep 3.1 # need 3 seconds to become master wait_until "ifconfig carp$IFNO1 | grep -q 'status: master'"
test sh -c "ifconfig carp$IFNO1 | grep -q 'status: master'" test sh -c "ifconfig carp$IFNO1 | grep -q 'status: master'"
test sh -c "ifconfig carp$IFNO2 | grep -q 'status: backup'" test sh -c "ifconfig carp$IFNO2 | grep -q 'status: backup'"
# carpdemote must work # carpdemote must work
ifconfig -g ${IFGPREFIX}a carpdemote ifconfig -g ${IFGPREFIX}a carpdemote
sleep 0.1 wait_until "ifconfig carp$IFNO1 | grep -q 'status: backup'"
test sh -c "ifconfig carp$IFNO1 | grep -q 'status: backup'" test sh -c "ifconfig carp$IFNO1 | grep -q 'status: backup'"
test sh -c "ifconfig carp$IFNO2 | grep -q 'status: master'" test sh -c "ifconfig carp$IFNO2 | grep -q 'status: master'"

View File

@ -55,6 +55,19 @@ test()
fi fi
} }
wait_until() {
local _i=0
while [ "$_i" -lt 8 ]; do
sh -c "$@" && return 0
sleep 0.5
_i="$((_i + 1))"
done
echo timeout
return 1
}
RDOMAINS="" RDOMAINS=""
IFACE_NUMS="" IFACE_NUMS=""
while getopts 'cvR:I:' ch "$@"; do while getopts 'cvR:I:' ch "$@"; do

View File

@ -1,4 +1,4 @@
.\" $OpenBSD: cargo-module.5,v 1.8 2024/01/01 14:16:59 semarie Exp $ .\" $OpenBSD: cargo-module.5,v 1.9 2024/01/06 08:03:31 semarie Exp $
.\" .\"
.\" Copyright (c) 2008 Marc Espie .\" Copyright (c) 2008 Marc Espie
.\" Copyright (c) 2017 Daniel Jakots .\" Copyright (c) 2017 Daniel Jakots
@ -25,7 +25,7 @@
.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.\" .\"
.Dd $Mdocdate: January 1 2024 $ .Dd $Mdocdate: January 6 2024 $
.Dt CARGO-MODULE 5 .Dt CARGO-MODULE 5
.Os .Os
.Sh NAME .Sh NAME
@ -88,7 +88,7 @@ is added to
.Ev BUILD_DEPENDS . .Ev BUILD_DEPENDS .
.Pp .Pp
This module defines: This module defines:
.Bl -tag -width MODCARGO_INSTALL_TARGET_PATH .Bl -tag -width MODCARGO_INSTALL_TARGET_PATHS
.It Ev MODCARGO_CARGOTOML .It Ev MODCARGO_CARGOTOML
Path to cargo manifest. Path to cargo manifest.
Defaults to Defaults to
@ -99,8 +99,8 @@ Crates that will be downloaded by the module.
List of crates to update, overriding the version listed in Cargo.lock. List of crates to update, overriding the version listed in Cargo.lock.
.It Ev MODCARGO_FEATURES .It Ev MODCARGO_FEATURES
List of features to be used when building. List of features to be used when building.
.It Ev MODCARGO_INSTALL_TARGET_PATH .It Ev MODCARGO_INSTALL_TARGET_PATHS
Path to pass to List of paths to pass to
.Cm cargo install .Cm cargo install
instead of instead of
.Pa \&. . .Pa \&. .

View File

@ -1,4 +1,4 @@
/* $OpenBSD: vmm_machdep.c,v 1.12 2023/12/10 21:25:14 dv Exp $ */ /* $OpenBSD: vmm_machdep.c,v 1.13 2024/01/06 13:17:20 dv Exp $ */
/* /*
* Copyright (c) 2014 Mike Larkin <mlarkin@openbsd.org> * Copyright (c) 2014 Mike Larkin <mlarkin@openbsd.org>
* *
@ -213,18 +213,18 @@ const struct {
uint64_t arid; uint64_t arid;
uint64_t baseid; uint64_t baseid;
} vmm_vmx_sreg_vmcs_fields[] = { } vmm_vmx_sreg_vmcs_fields[] = {
{ VMCS_GUEST_IA32_CS_SEL, VMCS_GUEST_IA32_CS_LIMIT,
VMCS_GUEST_IA32_CS_AR, VMCS_GUEST_IA32_CS_BASE },
{ VMCS_GUEST_IA32_DS_SEL, VMCS_GUEST_IA32_DS_LIMIT,
VMCS_GUEST_IA32_DS_AR, VMCS_GUEST_IA32_DS_BASE },
{ VMCS_GUEST_IA32_ES_SEL, VMCS_GUEST_IA32_ES_LIMIT, { VMCS_GUEST_IA32_ES_SEL, VMCS_GUEST_IA32_ES_LIMIT,
VMCS_GUEST_IA32_ES_AR, VMCS_GUEST_IA32_ES_BASE }, VMCS_GUEST_IA32_ES_AR, VMCS_GUEST_IA32_ES_BASE },
{ VMCS_GUEST_IA32_CS_SEL, VMCS_GUEST_IA32_CS_LIMIT,
VMCS_GUEST_IA32_CS_AR, VMCS_GUEST_IA32_CS_BASE },
{ VMCS_GUEST_IA32_SS_SEL, VMCS_GUEST_IA32_SS_LIMIT,
VMCS_GUEST_IA32_SS_AR, VMCS_GUEST_IA32_SS_BASE },
{ VMCS_GUEST_IA32_DS_SEL, VMCS_GUEST_IA32_DS_LIMIT,
VMCS_GUEST_IA32_DS_AR, VMCS_GUEST_IA32_DS_BASE },
{ VMCS_GUEST_IA32_FS_SEL, VMCS_GUEST_IA32_FS_LIMIT, { VMCS_GUEST_IA32_FS_SEL, VMCS_GUEST_IA32_FS_LIMIT,
VMCS_GUEST_IA32_FS_AR, VMCS_GUEST_IA32_FS_BASE }, VMCS_GUEST_IA32_FS_AR, VMCS_GUEST_IA32_FS_BASE },
{ VMCS_GUEST_IA32_GS_SEL, VMCS_GUEST_IA32_GS_LIMIT, { VMCS_GUEST_IA32_GS_SEL, VMCS_GUEST_IA32_GS_LIMIT,
VMCS_GUEST_IA32_GS_AR, VMCS_GUEST_IA32_GS_BASE }, VMCS_GUEST_IA32_GS_AR, VMCS_GUEST_IA32_GS_BASE },
{ VMCS_GUEST_IA32_SS_SEL, VMCS_GUEST_IA32_SS_LIMIT,
VMCS_GUEST_IA32_SS_AR, VMCS_GUEST_IA32_SS_BASE },
{ VMCS_GUEST_IA32_LDTR_SEL, VMCS_GUEST_IA32_LDTR_LIMIT, { VMCS_GUEST_IA32_LDTR_SEL, VMCS_GUEST_IA32_LDTR_LIMIT,
VMCS_GUEST_IA32_LDTR_AR, VMCS_GUEST_IA32_LDTR_BASE }, VMCS_GUEST_IA32_LDTR_AR, VMCS_GUEST_IA32_LDTR_BASE },
{ VMCS_GUEST_IA32_TR_SEL, VMCS_GUEST_IA32_TR_LIMIT, { VMCS_GUEST_IA32_TR_SEL, VMCS_GUEST_IA32_TR_LIMIT,

View File

@ -1,4 +1,4 @@
/* $OpenBSD: vmmvar.h,v 1.95 2023/11/28 00:17:48 dv Exp $ */ /* $OpenBSD: vmmvar.h,v 1.96 2024/01/06 13:17:20 dv Exp $ */
/* /*
* Copyright (c) 2014 Mike Larkin <mlarkin@openbsd.org> * Copyright (c) 2014 Mike Larkin <mlarkin@openbsd.org>
* *
@ -397,12 +397,12 @@ struct vcpu_segment_info {
#define VCPU_REGS_PDPTE3 9 #define VCPU_REGS_PDPTE3 9
#define VCPU_REGS_NCRS (VCPU_REGS_PDPTE3 + 1) #define VCPU_REGS_NCRS (VCPU_REGS_PDPTE3 + 1)
#define VCPU_REGS_CS 0 #define VCPU_REGS_ES 0
#define VCPU_REGS_DS 1 #define VCPU_REGS_CS 1
#define VCPU_REGS_ES 2 #define VCPU_REGS_SS 2
#define VCPU_REGS_FS 3 #define VCPU_REGS_DS 3
#define VCPU_REGS_GS 4 #define VCPU_REGS_FS 4
#define VCPU_REGS_SS 5 #define VCPU_REGS_GS 5
#define VCPU_REGS_LDTR 6 #define VCPU_REGS_LDTR 6
#define VCPU_REGS_TR 7 #define VCPU_REGS_TR 7
#define VCPU_REGS_NSREGS (VCPU_REGS_TR + 1) #define VCPU_REGS_NSREGS (VCPU_REGS_TR + 1)

View File

@ -1,4 +1,4 @@
/* $OpenBSD: ufshci_acpi.c,v 1.1 2023/02/04 23:11:59 mglocker Exp $ */ /* $OpenBSD: ufshci_acpi.c,v 1.2 2024/01/06 17:47:43 mglocker Exp $ */
/* /*
* Copyright (c) 2022 Marcus Glocker <mglocker@openbsd.org> * Copyright (c) 2022 Marcus Glocker <mglocker@openbsd.org>
* *
@ -100,10 +100,7 @@ ufshci_acpi_attach(struct device *parent, struct device *self, void *aux)
printf(": can't establish interrupt\n"); printf(": can't establish interrupt\n");
return; return;
} }
#if 0
/* XXX: Only for testing */
config_mountroot(self, ufshci_attach_hook);
#endif
error = ufshci_attach(&sc->sc); error = ufshci_attach(&sc->sc);
if (error) { if (error) {
printf("%s: attach failed, error=%d\n", printf("%s: attach failed, error=%d\n",

View File

@ -1,4 +1,4 @@
/* $OpenBSD: ufshci.c,v 1.6 2024/01/04 21:35:56 mglocker Exp $ */ /* $OpenBSD: ufshci.c,v 1.9 2024/01/06 17:47:43 mglocker Exp $ */
/* /*
* Copyright (c) 2022 Marcus Glocker <mglocker@openbsd.org> * Copyright (c) 2022 Marcus Glocker <mglocker@openbsd.org>
@ -68,21 +68,18 @@ void ufshci_doorbell_set(struct ufshci_softc *, int);
uint8_t ufshci_get_taskid(struct ufshci_softc *); uint8_t ufshci_get_taskid(struct ufshci_softc *);
int ufshci_utr_cmd_nop(struct ufshci_softc *); int ufshci_utr_cmd_nop(struct ufshci_softc *);
int ufshci_utr_cmd_lun(struct ufshci_softc *, int ufshci_utr_cmd_lun(struct ufshci_softc *,
struct ufshci_ccb *, int); struct ufshci_ccb *, struct scsi_xfer *);
int ufshci_utr_cmd_inquiry(struct ufshci_softc *, int ufshci_utr_cmd_inquiry(struct ufshci_softc *,
struct ufshci_ccb *, int, int); struct ufshci_ccb *, struct scsi_xfer *);
int ufshci_utr_cmd_capacity16(struct ufshci_softc *, int ufshci_utr_cmd_capacity16(struct ufshci_softc *,
struct ufshci_ccb *, int, int); struct ufshci_ccb *, struct scsi_xfer *);
int ufshci_utr_cmd_capacity(struct ufshci_softc *, int ufshci_utr_cmd_capacity(struct ufshci_softc *,
struct ufshci_ccb *, int, int); struct ufshci_ccb *, struct scsi_xfer *);
int ufshci_utr_cmd_read(struct ufshci_softc *, int ufshci_utr_cmd_io(struct ufshci_softc *,
struct ufshci_ccb *, int, int, struct ufshci_ccb *, struct scsi_xfer *, int);
struct scsi_generic *);
int ufshci_utr_cmd_write(struct ufshci_softc *,
struct ufshci_ccb *, int, int,
struct scsi_generic *);
int ufshci_utr_cmd_sync(struct ufshci_softc *, int ufshci_utr_cmd_sync(struct ufshci_softc *,
struct ufshci_ccb *, int, uint32_t, uint16_t); struct ufshci_ccb *, struct scsi_xfer *,
uint32_t, uint16_t);
int ufshci_xfer_complete(struct ufshci_softc *); int ufshci_xfer_complete(struct ufshci_softc *);
/* SCSI */ /* SCSI */
@ -150,15 +147,6 @@ ufshci_intr(void *arg)
return 1; return 1;
} }
/* XXX: Only for testing */
void
ufshci_attach_hook(struct device *self)
{
struct ufshci_softc *sc = (struct ufshci_softc *)self;
ufshci_attach(sc);
}
int int
ufshci_attach(struct ufshci_softc *sc) ufshci_attach(struct ufshci_softc *sc)
{ {
@ -619,7 +607,7 @@ ufshci_utr_cmd_nop(struct ufshci_softc *sc)
int int
ufshci_utr_cmd_lun(struct ufshci_softc *sc, struct ufshci_ccb *ccb, ufshci_utr_cmd_lun(struct ufshci_softc *sc, struct ufshci_ccb *ccb,
int rsp_size) struct scsi_xfer *xs)
{ {
int slot, off, len, i; int slot, off, len, i;
uint64_t dva; uint64_t dva;
@ -662,13 +650,13 @@ ufshci_utr_cmd_lun(struct ufshci_softc *sc, struct ufshci_ccb *ccb,
ucd->cmd.hdr.device_info = 0; ucd->cmd.hdr.device_info = 0;
ucd->cmd.hdr.ds_len = 0; ucd->cmd.hdr.ds_len = 0;
ucd->cmd.expected_xfer_len = htobe32(rsp_size); ucd->cmd.expected_xfer_len = htobe32(xs->datalen);
ucd->cmd.cdb[0] = REPORT_LUNS; ucd->cmd.cdb[0] = REPORT_LUNS;
ucd->cmd.cdb[6] = 0; ucd->cmd.cdb[6] = 0;
ucd->cmd.cdb[7] = 0; ucd->cmd.cdb[7] = 0;
ucd->cmd.cdb[8] = 0; ucd->cmd.cdb[8] = 0;
ucd->cmd.cdb[9] = rsp_size; ucd->cmd.cdb[9] = xs->datalen;
/* 7.2.1 Basic Steps when Building a UTP Transfer Request: 2g) */ /* 7.2.1 Basic Steps when Building a UTP Transfer Request: 2g) */
/* Already done with above memset */ /* Already done with above memset */
@ -728,7 +716,7 @@ ufshci_utr_cmd_lun(struct ufshci_softc *sc, struct ufshci_ccb *ccb,
int int
ufshci_utr_cmd_inquiry(struct ufshci_softc *sc, struct ufshci_ccb *ccb, ufshci_utr_cmd_inquiry(struct ufshci_softc *sc, struct ufshci_ccb *ccb,
int rsp_size, int flags) struct scsi_xfer *xs)
{ {
int slot, off, len, i; int slot, off, len, i;
uint64_t dva; uint64_t dva;
@ -771,11 +759,11 @@ ufshci_utr_cmd_inquiry(struct ufshci_softc *sc, struct ufshci_ccb *ccb,
ucd->cmd.hdr.device_info = 0; ucd->cmd.hdr.device_info = 0;
ucd->cmd.hdr.ds_len = 0; ucd->cmd.hdr.ds_len = 0;
ucd->cmd.expected_xfer_len = htobe32(rsp_size); ucd->cmd.expected_xfer_len = htobe32(xs->datalen);
ucd->cmd.cdb[0] = INQUIRY; /* 0x12 */ ucd->cmd.cdb[0] = INQUIRY; /* 0x12 */
ucd->cmd.cdb[3] = 0; ucd->cmd.cdb[3] = 0;
ucd->cmd.cdb[4] = rsp_size; ucd->cmd.cdb[4] = xs->datalen;
/* 7.2.1 Basic Steps when Building a UTP Transfer Request: 2g) */ /* 7.2.1 Basic Steps when Building a UTP Transfer Request: 2g) */
/* Already done with above memset */ /* Already done with above memset */
@ -821,7 +809,7 @@ ufshci_utr_cmd_inquiry(struct ufshci_softc *sc, struct ufshci_ccb *ccb,
/* 7.2.1 Basic Steps when Building a UTP Transfer Request: 11) */ /* 7.2.1 Basic Steps when Building a UTP Transfer Request: 11) */
/* 7.2.1 Basic Steps when Building a UTP Transfer Request: 12) */ /* 7.2.1 Basic Steps when Building a UTP Transfer Request: 12) */
/* 7.2.1 Basic Steps when Building a UTP Transfer Request: 13) */ /* 7.2.1 Basic Steps when Building a UTP Transfer Request: 13) */
if (!ISSET(flags, SCSI_POLL)) { if (!ISSET(xs->flags, SCSI_POLL)) {
UFSHCI_WRITE_4(sc, UFSHCI_REG_UTRIACR, UFSHCI_WRITE_4(sc, UFSHCI_REG_UTRIACR,
UFSHCI_REG_UTRIACR_IAEN | UFSHCI_REG_UTRIACR_IAEN |
UFSHCI_REG_UTRIACR_IAPWEN | UFSHCI_REG_UTRIACR_IAPWEN |
@ -837,7 +825,7 @@ ufshci_utr_cmd_inquiry(struct ufshci_softc *sc, struct ufshci_ccb *ccb,
int int
ufshci_utr_cmd_capacity16(struct ufshci_softc *sc, struct ufshci_ccb *ccb, ufshci_utr_cmd_capacity16(struct ufshci_softc *sc, struct ufshci_ccb *ccb,
int rsp_size, int flags) struct scsi_xfer *xs)
{ {
int slot, off, len, i; int slot, off, len, i;
uint64_t dva; uint64_t dva;
@ -880,7 +868,7 @@ ufshci_utr_cmd_capacity16(struct ufshci_softc *sc, struct ufshci_ccb *ccb,
ucd->cmd.hdr.device_info = 0; ucd->cmd.hdr.device_info = 0;
ucd->cmd.hdr.ds_len = 0; ucd->cmd.hdr.ds_len = 0;
ucd->cmd.expected_xfer_len = htobe32(rsp_size); ucd->cmd.expected_xfer_len = htobe32(xs->datalen);
ucd->cmd.cdb[0] = READ_CAPACITY_16; /* 0x9e */ ucd->cmd.cdb[0] = READ_CAPACITY_16; /* 0x9e */
ucd->cmd.cdb[1] = 0x10; /* Service Action */ ucd->cmd.cdb[1] = 0x10; /* Service Action */
@ -888,7 +876,7 @@ ufshci_utr_cmd_capacity16(struct ufshci_softc *sc, struct ufshci_ccb *ccb,
ucd->cmd.cdb[10] = 0; ucd->cmd.cdb[10] = 0;
ucd->cmd.cdb[11] = 0; ucd->cmd.cdb[11] = 0;
ucd->cmd.cdb[12] = 0; ucd->cmd.cdb[12] = 0;
ucd->cmd.cdb[13] = rsp_size; ucd->cmd.cdb[13] = xs->datalen;
/* 7.2.1 Basic Steps when Building a UTP Transfer Request: 2g) */ /* 7.2.1 Basic Steps when Building a UTP Transfer Request: 2g) */
/* Already done with above memset */ /* Already done with above memset */
@ -934,7 +922,7 @@ ufshci_utr_cmd_capacity16(struct ufshci_softc *sc, struct ufshci_ccb *ccb,
/* 7.2.1 Basic Steps when Building a UTP Transfer Request: 11) */ /* 7.2.1 Basic Steps when Building a UTP Transfer Request: 11) */
/* 7.2.1 Basic Steps when Building a UTP Transfer Request: 12) */ /* 7.2.1 Basic Steps when Building a UTP Transfer Request: 12) */
/* 7.2.1 Basic Steps when Building a UTP Transfer Request: 13) */ /* 7.2.1 Basic Steps when Building a UTP Transfer Request: 13) */
if (!ISSET(flags, SCSI_POLL)) { if (!ISSET(xs->flags, SCSI_POLL)) {
UFSHCI_WRITE_4(sc, UFSHCI_REG_UTRIACR, UFSHCI_WRITE_4(sc, UFSHCI_REG_UTRIACR,
UFSHCI_REG_UTRIACR_IAEN | UFSHCI_REG_UTRIACR_IAEN |
UFSHCI_REG_UTRIACR_IAPWEN | UFSHCI_REG_UTRIACR_IAPWEN |
@ -950,7 +938,7 @@ ufshci_utr_cmd_capacity16(struct ufshci_softc *sc, struct ufshci_ccb *ccb,
int int
ufshci_utr_cmd_capacity(struct ufshci_softc *sc, struct ufshci_ccb *ccb, ufshci_utr_cmd_capacity(struct ufshci_softc *sc, struct ufshci_ccb *ccb,
int rsp_size, int flags) struct scsi_xfer *xs)
{ {
int slot, off, len, i; int slot, off, len, i;
uint64_t dva; uint64_t dva;
@ -993,7 +981,7 @@ ufshci_utr_cmd_capacity(struct ufshci_softc *sc, struct ufshci_ccb *ccb,
ucd->cmd.hdr.device_info = 0; ucd->cmd.hdr.device_info = 0;
ucd->cmd.hdr.ds_len = 0; ucd->cmd.hdr.ds_len = 0;
ucd->cmd.expected_xfer_len = htobe32(rsp_size); ucd->cmd.expected_xfer_len = htobe32(xs->datalen);
ucd->cmd.cdb[0] = READ_CAPACITY; /* 0x25 */ ucd->cmd.cdb[0] = READ_CAPACITY; /* 0x25 */
/* Logical Block Address = 0 for UFS */ /* Logical Block Address = 0 for UFS */
@ -1046,7 +1034,7 @@ ufshci_utr_cmd_capacity(struct ufshci_softc *sc, struct ufshci_ccb *ccb,
/* 7.2.1 Basic Steps when Building a UTP Transfer Request: 11) */ /* 7.2.1 Basic Steps when Building a UTP Transfer Request: 11) */
/* 7.2.1 Basic Steps when Building a UTP Transfer Request: 12) */ /* 7.2.1 Basic Steps when Building a UTP Transfer Request: 12) */
/* 7.2.1 Basic Steps when Building a UTP Transfer Request: 13) */ /* 7.2.1 Basic Steps when Building a UTP Transfer Request: 13) */
if (!ISSET(flags, SCSI_POLL)) { if (!ISSET(xs->flags, SCSI_POLL)) {
UFSHCI_WRITE_4(sc, UFSHCI_REG_UTRIACR, UFSHCI_WRITE_4(sc, UFSHCI_REG_UTRIACR,
UFSHCI_REG_UTRIACR_IAEN | UFSHCI_REG_UTRIACR_IAEN |
UFSHCI_REG_UTRIACR_IAPWEN | UFSHCI_REG_UTRIACR_IAPWEN |
@ -1061,8 +1049,8 @@ ufshci_utr_cmd_capacity(struct ufshci_softc *sc, struct ufshci_ccb *ccb,
} }
int int
ufshci_utr_cmd_read(struct ufshci_softc *sc, struct ufshci_ccb *ccb, ufshci_utr_cmd_io(struct ufshci_softc *sc, struct ufshci_ccb *ccb,
int rsp_size, int flags, struct scsi_generic *scsi_cmd) struct scsi_xfer *xs, int dir)
{ {
int slot, off, len, i; int slot, off, len, i;
uint64_t dva; uint64_t dva;
@ -1080,114 +1068,9 @@ ufshci_utr_cmd_read(struct ufshci_softc *sc, struct ufshci_ccb *ccb,
utrd->dw0 = UFSHCI_UTRD_DW0_CT_UFS; utrd->dw0 = UFSHCI_UTRD_DW0_CT_UFS;
/* 7.2.1 Basic Steps when Building a UTP Transfer Request: 2b) */ /* 7.2.1 Basic Steps when Building a UTP Transfer Request: 2b) */
if (dir == SCSI_DATA_IN)
utrd->dw0 |= UFSHCI_UTRD_DW0_DD_T2I; utrd->dw0 |= UFSHCI_UTRD_DW0_DD_T2I;
else
/* 7.2.1 Basic Steps when Building a UTP Transfer Request: 2c) */
utrd->dw0 |= UFSHCI_UTRD_DW0_I_REG;
/* 7.2.1 Basic Steps when Building a UTP Transfer Request: 2d) */
utrd->dw2 = UFSHCI_UTRD_DW2_OCS_IOV;
/* 7.2.1 Basic Steps when Building a UTP Transfer Request: 2e) */
ucd = UFSHCI_DMA_KVA(sc->sc_dmamem_ucd) + (sizeof(*ucd) * slot);
memset(ucd, 0, sizeof(*ucd));
/* 7.2.1 Basic Steps when Building a UTP Transfer Request: 2f) */
ucd->cmd.hdr.tc = UPIU_TC_I2T_COMMAND;
ucd->cmd.hdr.flags = (1 << 6); /* Bit-5 = Write, Bit-6 = Read */
ucd->cmd.hdr.lun = 0;
ucd->cmd.hdr.taskid = ufshci_get_taskid(sc);
ucd->cmd.hdr.cmd_set_type = 0; /* SCSI command */
ucd->cmd.hdr.query = 0;
ucd->cmd.hdr.response = 0;
ucd->cmd.hdr.status = 0;
ucd->cmd.hdr.ehs_len = 0;
ucd->cmd.hdr.device_info = 0;
ucd->cmd.hdr.ds_len = 0;
ucd->cmd.expected_xfer_len = htobe32(rsp_size);
memcpy(ucd->cmd.cdb, scsi_cmd, sizeof(ucd->cmd.cdb));
//ucd->cmd.cdb[1] = (1 << 3); /* FUA: Force Unit Access */
/* 7.2.1 Basic Steps when Building a UTP Transfer Request: 2g) */
/* Already done with above memset */
/* 7.2.1 Basic Steps when Building a UTP Transfer Request: 3) */
dva = UFSHCI_DMA_DVA(sc->sc_dmamem_ucd) + (sizeof(*ucd) * slot);
DPRINTF("%s: ucd dva=%llu\n", __func__, dva);
utrd->dw4 = (uint32_t)dva;
utrd->dw5 = (uint32_t)(dva >> 32);
/* 7.2.1 Basic Steps when Building a UTP Transfer Request: 4) */
off = sizeof(struct upiu_command) / 4; /* DWORD offset */
utrd->dw6 = UFSHCI_UTRD_DW6_RUO(off);
/* 7.2.1 Basic Steps when Building a UTP Transfer Request: 5) */
len = sizeof(struct upiu_response) / 4; /* DWORD length */
utrd->dw6 |= UFSHCI_UTRD_DW6_RUL(len);
/* 7.2.1 Basic Steps when Building a UTP Transfer Request: 6) */
off = (sizeof(struct upiu_command) + sizeof(struct upiu_response)) / 4;
utrd->dw7 = UFSHCI_UTRD_DW7_PRDTO(off);
/* 7.2.1 Basic Steps when Building a UTP Transfer Request: 7) */
utrd->dw7 |= UFSHCI_UTRD_DW7_PRDTL(dmap->dm_nsegs);
/* Build PRDT data segment. */
for (i = 0; i < dmap->dm_nsegs; i++) {
dva = dmap->dm_segs[i].ds_addr;
ucd->prdt[i].dw0 = (uint32_t)dva;
ucd->prdt[i].dw1 = (uint32_t)(dva >> 32);
ucd->prdt[i].dw2 = 0;
ucd->prdt[i].dw3 = dmap->dm_segs[i].ds_len - 1;
}
/* 7.2.1 Basic Steps when Building a UTP Transfer Request: 9) */
if (UFSHCI_READ_4(sc, UFSHCI_REG_UTRLRSR) != 1) {
printf("%s: %s: UTRLRSR not set\n",
sc->sc_dev.dv_xname, __func__);
return -1;
}
/* 7.2.1 Basic Steps when Building a UTP Transfer Request: 10) */
/* 7.2.1 Basic Steps when Building a UTP Transfer Request: 11) */
/* 7.2.1 Basic Steps when Building a UTP Transfer Request: 12) */
/* 7.2.1 Basic Steps when Building a UTP Transfer Request: 13) */
if (!ISSET(flags, SCSI_POLL)) {
UFSHCI_WRITE_4(sc, UFSHCI_REG_UTRIACR,
UFSHCI_REG_UTRIACR_IAEN |
UFSHCI_REG_UTRIACR_IAPWEN |
UFSHCI_REG_UTRIACR_IACTH(UFSHCI_INTR_AGGR_COUNT) |
UFSHCI_REG_UTRIACR_IATOVAL(UFSHCI_INTR_AGGR_TIMEOUT));
}
/* 7.2.1 Basic Steps when Building a UTP Transfer Request: 14) */
ufshci_doorbell_set(sc, slot);
return slot;
}
int
ufshci_utr_cmd_write(struct ufshci_softc *sc, struct ufshci_ccb *ccb,
int rsp_size, int flags, struct scsi_generic *scsi_cmd)
{
int slot, off, len, i;
uint64_t dva;
struct ufshci_utrd *utrd;
struct ufshci_ucd *ucd;
bus_dmamap_t dmap = ccb->ccb_dmamap;
/* 7.2.1 Basic Steps when Building a UTP Transfer Request: 1) */
slot = ufshci_doorbell_get_free(sc);
utrd = UFSHCI_DMA_KVA(sc->sc_dmamem_utrd) + (sizeof(*utrd) * slot);
memset(utrd, 0, sizeof(*utrd));
DPRINTF("%s: slot=%d\n", __func__, slot);
/* 7.2.1 Basic Steps when Building a UTP Transfer Request: 2a) */
utrd->dw0 = UFSHCI_UTRD_DW0_CT_UFS;
/* 7.2.1 Basic Steps when Building a UTP Transfer Request: 2b) */
utrd->dw0 |= UFSHCI_UTRD_DW0_DD_I2T; utrd->dw0 |= UFSHCI_UTRD_DW0_DD_I2T;
/* 7.2.1 Basic Steps when Building a UTP Transfer Request: 2c) */ /* 7.2.1 Basic Steps when Building a UTP Transfer Request: 2c) */
@ -1202,7 +1085,10 @@ ufshci_utr_cmd_write(struct ufshci_softc *sc, struct ufshci_ccb *ccb,
/* 7.2.1 Basic Steps when Building a UTP Transfer Request: 2f) */ /* 7.2.1 Basic Steps when Building a UTP Transfer Request: 2f) */
ucd->cmd.hdr.tc = UPIU_TC_I2T_COMMAND; ucd->cmd.hdr.tc = UPIU_TC_I2T_COMMAND;
ucd->cmd.hdr.flags = (1 << 5); /* Bit-5 = Write, Bit-6 = Read */ if (dir == SCSI_DATA_IN)
ucd->cmd.hdr.flags = (1 << 6); /* Bit-6 = Read */
else
ucd->cmd.hdr.flags = (1 << 5); /* Bit-5 = Write */
ucd->cmd.hdr.lun = 0; ucd->cmd.hdr.lun = 0;
ucd->cmd.hdr.taskid = ufshci_get_taskid(sc); ucd->cmd.hdr.taskid = ufshci_get_taskid(sc);
ucd->cmd.hdr.cmd_set_type = 0; /* SCSI command */ ucd->cmd.hdr.cmd_set_type = 0; /* SCSI command */
@ -1213,9 +1099,10 @@ ufshci_utr_cmd_write(struct ufshci_softc *sc, struct ufshci_ccb *ccb,
ucd->cmd.hdr.device_info = 0; ucd->cmd.hdr.device_info = 0;
ucd->cmd.hdr.ds_len = 0; ucd->cmd.hdr.ds_len = 0;
ucd->cmd.expected_xfer_len = htobe32(rsp_size); ucd->cmd.expected_xfer_len = htobe32(xs->datalen);
memcpy(ucd->cmd.cdb, scsi_cmd, sizeof(ucd->cmd.cdb)); memcpy(ucd->cmd.cdb, &xs->cmd, sizeof(ucd->cmd.cdb));
if (dir == SCSI_DATA_OUT)
ucd->cmd.cdb[1] = (1 << 3); /* FUA: Force Unit Access */ ucd->cmd.cdb[1] = (1 << 3); /* FUA: Force Unit Access */
/* 7.2.1 Basic Steps when Building a UTP Transfer Request: 2g) */ /* 7.2.1 Basic Steps when Building a UTP Transfer Request: 2g) */
@ -1262,7 +1149,7 @@ ufshci_utr_cmd_write(struct ufshci_softc *sc, struct ufshci_ccb *ccb,
/* 7.2.1 Basic Steps when Building a UTP Transfer Request: 11) */ /* 7.2.1 Basic Steps when Building a UTP Transfer Request: 11) */
/* 7.2.1 Basic Steps when Building a UTP Transfer Request: 12) */ /* 7.2.1 Basic Steps when Building a UTP Transfer Request: 12) */
/* 7.2.1 Basic Steps when Building a UTP Transfer Request: 13) */ /* 7.2.1 Basic Steps when Building a UTP Transfer Request: 13) */
if (!ISSET(flags, SCSI_POLL)) { if (!ISSET(xs->flags, SCSI_POLL)) {
UFSHCI_WRITE_4(sc, UFSHCI_REG_UTRIACR, UFSHCI_WRITE_4(sc, UFSHCI_REG_UTRIACR,
UFSHCI_REG_UTRIACR_IAEN | UFSHCI_REG_UTRIACR_IAEN |
UFSHCI_REG_UTRIACR_IAPWEN | UFSHCI_REG_UTRIACR_IAPWEN |
@ -1278,7 +1165,7 @@ ufshci_utr_cmd_write(struct ufshci_softc *sc, struct ufshci_ccb *ccb,
int int
ufshci_utr_cmd_sync(struct ufshci_softc *sc, struct ufshci_ccb *ccb, ufshci_utr_cmd_sync(struct ufshci_softc *sc, struct ufshci_ccb *ccb,
int flags, uint32_t lba, uint16_t blocks) struct scsi_xfer *xs, uint32_t lba, uint16_t blocks)
{ {
int slot, off, len; int slot, off, len;
uint64_t dva; uint64_t dva;
@ -1365,7 +1252,7 @@ ufshci_utr_cmd_sync(struct ufshci_softc *sc, struct ufshci_ccb *ccb,
/* 7.2.1 Basic Steps when Building a UTP Transfer Request: 11) */ /* 7.2.1 Basic Steps when Building a UTP Transfer Request: 11) */
/* 7.2.1 Basic Steps when Building a UTP Transfer Request: 12) */ /* 7.2.1 Basic Steps when Building a UTP Transfer Request: 12) */
/* 7.2.1 Basic Steps when Building a UTP Transfer Request: 13) */ /* 7.2.1 Basic Steps when Building a UTP Transfer Request: 13) */
if (!ISSET(flags, SCSI_POLL)) { if (!ISSET(xs->flags, SCSI_POLL)) {
UFSHCI_WRITE_4(sc, UFSHCI_REG_UTRIACR, UFSHCI_WRITE_4(sc, UFSHCI_REG_UTRIACR,
UFSHCI_REG_UTRIACR_IAEN | UFSHCI_REG_UTRIACR_IAEN |
UFSHCI_REG_UTRIACR_IAPWEN | UFSHCI_REG_UTRIACR_IAPWEN |
@ -1611,7 +1498,7 @@ ufshci_scsi_inquiry(struct scsi_xfer *xs)
ccb->ccb_done = ufshci_scsi_io_done; ccb->ccb_done = ufshci_scsi_io_done;
/* Response length should be UPIU_SCSI_RSP_INQUIRY_SIZE. */ /* Response length should be UPIU_SCSI_RSP_INQUIRY_SIZE. */
ccb->ccb_slot = ufshci_utr_cmd_inquiry(sc, ccb, xs->datalen, xs->flags); ccb->ccb_slot = ufshci_utr_cmd_inquiry(sc, ccb, xs);
if (ccb->ccb_slot == -1) if (ccb->ccb_slot == -1)
goto error2; goto error2;
@ -1666,8 +1553,7 @@ ufshci_scsi_capacity16(struct scsi_xfer *xs)
ccb->ccb_done = ufshci_scsi_io_done; ccb->ccb_done = ufshci_scsi_io_done;
/* Response length should be UPIU_SCSI_RSP_CAPACITY16_SIZE. */ /* Response length should be UPIU_SCSI_RSP_CAPACITY16_SIZE. */
ccb->ccb_slot = ufshci_utr_cmd_capacity16(sc, ccb, xs->datalen, ccb->ccb_slot = ufshci_utr_cmd_capacity16(sc, ccb, xs);
xs->flags);
if (ccb->ccb_slot == -1) if (ccb->ccb_slot == -1)
goto error2; goto error2;
@ -1722,8 +1608,7 @@ ufshci_scsi_capacity(struct scsi_xfer *xs)
ccb->ccb_done = ufshci_scsi_io_done; ccb->ccb_done = ufshci_scsi_io_done;
/* Response length should be UPIU_SCSI_RSP_CAPACITY_SIZE */ /* Response length should be UPIU_SCSI_RSP_CAPACITY_SIZE */
ccb->ccb_slot = ufshci_utr_cmd_capacity(sc, ccb, xs->datalen, ccb->ccb_slot = ufshci_utr_cmd_capacity(sc, ccb, xs);
xs->flags);
if (ccb->ccb_slot == -1) if (ccb->ccb_slot == -1)
goto error2; goto error2;
@ -1766,7 +1651,7 @@ ufshci_scsi_sync(struct scsi_xfer *xs)
ccb->ccb_cookie = xs; ccb->ccb_cookie = xs;
ccb->ccb_done = ufshci_scsi_done; ccb->ccb_done = ufshci_scsi_done;
ccb->ccb_slot = ufshci_utr_cmd_sync(sc, ccb, xs->flags, (uint32_t)lba, ccb->ccb_slot = ufshci_utr_cmd_sync(sc, ccb, xs, (uint32_t)lba,
(uint16_t)blocks); (uint16_t)blocks);
if (ccb->ccb_slot == -1) if (ccb->ccb_slot == -1)
goto error; goto error;
@ -1822,13 +1707,10 @@ ufshci_scsi_io(struct scsi_xfer *xs, int dir)
ccb->ccb_cookie = xs; ccb->ccb_cookie = xs;
ccb->ccb_done = ufshci_scsi_io_done; ccb->ccb_done = ufshci_scsi_io_done;
if (dir == SCSI_DATA_IN) { if (dir == SCSI_DATA_IN)
ccb->ccb_slot = ufshci_utr_cmd_read(sc, ccb, xs->datalen, ccb->ccb_slot = ufshci_utr_cmd_io(sc, ccb, xs, SCSI_DATA_IN);
xs->flags, &xs->cmd); else
} else { ccb->ccb_slot = ufshci_utr_cmd_io(sc, ccb, xs, SCSI_DATA_OUT);
ccb->ccb_slot = ufshci_utr_cmd_write(sc, ccb, xs->datalen,
xs->flags, &xs->cmd);
}
if (ccb->ccb_slot == -1) if (ccb->ccb_slot == -1)
goto error2; goto error2;

View File

@ -985,12 +985,10 @@ static void amdgpu_dm_audio_component_unbind(struct device *kdev,
adev->dm.audio_component = NULL; adev->dm.audio_component = NULL;
} }
#ifdef notyet
static const struct component_ops amdgpu_dm_audio_component_bind_ops = { static const struct component_ops amdgpu_dm_audio_component_bind_ops = {
.bind = amdgpu_dm_audio_component_bind, .bind = amdgpu_dm_audio_component_bind,
.unbind = amdgpu_dm_audio_component_unbind, .unbind = amdgpu_dm_audio_component_unbind,
}; };
#endif
static int amdgpu_dm_audio_init(struct amdgpu_device *adev) static int amdgpu_dm_audio_init(struct amdgpu_device *adev)
{ {

View File

@ -775,6 +775,8 @@ static int devm_drm_dev_init(struct device *parent,
devm_drm_dev_init_release, dev); devm_drm_dev_init_release, dev);
} }
#endif
void *__devm_drm_dev_alloc(struct device *parent, void *__devm_drm_dev_alloc(struct device *parent,
const struct drm_driver *driver, const struct drm_driver *driver,
size_t size, size_t offset) size_t size, size_t offset)
@ -788,17 +790,21 @@ void *__devm_drm_dev_alloc(struct device *parent,
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
drm = container + offset; drm = container + offset;
#ifdef notyet
ret = devm_drm_dev_init(parent, drm, driver); ret = devm_drm_dev_init(parent, drm, driver);
if (ret) { if (ret) {
kfree(container); kfree(container);
return ERR_PTR(ret); return ERR_PTR(ret);
} }
drmm_add_final_kfree(drm, container); drmm_add_final_kfree(drm, container);
#endif
return container; return container;
} }
EXPORT_SYMBOL(__devm_drm_dev_alloc); EXPORT_SYMBOL(__devm_drm_dev_alloc);
#ifdef notyet
/** /**
* drm_dev_alloc - Allocate new DRM device * drm_dev_alloc - Allocate new DRM device
* @driver: DRM driver to allocate device for * @driver: DRM driver to allocate device for

View File

@ -0,0 +1,17 @@
/* Public Domain */
#include <drm/drm_framebuffer.h>
#include <drm/drm_fb_dma_helper.h>
#include <drm/drm_gem_dma_helper.h>
struct drm_gem_dma_object *
drm_fb_dma_get_gem_obj(struct drm_framebuffer *fb, unsigned int plane)
{
struct drm_gem_object *obj;
KASSERT(plane == 0);
obj = fb->obj[plane];
if (obj)
return to_drm_gem_dma_obj(obj);
return NULL;
}

View File

@ -1,4 +1,4 @@
/* $OpenBSD: drm_gem_dma_helper.c,v 1.1 2023/01/01 01:34:34 jsg Exp $ */ /* $OpenBSD: drm_gem_dma_helper.c,v 1.2 2024/01/06 09:33:08 kettenis Exp $ */
/* $NetBSD: drm_gem_dma_helper.c,v 1.9 2019/11/05 23:29:28 jmcneill Exp $ */ /* $NetBSD: drm_gem_dma_helper.c,v 1.9 2019/11/05 23:29:28 jmcneill Exp $ */
/*- /*-
* Copyright (c) 2015-2017 Jared McNeill <jmcneill@invisible.ca> * Copyright (c) 2015-2017 Jared McNeill <jmcneill@invisible.ca>
@ -54,6 +54,7 @@ drm_gem_dma_create_internal(struct drm_device *ddev, size_t size,
obj->base.funcs = &drm_gem_dma_default_funcs; obj->base.funcs = &drm_gem_dma_default_funcs;
if (sgt) { if (sgt) {
STUB();
#ifdef notyet #ifdef notyet
error = -drm_prime_sg_to_bus_dmamem(obj->dmat, obj->dmasegs, 1, error = -drm_prime_sg_to_bus_dmamem(obj->dmat, obj->dmasegs, 1,
&nsegs, sgt); &nsegs, sgt);
@ -89,6 +90,7 @@ drm_gem_dma_create_internal(struct drm_device *ddev, size_t size,
if (error) if (error)
goto unload; goto unload;
obj->dma_addr = obj->dmamap->dm_segs[0].ds_addr;
return obj; return obj;
unload: unload:
@ -144,16 +146,13 @@ drm_gem_dma_free_object(struct drm_gem_object *gem_obj)
} }
int int
drm_gem_dma_dumb_create(struct drm_file *file_priv, struct drm_device *ddev, drm_gem_dma_dumb_create_internal(struct drm_file *file_priv,
struct drm_mode_create_dumb *args) struct drm_device *ddev, struct drm_mode_create_dumb *args)
{ {
struct drm_gem_dma_object *obj; struct drm_gem_dma_object *obj;
uint32_t handle; uint32_t handle;
int error; int error;
args->pitch = args->width * ((args->bpp + 7) / 8);
args->size = args->pitch * args->height;
args->size = roundup(args->size, PAGE_SIZE);
args->handle = 0; args->handle = 0;
obj = drm_gem_dma_create(ddev, args->size); obj = drm_gem_dma_create(ddev, args->size);
@ -172,6 +171,17 @@ drm_gem_dma_dumb_create(struct drm_file *file_priv, struct drm_device *ddev,
return 0; return 0;
} }
int
drm_gem_dma_dumb_create(struct drm_file *file_priv, struct drm_device *ddev,
struct drm_mode_create_dumb *args)
{
args->pitch = args->width * ((args->bpp + 7) / 8);
args->size = args->pitch * args->height;
args->size = roundup(args->size, PAGE_SIZE);
return drm_gem_dma_dumb_create_internal(file_priv, ddev, args);
}
int int
drm_gem_dma_fault(struct drm_gem_object *gem_obj, struct uvm_faultinfo *ufi, drm_gem_dma_fault(struct drm_gem_object *gem_obj, struct uvm_faultinfo *ufi,
off_t offset, vaddr_t vaddr, vm_page_t *pps, int npages, int centeridx, off_t offset, vaddr_t vaddr, vm_page_t *pps, int npages, int centeridx,

View File

@ -2,6 +2,7 @@
#include <drm/drm_gem.h> #include <drm/drm_gem.h>
#include <drm/drm_framebuffer.h> #include <drm/drm_framebuffer.h>
#include <drm/drm_modeset_helper.h>
void void
drm_gem_fb_destroy(struct drm_framebuffer *fb) drm_gem_fb_destroy(struct drm_framebuffer *fb)
@ -20,3 +21,46 @@ drm_gem_fb_create_handle(struct drm_framebuffer *fb, struct drm_file *file,
{ {
return drm_gem_handle_create(file, fb->obj[0], handle); return drm_gem_handle_create(file, fb->obj[0], handle);
} }
const struct drm_framebuffer_funcs drm_gem_fb_funcs = {
.create_handle = drm_gem_fb_create_handle,
.destroy = drm_gem_fb_destroy,
};
struct drm_framebuffer *
drm_gem_fb_create(struct drm_device *dev, struct drm_file *file,
const struct drm_mode_fb_cmd2 *cmd)
{
struct drm_framebuffer *fb;
const struct drm_format_info *info;
struct drm_gem_object *gem_obj;
int error;
info = drm_get_format_info(dev, cmd);
if (!info)
return ERR_PTR(-EINVAL);
KASSERT(info->num_planes == 1);
gem_obj = drm_gem_object_lookup(file, cmd->handles[0]);
if (gem_obj == NULL)
return ERR_PTR(-ENOENT);
fb = malloc(sizeof(*fb), M_DRM, M_ZERO | M_WAITOK);
drm_helper_mode_fill_fb_struct(dev, fb, cmd);
fb->obj[0] = gem_obj;
error = drm_framebuffer_init(dev, fb, &drm_gem_fb_funcs);
if (error != 0)
goto dealloc;
return fb;
dealloc:
drm_framebuffer_cleanup(fb);
free(fb, M_DRM, sizeof(*fb));
drm_gem_object_put(gem_obj);
return ERR_PTR(error);
}

View File

@ -1,4 +1,4 @@
/* $OpenBSD: drm_linux.c,v 1.105 2023/12/23 14:18:27 kettenis Exp $ */ /* $OpenBSD: drm_linux.c,v 1.106 2024/01/06 09:33:08 kettenis Exp $ */
/* /*
* Copyright (c) 2013 Jonathan Gray <jsg@openbsd.org> * Copyright (c) 2013 Jonathan Gray <jsg@openbsd.org>
* Copyright (c) 2015, 2016 Mark Kettenis <kettenis@openbsd.org> * Copyright (c) 2015, 2016 Mark Kettenis <kettenis@openbsd.org>
@ -3182,3 +3182,634 @@ drm_firmware_drivers_only(void)
{ {
return false; return false;
} }
void *
memremap(phys_addr_t phys_addr, size_t size, int flags)
{
STUB();
return NULL;
}
void
memunmap(void *addr)
{
STUB();
}
#include <linux/platform_device.h>
bus_dma_tag_t
dma_tag_lookup(struct device *dev)
{
extern struct cfdriver drm_cd;
struct drm_device *drm;
int i;
for (i = 0; i < drm_cd.cd_ndevs; i++) {
drm = drm_cd.cd_devs[i];
if (drm && drm->dev == dev)
return drm->dmat;
}
return ((struct platform_device *)dev)->dmat;
}
LIST_HEAD(, drm_dmamem) dmamem_list = LIST_HEAD_INITIALIZER(dmamem_list);
void *
dma_alloc_coherent(struct device *dev, size_t size, dma_addr_t *dma_handle,
int gfp)
{
bus_dma_tag_t dmat = dma_tag_lookup(dev);
struct drm_dmamem *mem;
mem = drm_dmamem_alloc(dmat, size, PAGE_SIZE, 1, size,
BUS_DMA_COHERENT, 0);
if (mem == NULL)
return NULL;
*dma_handle = mem->map->dm_segs[0].ds_addr;
LIST_INSERT_HEAD(&dmamem_list, mem, next);
return mem->kva;
}
void
dma_free_coherent(struct device *dev, size_t size, void *cpu_addr,
dma_addr_t dma_handle)
{
bus_dma_tag_t dmat = dma_tag_lookup(dev);
struct drm_dmamem *mem;
LIST_FOREACH(mem, &dmamem_list, next) {
if (mem->kva == cpu_addr)
break;
}
KASSERT(mem);
KASSERT(mem->size == size);
KASSERT(mem->map->dm_segs[0].ds_addr == dma_handle);
LIST_REMOVE(mem, next);
drm_dmamem_free(dmat, mem);
}
int
dma_get_sgtable(struct device *dev, struct sg_table *sgt, void *cpu_addr,
dma_addr_t dma_addr, size_t size)
{
paddr_t pa;
int ret;
if (!pmap_extract(pmap_kernel(), (vaddr_t)cpu_addr, &pa))
return -EINVAL;
ret = sg_alloc_table(sgt, 1, GFP_KERNEL);
if (ret)
return ret;
sg_set_page(sgt->sgl, PHYS_TO_VM_PAGE(pa), size, 0);
return 0;
}
dma_addr_t
dma_map_resource(struct device *dev, phys_addr_t phys_addr, size_t size,
enum dma_data_direction dir, u_long attr)
{
bus_dma_tag_t dmat= dma_tag_lookup(dev);
bus_dmamap_t map;
bus_dma_segment_t seg;
if (bus_dmamap_create(dmat, size, 1, size, 0,
BUS_DMA_WAITOK | BUS_DMA_ALLOCNOW, &map))
return DMA_MAPPING_ERROR;
seg.ds_addr = phys_addr;
seg.ds_len = size;
if (bus_dmamap_load_raw(dmat, map, &seg, 1, size, BUS_DMA_WAITOK)) {
bus_dmamap_destroy(dmat, map);
return DMA_MAPPING_ERROR;
}
return map->dm_segs[0].ds_addr;
}
#ifdef BUS_DMA_FIXED
#include <linux/iommu.h>
size_t
iommu_map_sgtable(struct iommu_domain *domain, u_long iova,
struct sg_table *sgt, int prot)
{
bus_dma_segment_t seg;
int error;
error = bus_dmamap_create(domain->dmat, sgt->sgl->length, 1,
sgt->sgl->length, 0, BUS_DMA_WAITOK, &sgt->dmamap);
if (error)
return -ENOMEM;
sgt->dmamap->dm_segs[0].ds_addr = iova;
sgt->dmamap->dm_segs[0].ds_len = sgt->sgl->length;
sgt->dmamap->dm_nsegs = 1;
seg.ds_addr = VM_PAGE_TO_PHYS(sgt->sgl->__page);
seg.ds_len = sgt->sgl->length;
error = bus_dmamap_load_raw(domain->dmat, sgt->dmamap, &seg, 1,
sgt->sgl->length, BUS_DMA_WAITOK | BUS_DMA_FIXED);
if (error)
return -ENOMEM;
return sg_dma_len(sgt->sgl);
}
size_t
iommu_unmap(struct iommu_domain *domain, u_long iova, size_t size)
{
STUB();
return 0;
}
struct iommu_domain *
iommu_get_domain_for_dev(struct device *dev)
{
STUB();
return NULL;
}
phys_addr_t
iommu_iova_to_phys(struct iommu_domain *domain, dma_addr_t iova)
{
STUB();
return 0;
}
struct iommu_domain *
iommu_domain_alloc(struct bus_type *type)
{
return malloc(sizeof(struct iommu_domain), M_DEVBUF, M_WAITOK | M_ZERO);
}
int
iommu_attach_device(struct iommu_domain *domain, struct device *dev)
{
struct platform_device *pdev = (struct platform_device *)dev;
domain->dmat = pdev->dmat;
return 0;
}
#endif
#include <linux/component.h>
struct component_match {
struct device *dev;
};
int
component_compare_of(struct device *dev, void *data)
{
STUB();
return 0;
}
void
drm_of_component_match_add(struct device *master,
struct component_match **matchptr,
int (*compare)(struct device *, void *),
struct device_node *np)
{
struct component_match *match;
if (*matchptr == NULL) {
match = malloc(sizeof(struct component_match),
M_DEVBUF, M_WAITOK | M_ZERO);
match->dev = master;
*matchptr = match;
}
}
int
component_master_add_with_match(struct device *dev,
const struct component_master_ops *ops, struct component_match *match)
{
ops->bind(match->dev);
return 0;
}
#ifdef __HAVE_FDT
#include <linux/platform_device.h>
#include <dev/ofw/openfirm.h>
#include <dev/ofw/fdt.h>
#include <machine/fdt.h>
LIST_HEAD(, platform_device) pdev_list = LIST_HEAD_INITIALIZER(pdev_list);
void
platform_device_register(struct platform_device *pdev)
{
pdev->num_resources = pdev->faa->fa_nreg;
pdev->parent = pdev->dev.dv_parent;
pdev->node = pdev->faa->fa_node;
pdev->dmat = pdev->faa->fa_dmat;
LIST_INSERT_HEAD(&pdev_list, pdev, next);
}
struct resource *
platform_get_resource(struct platform_device *pdev, u_int type, u_int num)
{
struct fdt_attach_args *faa = pdev->faa;
if (pdev->resource == NULL) {
pdev->resource = mallocarray(pdev->num_resources,
sizeof(*pdev->resource), M_DEVBUF, M_WAITOK | M_ZERO);
}
pdev->resource[num].start = faa->fa_reg[num].addr;
pdev->resource[num].end = faa->fa_reg[num].addr +
faa->fa_reg[num].size - 1;
return &pdev->resource[num];
}
void __iomem *
devm_platform_ioremap_resource_byname(struct platform_device *pdev,
const char *name)
{
struct fdt_attach_args *faa = pdev->faa;
bus_space_handle_t ioh;
int err, idx;
idx = OF_getindex(faa->fa_node, name, "reg-names");
if (idx == -1 || idx >= faa->fa_nreg)
return ERR_PTR(-EINVAL);
err = bus_space_map(faa->fa_iot, faa->fa_reg[idx].addr,
faa->fa_reg[idx].size, BUS_SPACE_MAP_LINEAR, &ioh);
if (err)
return ERR_PTR(-err);
return bus_space_vaddr(faa->fa_iot, ioh);
}
#include <dev/ofw/ofw_clock.h>
#include <linux/clk.h>
struct clk *
devm_clk_get(struct device *dev, const char *name)
{
struct platform_device *pdev = (struct platform_device *)dev;
struct clk *clk;
clk = malloc(sizeof(*clk), M_DEVBUF, M_WAITOK);
clk->freq = clock_get_frequency(pdev->node, name);
return clk;
}
u_long
clk_get_rate(struct clk *clk)
{
return clk->freq;
}
#include <linux/gpio/consumer.h>
#include <dev/ofw/ofw_gpio.h>
struct gpio_desc {
uint32_t gpios[4];
};
struct gpio_desc *
devm_gpiod_get_optional(struct device *dev, const char *name, int flags)
{
struct platform_device *pdev = (struct platform_device *)dev;
struct gpio_desc *desc;
char fullname[128];
int len;
snprintf(fullname, sizeof(fullname), "%s-gpios", name);
desc = malloc(sizeof(*desc), M_DEVBUF, M_WAITOK | M_ZERO);
len = OF_getpropintarray(pdev->node, fullname, desc->gpios,
sizeof(desc->gpios));
KASSERT(len <= sizeof(desc->gpios));
if (len < 0) {
free(desc, M_DEVBUF, sizeof(*desc));
return NULL;
}
switch (flags) {
case GPIOD_IN:
gpio_controller_config_pin(desc->gpios, GPIO_CONFIG_INPUT);
break;
case GPIOD_OUT_HIGH:
gpio_controller_config_pin(desc->gpios, GPIO_CONFIG_OUTPUT);
gpio_controller_set_pin(desc->gpios, 1);
break;
default:
panic("%s: unimplemented flags 0x%x", __func__, flags);
}
return desc;
}
int
gpiod_get_value_cansleep(const struct gpio_desc *desc)
{
return gpio_controller_get_pin(((struct gpio_desc *)desc)->gpios);
}
struct phy {
int node;
const char *name;
};
struct phy *
devm_phy_optional_get(struct device *dev, const char *name)
{
struct platform_device *pdev = (struct platform_device *)dev;
struct phy *phy;
int idx;
idx = OF_getindex(pdev->node, name, "phy-names");
if (idx == -1)
return NULL;
phy = malloc(sizeof(*phy), M_DEVBUF, M_WAITOK);
phy->node = pdev->node;
phy->name = name;
return phy;
}
struct bus_type platform_bus_type;
#include <dev/ofw/ofw_misc.h>
#include <linux/of.h>
#include <linux/platform_device.h>
struct device_node *
__of_devnode(void *arg)
{
struct device *dev = container_of(arg, struct device, of_node);
struct platform_device *pdev = (struct platform_device *)dev;
return (struct device_node *)(uintptr_t)pdev->node;
}
int
__of_device_is_compatible(struct device_node *np, const char *compatible)
{
return OF_is_compatible((uintptr_t)np, compatible);
}
int
__of_property_present(struct device_node *np, const char *propname)
{
return OF_getpropbool((uintptr_t)np, (char *)propname);
}
int
__of_property_read_variable_u32_array(struct device_node *np,
const char *propname, uint32_t *out_values, size_t sz_min, size_t sz_max)
{
int len;
len = OF_getpropintarray((uintptr_t)np, (char *)propname, out_values,
sz_max * sizeof(*out_values));
if (len < 0)
return -EINVAL;
if (len == 0)
return -ENODATA;
if (len < sz_min * sizeof(*out_values) ||
len > sz_max * sizeof(*out_values))
return -EOVERFLOW;
if (sz_min == 1 && sz_max == 1)
return 0;
return len / sizeof(*out_values);
}
int
__of_property_read_variable_u64_array(struct device_node *np,
const char *propname, uint64_t *out_values, size_t sz_min, size_t sz_max)
{
int len;
len = OF_getpropint64array((uintptr_t)np, (char *)propname, out_values,
sz_max * sizeof(*out_values));
if (len < 0)
return -EINVAL;
if (len == 0)
return -ENODATA;
if (len < sz_min * sizeof(*out_values) ||
len > sz_max * sizeof(*out_values))
return -EOVERFLOW;
if (sz_min == 1 && sz_max == 1)
return 0;
return len / sizeof(*out_values);
}
int
__of_property_match_string(struct device_node *np,
const char *propname, const char *str)
{
int idx;
idx = OF_getindex((uintptr_t)np, str, propname);
if (idx == -1)
return -ENODATA;
return idx;
}
struct device_node *
__of_parse_phandle(struct device_node *np, const char *propname, int idx)
{
uint32_t phandles[16] = {};
int len, node;
len = OF_getpropintarray((uintptr_t)np, (char *)propname, phandles,
sizeof(phandles));
if (len < (idx + 1) * sizeof(uint32_t))
return NULL;
node = OF_getnodebyphandle(phandles[idx]);
if (node == 0)
return NULL;
return (struct device_node *)(uintptr_t)node;
}
int
__of_parse_phandle_with_args(struct device_node *np, const char *propname,
const char *cellsname, int idx, struct of_phandle_args *args)
{
uint32_t phandles[16] = {};
int i, len, node;
len = OF_getpropintarray((uintptr_t)np, (char *)propname, phandles,
sizeof(phandles));
if (len < (idx + 1) * sizeof(uint32_t))
return -ENOENT;
node = OF_getnodebyphandle(phandles[idx]);
if (node == 0)
return -ENOENT;
args->np = (struct device_node *)(uintptr_t)node;
args->args_count = OF_getpropint(node, (char *)cellsname, 0);
for (i = 0; i < args->args_count; i++)
args->args[i] = phandles[i + 1];
return 0;
}
int
of_address_to_resource(struct device_node *np, int idx, struct resource *res)
{
uint64_t reg[16] = {};
int len;
KASSERT(idx < 8);
len = OF_getpropint64array((uintptr_t)np, "reg", reg, sizeof(reg));
if (len < 0 || idx >= (len / (2 * sizeof(uint64_t))))
return -EINVAL;
res->start = reg[2 * idx];
res->end = reg[2 * idx] + reg[2 * idx + 1] - 1;
return 0;
}
static int
next_node(int node)
{
int peer = OF_peer(node);
while (node && !peer) {
node = OF_parent(node);
if (node)
peer = OF_peer(node);
}
return peer;
}
static int
find_matching_node(int node, const struct of_device_id *id)
{
int child, match;
int i;
for (child = OF_child(node); child; child = OF_peer(child)) {
match = find_matching_node(child, id);
if (match)
return match;
}
for (i = 0; id[i].compatible; i++) {
if (OF_is_compatible(node, id[i].compatible))
return node;
}
return 0;
}
struct device_node *
__matching_node(struct device_node *np, const struct of_device_id *id)
{
int node = OF_peer(0);
int match;
if (np)
node = next_node((uintptr_t)np);
while (node) {
match = find_matching_node(node, id);
if (match)
return (struct device_node *)(uintptr_t)match;
node = next_node(node);
}
return NULL;
}
struct platform_device *
of_platform_device_create(struct device_node *np, const char *bus_id,
struct device *parent)
{
struct platform_device *pdev;
pdev = malloc(sizeof(*pdev), M_DEVBUF, M_WAITOK | M_ZERO);
pdev->node = (intptr_t)np;
pdev->parent = parent;
LIST_INSERT_HEAD(&pdev_list, pdev, next);
return pdev;
}
struct platform_device *
of_find_device_by_node(struct device_node *np)
{
struct platform_device *pdev;
LIST_FOREACH(pdev, &pdev_list, next) {
if (pdev->node == (intptr_t)np)
return pdev;
}
return NULL;
}
int
of_device_is_available(struct device_node *np)
{
char status[32];
if (OF_getprop((uintptr_t)np, "status", status, sizeof(status)) > 0 &&
strcmp(status, "disabled") == 0)
return 0;
return 1;
}
int
of_dma_configure(struct device *dev, struct device_node *np, int force_dma)
{
struct platform_device *pdev = (struct platform_device *)dev;
bus_dma_tag_t dmat = dma_tag_lookup(pdev->parent);
pdev->dmat = iommu_device_map(pdev->node, dmat);
return 0;
}
struct device_node *
__of_get_compatible_child(void *p, const char *compat)
{
struct device *dev = container_of(p, struct device, of_node);
struct platform_device *pdev = (struct platform_device *)dev;
int child;
for (child = OF_child(pdev->node); child; child = OF_peer(child)) {
if (OF_is_compatible(child, compat))
return (struct device_node *)(uintptr_t)child;
}
return NULL;
}
struct device_node *
__of_get_child_by_name(void *p, const char *name)
{
struct device *dev = container_of(p, struct device, of_node);
struct platform_device *pdev = (struct platform_device *)dev;
int child;
child = OF_getnodebyname(pdev->node, name);
if (child == 0)
return NULL;
return (struct device_node *)(uintptr_t)child;
}
#endif

View File

@ -0,0 +1,13 @@
/* Public Domain */
#ifndef _DRM_DRM_FB_DMA_HELPER_H
#define _DRM_DRM_FB_DMA_HELPER_H
#include <linux/types.h>
struct drm_framebuffer;
struct drm_gem_dma_object *drm_fb_dma_get_gem_obj(struct drm_framebuffer *,
unsigned int);
#endif

View File

@ -0,0 +1,15 @@
/* SPDX-License-Identifier: MIT */
#ifndef DRM_FBDEV_GENERIC_H
#define DRM_FBDEV_GENERIC_H
struct drm_device;
#ifdef CONFIG_DRM_FBDEV_EMULATION
void drm_fbdev_generic_setup(struct drm_device *dev, unsigned int preferred_bpp);
#else
static inline void drm_fbdev_generic_setup(struct drm_device *dev, unsigned int preferred_bpp)
{ }
#endif
#endif

View File

@ -1,10 +1,15 @@
/* Public Domain */ /* Public Domain */
#ifndef _DRM_DRM_GEM_DMA_HELPER_H
#define _DRM_DRM_GEM_DMA_HELPER_H
#include <drm/drm_gem.h> #include <drm/drm_gem.h>
void drm_gem_dma_free_object(struct drm_gem_object *); void drm_gem_dma_free_object(struct drm_gem_object *);
int drm_gem_dma_dumb_create(struct drm_file *, struct drm_device *, int drm_gem_dma_dumb_create(struct drm_file *, struct drm_device *,
struct drm_mode_create_dumb *); struct drm_mode_create_dumb *);
int drm_gem_dma_dumb_create_internal(struct drm_file *, struct drm_device *,
struct drm_mode_create_dumb *);
int drm_gem_dma_dumb_map_offset(struct drm_file *, struct drm_device *, int drm_gem_dma_dumb_map_offset(struct drm_file *, struct drm_device *,
uint32_t, uint64_t *); uint32_t, uint64_t *);
struct drm_gem_dma_object *drm_gem_dma_create(struct drm_device *, struct drm_gem_dma_object *drm_gem_dma_create(struct drm_device *,
@ -23,8 +28,17 @@ struct drm_gem_dma_object {
bus_dmamap_t dmamap; bus_dmamap_t dmamap;
bus_dma_segment_t dmasegs[1]; bus_dma_segment_t dmasegs[1];
size_t dmasize; size_t dmasize;
dma_addr_t dma_addr;
caddr_t vaddr; caddr_t vaddr;
struct sg_table *sgt; struct sg_table *sgt;
}; };
#define to_drm_gem_dma_obj(gem_obj) container_of(gem_obj, struct drm_gem_dma_object, base) #define to_drm_gem_dma_obj(gem_obj) container_of(gem_obj, struct drm_gem_dma_object, base)
#define DEFINE_DRM_GEM_DMA_FOPS(name) struct file_operations name = {};
#define DRM_GEM_DMA_DRIVER_OPS_WITH_DUMB_CREATE(x) \
.dumb_create = (x), \
.gem_fault = drm_gem_dma_fault
#endif

View File

@ -6,6 +6,8 @@
struct drm_framebuffer; struct drm_framebuffer;
struct drm_file; struct drm_file;
struct drm_framebuffer *drm_gem_fb_create(struct drm_device *,
struct drm_file *, const struct drm_mode_fb_cmd2 *);
void drm_gem_fb_destroy(struct drm_framebuffer *); void drm_gem_fb_destroy(struct drm_framebuffer *);
int drm_gem_fb_create_handle(struct drm_framebuffer *, struct drm_file *, int drm_gem_fb_create_handle(struct drm_framebuffer *, struct drm_file *,
unsigned int *); unsigned int *);

View File

@ -100,6 +100,7 @@ struct drm_dmamem {
bus_size_t size; bus_size_t size;
int nsegs; int nsegs;
bus_dma_segment_t segs[1]; bus_dma_segment_t segs[1];
LIST_ENTRY(drm_dmamem) next;
}; };
typedef struct drm_dma_handle { typedef struct drm_dma_handle {

View File

@ -1 +1,11 @@
/* Public domain. */ /* Public domain. */
#ifndef _DRM_DRM_OF_H
#define _DRM_DRM_OF_H
struct component_match;
void drm_of_component_match_add(struct device *, struct component_match **,
int (*)(struct device *, void *), struct device_node *);
#endif

View File

@ -0,0 +1,17 @@
/* Public domain. */
#ifndef _DRM_DRM_SIMPLE_KMS_HELPER_H
#define _DRM_DRM_SIMPLE_KMS_HELPER_H
static inline void *
__drmm_simple_encoder_alloc(struct drm_device *dev, size_t size,
size_t offset, int type)
{
return __drmm_encoder_alloc(dev, size, offset, NULL, type, NULL);
}
#define drmm_simple_encoder_alloc(dev, type, member, encoder_type) \
((type *) __drmm_simple_encoder_alloc(dev, sizeof(type), \
offsetof(type, member), encoder_type))
#endif

View File

@ -0,0 +1,11 @@
/* Public domain. */
#ifndef _LINUX_ALIGN_H
#define _LINUX_ALIGN_H
#include <sys/param.h>
#undef ALIGN
#define ALIGN(x, y) roundup2((x), (y))
#endif

View File

@ -1,4 +1,4 @@
/* $OpenBSD: atomic.h,v 1.20 2023/01/01 01:34:58 jsg Exp $ */ /* $OpenBSD: atomic.h,v 1.22 2024/01/06 12:52:20 jsg Exp $ */
/** /**
* \file drm_atomic.h * \file drm_atomic.h
* Atomic operations used in the DRM which may or may not be provided by the OS. * Atomic operations used in the DRM which may or may not be provided by the OS.
@ -423,6 +423,9 @@ find_next_bit(const volatile void *p, int max, int b)
#define rmb() __membar("dsb ld") #define rmb() __membar("dsb ld")
#define wmb() __membar("dsb st") #define wmb() __membar("dsb st")
#define mb() __membar("dsb sy") #define mb() __membar("dsb sy")
#define dma_rmb() __membar("dmb oshld")
#define dma_wmb() __membar("dmb oshst")
#define dma_mb() __membar("dmb osh")
#elif defined(__arm__) #elif defined(__arm__)
#define rmb() __membar("dsb sy") #define rmb() __membar("dsb sy")
#define wmb() __membar("dsb sy") #define wmb() __membar("dsb sy")

View File

@ -1,4 +1,4 @@
/* $OpenBSD: bitmap.h,v 1.5 2023/01/01 01:34:58 jsg Exp $ */ /* $OpenBSD: bitmap.h,v 1.6 2024/01/06 09:33:08 kettenis Exp $ */
/* /*
* Copyright (c) 2013, 2014, 2015 Mark Kettenis * Copyright (c) 2013, 2014, 2015 Mark Kettenis
* *
@ -18,6 +18,7 @@
#ifndef _LINUX_BITMAP_H #ifndef _LINUX_BITMAP_H
#define _LINUX_BITMAP_H #define _LINUX_BITMAP_H
#include <linux/align.h>
#include <linux/bitops.h> #include <linux/bitops.h>
#include <linux/string.h> #include <linux/string.h>
@ -140,6 +141,26 @@ bitmap_weight(const void *p, u_int n)
return sum; return sum;
} }
static inline int
bitmap_find_free_region(void *p, u_int n, int o)
{
int b;
KASSERT(o == 0);
b = find_first_zero_bit(p, n);
if (b == n)
return -ENOMEM;
__set_bit(b, p);
return b;
}
static inline void
bitmap_release_region(void *p, u_int b, int o)
{
KASSERT(o == 0);
__clear_bit(b, p);
}
void *bitmap_zalloc(u_int, gfp_t); void *bitmap_zalloc(u_int, gfp_t);
void bitmap_free(void *); void bitmap_free(void *);

View File

@ -0,0 +1,14 @@
/* Public domain. */
#ifndef _LINUX_CLK_H
#define _LINUX_CLK_H
struct clk {
uint32_t freq;
};
unsigned long clk_get_rate(struct clk *);
struct clk *devm_clk_get(struct device *, const char *);
#define devm_clk_put(a, b)
#endif

View File

@ -1,4 +1,4 @@
/* $OpenBSD: completion.h,v 1.9 2020/06/22 14:19:35 jsg Exp $ */ /* $OpenBSD: completion.h,v 1.10 2024/01/06 09:33:08 kettenis Exp $ */
/* /*
* Copyright (c) 2015, 2018 Mark Kettenis * Copyright (c) 2015, 2018 Mark Kettenis
* *
@ -28,6 +28,9 @@ struct completion {
struct mutex lock; struct mutex lock;
}; };
#define DECLARE_COMPLETION_ONSTACK(name) \
struct completion name = { 0, MUTEX_INITIALIZER(IPL_TTY) }
static inline void static inline void
init_completion(struct completion *x) init_completion(struct completion *x)
{ {

View File

@ -3,7 +3,34 @@
#ifndef _LINUX_COMPONENT_H #ifndef _LINUX_COMPONENT_H
#define _LINUX_COMPONENT_H #define _LINUX_COMPONENT_H
#include <sys/_null.h>
struct component_match;
struct device;
struct component_ops {
int (*bind)(struct device *, struct device *, void *);
void (*unbind)(struct device *, struct device *, void *);
};
struct component_master_ops {
int (*bind)(struct device *);
void (*unbind)(struct device *);
};
#define component_del(a, b) #define component_del(a, b)
#define component_add(a, b) 0 #define component_add(a, b) 0
static inline int
component_bind_all(struct device *dev, void *data)
{
return 0;
}
#define component_unbind_all(a, b)
int component_compare_of(struct device *, void *);
int component_master_add_with_match(struct device *,
const struct component_master_ops *, struct component_match *);
#endif #endif

View File

@ -126,4 +126,9 @@ dev_driver_string(struct device *dev)
/* should be bus id as string, ie 0000:00:02.0 */ /* should be bus id as string, ie 0000:00:02.0 */
#define dev_name(dev) "" #define dev_name(dev) ""
static inline void
device_set_wakeup_path(struct device *dev)
{
}
#endif #endif

View File

@ -11,6 +11,8 @@ struct device;
#define DMA_BIT_MASK(n) (((n) == 64) ? ~0ULL : (1ULL<<(n)) -1) #define DMA_BIT_MASK(n) (((n) == 64) ? ~0ULL : (1ULL<<(n)) -1)
#define DMA_MAPPING_ERROR (dma_addr_t)-1
static inline int static inline int
dma_set_coherent_mask(struct device *dev, uint64_t m) dma_set_coherent_mask(struct device *dev, uint64_t m)
{ {
@ -60,4 +62,23 @@ dma_mapping_error(void *dev, dma_addr_t addr)
return 0; return 0;
} }
void *dma_alloc_coherent(struct device *, size_t, dma_addr_t *, int);
void dma_free_coherent(struct device *, size_t, void *, dma_addr_t);
static inline void *
dmam_alloc_coherent(struct device *dev, size_t size, dma_addr_t *dva, int gfp)
{
return dma_alloc_coherent(dev, size, dva, gfp);
}
int dma_get_sgtable(struct device *, struct sg_table *, void *,
dma_addr_t, size_t);
int dma_map_sgtable(struct device *, struct sg_table *,
enum dma_data_direction, u_long);
void dma_unmap_sgtable(struct device *, struct sg_table *,
enum dma_data_direction, u_long);
dma_addr_t dma_map_resource(struct device *, phys_addr_t, size_t,
enum dma_data_direction, u_long);
#endif #endif

View File

@ -19,4 +19,7 @@
struct address_space; struct address_space;
struct seq_file; struct seq_file;
struct file_operations {
};
#endif #endif

View File

@ -0,0 +1,21 @@
/* Public domain. */
#ifndef _LINUX_GPIO_CONSUMER_H
#define _LINUX_GPIO_CONSUMER_H
struct device;
struct gpio_desc;
#define GPIOD_IN 0x0001
#define GPIOD_OUT_HIGH 0x0002
struct gpio_desc *devm_gpiod_get_optional(struct device *, const char *, int);
int gpiod_get_value_cansleep(const struct gpio_desc *);
static inline int
gpiod_to_irq(const struct gpio_desc *desc)
{
return 42;
}
#endif

View File

@ -13,7 +13,12 @@
struct seq_file; struct seq_file;
#define IRQF_SHARED 0 #define IRQF_SHARED 0x0001
#define IRQF_ONESHOT 0x0002
#define IRQF_NO_AUTOEN 0x0004
#define IRQF_TRIGGER_RISING 0x1000
#define IRQF_TRIGGER_FALLING 0x2000
#define request_irq(irq, hdlr, flags, name, dev) (0) #define request_irq(irq, hdlr, flags, name, dev) (0)
@ -22,8 +27,25 @@ free_irq(unsigned int irq, void *dev)
{ {
} }
static inline void
disable_irq(u_int irq)
{
}
static inline void
enable_irq(u_int irq)
{
}
typedef irqreturn_t (*irq_handler_t)(int, void *); typedef irqreturn_t (*irq_handler_t)(int, void *);
static inline int
devm_request_threaded_irq(struct device *dev, u_int irq, irq_handler_t handler,
irq_handler_t thread_fn, u_int irqflags, const char *devname, void *arg)
{
return 0;
}
struct tasklet_struct { struct tasklet_struct {
union { union {
void (*func)(unsigned long); void (*func)(unsigned long);

View File

@ -183,4 +183,9 @@ IOMEM_ERR_PTR(long error)
return (void *) error; return (void *) error;
} }
#define MEMREMAP_WB (1 << 0)
void *memremap(phys_addr_t, size_t, int);
void memunmap(void *);
#endif #endif

View File

@ -0,0 +1,29 @@
/* Public domain. */
#ifndef _LINUX_IOMMU_H
#define _LINUX_IOMMU_H
struct bus_type;
struct sg_table;
struct iommu_domain {
bus_dma_tag_t dmat;
};
#define IOMMU_READ 0x0001
#define IOMMU_WRITE 0x0002
size_t iommu_map_sgtable(struct iommu_domain *, u_long,
struct sg_table *, int);
size_t iommu_unmap(struct iommu_domain *, u_long, size_t);
struct iommu_domain *iommu_get_domain_for_dev(struct device *);
phys_addr_t iommu_iova_to_phys(struct iommu_domain *, dma_addr_t);
struct iommu_domain *iommu_domain_alloc(struct bus_type *);
#define iommu_domain_free(a)
int iommu_attach_device(struct iommu_domain *, struct device *);
#define iommu_detach_device(a, b)
#endif

View File

@ -0,0 +1,20 @@
/* Public domain. */
#ifndef _LINUX_MUX_CONSUMER_H
#define _LINUX_MUX_CONSUMER_H
struct mux_control;
static inline struct mux_control *
devm_mux_control_get(struct device *dev, const char *name)
{
return NULL;
}
static inline int
mux_control_select(struct mux_control *mux, u_int state)
{
return 0;
}
#endif

View File

@ -12,4 +12,76 @@ of_machine_is_compatible(const char *model)
} }
#endif #endif
struct device_node {
const char *full_name;
};
#define of_node dv_cfdata
struct device_node *__of_get_compatible_child(void *, const char *);
#define of_get_compatible_child(d, n) \
__of_get_compatible_child(&(d), (n))
struct device_node *__of_get_child_by_name(void *, const char *);
#define of_get_child_by_name(d, n) \
__of_get_child_by_name(&(d), (n))
#define of_node_put(p)
struct device_node *__of_devnode(void *);
#define __of_node(arg) \
__builtin_types_compatible_p(typeof(arg), struct device_node *) ? \
(struct device_node *)arg : __of_devnode(&arg)
int __of_property_present(struct device_node *, const char *);
#define of_property_present(n, p) \
__of_property_present(__of_node(n), (p))
int __of_property_read_variable_u32_array(struct device_node *,
const char *, uint32_t *, size_t, size_t);
#define of_property_read_u32(n, p, o) \
__of_property_read_variable_u32_array(__of_node(n), (p), (o), 1, 1)
#define of_property_read_variable_u32_array(n, p, o, l, h) \
__of_property_read_variable_u32_array(__of_node(n), (p), (o), (l), (h))
int __of_property_read_variable_u64_array(struct device_node *,
const char *, uint64_t *, size_t, size_t);
#define of_property_read_u64(n, p, o) \
__of_property_read_variable_u64_array(__of_node(n), (p), (o), 1, 1)
int __of_property_match_string(struct device_node *,
const char *, const char *);
#define of_property_match_string(n, a, b) \
__of_property_match_string(__of_node(n), (a), (b))
struct device_node *__of_parse_phandle(struct device_node *,
const char *, int);
#define of_parse_phandle(n, a, b) \
__of_parse_phandle(__of_node(n), (a), (b))
struct of_phandle_args {
struct device_node *np;
int args_count;
uint32_t args[5];
};
int __of_parse_phandle_with_args(struct device_node *,
const char *, const char *, int, struct of_phandle_args *);
#define of_parse_phandle_with_args(n, a, b, c, d) \
__of_parse_phandle_with_args(__of_node(n), (a), (b), (c), (d))
int of_device_is_available(struct device_node *);
struct of_device_id {
const char *compatible;
const void *data;
};
struct device_node *__matching_node(struct device_node *,
const struct of_device_id *);
#define for_each_matching_node(a, b) \
for (a = __matching_node(NULL, b); a; a = __matching_node(a, b))
static const void *of_device_get_match_data(const struct device *);
#endif #endif

View File

@ -0,0 +1,11 @@
/* Public domain. */
#ifndef _LINUX_OF_ADDRESS_H
#define _LINUX_OF_ADDRESS_H
struct device_node;
struct resource;
int of_address_to_resource(struct device_node *, int, struct resource *);
#endif

View File

@ -0,0 +1,8 @@
#include <linux/of.h>
#include <linux/of_platform.h>
int __of_device_is_compatible(struct device_node *, const char *);
#define of_device_is_compatible(n, c) \
__of_device_is_compatible(__of_node(n), (c))
int of_dma_configure(struct device *, struct device_node *, int);

View File

@ -0,0 +1,12 @@
/* Public domain. */
#ifndef _LINUX_OF_PLATFORM_H
#define _LINUX_OF_PLATFORM_H
struct platform_device *of_platform_device_create(struct device_node *,
const char *, struct device *);
struct platform_device *of_find_device_by_node(struct device_node *);
#define of_platform_device_destroy(a, b)
#endif

View File

@ -0,0 +1,39 @@
/* Public domain. */
#ifndef _LINUX_PHY_PHY_H
#define _LINUX_PHY_PHY_H
struct phy_configure_opts_dp {
u_int link_rate;
u_int lanes;
int set_rate : 1;
int set_lanes : 1;
int set_voltages : 1;
};
union phy_configure_opts {
struct phy_configure_opts_dp dp;
};
enum phy_mode {
PHY_MODE_INVALID,
PHY_MODE_DP,
};
struct phy;
struct phy *devm_phy_optional_get(struct device *, const char *);
static inline int
phy_configure(struct phy *phy, union phy_configure_opts *opts)
{
return 0;
}
static inline int
phy_set_mode_ext(struct phy *phy, enum phy_mode mode, int submode)
{
return 0;
}
#endif

View File

@ -0,0 +1,53 @@
/* Public domain. */
#ifndef _LINUX_PLATFORM_DEVICE_H
#define _LINUX_PLATFORM_DEVICE_H
#include <linux/device.h>
struct platform_driver;
struct platform_device {
struct device dev;
int num_resources;
struct resource *resource;
struct device *parent;
bus_dma_tag_t dmat;
int node;
#ifdef __HAVE_FDT
struct fdt_attach_args *faa;
#endif
LIST_ENTRY(platform_device) next;
};
#define to_platform_device(p) (struct platform_device *)(p)
extern struct bus_type platform_bus_type;
void __iomem *
devm_platform_ioremap_resource_byname(struct platform_device *, const char *);
inline void
platform_set_drvdata(struct platform_device *pdev, void *data)
{
dev_set_drvdata(&pdev->dev, data);
}
inline void *
platform_get_drvdata(struct platform_device *pdev)
{
return dev_get_drvdata(&pdev->dev);
}
inline int
platform_driver_register(struct platform_driver *platform_drv)
{
return 0;
}
void platform_device_register(struct platform_device *);
struct resource *platform_get_resource(struct platform_device *, u_int, u_int);
#endif

View File

@ -5,6 +5,16 @@
#include <linux/completion.h> #include <linux/completion.h>
struct dev_pm_ops {
int (*suspend)(struct device *);
int (*resume)(struct device *);
};
#define DEFINE_SIMPLE_DEV_PM_OPS(name, suspend_fn, resume_fn) \
const struct dev_pm_ops name = { \
.suspend = suspend_fn, .resume = resume_fn \
}
struct dev_pm_domain { struct dev_pm_domain {
}; };

View File

@ -1,4 +1,4 @@
/* $OpenBSD: scatterlist.h,v 1.6 2023/08/02 11:03:17 jsg Exp $ */ /* $OpenBSD: scatterlist.h,v 1.7 2024/01/06 09:33:08 kettenis Exp $ */
/* /*
* Copyright (c) 2013, 2014, 2015 Mark Kettenis * Copyright (c) 2013, 2014, 2015 Mark Kettenis
* *
@ -37,6 +37,7 @@ struct sg_table {
struct scatterlist *sgl; struct scatterlist *sgl;
unsigned int nents; unsigned int nents;
unsigned int orig_nents; unsigned int orig_nents;
bus_dmamap_t dmamap;
}; };
struct sg_page_iter { struct sg_page_iter {

View File

@ -1,4 +1,4 @@
/* $OpenBSD: time.h,v 1.4 2020/08/03 07:02:08 jsg Exp $ */ /* $OpenBSD: time.h,v 1.5 2024/01/06 09:33:08 kettenis Exp $ */
/* /*
* Copyright (c) 2013, 2014, 2015 Mark Kettenis * Copyright (c) 2013, 2014, 2015 Mark Kettenis
* *
@ -29,6 +29,8 @@
#define USEC_PER_MSEC 1000L #define USEC_PER_MSEC 1000L
#define USEC_PER_SEC 1000000L #define USEC_PER_SEC 1000000L
#define MSEC_PER_SEC 1000L
struct timespec64 { struct timespec64 {
time_t tv_sec; time_t tv_sec;
long tv_nsec; long tv_nsec;

View File

@ -1,4 +1,4 @@
/* $OpenBSD: workqueue.h,v 1.10 2023/03/21 09:44:35 jsg Exp $ */ /* $OpenBSD: workqueue.h,v 1.11 2024/01/06 09:33:08 kettenis Exp $ */
/* /*
* Copyright (c) 2015 Mark Kettenis * Copyright (c) 2015 Mark Kettenis
* *
@ -35,9 +35,10 @@ extern struct workqueue_struct *system_highpri_wq;
extern struct workqueue_struct *system_unbound_wq; extern struct workqueue_struct *system_unbound_wq;
extern struct workqueue_struct *system_long_wq; extern struct workqueue_struct *system_long_wq;
#define WQ_HIGHPRI 1 #define WQ_HIGHPRI (1 << 1)
#define WQ_FREEZABLE 2 #define WQ_FREEZABLE (1 << 2)
#define WQ_UNBOUND 4 #define WQ_UNBOUND (1 << 3)
#define WQ_MEM_RECLAIM (1 << 4)
#define WQ_UNBOUND_MAX_ACTIVE 4 /* matches nthreads in drm_linux.c */ #define WQ_UNBOUND_MAX_ACTIVE 4 /* matches nthreads in drm_linux.c */
@ -49,7 +50,7 @@ alloc_workqueue(const char *name, int flags, int max_active)
} }
static inline struct workqueue_struct * static inline struct workqueue_struct *
alloc_ordered_workqueue(const char *name, int flags) alloc_ordered_workqueue(const char *name, int flags, ...)
{ {
struct taskq *tq = taskq_create(name, 1, IPL_TTY, 0); struct taskq *tq = taskq_create(name, 1, IPL_TTY, 0);
return (struct workqueue_struct *)tq; return (struct workqueue_struct *)tq;

View File

@ -0,0 +1,43 @@
/* Public domain. */
#ifndef _SOUND_PCM_H
#define _SOUND_PCM_H
#define SNDRV_CHMAP_UNKNOWN 0
#define SNDRV_CHMAP_FL 1
#define SNDRV_CHMAP_FR 2
#define SNDRV_CHMAP_RL 3
#define SNDRV_CHMAP_RR 4
#define SNDRV_CHMAP_FC 5
#define SNDRV_CHMAP_LFE 6
#define SNDRV_CHMAP_RC 7
#define SNDRV_CHMAP_FLC 8
#define SNDRV_CHMAP_FRC 9
#define SNDRV_CHMAP_RLC 10
#define SNDRV_CHMAP_RRC 11
#define SNDRV_CHMAP_FLW 12
#define SNDRV_CHMAP_FRW 13
#define SNDRV_CHMAP_FLH 14
#define SNDRV_CHMAP_FCH 15
#define SNDRV_CHMAP_FRH 16
#define SNDRV_CHMAP_TC 17
#define SNDRV_PCM_RATE_KNOT -1
#define SNDRV_PCM_FMTBIT_S16 0x0001
#define SNDRV_PCM_FMTBIT_S20 0x0002
#define SNDRV_PCM_FMTBIT_S24 0x0004
#define SNDRV_PCM_FMTBIT_S32 0x0008
struct snd_pcm_chmap_elem {
u_char channels;
u_char map[15];
};
static inline int
snd_pcm_rate_to_rate_bit(u_int rate)
{
return SNDRV_PCM_RATE_KNOT;
}
#endif

View File

@ -1,4 +1,4 @@
/* $OpenBSD: if.c,v 1.714 2023/12/29 11:43:04 bluhm Exp $ */ /* $OpenBSD: if.c,v 1.716 2024/01/06 11:42:11 bluhm Exp $ */
/* $NetBSD: if.c,v 1.35 1996/05/07 05:26:04 thorpej Exp $ */ /* $NetBSD: if.c,v 1.35 1996/05/07 05:26:04 thorpej Exp $ */
/* /*
@ -839,11 +839,8 @@ if_input_local(struct ifnet *ifp, struct mbuf *m, sa_family_t af)
if (ISSET(keepcksum, M_ICMP_CSUM_OUT)) if (ISSET(keepcksum, M_ICMP_CSUM_OUT))
m->m_pkthdr.csum_flags |= M_ICMP_CSUM_IN_OK; m->m_pkthdr.csum_flags |= M_ICMP_CSUM_IN_OK;
if (ifp->if_counters == NULL) { /* do not count multicast loopback and simplex interfaces */
/* XXXSMP multicast loopback and simplex interfaces */ if (ISSET(ifp->if_flags, IFF_LOOPBACK)) {
ifp->if_opackets++;
ifp->if_obytes += m->m_pkthdr.len;
} else {
counters_pkt(ifp->if_counters, ifc_opackets, ifc_obytes, counters_pkt(ifp->if_counters, ifc_opackets, ifc_obytes,
m->m_pkthdr.len); m->m_pkthdr.len);
} }
@ -1774,16 +1771,16 @@ if_linkstate_task(void *xifidx)
unsigned int ifidx = (unsigned long)xifidx; unsigned int ifidx = (unsigned long)xifidx;
struct ifnet *ifp; struct ifnet *ifp;
KERNEL_LOCK();
NET_LOCK(); NET_LOCK();
KERNEL_LOCK();
ifp = if_get(ifidx); ifp = if_get(ifidx);
if (ifp != NULL) if (ifp != NULL)
if_linkstate(ifp); if_linkstate(ifp);
if_put(ifp); if_put(ifp);
NET_UNLOCK();
KERNEL_UNLOCK(); KERNEL_UNLOCK();
NET_UNLOCK();
} }
void void

View File

@ -1,4 +1,4 @@
/* $OpenBSD: in.c,v 1.185 2023/06/28 11:49:49 kn Exp $ */ /* $OpenBSD: in.c,v 1.186 2024/01/06 10:58:45 bluhm Exp $ */
/* $NetBSD: in.c,v 1.26 1996/02/13 23:41:39 christos Exp $ */ /* $NetBSD: in.c,v 1.26 1996/02/13 23:41:39 christos Exp $ */
/* /*
@ -260,8 +260,8 @@ in_ioctl(u_long cmd, caddr_t data, struct ifnet *ifp, int privileged)
return (error); return (error);
} }
KERNEL_LOCK();
NET_LOCK(); NET_LOCK();
KERNEL_LOCK();
TAILQ_FOREACH(ifa, &ifp->if_addrlist, ifa_list) { TAILQ_FOREACH(ifa, &ifp->if_addrlist, ifa_list) {
if (ifa->ifa_addr->sa_family != AF_INET) if (ifa->ifa_addr->sa_family != AF_INET)
@ -331,8 +331,8 @@ in_ioctl(u_long cmd, caddr_t data, struct ifnet *ifp, int privileged)
break; break;
} }
err: err:
NET_UNLOCK();
KERNEL_UNLOCK(); KERNEL_UNLOCK();
NET_UNLOCK();
return (error); return (error);
} }
@ -353,8 +353,8 @@ in_ioctl_set_ifaddr(u_long cmd, caddr_t data, struct ifnet *ifp)
if (error) if (error)
return (error); return (error);
KERNEL_LOCK();
NET_LOCK(); NET_LOCK();
KERNEL_LOCK();
TAILQ_FOREACH(ifa, &ifp->if_addrlist, ifa_list) { TAILQ_FOREACH(ifa, &ifp->if_addrlist, ifa_list) {
if (ifa->ifa_addr->sa_family != AF_INET) if (ifa->ifa_addr->sa_family != AF_INET)
@ -387,8 +387,8 @@ in_ioctl_set_ifaddr(u_long cmd, caddr_t data, struct ifnet *ifp)
if (!error) if (!error)
if_addrhooks_run(ifp); if_addrhooks_run(ifp);
NET_UNLOCK();
KERNEL_UNLOCK(); KERNEL_UNLOCK();
NET_UNLOCK();
return error; return error;
} }
@ -409,8 +409,8 @@ in_ioctl_change_ifaddr(u_long cmd, caddr_t data, struct ifnet *ifp)
return (error); return (error);
} }
KERNEL_LOCK();
NET_LOCK(); NET_LOCK();
KERNEL_LOCK();
TAILQ_FOREACH(ifa, &ifp->if_addrlist, ifa_list) { TAILQ_FOREACH(ifa, &ifp->if_addrlist, ifa_list) {
if (ifa->ifa_addr->sa_family != AF_INET) if (ifa->ifa_addr->sa_family != AF_INET)
@ -527,8 +527,8 @@ in_ioctl_change_ifaddr(u_long cmd, caddr_t data, struct ifnet *ifp)
panic("%s: invalid ioctl %lu", __func__, cmd); panic("%s: invalid ioctl %lu", __func__, cmd);
} }
NET_UNLOCK();
KERNEL_UNLOCK(); KERNEL_UNLOCK();
NET_UNLOCK();
return (error); return (error);
} }

View File

@ -13,7 +13,7 @@
* *
* ISBN 3-924521-59-X * ISBN 3-924521-59-X
* *
* $OpenBSD: calendar.geschichte,v 1.2 2018/04/08 15:43:43 tb Exp $ * $OpenBSD: calendar.geschichte,v 1.3 2024/01/06 15:38:45 schwarze Exp $
*/ */
#ifndef _de_DE_ISO_8859_1_geschichte_ #ifndef _de_DE_ISO_8859_1_geschichte_
@ -36,10 +36,10 @@ LANG=de_DE.UTF-8
Paulskirche, Wahl von Friedrich Wilhelm IV von Preußen zum Paulskirche, Wahl von Friedrich Wilhelm IV von Preußen zum
deutschen Kaiser, 1849 deutschen Kaiser, 1849
04/28 Ablehnung der deutschen Kaiserkrone durch den preußischen König, 1849 04/28 Ablehnung der deutschen Kaiserkrone durch den preußischen König, 1849
07/03 Schlacht von Königgrätz 07/03 Schlacht von Königgrätz, 1866
07/13 Emser Depesche, 1870 07/13 Emser Depesche, 1870
07/18 Verkündung des Dogmas von der päpstlichen Unfehlbarkeit 07/18 Verkündung des Dogmas von der päpstlichen Unfehlbarkeit
durch das I. Vatikanische Konzil durch das I. Vatikanische Konzil, 1870
01/18 Proklamation des deutschen Kaiserreiches in Versailles, 1871 01/18 Proklamation des deutschen Kaiserreiches in Versailles, 1871
10/18 Verabschiedung des Sozialistengesetzes durch den Reichstag, 1878 10/18 Verabschiedung des Sozialistengesetzes durch den Reichstag, 1878
03/20 Entlassung von Bismarck als Reichskanzler und 03/20 Entlassung von Bismarck als Reichskanzler und
@ -57,7 +57,7 @@ LANG=de_DE.UTF-8
08/26 Schlacht bei Tannenberg, 1914 08/26 Schlacht bei Tannenberg, 1914
02/21 Schlacht um Verdun, 1916 02/21 Schlacht um Verdun, 1916
03/08 Ausbruch der Revolution in Rußland, Abdankung von Zar Nikolaus II, 1917 03/08 Ausbruch der Revolution in Rußland, Abdankung von Zar Nikolaus II, 1917
04/06 Kriegserklärung der USA an Deutschland 04/06 Kriegserklärung der USA an Deutschland, 1917
12/15 Waffenstillstand zwischen Rußland und Deutschland, 1917 12/15 Waffenstillstand zwischen Rußland und Deutschland, 1917
03/03 Frieden von Brest-Litowsk, 1918 03/03 Frieden von Brest-Litowsk, 1918
11/03 Matrosenaufstand in Kiel, 1918 11/03 Matrosenaufstand in Kiel, 1918
@ -115,7 +115,7 @@ LANG=de_DE.UTF-8
05/05 Natobeitritt, Wiederbewaffnung, Souveränität der Bundesrepublik, 1955 05/05 Natobeitritt, Wiederbewaffnung, Souveränität der Bundesrepublik, 1955
05/06 Rücktritt von Brandt, 1974 05/06 Rücktritt von Brandt, 1974
05/16 Wahl von Schmidt (SPD) zum Bundeskanzler, 1974 05/16 Wahl von Schmidt (SPD) zum Bundeskanzler, 1974
05/23 Verkündung des Grundgesetzes 05/23 Verkündung des Grundgesetzes, 1949
05/23 Wahl von Richard von Weizsäcker zum Bundespräsidenten, 1984 05/23 Wahl von Richard von Weizsäcker zum Bundespräsidenten, 1984
06/05 Marshallplan, 1947 06/05 Marshallplan, 1947
06/20 Währungsreform in den Westzonen, 1948 06/20 Währungsreform in den Westzonen, 1948

View File

@ -1,7 +1,7 @@
/* /*
* Musik * Musik
* *
* $OpenBSD: calendar.musik,v 1.2 2016/03/27 18:15:51 tim Exp $ * $OpenBSD: calendar.musik,v 1.3 2024/01/06 15:38:45 schwarze Exp $
*/ */
#ifndef _de_DE_ISO_8859_1_musik_ #ifndef _de_DE_ISO_8859_1_musik_
@ -52,6 +52,6 @@ LANG=de_DE.UTF-8
12/28 Paul Hindemith in Frankfurt am Main gestorben, 1963 12/28 Paul Hindemith in Frankfurt am Main gestorben, 1963
/* Pop */ /* Pop */
09/18 Jimi Hendrix gestorben 09/18 Jimi Hendrix gestorben, 1970
#endif /* !_de_DE_ISO_8859_1_musik_ */ #endif /* !_de_DE_ISO_8859_1_musik_ */

View File

@ -1,4 +1,4 @@
/* $OpenBSD: rtr_proto.c,v 1.22 2024/01/04 14:30:09 claudio Exp $ */ /* $OpenBSD: rtr_proto.c,v 1.23 2024/01/05 11:02:57 claudio Exp $ */
/* /*
* Copyright (c) 2020 Claudio Jeker <claudio@openbsd.org> * Copyright (c) 2020 Claudio Jeker <claudio@openbsd.org>
@ -299,8 +299,8 @@ rtr_send_error(struct rtr_session *rs, enum rtr_error err, char *msg,
goto fail; goto fail;
ibuf_close(&rs->w, buf); ibuf_close(&rs->w, buf);
log_warnx("rtr %s: sending error report[%u] %s", log_rtr(rs), err, log_warnx("rtr %s: sending error: %s%s%s", log_rtr(rs),
msg ? msg : ""); log_rtr_error(err), msg ? ": " : "", msg ? msg : "");
rtr_fsm(rs, RTR_EVNT_SEND_ERROR); rtr_fsm(rs, RTR_EVNT_SEND_ERROR);
return; return;
@ -1096,7 +1096,7 @@ rtr_fsm(struct rtr_session *rs, enum rtr_event event)
break; break;
} }
log_info("rtr %s: state change %s -> %s, reason: %s", log_debug("rtr %s: state change %s -> %s, reason: %s",
log_rtr(rs), rtr_statenames[prev_state], rtr_statenames[rs->state], log_rtr(rs), rtr_statenames[prev_state], rtr_statenames[rs->state],
rtr_eventnames[event]); rtr_eventnames[event]);
} }

View File

@ -1,6 +1,7 @@
static const char *js = static const char *js =
const rowValue = (tr, idx) => tr.children[idx].getAttribute('data-o') || tr.children[idx].innerText || tr.children[idx].textContent; const cellVal = (e) => e.getAttribute('title') || e.getAttribute('data-o') ||
e.innerText || e.textContent;
const rowValue = (tr, idx) => cellVal(tr.children[idx]);
const compare = (idx, asc) => (a, b) => ((v1, v2) => const compare = (idx, asc) => (a, b) => ((v1, v2) =>
v1 !== '' && v2 !== '' && !isNaN(v1) && !isNaN(v2) ? v1 - v2 : v1.toString().localeCompare(v2) v1 !== '' && v2 !== '' && !isNaN(v1) && !isNaN(v2) ? v1 - v2 : v1.toString().localeCompare(v2)
)(rowValue(asc ? a : b, idx), rowValue(asc ? b : a, idx)); )(rowValue(asc ? a : b, idx), rowValue(asc ? b : a, idx));

View File

@ -1,4 +1,4 @@
/* $OpenBSD: server_file.c,v 1.77 2024/01/04 18:17:47 espie Exp $ */ /* $OpenBSD: server_file.c,v 1.78 2024/01/06 11:29:00 espie Exp $ */
/* /*
* Copyright (c) 2006 - 2017 Reyk Floeter <reyk@openbsd.org> * Copyright (c) 2006 - 2017 Reyk Floeter <reyk@openbsd.org>
@ -596,7 +596,7 @@ server_file_index(struct httpd *env, struct client *clt)
(evbuffer_add_printf(evb, (evbuffer_add_printf(evb,
"<tr><td><a href=\"%s%s\">%s</a></td>\n" "<tr><td><a href=\"%s%s\">%s</a></td>\n"
" <td data-o=\"%lld\">%s</td>" " <td data-o=\"%lld\">%s</td>"
"<td data-o=\"%llu\">%s</td></tr>\n", "<td title=\"%llu\">%s</td></tr>\n",
strchr(escapeduri, ':') != NULL ? "./" : "", strchr(escapeduri, ':') != NULL ? "./" : "",
escapeduri, escapedhtml, escapeduri, escapedhtml,
(long long)t, tmstr, (long long)t, tmstr,

View File

@ -1,4 +1,4 @@
/* $OpenBSD: extern.h,v 1.197 2023/12/27 07:15:55 tb Exp $ */ /* $OpenBSD: extern.h,v 1.198 2024/01/07 09:48:29 tb Exp $ */
/* /*
* Copyright (c) 2019 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2019 Kristaps Dzonsons <kristaps@bsd.lv>
* *

View File

@ -1,4 +1,4 @@
/* $OpenBSD: validate.c,v 1.69 2023/12/27 07:15:55 tb Exp $ */ /* $OpenBSD: validate.c,v 1.70 2024/01/07 09:48:03 tb Exp $ */
/* /*
* Copyright (c) 2019 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2019 Kristaps Dzonsons <kristaps@bsd.lv>
* *
@ -371,6 +371,29 @@ build_crls(const struct crl *crl, STACK_OF(X509_CRL) **crls)
err(1, "sk_X509_CRL_push"); err(1, "sk_X509_CRL_push");
} }
/*
* Attempt to upgrade the generic 'certificate revoked' message to include
* a timestamp.
*/
static void
pretty_revocation_time(X509 *x509, X509_CRL *crl, const char **errstr)
{
static char buf[64];
X509_REVOKED *revoked;
const ASN1_TIME *atime;
time_t t;
if (X509_CRL_get0_by_cert(crl, &revoked, x509) != 1)
return;
if ((atime = X509_REVOKED_get0_revocationDate(revoked)) == NULL)
return;
if (!x509_get_time(atime, &t))
return;
snprintf(buf, sizeof(buf), "certificate revoked on %s", time2str(t));
*errstr = buf;
}
/* /*
* Validate the X509 certificate. Returns 1 for valid certificates, * Validate the X509 certificate. Returns 1 for valid certificates,
* returns 0 if there is a verify error and sets *errstr to the error * returns 0 if there is a verify error and sets *errstr to the error
@ -422,6 +445,8 @@ valid_x509(char *file, X509_STORE_CTX *store_ctx, X509 *x509, struct auth *a,
if (X509_verify_cert(store_ctx) <= 0) { if (X509_verify_cert(store_ctx) <= 0) {
error = X509_STORE_CTX_get_error(store_ctx); error = X509_STORE_CTX_get_error(store_ctx);
*errstr = X509_verify_cert_error_string(error); *errstr = X509_verify_cert_error_string(error);
if (filemode && error == X509_V_ERR_CERT_REVOKED)
pretty_revocation_time(x509, crl->x509_crl, errstr);
X509_STORE_CTX_cleanup(store_ctx); X509_STORE_CTX_cleanup(store_ctx);
sk_X509_free(intermediates); sk_X509_free(intermediates);
sk_X509_free(root); sk_X509_free(root);

View File

@ -1,4 +1,4 @@
/* $OpenBSD: syslogd.c,v 1.279 2023/10/19 22:16:10 bluhm Exp $ */ /* $OpenBSD: syslogd.c,v 1.280 2024/01/06 19:34:54 bluhm Exp $ */
/* /*
* Copyright (c) 2014-2021 Alexander Bluhm <bluhm@genua.de> * Copyright (c) 2014-2021 Alexander Bluhm <bluhm@genua.de>
@ -1427,6 +1427,7 @@ tcp_errorcb(struct bufferevent *bufev, short event, void *arg)
tls_free(f->f_un.f_forw.f_ctx); tls_free(f->f_un.f_forw.f_ctx);
f->f_un.f_forw.f_ctx = NULL; f->f_un.f_forw.f_ctx = NULL;
} }
bufferevent_disable(bufev, EV_READ|EV_WRITE);
close(f->f_file); close(f->f_file);
f->f_file = -1; f->f_file = -1;
@ -1521,6 +1522,7 @@ tcp_connectcb(int fd, short event, void *arg)
tls_free(f->f_un.f_forw.f_ctx); tls_free(f->f_un.f_forw.f_ctx);
f->f_un.f_forw.f_ctx = NULL; f->f_un.f_forw.f_ctx = NULL;
} }
bufferevent_disable(bufev, EV_READ|EV_WRITE);
close(f->f_file); close(f->f_file);
f->f_file = -1; f->f_file = -1;
loghost_retry(f); loghost_retry(f);
@ -2421,9 +2423,14 @@ init(void)
/* FALLTHROUGH */ /* FALLTHROUGH */
case F_FORWTCP: case F_FORWTCP:
evtimer_del(&f->f_un.f_forw.f_ev); evtimer_del(&f->f_un.f_forw.f_ev);
tcpbuf_dropped += f->f_dropped + tcpbuf_dropped += f->f_dropped;
if (f->f_un.f_forw.f_bufev) {
bufferevent_disable(f->f_un.f_forw.f_bufev,
EV_READ|EV_WRITE);
tcpbuf_dropped +=
tcpbuf_countmsg(f->f_un.f_forw.f_bufev); tcpbuf_countmsg(f->f_un.f_forw.f_bufev);
bufferevent_free(f->f_un.f_forw.f_bufev); bufferevent_free(f->f_un.f_forw.f_bufev);
}
free(f->f_un.f_forw.f_ipproto); free(f->f_un.f_forw.f_ipproto);
free(f->f_un.f_forw.f_host); free(f->f_un.f_forw.f_host);
free(f->f_un.f_forw.f_port); free(f->f_un.f_forw.f_port);