IFC @r273066

This commit is contained in:
neel 2014-10-14 03:39:31 +00:00
commit c0576dea26
187 changed files with 2636 additions and 4250 deletions

View File

@ -168,6 +168,8 @@ evalstring(char *s, int flags)
else else
evaltree(n, flags); evaltree(n, flags);
any = 1; any = 1;
if (evalskip)
break;
} }
popstackmark(&smark); popstackmark(&smark);
setstackmark(&smark); setstackmark(&smark);

View File

@ -72,6 +72,8 @@ FILES+= eval3.0
FILES+= eval4.0 FILES+= eval4.0
FILES+= eval5.0 FILES+= eval5.0
FILES+= eval6.0 FILES+= eval6.0
FILES+= eval7.0
FILES+= eval8.7
FILES+= exec1.0 FILES+= exec1.0
FILES+= exec2.0 FILES+= exec2.0
FILES+= exit1.0 FILES+= exit1.0

View File

@ -0,0 +1,9 @@
# $FreeBSD$
# Assumes that break can break out of a loop outside eval.
while :; do
eval "break
echo bad1"
echo bad2
exit 3
done

View File

@ -0,0 +1,7 @@
# $FreeBSD$
f() {
eval "return 7
echo bad2"
}
f

View File

@ -7572,7 +7572,7 @@ ppc_elf_finish_dynamic_sections (bfd *output_bfd,
#define TARGET_LITTLE_SYM bfd_elf32_powerpcle_vec #define TARGET_LITTLE_SYM bfd_elf32_powerpcle_vec
#define TARGET_LITTLE_NAME "elf32-powerpcle" #define TARGET_LITTLE_NAME "elf32-powerpcle"
#define TARGET_BIG_SYM bfd_elf32_powerpc_vec #define TARGET_BIG_SYM bfd_elf32_powerpc_vec
#define TARGET_BIG_NAME "elf32-powerpc" #define TARGET_BIG_NAME "elf32-powerpc-freebsd"
#define ELF_ARCH bfd_arch_powerpc #define ELF_ARCH bfd_arch_powerpc
#define ELF_MACHINE_CODE EM_PPC #define ELF_MACHINE_CODE EM_PPC
#ifdef __QNXTARGET__ #ifdef __QNXTARGET__

View File

@ -58,7 +58,7 @@ static bfd_vma opd_entry_value
#define TARGET_LITTLE_SYM bfd_elf64_powerpcle_vec #define TARGET_LITTLE_SYM bfd_elf64_powerpcle_vec
#define TARGET_LITTLE_NAME "elf64-powerpcle" #define TARGET_LITTLE_NAME "elf64-powerpcle"
#define TARGET_BIG_SYM bfd_elf64_powerpc_vec #define TARGET_BIG_SYM bfd_elf64_powerpc_vec
#define TARGET_BIG_NAME "elf64-powerpc" #define TARGET_BIG_NAME "elf64-powerpc-freebsd"
#define ELF_ARCH bfd_arch_powerpc #define ELF_ARCH bfd_arch_powerpc
#define ELF_MACHINE_CODE EM_PPC64 #define ELF_MACHINE_CODE EM_PPC64
#define ELF_MAXPAGESIZE 0x10000 #define ELF_MAXPAGESIZE 0x10000

View File

@ -1210,7 +1210,7 @@ ppc_target_format (void)
return "elf32-powerpc-vxworks"; return "elf32-powerpc-vxworks";
# else # else
return (target_big_endian return (target_big_endian
? (ppc_obj64 ? "elf64-powerpc" : "elf32-powerpc") ? (ppc_obj64 ? "elf64-powerpc-freebsd" : "elf32-powerpc-freebsd")
: (ppc_obj64 ? "elf64-powerpcle" : "elf32-powerpcle")); : (ppc_obj64 ? "elf64-powerpcle" : "elf32-powerpcle"));
# endif # endif
#endif #endif

View File

@ -1,2 +1,4 @@
. ${srcdir}/emulparams/elf32ppc.sh . ${srcdir}/emulparams/elf32ppc.sh
. ${srcdir}/emulparams/elf_fbsd.sh . ${srcdir}/emulparams/elf_fbsd.sh
OUTPUT_FORMAT="elf32-powerpc-freebsd"

View File

@ -1,3 +1,4 @@
. ${srcdir}/emulparams/elf64ppc.sh . ${srcdir}/emulparams/elf64ppc.sh
. ${srcdir}/emulparams/elf_fbsd.sh . ${srcdir}/emulparams/elf_fbsd.sh
OUTPUT_FORMAT="elf64-powerpc-freebsd"

View File

@ -374,6 +374,7 @@ namespace std {
#define _LIBCPP_HAS_NO_VARIADICS #define _LIBCPP_HAS_NO_VARIADICS
#define _LIBCPP_HAS_NO_RVALUE_REFERENCES #define _LIBCPP_HAS_NO_RVALUE_REFERENCES
#define _LIBCPP_HAS_NO_ALWAYS_INLINE_VARIADICS #define _LIBCPP_HAS_NO_ALWAYS_INLINE_VARIADICS
#define _LIBCPP_HAS_NO_STRONG_ENUMS
#else // __GXX_EXPERIMENTAL_CXX0X__ #else // __GXX_EXPERIMENTAL_CXX0X__

View File

@ -31,6 +31,9 @@
*/ */
#if defined(__FreeBSD__)
#include <sys/stat.h>
#endif
#include <atf-c.h> #include <atf-c.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
@ -248,6 +251,7 @@ ATF_TC_BODY(t_spawn_open_nonexistent, tc)
posix_spawn_file_actions_destroy(&fa); posix_spawn_file_actions_destroy(&fa);
} }
#if defined(__NetBSD__)
ATF_TC(t_spawn_open_nonexistent_diag); ATF_TC(t_spawn_open_nonexistent_diag);
ATF_TC_HEAD(t_spawn_open_nonexistent_diag, tc) ATF_TC_HEAD(t_spawn_open_nonexistent_diag, tc)
@ -283,6 +287,7 @@ ATF_TC_BODY(t_spawn_open_nonexistent_diag, tc)
posix_spawn_file_actions_destroy(&fa); posix_spawn_file_actions_destroy(&fa);
posix_spawnattr_destroy(&attr); posix_spawnattr_destroy(&attr);
} }
#endif
ATF_TC(t_spawn_fileactions); ATF_TC(t_spawn_fileactions);
@ -376,7 +381,9 @@ ATF_TP_ADD_TCS(tp)
{ {
ATF_TP_ADD_TC(tp, t_spawn_fileactions); ATF_TP_ADD_TC(tp, t_spawn_fileactions);
ATF_TP_ADD_TC(tp, t_spawn_open_nonexistent); ATF_TP_ADD_TC(tp, t_spawn_open_nonexistent);
#if defined(__NetBSD__)
ATF_TP_ADD_TC(tp, t_spawn_open_nonexistent_diag); ATF_TP_ADD_TC(tp, t_spawn_open_nonexistent_diag);
#endif
ATF_TP_ADD_TC(tp, t_spawn_reopen); ATF_TP_ADD_TC(tp, t_spawn_reopen);
ATF_TP_ADD_TC(tp, t_spawn_openmode); ATF_TP_ADD_TC(tp, t_spawn_openmode);
ATF_TP_ADD_TC(tp, t_spawn_empty_fileactions); ATF_TP_ADD_TC(tp, t_spawn_empty_fileactions);

View File

@ -56,10 +56,12 @@ ATF_TC_BODY(getcwd_err, tc)
ATF_REQUIRE(getcwd(buf, 0) == NULL); ATF_REQUIRE(getcwd(buf, 0) == NULL);
ATF_REQUIRE(errno == EINVAL); ATF_REQUIRE(errno == EINVAL);
#if defined(__NetBSD__)
errno = 0; errno = 0;
ATF_REQUIRE(getcwd((void *)-1, sizeof(buf)) == NULL); ATF_REQUIRE(getcwd((void *)-1, sizeof(buf)) == NULL);
ATF_REQUIRE(errno == EFAULT); ATF_REQUIRE(errno == EFAULT);
#endif
} }
ATF_TC(getcwd_fts); ATF_TC(getcwd_fts);

View File

@ -46,7 +46,13 @@ __RCSID("$NetBSD: t_glob.c,v 1.3 2013/01/02 11:28:48 martin Exp $");
#include <string.h> #include <string.h>
#include <errno.h> #include <errno.h>
#if defined(__FreeBSD__)
#include "h_macros.h"
#define __gl_stat_t struct stat
#define _S_IFDIR S_IFDIR
#else
#include "../../../h_macros.h" #include "../../../h_macros.h"
#endif
#ifdef DEBUG #ifdef DEBUG
@ -132,7 +138,11 @@ gl_readdir(void *v)
dir.d_ino = dd->pos; dir.d_ino = dd->pos;
dir.d_type = f->dir ? DT_DIR : DT_REG; dir.d_type = f->dir ? DT_DIR : DT_REG;
DPRINTF(("readdir %s %d\n", dir.d_name, dir.d_type)); DPRINTF(("readdir %s %d\n", dir.d_name, dir.d_type));
#if defined(__FreeBSD__)
dir.d_reclen = -1; /* Does not have _DIRENT_RECLEN */
#else
dir.d_reclen = _DIRENT_RECLEN(&dir, dir.d_namlen); dir.d_reclen = _DIRENT_RECLEN(&dir, dir.d_namlen);
#endif
return &dir; return &dir;
} }
return NULL; return NULL;
@ -213,6 +223,7 @@ run(const char *p, int flags, const char **res, size_t len)
} }
#if !defined(__FreeBSD__)
ATF_TC(glob_star); ATF_TC(glob_star);
ATF_TC_HEAD(glob_star, tc) ATF_TC_HEAD(glob_star, tc)
{ {
@ -224,6 +235,7 @@ ATF_TC_BODY(glob_star, tc)
{ {
run("a/**", GLOB_STAR, glob_star, __arraycount(glob_star)); run("a/**", GLOB_STAR, glob_star, __arraycount(glob_star));
} }
#endif
ATF_TC(glob_star_not); ATF_TC(glob_star_not);
ATF_TC_HEAD(glob_star_not, tc) ATF_TC_HEAD(glob_star_not, tc)
@ -260,7 +272,9 @@ ATF_TC_BODY(glob_nocheck, tc)
ATF_TP_ADD_TCS(tp) ATF_TP_ADD_TCS(tp)
{ {
#if !defined(__FreeBSD__)
ATF_TP_ADD_TC(tp, glob_star); ATF_TP_ADD_TC(tp, glob_star);
#endif
ATF_TP_ADD_TC(tp, glob_star_not); ATF_TP_ADD_TC(tp, glob_star_not);
/* /*
* Remove this test for now - the GLOB_NOCHECK return value has been * Remove this test for now - the GLOB_NOCHECK return value has been

View File

@ -34,7 +34,11 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#if defined(__FreeBSD__)
#include <libutil.h>
#else
#include <util.h> #include <util.h>
#endif
const struct hnopts { const struct hnopts {
size_t ho_len; size_t ho_len;
@ -78,6 +82,7 @@ const struct hnopts {
/* /*
* Truncated output. Rev. 1.7 produces "1.0 K". * Truncated output. Rev. 1.7 produces "1.0 K".
*/ */
#if !defined(__FreeBSD__)
{ 6, 1000, "A", HN_AUTOSCALE, HN_DECIMAL, -1, "" }, { 6, 1000, "A", HN_AUTOSCALE, HN_DECIMAL, -1, "" },
/* /*
@ -90,6 +95,7 @@ const struct hnopts {
/* Similar case it prints 1000 where it shouldn't */ /* Similar case it prints 1000 where it shouldn't */
{ 5, 1023488, "", { 5, 1023488, "",
HN_AUTOSCALE, HN_B | HN_NOSPACE | HN_DECIMAL, 4, "1.0M" }, HN_AUTOSCALE, HN_B | HN_NOSPACE | HN_DECIMAL, 4, "1.0M" },
#endif
{ 5, 1023999, "", { 5, 1023999, "",
HN_AUTOSCALE, HN_B | HN_NOSPACE | HN_DECIMAL, 4, "1.0M" }, HN_AUTOSCALE, HN_B | HN_NOSPACE | HN_DECIMAL, 4, "1.0M" },
}; };

View File

@ -72,6 +72,11 @@ ATF_TC_BODY(nice_err, tc)
{ {
int i; int i;
#if defined(__FreeBSD__)
atf_tc_expect_fail("nice(incr) with incr < 0 fails with unprivileged "
"users and sets errno == EPERM; see PR # 189821 for more details");
#endif
/* /*
* The call should fail with EPERM if the * The call should fail with EPERM if the
* supplied parameter is negative and the * supplied parameter is negative and the
@ -93,7 +98,11 @@ ATF_TC_HEAD(nice_priority, tc)
ATF_TC_BODY(nice_priority, tc) ATF_TC_BODY(nice_priority, tc)
{ {
#if defined(__FreeBSD__)
int i, pri, pri2, nic;
#else
int i, pri, nic; int i, pri, nic;
#endif
pid_t pid; pid_t pid;
int sta; int sta;
@ -106,8 +115,10 @@ ATF_TC_BODY(nice_priority, tc)
pri = getpriority(PRIO_PROCESS, 0); pri = getpriority(PRIO_PROCESS, 0);
ATF_REQUIRE(errno == 0); ATF_REQUIRE(errno == 0);
#if defined(__NetBSD__)
if (nic != pri) if (nic != pri)
atf_tc_fail("nice(3) and getpriority(2) conflict"); atf_tc_fail("nice(3) and getpriority(2) conflict");
#endif
/* /*
* Also verify that the nice(3) values * Also verify that the nice(3) values
@ -119,10 +130,18 @@ ATF_TC_BODY(nice_priority, tc)
if (pid == 0) { if (pid == 0) {
errno = 0; errno = 0;
#if defined(__FreeBSD__)
pri = getpriority(PRIO_PROCESS, 0); pri = getpriority(PRIO_PROCESS, 0);
#else
pri2 = getpriority(PRIO_PROCESS, 0);
#endif
ATF_REQUIRE(errno == 0); ATF_REQUIRE(errno == 0);
#if defined(__FreeBSD__)
if (pri != pri2)
#else
if (nic != pri) if (nic != pri)
#endif
_exit(EXIT_FAILURE); _exit(EXIT_FAILURE);
_exit(EXIT_SUCCESS); _exit(EXIT_SUCCESS);
@ -161,7 +180,11 @@ ATF_TC_HEAD(nice_thread, tc)
ATF_TC_BODY(nice_thread, tc) ATF_TC_BODY(nice_thread, tc)
{ {
pthread_t tid[5]; pthread_t tid[5];
#if defined(__FreeBSD__)
int pri, rv, val;
#else
int rv, val; int rv, val;
#endif
size_t i; size_t i;
/* /*
@ -173,7 +196,12 @@ ATF_TC_BODY(nice_thread, tc)
val = nice(i); val = nice(i);
ATF_REQUIRE(val != -1); ATF_REQUIRE(val != -1);
#if defined(__FreeBSD__)
pri = getpriority(PRIO_PROCESS, 0);
rv = pthread_create(&tid[i], NULL, threadfunc, &pri);
#else
rv = pthread_create(&tid[i], NULL, threadfunc, &val); rv = pthread_create(&tid[i], NULL, threadfunc, &val);
#endif
ATF_REQUIRE(rv == 0); ATF_REQUIRE(rv == 0);
rv = pthread_join(tid[i], NULL); rv = pthread_join(tid[i], NULL);

View File

@ -43,7 +43,11 @@ static int count;
static void handler_err(int); static void handler_err(int);
static void handler_ret(int); static void handler_ret(int);
static void handler_stress(int); static void handler_stress(int);
#if defined(__FreeBSD__)
static int sig[] = { SIGALRM, SIGIO, SIGUSR1, SIGUSR2 };
#else
static int sig[] = { SIGALRM, SIGIO, SIGUSR1, SIGUSR2, SIGPWR }; static int sig[] = { SIGALRM, SIGIO, SIGUSR1, SIGUSR2, SIGPWR };
#endif
static void static void
handler_stress(int signo) handler_stress(int signo)

View File

@ -63,8 +63,20 @@ ATF_TC_BODY(setdomainname_basic, tc)
(void)memset(name, 0, sizeof(name)); (void)memset(name, 0, sizeof(name));
#if defined(__FreeBSD__)
/*
* Sanity checks to ensure that the wrong invariant isn't being
* tested for per PR # 181127
*/
ATF_REQUIRE_EQ(sizeof(domains[i]), MAXHOSTNAMELEN);
ATF_REQUIRE_EQ(sizeof(name), MAXHOSTNAMELEN);
ATF_REQUIRE(setdomainname(domains[i],sizeof(domains[i]) - 1) == 0);
ATF_REQUIRE(getdomainname(name, sizeof(name) - 1) == 0);
#else
ATF_REQUIRE(setdomainname(domains[i],sizeof(domains[i])) == 0); ATF_REQUIRE(setdomainname(domains[i],sizeof(domains[i])) == 0);
ATF_REQUIRE(getdomainname(name, sizeof(name)) == 0); ATF_REQUIRE(getdomainname(name, sizeof(name)) == 0);
#endif
ATF_REQUIRE(strcmp(domains[i], name) == 0); ATF_REQUIRE(strcmp(domains[i], name) == 0);
} }
@ -89,6 +101,10 @@ ATF_TC_BODY(setdomainname_limit, tc)
(void)memset(name, 0, sizeof(name)); (void)memset(name, 0, sizeof(name));
#if defined(__FreeBSD__)
ATF_REQUIRE(setdomainname(name, MAXHOSTNAMELEN - 1 ) == 0);
ATF_REQUIRE(setdomainname(name, MAXHOSTNAMELEN) == -1);
#endif
ATF_REQUIRE(setdomainname(name, sizeof(name)) == -1); ATF_REQUIRE(setdomainname(name, sizeof(name)) == -1);
} }

View File

@ -63,8 +63,20 @@ ATF_TC_BODY(sethostname_basic, tc)
(void)memset(name, 0, sizeof(name)); (void)memset(name, 0, sizeof(name));
#if defined(__FreeBSD__)
/*
* Sanity checks to ensure that the wrong invariant isn't being
* tested for per PR # 181127
*/
ATF_REQUIRE_EQ(sizeof(hosts[i]), MAXHOSTNAMELEN);
ATF_REQUIRE_EQ(sizeof(name), MAXHOSTNAMELEN);
ATF_REQUIRE(sethostname(hosts[i], sizeof(hosts[i]) - 1) == 0);
ATF_REQUIRE(gethostname(name, sizeof(name) - 1) == 0);
#else
ATF_REQUIRE(sethostname(hosts[i], sizeof(hosts[i])) == 0); ATF_REQUIRE(sethostname(hosts[i], sizeof(hosts[i])) == 0);
ATF_REQUIRE(gethostname(name, sizeof(name)) == 0); ATF_REQUIRE(gethostname(name, sizeof(name)) == 0);
#endif
ATF_REQUIRE(strcmp(hosts[i], name) == 0); ATF_REQUIRE(strcmp(hosts[i], name) == 0);
} }
@ -94,6 +106,10 @@ ATF_TC_BODY(sethostname_limit, tc)
ATF_TC_CLEANUP(sethostname_limit, tc) ATF_TC_CLEANUP(sethostname_limit, tc)
{ {
#if defined(__FreeBSD__)
ATF_REQUIRE(sethostname(host, MAXHOSTNAMELEN - 1 ) == 0);
ATF_REQUIRE(sethostname(host, MAXHOSTNAMELEN) == -1);
#endif
(void)sethostname(host, sizeof(host)); (void)sethostname(host, sizeof(host));
} }

View File

@ -31,6 +31,9 @@
#include <sys/cdefs.h> #include <sys/cdefs.h>
__RCSID("$NetBSD: t_time.c,v 1.2 2011/11/11 05:03:38 jruoho Exp $"); __RCSID("$NetBSD: t_time.c,v 1.2 2011/11/11 05:03:38 jruoho Exp $");
#if defined(__FreeBSD__)
#include <sys/time.h>
#endif
#include <atf-c.h> #include <atf-c.h>
#include <errno.h> #include <errno.h>
#include <inttypes.h> #include <inttypes.h>

View File

@ -107,6 +107,9 @@ ATF_TC_BODY(ttyname_r_err, tc)
ATF_REQUIRE(rv == ERANGE); ATF_REQUIRE(rv == ERANGE);
} }
#if defined(__FreeBSD__)
atf_tc_expect_fail("FreeBSD returns ENOTTY instead of EBADF; see bin/191936");
#endif
rv = ttyname_r(-1, buf, ttymax); rv = ttyname_r(-1, buf, ttymax);
ATF_REQUIRE(rv == EBADF); ATF_REQUIRE(rv == EBADF);

View File

@ -56,6 +56,11 @@ ATF_TC_BODY(bad_big5_wprintf, tc)
/* XXX implementation detail knowledge (wchar_t encoding) */ /* XXX implementation detail knowledge (wchar_t encoding) */
wchar_t ibuf[] = { 0xcf10, 0 }; wchar_t ibuf[] = { 0xcf10, 0 };
setlocale(LC_CTYPE, "zh_TW.Big5"); setlocale(LC_CTYPE, "zh_TW.Big5");
#if defined(__FreeBSD__)
atf_tc_expect_fail("does not fail as expected (may be implementation "
"specific issue with the test)");
#endif
ATF_REQUIRE_ERRNO(EILSEQ, wprintf(L"%ls\n", ibuf) < 0); ATF_REQUIRE_ERRNO(EILSEQ, wprintf(L"%ls\n", ibuf) < 0);
ATF_REQUIRE(ferror(stdout)); ATF_REQUIRE(ferror(stdout));
} }
@ -72,6 +77,11 @@ ATF_TC_BODY(bad_big5_swprintf, tc)
wchar_t ibuf[] = { 0xcf10, 0 }; wchar_t ibuf[] = { 0xcf10, 0 };
wchar_t obuf[20]; wchar_t obuf[20];
setlocale(LC_CTYPE, "zh_TW.Big5"); setlocale(LC_CTYPE, "zh_TW.Big5");
#if defined(__FreeBSD__)
atf_tc_expect_fail("does not fail as expected (may be implementation "
"specific issue with the test)");
#endif
ATF_REQUIRE_ERRNO(EILSEQ, ATF_REQUIRE_ERRNO(EILSEQ,
swprintf(obuf, sizeof(obuf), L"%ls\n", ibuf) < 0); swprintf(obuf, sizeof(obuf), L"%ls\n", ibuf) < 0);
} }
@ -161,6 +171,9 @@ ATF_TC_BODY(bad_big5_getwc, tc)
ATF_REQUIRE(fp != NULL); ATF_REQUIRE(fp != NULL);
setlocale(LC_CTYPE, "zh_TW.Big5"); setlocale(LC_CTYPE, "zh_TW.Big5");
#if defined(__FreeBSD__)
atf_tc_expect_fail("does not return WEOF as expected");
#endif
ATF_REQUIRE_EQ(getwc(fp), WEOF); ATF_REQUIRE_EQ(getwc(fp), WEOF);
fclose(fp); fclose(fp);
} }

View File

@ -132,7 +132,14 @@ h_ctype2(const struct test *t, bool use_mbstate)
size_t n; size_t n;
ATF_REQUIRE_STREQ(setlocale(LC_ALL, "C"), "C"); ATF_REQUIRE_STREQ(setlocale(LC_ALL, "C"), "C");
#if defined(__NetBSD__)
ATF_REQUIRE(setlocale(LC_CTYPE, t->locale) != NULL); ATF_REQUIRE(setlocale(LC_CTYPE, t->locale) != NULL);
#else
if (setlocale(LC_CTYPE, t->locale) == NULL) {
fprintf(stderr, "Locale %s not found.\n", t->locale);
return;
}
#endif
(void)strvis(buf, t->data, VIS_WHITE | VIS_OCTAL); (void)strvis(buf, t->data, VIS_WHITE | VIS_OCTAL);
(void)printf("Checking string: \"%s\"\n", buf); (void)printf("Checking string: \"%s\"\n", buf);
@ -238,6 +245,9 @@ ATF_TC_BODY(mbrtowc_internal, tc)
{ {
struct test *t; struct test *t;
#if defined(__FreeBSD__)
atf_tc_expect_fail("ja_* locale fails");
#endif
for (t = &tests[0]; t->data != NULL; ++t) for (t = &tests[0]; t->data != NULL; ++t)
h_ctype2(t, false); h_ctype2(t, false);
} }

View File

@ -150,7 +150,14 @@ ATF_TC_BODY(mbstowcs_basic, tc)
int i; int i;
ATF_REQUIRE_STREQ(setlocale(LC_ALL, "C"), "C"); ATF_REQUIRE_STREQ(setlocale(LC_ALL, "C"), "C");
#if defined(__NetBSD__)
ATF_REQUIRE(setlocale(LC_CTYPE, t->locale) != NULL); ATF_REQUIRE(setlocale(LC_CTYPE, t->locale) != NULL);
#else
if (setlocale(LC_CTYPE, t->locale) == NULL) {
fprintf(stderr, "Locale %s not found.\n", t->locale);
continue;
}
#endif
(void)strvis(visbuf, t->data, VIS_WHITE | VIS_OCTAL); (void)strvis(visbuf, t->data, VIS_WHITE | VIS_OCTAL);
(void)printf("Checking string: \"%s\"\n", visbuf); (void)printf("Checking string: \"%s\"\n", visbuf);

View File

@ -76,7 +76,14 @@ h_mbtowc(const char *locale, const char *illegal, const char *legal)
char *str; char *str;
ATF_REQUIRE_STREQ(setlocale(LC_ALL, "C"), "C"); ATF_REQUIRE_STREQ(setlocale(LC_ALL, "C"), "C");
#if defined(__NetBSD__)
ATF_REQUIRE(setlocale(LC_CTYPE, locale) != NULL); ATF_REQUIRE(setlocale(LC_CTYPE, locale) != NULL);
#else
if (setlocale(LC_CTYPE, locale) == NULL) {
fprintf(stderr, "Locale %s not found.\n", locale);
return;
}
#endif
ATF_REQUIRE((str = setlocale(LC_ALL, NULL)) != NULL); ATF_REQUIRE((str = setlocale(LC_ALL, NULL)) != NULL);
(void)printf("Using locale: %s\n", str); (void)printf("Using locale: %s\n", str);
@ -130,9 +137,16 @@ ATF_TC_BODY(mbtowc, tc)
h_mbtowc("ja_JP.ISO2022-JP", "\033$B", "\033$B$\"\033(B"); h_mbtowc("ja_JP.ISO2022-JP", "\033$B", "\033$B$\"\033(B");
h_mbtowc("ja_JP.SJIS", "\202", "\202\240"); h_mbtowc("ja_JP.SJIS", "\202", "\202\240");
h_mbtowc("ja_JP.eucJP", "\244", "\244\242"); h_mbtowc("ja_JP.eucJP", "\244", "\244\242");
#if !defined(__FreeBSD__)
/* Moved last as it fails */
h_mbtowc("zh_CN.GB18030", "\241", "\241\241"); h_mbtowc("zh_CN.GB18030", "\241", "\241\241");
#endif
h_mbtowc("zh_TW.Big5", "\241", "\241@"); h_mbtowc("zh_TW.Big5", "\241", "\241@");
h_mbtowc("zh_TW.eucTW", "\241", "\241\241"); h_mbtowc("zh_TW.eucTW", "\241", "\241\241");
#if defined(__FreeBSD__)
atf_tc_expect_fail("zh_CN.GB18030");
h_mbtowc("zh_CN.GB18030", "\241", "\241\241");
#endif
} }
ATF_TP_ADD_TCS(tp) ATF_TP_ADD_TCS(tp)

View File

@ -66,6 +66,10 @@ __RCSID("$NetBSD: t_wcstod.c,v 1.3 2011/10/01 17:56:11 christos Exp $");
#include <atf-c.h> #include <atf-c.h>
#if defined(__FreeBSD__)
#include <stdio.h>
#endif
#define ALT_HUGE_VAL -1 #define ALT_HUGE_VAL -1
#define ALT_MINUS_HUGE_VAL -2 #define ALT_MINUS_HUGE_VAL -2
#define ALT_NAN -3 #define ALT_NAN -3
@ -234,7 +238,7 @@ static struct test {
{ L" -0X.", 12, 0, 0 }, { L" -0X.", 12, 0, 0 },
#endif #endif
/* XXX: FIXME */ /* XXX: FIXME */
#if defined(__NetBSD__) || defined(__linux__) #if defined(__NetBSD__) || defined(__linux__) || defined(__FreeBSD__)
{ L"0X.0", 4, 0, 0 }, { L"0X.0", 4, 0, 0 },
{ L"+0X.0", 5, 0, 0 }, { L"+0X.0", 5, 0, 0 },
{ L"-0X.0", 5, 0, 0 }, { L"-0X.0", 5, 0, 0 },

View File

@ -109,7 +109,14 @@ h_wctomb(const struct test *t, char tc)
size_t sz, ret, i; size_t sz, ret, i;
ATF_REQUIRE_STREQ(setlocale(LC_ALL, "C"), "C"); ATF_REQUIRE_STREQ(setlocale(LC_ALL, "C"), "C");
#if defined(__NetBSD__)
ATF_REQUIRE(setlocale(LC_CTYPE, t->locale) != NULL); ATF_REQUIRE(setlocale(LC_CTYPE, t->locale) != NULL);
#else
if (setlocale(LC_CTYPE, t->locale) == NULL) {
fprintf(stderr, "Locale %s not found.\n", t->locale);
return;
}
#endif
(void)strvis(buf, t->data, VIS_WHITE | VIS_OCTAL); (void)strvis(buf, t->data, VIS_WHITE | VIS_OCTAL);
(void)printf("Checking sequence: \"%s\"\n", buf); (void)printf("Checking sequence: \"%s\"\n", buf);

View File

@ -34,6 +34,10 @@
#include <string.h> #include <string.h>
#include <sys/types.h> #include <sys/types.h>
#if defined(__FreeBSD__)
#include <wchar.h>
#include <wctype.h>
#endif
/* Don't sort these! */ /* Don't sort these! */
#include "utils.h" #include "utils.h"
@ -50,6 +54,7 @@ static char *regchar(int);
void void
regprint(regex_t *r, FILE *d) regprint(regex_t *r, FILE *d)
{ {
#if defined(__NetBSD__)
struct re_guts *g = r->re_g; struct re_guts *g = r->re_g;
int c; int c;
int last; int last;
@ -111,6 +116,7 @@ regprint(regex_t *r, FILE *d)
} }
fprintf(d, "\n"); fprintf(d, "\n");
} }
#endif
} }
/* /*
@ -171,6 +177,7 @@ s_print(struct re_guts *g, FILE *d)
break; break;
case OANYOF: case OANYOF:
fprintf(d, "[(%ld)", (long)opnd); fprintf(d, "[(%ld)", (long)opnd);
#if defined(__NetBSD__)
cs = &g->sets[opnd]; cs = &g->sets[opnd];
last = -1; last = -1;
for (size_t i = 0; i < g->csetsize+1; i++) /* +1 flushes */ for (size_t i = 0; i < g->csetsize+1; i++) /* +1 flushes */
@ -187,6 +194,7 @@ s_print(struct re_guts *g, FILE *d)
last = -1; last = -1;
} }
} }
#endif
fprintf(d, "]"); fprintf(d, "]");
break; break;
case OBACK_: case OBACK_:
@ -242,7 +250,11 @@ s_print(struct re_guts *g, FILE *d)
fprintf(d, ">"); fprintf(d, ">");
break; break;
default: default:
#if defined(__FreeBSD__)
fprintf(d, "!%ld(%ld)!", OP(*s), opnd);
#else
fprintf(d, "!%d(%d)!", OP(*s), opnd); fprintf(d, "!%d(%d)!", OP(*s), opnd);
#endif
break; break;
} }
if (!done) if (!done)

View File

@ -45,6 +45,9 @@ __RCSID("$NetBSD: t_exhaust.c,v 1.7 2011/11/16 18:37:31 christos Exp $");
#include <stdlib.h> #include <stdlib.h>
#include <err.h> #include <err.h>
#include <atf-c.h> #include <atf-c.h>
#if defined(__FreeBSD__)
#include <sys/resource.h>
#endif
#ifndef REGEX_MAXSIZE #ifndef REGEX_MAXSIZE
#define REGEX_MAXSIZE 9999 #define REGEX_MAXSIZE 9999
@ -176,14 +179,25 @@ ATF_TC_HEAD(regcomp_too_big, tc)
" crash, but return a proper error code"); " crash, but return a proper error code");
// libtre needs it. // libtre needs it.
atf_tc_set_md_var(tc, "timeout", "600"); atf_tc_set_md_var(tc, "timeout", "600");
#if defined(__FreeBSD__)
atf_tc_set_md_var(tc, "require.memory", "64M");
#else
atf_tc_set_md_var(tc, "require.memory", "120M"); atf_tc_set_md_var(tc, "require.memory", "120M");
#endif
} }
ATF_TC_BODY(regcomp_too_big, tc) ATF_TC_BODY(regcomp_too_big, tc)
{ {
regex_t re; regex_t re;
#if defined(__FreeBSD__)
struct rlimit limit;
#endif
int e; int e;
#if defined(__FreeBSD__)
limit.rlim_cur = limit.rlim_max = 64 * 1024 * 1024;
ATF_REQUIRE(setrlimit(RLIMIT_VMEM, &limit) != -1);
#endif
for (size_t i = 0; i < __arraycount(tests); i++) { for (size_t i = 0; i < __arraycount(tests); i++) {
char *d = (*tests[i].pattern)(REGEX_MAXSIZE); char *d = (*tests[i].pattern)(REGEX_MAXSIZE);
e = regcomp(&re, d, tests[i].type); e = regcomp(&re, d, tests[i].type);

View File

@ -48,6 +48,9 @@ __RCSID("$NetBSD: t_regex_att.c,v 1.1 2012/08/24 20:24:40 jmmv Exp $");
#include <vis.h> #include <vis.h>
#include <ctype.h> #include <ctype.h>
#include <atf-c.h> #include <atf-c.h>
#if defined(__FreeBSD__)
#include <libutil.h>
#endif
static const char sep[] = "\r\n\t"; static const char sep[] = "\r\n\t";
static const char delim[3] = "\\\\\0"; static const char delim[3] = "\\\\\0";
@ -374,7 +377,11 @@ checkmatches(const char *matches, size_t nm, const regmatch_t *pm,
" cur=%d, max=%zu", res, l, len - off); " cur=%d, max=%zu", res, l, len - off);
off += l; off += l;
} }
#if defined(__FreeBSD__)
ATF_CHECK_STREQ_MSG(res, matches, " at line %zu", lineno);
#else
ATF_REQUIRE_STREQ_MSG(res, matches, " at line %zu", lineno); ATF_REQUIRE_STREQ_MSG(res, matches, " at line %zu", lineno);
#endif
free(res); free(res);
} }
@ -572,6 +579,9 @@ ATF_TC_BODY(leftassoc, tc)
* disabled this test in a very unconventional way without giving * disabled this test in a very unconventional way without giving
* any explation. Mark as broken here, but I don't know why. */ * any explation. Mark as broken here, but I don't know why. */
atf_tc_expect_fail("Reason for breakage unknown"); atf_tc_expect_fail("Reason for breakage unknown");
#endif
#if defined(__FreeBSD__)
atf_tc_expect_fail("The expected and matched groups are mismatched on FreeBSD");
#endif #endif
att_test(tc, "leftassoc"); att_test(tc, "leftassoc");
} }

View File

@ -36,6 +36,9 @@
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
#include <unistd.h> #include <unistd.h>
#if defined(__FreeBSD__)
#include <libutil.h>
#endif
#define SKIPWS(p) while (isspace((int)(*p))) p++ #define SKIPWS(p) while (isspace((int)(*p))) p++
#define WS "\t\n " #define WS "\t\n "

View File

@ -40,6 +40,9 @@ __RCSID("$NetBSD: t_getenv.c,v 1.2 2011/07/15 13:54:31 jruoho Exp $");
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#if defined(__FreeBSD__)
#include <signal.h>
#endif
extern char **environ; extern char **environ;
@ -152,6 +155,15 @@ ATF_TC_BODY(setenv_basic, tc)
ATF_CHECK_ERRNO(EINVAL, setenv(NULL, "val", 1) == -1); ATF_CHECK_ERRNO(EINVAL, setenv(NULL, "val", 1) == -1);
ATF_CHECK_ERRNO(EINVAL, setenv("", "val", 1) == -1); ATF_CHECK_ERRNO(EINVAL, setenv("", "val", 1) == -1);
ATF_CHECK_ERRNO(EINVAL, setenv("v=r", "val", 1) == -1); ATF_CHECK_ERRNO(EINVAL, setenv("v=r", "val", 1) == -1);
#if defined(__FreeBSD__)
/*
Both FreeBSD and OS/X does not validate the second
argument to setenv(3)
*/
atf_tc_expect_signal(SIGSEGV, "FreeBSD does not validate the second "
"argument to setenv(3); see bin/189805");
#endif
ATF_CHECK_ERRNO(EINVAL, setenv("var", NULL, 1) == -1); ATF_CHECK_ERRNO(EINVAL, setenv("var", NULL, 1) == -1);
ATF_CHECK(setenv("var", "=val", 1) == 0); ATF_CHECK(setenv("var", "=val", 1) == 0);

View File

@ -75,6 +75,7 @@ __RCSID("$NetBSD: t_hsearch.c,v 1.4 2014/07/20 20:17:21 christos Exp $");
#define REQUIRE_ERRNO(x) ATF_REQUIRE_MSG(x, "%s", strerror(errno)) #define REQUIRE_ERRNO(x) ATF_REQUIRE_MSG(x, "%s", strerror(errno))
#if defined(__NetBSD__)
ATF_TC(hsearch_basic); ATF_TC(hsearch_basic);
ATF_TC_HEAD(hsearch_basic, tc) ATF_TC_HEAD(hsearch_basic, tc)
{ {
@ -123,6 +124,7 @@ ATF_TC_BODY(hsearch_basic, tc)
hdestroy1(free, NULL); hdestroy1(free, NULL);
} }
#endif
ATF_TC(hsearch_duplicate); ATF_TC(hsearch_duplicate);
ATF_TC_HEAD(hsearch_duplicate, tc) ATF_TC_HEAD(hsearch_duplicate, tc)
@ -229,6 +231,7 @@ ATF_TC_BODY(hsearch_two, tc)
hdestroy(); hdestroy();
} }
#if defined(__NetBSD__)
ATF_TC(hsearch_r_basic); ATF_TC(hsearch_r_basic);
ATF_TC_HEAD(hsearch_r_basic, tc) ATF_TC_HEAD(hsearch_r_basic, tc)
{ {
@ -276,6 +279,7 @@ ATF_TC_BODY(hsearch_r_basic, tc)
hdestroy1_r(&t, free, NULL); hdestroy1_r(&t, free, NULL);
} }
#endif
ATF_TC(hsearch_r_duplicate); ATF_TC(hsearch_r_duplicate);
ATF_TC_HEAD(hsearch_r_duplicate, tc) ATF_TC_HEAD(hsearch_r_duplicate, tc)
@ -385,12 +389,16 @@ ATF_TC_BODY(hsearch_r_two, tc)
ATF_TP_ADD_TCS(tp) ATF_TP_ADD_TCS(tp)
{ {
#if defined(__NetBSD__)
ATF_TP_ADD_TC(tp, hsearch_basic); ATF_TP_ADD_TC(tp, hsearch_basic);
#endif
ATF_TP_ADD_TC(tp, hsearch_duplicate); ATF_TP_ADD_TC(tp, hsearch_duplicate);
ATF_TP_ADD_TC(tp, hsearch_nonexistent); ATF_TP_ADD_TC(tp, hsearch_nonexistent);
ATF_TP_ADD_TC(tp, hsearch_two); ATF_TP_ADD_TC(tp, hsearch_two);
#if defined(__NetBSD__)
ATF_TP_ADD_TC(tp, hsearch_r_basic); ATF_TP_ADD_TC(tp, hsearch_r_basic);
#endif
ATF_TP_ADD_TC(tp, hsearch_r_duplicate); ATF_TP_ADD_TC(tp, hsearch_r_duplicate);
ATF_TP_ADD_TC(tp, hsearch_r_nonexistent); ATF_TP_ADD_TC(tp, hsearch_r_nonexistent);
ATF_TP_ADD_TC(tp, hsearch_r_two); ATF_TP_ADD_TC(tp, hsearch_r_two);

View File

@ -221,7 +221,9 @@ ATF_TC_BODY(strtold_nan, tc)
volatile long double ld = strtold(nan_string, &end); volatile long double ld = strtold(nan_string, &end);
ATF_REQUIRE(isnan(ld) != 0); ATF_REQUIRE(isnan(ld) != 0);
#if !defined(__FreeBSD__)
ATF_REQUIRE(__isnanl(ld) != 0); ATF_REQUIRE(__isnanl(ld) != 0);
#endif
ATF_REQUIRE(strcmp(end, "y") == 0); ATF_REQUIRE(strcmp(end, "y") == 0);
# else # else
atf_tc_skip("Requires long double support"); atf_tc_skip("Requires long double support");

View File

@ -51,7 +51,11 @@ unsigned char *start[BLOCKTYPES] = {
}; };
char result[100]; char result[100];
#if defined(__NetBSD__)
const char goodResult[] = "7b405d24bc03195474c70ddae9e1f8fb"; const char goodResult[] = "7b405d24bc03195474c70ddae9e1f8fb";
#else
const char goodResult[] = "217b4fbe456916bf62a2f85df752e4ab";
#endif
static void static void
runTest(unsigned char *b1, unsigned char *b2) runTest(unsigned char *b1, unsigned char *b2)
@ -89,7 +93,15 @@ ATF_TC_BODY(memcpy_basic, tc)
start[2] = auto1; start[2] = auto1;
start[3] = auto2; start[3] = auto2;
#if defined(__NetBSD__)
srandom(0L); srandom(0L);
#else
/*
* random() shall produce by default a sequence of numbers that can be
* duplicated by calling srandom() with 1 as the seed.
*/
srandom(1);
#endif
MD5Init(mc); MD5Init(mc);
for (i = 0; i < BLOCKTYPES; ++i) for (i = 0; i < BLOCKTYPES; ++i)
for (j = 0; j < BLOCKTYPES; ++j) for (j = 0; j < BLOCKTYPES; ++j)

View File

@ -75,8 +75,13 @@ ATF_TC_HEAD(memmem_basic, tc)
ATF_TC_BODY(memmem_basic, tc) ATF_TC_BODY(memmem_basic, tc)
{ {
#if defined(__darwin__) || defined(__FreeBSD__)
expect(memmem(b2, lb2, p0, lp0) == NULL);
expect(memmem(b0, lb0, p0, lp0) == NULL);
#else
expect(memmem(b2, lb2, p0, lp0) == b2); expect(memmem(b2, lb2, p0, lp0) == b2);
expect(memmem(b0, lb0, p0, lp0) == b0); expect(memmem(b0, lb0, p0, lp0) == b0);
#endif
expect(memmem(b0, lb0, p1, lp1) == NULL); expect(memmem(b0, lb0, p1, lp1) == NULL);
expect(memmem(b1, lb1, p1, lp1) == NULL); expect(memmem(b1, lb1, p1, lp1) == NULL);

View File

@ -37,6 +37,10 @@ __RCSID("$NetBSD: t_strerror.c,v 1.3 2011/05/10 06:55:27 jruoho Exp $");
#include <locale.h> #include <locale.h>
#include <string.h> #include <string.h>
#if defined(__FreeBSD__)
#include <stdio.h>
#endif
ATF_TC(strerror_basic); ATF_TC(strerror_basic);
ATF_TC_HEAD(strerror_basic, tc) ATF_TC_HEAD(strerror_basic, tc)
{ {

View File

@ -72,7 +72,12 @@ ATF_TC_BODY(mktime_negyear, tc)
errno = 0; errno = 0;
t = mktime(&tms); t = mktime(&tms);
#if defined(__FreeBSD__)
/* Open Group says "and may set errno to indicate the error" */
ATF_REQUIRE(t == (time_t)-1);
#else
ATF_REQUIRE_ERRNO(0, t != (time_t)-1); ATF_REQUIRE_ERRNO(0, t != (time_t)-1);
#endif
} }
ATF_TC(timegm_epoch); ATF_TC(timegm_epoch);

View File

@ -49,6 +49,17 @@ h_pass(const char *buf, const char *fmt, int len,
exp = buf + len; exp = buf + len;
ret = strptime(buf, fmt, &tm); ret = strptime(buf, fmt, &tm);
#if defined(__FreeBSD__)
ATF_CHECK_MSG(ret == exp,
"strptime(\"%s\", \"%s\", tm): incorrect return code: "
"expected: %p, got: %p", buf, fmt, exp, ret);
#define H_REQUIRE_FIELD(field) \
ATF_CHECK_MSG(tm.field == field, \
"strptime(\"%s\", \"%s\", tm): incorrect %s: " \
"expected: %d, but got: %d", buf, fmt, \
___STRING(field), field, tm.field)
#else
ATF_REQUIRE_MSG(ret == exp, ATF_REQUIRE_MSG(ret == exp,
"strptime(\"%s\", \"%s\", tm): incorrect return code: " "strptime(\"%s\", \"%s\", tm): incorrect return code: "
"expected: %p, got: %p", buf, fmt, exp, ret); "expected: %p, got: %p", buf, fmt, exp, ret);
@ -58,6 +69,7 @@ h_pass(const char *buf, const char *fmt, int len,
"strptime(\"%s\", \"%s\", tm): incorrect %s: " \ "strptime(\"%s\", \"%s\", tm): incorrect %s: " \
"expected: %d, but got: %d", buf, fmt, \ "expected: %d, but got: %d", buf, fmt, \
___STRING(field), field, tm.field) ___STRING(field), field, tm.field)
#endif
H_REQUIRE_FIELD(tm_sec); H_REQUIRE_FIELD(tm_sec);
H_REQUIRE_FIELD(tm_min); H_REQUIRE_FIELD(tm_min);
@ -76,8 +88,13 @@ h_fail(const char *buf, const char *fmt)
{ {
struct tm tm = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, NULL }; struct tm tm = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, NULL };
#if defined(__FreeBSD__)
ATF_CHECK_MSG(strptime(buf, fmt, &tm) == NULL, "strptime(\"%s\", "
"\"%s\", &tm) should fail, but it didn't", buf, fmt);
#else
ATF_REQUIRE_MSG(strptime(buf, fmt, &tm) == NULL, "strptime(\"%s\", " ATF_REQUIRE_MSG(strptime(buf, fmt, &tm) == NULL, "strptime(\"%s\", "
"\"%s\", &tm) should fail, but it didn't", buf, fmt); "\"%s\", &tm) should fail, but it didn't", buf, fmt);
#endif
} }
ATF_TC(common); ATF_TC(common);
@ -91,6 +108,10 @@ ATF_TC_HEAD(common, tc)
ATF_TC_BODY(common, tc) ATF_TC_BODY(common, tc)
{ {
#if defined(__FreeBSD__)
atf_tc_expect_fail("There are various issues with strptime on FreeBSD");
#endif
h_pass("Tue Jan 20 23:27:46 1998", "%a %b %d %T %Y", h_pass("Tue Jan 20 23:27:46 1998", "%a %b %d %T %Y",
24, 46, 27, 23, 20, 0, 98, 2, -1); 24, 46, 27, 23, 20, 0, 98, 2, -1);
h_pass("Tue Jan 20 23:27:46 1998", "%a %b %d %H:%M:%S %Y", h_pass("Tue Jan 20 23:27:46 1998", "%a %b %d %H:%M:%S %Y",
@ -168,9 +189,17 @@ ATF_TC_BODY(day, tc)
h_pass("mon", "%a", 3, -1, -1, -1, -1, -1, -1, 1, -1); h_pass("mon", "%a", 3, -1, -1, -1, -1, -1, -1, 1, -1);
h_pass("tueSDay", "%A", 7, -1, -1, -1, -1, -1, -1, 2, -1); h_pass("tueSDay", "%A", 7, -1, -1, -1, -1, -1, -1, 2, -1);
h_pass("sunday", "%A", 6, -1, -1, -1, -1, -1, -1, 0, -1); h_pass("sunday", "%A", 6, -1, -1, -1, -1, -1, -1, 0, -1);
#if defined(__NetBSD__)
h_fail("sunday", "%EA"); h_fail("sunday", "%EA");
#else
h_pass("Sunday", "%EA", 6, -1, -1, -1, -1, -1, -1, 0, -1);
#endif
h_pass("SaturDay", "%A", 8, -1, -1, -1, -1, -1, -1, 6, -1); h_pass("SaturDay", "%A", 8, -1, -1, -1, -1, -1, -1, 6, -1);
#if defined(__NetBSD__)
h_fail("SaturDay", "%OA"); h_fail("SaturDay", "%OA");
#else
h_pass("SaturDay", "%OA", 8, -1, -1, -1, -1, -1, -1, 6, -1);
#endif
} }
ATF_TC(month); ATF_TC(month);

View File

@ -36,7 +36,9 @@ __RCSID("$NetBSD: h_tls_dlopen.c,v 1.5 2013/10/21 19:14:16 joerg Exp $");
#include <atf-c.h> #include <atf-c.h>
#include <unistd.h> #include <unistd.h>
#if defined(__NetBSD__)
#include <sys/tls.h> #include <sys/tls.h>
#endif
#ifdef __HAVE_NO___THREAD #ifdef __HAVE_NO___THREAD
#define __thread #define __thread

View File

@ -39,7 +39,9 @@ __RCSID("$NetBSD: t_tls_dlopen.c,v 1.3 2012/01/17 20:34:57 joerg Exp $");
#include <pthread.h> #include <pthread.h>
#include <unistd.h> #include <unistd.h>
#if defined(__NetBSD__)
#include <sys/tls.h> #include <sys/tls.h>
#endif
#ifdef __HAVE_NO___THREAD #ifdef __HAVE_NO___THREAD
#define __thread #define __thread

View File

@ -38,7 +38,9 @@ __RCSID("$NetBSD: t_tls_dynamic.c,v 1.3 2012/01/17 20:34:57 joerg Exp $");
#include <pthread.h> #include <pthread.h>
#include <unistd.h> #include <unistd.h>
#if defined(__NetBSD__)
#include <sys/tls.h> #include <sys/tls.h>
#endif
#ifdef __HAVE_NO___THREAD #ifdef __HAVE_NO___THREAD
#define __thread #define __thread

View File

@ -37,7 +37,9 @@ __RCSID("$NetBSD: t_tls_static.c,v 1.2 2012/01/17 20:34:57 joerg Exp $");
#include <atf-c.h> #include <atf-c.h>
#include <pthread.h> #include <pthread.h>
#if defined(__NetBSD__)
#include <sys/tls.h> #include <sys/tls.h>
#endif
#ifdef __HAVE_NO___THREAD #ifdef __HAVE_NO___THREAD
#define __thread #define __thread

View File

@ -34,7 +34,9 @@
#include <sys/cdefs.h> #include <sys/cdefs.h>
__RCSID("$NetBSD: t_tls_static_helper.c,v 1.2 2012/01/17 20:34:57 joerg Exp $"); __RCSID("$NetBSD: t_tls_static_helper.c,v 1.2 2012/01/17 20:34:57 joerg Exp $");
#if defined(__NetBSD__)
#include <sys/tls.h> #include <sys/tls.h>
#endif
#ifdef __HAVE_NO___THREAD #ifdef __HAVE_NO___THREAD
#define __thread #define __thread

View File

@ -35,7 +35,9 @@
__RCSID("$NetBSD: h_tls_dynamic.c,v 1.5 2013/10/21 19:11:17 joerg Exp $"); __RCSID("$NetBSD: h_tls_dynamic.c,v 1.5 2013/10/21 19:11:17 joerg Exp $");
#include <unistd.h> #include <unistd.h>
#if defined(__NetBSD__)
#include <sys/tls.h> #include <sys/tls.h>
#endif
#ifdef __HAVE_NO___THREAD #ifdef __HAVE_NO___THREAD
#define __thread #define __thread

View File

@ -8,7 +8,7 @@ extern char *inet_cfg(); /* read inetd.conf file */
extern void inet_set(); /* remember internet service */ extern void inet_set(); /* remember internet service */
extern int inet_get(); /* look up internet service */ extern int inet_get(); /* look up internet service */
#define WR_UNKNOWN (-1) /* service unknown */ #define WR_UNKNOWN (-1) /* service unknown */
#define WR_NOT 1 /* may not be wrapped */ #define WR_NOT 1 /* may not be wrapped */
#define WR_MAYBE 2 /* may be wrapped */ #define WR_MAYBE 2 /* may be wrapped */
#define WR_YES 3 /* service is wrapped */ #define WR_YES 3 /* service is wrapped */

View File

@ -6,14 +6,14 @@
#ifdef __STDC__ #ifdef __STDC__
#include <stdarg.h> #include <stdarg.h>
#define VARARGS(func,type,arg) func(type arg, ...) #define VARARGS(func,type,arg) func(type arg, ...)
#define VASTART(ap,type,name) va_start(ap,name) #define VASTART(ap,type,name) va_start(ap,name)
#define VAEND(ap) va_end(ap) #define VAEND(ap) va_end(ap)
#else #else
#include <varargs.h> #include <varargs.h>
#define VARARGS(func,type,arg) func(va_alist) va_dcl #define VARARGS(func,type,arg) func(va_alist) va_dcl
#define VASTART(ap,type,name) {type name; va_start(ap); name = va_arg(ap, type) #define VASTART(ap,type,name) {type name; va_start(ap); name = va_arg(ap, type)
#define VAEND(ap) va_end(ap);} #define VAEND(ap) va_end(ap);}
#endif #endif
extern char *percent_m(); extern char *percent_m();

View File

@ -8,7 +8,7 @@
/* Structure to describe one communications endpoint. */ /* Structure to describe one communications endpoint. */
#define STRING_LENGTH 128 /* hosts, users, processes */ #define STRING_LENGTH 128 /* hosts, users, processes */
struct host_info { struct host_info {
char name[STRING_LENGTH]; /* access via eval_hostname(host) */ char name[STRING_LENGTH]; /* access via eval_hostname(host) */
@ -31,21 +31,21 @@ struct request_info {
char pid[10]; /* access via eval_pid(request) */ char pid[10]; /* access via eval_pid(request) */
struct host_info client[1]; /* client endpoint info */ struct host_info client[1]; /* client endpoint info */
struct host_info server[1]; /* server endpoint info */ struct host_info server[1]; /* server endpoint info */
void (*sink) (); /* datagram sink function or 0 */ void (*sink) (int); /* datagram sink function or 0 */
void (*hostname) (); /* address to printable hostname */ void (*hostname) (struct host_info *); /* address to printable hostname */
void (*hostaddr) (); /* address to printable address */ void (*hostaddr) (struct host_info *); /* address to printable address */
void (*cleanup) (); /* cleanup function or 0 */ void (*cleanup) (struct request_info *); /* cleanup function or 0 */
struct netconfig *config; /* netdir handle */ struct netconfig *config; /* netdir handle */
}; };
/* Common string operations. Less clutter should be more readable. */ /* Common string operations. Less clutter should be more readable. */
#define STRN_CPY(d,s,l) { strncpy((d),(s),(l)); (d)[(l)-1] = 0; } #define STRN_CPY(d,s,l) { strncpy((d),(s),(l)); (d)[(l)-1] = 0; }
#define STRN_EQ(x,y,l) (strncasecmp((x),(y),(l)) == 0) #define STRN_EQ(x,y,l) (strncasecmp((x),(y),(l)) == 0)
#define STRN_NE(x,y,l) (strncasecmp((x),(y),(l)) != 0) #define STRN_NE(x,y,l) (strncasecmp((x),(y),(l)) != 0)
#define STR_EQ(x,y) (strcasecmp((x),(y)) == 0) #define STR_EQ(x,y) (strcasecmp((x),(y)) == 0)
#define STR_NE(x,y) (strcasecmp((x),(y)) != 0) #define STR_NE(x,y) (strcasecmp((x),(y)) != 0)
/* /*
* Initially, all above strings have the empty value. Information that * Initially, all above strings have the empty value. Information that
@ -54,25 +54,26 @@ struct request_info {
* that we do not believe in is set to "paranoid". * that we do not believe in is set to "paranoid".
*/ */
#define STRING_UNKNOWN "unknown" /* lookup failed */ #define STRING_UNKNOWN "unknown" /* lookup failed */
#define STRING_PARANOID "paranoid" /* hostname conflict */ #define STRING_PARANOID "paranoid" /* hostname conflict */
extern char unknown[]; extern char unknown[];
extern char paranoid[]; extern char paranoid[];
#define HOSTNAME_KNOWN(s) (STR_NE((s),unknown) && STR_NE((s),paranoid)) #define HOSTNAME_KNOWN(s) (STR_NE((s),unknown) && STR_NE((s),paranoid))
#define NOT_INADDR(s) (s[strspn(s,"01234567890./")] != 0) #define NOT_INADDR(s) (s[strspn(s,"01234567890./")] != 0)
/* Global functions. */ /* Global functions. */
#if defined(TLI) || defined(PTX) || defined(TLI_SEQUENT) #if defined(TLI) || defined(PTX) || defined(TLI_SEQUENT)
extern void fromhost(); /* get/validate client host info */ extern void fromhost(); /* get/validate client host info */
#else #else
#define fromhost sock_host /* no TLI support needed */ #define fromhost sock_host /* no TLI support needed */
#endif #endif
extern int hosts_access(); /* access control */ extern int hosts_access(); /* access control */
extern int hosts_ctl(); /* wrapper around request_init() */
extern void shell_cmd(); /* execute shell command */ extern void shell_cmd(); /* execute shell command */
extern char *percent_x(); /* do %<char> expansion */ extern char *percent_x(); /* do %<char> expansion */
extern void rfc931(); /* client name from RFC 931 daemon */ extern void rfc931(); /* client name from RFC 931 daemon */
@ -105,15 +106,15 @@ extern struct request_info *request_init(); /* initialize request */
extern struct request_info *request_set(); /* update request structure */ extern struct request_info *request_set(); /* update request structure */
#endif #endif
#define RQ_FILE 1 /* file descriptor */ #define RQ_FILE 1 /* file descriptor */
#define RQ_DAEMON 2 /* server process (argv[0]) */ #define RQ_DAEMON 2 /* server process (argv[0]) */
#define RQ_USER 3 /* client user name */ #define RQ_USER 3 /* client user name */
#define RQ_CLIENT_NAME 4 /* client host name */ #define RQ_CLIENT_NAME 4 /* client host name */
#define RQ_CLIENT_ADDR 5 /* client host address */ #define RQ_CLIENT_ADDR 5 /* client host address */
#define RQ_CLIENT_SIN 6 /* client endpoint (internal) */ #define RQ_CLIENT_SIN 6 /* client endpoint (internal) */
#define RQ_SERVER_NAME 7 /* server host name */ #define RQ_SERVER_NAME 7 /* server host name */
#define RQ_SERVER_ADDR 8 /* server host address */ #define RQ_SERVER_ADDR 8 /* server host address */
#define RQ_SERVER_SIN 9 /* server endpoint (internal) */ #define RQ_SERVER_SIN 9 /* server endpoint (internal) */
/* /*
* Routines for delayed evaluation of request attributes. Each attribute * Routines for delayed evaluation of request attributes. Each attribute
@ -129,15 +130,15 @@ extern char *eval_hostaddr(); /* printable host address */
extern char *eval_hostinfo(); /* host name or address */ extern char *eval_hostinfo(); /* host name or address */
extern char *eval_client(); /* whatever is available */ extern char *eval_client(); /* whatever is available */
extern char *eval_server(); /* whatever is available */ extern char *eval_server(); /* whatever is available */
#define eval_daemon(r) ((r)->daemon) /* daemon process name */ #define eval_daemon(r) ((r)->daemon) /* daemon process name */
#define eval_pid(r) ((r)->pid) /* process id */ #define eval_pid(r) ((r)->pid) /* process id */
/* Socket-specific methods, including DNS hostname lookups. */ /* Socket-specific methods, including DNS hostname lookups. */
extern void sock_host(); /* look up endpoint addresses */ extern void sock_host(); /* look up endpoint addresses */
extern void sock_hostname(); /* translate address to hostname */ extern void sock_hostname(); /* translate address to hostname */
extern void sock_hostaddr(); /* address to printable address */ extern void sock_hostaddr(); /* address to printable address */
#define sock_methods(r) \ #define sock_methods(r) \
{ (r)->hostname = sock_hostname; (r)->hostaddr = sock_hostaddr; } { (r)->hostname = sock_hostname; (r)->hostaddr = sock_hostaddr; }
/* The System V Transport-Level Interface (TLI) interface. */ /* The System V Transport-Level Interface (TLI) interface. */
@ -173,9 +174,9 @@ extern struct tcpd_context tcpd_context;
* (-1) returns are here because zero is already taken by longjmp(). * (-1) returns are here because zero is already taken by longjmp().
*/ */
#define AC_PERMIT 1 /* permit access */ #define AC_PERMIT 1 /* permit access */
#define AC_DENY (-1) /* deny_access */ #define AC_DENY (-1) /* deny_access */
#define AC_ERROR AC_DENY /* XXX */ #define AC_ERROR AC_DENY /* XXX */
/* /*
* In verification mode an option function should just say what it would do, * In verification mode an option function should just say what it would do,
@ -190,36 +191,36 @@ extern int dry_run; /* verification flag */
/* Bug workarounds. */ /* Bug workarounds. */
#ifdef INET_ADDR_BUG /* inet_addr() returns struct */ #ifdef INET_ADDR_BUG /* inet_addr() returns struct */
#define inet_addr fix_inet_addr #define inet_addr fix_inet_addr
extern long fix_inet_addr(); extern long fix_inet_addr();
#endif #endif
#ifdef BROKEN_FGETS /* partial reads from sockets */ #ifdef BROKEN_FGETS /* partial reads from sockets */
#define fgets fix_fgets #define fgets fix_fgets
extern char *fix_fgets(); extern char *fix_fgets();
#endif #endif
#ifdef RECVFROM_BUG /* no address family info */ #ifdef RECVFROM_BUG /* no address family info */
#define recvfrom fix_recvfrom #define recvfrom fix_recvfrom
extern int fix_recvfrom(); extern int fix_recvfrom();
#endif #endif
#ifdef GETPEERNAME_BUG /* claims success with UDP */ #ifdef GETPEERNAME_BUG /* claims success with UDP */
#define getpeername fix_getpeername #define getpeername fix_getpeername
extern int fix_getpeername(); extern int fix_getpeername();
#endif #endif
#ifdef SOLARIS_24_GETHOSTBYNAME_BUG /* lists addresses as aliases */ #ifdef SOLARIS_24_GETHOSTBYNAME_BUG /* lists addresses as aliases */
#define gethostbyname fix_gethostbyname #define gethostbyname fix_gethostbyname
extern struct hostent *fix_gethostbyname(); extern struct hostent *fix_gethostbyname();
#endif #endif
#ifdef USE_STRSEP /* libc calls strtok() */ #ifdef USE_STRSEP /* libc calls strtok() */
#define strtok fix_strtok #define strtok fix_strtok
extern char *fix_strtok(); extern char *fix_strtok();
#endif #endif
#ifdef LIBC_CALLS_STRTOK /* libc calls strtok() */ #ifdef LIBC_CALLS_STRTOK /* libc calls strtok() */
#define strtok my_strtok #define strtok my_strtok
extern char *my_strtok(); extern char *my_strtok();
#endif #endif

View File

@ -1,7 +1,7 @@
#ifdef __STDC__ #ifdef __STDC__
#define __P(X) X #define __P(X) X
#else #else
#define __P(X) () #define __P(X) ()
#endif #endif
extern int t_sync __P((int)); extern int t_sync __P((int));

View File

@ -110,6 +110,7 @@ synchronous_dhclient="NO" # Start dhclient directly on configured
# interfaces during startup. # interfaces during startup.
defaultroute_delay="30" # Time to wait for a default route on a DHCP interface. defaultroute_delay="30" # Time to wait for a default route on a DHCP interface.
defaultroute_carrier_delay="5" # Time to wait for carrier while waiting for a default route. defaultroute_carrier_delay="5" # Time to wait for carrier while waiting for a default route.
netif_enable="YES" # Set to YES to initialize network interfaces
netif_ipexpand_max="2048" # Maximum number of IP addrs in a range spec. netif_ipexpand_max="2048" # Maximum number of IP addrs in a range spec.
wpa_supplicant_program="/usr/sbin/wpa_supplicant" wpa_supplicant_program="/usr/sbin/wpa_supplicant"
wpa_supplicant_flags="-s" # Extra flags to pass to wpa_supplicant wpa_supplicant_flags="-s" # Extra flags to pass to wpa_supplicant

View File

@ -71,4 +71,10 @@ notify 0 {
action "camcontrol eject cd0"; action "camcontrol eject cd0";
}; };
# Equivalent to the ACPI/ACAD notify
notify 10 {
match "system" "PMU";
match "subsystem" "POWER";
match "type" "ACLINE";
action "/etc/rc.d/power_profile $notify";
}

View File

@ -9,7 +9,7 @@
. /etc/rc.subr . /etc/rc.subr
name="background-fsck" name="background_fsck"
rcvar="background_fsck" rcvar="background_fsck"
start_cmd="bgfsck_start" start_cmd="bgfsck_start"
stop_cmd=":" stop_cmd=":"

View File

@ -33,9 +33,10 @@
. /etc/rc.subr . /etc/rc.subr
. /etc/network.subr . /etc/network.subr
name="network" name="netif"
start_cmd="network_start" rcvar="${name}_enable"
stop_cmd="network_stop" start_cmd="netif_start"
stop_cmd="netif_stop"
cloneup_cmd="clone_up" cloneup_cmd="clone_up"
clonedown_cmd="clone_down" clonedown_cmd="clone_down"
clear_cmd="doclear" clear_cmd="doclear"
@ -47,7 +48,7 @@ cmdifn=
set_rcvar_obsolete ipv6_enable ipv6_activate_all_interfaces set_rcvar_obsolete ipv6_enable ipv6_activate_all_interfaces
set_rcvar_obsolete ipv6_prefer set_rcvar_obsolete ipv6_prefer
network_start() netif_start()
{ {
local _if local _if
@ -71,7 +72,7 @@ network_start()
ifnet_rename $cmdifn ifnet_rename $cmdifn
# Configure the interface(s). # Configure the interface(s).
network_common ifn_start $cmdifn netif_common ifn_start $cmdifn
if [ -f /etc/rc.d/ipfilter ] ; then if [ -f /etc/rc.d/ipfilter ] ; then
# Resync ipfilter # Resync ipfilter
@ -87,19 +88,19 @@ network_start()
fi fi
} }
network_stop() netif_stop()
{ {
_clone_down=1 _clone_down=1
network_stop0 $* netif_stop0 $*
} }
doclear() doclear()
{ {
_clone_down= _clone_down=
network_stop0 $* netif_stop0 $*
} }
network_stop0() netif_stop0()
{ {
local _if local _if
@ -108,7 +109,7 @@ network_stop0()
cmdifn=$* cmdifn=$*
# Deconfigure the interface(s) # Deconfigure the interface(s)
network_common ifn_stop $cmdifn netif_common ifn_stop $cmdifn
# Destroy cloned interfaces # Destroy cloned interfaces
if [ -n "$_clone_down" ]; then if [ -n "$_clone_down" ]; then
@ -126,28 +127,28 @@ vnet_up()
{ {
cmdifn=$* cmdifn=$*
network_common ifn_vnetup $cmdifn netif_common ifn_vnetup $cmdifn
} }
vnet_down() vnet_down()
{ {
cmdifn=$* cmdifn=$*
network_common ifn_vnetdown $cmdifn netif_common ifn_vnetdown $cmdifn
} }
# network_common routine # netif_common routine
# Common configuration subroutine for network interfaces. This # Common configuration subroutine for network interfaces. This
# routine takes all the preparatory steps needed for configuriing # routine takes all the preparatory steps needed for configuriing
# an interface and then calls $routine. # an interface and then calls $routine.
network_common() netif_common()
{ {
local _cooked_list _tmp_list _fail _func _ok _str _cmdifn local _cooked_list _tmp_list _fail _func _ok _str _cmdifn
_func= _func=
if [ -z "$1" ]; then if [ -z "$1" ]; then
err 1 "network_common(): No function name specified." err 1 "netif_common(): No function name specified."
else else
_func="$1" _func="$1"
shift shift

View File

@ -749,6 +749,8 @@ check_startmsgs()
# NOTE: $flags from the parent environment # NOTE: $flags from the parent environment
# can be used to override this. # can be used to override this.
# #
# ${name}_env n Environment variables to run ${command} with.
#
# ${name}_fib n Routing table number to run ${command} with. # ${name}_fib n Routing table number to run ${command} with.
# #
# ${name}_nice n Nice level to run ${command} at. # ${name}_nice n Nice level to run ${command} at.
@ -764,6 +766,8 @@ check_startmsgs()
# to run the chrooted ${command} with. # to run the chrooted ${command} with.
# Requires /usr to be mounted. # Requires /usr to be mounted.
# #
# ${name}_prepend n Command added before ${command}.
#
# ${rc_arg}_cmd n If set, use this as the method when invoked; # ${rc_arg}_cmd n If set, use this as the method when invoked;
# Otherwise, use default command (see below) # Otherwise, use default command (see below)
# #
@ -937,7 +941,8 @@ run_rc_command()
eval _chdir=\$${name}_chdir _chroot=\$${name}_chroot \ eval _chdir=\$${name}_chdir _chroot=\$${name}_chroot \
_nice=\$${name}_nice _user=\$${name}_user \ _nice=\$${name}_nice _user=\$${name}_user \
_group=\$${name}_group _groups=\$${name}_groups \ _group=\$${name}_group _groups=\$${name}_groups \
_fib=\$${name}_fib _fib=\$${name}_fib _env=\$${name}_env \
_prepend=\$${name}_prepend
if [ -n "$_user" ]; then # unset $_user if running as that user if [ -n "$_user" ]; then # unset $_user if running as that user
if [ "$_user" = "$(eval $IDCMD)" ]; then if [ "$_user" = "$(eval $IDCMD)" ]; then
@ -1022,12 +1027,14 @@ run_rc_command()
_doit="\ _doit="\
${_nice:+nice -n $_nice }\ ${_nice:+nice -n $_nice }\
${_fib:+setfib -F $_fib }\ ${_fib:+setfib -F $_fib }\
${_env:+env $_env }\
chroot ${_user:+-u $_user }${_group:+-g $_group }${_groups:+-G $_groups }\ chroot ${_user:+-u $_user }${_group:+-g $_group }${_groups:+-G $_groups }\
$_chroot $command $rc_flags $command_args" $_chroot $command $rc_flags $command_args"
else else
_doit="\ _doit="\
${_chdir:+cd $_chdir && }\ ${_chdir:+cd $_chdir && }\
${_fib:+setfib -F $_fib }\ ${_fib:+setfib -F $_fib }\
${_env:+env $_env }\
$command $rc_flags $command_args" $command $rc_flags $command_args"
if [ -n "$_user" ]; then if [ -n "$_user" ]; then
_doit="su -m $_user -c 'sh -c \"$_doit\"'" _doit="su -m $_user -c 'sh -c \"$_doit\"'"
@ -1038,6 +1045,9 @@ $command $rc_flags $command_args"
fi fi
_doit="nice -n $_nice $_doit" _doit="nice -n $_nice $_doit"
fi fi
if [ -n "$_prepend" ]; then
_doit="$_prepend $_doit"
fi
fi fi
# run the full command # run the full command
@ -2040,7 +2050,7 @@ check_kern_features()
# check_namevarlist var # check_namevarlist var
# Return "0" if ${name}_var is reserved in rc.subr. # Return "0" if ${name}_var is reserved in rc.subr.
_rc_namevarlist="program chroot chdir flags fib nice user group groups" _rc_namevarlist="program chroot chdir env flags fib nice user group groups prepend"
check_namevarlist() check_namevarlist()
{ {
local _v local _v

View File

@ -44,6 +44,7 @@ SUBDIR= ${SUBDIR_ORDERED} \
libdevstat \ libdevstat \
libdwarf \ libdwarf \
libedit \ libedit \
${_libevent} \
libexecinfo \ libexecinfo \
libexpat \ libexpat \
libfetch \ libfetch \
@ -226,6 +227,10 @@ _libnetgraph= libnetgraph
_libypclnt= libypclnt _libypclnt= libypclnt
.endif .endif
.if ${MK_PF} != "no"
_libevent= libevent
.endif
.if ${MACHINE_CPUARCH} == "i386" || ${MACHINE_CPUARCH} == "amd64" .if ${MACHINE_CPUARCH} == "i386" || ${MACHINE_CPUARCH} == "amd64"
_libsmb= libsmb _libsmb= libsmb
_libvgl= libvgl _libvgl= libvgl

View File

@ -87,17 +87,11 @@ static TAILQ_HEAD(, cuse_dev_entered) h_cuse_entered __guarded_by(m_cuse);
static struct cuse_vm_allocation a_cuse[CUSE_ALLOC_UNIT_MAX] static struct cuse_vm_allocation a_cuse[CUSE_ALLOC_UNIT_MAX]
__guarded_by(m_cuse); __guarded_by(m_cuse);
static void #define CUSE_LOCK() \
cuse_lock(void) __locks_exclusive(m_cuse) pthread_mutex_lock(&m_cuse)
{
pthread_mutex_lock(&m_cuse);
}
static void #define CUSE_UNLOCK() \
cuse_unlock(void) __unlocks(m_cuse) pthread_mutex_unlock(&m_cuse)
{
pthread_mutex_unlock(&m_cuse);
}
int int
cuse_init(void) cuse_init(void)
@ -150,7 +144,7 @@ cuse_vmoffset(void *_ptr)
unsigned long remainder; unsigned long remainder;
int n; int n;
cuse_lock(); CUSE_LOCK();
for (n = 0; n != CUSE_ALLOC_UNIT_MAX; n++) { for (n = 0; n != CUSE_ALLOC_UNIT_MAX; n++) {
if (a_cuse[n].ptr == NULL) if (a_cuse[n].ptr == NULL)
continue; continue;
@ -160,7 +154,7 @@ cuse_vmoffset(void *_ptr)
if ((ptr >= ptr_min) && (ptr <= ptr_max)) { if ((ptr >= ptr_min) && (ptr <= ptr_max)) {
cuse_unlock(); CUSE_UNLOCK();
remainder = (ptr - ptr_min); remainder = (ptr - ptr_min);
@ -169,7 +163,7 @@ cuse_vmoffset(void *_ptr)
return ((n * PAGE_SIZE * CUSE_ALLOC_PAGES_MAX) + remainder); return ((n * PAGE_SIZE * CUSE_ALLOC_PAGES_MAX) + remainder);
} }
} }
cuse_unlock(); CUSE_UNLOCK();
return (0x80000000UL); /* failure */ return (0x80000000UL); /* failure */
} }
@ -192,7 +186,7 @@ cuse_vmalloc(int size)
info.page_count = (size + PAGE_SIZE - 1) / PAGE_SIZE; info.page_count = (size + PAGE_SIZE - 1) / PAGE_SIZE;
cuse_lock(); CUSE_LOCK();
for (n = 0; n != CUSE_ALLOC_UNIT_MAX; n++) { for (n = 0; n != CUSE_ALLOC_UNIT_MAX; n++) {
if (a_cuse[n].ptr != NULL) if (a_cuse[n].ptr != NULL)
@ -201,7 +195,7 @@ cuse_vmalloc(int size)
a_cuse[n].ptr = ((uint8_t *)1); /* reserve */ a_cuse[n].ptr = ((uint8_t *)1); /* reserve */
a_cuse[n].size = 0; a_cuse[n].size = 0;
cuse_unlock(); CUSE_UNLOCK();
info.alloc_nr = n; info.alloc_nr = n;
@ -209,7 +203,7 @@ cuse_vmalloc(int size)
if (error) { if (error) {
cuse_lock(); CUSE_LOCK();
a_cuse[n].ptr = NULL; a_cuse[n].ptr = NULL;
@ -230,20 +224,20 @@ cuse_vmalloc(int size)
if (error) { if (error) {
/* ignore */ /* ignore */
} }
cuse_lock(); CUSE_LOCK();
a_cuse[n].ptr = NULL; a_cuse[n].ptr = NULL;
break; break;
} }
cuse_lock(); CUSE_LOCK();
a_cuse[n].ptr = ptr; a_cuse[n].ptr = ptr;
a_cuse[n].size = size; a_cuse[n].size = size;
cuse_unlock(); CUSE_UNLOCK();
return (ptr); /* success */ return (ptr); /* success */
} }
cuse_unlock(); CUSE_UNLOCK();
return (NULL); /* failure */ return (NULL); /* failure */
} }
@ -255,12 +249,12 @@ cuse_is_vmalloc_addr(void *ptr)
if (f_cuse < 0 || ptr == NULL) if (f_cuse < 0 || ptr == NULL)
return (0); /* false */ return (0); /* false */
cuse_lock(); CUSE_LOCK();
for (n = 0; n != CUSE_ALLOC_UNIT_MAX; n++) { for (n = 0; n != CUSE_ALLOC_UNIT_MAX; n++) {
if (a_cuse[n].ptr == ptr) if (a_cuse[n].ptr == ptr)
break; break;
} }
cuse_unlock(); CUSE_UNLOCK();
return (n != CUSE_ALLOC_UNIT_MAX); return (n != CUSE_ALLOC_UNIT_MAX);
} }
@ -268,6 +262,7 @@ cuse_is_vmalloc_addr(void *ptr)
void void
cuse_vmfree(void *ptr) cuse_vmfree(void *ptr)
{ {
struct cuse_vm_allocation temp;
struct cuse_alloc_info info; struct cuse_alloc_info info;
int error; int error;
int n; int n;
@ -275,32 +270,35 @@ cuse_vmfree(void *ptr)
if (f_cuse < 0) if (f_cuse < 0)
return; return;
memset(&info, 0, sizeof(info)); CUSE_LOCK();
cuse_lock();
for (n = 0; n != CUSE_ALLOC_UNIT_MAX; n++) { for (n = 0; n != CUSE_ALLOC_UNIT_MAX; n++) {
if (a_cuse[n].ptr != ptr) if (a_cuse[n].ptr != ptr)
continue; continue;
cuse_unlock(); temp = a_cuse[n];
CUSE_UNLOCK();
munmap(temp.ptr, temp.size);
memset(&info, 0, sizeof(info));
info.alloc_nr = n; info.alloc_nr = n;
munmap(ptr, a_cuse[n].size);
error = ioctl(f_cuse, CUSE_IOCTL_FREE_MEMORY, &info); error = ioctl(f_cuse, CUSE_IOCTL_FREE_MEMORY, &info);
if (error) { if (error != 0) {
/* ignore */ /* ignore any errors */
DPRINTF("Freeing memory failed: %d\n", errno);
} }
cuse_lock(); CUSE_LOCK();
a_cuse[n].ptr = NULL; a_cuse[n].ptr = NULL;
a_cuse[n].size = 0; a_cuse[n].size = 0;
break; break;
} }
cuse_unlock(); CUSE_UNLOCK();
} }
int int
@ -407,9 +405,9 @@ cuse_dev_create(const struct cuse_methods *mtod, void *priv0, void *priv1,
free(cdev); free(cdev);
return (NULL); return (NULL);
} }
cuse_lock(); CUSE_LOCK();
TAILQ_INSERT_TAIL(&h_cuse, cdev, entry); TAILQ_INSERT_TAIL(&h_cuse, cdev, entry);
cuse_unlock(); CUSE_UNLOCK();
return (cdev); return (cdev);
} }
@ -423,9 +421,9 @@ cuse_dev_destroy(struct cuse_dev *cdev)
if (f_cuse < 0) if (f_cuse < 0)
return; return;
cuse_lock(); CUSE_LOCK();
TAILQ_REMOVE(&h_cuse, cdev, entry); TAILQ_REMOVE(&h_cuse, cdev, entry);
cuse_unlock(); CUSE_UNLOCK();
error = ioctl(f_cuse, CUSE_IOCTL_DESTROY_DEV, &cdev); error = ioctl(f_cuse, CUSE_IOCTL_DESTROY_DEV, &cdev);
if (error) if (error)
@ -477,7 +475,7 @@ cuse_wait_and_process(void)
cdev = info.dev; cdev = info.dev;
cuse_lock(); CUSE_LOCK();
enter.thread = curr; enter.thread = curr;
enter.per_file_handle = (void *)info.per_file_handle; enter.per_file_handle = (void *)info.per_file_handle;
enter.cmd = info.command; enter.cmd = info.command;
@ -485,7 +483,7 @@ cuse_wait_and_process(void)
enter.got_signal = 0; enter.got_signal = 0;
enter.cdev = cdev; enter.cdev = cdev;
TAILQ_INSERT_TAIL(&h_cuse_entered, &enter, entry); TAILQ_INSERT_TAIL(&h_cuse_entered, &enter, entry);
cuse_unlock(); CUSE_UNLOCK();
DPRINTF("cuse: Command = %d = %s, flags = %d, arg = 0x%08x, ptr = 0x%08x\n", DPRINTF("cuse: Command = %d = %s, flags = %d, arg = 0x%08x, ptr = 0x%08x\n",
(int)info.command, cuse_cmd_str(info.command), (int)info.fflags, (int)info.command, cuse_cmd_str(info.command), (int)info.fflags,
@ -507,7 +505,7 @@ cuse_wait_and_process(void)
error = 0; error = 0;
cuse_lock(); CUSE_LOCK();
TAILQ_FOREACH(pe, &h_cuse_entered, entry) { TAILQ_FOREACH(pe, &h_cuse_entered, entry) {
if (pe->cdev != cdev) if (pe->cdev != cdev)
continue; continue;
@ -520,7 +518,7 @@ cuse_wait_and_process(void)
pthread_kill(pe->thread, SIGHUP); pthread_kill(pe->thread, SIGHUP);
error = CUSE_ERR_BUSY; error = CUSE_ERR_BUSY;
} }
cuse_unlock(); CUSE_UNLOCK();
if (error == 0) if (error == 0)
break; break;
@ -571,7 +569,7 @@ cuse_wait_and_process(void)
break; break;
case CUSE_CMD_SIGNAL: case CUSE_CMD_SIGNAL:
cuse_lock(); CUSE_LOCK();
TAILQ_FOREACH(pe, &h_cuse_entered, entry) { TAILQ_FOREACH(pe, &h_cuse_entered, entry) {
if (pe->cdev != cdev) if (pe->cdev != cdev)
continue; continue;
@ -583,7 +581,7 @@ cuse_wait_and_process(void)
pe->got_signal = 1; pe->got_signal = 1;
pthread_kill(pe->thread, SIGHUP); pthread_kill(pe->thread, SIGHUP);
} }
cuse_unlock(); CUSE_UNLOCK();
break; break;
default: default:
@ -594,9 +592,9 @@ cuse_wait_and_process(void)
DPRINTF("cuse: Command error = %d for %s\n", DPRINTF("cuse: Command error = %d for %s\n",
error, cuse_cmd_str(info.command)); error, cuse_cmd_str(info.command));
cuse_lock(); CUSE_LOCK();
TAILQ_REMOVE(&h_cuse_entered, &enter, entry); TAILQ_REMOVE(&h_cuse_entered, &enter, entry);
cuse_unlock(); CUSE_UNLOCK();
/* we ignore any sync command failures */ /* we ignore any sync command failures */
ioctl(f_cuse, CUSE_IOCTL_SYNC_COMMAND, &error); ioctl(f_cuse, CUSE_IOCTL_SYNC_COMMAND, &error);
@ -610,12 +608,12 @@ cuse_dev_get_entered(void)
struct cuse_dev_entered *pe; struct cuse_dev_entered *pe;
pthread_t curr = pthread_self(); pthread_t curr = pthread_self();
cuse_lock(); CUSE_LOCK();
TAILQ_FOREACH(pe, &h_cuse_entered, entry) { TAILQ_FOREACH(pe, &h_cuse_entered, entry) {
if (pe->thread == curr) if (pe->thread == curr)
break; break;
} }
cuse_unlock(); CUSE_UNLOCK();
return (pe); return (pe);
} }

View File

@ -1,10 +1,14 @@
# $FreeBSD$ # $FreeBSD$
.PATH: ${.CURDIR}/../../../contrib/pf/libevent .PATH: ${.CURDIR}/../../contrib/pf/libevent
.include <src.opts.mk>
LIB= event
SHLIB_MAJOR= 1
PRIVATELIB=
INTERNALLIB=
LIB= event
INTERNALLIB=yes
SRCS= buffer.c evbuffer.c event.c kqueue.c log.c poll.c select.c signal.c SRCS= buffer.c evbuffer.c event.c kqueue.c log.c poll.c select.c signal.c
HDRS= event.h HDRS= event.h

View File

@ -2111,13 +2111,19 @@ static int
do_range_cmd(int cmd, ipfw_range_tlv *rt) do_range_cmd(int cmd, ipfw_range_tlv *rt)
{ {
ipfw_range_header rh; ipfw_range_header rh;
size_t sz;
memset(&rh, 0, sizeof(rh)); memset(&rh, 0, sizeof(rh));
memcpy(&rh.range, rt, sizeof(*rt)); memcpy(&rh.range, rt, sizeof(*rt));
rh.range.head.length = sizeof(*rt); rh.range.head.length = sizeof(*rt);
rh.range.head.type = IPFW_TLV_RANGE; rh.range.head.type = IPFW_TLV_RANGE;
sz = sizeof(rh);
return (do_set3(cmd, &rh.opheader, sizeof(rh))); if (do_get3(cmd, &rh.opheader, &sz) != 0)
return (-1);
/* Save number of matched objects */
rt->new_set = rh.range.new_set;
return (0);
} }
/* /*
@ -2580,7 +2586,7 @@ ipfw_show_config(struct cmdline_opts *co, struct format_opts *fo,
list_static_range(co, fo, &bp, rbase, rcnt); list_static_range(co, fo, &bp, rbase, rcnt);
if (co->do_dynamic && dynsz > 0) { if (co->do_dynamic && dynsz > 0) {
printf("## Dynamic rules (%d %lu):\n", fo->dcnt, dynsz); printf("## Dynamic rules (%d %zu):\n", fo->dcnt, dynsz);
list_dyn_range(co, fo, &bp, dynbase, dynsz); list_dyn_range(co, fo, &bp, dynbase, dynsz);
} }
@ -3003,7 +3009,6 @@ fill_flags_cmd(ipfw_insn *cmd, enum ipfw_opcodes opcode,
void void
ipfw_delete(char *av[]) ipfw_delete(char *av[])
{ {
uint32_t rulenum;
int i; int i;
int exitval = EX_OK; int exitval = EX_OK;
int do_set = 0; int do_set = 0;
@ -3053,7 +3058,15 @@ ipfw_delete(char *av[])
if (i != 0) { if (i != 0) {
exitval = EX_UNAVAILABLE; exitval = EX_UNAVAILABLE;
warn("rule %u: setsockopt(IP_FW_XDEL)", warn("rule %u: setsockopt(IP_FW_XDEL)",
rulenum); rt.start_rule);
} else if (rt.new_set == 0) {
exitval = EX_UNAVAILABLE;
if (rt.start_rule != rt.end_rule)
warnx("no rules rules in %u-%u range",
rt.start_rule, rt.end_rule);
else
warnx("rule %u not found",
rt.start_rule);
} }
} }
} }
@ -4792,6 +4805,9 @@ ipfw_zero(int ac, char *av[], int optname)
warn("rule %u: setsockopt(IP_FW_X%s)", warn("rule %u: setsockopt(IP_FW_X%s)",
arg, name); arg, name);
failed = EX_UNAVAILABLE; failed = EX_UNAVAILABLE;
} else if (rt.new_set == 0) {
printf("Entry %d not found\n", arg);
failed = EX_UNAVAILABLE;
} else if (!co.do_quiet) } else if (!co.do_quiet)
printf("Entry %d %s.\n", arg, printf("Entry %d %s.\n", arg,
optname == IP_FW_XZERO ? optname == IP_FW_XZERO ?
@ -4799,6 +4815,7 @@ ipfw_zero(int ac, char *av[], int optname)
} else { } else {
errx(EX_USAGE, "invalid rule number ``%s''", *av); errx(EX_USAGE, "invalid rule number ``%s''", *av);
} }
av++; ac--;
} }
if (failed != EX_OK) if (failed != EX_OK)
exit(failed); exit(failed);

View File

@ -13,7 +13,7 @@
* *
* in-kernel ipfw tables support. * in-kernel ipfw tables support.
* *
* $FreeBSD: projects/ipfw/sbin/ipfw/ipfw2.c 267467 2014-06-14 10:58:39Z melifaro $ * $FreeBSD$
*/ */
@ -1908,7 +1908,7 @@ ipfw_list_values(int ac, char *av[])
for (i = 0; i < olh->count; i++) { for (i = 0; i < olh->count; i++) {
table_show_value(buf, sizeof(buf), (ipfw_table_value *)v, table_show_value(buf, sizeof(buf), (ipfw_table_value *)v,
vmask, 0); vmask, 0);
printf("[%u] refs=%lu %s\n", v->spare1, v->refcnt, buf); printf("[%u] refs=%ju %s\n", v->spare1, v->refcnt, buf);
v = (struct _table_value *)((caddr_t)v + olh->objsize); v = (struct _table_value *)((caddr_t)v + olh->objsize);
} }

View File

@ -24,7 +24,7 @@
.\" .\"
.\" $FreeBSD$ .\" $FreeBSD$
.\" .\"
.Dd August 9, 2010 .Dd October 9, 2014
.Dt ISCONTROL 8 .Dt ISCONTROL 8
.Os .Os
.Sh NAME .Sh NAME
@ -41,6 +41,15 @@
.Op Fl t Ar target .Op Fl t Ar target
.Op Ar variable Ns = Ns Ar value .Op Ar variable Ns = Ns Ar value
.Sh DESCRIPTION .Sh DESCRIPTION
.Bf -symbolic
This command, along with its kernel counterpart
.Xr iscsi_initiator 4 ,
is obsolete.
Users are advised to use
.Xr iscsictl 8
instead.
.Ef
.Pp
Internet SCSI (iSCSI) is a network protocol standard, that allows the Internet SCSI (iSCSI) is a network protocol standard, that allows the
use of the SCSI protocol over TCP/IP networks, use of the SCSI protocol over TCP/IP networks,
the the

View File

@ -24,7 +24,7 @@
.\" .\"
.\" $FreeBSD$ .\" $FreeBSD$
.\" .\"
.Dd August 3, 2010 .Dd October 9, 2014
.Dt ISCSI_INITIATOR 4 .Dt ISCSI_INITIATOR 4
.Os .Os
.Sh NAME .Sh NAME
@ -45,6 +45,16 @@ module at boot time, place the following line in
iscsi_initiator_load="YES" iscsi_initiator_load="YES"
.Ed .Ed
.Sh DESCRIPTION .Sh DESCRIPTION
.Bf -symbolic
This driver, along with its userspace counterpart
.Xr iscontrol 8 ,
is obsolete.
Users are advised to use
.Xr iscsi 4
instead.
.Ef
.Pp
The The
.Nm .Nm
implements the kernel side of the Internet SCSI (iSCSI) network implements the kernel side of the Internet SCSI (iSCSI) network

View File

@ -34,7 +34,7 @@
.\" From: @(#)tcp.4 8.1 (Berkeley) 6/5/93 .\" From: @(#)tcp.4 8.1 (Berkeley) 6/5/93
.\" $FreeBSD$ .\" $FreeBSD$
.\" .\"
.Dd November 8, 2013 .Dd October 13, 2014
.Dt TCP 4 .Dt TCP 4
.Os .Os
.Sh NAME .Sh NAME
@ -518,6 +518,21 @@ avoid packet drops.
Number of retries (SYN or SYN/ACK retransmits) before disabling ECN on a Number of retries (SYN or SYN/ACK retransmits) before disabling ECN on a
specific connection. This is needed to help with connection establishment specific connection. This is needed to help with connection establishment
when a broken firewall is in the network path. when a broken firewall is in the network path.
.It Va pmtud_blackhole_detection
Turn on automatic path MTU blackhole detection. In case of retransmits we will
lower the MSS to check if it's MTU problem. If current MSS is greater than
configured value to try, it will be set to it, otherwise, MSS will be set to
default values (net.inet.tcp.mssdflt and net.inet.tcp.v6mssdflt).
.It Va pmtud_blackhole_mss
MSS to try for IPv4 if PMTU blackhole detection is turned on.
.It Va v6pmtud_blackhole_mss
MSS to try for IPv6 if PMTU blackhole detection is turned on.
.It Va pmtud_blackhole_activated
Number of times the code was activated to attempt a MSS downshift.
.It Va pmtud_blackhole_min_activated
Number of times the blackhole MSS was used in an attempt to downshift.
.It Va pmtud_blackhole_failed
Number of times that we failed to connect after we downshifted the MSS.
.El .El
.Sh ERRORS .Sh ERRORS
A socket operation may fail with one of the following errors returned: A socket operation may fail with one of the following errors returned:

View File

@ -29,7 +29,7 @@
.\" .\"
.\" $FreeBSD$ .\" $FreeBSD$
.\" .\"
.Dd September 23, 2012 .Dd October 12, 2014
.Dt RC.SUBR 8 .Dt RC.SUBR 8
.Os .Os
.Sh NAME .Sh NAME
@ -568,6 +568,22 @@ to before running
Only supported after Only supported after
.Pa /usr .Pa /usr
is mounted. is mounted.
.It Va ${name}_env
A list of environment variables to run
.Va command
with.
This will be passed as arguments to
.Xr env 1
utility.
.It Va ${name}_fib
FIB
.Pa Routing Table
number to run
.Va command
with.
See
.Xr setfib 1
for more details.
.It Va ${name}_flags .It Va ${name}_flags
Arguments to call Arguments to call
.Va command .Va command
@ -622,6 +638,14 @@ as.
Comma separated list of supplementary groups to run the chrooted Comma separated list of supplementary groups to run the chrooted
.Va command .Va command
with. with.
.It Va ${name}_prepend
Commands to be prepended to
.Va command .
This is a generic version of
.Va ${name}_env ,
.Va ${name}_fib ,
or
.Va ${name}_nice .
.It Ar argument Ns Va _cmd .It Ar argument Ns Va _cmd
Shell commands which override the default method for Shell commands which override the default method for
.Ar argument . .Ar argument .

View File

@ -43,7 +43,7 @@ PROG ?= $t
.if defined(PROG) .if defined(PROG)
# just one of many # just one of many
PROG_OVERRIDE_VARS += BINDIR MAN SRCS PROG_OVERRIDE_VARS += BINDIR MAN SRCS
PROG_VARS += CFLAGS CPPFLAGS CXXFLAGS DPADD DPLIBS LDADD ${PROG_OVERRIDE_VARS} PROG_VARS += CFLAGS CPPFLAGS CXXFLAGS DPADD DPLIBS LDADD LDFLAGS ${PROG_OVERRIDE_VARS}
.for v in ${PROG_VARS:O:u} .for v in ${PROG_VARS:O:u}
.if empty(${PROG_OVERRIDE_VARS:M$v}) .if empty(${PROG_OVERRIDE_VARS:M$v})
.if defined(${v}.${PROG}) .if defined(${v}.${PROG})

View File

@ -21,6 +21,10 @@ LIBBSDSTATDIR= ${ROOTOBJDIR}/lib/libbsdstat
LDBSDSTAT?= ${LIBBSDSTATDIR}/libbsdstat.so LDBSDSTAT?= ${LIBBSDSTATDIR}/libbsdstat.so
LIBBSDSTAT?= ${LIBBSDSTATDIR}/libbsdstat.a LIBBSDSTAT?= ${LIBBSDSTATDIR}/libbsdstat.a
LIBEVENTDIR= ${ROOTOBJDIR}/lib/libevent
LDEVENT?= ${LIBEVENTDIR}/libevent.so
LIBEVENT?= ${LIBEVENTDIR}/libevent.a
LIBHEIMIPCCDIR= ${ROOTOBJDIR}/kerberos5/lib/libheimipcc LIBHEIMIPCCDIR= ${ROOTOBJDIR}/kerberos5/lib/libheimipcc
LDHEIMIPCC?= ${LIBHEIMIPCCDIR}/libheimipcc.so LDHEIMIPCC?= ${LIBHEIMIPCCDIR}/libheimipcc.so
LIBHEIMIPCC?= ${LIBHEIMIPCCDIR}/libheimipcc.a LIBHEIMIPCC?= ${LIBHEIMIPCCDIR}/libheimipcc.a

View File

@ -17,6 +17,7 @@ arm/altera/socfpga/socfpga_common.c standard
arm/altera/socfpga/socfpga_machdep.c standard arm/altera/socfpga/socfpga_machdep.c standard
arm/altera/socfpga/socfpga_manager.c standard arm/altera/socfpga/socfpga_manager.c standard
arm/altera/socfpga/socfpga_rstmgr.c standard arm/altera/socfpga/socfpga_rstmgr.c standard
arm/altera/socfpga/socfpga_mp.c optional smp
dev/dwc/if_dwc.c optional dwc dev/dwc/if_dwc.c optional dwc
dev/mmc/host/dwmmc.c optional dwmmc dev/mmc/host/dwmmc.c optional dwmmc

View File

@ -92,6 +92,9 @@ platform_devmap_init(void)
/* dwmmc */ /* dwmmc */
arm_devmap_add_entry(0xff700000, 0x100000); arm_devmap_add_entry(0xff700000, 0x100000);
/* scu */
arm_devmap_add_entry(0xfff00000, 0x100000);
return (0); return (0);
} }

View File

@ -0,0 +1,180 @@
/*-
* Copyright (c) 2014 Ruslan Bukin <br@bsdpad.com>
* All rights reserved.
*
* This software was developed by SRI International and the University of
* Cambridge Computer Laboratory under DARPA/AFRL contract (FA8750-10-C-0237)
* ("CTSRD"), as part of the DARPA CRASH research programme.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/bus.h>
#include <sys/kernel.h>
#include <sys/lock.h>
#include <sys/mutex.h>
#include <sys/smp.h>
#include <machine/smp.h>
#include <machine/fdt.h>
#include <machine/intr.h>
#define SCU_PHYSBASE 0xFFFEC000
#define SCU_SIZE 0x100
#define SCU_CONTROL_REG 0x00
#define SCU_CONTROL_ENABLE (1 << 0)
#define SCU_CONFIG_REG 0x04
#define SCU_CONFIG_REG_NCPU_MASK 0x03
#define SCU_CPUPOWER_REG 0x08
#define SCU_INV_TAGS_REG 0x0c
#define SCU_DIAG_CONTROL 0x30
#define SCU_DIAG_DISABLE_MIGBIT (1 << 0)
#define SCU_FILTER_START_REG 0x40
#define SCU_FILTER_END_REG 0x44
#define SCU_SECURE_ACCESS_REG 0x50
#define SCU_NONSECURE_ACCESS_REG 0x54
#define RSTMGR_PHYSBASE 0xFFD05000
#define RSTMGR_SIZE 0x100
#define MPUMODRST 0x10
#define MPUMODRST_CPU1 (1 << 1)
#define RAM_PHYSBASE 0x0
#define RAM_SIZE 0x1000
extern char *mpentry_addr;
static void socfpga_trampoline(void);
static void
socfpga_trampoline(void)
{
__asm __volatile(
"ldr pc, 1f\n"
".globl mpentry_addr\n"
"mpentry_addr:\n"
"1: .space 4\n");
}
void
platform_mp_init_secondary(void)
{
gic_init_secondary();
}
void
platform_mp_setmaxid(void)
{
int hwcpu, ncpu;
/* If we've already set this don't bother to do it again. */
if (mp_ncpus != 0)
return;
hwcpu = 2;
ncpu = hwcpu;
TUNABLE_INT_FETCH("hw.ncpu", &ncpu);
if (ncpu < 1 || ncpu > hwcpu)
ncpu = hwcpu;
mp_ncpus = ncpu;
mp_maxid = ncpu - 1;
}
int
platform_mp_probe(void)
{
if (mp_ncpus == 0)
platform_mp_setmaxid();
return (mp_ncpus > 1);
}
void
platform_mp_start_ap(void)
{
bus_space_handle_t scu, rst, ram;
int reg;
if (bus_space_map(fdtbus_bs_tag, SCU_PHYSBASE,
SCU_SIZE, 0, &scu) != 0)
panic("Couldn't map the SCU\n");
if (bus_space_map(fdtbus_bs_tag, RSTMGR_PHYSBASE,
RSTMGR_SIZE, 0, &rst) != 0)
panic("Couldn't map the reset manager (RSTMGR)\n");
if (bus_space_map(fdtbus_bs_tag, RAM_PHYSBASE,
RAM_SIZE, 0, &ram) != 0)
panic("Couldn't map the first physram page\n");
/* Invalidate SCU cache tags */
bus_space_write_4(fdtbus_bs_tag, scu,
SCU_INV_TAGS_REG, 0x0000ffff);
/*
* Erratum ARM/MP: 764369 (problems with cache maintenance).
* Setting the "disable-migratory bit" in the undocumented SCU
* Diagnostic Control Register helps work around the problem.
*/
reg = bus_space_read_4(fdtbus_bs_tag, scu, SCU_DIAG_CONTROL);
reg |= (SCU_DIAG_DISABLE_MIGBIT);
bus_space_write_4(fdtbus_bs_tag, scu, SCU_DIAG_CONTROL, reg);
/* Put CPU1 to reset state */
bus_space_write_4(fdtbus_bs_tag, rst, MPUMODRST, MPUMODRST_CPU1);
/* Enable the SCU, then clean the cache on this core */
reg = bus_space_read_4(fdtbus_bs_tag, scu, SCU_CONTROL_REG);
reg |= (SCU_CONTROL_ENABLE);
bus_space_write_4(fdtbus_bs_tag, scu, SCU_CONTROL_REG, reg);
/* Set up trampoline code */
mpentry_addr = (char *)pmap_kextract((vm_offset_t)mpentry);
bus_space_write_region_4(fdtbus_bs_tag, ram, 0,
(uint32_t *)&socfpga_trampoline, 8);
cpu_idcache_wbinv_all();
cpu_l2cache_wbinv_all();
/* Put CPU1 out from reset */
bus_space_write_4(fdtbus_bs_tag, rst, MPUMODRST, 0);
armv7_sev();
bus_space_unmap(fdtbus_bs_tag, scu, SCU_SIZE);
bus_space_unmap(fdtbus_bs_tag, rst, RSTMGR_SIZE);
bus_space_unmap(fdtbus_bs_tag, ram, RAM_SIZE);
}
void
platform_ipi_send(cpuset_t cpus, u_int ipi)
{
pic_ipi_send(cpus, ipi);
}

View File

@ -22,7 +22,7 @@
ident BEAGLEBONE ident BEAGLEBONE
include "../ti/am335x/std.beaglebone" include "../ti/am335x/std.am335x"
makeoptions WITHOUT_MODULES="ahc" makeoptions WITHOUT_MODULES="ahc"

View File

@ -53,7 +53,7 @@ options PREEMPTION
options FREEBSD_BOOT_LOADER options FREEBSD_BOOT_LOADER
options VFP # vfp/neon options VFP # vfp/neon
#options SMP options SMP
# Debugging # Debugging
makeoptions DEBUG=-g # Build kernel with gdb(1) debug symbols makeoptions DEBUG=-g # Build kernel with gdb(1) debug symbols

View File

@ -1,14 +1,15 @@
#$FreeBSD$ #$FreeBSD$
arm/ti/aintc.c standard arm/ti/aintc.c standard
arm/ti/am335x/am335x_prcm.c standard
arm/ti/am335x/am335x_dmtimer.c standard arm/ti/am335x/am335x_dmtimer.c standard
arm/ti/am335x/am335x_scm_padconf.c standard
arm/ti/am335x/am335x_lcd.c optional sc arm/ti/am335x/am335x_lcd.c optional sc
arm/ti/am335x/am335x_lcd_syscons.c optional sc arm/ti/am335x/am335x_lcd_syscons.c optional sc
arm/ti/am335x/am335x_pmic.c optional am335x_pmic
arm/ti/am335x/am335x_prcm.c standard
arm/ti/am335x/am335x_pwm.c standard arm/ti/am335x/am335x_pwm.c standard
arm/ti/am335x/am335x_scm_padconf.c standard
arm/ti/am335x/am335x_usbss.c optional musb fdt arm/ti/am335x/am335x_usbss.c optional musb fdt
arm/ti/ti_edma3.c standard arm/ti/ti_edma3.c standard
arm/ti/ti_sdhci.c optional sdhci
#arm/ti/ti_mmchs.c optional mmc
arm/ti/cpsw/if_cpsw.c optional cpsw arm/ti/cpsw/if_cpsw.c optional cpsw

View File

@ -1,3 +0,0 @@
#$FreeBSD$
arm/ti/am335x/am335x_pmic.c optional am335x_pmic

View File

@ -1,4 +0,0 @@
# $FreeBSD$
files "../ti/am335x/files.beaglebone"
include "../ti/am335x/std.am335x"

View File

@ -22,6 +22,7 @@ arm/ti/ti_pruss.c standard
arm/ti/ti_adc.c optional ti_adc arm/ti/ti_adc.c optional ti_adc
arm/ti/ti_gpio.c optional gpio arm/ti/ti_gpio.c optional gpio
arm/ti/ti_i2c.c optional ti_i2c arm/ti/ti_i2c.c optional ti_i2c
arm/ti/ti_sdhci.c optional sdhci
dev/uart/uart_dev_ti8250.c optional uart dev/uart/uart_dev_ti8250.c optional uart
dev/uart/uart_dev_ns8250.c optional uart dev/uart/uart_dev_ns8250.c optional uart

View File

@ -1,780 +0,0 @@
/*-
* Copyright (c) 2011
* Ben Gray <ben.r.gray@gmail.com>.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $FreeBSD$
*/
/*
* Texas Instruments - OMAP3xxx series processors
*
* Reference:
* OMAP35x Applications Processor
* Technical Reference Manual
* (omap35xx_techref.pdf)
*
*
* Note:
* The devices are mapped into address above 0xD000_0000 as the kernel space
* memory is at 0xC000_0000 and above. The first 256MB after this is reserved
* for the size of the kernel, everything above that is reserved for SoC
* devices.
*
*/
#ifndef _OMAP35XX_REG_H_
#define _OMAP35XX_REG_H_
#ifndef _LOCORE
#include <sys/types.h> /* for uint32_t */
#endif
#define OMAP35XX_SDRAM0_START 0x80000000UL
#define OMAP35XX_SDRAM1_START 0xA0000000UL
#define OMAP35XX_SDRAM_BANKS 2
#define OMAP35XX_SDRAM_BANK_SIZE 0x20000000UL
/* Physical/Virtual address for SDRAM controller */
#define OMAP35XX_SMS_VBASE 0x6C000000UL
#define OMAP35XX_SMS_HWBASE 0x6C000000UL
#define OMAP35XX_SMS_SIZE 0x01000000UL
#define OMAP35XX_SDRC_VBASE 0x6D000000UL
#define OMAP35XX_SDRC_HWBASE 0x6D000000UL
#define OMAP35XX_SDRC_SIZE 0x01000000UL
/* Physical/Virtual address for I/O space */
#define OMAP35XX_L3_VBASE 0xD0000000UL
#define OMAP35XX_L3_HWBASE 0x68000000UL
#define OMAP35XX_L3_SIZE 0x01000000UL
#define OMAP35XX_L4_CORE_VBASE 0xE8000000UL
#define OMAP35XX_L4_CORE_HWBASE 0x48000000UL
#define OMAP35XX_L4_CORE_SIZE 0x01000000UL
#define OMAP35XX_L4_WAKEUP_VBASE 0xE8300000UL
#define OMAP35XX_L4_WAKEUP_HWBASE 0x48300000UL
#define OMAP35XX_L4_WAKEUP_SIZE 0x00040000UL
#define OMAP35XX_L4_PERIPH_VBASE 0xE9000000UL
#define OMAP35XX_L4_PERIPH_HWBASE 0x49000000UL
#define OMAP35XX_L4_PERIPH_SIZE 0x00100000UL
/*
* L4-CORE Physical/Virtual addresss offsets
*/
#define OMAP35XX_SCM_OFFSET 0x00002000UL
#define OMAP35XX_CM_OFFSET 0x00004000UL
#define OMAP35XX_SDMA_OFFSET 0x00056000UL
#define OMAP35XX_I2C3_OFFSET 0x00060000UL
#define OMAP35XX_USB_TLL_OFFSET 0x00062000UL
#define OMAP35XX_USB_UHH_OFFSET 0x00064000UL
#define OMAP35XX_USB_EHCI_OFFSET 0x00064800UL
#define OMAP35XX_UART1_OFFSET 0x0006A000UL
#define OMAP35XX_UART2_OFFSET 0x0006C000UL
#define OMAP35XX_I2C1_OFFSET 0x00070000UL
#define OMAP35XX_I2C2_OFFSET 0x00072000UL
#define OMAP35XX_MCBSP1_OFFSET 0x00074000UL
#define OMAP35XX_GPTIMER10_OFFSET 0x00086000UL
#define OMAP35XX_GPTIMER11_OFFSET 0x00088000UL
#define OMAP35XX_MCBSP5_OFFSET 0x00096000UL
#define OMAP35XX_MMU1_OFFSET 0x000BD400UL
#define OMAP35XX_INTCPS_OFFSET 0x00200000UL
/*
* L4-WAKEUP Physical/Virtual addresss offsets
*/
#define OMAP35XX_PRM_OFFSET 0x00006000UL
#define OMAP35XX_GPIO1_OFFSET 0x00010000UL
#define OMAP35XX_GPTIMER1_OFFSET 0x00018000UL
/*
* L4-PERIPH Physical/Virtual addresss offsets
*/
#define OMAP35XX_UART3_OFFSET 0x00020000UL
#define OMAP35XX_MCBSP2_OFFSET 0x00022000UL
#define OMAP35XX_MCBSP3_OFFSET 0x00024000UL
#define OMAP35XX_MCBSP4_OFFSET 0x00026000UL
#define OMAP35XX_SIDETONE_MCBSP2_OFFSET 0x00028000UL
#define OMAP35XX_SIDETONE_MCBSP3_OFFSET 0x0002A000UL
#define OMAP35XX_GPTIMER2_OFFSET 0x00032000UL
#define OMAP35XX_GPTIMER3_OFFSET 0x00034000UL
#define OMAP35XX_GPTIMER4_OFFSET 0x00036000UL
#define OMAP35XX_GPTIMER5_OFFSET 0x00038000UL
#define OMAP35XX_GPTIMER6_OFFSET 0x0003A000UL
#define OMAP35XX_GPTIMER7_OFFSET 0x0003C000UL
#define OMAP35XX_GPTIMER8_OFFSET 0x0003E000UL
#define OMAP35XX_GPTIMER9_OFFSET 0x00040000UL
#define OMAP35XX_GPIO2_OFFSET 0x00050000UL
#define OMAP35XX_GPIO3_OFFSET 0x00052000UL
#define OMAP35XX_GPIO4_OFFSET 0x00054000UL
#define OMAP35XX_GPIO5_OFFSET 0x00056000UL
#define OMAP35XX_GPIO6_OFFSET 0x00058000UL
/*
* System Control Module
*/
#define OMAP35XX_SCM_HWBASE (OMAP35XX_L4_CORE_HWBASE + OMAP35XX_SCM_OFFSET)
#define OMAP35XX_SCM_VBASE (OMAP35XX_L4_CORE_VBASE + OMAP35XX_SCM_OFFSET)
#define OMAP35XX_SCM_SIZE 0x00001000UL
#define OMAP35XX_SCM_REVISION 0x00000000UL
#define OMAP35XX_SCM_SYSCONFIG 0x00000010UL
#define OMAP35XX_SCM_PADCONFS_BASE 0x00000030UL
#define OMAP35XX_SCM_DEVCONF0 0x00000274UL
#define OMAP35XX_SCM_MEM_DFTRW0 0x00000278UL
/*
*
*/
#define OMAP35XX_CM_HWBASE (OMAP35XX_L4_CORE_HWBASE + OMAP35XX_CM_OFFSET)
#define OMAP35XX_CM_VBASE (OMAP35XX_L4_CORE_VBASE + OMAP35XX_CM_OFFSET)
#define OMAP35XX_CM_SIZE 0x00001500UL
#define OMAP35XX_CM_CORE_OFFSET 0x00000A00UL
#define OMAP35XX_CM_CORE_SIZE 0x00000100UL
#define OMAP35XX_CM_FCLKEN1_CORE (OMAP35XX_CM_CORE_OFFSET + 0x0000UL)
#define OMAP35XX_CM_FCLKEN3_CORE (OMAP35XX_CM_CORE_OFFSET + 0x0008UL)
#define OMAP35XX_CM_ICLKEN1_CORE (OMAP35XX_CM_CORE_OFFSET + 0x0010UL)
#define OMAP35XX_CM_ICLKEN2_CORE (OMAP35XX_CM_CORE_OFFSET + 0x0014UL)
#define OMAP35XX_CM_ICLKEN3_CORE (OMAP35XX_CM_CORE_OFFSET + 0x0018UL)
#define OMAP35XX_CM_IDLEST1_CORE (OMAP35XX_CM_CORE_OFFSET + 0x0020UL)
#define OMAP35XX_CM_IDLEST2_CORE (OMAP35XX_CM_CORE_OFFSET + 0x0024UL)
#define OMAP35XX_CM_IDLEST3_CORE (OMAP35XX_CM_CORE_OFFSET + 0x0028UL)
#define OMAP35XX_CM_AUTOIDLE1_CORE (OMAP35XX_CM_CORE_OFFSET + 0x0030UL)
#define OMAP35XX_CM_AUTOIDLE2_CORE (OMAP35XX_CM_CORE_OFFSET + 0x0034UL)
#define OMAP35XX_CM_AUTOIDLE3_CORE (OMAP35XX_CM_CORE_OFFSET + 0x0038UL)
#define OMAP35XX_CM_CLKSEL_CORE (OMAP35XX_CM_CORE_OFFSET + 0x0040UL)
#define OMAP35XX_CM_CLKSTCTRL_CORE (OMAP35XX_CM_CORE_OFFSET + 0x0048UL)
#define OMAP35XX_CM_CLKSTST_CORE (OMAP35XX_CM_CORE_OFFSET + 0x004CUL)
#define OMAP35XX_CM_WKUP_OFFSET 0x00000C00UL
#define OMAP35XX_CM_WKUP_SIZE 0x00000100UL
#define OMAP35XX_CM_FCLKEN_WKUP (OMAP35XX_CM_WKUP_OFFSET + 0x0000UL)
#define OMAP35XX_CM_ICLKEN_WKUP (OMAP35XX_CM_WKUP_OFFSET + 0x0010UL)
#define OMAP35XX_CM_IDLEST_WKUP (OMAP35XX_CM_WKUP_OFFSET + 0x0020UL)
#define OMAP35XX_CM_AUTOIDLE_WKUP (OMAP35XX_CM_WKUP_OFFSET + 0x0030UL)
#define OMAP35XX_CM_CLKSEL_WKUP (OMAP35XX_CM_WKUP_OFFSET + 0x0040UL)
#define OMAP35XX_CM_PLL_OFFSET 0x00000D00UL
#define OMAP35XX_CM_PLL_SIZE 0x00000100UL
#define OMAP35XX_CM_CLKEN_PLL (OMAP35XX_CM_PLL_OFFSET + 0x0000UL)
#define OMAP35XX_CM_CLKEN2_PLL (OMAP35XX_CM_PLL_OFFSET + 0x0004UL)
#define OMAP35XX_CM_IDLEST_CKGEN (OMAP35XX_CM_PLL_OFFSET + 0x0020UL)
#define OMAP35XX_CM_IDLEST2_CKGEN (OMAP35XX_CM_PLL_OFFSET + 0x0024UL)
#define OMAP35XX_CM_AUTOIDLE_PLL (OMAP35XX_CM_PLL_OFFSET + 0x0030UL)
#define OMAP35XX_CM_AUTOIDLE2_PLL (OMAP35XX_CM_PLL_OFFSET + 0x0034UL)
#define OMAP35XX_CM_CLKSEL1_PLL (OMAP35XX_CM_PLL_OFFSET + 0x0040UL)
#define OMAP35XX_CM_CLKSEL2_PLL (OMAP35XX_CM_PLL_OFFSET + 0x0044UL)
#define OMAP35XX_CM_CLKSEL3_PLL (OMAP35XX_CM_PLL_OFFSET + 0x0048UL)
#define OMAP35XX_CM_CLKSEL4_PLL (OMAP35XX_CM_PLL_OFFSET + 0x004CUL)
#define OMAP35XX_CM_CLKSEL5_PLL (OMAP35XX_CM_PLL_OFFSET + 0x0050UL)
#define OMAP35XX_CM_CLKOUT_CTRL (OMAP35XX_CM_PLL_OFFSET + 0x0070UL)
#define OMAP35XX_CM_PER_OFFSET 0x00001000UL
#define OMAP35XX_CM_PER_SIZE 0x00000100UL
#define OMAP35XX_CM_FCLKEN_PER (OMAP35XX_CM_PER_OFFSET + 0x0000UL)
#define OMAP35XX_CM_ICLKEN_PER (OMAP35XX_CM_PER_OFFSET + 0x0010UL)
#define OMAP35XX_CM_IDLEST_PER (OMAP35XX_CM_PER_OFFSET + 0x0020UL)
#define OMAP35XX_CM_AUTOIDLE_PER (OMAP35XX_CM_PER_OFFSET + 0x0030UL)
#define OMAP35XX_CM_CLKSEL_PER (OMAP35XX_CM_PER_OFFSET + 0x0040UL)
#define OMAP35XX_CM_SLEEPDEP_PER (OMAP35XX_CM_PER_OFFSET + 0x0044UL)
#define OMAP35XX_CM_CLKSTCTRL_PER (OMAP35XX_CM_PER_OFFSET + 0x0048UL)
#define OMAP35XX_CM_CLKSTST_PER (OMAP35XX_CM_PER_OFFSET + 0x004CUL)
#define OMAP35XX_CM_USBHOST_OFFSET 0x00001400UL
#define OMAP35XX_CM_USBHOST_SIZE 0x00000100UL
#define OMAP35XX_CM_FCLKEN_USBHOST (OMAP35XX_CM_USBHOST_OFFSET + 0x0000UL)
#define OMAP35XX_CM_ICLKEN_USBHOST (OMAP35XX_CM_USBHOST_OFFSET + 0x0010UL)
#define OMAP35XX_CM_IDLEST_USBHOST (OMAP35XX_CM_USBHOST_OFFSET + 0x0020UL)
#define OMAP35XX_CM_AUTOIDLE_USBHOST (OMAP35XX_CM_USBHOST_OFFSET + 0x0030UL)
#define OMAP35XX_CM_SLEEPDEP_USBHOST (OMAP35XX_CM_USBHOST_OFFSET + 0x0044UL)
#define OMAP35XX_CM_CLKSTCTRL_USBHOST (OMAP35XX_CM_USBHOST_OFFSET + 0x0048UL)
#define OMAP35XX_CM_CLKSTST_USBHOST (OMAP35XX_CM_USBHOST_OFFSET + 0x004CUL)
/*
*
*/
#define OMAP35XX_PRM_HWBASE (OMAP35XX_L4_WAKEUP_HWBASE + OMAP35XX_PRM_OFFSET)
#define OMAP35XX_PRM_VBASE (OMAP35XX_L4_WAKEUP_VBASE + OMAP35XX_PRM_OFFSET)
#define OMAP35XX_PRM_SIZE 0x00001600UL
#define OMAP35XX_PRM_CLKCTRL_OFFSET 0x00000D00UL
#define OMAP35XX_PRM_CLKCTRL_SIZE 0x00000100UL
#define OMAP35XX_PRM_CLKSEL (OMAP35XX_PRM_CLKCTRL_OFFSET + 0x0040UL)
#define OMAP35XX_PRM_CLKOUT_CTRL (OMAP35XX_PRM_CLKCTRL_OFFSET + 0x0070UL)
#define OMAP35XX_PRM_GLOBAL_OFFSET 0x00001200UL
#define OMAP35XX_PRM_GLOBAL_SIZE 0x00000100UL
#define OMAP35XX_PRM_CLKSRC_CTRL (OMAP35XX_PRM_GLOBAL_OFFSET + 0x0070UL)
/*
* Uarts
*/
#define OMAP35XX_UART1_HWBASE (OMAP35XX_L4_CORE_HWBASE + OMAP35XX_UART1_OFFSET)
#define OMAP35XX_UART1_VBASE (OMAP35XX_L4_CORE_VBASE + OMAP35XX_UART1_OFFSET)
#define OMAP35XX_UART1_SIZE 0x00001000UL
#define OMAP35XX_UART2_HWBASE (OMAP35XX_L4_CORE_HWBASE + OMAP35XX_UART2_OFFSET)
#define OMAP35XX_UART2_VBASE (OMAP35XX_L4_CORE_VBASE + OMAP35XX_UART2_OFFSET)
#define OMAP35XX_UART2_SIZE 0x00001000UL
#define OMAP35XX_UART3_HWBASE (OMAP35XX_L4_PERIPH_HWBASE + OMAP35XX_UART3_OFFSET)
#define OMAP35XX_UART3_VBASE (OMAP35XX_L4_PERIPH_VBASE + OMAP35XX_UART3_OFFSET)
#define OMAP35XX_UART3_SIZE 0x00001000UL
/*
* I2C Modules
*/
#define OMAP35XX_I2C1_HWBASE (OMAP35XX_L4_CORE_HWBASE + OMAP35XX_I2C1_OFFSET)
#define OMAP35XX_I2C1_VBASE (OMAP35XX_L4_CORE_VBASE + OMAP35XX_I2C1_OFFSET)
#define OMAP35XX_I2C1_SIZE 0x00000080UL
#define OMAP35XX_I2C2_HWBASE (OMAP35XX_L4_CORE_HWBASE + OMAP35XX_I2C2_OFFSET)
#define OMAP35XX_I2C2_VBASE (OMAP35XX_L4_CORE_VBASE + OMAP35XX_I2C2_OFFSET)
#define OMAP35XX_I2C2_SIZE 0x00000080UL
#define OMAP35XX_I2C3_HWBASE (OMAP35XX_L4_CORE_HWBASE + OMAP35XX_I2C3_OFFSET)
#define OMAP35XX_I2C3_VBASE (OMAP35XX_L4_CORE_VBASE + OMAP35XX_I2C3_OFFSET)
#define OMAP35XX_I2C3_SIZE 0x00000080UL
#define OMAP35XX_I2C_IE 0x04
#define OMAP35XX_I2C_STAT 0x08
#define OMAP35XX_I2C_WE 0x0C
#define OMAP35XX_I2C_SYSS 0x10
#define OMAP35XX_I2C_BUF 0x14
#define OMAP35XX_I2C_CNT 0x18
#define OMAP35XX_I2C_DATA 0x1C
#define OMAP35XX_I2C_SYSC 0x20
#define OMAP35XX_I2C_CON 0x24
#define OMAP35XX_I2C_OA0 0x28
#define OMAP35XX_I2C_SA 0x2C
#define OMAP35XX_I2C_PSC 0x30
#define OMAP35XX_I2C_SCLL 0x34
#define OMAP35XX_I2C_SCLH 0x38
#define OMAP35XX_I2C_SYSTEST 0x3C
#define OMAP35XX_I2C_BUFSTAT 0x40
#define OMAP35XX_I2C_OA1 0x44
#define OMAP35XX_I2C_OA2 0x48
#define OMAP35XX_I2C_OA3 0x4C
#define OMAP35XX_I2C_ACTOA 0x50
#define OMAP35XX_I2C_SBLOCK 0x54
/*
* McBSP Modules
*/
#define OMAP35XX_MCBSP1_HWBASE (OMAP35XX_L4_CORE_HWBASE + OMAP35XX_MCBSP1_OFFSET)
#define OMAP35XX_MCBSP1_VBASE (OMAP35XX_L4_CORE_VBASE + OMAP35XX_MCBSP1_OFFSET)
#define OMAP35XX_MCBSP1_SIZE 0x00001000UL
#define OMAP35XX_MCBSP2_HWBASE (OMAP35XX_L4_PERIPH_HWBASE + OMAP35XX_MCBSP2_OFFSET)
#define OMAP35XX_MCBSP2_VBASE (OMAP35XX_L4_PERIPH_VBASE + OMAP35XX_MCBSP2_OFFSET)
#define OMAP35XX_MCBSP2_SIZE 0x00001000UL
#define OMAP35XX_MCBSP3_HWBASE (OMAP35XX_L4_PERIPH_HWBASE + OMAP35XX_MCBSP3_OFFSET)
#define OMAP35XX_MCBSP3_VBASE (OMAP35XX_L4_PERIPH_VBASE + OMAP35XX_MCBSP3_OFFSET)
#define OMAP35XX_MCBSP3_SIZE 0x00001000UL
#define OMAP35XX_MCBSP4_HWBASE (OMAP35XX_L4_PERIPH_HWBASE + OMAP35XX_MCBSP4_OFFSET)
#define OMAP35XX_MCBSP4_VBASE (OMAP35XX_L4_PERIPH_VBASE + OMAP35XX_MCBSP4_OFFSET)
#define OMAP35XX_MCBSP4_SIZE 0x00001000UL
#define OMAP35XX_MCBSP5_HWBASE (OMAP35XX_L4_CORE_HWBASE + OMAP35XX_MCBSP5_OFFSET)
#define OMAP35XX_MCBSP5_VBASE (OMAP35XX_L4_CORE_VBASE + OMAP35XX_MCBSP5_OFFSET)
#define OMAP35XX_MCBSP5_SIZE 0x00001000UL
#define OMAP35XX_MCBSP_DRR 0x0000
#define OMAP35XX_MCBSP_DXR 0x0008
#define OMAP35XX_MCBSP_SPCR2 0x0010
#define OMAP35XX_MCBSP_SPCR1 0x0014
#define OMAP35XX_MCBSP_RCR2 0x0018
#define OMAP35XX_MCBSP_RCR1 0x001C
#define OMAP35XX_MCBSP_XCR2 0x0020
#define OMAP35XX_MCBSP_XCR1 0x0024
#define OMAP35XX_MCBSP_SRGR2 0x0028
#define OMAP35XX_MCBSP_SRGR1 0x002C
#define OMAP35XX_MCBSP_MCR2 0x0030
#define OMAP35XX_MCBSP_MCR1 0x0034
#define OMAP35XX_MCBSP_RCERA 0x0038
#define OMAP35XX_MCBSP_RCERB 0x003C
#define OMAP35XX_MCBSP_XCERA 0x0040
#define OMAP35XX_MCBSP_XCERB 0x0044
#define OMAP35XX_MCBSP_PCR 0x0048
#define OMAP35XX_MCBSP_RCERC 0x004C
#define OMAP35XX_MCBSP_RCERD 0x0050
#define OMAP35XX_MCBSP_XCERC 0x0054
#define OMAP35XX_MCBSP_XCERD 0x0058
#define OMAP35XX_MCBSP_RCERE 0x005C
#define OMAP35XX_MCBSP_RCERF 0x0060
#define OMAP35XX_MCBSP_XCERE 0x0064
#define OMAP35XX_MCBSP_XCERF 0x0068
#define OMAP35XX_MCBSP_RCERG 0x006C
#define OMAP35XX_MCBSP_RCERH 0x0070
#define OMAP35XX_MCBSP_XCERG 0x0074
#define OMAP35XX_MCBSP_XCERH 0x0078
#define OMAP35XX_MCBSP_RINTCLR 0x0080
#define OMAP35XX_MCBSP_XINTCLR 0x0084
#define OMAP35XX_MCBSP_ROVFLCLR 0x0088
#define OMAP35XX_MCBSP_SYSCONFIG 0x008C
#define OMAP35XX_MCBSP_THRSH2 0x0090
#define OMAP35XX_MCBSP_THRSH1 0x0094
#define OMAP35XX_MCBSP_IRQSTATUS 0x00A0
#define OMAP35XX_MCBSP_IRQENABLE 0x00A4
#define OMAP35XX_MCBSP_WAKEUPEN 0x00A8
#define OMAP35XX_MCBSP_XCCR 0x00AC
#define OMAP35XX_MCBSP_RCCR 0x00B0
#define OMAP35XX_MCBSP_XBUFFSTAT 0x00B4
#define OMAP35XX_MCBSP_RBUFFSTAT 0x00B8
#define OMAP35XX_MCBSP_SSELCR 0x00BC
#define OMAP35XX_MCBSP_STATUS 0x00C0
/*
* USB TTL Module
*/
#define OMAP35XX_USBTLL_HWBASE (OMAP35XX_L4_CORE_HWBASE + OMAP35XX_USBTLL_OFFSET)
#define OMAP35XX_USBTLL_VBASE (OMAP35XX_L4_CORE_VBASE + OMAP35XX_USBTLL_OFFSET)
#define OMAP35XX_USBTLL_SIZE 0x00001000UL
#define OMAP35XX_USBTLL_REVISION 0x0000
#define OMAP35XX_USBTLL_SYSCONFIG 0x0010
#define OMAP35XX_USBTLL_SYSSTATUS 0x0014
#define OMAP35XX_USBTLL_IRQSTATUS 0x0018
#define OMAP35XX_USBTLL_IRQENABLE 0x001C
#define OMAP35XX_USBTLL_TLL_SHARED_CONF 0x0030
#define OMAP35XX_USBTLL_TLL_CHANNEL_CONF(i) (0x0040 + (0x04 * (i)))
#define OMAP35XX_USBTLL_ULPI_VENDOR_ID_LO(i) (0x0800 + (0x100 * (i)))
#define OMAP35XX_USBTLL_ULPI_VENDOR_ID_HI(i) (0x0801 + (0x100 * (i)))
#define OMAP35XX_USBTLL_ULPI_PRODUCT_ID_LO(i) (0x0802 + (0x100 * (i)))
#define OMAP35XX_USBTLL_ULPI_PRODUCT_ID_HI(i) (0x0803 + (0x100 * (i)))
#define OMAP35XX_USBTLL_ULPI_FUNCTION_CTRL(i) (0x0804 + (0x100 * (i)))
#define OMAP35XX_USBTLL_ULPI_FUNCTION_CTRL_SET(i) (0x0805 + (0x100 * (i)))
#define OMAP35XX_USBTLL_ULPI_FUNCTION_CTRL_CLR(i) (0x0806 + (0x100 * (i)))
#define OMAP35XX_USBTLL_ULPI_INTERFACE_CTRL(i) (0x0807 + (0x100 * (i)))
#define OMAP35XX_USBTLL_ULPI_INTERFACE_CTRL_SET(i) (0x0808 + (0x100 * (i)))
#define OMAP35XX_USBTLL_ULPI_INTERFACE_CTRL_CLR(i) (0x0809 + (0x100 * (i)))
#define OMAP35XX_USBTLL_ULPI_OTG_CTRL(i) (0x080A + (0x100 * (i)))
#define OMAP35XX_USBTLL_ULPI_OTG_CTRL_SET(i) (0x080B + (0x100 * (i)))
#define OMAP35XX_USBTLL_ULPI_OTG_CTRL_CLR(i) (0x080C + (0x100 * (i)))
#define OMAP35XX_USBTLL_ULPI_USB_INT_EN_RISE(i) (0x080D + (0x100 * (i)))
#define OMAP35XX_USBTLL_ULPI_USB_INT_EN_RISE_SET(i) (0x080E + (0x100 * (i)))
#define OMAP35XX_USBTLL_ULPI_USB_INT_EN_RISE_CLR(i) (0x080F + (0x100 * (i)))
#define OMAP35XX_USBTLL_ULPI_USB_INT_EN_FALL(i) (0x0810 + (0x100 * (i)))
#define OMAP35XX_USBTLL_ULPI_USB_INT_EN_FALL_SET(i) (0x0811 + (0x100 * (i)))
#define OMAP35XX_USBTLL_ULPI_USB_INT_EN_FALL_CLR(i) (0x0812 + (0x100 * (i)))
#define OMAP35XX_USBTLL_ULPI_USB_INT_STATUS(i) (0x0813 + (0x100 * (i)))
#define OMAP35XX_USBTLL_ULPI_USB_INT_LATCH(i) (0x0814 + (0x100 * (i)))
#define OMAP35XX_USBTLL_ULPI_DEBUG(i) (0x0815 + (0x100 * (i)))
#define OMAP35XX_USBTLL_ULPI_SCRATCH_REGISTER(i) (0x0816 + (0x100 * (i)))
#define OMAP35XX_USBTLL_ULPI_SCRATCH_REGISTER_SET(i) (0x0817 + (0x100 * (i)))
#define OMAP35XX_USBTLL_ULPI_SCRATCH_REGISTER_CLR(i) (0x0818 + (0x100 * (i)))
#define OMAP35XX_USBTLL_ULPI_EXTENDED_SET_ACCESS(i) (0x082F + (0x100 * (i)))
#define OMAP35XX_USBTLL_ULPI_UTMI_VCONTROL_EN(i) (0x0830 + (0x100 * (i)))
#define OMAP35XX_USBTLL_ULPI_UTMI_VCONTROL_EN_SET(i) (0x0831 + (0x100 * (i)))
#define OMAP35XX_USBTLL_ULPI_UTMI_VCONTROL_EN_CLR(i) (0x0832 + (0x100 * (i)))
#define OMAP35XX_USBTLL_ULPI_UTMI_VCONTROL_STATUS(i) (0x0833 + (0x100 * (i)))
#define OMAP35XX_USBTLL_ULPI_UTMI_VCONTROL_LATCH(i) (0x0834 + (0x100 * (i)))
#define OMAP35XX_USBTLL_ULPI_UTMI_VSTATUS(i) (0x0835 + (0x100 * (i)))
#define OMAP35XX_USBTLL_ULPI_UTMI_VSTATUS_SET(i) (0x0836 + (0x100 * (i)))
#define OMAP35XX_USBTLL_ULPI_UTMI_VSTATUS_CLR(i) (0x0837 + (0x100 * (i)))
#define OMAP35XX_USBTLL_ULPI_USB_INT_LATCH_NOCLR(i) (0x0838 + (0x100 * (i)))
#define OMAP35XX_USBTLL_ULPI_VENDOR_INT_EN(i) (0x083B + (0x100 * (i)))
#define OMAP35XX_USBTLL_ULPI_VENDOR_INT_EN_SET(i) (0x083C + (0x100 * (i)))
#define OMAP35XX_USBTLL_ULPI_VENDOR_INT_EN_CLR(i) (0x083D + (0x100 * (i)))
#define OMAP35XX_USBTLL_ULPI_VENDOR_INT_STATUS(i) (0x083E + (0x100 * (i)))
#define OMAP35XX_USBTLL_ULPI_VENDOR_INT_LATCH(i) (0x083F + (0x100 * (i)))
/*
* USB Host Module
*/
#define OMAP35XX_USB_TLL_HWBASE (OMAP35XX_L4_CORE_HWBASE + OMAP35XX_USB_TLL_OFFSET)
#define OMAP35XX_USB_TLL_VBASE (OMAP35XX_L4_CORE_VBASE + OMAP35XX_USB_TLL_OFFSET)
#define OMAP35XX_USB_TLL_SIZE 0x00001000UL
#define OMAP35XX_USB_EHCI_HWBASE (OMAP35XX_L4_CORE_HWBASE + OMAP35XX_USB_EHCI_OFFSET)
#define OMAP35XX_USB_EHCI_VBASE (OMAP35XX_L4_CORE_VBASE + OMAP35XX_USB_EHCI_OFFSET)
#define OMAP35XX_USB_EHCI_SIZE 0x00000400UL
#define OMAP35XX_USB_UHH_HWBASE (OMAP35XX_L4_CORE_HWBASE + OMAP35XX_USB_UHH_OFFSET)
#define OMAP35XX_USB_UHH_VBASE (OMAP35XX_L4_CORE_VBASE + OMAP35XX_USB_UHH_OFFSET)
#define OMAP35XX_USB_UHH_SIZE 0x00000400UL
/*
* SDRAM Controler (SDRC)
* PA 0x6D00_0000
*/
#define OMAP35XX_SDRC_SYSCONFIG (OMAP35XX_SDRC_VBASE + 0x10)
#define OMAP35XX_SDRC_SYSSTATUS (OMAP35XX_SDRC_VBASE + 0x14)
#define OMAP35XX_SDRC_CS_CFG (OMAP35XX_SDRC_VBASE + 0x40)
#define OMAP35XX_SDRC_SHARING (OMAP35XX_SDRC_VBASE + 0x44)
#define OMAP35XX_SDRC_ERR_ADDR (OMAP35XX_SDRC_VBASE + 0x48)
#define OMAP35XX_SDRC_ERR_TYPE (OMAP35XX_SDRC_VBASE + 0x4C)
#define OMAP35XX_SDRC_DLLA_CTRL (OMAP35XX_SDRC_VBASE + 0x60)
#define OMAP35XX_SDRC_DLLA_STATUS (OMAP35XX_SDRC_VBASE + 0x64)
#define OMAP35XX_SDRC_POWER_REG (OMAP35XX_SDRC_VBASE + 0x70)
#define OMAP35XX_SDRC_MCFG(p) (OMAP35XX_SDRC_VBASE + 0x80 + (0x30 * (p)))
#define OMAP35XX_SDRC_MR(p) (OMAP35XX_SDRC_VBASE + 0x84 + (0x30 * (p)))
#define OMAP35XX_SDRC_EMR2(p) (OMAP35XX_SDRC_VBASE + 0x8C + (0x30 * (p)))
#define OMAP35XX_SDRC_ACTIM_CTRLA(p) (OMAP35XX_SDRC_VBASE + 0x9C + (0x28 * (p)))
#define OMAP35XX_SDRC_ACTIM_CTRLB(p) (OMAP35XX_SDRC_VBASE + 0xA0 + (0x28 * (p)))
#define OMAP35XX_SDRC_RFR_CTRL(p) (OMAP35XX_SDRC_VBASE + 0xA4 + (0x30 * (p)))
#define OMAP35XX_SDRC_MANUAL(p) (OMAP35XX_SDRC_VBASE + 0xA8 + (0x30 * (p)))
/*
* SDMA Offset
* PA 0x4805 6000
*/
#define OMAP35XX_SDMA_HWBASE (OMAP35XX_L4_CORE_HWBASE + OMAP35XX_SDMA_OFFSET)
#define OMAP35XX_SDMA_VBASE (OMAP35XX_L4_CORE_VBASE + OMAP35XX_SDMA_OFFSET)
#define OMAP35XX_SDMA_SIZE 0x00001000UL
/*
* Interrupt Controller Unit.
* PA 0x4820_0000
*/
#define OMAP35XX_INTCPS_HWBASE (OMAP35XX_L4_CORE_HWBASE + OMAP35XX_INTCPS_OFFSET)
#define OMAP35XX_INTCPS_VBASE (OMAP35XX_L4_CORE_VBASE + OMAP35XX_INTCPS_OFFSET)
#define OMAP35XX_INTCPS_SIZE 0x00001000UL
#define OMAP35XX_INTCPS_SYSCONFIG (OMAP35XX_INTCPS_VBASE + 0x10)
#define OMAP35XX_INTCPS_SYSSTATUS (OMAP35XX_INTCPS_VBASE + 0x14)
#define OMAP35XX_INTCPS_SIR_IRQ (OMAP35XX_INTCPS_VBASE + 0x40)
#define OMAP35XX_INTCPS_SIR_FIQ (OMAP35XX_INTCPS_VBASE + 0x44)
#define OMAP35XX_INTCPS_CONTROL (OMAP35XX_INTCPS_VBASE + 0x48)
#define OMAP35XX_INTCPS_PROTECTION (OMAP35XX_INTCPS_VBASE + 0x4C)
#define OMAP35XX_INTCPS_IDLE (OMAP35XX_INTCPS_VBASE + 0x50)
#define OMAP35XX_INTCPS_IRQ_PRIORITY (OMAP35XX_INTCPS_VBASE + 0x60)
#define OMAP35XX_INTCPS_FIQ_PRIORITY (OMAP35XX_INTCPS_VBASE + 0x64)
#define OMAP35XX_INTCPS_THRESHOLD (OMAP35XX_INTCPS_VBASE + 0x68)
#define OMAP35XX_INTCPS_ITR(n) (OMAP35XX_INTCPS_VBASE + 0x80 + (0x20 * (n)))
#define OMAP35XX_INTCPS_MIR(n) (OMAP35XX_INTCPS_VBASE + 0x84 + (0x20 * (n)))
#define OMAP35XX_INTCPS_MIR_CLEAR(n) (OMAP35XX_INTCPS_VBASE + 0x88 + (0x20 * (n)))
#define OMAP35XX_INTCPS_MIR_SET(n) (OMAP35XX_INTCPS_VBASE + 0x8C + (0x20 * (n)))
#define OMAP35XX_INTCPS_ISR_SET(n) (OMAP35XX_INTCPS_VBASE + 0x90 + (0x20 * (n)))
#define OMAP35XX_INTCPS_ISR_CLEAR(n) (OMAP35XX_INTCPS_VBASE + 0x94 + (0x20 * (n)))
#define OMAP35XX_INTCPS_PENDING_IRQ(n) (OMAP35XX_INTCPS_VBASE + 0x98 + (0x20 * (n)))
#define OMAP35XX_INTCPS_PENDING_FIQ(n) (OMAP35XX_INTCPS_VBASE + 0x9C + (0x20 * (n)))
#define OMAP35XX_INTCPS_ILR(m) (OMAP35XX_INTCPS_VBASE + 0x100 + (0x4 * (m)))
#define OMAP35XX_IRQ_EMUINT 0 /* MPU emulation(2) */
#define OMAP35XX_IRQ_COMMTX 1 /* MPU emulation(2) */
#define OMAP35XX_IRQ_COMMRX 2 /* MPU emulation(2) */
#define OMAP35XX_IRQ_BENCH 3 /* MPU emulation(2) */
#define OMAP35XX_IRQ_MCBSP2_ST 4 /* Sidetone MCBSP2 overflow */
#define OMAP35XX_IRQ_MCBSP3_ST 5 /* Sidetone MCBSP3 overflow */
#define OMAP35XX_IRQ_SSM_ABORT 6 /* MPU subsystem secure state-machine abort (2) */
#define OMAP35XX_IRQ_SYS_NIRQ 7 /* External source (active low) */
#define OMAP35XX_IRQ_RESERVED8 8 /* RESERVED */
#define OMAP35XX_IRQ_SMX_DBG 9 /* SMX error for debug */
#define OMAP35XX_IRQ_SMX_APP 10 /* SMX error for application */
#define OMAP35XX_IRQ_PRCM_MPU 11 /* PRCM module IRQ */
#define OMAP35XX_IRQ_SDMA0 12 /* System DMA request 0(3) */
#define OMAP35XX_IRQ_SDMA1 13 /* System DMA request 1(3) */
#define OMAP35XX_IRQ_SDMA2 14 /* System DMA request 2 */
#define OMAP35XX_IRQ_SDMA3 15 /* System DMA request 3 */
#define OMAP35XX_IRQ_MCBSP1 16 /* McBSP module 1 IRQ (3) */
#define OMAP35XX_IRQ_MCBSP2 17 /* McBSP module 2 IRQ (3) */
#define OMAP35XX_IRQ_SR1 18 /* SmartReflex™ 1 */
#define OMAP35XX_IRQ_SR2 19 /* SmartReflex™ 2 */
#define OMAP35XX_IRQ_GPMC 20 /* General-purpose memory controller module */
#define OMAP35XX_IRQ_SGX 21 /* 2D/3D graphics module */
#define OMAP35XX_IRQ_MCBSP3 22 /* McBSP module 3(3) */
#define OMAP35XX_IRQ_MCBSP4 23 /* McBSP module 4(3) */
#define OMAP35XX_IRQ_CAM0 24 /* Camera interface request 0 */
#define OMAP35XX_IRQ_DSS 25 /* Display subsystem module(3) */
#define OMAP35XX_IRQ_MAIL_U0 26 /* Mailbox user 0 request */
#define OMAP35XX_IRQ_MCBSP5_IRQ1 27 /* McBSP module 5 (3) */
#define OMAP35XX_IRQ_IVA2_MMU 28 /* IVA2 MMU */
#define OMAP35XX_IRQ_GPIO1_MPU 29 /* GPIO module 1(3) */
#define OMAP35XX_IRQ_GPIO2_MPU 30 /* GPIO module 2(3) */
#define OMAP35XX_IRQ_GPIO3_MPU 31 /* GPIO module 3(3) */
#define OMAP35XX_IRQ_GPIO4_MPU 32 /* GPIO module 4(3) */
#define OMAP35XX_IRQ_GPIO5_MPU 33 /* GPIO module 5(3) */
#define OMAP35XX_IRQ_GPIO6_MPU 34 /* GPIO module 6(3) */
#define OMAP35XX_IRQ_USIM 35 /* USIM interrupt (HS devices only) (4) */
#define OMAP35XX_IRQ_WDT3 36 /* Watchdog timer module 3 overflow */
#define OMAP35XX_IRQ_GPT1 37 /* General-purpose timer module 1 */
#define OMAP35XX_IRQ_GPT2 38 /* General-purpose timer module 2 */
#define OMAP35XX_IRQ_GPT3 39 /* General-purpose timer module 3 */
#define OMAP35XX_IRQ_GPT4 40 /* General-purpose timer module 4 */
#define OMAP35XX_IRQ_GPT5 41 /* General-purpose timer module 5(3) */
#define OMAP35XX_IRQ_GPT6 42 /* General-purpose timer module 6(3) */
#define OMAP35XX_IRQ_GPT7 43 /* General-purpose timer module 7(3) */
#define OMAP35XX_IRQ_GPT8 44 /* General-purpose timer module 8(3) */
#define OMAP35XX_IRQ_GPT9 45 /* General-purpose timer module 9 */
#define OMAP35XX_IRQ_GPT10 46 /* General-purpose timer module 10 */
#define OMAP35XX_IRQ_GPT11 47 /* General-purpose timer module 11 */
#define OMAP35XX_IRQ_SPI4 48 /* McSPI module 4 */
#define OMAP35XX_IRQ_SHA1MD5_2 49 /* SHA-1/MD5 crypto-accelerator 2 (HS devices only)(4) */
#define OMAP35XX_IRQ_FPKA_IRQREADY_N 50 /* PKA crypto-accelerator (HS devices only) (4) */
#define OMAP35XX_IRQ_SHA2MD5 51 /* SHA-2/MD5 crypto-accelerator 1 (HS devices only) (4) */
#define OMAP35XX_IRQ_RNG 52 /* RNG module (HS devices only) (4) */
#define OMAP35XX_IRQ_MG 53 /* MG function (3) */
#define OMAP35XX_IRQ_MCBSP4_TX 54 /* McBSP module 4 transmit(3) */
#define OMAP35XX_IRQ_MCBSP4_RX 55 /* McBSP module 4 receive(3) */
#define OMAP35XX_IRQ_I2C1 56 /* I2C module 1 */
#define OMAP35XX_IRQ_I2C2 57 /* I2C module 2 */
#define OMAP35XX_IRQ_HDQ 58 /* HDQ / One-wire */
#define OMAP35XX_IRQ_MCBSP1_TX 59 /* McBSP module 1 transmit(3) */
#define OMAP35XX_IRQ_MCBSP1_RX 60 /* McBSP module 1 receive(3) */
#define OMAP35XX_IRQ_I2C3 61 /* I2C module 3 */
#define OMAP35XX_IRQ_McBSP2_TX 62 /* McBSP module 2 transmit(3) */
#define OMAP35XX_IRQ_McBSP2_RX 63 /* McBSP module 2 receive(3) */
#define OMAP35XX_IRQ_FPKA_IRQRERROR_N 64 /* PKA crypto-accelerator (HS devices only) (4) */
#define OMAP35XX_IRQ_SPI1 65 /* McSPI module 1 */
#define OMAP35XX_IRQ_SPI2 66 /* McSPI module 2 */
#define OMAP35XX_IRQ_RESERVED67 67 /* RESERVED */
#define OMAP35XX_IRQ_RESERVED68 68 /* RESERVED */
#define OMAP35XX_IRQ_RESERVED69 69 /* RESERVED */
#define OMAP35XX_IRQ_RESERVED70 70 /* RESERVED */
#define OMAP35XX_IRQ_RESERVED71 71 /* RESERVED */
#define OMAP35XX_IRQ_UART1 72 /* UART module 1 */
#define OMAP35XX_IRQ_UART2 73 /* UART module 2 */
#define OMAP35XX_IRQ_UART3 74 /* UART module 3 (also infrared)(3) */
#define OMAP35XX_IRQ_PBIAS 75 /* Merged interrupt for PBIASlite1 and 2 */
#define OMAP35XX_IRQ_OHCI 76 /* OHCI controller HSUSB MP Host Interrupt */
#define OMAP35XX_IRQ_EHCI 77 /* EHCI controller HSUSB MP Host Interrupt */
#define OMAP35XX_IRQ_TLL 78 /* HSUSB MP TLL Interrupt */
#define OMAP35XX_IRQ_PARTHASH 79 /* SHA2/MD5 crypto-accelerator 1 (HS devices only) (4) */
#define OMAP35XX_IRQ_RESERVED80 80 /* Reserved */
#define OMAP35XX_IRQ_MCBSP5_TX 81 /* McBSP module 5 transmit(3) */
#define OMAP35XX_IRQ_MCBSP5_RX 82 /* McBSP module 5 receive(3) */
#define OMAP35XX_IRQ_MMC1 83 /* MMC/SD module 1 */
#define OMAP35XX_IRQ_MS 84 /* MS-PRO™ module */
#define OMAP35XX_IRQ_RESERVED85 85 /* Reserved */
#define OMAP35XX_IRQ_MMC2 86 /* MMC/SD module 2 */
#define OMAP35XX_IRQ_MPU_ICR 87 /* MPU ICR */
#define OMAP35XX_IRQ_RESERVED 88 /* RESERVED */
#define OMAP35XX_IRQ_MCBSP3_TX 89 /* McBSP module 3 transmit(3) */
#define OMAP35XX_IRQ_MCBSP3_RX 90 /* McBSP module 3 receive(3) */
#define OMAP35XX_IRQ_SPI3 91 /* McSPI module 3 */
#define OMAP35XX_IRQ_HSUSB_MC_NINT 92 /* High-Speed USB OTG controller */
#define OMAP35XX_IRQ_HSUSB_DMA_NINT 93 /* High-Speed USB OTG DMA controller */
#define OMAP35XX_IRQ_MMC3 94 /* MMC/SD module 3 */
#define OMAP35XX_IRQ_GPT12 95 /* General-purpose timer module 12 */
/*
* General Purpose Timers
*/
#define OMAP35XX_GPTIMER1_VBASE (OMAP35XX_L4_WAKEUP_VBASE + OMAP35XX_GPTIMER1_OFFSET)
#define OMAP35XX_GPTIMER1_HWBASE (OMAP35XX_L4_WAKEUP_HWBASE + OMAP35XX_GPTIMER1_OFFSET)
#define OMAP35XX_GPTIMER2_VBASE (OMAP35XX_L4_PERIPH_VBASE + OMAP35XX_GPTIMER2_OFFSET)
#define OMAP35XX_GPTIMER2_HWBASE (OMAP35XX_L4_PERIPH_HWBASE + OMAP35XX_GPTIMER2_OFFSET)
#define OMAP35XX_GPTIMER3_VBASE (OMAP35XX_L4_PERIPH_VBASE + OMAP35XX_GPTIMER3_OFFSET)
#define OMAP35XX_GPTIMER3_HWBASE (OMAP35XX_L4_PERIPH_HWBASE + OMAP35XX_GPTIMER3_OFFSET)
#define OMAP35XX_GPTIMER4_VBASE (OMAP35XX_L4_PERIPH_VBASE + OMAP35XX_GPTIMER4_OFFSET)
#define OMAP35XX_GPTIMER4_HWBASE (OMAP35XX_L4_PERIPH_HWBASE + OMAP35XX_GPTIMER4_OFFSET)
#define OMAP35XX_GPTIMER5_VBASE (OMAP35XX_L4_PERIPH_VBASE + OMAP35XX_GPTIMER5_OFFSET)
#define OMAP35XX_GPTIMER5_HWBASE (OMAP35XX_L4_PERIPH_HWBASE + OMAP35XX_GPTIMER5_OFFSET)
#define OMAP35XX_GPTIMER6_VBASE (OMAP35XX_L4_PERIPH_VBASE + OMAP35XX_GPTIMER6_OFFSET)
#define OMAP35XX_GPTIMER6_HWBASE (OMAP35XX_L4_PERIPH_HWBASE + OMAP35XX_GPTIMER6_OFFSET)
#define OMAP35XX_GPTIMER7_VBASE (OMAP35XX_L4_PERIPH_VBASE + OMAP35XX_GPTIMER7_OFFSET)
#define OMAP35XX_GPTIMER7_HWBASE (OMAP35XX_L4_PERIPH_HWBASE + OMAP35XX_GPTIMER7_OFFSET)
#define OMAP35XX_GPTIMER8_VBASE (OMAP35XX_L4_PERIPH_VBASE + OMAP35XX_GPTIMER8_OFFSET)
#define OMAP35XX_GPTIMER8_HWBASE (OMAP35XX_L4_PERIPH_HWBASE + OMAP35XX_GPTIMER8_OFFSET)
#define OMAP35XX_GPTIMER9_VBASE (OMAP35XX_L4_PERIPH_VBASE + OMAP35XX_GPTIMER9_OFFSET)
#define OMAP35XX_GPTIMER9_HWBASE (OMAP35XX_L4_PERIPH_HWBASE + OMAP35XX_GPTIMER9_OFFSET)
#define OMAP35XX_GPTIMER10_VBASE (OMAP35XX_L4_CORE_VBASE + OMAP35XX_GPTIMER10_OFFSET)
#define OMAP35XX_GPTIMER10_HWBASE (OMAP35XX_L4_CORE_HWBASE + OMAP35XX_GPTIMER10_OFFSET)
#define OMAP35XX_GPTIMER11_VBASE (OMAP35XX_L4_CORE_VBASE + OMAP35XX_GPTIMER11_OFFSET)
#define OMAP35XX_GPTIMER11_HWBASE (OMAP35XX_L4_CORE_HWBASE + OMAP35XX_GPTIMER11_OFFSET)
#define OMAP35XX_GPTIMER12_VBASE 0x48304000UL /* GPTIMER12 */
#define OMAP35XX_GPTIMER_SIZE 0x00001000UL
/* Timer register offsets */
#define OMAP35XX_GPTIMER_TIOCP_CFG 0x010
#define OMAP35XX_GPTIMER_TISTAT 0x014
#define OMAP35XX_GPTIMER_TISR 0x018
#define OMAP35XX_GPTIMER_TIER 0x01C
#define OMAP35XX_GPTIMER_TWER 0x020
#define OMAP35XX_GPTIMER_TCLR 0x024
#define OMAP35XX_GPTIMER_TCRR 0x028
#define OMAP35XX_GPTIMER_TLDR 0x02C
#define OMAP35XX_GPTIMER_TTGR 0x030
#define OMAP35XX_GPTIMER_TWPS 0x034
#define OMAP35XX_GPTIMER_TMAR 0x038
#define OMAP35XX_GPTIMER_TCAR1 0x03C
#define OMAP35XX_GPTIMER_TSICR 0x040
#define OMAP35XX_GPTIMER_TCAR2 0x044
#define OMAP35XX_GPTIMER_TPIR 0x048
#define OMAP35XX_GPTIMER_TNIR 0x04C
#define OMAP35XX_GPTIMER_TCVR 0x050
#define OMAP35XX_GPTIMER_TOCR 0x054
#define OMAP35XX_GPTIMER_TOWR 0x058
/* Bit values */
#define MAT_IT_FLAG 0x01
#define OVF_IT_FLAG 0x02
#define TCAR_IT_FLAG 0x04
/*
* GPIO - General Purpose IO
*/
/* Base addresses for the GPIO modules */
#define OMAP35XX_GPIO1_HWBASE (OMAP35XX_L4_WAKEUP_HWBASE + OMAP35XX_GPIO1_OFFSET)
#define OMAP35XX_GPIO1_VBASE (OMAP35XX_L4_WAKEUP_VBASE + OMAP35XX_GPIO1_OFFSET)
#define OMAP35XX_GPIO1_SIZE 0x00001000UL
#define OMAP35XX_GPIO2_HWBASE (OMAP35XX_L4_PERIPH_HWBASE + OMAP35XX_GPIO2_OFFSET)
#define OMAP35XX_GPIO2_VBASE (OMAP35XX_L4_PERIPH_VBASE + OMAP35XX_GPIO2_OFFSET)
#define OMAP35XX_GPIO2_SIZE 0x00001000UL
#define OMAP35XX_GPIO3_HWBASE (OMAP35XX_L4_PERIPH_HWBASE + OMAP35XX_GPIO3_OFFSET)
#define OMAP35XX_GPIO3_VBASE (OMAP35XX_L4_PERIPH_VBASE + OMAP35XX_GPIO3_OFFSET)
#define OMAP35XX_GPIO3_SIZE 0x00001000UL
#define OMAP35XX_GPIO4_HWBASE (OMAP35XX_L4_PERIPH_HWBASE + OMAP35XX_GPIO4_OFFSET)
#define OMAP35XX_GPIO4_VBASE (OMAP35XX_L4_PERIPH_VBASE + OMAP35XX_GPIO4_OFFSET)
#define OMAP35XX_GPIO4_SIZE 0x00001000UL
#define OMAP35XX_GPIO5_HWBASE (OMAP35XX_L4_PERIPH_HWBASE + OMAP35XX_GPIO5_OFFSET)
#define OMAP35XX_GPIO5_VBASE (OMAP35XX_L4_PERIPH_VBASE + OMAP35XX_GPIO5_OFFSET)
#define OMAP35XX_GPIO5_SIZE 0x00001000UL
#define OMAP35XX_GPIO6_HWBASE (OMAP35XX_L4_PERIPH_HWBASE + OMAP35XX_GPIO6_OFFSET)
#define OMAP35XX_GPIO6_VBASE (OMAP35XX_L4_PERIPH_VBASE + OMAP35XX_GPIO6_OFFSET)
#define OMAP35XX_GPIO6_SIZE 0x00001000UL
/* Register offsets within the banks above */
#define OMAP35XX_GPIO_SYSCONFIG 0x010
#define OMAP35XX_GPIO_SYSSTATUS 0x014
#define OMAP35XX_GPIO_IRQSTATUS1 0x018
#define OMAP35XX_GPIO_IRQENABLE1 0x01C
#define OMAP35XX_GPIO_WAKEUPENABLE 0x020
#define OMAP35XX_GPIO_IRQSTATUS2 0x028
#define OMAP35XX_GPIO_IRQENABLE2 0x02C
#define OMAP35XX_GPIO_CTRL 0x030
#define OMAP35XX_GPIO_OE 0x034
#define OMAP35XX_GPIO_DATAIN 0x038
#define OMAP35XX_GPIO_DATAOUT 0x03C
#define OMAP35XX_GPIO_LEVELDETECT0 0x040
#define OMAP35XX_GPIO_LEVELDETECT1 0x044
#define OMAP35XX_GPIO_RISINGDETECT 0x048
#define OMAP35XX_GPIO_FALLINGDETECT 0x04C
#define OMAP35XX_GPIO_DEBOUNCENABLE 0x050
#define OMAP35XX_GPIO_DEBOUNCINGTIME 0x054
#define OMAP35XX_GPIO_CLEARIRQENABLE1 0x060
#define OMAP35XX_GPIO_SETIRQENABLE1 0x064
#define OMAP35XX_GPIO_CLEARIRQENABLE2 0x070
#define OMAP35XX_GPIO_SETIRQENABLE2 0x074
#define OMAP35XX_GPIO_CLEARWKUENA 0x080
#define OMAP35XX_GPIO_SETWKUENA 0x084
#define OMAP35XX_GPIO_CLEARDATAOUT 0x090
#define OMAP35XX_GPIO_SETDATAOUT 0x094
/*
* MMC/SD/SDIO
*/
/* Base addresses for the MMC/SD/SDIO modules */
#define OMAP35XX_MMCHS1_HWBASE (OMAP35XX_L4_CORE_HWBASE + 0x0009C000)
#define OMAP35XX_MMCHS1_VBASE (OMAP35XX_L4_CORE_VBASE + 0x0009C000)
#define OMAP35XX_MMCHS2_HWBASE (OMAP35XX_L4_CORE_HWBASE + 0x000B4000)
#define OMAP35XX_MMCHS2_VBASE (OMAP35XX_L4_CORE_VBASE + 0x000B4000)
#define OMAP35XX_MMCHS3_HWBASE (OMAP35XX_L4_CORE_HWBASE + 0x000AD000)
#define OMAP35XX_MMCHS3_VBASE (OMAP35XX_L4_CORE_VBASE + 0x000AD000)
#define OMAP35XX_MMCHS_SIZE 0x00000200UL
/* Register offsets within each of the MMC/SD/SDIO controllers */
#define OMAP35XX_MMCHS_SYSCONFIG 0x010
#define OMAP35XX_MMCHS_SYSSTATUS 0x014
#define OMAP35XX_MMCHS_CSRE 0x024
#define OMAP35XX_MMCHS_SYSTEST 0x028
#define OMAP35XX_MMCHS_CON 0x02C
#define OMAP35XX_MMCHS_PWCNT 0x030
#define OMAP35XX_MMCHS_BLK 0x104
#define OMAP35XX_MMCHS_ARG 0x108
#define OMAP35XX_MMCHS_CMD 0x10C
#define OMAP35XX_MMCHS_RSP10 0x110
#define OMAP35XX_MMCHS_RSP32 0x114
#define OMAP35XX_MMCHS_RSP54 0x118
#define OMAP35XX_MMCHS_RSP76 0x11C
#define OMAP35XX_MMCHS_DATA 0x120
#define OMAP35XX_MMCHS_PSTATE 0x124
#define OMAP35XX_MMCHS_HCTL 0x128
#define OMAP35XX_MMCHS_SYSCTL 0x12C
#define OMAP35XX_MMCHS_STAT 0x130
#define OMAP35XX_MMCHS_IE 0x134
#define OMAP35XX_MMCHS_ISE 0x138
#define OMAP35XX_MMCHS_AC12 0x13C
#define OMAP35XX_MMCHS_CAPA 0x140
#define OMAP35XX_MMCHS_CUR_CAPA 0x148
#define OMAP35XX_MMCHS_REV 0x1FC
#endif /* _OMAP35XX_REG_H_ */

View File

@ -6,8 +6,6 @@ arm/ti/ti_smc.S standard
arm/ti/usb/omap_ehci.c optional usb ehci arm/ti/usb/omap_ehci.c optional usb ehci
arm/ti/ti_sdma.c optional ti_sdma arm/ti/ti_sdma.c optional ti_sdma
arm/ti/ti_sdhci.c optional sdhci
#arm/ti/ti_mmchs.c optional mmc
arm/ti/omap4/omap4_l2cache.c optional pl310 arm/ti/omap4/omap4_l2cache.c optional pl310
arm/ti/omap4/omap4_prcm_clks.c standard arm/ti/omap4/omap4_prcm_clks.c standard

View File

@ -49,7 +49,6 @@ __FBSDID("$FreeBSD$");
#include <arm/ti/ti_cpuid.h> #include <arm/ti/ti_cpuid.h>
#include <arm/ti/omap4/omap4_reg.h> #include <arm/ti/omap4/omap4_reg.h>
#include <arm/ti/omap3/omap3_reg.h>
#include <arm/ti/am335x/am335x_reg.h> #include <arm/ti/am335x/am335x_reg.h>
#define OMAP4_STD_FUSE_DIE_ID_0 0x2200 #define OMAP4_STD_FUSE_DIE_ID_0 0x2200
@ -198,67 +197,6 @@ omap4_get_revision(void)
} }
} }
/**
* omap3_get_revision - determines omap3 revision
*
* Reads the registers to determine the revision of the chip we are currently
* running on. Stores the information in global variables.
*
* WARNING: This function currently only really works for OMAP3530 devices.
*
*
*
*/
static void
omap3_get_revision(void)
{
uint32_t id_code;
uint32_t revision;
uint32_t hawkeye;
bus_space_handle_t bsh;
/* The chip revsion is read from the device identification registers and
* the JTAG (?) tap registers, which are located in address 0x4A00_2200 to
* 0x4A00_2218. This is part of the L4_CORE memory range and should have
* been mapped in by the machdep.c code.
*
* CONTROL_IDCODE 0x4830 A204 (this is the only one we need)
*
*
*/
bus_space_map(fdtbus_bs_tag, OMAP35XX_L4_WAKEUP_HWBASE, 0x10000, 0, &bsh);
id_code = bus_space_read_4(fdtbus_bs_tag, bsh, OMAP3_ID_CODE);
bus_space_unmap(fdtbus_bs_tag, bsh, 0x10000);
hawkeye = ((id_code >> 12) & 0xffff);
revision = ((id_code >> 28) & 0xf);
switch (hawkeye) {
case 0xB6D6:
chip_revision = OMAP3350_REV_ES1_0;
break;
case 0xB7AE:
if (revision == 1)
chip_revision = OMAP3530_REV_ES2_0;
else if (revision == 2)
chip_revision = OMAP3530_REV_ES2_1;
else if (revision == 3)
chip_revision = OMAP3530_REV_ES3_0;
else if (revision == 4)
chip_revision = OMAP3530_REV_ES3_1;
else if (revision == 7)
chip_revision = OMAP3530_REV_ES3_1_2;
break;
default:
/* Default to the latest revision if we can't determine type */
chip_revision = OMAP3530_REV_ES3_1_2;
break;
}
printf("Texas Instruments OMAP%04x Processor, Revision ES%u.%u\n",
OMAP_REV_DEVICE(chip_revision), OMAP_REV_MAJOR(chip_revision),
OMAP_REV_MINOR(chip_revision));
}
static void static void
am335x_get_revision(void) am335x_get_revision(void)
{ {
@ -313,9 +251,6 @@ static void
ti_cpu_ident(void *dummy) ti_cpu_ident(void *dummy)
{ {
switch(ti_chip()) { switch(ti_chip()) {
case CHIP_OMAP_3:
omap3_get_revision();
break;
case CHIP_OMAP_4: case CHIP_OMAP_4:
omap4_get_revision(); omap4_get_revision();
break; break;

View File

@ -67,16 +67,13 @@
#define AM335X_DEVREV(x) ((x) >> 28) #define AM335X_DEVREV(x) ((x) >> 28)
#define CHIP_OMAP_3 0 #define CHIP_OMAP_4 0
#define CHIP_OMAP_4 1 #define CHIP_AM335X 1
#define CHIP_AM335X 2
static __inline int ti_chip(void) static __inline int ti_chip(void)
{ {
#if defined(SOC_OMAP4) #if defined(SOC_OMAP4)
return CHIP_OMAP_4; return CHIP_OMAP_4;
#elif defined(SOC_OMAP3)
return CHIP_OMAP_3;
#elif defined(SOC_TI_AM335X) #elif defined(SOC_TI_AM335X)
return CHIP_AM335X; return CHIP_AM335X;
#else #else

View File

@ -70,32 +70,7 @@ __FBSDID("$FreeBSD$");
/* Register definitions */ /* Register definitions */
#define TI_GPIO_REVISION 0x0000 #define TI_GPIO_REVISION 0x0000
#define TI_GPIO_SYSCONFIG 0x0010 #define TI_GPIO_SYSCONFIG 0x0010
#if defined(SOC_OMAP3) #if defined(SOC_OMAP4) || defined(SOC_TI_AM335X)
#define TI_GPIO_SYSSTATUS 0x0014
#define TI_GPIO_IRQSTATUS1 0x0018
#define TI_GPIO_IRQENABLE1 0x001C
#define TI_GPIO_WAKEUPENABLE 0x0020
#define TI_GPIO_IRQSTATUS2 0x0028
#define TI_GPIO_IRQENABLE2 0x002C
#define TI_GPIO_CTRL 0x0030
#define TI_GPIO_OE 0x0034
#define TI_GPIO_DATAIN 0x0038
#define TI_GPIO_DATAOUT 0x003C
#define TI_GPIO_LEVELDETECT0 0x0040
#define TI_GPIO_LEVELDETECT1 0x0044
#define TI_GPIO_RISINGDETECT 0x0048
#define TI_GPIO_FALLINGDETECT 0x004C
#define TI_GPIO_DEBOUNCENABLE 0x0050
#define TI_GPIO_DEBOUNCINGTIME 0x0054
#define TI_GPIO_CLEARIRQENABLE1 0x0060
#define TI_GPIO_SETIRQENABLE1 0x0064
#define TI_GPIO_CLEARIRQENABLE2 0x0070
#define TI_GPIO_SETIRQENABLE2 0x0074
#define TI_GPIO_CLEARWKUENA 0x0080
#define TI_GPIO_SETWKUENA 0x0084
#define TI_GPIO_CLEARDATAOUT 0x0090
#define TI_GPIO_SETDATAOUT 0x0094
#elif defined(SOC_OMAP4) || defined(SOC_TI_AM335X)
#define TI_GPIO_IRQSTATUS_RAW_0 0x0024 #define TI_GPIO_IRQSTATUS_RAW_0 0x0024
#define TI_GPIO_IRQSTATUS_RAW_1 0x0028 #define TI_GPIO_IRQSTATUS_RAW_1 0x0028
#define TI_GPIO_IRQSTATUS_0 0x002C #define TI_GPIO_IRQSTATUS_0 0x002C
@ -131,10 +106,6 @@ __FBSDID("$FreeBSD$");
#endif #endif
/* Other SoC Specific definitions */ /* Other SoC Specific definitions */
#define OMAP3_MAX_GPIO_BANKS 6
#define OMAP3_FIRST_GPIO_BANK 1
#define OMAP3_INTR_PER_BANK 1
#define OMAP3_GPIO_REV 0x00000025
#define OMAP4_MAX_GPIO_BANKS 6 #define OMAP4_MAX_GPIO_BANKS 6
#define OMAP4_FIRST_GPIO_BANK 1 #define OMAP4_FIRST_GPIO_BANK 1
#define OMAP4_INTR_PER_BANK 1 #define OMAP4_INTR_PER_BANK 1
@ -152,10 +123,6 @@ static u_int
ti_max_gpio_banks(void) ti_max_gpio_banks(void)
{ {
switch(ti_chip()) { switch(ti_chip()) {
#ifdef SOC_OMAP3
case CHIP_OMAP_3:
return (OMAP3_MAX_GPIO_BANKS);
#endif
#ifdef SOC_OMAP4 #ifdef SOC_OMAP4
case CHIP_OMAP_4: case CHIP_OMAP_4:
return (OMAP4_MAX_GPIO_BANKS); return (OMAP4_MAX_GPIO_BANKS);
@ -172,10 +139,6 @@ static u_int
ti_max_gpio_intrs(void) ti_max_gpio_intrs(void)
{ {
switch(ti_chip()) { switch(ti_chip()) {
#ifdef SOC_OMAP3
case CHIP_OMAP_3:
return (OMAP3_MAX_GPIO_BANKS * OMAP3_INTR_PER_BANK);
#endif
#ifdef SOC_OMAP4 #ifdef SOC_OMAP4
case CHIP_OMAP_4: case CHIP_OMAP_4:
return (OMAP4_MAX_GPIO_BANKS * OMAP4_INTR_PER_BANK); return (OMAP4_MAX_GPIO_BANKS * OMAP4_INTR_PER_BANK);
@ -192,10 +155,6 @@ static u_int
ti_first_gpio_bank(void) ti_first_gpio_bank(void)
{ {
switch(ti_chip()) { switch(ti_chip()) {
#ifdef SOC_OMAP3
case CHIP_OMAP_3:
return (OMAP3_FIRST_GPIO_BANK);
#endif
#ifdef SOC_OMAP4 #ifdef SOC_OMAP4
case CHIP_OMAP_4: case CHIP_OMAP_4:
return (OMAP4_FIRST_GPIO_BANK); return (OMAP4_FIRST_GPIO_BANK);
@ -212,10 +171,6 @@ static uint32_t
ti_gpio_rev(void) ti_gpio_rev(void)
{ {
switch(ti_chip()) { switch(ti_chip()) {
#ifdef SOC_OMAP3
case CHIP_OMAP_3:
return (OMAP3_GPIO_REV);
#endif
#ifdef SOC_OMAP4 #ifdef SOC_OMAP4
case CHIP_OMAP_4: case CHIP_OMAP_4:
return (OMAP4_GPIO_REV); return (OMAP4_GPIO_REV);

View File

@ -111,10 +111,6 @@ struct ti_i2c_clock_config
uint8_t hssclh; /* High Speed mode SCL high time */ uint8_t hssclh; /* High Speed mode SCL high time */
}; };
#if defined(SOC_OMAP3)
#error "Unsupported SoC"
#endif
#if defined(SOC_OMAP4) #if defined(SOC_OMAP4)
static struct ti_i2c_clock_config ti_omap4_i2c_clock_configs[] = { static struct ti_i2c_clock_config ti_omap4_i2c_clock_configs[] = {
{ IIC_UNKNOWN, 100000, 23, 13, 15, 0, 0}, { IIC_UNKNOWN, 100000, 23, 13, 15, 0, 0},

File diff suppressed because it is too large Load Diff

View File

@ -1,176 +0,0 @@
/*-
* Copyright (c) 2011
* Ben Gray <ben.r.gray@gmail.com>.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $FreeBSD$
*/
#ifndef _TI_MMCHS_H_
#define _TI_MMCHS_H_
/**
* Header file for the TI MMC/SD/SDIO driver.
*
* Simply contains register addresses and bit flags.
*/
/* Register offsets within each of the MMC/SD/SDIO controllers */
#define MMCHS_SYSCONFIG 0x010
#define MMCHS_SYSSTATUS 0x014
#define MMCHS_CSRE 0x024
#define MMCHS_SYSTEST 0x028
#define MMCHS_CON 0x02C
#define MMCHS_PWCNT 0x030
#define MMCHS_BLK 0x104
#define MMCHS_ARG 0x108
#define MMCHS_CMD 0x10C
#define MMCHS_RSP10 0x110
#define MMCHS_RSP32 0x114
#define MMCHS_RSP54 0x118
#define MMCHS_RSP76 0x11C
#define MMCHS_DATA 0x120
#define MMCHS_PSTATE 0x124
#define MMCHS_HCTL 0x128
#define MMCHS_SYSCTL 0x12C
#define MMCHS_STAT 0x130
#define MMCHS_IE 0x134
#define MMCHS_ISE 0x138
#define MMCHS_AC12 0x13C
#define MMCHS_CAPA 0x140
#define MMCHS_CUR_CAPA 0x148
#define MMCHS_REV 0x1FC
/* OMAP4 and OMAP4 have different register addresses */
#define OMAP3_MMCHS_REG_OFFSET 0x000
#define OMAP4_MMCHS_REG_OFFSET 0x100
#define AM335X_MMCHS_REG_OFFSET 0x100
/* Register bit settings */
#define MMCHS_SYSCONFIG_CLK_FUN (2 << 8)
#define MMCHS_SYSCONFIG_CLK_IFC (1 << 8)
#define MMCHS_SYSCONFIG_SIDL (2 << 3)
#define MMCHS_SYSCONFIG_ENW (1 << 2)
#define MMCHS_SYSCONFIG_SRST (1 << 1)
#define MMCHS_SYSCONFIG_AIDL (1 << 0)
#define MMCHS_STAT_BADA (1UL << 29)
#define MMCHS_STAT_CERR (1UL << 28)
#define MMCHS_STAT_ACE (1UL << 24)
#define MMCHS_STAT_DEB (1UL << 22)
#define MMCHS_STAT_DCRC (1UL << 21)
#define MMCHS_STAT_DTO (1UL << 20)
#define MMCHS_STAT_CIE (1UL << 19)
#define MMCHS_STAT_CEB (1UL << 18)
#define MMCHS_STAT_CCRC (1UL << 17)
#define MMCHS_STAT_CTO (1UL << 16)
#define MMCHS_STAT_ERRI (1UL << 15)
#define MMCHS_STAT_OBI (1UL << 9)
#define MMCHS_STAT_CIRQ (1UL << 8)
#define MMCHS_STAT_BRR (1UL << 5)
#define MMCHS_STAT_BWR (1UL << 4)
#define MMCHS_STAT_BGE (1UL << 2)
#define MMCHS_STAT_TC (1UL << 1)
#define MMCHS_STAT_CC (1UL << 0)
#define MMCHS_STAT_CLEAR_MASK 0x3BFF8337UL
#define MMCHS_SYSCTL_SRD (1UL << 26)
#define MMCHS_SYSCTL_SRC (1UL << 25)
#define MMCHS_SYSCTL_SRA (1UL << 24)
#define MMCHS_SYSCTL_DTO(x) (((x) & 0xf) << 16)
#define MMCHS_SYSCTL_DTO_MASK MMCHS_SYSCTL_DTO(0xf)
#define MMCHS_SYSCTL_CLKD(x) (((x) & 0x3ff) << 6)
#define MMCHS_SYSCTL_CLKD_MASK MMCHS_SYSCTL_CLKD(0x3ff)
#define MMCHS_SYSCTL_CEN (1UL << 2)
#define MMCHS_SYSCTL_ICS (1UL << 1)
#define MMCHS_SYSCTL_ICE (1UL << 0)
#define MMCHS_HCTL_OBWE (1UL << 27)
#define MMCHS_HCTL_REM (1UL << 26)
#define MMCHS_HCTL_INS (1UL << 25)
#define MMCHS_HCTL_IWE (1UL << 24)
#define MMCHS_HCTL_IBG (1UL << 19)
#define MMCHS_HCTL_RWC (1UL << 18)
#define MMCHS_HCTL_CR (1UL << 17)
#define MMCHS_HCTL_SBGR (1UL << 16)
#define MMCHS_HCTL_SDVS_MASK (7UL << 9)
#define MMCHS_HCTL_SDVS_V18 (5UL << 9)
#define MMCHS_HCTL_SDVS_V30 (6UL << 9)
#define MMCHS_HCTL_SDVS_V33 (7UL << 9)
#define MMCHS_HCTL_SDBP (1UL << 8)
#define MMCHS_HCTL_DTW (1UL << 1)
#define MMCHS_CAPA_VS18 (1UL << 26)
#define MMCHS_CAPA_VS30 (1UL << 25)
#define MMCHS_CAPA_VS33 (1UL << 24)
#define MMCHS_CMD_CMD_TYPE_IO_ABORT (3UL << 21)
#define MMCHS_CMD_CMD_TYPE_FUNC_SEL (2UL << 21)
#define MMCHS_CMD_CMD_TYPE_SUSPEND (1UL << 21)
#define MMCHS_CMD_CMD_TYPE_OTHERS (0UL << 21)
#define MMCHS_CMD_CMD_TYPE_MASK (3UL << 22)
#define MMCHS_CMD_DP (1UL << 21)
#define MMCHS_CMD_CICE (1UL << 20)
#define MMCHS_CMD_CCCE (1UL << 19)
#define MMCHS_CMD_RSP_TYPE_MASK (3UL << 16)
#define MMCHS_CMD_RSP_TYPE_NO (0UL << 16)
#define MMCHS_CMD_RSP_TYPE_136 (1UL << 16)
#define MMCHS_CMD_RSP_TYPE_48 (2UL << 16)
#define MMCHS_CMD_RSP_TYPE_48_BSY (3UL << 16)
#define MMCHS_CMD_MSBS (1UL << 5)
#define MMCHS_CMD_DDIR (1UL << 4)
#define MMCHS_CMD_ACEN (1UL << 2)
#define MMCHS_CMD_BCE (1UL << 1)
#define MMCHS_CMD_DE (1UL << 0)
#define MMCHS_CON_CLKEXTFREE (1UL << 16)
#define MMCHS_CON_PADEN (1UL << 15)
#define MMCHS_CON_OBIE (1UL << 14)
#define MMCHS_CON_OBIP (1UL << 13)
#define MMCHS_CON_CEATA (1UL << 12)
#define MMCHS_CON_CTPL (1UL << 11)
#define MMCHS_CON_DVAL_8_4MS (3UL << 9)
#define MMCHS_CON_DVAL_1MS (2UL << 9)
#define MMCHS_CON_DVAL_231US (1UL << 9)
#define MMCHS_CON_DVAL_33US (0UL << 9)
#define MMCHS_CON_DVAL_MASK (3UL << 9)
#define MMCHS_CON_WPP (1UL << 8)
#define MMCHS_CON_CDP (1UL << 7)
#define MMCHS_CON_MIT (1UL << 6)
#define MMCHS_CON_DW8 (1UL << 5)
#define MMCHS_CON_MODE (1UL << 4)
#define MMCHS_CON_STR (1UL << 3)
#define MMCHS_CON_HR (1UL << 2)
#define MMCHS_CON_INIT (1UL << 1)
#define MMCHS_CON_OD (1UL << 0)
#define MMCHS_CAPA_VS18 (1UL << 26)
#define MMCHS_CAPA_VS30 (1UL << 25)
#define MMCHS_CAPA_VS33 (1UL << 24)
#endif /* _TI_MMCHS_H_ */

View File

@ -494,15 +494,21 @@ ti_sdhci_attach(device_t dev)
* Set the offset from the device's memory start to the MMCHS registers. * Set the offset from the device's memory start to the MMCHS registers.
* Also for OMAP4 disable high speed mode due to erratum ID i626. * Also for OMAP4 disable high speed mode due to erratum ID i626.
*/ */
if (ti_chip() == CHIP_OMAP_3) switch (ti_chip()) {
sc->mmchs_reg_off = OMAP3_MMCHS_REG_OFFSET; #ifdef SOC_OMAP4
else if (ti_chip() == CHIP_OMAP_4) { case CHIP_OMAP_4:
sc->mmchs_reg_off = OMAP4_MMCHS_REG_OFFSET; sc->mmchs_reg_off = OMAP4_MMCHS_REG_OFFSET;
sc->disable_highspeed = true; sc->disable_highspeed = true;
} else if (ti_chip() == CHIP_AM335X) break;
#endif
#ifdef SOC_TI_AM335X
case CHIP_AM335X:
sc->mmchs_reg_off = AM335X_MMCHS_REG_OFFSET; sc->mmchs_reg_off = AM335X_MMCHS_REG_OFFSET;
else break;
#endif
default:
panic("Unknown OMAP device\n"); panic("Unknown OMAP device\n");
}
/* /*
* The standard SDHCI registers are at a fixed offset (the same on all * The standard SDHCI registers are at a fixed offset (the same on all

View File

@ -38,6 +38,9 @@
model = "Terasic SoCKit"; model = "Terasic SoCKit";
compatible = "altr,socfpga-cyclone5", "altr,socfpga"; compatible = "altr,socfpga-cyclone5", "altr,socfpga";
/* Reserve first page for secondary CPU trampoline code */
memreserve = < 0x00000000 0x1000 >;
memory { memory {
device_type = "memory"; device_type = "memory";
reg = < 0x00000000 0x40000000 >; /* 1G RAM */ reg = < 0x00000000 0x40000000 >; /* 1G RAM */

View File

@ -1,6 +1,7 @@
/* $FreeBSD$ */ /* $FreeBSD$ */
OUTPUT_FORMAT("elf32-powerpc", "elf32-powerpc", "elf32-powerpc") OUTPUT_FORMAT("elf32-powerpc-freebsd", "elf32-powerpc-freebsd",
"elf32-powerpc-freebsd")
OUTPUT_ARCH(powerpc:common) OUTPUT_ARCH(powerpc:common)
ENTRY(_start) ENTRY(_start)
SEARCH_DIR(/usr/lib); SEARCH_DIR(/usr/lib);

View File

@ -1,6 +1,7 @@
/* $FreeBSD$ */ /* $FreeBSD$ */
OUTPUT_FORMAT("elf32-powerpc", "elf32-powerpc", "elf32-powerpc") OUTPUT_FORMAT("elf32-powerpc-freebsd", "elf32-powerpc-freebsd",
"elf32-powerpc-freebsd")
OUTPUT_ARCH(powerpc:common) OUTPUT_ARCH(powerpc:common)
ENTRY(_start) ENTRY(_start)
SEARCH_DIR(/usr/lib); SEARCH_DIR(/usr/lib);

View File

@ -1,6 +1,7 @@
/* $FreeBSD$ */ /* $FreeBSD$ */
OUTPUT_FORMAT("elf32-powerpc", "elf32-powerpc", "elf32-powerpc") OUTPUT_FORMAT("elf32-powerpc-freebsd", "elf32-powerpc-freebsd",
"elf32-powerpc-freebsd")
OUTPUT_ARCH(powerpc:common) OUTPUT_ARCH(powerpc:common)
ENTRY(_start) ENTRY(_start)
SEARCH_DIR(/usr/lib); SEARCH_DIR(/usr/lib);

View File

@ -2237,6 +2237,43 @@ ctl_sbuf_printf_esc(struct sbuf *sb, char *str)
return (retval); return (retval);
} }
static void
ctl_id_sbuf(struct ctl_devid *id, struct sbuf *sb)
{
struct scsi_vpd_id_descriptor *desc;
int i;
if (id == NULL || id->len < 4)
return;
desc = (struct scsi_vpd_id_descriptor *)id->data;
switch (desc->id_type & SVPD_ID_TYPE_MASK) {
case SVPD_ID_TYPE_T10:
sbuf_printf(sb, "t10.");
break;
case SVPD_ID_TYPE_EUI64:
sbuf_printf(sb, "eui.");
break;
case SVPD_ID_TYPE_NAA:
sbuf_printf(sb, "naa.");
break;
case SVPD_ID_TYPE_SCSI_NAME:
break;
}
switch (desc->proto_codeset & SVPD_ID_CODESET_MASK) {
case SVPD_ID_CODESET_BINARY:
for (i = 0; i < desc->length; i++)
sbuf_printf(sb, "%02x", desc->identifier[i]);
break;
case SVPD_ID_CODESET_ASCII:
sbuf_printf(sb, "%.*s", (int)desc->length,
(char *)desc->identifier);
break;
case SVPD_ID_CODESET_UTF8:
sbuf_printf(sb, "%s", (char *)desc->identifier);
break;
}
}
static int static int
ctl_ioctl(struct cdev *dev, u_long cmd, caddr_t addr, int flag, ctl_ioctl(struct cdev *dev, u_long cmd, caddr_t addr, int flag,
struct thread *td) struct thread *td)
@ -2990,12 +3027,11 @@ ctl_ioctl(struct cdev *dev, u_long cmd, caddr_t addr, int flag,
for (j = 0; j < (CTL_MAX_PORTS * 2); j++) { for (j = 0; j < (CTL_MAX_PORTS * 2); j++) {
for (k = 0; k < CTL_MAX_INIT_PER_PORT; k++){ for (k = 0; k < CTL_MAX_INIT_PER_PORT; k++){
idx = j * CTL_MAX_INIT_PER_PORT + k; idx = j * CTL_MAX_INIT_PER_PORT + k;
if (lun->per_res[idx].registered == 0) if (lun->pr_keys[idx] == 0)
continue; continue;
printf(" LUN %d port %d iid %d key " printf(" LUN %d port %d iid %d key "
"%#jx\n", i, j, k, "%#jx\n", i, j, k,
(uintmax_t)scsi_8btou64( (uintmax_t)lun->pr_keys[idx]);
lun->per_res[idx].res_key.key));
} }
} }
} }
@ -3289,6 +3325,7 @@ ctl_ioctl(struct cdev *dev, u_long cmd, caddr_t addr, int flag,
struct ctl_port *port; struct ctl_port *port;
struct ctl_lun_list *list; struct ctl_lun_list *list;
struct ctl_option *opt; struct ctl_option *opt;
int j;
list = (struct ctl_lun_list *)addr; list = (struct ctl_lun_list *)addr;
@ -3345,15 +3382,17 @@ ctl_ioctl(struct cdev *dev, u_long cmd, caddr_t addr, int flag,
if (retval != 0) if (retval != 0)
break; break;
retval = sbuf_printf(sb, "\t<wwnn>%#jx</wwnn>\n", if (port->target_devid != NULL) {
(uintmax_t)port->wwnn); sbuf_printf(sb, "\t<target>");
if (retval != 0) ctl_id_sbuf(port->target_devid, sb);
break; sbuf_printf(sb, "</target>\n");
}
retval = sbuf_printf(sb, "\t<wwpn>%#jx</wwpn>\n", if (port->port_devid != NULL) {
(uintmax_t)port->wwpn); sbuf_printf(sb, "\t<port>");
if (retval != 0) ctl_id_sbuf(port->port_devid, sb);
break; sbuf_printf(sb, "</port>\n");
}
if (port->port_info != NULL) { if (port->port_info != NULL) {
retval = port->port_info(port->onoff_arg, sb); retval = port->port_info(port->onoff_arg, sb);
@ -3367,6 +3406,26 @@ ctl_ioctl(struct cdev *dev, u_long cmd, caddr_t addr, int flag,
break; break;
} }
for (j = 0; j < CTL_MAX_INIT_PER_PORT; j++) {
if (port->wwpn_iid[j].in_use == 0 ||
(port->wwpn_iid[j].wwpn == 0 &&
port->wwpn_iid[j].name == NULL))
continue;
if (port->wwpn_iid[j].name != NULL)
retval = sbuf_printf(sb,
"\t<initiator>%u %s</initiator>\n",
j, port->wwpn_iid[j].name);
else
retval = sbuf_printf(sb,
"\t<initiator>%u naa.%08jx</initiator>\n",
j, port->wwpn_iid[j].wwpn);
if (retval != 0)
break;
}
if (retval != 0)
break;
retval = sbuf_printf(sb, "</targ_port>\n"); retval = sbuf_printf(sb, "</targ_port>\n");
if (retval != 0) if (retval != 0)
break; break;
@ -4600,6 +4659,9 @@ ctl_alloc_lun(struct ctl_softc *ctl_softc, struct ctl_lun *ctl_lun,
be_lun->ctl_lun = lun; be_lun->ctl_lun = lun;
be_lun->lun_id = lun_number; be_lun->lun_id = lun_number;
atomic_add_int(&be_lun->be->num_luns, 1); atomic_add_int(&be_lun->be->num_luns, 1);
if (be_lun->flags & CTL_LUN_FLAG_OFFLINE)
lun->flags |= CTL_LUN_OFFLINE;
if (be_lun->flags & CTL_LUN_FLAG_POWERED_OFF) if (be_lun->flags & CTL_LUN_FLAG_POWERED_OFF)
lun->flags |= CTL_LUN_STOPPED; lun->flags |= CTL_LUN_STOPPED;
@ -5536,7 +5598,7 @@ ctl_start_stop(struct ctl_scsiio *ctsio)
uint32_t residx; uint32_t residx;
residx = ctl_get_resindex(&ctsio->io_hdr.nexus); residx = ctl_get_resindex(&ctsio->io_hdr.nexus);
if (!lun->per_res[residx].registered if (lun->pr_keys[residx] == 0
|| (lun->pr_res_idx!=residx && lun->res_type < 4)) { || (lun->pr_res_idx!=residx && lun->res_type < 4)) {
ctl_set_reservation_conflict(ctsio); ctl_set_reservation_conflict(ctsio);
@ -5827,7 +5889,7 @@ ctl_read_buffer(struct ctl_scsiio *ctsio)
&& residx != lun->pr_res_idx) && residx != lun->pr_res_idx)
|| ((lun->res_type == SPR_TYPE_EX_AC_RO || ((lun->res_type == SPR_TYPE_EX_AC_RO
|| lun->res_type == SPR_TYPE_EX_AC_AR) || lun->res_type == SPR_TYPE_EX_AC_AR)
&& !lun->per_res[residx].registered)) { && lun->pr_keys[residx] == 0)) {
ctl_set_reservation_conflict(ctsio); ctl_set_reservation_conflict(ctsio);
ctl_done((union ctl_io *)ctsio); ctl_done((union ctl_io *)ctsio);
return (CTL_RETVAL_COMPLETE); return (CTL_RETVAL_COMPLETE);
@ -6882,7 +6944,7 @@ ctl_mode_sense(struct ctl_scsiio *ctsio)
&& residx != lun->pr_res_idx) && residx != lun->pr_res_idx)
|| ((lun->res_type == SPR_TYPE_EX_AC_RO || ((lun->res_type == SPR_TYPE_EX_AC_RO
|| lun->res_type == SPR_TYPE_EX_AC_AR) || lun->res_type == SPR_TYPE_EX_AC_AR)
&& !lun->per_res[residx].registered)) { && lun->pr_keys[residx] == 0)) {
ctl_set_reservation_conflict(ctsio); ctl_set_reservation_conflict(ctsio);
ctl_done((union ctl_io *)ctsio); ctl_done((union ctl_io *)ctsio);
return (CTL_RETVAL_COMPLETE); return (CTL_RETVAL_COMPLETE);
@ -7326,6 +7388,89 @@ ctl_read_capacity_16(struct ctl_scsiio *ctsio)
return (CTL_RETVAL_COMPLETE); return (CTL_RETVAL_COMPLETE);
} }
int
ctl_read_defect(struct ctl_scsiio *ctsio)
{
struct scsi_read_defect_data_10 *ccb10;
struct scsi_read_defect_data_12 *ccb12;
struct scsi_read_defect_data_hdr_10 *data10;
struct scsi_read_defect_data_hdr_12 *data12;
struct ctl_lun *lun;
uint32_t alloc_len, data_len;
uint8_t format;
CTL_DEBUG_PRINT(("ctl_read_defect\n"));
lun = (struct ctl_lun *)ctsio->io_hdr.ctl_private[CTL_PRIV_LUN].ptr;
if (lun->flags & CTL_LUN_PR_RESERVED) {
uint32_t residx;
/*
* XXX KDM need a lock here.
*/
residx = ctl_get_resindex(&ctsio->io_hdr.nexus);
if ((lun->res_type == SPR_TYPE_EX_AC
&& residx != lun->pr_res_idx)
|| ((lun->res_type == SPR_TYPE_EX_AC_RO
|| lun->res_type == SPR_TYPE_EX_AC_AR)
&& lun->pr_keys[residx] == 0)) {
ctl_set_reservation_conflict(ctsio);
ctl_done((union ctl_io *)ctsio);
return (CTL_RETVAL_COMPLETE);
}
}
if (ctsio->cdb[0] == READ_DEFECT_DATA_10) {
ccb10 = (struct scsi_read_defect_data_10 *)&ctsio->cdb;
format = ccb10->format;
alloc_len = scsi_2btoul(ccb10->alloc_length);
data_len = sizeof(*data10);
} else {
ccb12 = (struct scsi_read_defect_data_12 *)&ctsio->cdb;
format = ccb12->format;
alloc_len = scsi_4btoul(ccb12->alloc_length);
data_len = sizeof(*data12);
}
if (alloc_len == 0) {
ctl_set_success(ctsio);
ctl_done((union ctl_io *)ctsio);
return (CTL_RETVAL_COMPLETE);
}
ctsio->kern_data_ptr = malloc(data_len, M_CTL, M_WAITOK | M_ZERO);
if (data_len < alloc_len) {
ctsio->residual = alloc_len - data_len;
ctsio->kern_data_len = data_len;
ctsio->kern_total_len = data_len;
} else {
ctsio->residual = 0;
ctsio->kern_data_len = alloc_len;
ctsio->kern_total_len = alloc_len;
}
ctsio->kern_data_resid = 0;
ctsio->kern_rel_offset = 0;
ctsio->kern_sg_entries = 0;
if (ctsio->cdb[0] == READ_DEFECT_DATA_10) {
data10 = (struct scsi_read_defect_data_hdr_10 *)
ctsio->kern_data_ptr;
data10->format = format;
scsi_ulto2b(0, data10->length);
} else {
data12 = (struct scsi_read_defect_data_hdr_12 *)
ctsio->kern_data_ptr;
data12->format = format;
scsi_ulto2b(0, data12->generation);
scsi_ulto4b(0, data12->length);
}
ctsio->scsi_status = SCSI_STATUS_OK;
ctsio->io_hdr.flags |= CTL_FLAG_ALLOCATED;
ctsio->be_move_done = ctl_config_move_done;
ctl_datamove((union ctl_io *)ctsio);
return (CTL_RETVAL_COMPLETE);
}
int int
ctl_report_tagret_port_groups(struct ctl_scsiio *ctsio) ctl_report_tagret_port_groups(struct ctl_scsiio *ctsio)
{ {
@ -7825,7 +7970,7 @@ ctl_persistent_reserve_in(struct ctl_scsiio *ctsio)
lun->pr_key_count, res_keys->header.length); lun->pr_key_count, res_keys->header.length);
for (i = 0, key_count = 0; i < 2*CTL_MAX_INITIATORS; i++) { for (i = 0, key_count = 0; i < 2*CTL_MAX_INITIATORS; i++) {
if (!lun->per_res[i].registered) if (lun->pr_keys[i] == 0)
continue; continue;
/* /*
@ -7851,10 +7996,8 @@ ctl_persistent_reserve_in(struct ctl_scsiio *ctsio)
key_count++; key_count++;
continue; continue;
} }
memcpy(res_keys->keys[key_count].key, scsi_u64to8b(lun->pr_keys[i],
lun->per_res[i].res_key.key, res_keys->keys[key_count].key);
ctl_min(sizeof(res_keys->keys[key_count].key),
sizeof(lun->per_res[i].res_key)));
key_count++; key_count++;
} }
break; break;
@ -7905,9 +8048,8 @@ ctl_persistent_reserve_in(struct ctl_scsiio *ctsio)
* is 0, since it doesn't really matter. * is 0, since it doesn't really matter.
*/ */
if (lun->pr_res_idx != CTL_PR_ALL_REGISTRANTS) { if (lun->pr_res_idx != CTL_PR_ALL_REGISTRANTS) {
memcpy(res->data.reservation, scsi_u64to8b(lun->pr_keys[lun->pr_res_idx],
&lun->per_res[lun->pr_res_idx].res_key, res->data.reservation);
sizeof(struct scsi_per_res_key));
} }
res->data.scopetype = lun->res_type; res->data.scopetype = lun->res_type;
break; break;
@ -7958,11 +8100,10 @@ ctl_persistent_reserve_in(struct ctl_scsiio *ctsio)
res_desc = &res_status->desc[0]; res_desc = &res_status->desc[0];
for (i = 0; i < 2*CTL_MAX_INITIATORS; i++) { for (i = 0; i < 2*CTL_MAX_INITIATORS; i++) {
if (!lun->per_res[i].registered) if (lun->pr_keys[i] == 0)
continue; continue;
memcpy(&res_desc->res_key, &lun->per_res[i].res_key.key, scsi_u64to8b(lun->pr_keys[i], res_desc->res_key.key);
sizeof(res_desc->res_key));
if ((lun->flags & CTL_LUN_PR_RESERVED) && if ((lun->flags & CTL_LUN_PR_RESERVED) &&
(lun->pr_res_idx == i || (lun->pr_res_idx == i ||
lun->pr_res_idx == CTL_PR_ALL_REGISTRANTS)) { lun->pr_res_idx == CTL_PR_ALL_REGISTRANTS)) {
@ -8055,15 +8196,12 @@ ctl_pro_preempt(struct ctl_softc *softc, struct ctl_lun *lun, uint64_t res_key,
return (1); return (1);
} }
/* temporarily unregister this nexus */
lun->per_res[residx].registered = 0;
/* /*
* Unregister everybody else and build UA for * Unregister everybody else and build UA for
* them * them
*/ */
for(i=0; i < 2*CTL_MAX_INITIATORS; i++) { for(i=0; i < 2*CTL_MAX_INITIATORS; i++) {
if (lun->per_res[i].registered == 0) if (i == residx || lun->pr_keys[i] == 0)
continue; continue;
if (!persis_offset if (!persis_offset
@ -8074,11 +8212,8 @@ ctl_pro_preempt(struct ctl_softc *softc, struct ctl_lun *lun, uint64_t res_key,
&& i >= persis_offset) && i >= persis_offset)
lun->pending_ua[i-persis_offset] |= lun->pending_ua[i-persis_offset] |=
CTL_UA_REG_PREEMPT; CTL_UA_REG_PREEMPT;
lun->per_res[i].registered = 0; lun->pr_keys[i] = 0;
memset(&lun->per_res[i].res_key, 0,
sizeof(struct scsi_per_res_key));
} }
lun->per_res[residx].registered = 1;
lun->pr_key_count = 1; lun->pr_key_count = 1;
lun->res_type = type; lun->res_type = type;
if (lun->res_type != SPR_TYPE_WR_EX_AR if (lun->res_type != SPR_TYPE_WR_EX_AR
@ -8142,16 +8277,11 @@ ctl_pro_preempt(struct ctl_softc *softc, struct ctl_lun *lun, uint64_t res_key,
} }
for (i=0; i < 2*CTL_MAX_INITIATORS; i++) { for (i=0; i < 2*CTL_MAX_INITIATORS; i++) {
if (lun->per_res[i].registered if (lun->pr_keys[i] != sa_res_key)
&& memcmp(param->serv_act_res_key,
lun->per_res[i].res_key.key,
sizeof(struct scsi_per_res_key)) != 0)
continue; continue;
found = 1; found = 1;
lun->per_res[i].registered = 0; lun->pr_keys[i] = 0;
memset(&lun->per_res[i].res_key, 0,
sizeof(struct scsi_per_res_key));
lun->pr_key_count--; lun->pr_key_count--;
if (!persis_offset && i < CTL_MAX_INITIATORS) if (!persis_offset && i < CTL_MAX_INITIATORS)
@ -8185,9 +8315,7 @@ ctl_pro_preempt(struct ctl_softc *softc, struct ctl_lun *lun, uint64_t res_key,
} else { } else {
/* Reserved but not all registrants */ /* Reserved but not all registrants */
/* sa_res_key is res holder */ /* sa_res_key is res holder */
if (memcmp(param->serv_act_res_key, if (sa_res_key == lun->pr_keys[lun->pr_res_idx]) {
lun->per_res[lun->pr_res_idx].res_key.key,
sizeof(struct scsi_per_res_key)) == 0) {
/* validate scope and type */ /* validate scope and type */
if ((cdb->scope_type & SPR_SCOPE_MASK) != if ((cdb->scope_type & SPR_SCOPE_MASK) !=
SPR_LU_SCOPE) { SPR_LU_SCOPE) {
@ -8228,22 +8356,12 @@ ctl_pro_preempt(struct ctl_softc *softc, struct ctl_lun *lun, uint64_t res_key,
* except don't unregister the res holder. * except don't unregister the res holder.
*/ */
/*
* Temporarily unregister so it won't get
* removed or UA generated
*/
lun->per_res[residx].registered = 0;
for(i=0; i < 2*CTL_MAX_INITIATORS; i++) { for(i=0; i < 2*CTL_MAX_INITIATORS; i++) {
if (lun->per_res[i].registered == 0) if (i == residx || lun->pr_keys[i] == 0)
continue; continue;
if (memcmp(param->serv_act_res_key, if (sa_res_key == lun->pr_keys[i]) {
lun->per_res[i].res_key.key, lun->pr_keys[i] = 0;
sizeof(struct scsi_per_res_key)) == 0) {
lun->per_res[i].registered = 0;
memset(&lun->per_res[i].res_key,
0,
sizeof(struct scsi_per_res_key));
lun->pr_key_count--; lun->pr_key_count--;
if (!persis_offset if (!persis_offset
@ -8268,7 +8386,6 @@ ctl_pro_preempt(struct ctl_softc *softc, struct ctl_lun *lun, uint64_t res_key,
CTL_UA_RES_RELEASE; CTL_UA_RES_RELEASE;
} }
} }
lun->per_res[residx].registered = 1;
lun->res_type = type; lun->res_type = type;
if (lun->res_type != SPR_TYPE_WR_EX_AR if (lun->res_type != SPR_TYPE_WR_EX_AR
&& lun->res_type != SPR_TYPE_EX_AC_AR) && lun->res_type != SPR_TYPE_EX_AC_AR)
@ -8299,15 +8416,11 @@ ctl_pro_preempt(struct ctl_softc *softc, struct ctl_lun *lun, uint64_t res_key,
int found=0; int found=0;
for (i=0; i < 2*CTL_MAX_INITIATORS; i++) { for (i=0; i < 2*CTL_MAX_INITIATORS; i++) {
if (memcmp(param->serv_act_res_key, if (sa_res_key != lun->pr_keys[i])
lun->per_res[i].res_key.key,
sizeof(struct scsi_per_res_key)) != 0)
continue; continue;
found = 1; found = 1;
lun->per_res[i].registered = 0; lun->pr_keys[i] = 0;
memset(&lun->per_res[i].res_key, 0,
sizeof(struct scsi_per_res_key));
lun->pr_key_count--; lun->pr_key_count--;
if (!persis_offset if (!persis_offset
@ -8354,26 +8467,22 @@ ctl_pro_preempt(struct ctl_softc *softc, struct ctl_lun *lun, uint64_t res_key,
static void static void
ctl_pro_preempt_other(struct ctl_lun *lun, union ctl_ha_msg *msg) ctl_pro_preempt_other(struct ctl_lun *lun, union ctl_ha_msg *msg)
{ {
uint64_t sa_res_key;
int i; int i;
sa_res_key = scsi_8btou64(msg->pr.pr_info.sa_res_key);
if (lun->pr_res_idx == CTL_PR_ALL_REGISTRANTS if (lun->pr_res_idx == CTL_PR_ALL_REGISTRANTS
|| lun->pr_res_idx == CTL_PR_NO_RESERVATION || lun->pr_res_idx == CTL_PR_NO_RESERVATION
|| memcmp(&lun->per_res[lun->pr_res_idx].res_key, || sa_res_key != lun->pr_keys[lun->pr_res_idx]) {
msg->pr.pr_info.sa_res_key,
sizeof(struct scsi_per_res_key)) != 0) {
uint64_t sa_res_key;
sa_res_key = scsi_8btou64(msg->pr.pr_info.sa_res_key);
if (sa_res_key == 0) { if (sa_res_key == 0) {
/* temporarily unregister this nexus */
lun->per_res[msg->pr.pr_info.residx].registered = 0;
/* /*
* Unregister everybody else and build UA for * Unregister everybody else and build UA for
* them * them
*/ */
for(i=0; i < 2*CTL_MAX_INITIATORS; i++) { for(i=0; i < 2*CTL_MAX_INITIATORS; i++) {
if (lun->per_res[i].registered == 0) if (i == msg->pr.pr_info.residx ||
lun->pr_keys[i] == 0)
continue; continue;
if (!persis_offset if (!persis_offset
@ -8383,12 +8492,9 @@ ctl_pro_preempt_other(struct ctl_lun *lun, union ctl_ha_msg *msg)
else if (persis_offset && i >= persis_offset) else if (persis_offset && i >= persis_offset)
lun->pending_ua[i - persis_offset] |= lun->pending_ua[i - persis_offset] |=
CTL_UA_REG_PREEMPT; CTL_UA_REG_PREEMPT;
lun->per_res[i].registered = 0; lun->pr_keys[i] = 0;
memset(&lun->per_res[i].res_key, 0,
sizeof(struct scsi_per_res_key));
} }
lun->per_res[msg->pr.pr_info.residx].registered = 1;
lun->pr_key_count = 1; lun->pr_key_count = 1;
lun->res_type = msg->pr.pr_info.res_type; lun->res_type = msg->pr.pr_info.res_type;
if (lun->res_type != SPR_TYPE_WR_EX_AR if (lun->res_type != SPR_TYPE_WR_EX_AR
@ -8396,14 +8502,10 @@ ctl_pro_preempt_other(struct ctl_lun *lun, union ctl_ha_msg *msg)
lun->pr_res_idx = msg->pr.pr_info.residx; lun->pr_res_idx = msg->pr.pr_info.residx;
} else { } else {
for (i=0; i < 2*CTL_MAX_INITIATORS; i++) { for (i=0; i < 2*CTL_MAX_INITIATORS; i++) {
if (memcmp(msg->pr.pr_info.sa_res_key, if (sa_res_key == lun->pr_keys[i])
lun->per_res[i].res_key.key,
sizeof(struct scsi_per_res_key)) != 0)
continue; continue;
lun->per_res[i].registered = 0; lun->pr_keys[i] = 0;
memset(&lun->per_res[i].res_key, 0,
sizeof(struct scsi_per_res_key));
lun->pr_key_count--; lun->pr_key_count--;
if (!persis_offset if (!persis_offset
@ -8417,21 +8519,13 @@ ctl_pro_preempt_other(struct ctl_lun *lun, union ctl_ha_msg *msg)
} }
} }
} else { } else {
/*
* Temporarily unregister so it won't get removed
* or UA generated
*/
lun->per_res[msg->pr.pr_info.residx].registered = 0;
for (i=0; i < 2*CTL_MAX_INITIATORS; i++) { for (i=0; i < 2*CTL_MAX_INITIATORS; i++) {
if (lun->per_res[i].registered == 0) if (i == msg->pr.pr_info.residx ||
lun->pr_keys[i] == 0)
continue; continue;
if (memcmp(msg->pr.pr_info.sa_res_key, if (sa_res_key == lun->pr_keys[i]) {
lun->per_res[i].res_key.key, lun->pr_keys[i] = 0;
sizeof(struct scsi_per_res_key)) == 0) {
lun->per_res[i].registered = 0;
memset(&lun->per_res[i].res_key, 0,
sizeof(struct scsi_per_res_key));
lun->pr_key_count--; lun->pr_key_count--;
if (!persis_offset if (!persis_offset
&& i < CTL_MAX_INITIATORS) && i < CTL_MAX_INITIATORS)
@ -8454,7 +8548,6 @@ ctl_pro_preempt_other(struct ctl_lun *lun, union ctl_ha_msg *msg)
CTL_UA_RES_RELEASE; CTL_UA_RES_RELEASE;
} }
} }
lun->per_res[msg->pr.pr_info.residx].registered = 1;
lun->res_type = msg->pr.pr_info.res_type; lun->res_type = msg->pr.pr_info.res_type;
if (lun->res_type != SPR_TYPE_WR_EX_AR if (lun->res_type != SPR_TYPE_WR_EX_AR
&& lun->res_type != SPR_TYPE_EX_AC_AR) && lun->res_type != SPR_TYPE_EX_AC_AR)
@ -8552,11 +8645,8 @@ ctl_persistent_reserve_out(struct ctl_scsiio *ctsio)
*/ */
if ((cdb->action & SPRO_ACTION_MASK) != SPRO_REG_IGNO) { if ((cdb->action & SPRO_ACTION_MASK) != SPRO_REG_IGNO) {
mtx_lock(&lun->lun_lock); mtx_lock(&lun->lun_lock);
if (lun->per_res[residx].registered) { if (lun->pr_keys[residx] != 0) {
if (memcmp(param->res_key.key, if (res_key != lun->pr_keys[residx]) {
lun->per_res[residx].res_key.key,
ctl_min(sizeof(param->res_key),
sizeof(lun->per_res[residx].res_key))) != 0) {
/* /*
* The current key passed in doesn't match * The current key passed in doesn't match
* the one the initiator previously * the one the initiator previously
@ -8637,14 +8727,12 @@ ctl_persistent_reserve_out(struct ctl_scsiio *ctsio)
if ((res_key == 0 if ((res_key == 0
&& (cdb->action & SPRO_ACTION_MASK) == SPRO_REGISTER) && (cdb->action & SPRO_ACTION_MASK) == SPRO_REGISTER)
|| ((cdb->action & SPRO_ACTION_MASK) == SPRO_REG_IGNO || ((cdb->action & SPRO_ACTION_MASK) == SPRO_REG_IGNO
&& !lun->per_res[residx].registered)) { && lun->pr_keys[residx] == 0)) {
mtx_unlock(&lun->lun_lock); mtx_unlock(&lun->lun_lock);
goto done; goto done;
} }
lun->per_res[residx].registered = 0; lun->pr_keys[residx] = 0;
memset(&lun->per_res[residx].res_key,
0, sizeof(lun->per_res[residx].res_key));
lun->pr_key_count--; lun->pr_key_count--;
if (residx == lun->pr_res_idx) { if (residx == lun->pr_res_idx) {
@ -8663,9 +8751,8 @@ ctl_persistent_reserve_out(struct ctl_scsiio *ctsio)
*/ */
for (i = 0; i < CTL_MAX_INITIATORS;i++){ for (i = 0; i < CTL_MAX_INITIATORS;i++){
if (lun->per_res[ if (lun->pr_keys[
i+persis_offset].registered i + persis_offset] == 0)
== 0)
continue; continue;
lun->pending_ua[i] |= lun->pending_ua[i] |=
CTL_UA_RES_RELEASE; CTL_UA_RES_RELEASE;
@ -8695,15 +8782,9 @@ ctl_persistent_reserve_out(struct ctl_scsiio *ctsio)
* If we aren't registered currently then increment * If we aren't registered currently then increment
* the key count and set the registered flag. * the key count and set the registered flag.
*/ */
if (!lun->per_res[residx].registered) { if (lun->pr_keys[residx] == 0)
lun->pr_key_count++; lun->pr_key_count++;
lun->per_res[residx].registered = 1; lun->pr_keys[residx] = sa_res_key;
}
memcpy(&lun->per_res[residx].res_key,
param->serv_act_res_key,
ctl_min(sizeof(param->serv_act_res_key),
sizeof(lun->per_res[residx].res_key)));
persis_io.hdr.nexus = ctsio->io_hdr.nexus; persis_io.hdr.nexus = ctsio->io_hdr.nexus;
persis_io.hdr.msg_type = CTL_MSG_PERS_ACTION; persis_io.hdr.msg_type = CTL_MSG_PERS_ACTION;
@ -8816,20 +8897,12 @@ ctl_persistent_reserve_out(struct ctl_scsiio *ctsio)
*/ */
if (type != SPR_TYPE_EX_AC if (type != SPR_TYPE_EX_AC
&& type != SPR_TYPE_WR_EX) { && type != SPR_TYPE_WR_EX) {
/*
* temporarily unregister so we don't generate UA
*/
lun->per_res[residx].registered = 0;
for (i = 0; i < CTL_MAX_INITIATORS; i++) { for (i = 0; i < CTL_MAX_INITIATORS; i++) {
if (lun->per_res[i+persis_offset].registered if (i == residx ||
== 0) lun->pr_keys[i + persis_offset] == 0)
continue; continue;
lun->pending_ua[i] |= lun->pending_ua[i] |= CTL_UA_RES_RELEASE;
CTL_UA_RES_RELEASE;
} }
lun->per_res[residx].registered = 1;
} }
mtx_unlock(&lun->lun_lock); mtx_unlock(&lun->lun_lock);
/* Send msg to other side */ /* Send msg to other side */
@ -8852,13 +8925,10 @@ ctl_persistent_reserve_out(struct ctl_scsiio *ctsio)
lun->pr_key_count = 0; lun->pr_key_count = 0;
lun->pr_res_idx = CTL_PR_NO_RESERVATION; lun->pr_res_idx = CTL_PR_NO_RESERVATION;
lun->pr_keys[residx] = 0;
memset(&lun->per_res[residx].res_key,
0, sizeof(lun->per_res[residx].res_key));
lun->per_res[residx].registered = 0;
for (i=0; i < 2*CTL_MAX_INITIATORS; i++) for (i=0; i < 2*CTL_MAX_INITIATORS; i++)
if (lun->per_res[i].registered) { if (lun->pr_keys[i] != 0) {
if (!persis_offset && i < CTL_MAX_INITIATORS) if (!persis_offset && i < CTL_MAX_INITIATORS)
lun->pending_ua[i] |= lun->pending_ua[i] |=
CTL_UA_RES_PREEMPT; CTL_UA_RES_PREEMPT;
@ -8866,9 +8936,7 @@ ctl_persistent_reserve_out(struct ctl_scsiio *ctsio)
lun->pending_ua[i-persis_offset] |= lun->pending_ua[i-persis_offset] |=
CTL_UA_RES_PREEMPT; CTL_UA_RES_PREEMPT;
memset(&lun->per_res[i].res_key, lun->pr_keys[i] = 0;
0, sizeof(struct scsi_per_res_key));
lun->per_res[i].registered = 0;
} }
lun->PRGeneration++; lun->PRGeneration++;
mtx_unlock(&lun->lun_lock); mtx_unlock(&lun->lun_lock);
@ -8924,20 +8992,15 @@ ctl_hndl_per_res_out_on_other_sc(union ctl_ha_msg *msg)
mtx_lock(&lun->lun_lock); mtx_lock(&lun->lun_lock);
switch(msg->pr.pr_info.action) { switch(msg->pr.pr_info.action) {
case CTL_PR_REG_KEY: case CTL_PR_REG_KEY:
if (!lun->per_res[msg->pr.pr_info.residx].registered) { if (lun->pr_keys[msg->pr.pr_info.residx] == 0)
lun->per_res[msg->pr.pr_info.residx].registered = 1;
lun->pr_key_count++; lun->pr_key_count++;
} lun->pr_keys[msg->pr.pr_info.residx] =
scsi_8btou64(msg->pr.pr_info.sa_res_key);
lun->PRGeneration++; lun->PRGeneration++;
memcpy(&lun->per_res[msg->pr.pr_info.residx].res_key,
msg->pr.pr_info.sa_res_key,
sizeof(struct scsi_per_res_key));
break; break;
case CTL_PR_UNREG_KEY: case CTL_PR_UNREG_KEY:
lun->per_res[msg->pr.pr_info.residx].registered = 0; lun->pr_keys[msg->pr.pr_info.residx] = 0;
memset(&lun->per_res[msg->pr.pr_info.residx].res_key,
0, sizeof(struct scsi_per_res_key));
lun->pr_key_count--; lun->pr_key_count--;
/* XXX Need to see if the reservation has been released */ /* XXX Need to see if the reservation has been released */
@ -8958,8 +9021,8 @@ ctl_hndl_per_res_out_on_other_sc(union ctl_ha_msg *msg)
*/ */
for (i = 0; i < CTL_MAX_INITIATORS; i++) { for (i = 0; i < CTL_MAX_INITIATORS; i++) {
if (lun->per_res[i+ if (lun->pr_keys[i+
persis_offset].registered == 0) persis_offset] == 0)
continue; continue;
lun->pending_ua[i] |= lun->pending_ua[i] |=
@ -8992,7 +9055,7 @@ ctl_hndl_per_res_out_on_other_sc(union ctl_ha_msg *msg)
if (lun->res_type != SPR_TYPE_EX_AC if (lun->res_type != SPR_TYPE_EX_AC
&& lun->res_type != SPR_TYPE_WR_EX) { && lun->res_type != SPR_TYPE_WR_EX) {
for (i = 0; i < CTL_MAX_INITIATORS; i++) for (i = 0; i < CTL_MAX_INITIATORS; i++)
if (lun->per_res[i+persis_offset].registered) if (lun->pr_keys[i+persis_offset] != 0)
lun->pending_ua[i] |= lun->pending_ua[i] |=
CTL_UA_RES_RELEASE; CTL_UA_RES_RELEASE;
} }
@ -9012,7 +9075,7 @@ ctl_hndl_per_res_out_on_other_sc(union ctl_ha_msg *msg)
lun->pr_res_idx = CTL_PR_NO_RESERVATION; lun->pr_res_idx = CTL_PR_NO_RESERVATION;
for (i=0; i < 2*CTL_MAX_INITIATORS; i++) { for (i=0; i < 2*CTL_MAX_INITIATORS; i++) {
if (lun->per_res[i].registered == 0) if (lun->pr_keys[i] == 0)
continue; continue;
if (!persis_offset if (!persis_offset
&& i < CTL_MAX_INITIATORS) && i < CTL_MAX_INITIATORS)
@ -9021,9 +9084,7 @@ ctl_hndl_per_res_out_on_other_sc(union ctl_ha_msg *msg)
&& i >= persis_offset) && i >= persis_offset)
lun->pending_ua[i-persis_offset] |= lun->pending_ua[i-persis_offset] |=
CTL_UA_RES_PREEMPT; CTL_UA_RES_PREEMPT;
memset(&lun->per_res[i].res_key, 0, lun->pr_keys[i] = 0;
sizeof(struct scsi_per_res_key));
lun->per_res[i].registered = 0;
} }
lun->PRGeneration++; lun->PRGeneration++;
break; break;
@ -9062,7 +9123,7 @@ ctl_read_write(struct ctl_scsiio *ctsio)
&& residx != lun->pr_res_idx) && residx != lun->pr_res_idx)
|| ((lun->res_type == SPR_TYPE_EX_AC_RO || ((lun->res_type == SPR_TYPE_EX_AC_RO
|| lun->res_type == SPR_TYPE_EX_AC_AR) || lun->res_type == SPR_TYPE_EX_AC_AR)
&& !lun->per_res[residx].registered)) { && lun->pr_keys[residx] == 0)) {
ctl_set_reservation_conflict(ctsio); ctl_set_reservation_conflict(ctsio);
ctl_done((union ctl_io *)ctsio); ctl_done((union ctl_io *)ctsio);
return (CTL_RETVAL_COMPLETE); return (CTL_RETVAL_COMPLETE);
@ -10760,15 +10821,9 @@ ctl_inquiry_std(struct ctl_scsiio *ctsio)
} }
ctsio->scsi_status = SCSI_STATUS_OK; ctsio->scsi_status = SCSI_STATUS_OK;
if (ctsio->kern_data_len > 0) { ctsio->io_hdr.flags |= CTL_FLAG_ALLOCATED;
ctsio->io_hdr.flags |= CTL_FLAG_ALLOCATED; ctsio->be_move_done = ctl_config_move_done;
ctsio->be_move_done = ctl_config_move_done; ctl_datamove((union ctl_io *)ctsio);
ctl_datamove((union ctl_io *)ctsio);
} else {
ctsio->io_hdr.status = CTL_SUCCESS;
ctl_done((union ctl_io *)ctsio);
}
return (CTL_RETVAL_COMPLETE); return (CTL_RETVAL_COMPLETE);
} }
@ -11379,7 +11434,7 @@ ctl_scsiio_lun_check(struct ctl_softc *ctl_softc, struct ctl_lun *lun,
* type reservations are checked in the particular command * type reservations are checked in the particular command
* for a conflict. Read and SSU are the only ones. * for a conflict. Read and SSU are the only ones.
*/ */
if (!lun->per_res[residx].registered if (lun->pr_keys[residx] == 0
|| (residx != lun->pr_res_idx && lun->res_type < 4)) { || (residx != lun->pr_res_idx && lun->res_type < 4)) {
ctsio->scsi_status = SCSI_STATUS_RESERV_CONFLICT; ctsio->scsi_status = SCSI_STATUS_RESERV_CONFLICT;
ctsio->io_hdr.status = CTL_SCSI_ERROR; ctsio->io_hdr.status = CTL_SCSI_ERROR;
@ -12840,6 +12895,12 @@ ctl_datamove(union ctl_io *io)
return; return;
} }
/* Don't confuse frontend with zero length data move. */
if (io->scsiio.kern_data_len == 0) {
io->scsiio.be_move_done(io);
return;
}
/* /*
* If we're in XFER mode and this I/O is from the other shelf * If we're in XFER mode and this I/O is from the other shelf
* controller, we need to send the DMA to the other side to * controller, we need to send the DMA to the other side to

View File

@ -73,6 +73,8 @@
* The DEV_TYPE flag tells us that the device_type field is filled in. * The DEV_TYPE flag tells us that the device_type field is filled in.
* *
* The UNMAP flag tells us that this LUN supports UNMAP. * The UNMAP flag tells us that this LUN supports UNMAP.
*
* The OFFLINE flag tells us that this LUN can not access backing store.
*/ */
typedef enum { typedef enum {
CTL_LUN_FLAG_ID_REQ = 0x01, CTL_LUN_FLAG_ID_REQ = 0x01,
@ -82,7 +84,8 @@ typedef enum {
CTL_LUN_FLAG_SERIAL_NUM = 0x10, CTL_LUN_FLAG_SERIAL_NUM = 0x10,
CTL_LUN_FLAG_DEVID = 0x20, CTL_LUN_FLAG_DEVID = 0x20,
CTL_LUN_FLAG_DEV_TYPE = 0x40, CTL_LUN_FLAG_DEV_TYPE = 0x40,
CTL_LUN_FLAG_UNMAP = 0x80 CTL_LUN_FLAG_UNMAP = 0x80,
CTL_LUN_FLAG_OFFLINE = 0x100
} ctl_backend_lun_flags; } ctl_backend_lun_flags;
#ifdef _KERNEL #ifdef _KERNEL

View File

@ -151,6 +151,7 @@ typedef void (*cbb_dispatch_t)(struct ctl_be_block_lun *be_lun,
* and a backend block LUN, and between a backend block LUN and a CTL LUN. * and a backend block LUN, and between a backend block LUN and a CTL LUN.
*/ */
struct ctl_be_block_lun { struct ctl_be_block_lun {
struct ctl_lun_create_params params;
struct ctl_block_disk *disk; struct ctl_block_disk *disk;
char lunname[32]; char lunname[32];
char *dev_path; char *dev_path;
@ -1521,7 +1522,7 @@ ctl_be_block_ioctl(struct cdev *dev, u_long cmd, caddr_t addr,
default: default:
lun_req->status = CTL_LUN_ERROR; lun_req->status = CTL_LUN_ERROR;
snprintf(lun_req->error_str, sizeof(lun_req->error_str), snprintf(lun_req->error_str, sizeof(lun_req->error_str),
"%s: invalid LUN request type %d", __func__, "invalid LUN request type %d",
lun_req->reqtype); lun_req->reqtype);
break; break;
} }
@ -1541,11 +1542,12 @@ ctl_be_block_open_file(struct ctl_be_block_lun *be_lun, struct ctl_lun_req *req)
struct ctl_be_block_filedata *file_data; struct ctl_be_block_filedata *file_data;
struct ctl_lun_create_params *params; struct ctl_lun_create_params *params;
struct vattr vattr; struct vattr vattr;
off_t pss;
int error; int error;
error = 0; error = 0;
file_data = &be_lun->backend.file; file_data = &be_lun->backend.file;
params = &req->reqdata.create; params = &be_lun->params;
be_lun->dev_type = CTL_BE_BLOCK_FILE; be_lun->dev_type = CTL_BE_BLOCK_FILE;
be_lun->dispatch = ctl_be_block_dispatch_file; be_lun->dispatch = ctl_be_block_dispatch_file;
@ -1589,21 +1591,21 @@ ctl_be_block_open_file(struct ctl_be_block_lun *be_lun, struct ctl_lun_req *req)
be_lun->flags |= CTL_BE_BLOCK_LUN_MULTI_THREAD; be_lun->flags |= CTL_BE_BLOCK_LUN_MULTI_THREAD;
/* /*
* XXX KDM vattr.va_blocksize may be larger than 512 bytes here. * For files we can use any logical block size. Prefer 512 bytes
* With ZFS, it is 131072 bytes. Block sizes that large don't work * for compatibility reasons. If file's vattr.va_blocksize
* with disklabel and UFS on FreeBSD at least. Large block sizes * (preferred I/O block size) is bigger and multiple to chosen
* may not work with other OSes as well. So just export a sector * logical block size -- report it as physical block size.
* size of 512 bytes, which should work with any OS or
* application. Since our backing is a file, any block size will
* work fine for the backing store.
*/ */
#if 0
be_lun->blocksize= vattr.va_blocksize;
#endif
if (params->blocksize_bytes != 0) if (params->blocksize_bytes != 0)
be_lun->blocksize = params->blocksize_bytes; be_lun->blocksize = params->blocksize_bytes;
else else
be_lun->blocksize = 512; be_lun->blocksize = 512;
pss = vattr.va_blocksize / be_lun->blocksize;
if ((pss > 0) && (pss * be_lun->blocksize == vattr.va_blocksize) &&
((pss & (pss - 1)) == 0)) {
be_lun->pblockexp = fls(pss) - 1;
be_lun->pblockoff = 0;
}
/* /*
* Sanity check. The media size has to be at least one * Sanity check. The media size has to be at least one
@ -1628,7 +1630,7 @@ ctl_be_block_open_dev(struct ctl_be_block_lun *be_lun, struct ctl_lun_req *req)
int error; int error;
off_t ps, pss, po, pos; off_t ps, pss, po, pos;
params = &req->reqdata.create; params = &be_lun->params;
be_lun->dev_type = CTL_BE_BLOCK_DEV; be_lun->dev_type = CTL_BE_BLOCK_DEV;
be_lun->backend.dev.cdev = be_lun->vn->v_rdev; be_lun->backend.dev.cdev = be_lun->vn->v_rdev;
@ -1646,8 +1648,8 @@ ctl_be_block_open_dev(struct ctl_be_block_lun *be_lun, struct ctl_lun_req *req)
error = VOP_GETATTR(be_lun->vn, &vattr, NOCRED); error = VOP_GETATTR(be_lun->vn, &vattr, NOCRED);
if (error) { if (error) {
snprintf(req->error_str, sizeof(req->error_str), snprintf(req->error_str, sizeof(req->error_str),
"%s: error getting vnode attributes for device %s", "error getting vnode attributes for device %s",
__func__, be_lun->dev_path); be_lun->dev_path);
return (error); return (error);
} }
@ -1655,7 +1657,7 @@ ctl_be_block_open_dev(struct ctl_be_block_lun *be_lun, struct ctl_lun_req *req)
devsw = dev->si_devsw; devsw = dev->si_devsw;
if (!devsw->d_ioctl) { if (!devsw->d_ioctl) {
snprintf(req->error_str, sizeof(req->error_str), snprintf(req->error_str, sizeof(req->error_str),
"%s: no d_ioctl for device %s!", __func__, "no d_ioctl for device %s!",
be_lun->dev_path); be_lun->dev_path);
return (ENODEV); return (ENODEV);
} }
@ -1665,8 +1667,8 @@ ctl_be_block_open_dev(struct ctl_be_block_lun *be_lun, struct ctl_lun_req *req)
curthread); curthread);
if (error) { if (error) {
snprintf(req->error_str, sizeof(req->error_str), snprintf(req->error_str, sizeof(req->error_str),
"%s: error %d returned for DIOCGSECTORSIZE ioctl " "error %d returned for DIOCGSECTORSIZE ioctl "
"on %s!", __func__, error, be_lun->dev_path); "on %s!", error, be_lun->dev_path);
return (error); return (error);
} }
@ -1688,9 +1690,9 @@ ctl_be_block_open_dev(struct ctl_be_block_lun *be_lun, struct ctl_lun_req *req)
be_lun->blocksize = params->blocksize_bytes; be_lun->blocksize = params->blocksize_bytes;
} else { } else {
snprintf(req->error_str, sizeof(req->error_str), snprintf(req->error_str, sizeof(req->error_str),
"%s: requested blocksize %u is not an even " "requested blocksize %u is not an even "
"multiple of backing device blocksize %u", "multiple of backing device blocksize %u",
__func__, params->blocksize_bytes, params->blocksize_bytes,
be_lun->blocksize); be_lun->blocksize);
return (EINVAL); return (EINVAL);
@ -1698,8 +1700,8 @@ ctl_be_block_open_dev(struct ctl_be_block_lun *be_lun, struct ctl_lun_req *req)
} else if ((params->blocksize_bytes != 0) } else if ((params->blocksize_bytes != 0)
&& (params->blocksize_bytes != be_lun->blocksize)) { && (params->blocksize_bytes != be_lun->blocksize)) {
snprintf(req->error_str, sizeof(req->error_str), snprintf(req->error_str, sizeof(req->error_str),
"%s: requested blocksize %u < backing device " "requested blocksize %u < backing device "
"blocksize %u", __func__, params->blocksize_bytes, "blocksize %u", params->blocksize_bytes,
be_lun->blocksize); be_lun->blocksize);
return (EINVAL); return (EINVAL);
} }
@ -1709,8 +1711,8 @@ ctl_be_block_open_dev(struct ctl_be_block_lun *be_lun, struct ctl_lun_req *req)
curthread); curthread);
if (error) { if (error) {
snprintf(req->error_str, sizeof(req->error_str), snprintf(req->error_str, sizeof(req->error_str),
"%s: error %d returned for DIOCGMEDIASIZE " "error %d returned for DIOCGMEDIASIZE "
" ioctl on %s!", __func__, error, " ioctl on %s!", error,
be_lun->dev_path); be_lun->dev_path);
return (error); return (error);
} }
@ -1718,8 +1720,8 @@ ctl_be_block_open_dev(struct ctl_be_block_lun *be_lun, struct ctl_lun_req *req)
if (params->lun_size_bytes != 0) { if (params->lun_size_bytes != 0) {
if (params->lun_size_bytes > be_lun->size_bytes) { if (params->lun_size_bytes > be_lun->size_bytes) {
snprintf(req->error_str, sizeof(req->error_str), snprintf(req->error_str, sizeof(req->error_str),
"%s: requested LUN size %ju > backing device " "requested LUN size %ju > backing device "
"size %ju", __func__, "size %ju",
(uintmax_t)params->lun_size_bytes, (uintmax_t)params->lun_size_bytes,
(uintmax_t)be_lun->size_bytes); (uintmax_t)be_lun->size_bytes);
return (EINVAL); return (EINVAL);
@ -1792,6 +1794,7 @@ ctl_be_block_close(struct ctl_be_block_lun *be_lun)
panic("Unexpected backend type."); panic("Unexpected backend type.");
break; break;
} }
be_lun->dev_type = CTL_BE_BLOCK_NONE;
} }
PICKUP_GIANT(); PICKUP_GIANT();
@ -1814,7 +1817,7 @@ ctl_be_block_open(struct ctl_be_block_softc *softc,
if (rootvnode == NULL) { if (rootvnode == NULL) {
snprintf(req->error_str, sizeof(req->error_str), snprintf(req->error_str, sizeof(req->error_str),
"%s: Root filesystem is not mounted", __func__); "Root filesystem is not mounted");
return (1); return (1);
} }
@ -1858,7 +1861,7 @@ ctl_be_block_open(struct ctl_be_block_softc *softc,
} }
} }
snprintf(req->error_str, sizeof(req->error_str), snprintf(req->error_str, sizeof(req->error_str),
"%s: error opening %s", __func__, be_lun->dev_path); "error opening %s: %d", be_lun->dev_path, error);
return (error); return (error);
} }
@ -1902,11 +1905,13 @@ ctl_be_block_create(struct ctl_be_block_softc *softc, struct ctl_lun_req *req)
params = &req->reqdata.create; params = &req->reqdata.create;
retval = 0; retval = 0;
req->status = CTL_LUN_OK;
num_threads = cbb_num_threads; num_threads = cbb_num_threads;
be_lun = malloc(sizeof(*be_lun), M_CTLBLK, M_ZERO | M_WAITOK); be_lun = malloc(sizeof(*be_lun), M_CTLBLK, M_ZERO | M_WAITOK);
be_lun->params = req->reqdata.create;
be_lun->softc = softc; be_lun->softc = softc;
STAILQ_INIT(&be_lun->input_queue); STAILQ_INIT(&be_lun->input_queue);
STAILQ_INIT(&be_lun->config_write_queue); STAILQ_INIT(&be_lun->config_write_queue);
@ -1922,7 +1927,7 @@ ctl_be_block_create(struct ctl_be_block_softc *softc, struct ctl_lun_req *req)
if (be_lun->lun_zone == NULL) { if (be_lun->lun_zone == NULL) {
snprintf(req->error_str, sizeof(req->error_str), snprintf(req->error_str, sizeof(req->error_str),
"%s: error allocating UMA zone", __func__); "error allocating UMA zone");
goto bailout_error; goto bailout_error;
} }
@ -1935,26 +1940,18 @@ ctl_be_block_create(struct ctl_be_block_softc *softc, struct ctl_lun_req *req)
value = ctl_get_opt(&be_lun->ctl_be_lun.options, "file"); value = ctl_get_opt(&be_lun->ctl_be_lun.options, "file");
if (value == NULL) { if (value == NULL) {
snprintf(req->error_str, sizeof(req->error_str), snprintf(req->error_str, sizeof(req->error_str),
"%s: no file argument specified", __func__); "no file argument specified");
goto bailout_error; goto bailout_error;
} }
be_lun->dev_path = strdup(value, M_CTLBLK); be_lun->dev_path = strdup(value, M_CTLBLK);
be_lun->blocksize = 512;
be_lun->blocksize_shift = fls(be_lun->blocksize) - 1;
retval = ctl_be_block_open(softc, be_lun, req); retval = ctl_be_block_open(softc, be_lun, req);
if (retval != 0) { if (retval != 0) {
retval = 0; retval = 0;
goto bailout_error; req->status = CTL_LUN_WARNING;
} }
/*
* Tell the user the size of the file/device.
*/
params->lun_size_bytes = be_lun->size_bytes;
/*
* The maximum LBA is the size - 1.
*/
be_lun->ctl_be_lun.maxlba = be_lun->size_blocks - 1;
} else { } else {
/* /*
* For processor devices, we don't have any size. * For processor devices, we don't have any size.
@ -1965,7 +1962,6 @@ ctl_be_block_create(struct ctl_be_block_softc *softc, struct ctl_lun_req *req)
be_lun->size_blocks = 0; be_lun->size_blocks = 0;
be_lun->size_bytes = 0; be_lun->size_bytes = 0;
be_lun->ctl_be_lun.maxlba = 0; be_lun->ctl_be_lun.maxlba = 0;
params->lun_size_bytes = 0;
/* /*
* Default to just 1 thread for processor devices. * Default to just 1 thread for processor devices.
@ -1988,8 +1984,8 @@ ctl_be_block_create(struct ctl_be_block_softc *softc, struct ctl_lun_req *req)
*/ */
if (tmp_num_threads < 1) { if (tmp_num_threads < 1) {
snprintf(req->error_str, sizeof(req->error_str), snprintf(req->error_str, sizeof(req->error_str),
"%s: invalid number of threads %s", "invalid number of threads %s",
__func__, num_thread_str); num_thread_str);
goto bailout_error; goto bailout_error;
} }
num_threads = tmp_num_threads; num_threads = tmp_num_threads;
@ -2001,16 +1997,22 @@ ctl_be_block_create(struct ctl_be_block_softc *softc, struct ctl_lun_req *req)
be_lun->flags = CTL_BE_BLOCK_LUN_UNCONFIGURED; be_lun->flags = CTL_BE_BLOCK_LUN_UNCONFIGURED;
be_lun->ctl_be_lun.flags = CTL_LUN_FLAG_PRIMARY; be_lun->ctl_be_lun.flags = CTL_LUN_FLAG_PRIMARY;
if (be_lun->vn == NULL)
be_lun->ctl_be_lun.flags |= CTL_LUN_FLAG_OFFLINE;
if (unmap) if (unmap)
be_lun->ctl_be_lun.flags |= CTL_LUN_FLAG_UNMAP; be_lun->ctl_be_lun.flags |= CTL_LUN_FLAG_UNMAP;
if (be_lun->dispatch == ctl_be_block_dispatch_zvol)
be_lun->ctl_be_lun.atomicblock = CTLBLK_MAX_IO_SIZE /
be_lun->blocksize;
be_lun->ctl_be_lun.be_lun = be_lun; be_lun->ctl_be_lun.be_lun = be_lun;
be_lun->ctl_be_lun.maxlba = (be_lun->size_blocks == 0) ?
0 : (be_lun->size_blocks - 1);
be_lun->ctl_be_lun.blocksize = be_lun->blocksize; be_lun->ctl_be_lun.blocksize = be_lun->blocksize;
be_lun->ctl_be_lun.pblockexp = be_lun->pblockexp; be_lun->ctl_be_lun.pblockexp = be_lun->pblockexp;
be_lun->ctl_be_lun.pblockoff = be_lun->pblockoff; be_lun->ctl_be_lun.pblockoff = be_lun->pblockoff;
if (be_lun->dispatch == ctl_be_block_dispatch_zvol &&
be_lun->blocksize != 0)
be_lun->ctl_be_lun.atomicblock = CTLBLK_MAX_IO_SIZE /
be_lun->blocksize;
/* Tell the user the blocksize we ended up using */ /* Tell the user the blocksize we ended up using */
params->lun_size_bytes = be_lun->size_bytes;
params->blocksize_bytes = be_lun->blocksize; params->blocksize_bytes = be_lun->blocksize;
if (params->flags & CTL_LUN_FLAG_ID_REQ) { if (params->flags & CTL_LUN_FLAG_ID_REQ) {
be_lun->ctl_be_lun.req_lun_id = params->req_lun_id; be_lun->ctl_be_lun.req_lun_id = params->req_lun_id;
@ -2062,7 +2064,7 @@ ctl_be_block_create(struct ctl_be_block_softc *softc, struct ctl_lun_req *req)
if (be_lun->io_taskqueue == NULL) { if (be_lun->io_taskqueue == NULL) {
snprintf(req->error_str, sizeof(req->error_str), snprintf(req->error_str, sizeof(req->error_str),
"%s: Unable to create taskqueue", __func__); "unable to create taskqueue");
goto bailout_error; goto bailout_error;
} }
@ -2105,8 +2107,8 @@ ctl_be_block_create(struct ctl_be_block_softc *softc, struct ctl_lun_req *req)
softc->num_luns--; softc->num_luns--;
mtx_unlock(&softc->lock); mtx_unlock(&softc->lock);
snprintf(req->error_str, sizeof(req->error_str), snprintf(req->error_str, sizeof(req->error_str),
"%s: ctl_add_lun() returned error %d, see dmesg for " "ctl_add_lun() returned error %d, see dmesg for "
"details", __func__, retval); "details", retval);
retval = 0; retval = 0;
goto bailout_error; goto bailout_error;
} }
@ -2128,8 +2130,7 @@ ctl_be_block_create(struct ctl_be_block_softc *softc, struct ctl_lun_req *req)
if (be_lun->flags & CTL_BE_BLOCK_LUN_CONFIG_ERR) { if (be_lun->flags & CTL_BE_BLOCK_LUN_CONFIG_ERR) {
snprintf(req->error_str, sizeof(req->error_str), snprintf(req->error_str, sizeof(req->error_str),
"%s: LUN configuration error, see dmesg for details", "LUN configuration error, see dmesg for details");
__func__);
STAILQ_REMOVE(&softc->lun_list, be_lun, ctl_be_block_lun, STAILQ_REMOVE(&softc->lun_list, be_lun, ctl_be_block_lun,
links); links);
softc->num_luns--; softc->num_luns--;
@ -2148,9 +2149,6 @@ ctl_be_block_create(struct ctl_be_block_softc *softc, struct ctl_lun_req *req)
| DEVSTAT_TYPE_IF_OTHER, | DEVSTAT_TYPE_IF_OTHER,
DEVSTAT_PRIORITY_OTHER); DEVSTAT_PRIORITY_OTHER);
req->status = CTL_LUN_OK;
return (retval); return (retval);
bailout_error: bailout_error:
@ -2192,8 +2190,8 @@ ctl_be_block_rm(struct ctl_be_block_softc *softc, struct ctl_lun_req *req)
if (be_lun == NULL) { if (be_lun == NULL) {
snprintf(req->error_str, sizeof(req->error_str), snprintf(req->error_str, sizeof(req->error_str),
"%s: LUN %u is not managed by the block backend", "LUN %u is not managed by the block backend",
__func__, params->lun_id); params->lun_id);
goto bailout_error; goto bailout_error;
} }
@ -2201,8 +2199,8 @@ ctl_be_block_rm(struct ctl_be_block_softc *softc, struct ctl_lun_req *req)
if (retval != 0) { if (retval != 0) {
snprintf(req->error_str, sizeof(req->error_str), snprintf(req->error_str, sizeof(req->error_str),
"%s: error %d returned from ctl_disable_lun() for " "error %d returned from ctl_disable_lun() for "
"LUN %d", __func__, retval, params->lun_id); "LUN %d", retval, params->lun_id);
goto bailout_error; goto bailout_error;
} }
@ -2210,8 +2208,8 @@ ctl_be_block_rm(struct ctl_be_block_softc *softc, struct ctl_lun_req *req)
retval = ctl_invalidate_lun(&be_lun->ctl_be_lun); retval = ctl_invalidate_lun(&be_lun->ctl_be_lun);
if (retval != 0) { if (retval != 0) {
snprintf(req->error_str, sizeof(req->error_str), snprintf(req->error_str, sizeof(req->error_str),
"%s: error %d returned from ctl_invalidate_lun() for " "error %d returned from ctl_invalidate_lun() for "
"LUN %d", __func__, retval, params->lun_id); "LUN %d", retval, params->lun_id);
goto bailout_error; goto bailout_error;
} }
@ -2229,8 +2227,7 @@ ctl_be_block_rm(struct ctl_be_block_softc *softc, struct ctl_lun_req *req)
if ((be_lun->flags & CTL_BE_BLOCK_LUN_UNCONFIGURED) == 0) { if ((be_lun->flags & CTL_BE_BLOCK_LUN_UNCONFIGURED) == 0) {
snprintf(req->error_str, sizeof(req->error_str), snprintf(req->error_str, sizeof(req->error_str),
"%s: interrupted waiting for LUN to be freed", "interrupted waiting for LUN to be freed");
__func__);
mtx_unlock(&softc->lock); mtx_unlock(&softc->lock);
goto bailout_error; goto bailout_error;
} }
@ -2274,9 +2271,7 @@ ctl_be_block_modify_file(struct ctl_be_block_lun *be_lun,
{ {
struct vattr vattr; struct vattr vattr;
int error; int error;
struct ctl_lun_modify_params *params; struct ctl_lun_create_params *params = &be_lun->params;
params = &req->reqdata.modify;
if (params->lun_size_bytes != 0) { if (params->lun_size_bytes != 0) {
be_lun->size_bytes = params->lun_size_bytes; be_lun->size_bytes = params->lun_size_bytes;
@ -2303,16 +2298,13 @@ ctl_be_block_modify_dev(struct ctl_be_block_lun *be_lun,
{ {
struct ctl_be_block_devdata *dev_data; struct ctl_be_block_devdata *dev_data;
int error; int error;
struct ctl_lun_modify_params *params; struct ctl_lun_create_params *params = &be_lun->params;
uint64_t size_bytes; uint64_t size_bytes;
params = &req->reqdata.modify;
dev_data = &be_lun->backend.dev; dev_data = &be_lun->backend.dev;
if (!dev_data->csw->d_ioctl) { if (!dev_data->csw->d_ioctl) {
snprintf(req->error_str, sizeof(req->error_str), snprintf(req->error_str, sizeof(req->error_str),
"%s: no d_ioctl for device %s!", __func__, "no d_ioctl for device %s!", be_lun->dev_path);
be_lun->dev_path);
return (ENODEV); return (ENODEV);
} }
@ -2321,16 +2313,16 @@ ctl_be_block_modify_dev(struct ctl_be_block_lun *be_lun,
curthread); curthread);
if (error) { if (error) {
snprintf(req->error_str, sizeof(req->error_str), snprintf(req->error_str, sizeof(req->error_str),
"%s: error %d returned for DIOCGMEDIASIZE ioctl " "error %d returned for DIOCGMEDIASIZE ioctl "
"on %s!", __func__, error, be_lun->dev_path); "on %s!", error, be_lun->dev_path);
return (error); return (error);
} }
if (params->lun_size_bytes != 0) { if (params->lun_size_bytes != 0) {
if (params->lun_size_bytes > size_bytes) { if (params->lun_size_bytes > size_bytes) {
snprintf(req->error_str, sizeof(req->error_str), snprintf(req->error_str, sizeof(req->error_str),
"%s: requested LUN size %ju > backing device " "requested LUN size %ju > backing device "
"size %ju", __func__, "size %ju",
(uintmax_t)params->lun_size_bytes, (uintmax_t)params->lun_size_bytes,
(uintmax_t)size_bytes); (uintmax_t)size_bytes);
return (EINVAL); return (EINVAL);
@ -2355,9 +2347,7 @@ ctl_be_block_modify(struct ctl_be_block_softc *softc, struct ctl_lun_req *req)
params = &req->reqdata.modify; params = &req->reqdata.modify;
mtx_lock(&softc->lock); mtx_lock(&softc->lock);
be_lun = NULL; be_lun = NULL;
STAILQ_FOREACH(be_lun, &softc->lun_list, links) { STAILQ_FOREACH(be_lun, &softc->lun_list, links) {
if (be_lun->ctl_be_lun.lun_id == params->lun_id) if (be_lun->ctl_be_lun.lun_id == params->lun_id)
break; break;
@ -2366,29 +2356,22 @@ ctl_be_block_modify(struct ctl_be_block_softc *softc, struct ctl_lun_req *req)
if (be_lun == NULL) { if (be_lun == NULL) {
snprintf(req->error_str, sizeof(req->error_str), snprintf(req->error_str, sizeof(req->error_str),
"%s: LUN %u is not managed by the block backend", "LUN %u is not managed by the block backend",
__func__, params->lun_id); params->lun_id);
goto bailout_error; goto bailout_error;
} }
if (params->lun_size_bytes != 0) { be_lun->params.lun_size_bytes = params->lun_size_bytes;
if (params->lun_size_bytes < be_lun->blocksize) {
snprintf(req->error_str, sizeof(req->error_str),
"%s: LUN size %ju < blocksize %u", __func__,
params->lun_size_bytes, be_lun->blocksize);
goto bailout_error;
}
}
oldsize = be_lun->size_bytes; oldsize = be_lun->size_blocks;
if (be_lun->vn->v_type == VREG) if (be_lun->vn == NULL)
error = ctl_be_block_open(softc, be_lun, req);
else if (be_lun->vn->v_type == VREG)
error = ctl_be_block_modify_file(be_lun, req); error = ctl_be_block_modify_file(be_lun, req);
else else
error = ctl_be_block_modify_dev(be_lun, req); error = ctl_be_block_modify_dev(be_lun, req);
if (error != 0)
goto bailout_error;
if (be_lun->size_bytes != oldsize) { if (error == 0 && be_lun->size_blocks != oldsize) {
be_lun->size_blocks = be_lun->size_bytes >> be_lun->size_blocks = be_lun->size_bytes >>
be_lun->blocksize_shift; be_lun->blocksize_shift;
@ -2398,14 +2381,24 @@ ctl_be_block_modify(struct ctl_be_block_softc *softc, struct ctl_lun_req *req)
* XXX: Note that this field is being updated without locking, * XXX: Note that this field is being updated without locking,
* which might cause problems on 32-bit architectures. * which might cause problems on 32-bit architectures.
*/ */
be_lun->ctl_be_lun.maxlba = be_lun->size_blocks - 1; be_lun->ctl_be_lun.maxlba = (be_lun->size_blocks == 0) ?
0 : (be_lun->size_blocks - 1);
be_lun->ctl_be_lun.blocksize = be_lun->blocksize;
be_lun->ctl_be_lun.pblockexp = be_lun->pblockexp;
be_lun->ctl_be_lun.pblockoff = be_lun->pblockoff;
if (be_lun->dispatch == ctl_be_block_dispatch_zvol &&
be_lun->blocksize != 0)
be_lun->ctl_be_lun.atomicblock = CTLBLK_MAX_IO_SIZE /
be_lun->blocksize;
ctl_lun_capacity_changed(&be_lun->ctl_be_lun); ctl_lun_capacity_changed(&be_lun->ctl_be_lun);
if (oldsize == 0 && be_lun->size_blocks != 0)
ctl_lun_online(&be_lun->ctl_be_lun);
} }
/* Tell the user the exact size we ended up using */ /* Tell the user the exact size we ended up using */
params->lun_size_bytes = be_lun->size_bytes; params->lun_size_bytes = be_lun->size_bytes;
req->status = CTL_LUN_OK; req->status = error ? CTL_LUN_WARNING : CTL_LUN_OK;
return (0); return (0);

View File

@ -70,6 +70,7 @@ const struct ctl_cmd_entry ctl_cmd_table_5e[32] =
CTL_CMD_FLAG_OK_ON_BOTH | CTL_CMD_FLAG_OK_ON_BOTH |
CTL_CMD_FLAG_OK_ON_STOPPED | CTL_CMD_FLAG_OK_ON_STOPPED |
CTL_CMD_FLAG_OK_ON_INOPERABLE | CTL_CMD_FLAG_OK_ON_INOPERABLE |
CTL_CMD_FLAG_OK_ON_OFFLINE |
CTL_CMD_FLAG_OK_ON_SECONDARY | CTL_CMD_FLAG_OK_ON_SECONDARY |
CTL_FLAG_DATA_IN | CTL_FLAG_DATA_IN |
CTL_CMD_FLAG_ALLOW_ON_PR_RESV, CTL_CMD_FLAG_ALLOW_ON_PR_RESV,
@ -81,6 +82,7 @@ const struct ctl_cmd_entry ctl_cmd_table_5e[32] =
CTL_CMD_FLAG_OK_ON_BOTH | CTL_CMD_FLAG_OK_ON_BOTH |
CTL_CMD_FLAG_OK_ON_STOPPED | CTL_CMD_FLAG_OK_ON_STOPPED |
CTL_CMD_FLAG_OK_ON_INOPERABLE | CTL_CMD_FLAG_OK_ON_INOPERABLE |
CTL_CMD_FLAG_OK_ON_OFFLINE |
CTL_CMD_FLAG_OK_ON_SECONDARY | CTL_CMD_FLAG_OK_ON_SECONDARY |
CTL_FLAG_DATA_IN | CTL_FLAG_DATA_IN |
CTL_CMD_FLAG_ALLOW_ON_PR_RESV, CTL_CMD_FLAG_ALLOW_ON_PR_RESV,
@ -92,6 +94,7 @@ const struct ctl_cmd_entry ctl_cmd_table_5e[32] =
CTL_CMD_FLAG_OK_ON_BOTH | CTL_CMD_FLAG_OK_ON_BOTH |
CTL_CMD_FLAG_OK_ON_STOPPED | CTL_CMD_FLAG_OK_ON_STOPPED |
CTL_CMD_FLAG_OK_ON_INOPERABLE | CTL_CMD_FLAG_OK_ON_INOPERABLE |
CTL_CMD_FLAG_OK_ON_OFFLINE |
CTL_CMD_FLAG_OK_ON_SECONDARY | CTL_CMD_FLAG_OK_ON_SECONDARY |
CTL_FLAG_DATA_IN | CTL_FLAG_DATA_IN |
CTL_CMD_FLAG_ALLOW_ON_PR_RESV, CTL_CMD_FLAG_ALLOW_ON_PR_RESV,
@ -103,6 +106,7 @@ const struct ctl_cmd_entry ctl_cmd_table_5e[32] =
CTL_CMD_FLAG_OK_ON_BOTH | CTL_CMD_FLAG_OK_ON_BOTH |
CTL_CMD_FLAG_OK_ON_STOPPED | CTL_CMD_FLAG_OK_ON_STOPPED |
CTL_CMD_FLAG_OK_ON_INOPERABLE | CTL_CMD_FLAG_OK_ON_INOPERABLE |
CTL_CMD_FLAG_OK_ON_OFFLINE |
CTL_CMD_FLAG_OK_ON_SECONDARY | CTL_CMD_FLAG_OK_ON_SECONDARY |
CTL_FLAG_DATA_IN | CTL_FLAG_DATA_IN |
CTL_CMD_FLAG_ALLOW_ON_PR_RESV, CTL_CMD_FLAG_ALLOW_ON_PR_RESV,
@ -120,6 +124,7 @@ const struct ctl_cmd_entry ctl_cmd_table_5f[32] =
CTL_CMD_FLAG_OK_ON_BOTH | CTL_CMD_FLAG_OK_ON_BOTH |
CTL_CMD_FLAG_OK_ON_STOPPED | CTL_CMD_FLAG_OK_ON_STOPPED |
CTL_CMD_FLAG_OK_ON_INOPERABLE | CTL_CMD_FLAG_OK_ON_INOPERABLE |
CTL_CMD_FLAG_OK_ON_OFFLINE |
CTL_CMD_FLAG_OK_ON_SECONDARY | CTL_CMD_FLAG_OK_ON_SECONDARY |
CTL_FLAG_DATA_OUT | CTL_FLAG_DATA_OUT |
CTL_CMD_FLAG_ALLOW_ON_PR_RESV, CTL_CMD_FLAG_ALLOW_ON_PR_RESV,
@ -131,6 +136,7 @@ const struct ctl_cmd_entry ctl_cmd_table_5f[32] =
CTL_CMD_FLAG_OK_ON_BOTH | CTL_CMD_FLAG_OK_ON_BOTH |
CTL_CMD_FLAG_OK_ON_STOPPED | CTL_CMD_FLAG_OK_ON_STOPPED |
CTL_CMD_FLAG_OK_ON_INOPERABLE | CTL_CMD_FLAG_OK_ON_INOPERABLE |
CTL_CMD_FLAG_OK_ON_OFFLINE |
CTL_CMD_FLAG_OK_ON_SECONDARY | CTL_CMD_FLAG_OK_ON_SECONDARY |
CTL_FLAG_DATA_OUT | CTL_FLAG_DATA_OUT |
CTL_CMD_FLAG_ALLOW_ON_PR_RESV, CTL_CMD_FLAG_ALLOW_ON_PR_RESV,
@ -142,6 +148,7 @@ const struct ctl_cmd_entry ctl_cmd_table_5f[32] =
CTL_CMD_FLAG_OK_ON_BOTH | CTL_CMD_FLAG_OK_ON_BOTH |
CTL_CMD_FLAG_OK_ON_STOPPED | CTL_CMD_FLAG_OK_ON_STOPPED |
CTL_CMD_FLAG_OK_ON_INOPERABLE | CTL_CMD_FLAG_OK_ON_INOPERABLE |
CTL_CMD_FLAG_OK_ON_OFFLINE |
CTL_CMD_FLAG_OK_ON_SECONDARY | CTL_CMD_FLAG_OK_ON_SECONDARY |
CTL_FLAG_DATA_OUT | CTL_FLAG_DATA_OUT |
CTL_CMD_FLAG_ALLOW_ON_PR_RESV, CTL_CMD_FLAG_ALLOW_ON_PR_RESV,
@ -153,6 +160,7 @@ const struct ctl_cmd_entry ctl_cmd_table_5f[32] =
CTL_CMD_FLAG_OK_ON_BOTH | CTL_CMD_FLAG_OK_ON_BOTH |
CTL_CMD_FLAG_OK_ON_STOPPED | CTL_CMD_FLAG_OK_ON_STOPPED |
CTL_CMD_FLAG_OK_ON_INOPERABLE | CTL_CMD_FLAG_OK_ON_INOPERABLE |
CTL_CMD_FLAG_OK_ON_OFFLINE |
CTL_CMD_FLAG_OK_ON_SECONDARY | CTL_CMD_FLAG_OK_ON_SECONDARY |
CTL_FLAG_DATA_OUT | CTL_FLAG_DATA_OUT |
CTL_CMD_FLAG_ALLOW_ON_PR_RESV, CTL_CMD_FLAG_ALLOW_ON_PR_RESV,
@ -164,6 +172,7 @@ const struct ctl_cmd_entry ctl_cmd_table_5f[32] =
CTL_CMD_FLAG_OK_ON_BOTH | CTL_CMD_FLAG_OK_ON_BOTH |
CTL_CMD_FLAG_OK_ON_STOPPED | CTL_CMD_FLAG_OK_ON_STOPPED |
CTL_CMD_FLAG_OK_ON_INOPERABLE | CTL_CMD_FLAG_OK_ON_INOPERABLE |
CTL_CMD_FLAG_OK_ON_OFFLINE |
CTL_CMD_FLAG_OK_ON_SECONDARY | CTL_CMD_FLAG_OK_ON_SECONDARY |
CTL_FLAG_DATA_OUT | CTL_FLAG_DATA_OUT |
CTL_CMD_FLAG_ALLOW_ON_PR_RESV, CTL_CMD_FLAG_ALLOW_ON_PR_RESV,
@ -178,6 +187,7 @@ const struct ctl_cmd_entry ctl_cmd_table_5f[32] =
CTL_CMD_FLAG_OK_ON_BOTH | CTL_CMD_FLAG_OK_ON_BOTH |
CTL_CMD_FLAG_OK_ON_STOPPED | CTL_CMD_FLAG_OK_ON_STOPPED |
CTL_CMD_FLAG_OK_ON_INOPERABLE | CTL_CMD_FLAG_OK_ON_INOPERABLE |
CTL_CMD_FLAG_OK_ON_OFFLINE |
CTL_CMD_FLAG_OK_ON_SECONDARY | CTL_CMD_FLAG_OK_ON_SECONDARY |
CTL_FLAG_DATA_OUT | CTL_FLAG_DATA_OUT |
CTL_CMD_FLAG_ALLOW_ON_PR_RESV, CTL_CMD_FLAG_ALLOW_ON_PR_RESV,
@ -460,6 +470,7 @@ const struct ctl_cmd_entry ctl_cmd_table_a3[32] =
{ctl_report_tagret_port_groups, CTL_SERIDX_INQ, CTL_CMD_FLAG_OK_ON_BOTH | {ctl_report_tagret_port_groups, CTL_SERIDX_INQ, CTL_CMD_FLAG_OK_ON_BOTH |
CTL_CMD_FLAG_OK_ON_STOPPED | CTL_CMD_FLAG_OK_ON_STOPPED |
CTL_CMD_FLAG_OK_ON_INOPERABLE | CTL_CMD_FLAG_OK_ON_INOPERABLE |
CTL_CMD_FLAG_OK_ON_OFFLINE |
CTL_CMD_FLAG_OK_ON_SECONDARY | CTL_CMD_FLAG_OK_ON_SECONDARY |
CTL_FLAG_DATA_IN, CTL_FLAG_DATA_IN,
CTL_LUN_PAT_NONE, CTL_LUN_PAT_NONE,
@ -472,6 +483,7 @@ const struct ctl_cmd_entry ctl_cmd_table_a3[32] =
{ctl_report_supported_opcodes, CTL_SERIDX_INQ, CTL_CMD_FLAG_OK_ON_BOTH | {ctl_report_supported_opcodes, CTL_SERIDX_INQ, CTL_CMD_FLAG_OK_ON_BOTH |
CTL_CMD_FLAG_OK_ON_STOPPED | CTL_CMD_FLAG_OK_ON_STOPPED |
CTL_CMD_FLAG_OK_ON_INOPERABLE | CTL_CMD_FLAG_OK_ON_INOPERABLE |
CTL_CMD_FLAG_OK_ON_OFFLINE |
CTL_CMD_FLAG_OK_ON_SECONDARY | CTL_CMD_FLAG_OK_ON_SECONDARY |
CTL_FLAG_DATA_IN | CTL_FLAG_DATA_IN |
CTL_CMD_FLAG_ALLOW_ON_PR_RESV, CTL_CMD_FLAG_ALLOW_ON_PR_RESV,
@ -482,6 +494,7 @@ const struct ctl_cmd_entry ctl_cmd_table_a3[32] =
{ctl_report_supported_tmf, CTL_SERIDX_INQ, CTL_CMD_FLAG_OK_ON_BOTH | {ctl_report_supported_tmf, CTL_SERIDX_INQ, CTL_CMD_FLAG_OK_ON_BOTH |
CTL_CMD_FLAG_OK_ON_STOPPED | CTL_CMD_FLAG_OK_ON_STOPPED |
CTL_CMD_FLAG_OK_ON_INOPERABLE | CTL_CMD_FLAG_OK_ON_INOPERABLE |
CTL_CMD_FLAG_OK_ON_OFFLINE |
CTL_CMD_FLAG_OK_ON_SECONDARY | CTL_CMD_FLAG_OK_ON_SECONDARY |
CTL_FLAG_DATA_IN | CTL_FLAG_DATA_IN |
CTL_CMD_FLAG_ALLOW_ON_PR_RESV, CTL_CMD_FLAG_ALLOW_ON_PR_RESV,
@ -495,6 +508,7 @@ const struct ctl_cmd_entry ctl_cmd_table_a3[32] =
{ctl_report_timestamp, CTL_SERIDX_INQ, CTL_CMD_FLAG_OK_ON_BOTH | {ctl_report_timestamp, CTL_SERIDX_INQ, CTL_CMD_FLAG_OK_ON_BOTH |
CTL_CMD_FLAG_OK_ON_STOPPED | CTL_CMD_FLAG_OK_ON_STOPPED |
CTL_CMD_FLAG_OK_ON_INOPERABLE | CTL_CMD_FLAG_OK_ON_INOPERABLE |
CTL_CMD_FLAG_OK_ON_OFFLINE |
CTL_CMD_FLAG_OK_ON_SECONDARY | CTL_CMD_FLAG_OK_ON_SECONDARY |
CTL_FLAG_DATA_IN, CTL_FLAG_DATA_IN,
CTL_LUN_PAT_NONE, CTL_LUN_PAT_NONE,
@ -601,6 +615,7 @@ const struct ctl_cmd_entry ctl_cmd_table[256] =
{ctl_mode_select, CTL_SERIDX_MD_SEL, CTL_CMD_FLAG_OK_ON_BOTH | {ctl_mode_select, CTL_SERIDX_MD_SEL, CTL_CMD_FLAG_OK_ON_BOTH |
CTL_CMD_FLAG_OK_ON_STOPPED | CTL_CMD_FLAG_OK_ON_STOPPED |
CTL_CMD_FLAG_OK_ON_INOPERABLE | CTL_CMD_FLAG_OK_ON_INOPERABLE |
CTL_CMD_FLAG_OK_ON_OFFLINE |
CTL_CMD_FLAG_OK_ON_SECONDARY | CTL_CMD_FLAG_OK_ON_SECONDARY |
CTL_FLAG_DATA_OUT, CTL_FLAG_DATA_OUT,
CTL_LUN_PAT_NONE, 6, {0x11, 0, 0, 0xff, 0x07}}, CTL_LUN_PAT_NONE, 6, {0x11, 0, 0, 0xff, 0x07}},
@ -610,6 +625,7 @@ const struct ctl_cmd_entry ctl_cmd_table[256] =
CTL_CMD_FLAG_OK_ON_BOTH | CTL_CMD_FLAG_OK_ON_BOTH |
CTL_CMD_FLAG_OK_ON_STOPPED | CTL_CMD_FLAG_OK_ON_STOPPED |
CTL_CMD_FLAG_OK_ON_INOPERABLE | CTL_CMD_FLAG_OK_ON_INOPERABLE |
CTL_CMD_FLAG_OK_ON_OFFLINE |
CTL_CMD_FLAG_OK_ON_SECONDARY | CTL_CMD_FLAG_OK_ON_SECONDARY |
CTL_FLAG_DATA_OUT, CTL_FLAG_DATA_OUT,
CTL_LUN_PAT_NONE, 6, {0, 0, 0, 0, 0x07}}, CTL_LUN_PAT_NONE, 6, {0, 0, 0, 0, 0x07}},
@ -619,6 +635,7 @@ const struct ctl_cmd_entry ctl_cmd_table[256] =
CTL_CMD_FLAG_OK_ON_BOTH | CTL_CMD_FLAG_OK_ON_BOTH |
CTL_CMD_FLAG_OK_ON_STOPPED | CTL_CMD_FLAG_OK_ON_STOPPED |
CTL_CMD_FLAG_OK_ON_INOPERABLE | CTL_CMD_FLAG_OK_ON_INOPERABLE |
CTL_CMD_FLAG_OK_ON_OFFLINE |
CTL_CMD_FLAG_OK_ON_SECONDARY | CTL_CMD_FLAG_OK_ON_SECONDARY |
CTL_FLAG_DATA_NONE, CTL_FLAG_DATA_NONE,
CTL_LUN_PAT_NONE, 6, {0, 0, 0, 0, 0x07}}, CTL_LUN_PAT_NONE, 6, {0, 0, 0, 0, 0x07}},
@ -633,6 +650,7 @@ const struct ctl_cmd_entry ctl_cmd_table[256] =
{ctl_mode_sense, CTL_SERIDX_MD_SNS, CTL_CMD_FLAG_OK_ON_BOTH | {ctl_mode_sense, CTL_SERIDX_MD_SNS, CTL_CMD_FLAG_OK_ON_BOTH |
CTL_CMD_FLAG_OK_ON_STOPPED | CTL_CMD_FLAG_OK_ON_STOPPED |
CTL_CMD_FLAG_OK_ON_INOPERABLE | CTL_CMD_FLAG_OK_ON_INOPERABLE |
CTL_CMD_FLAG_OK_ON_OFFLINE |
CTL_CMD_FLAG_OK_ON_SECONDARY | CTL_CMD_FLAG_OK_ON_SECONDARY |
CTL_FLAG_DATA_IN | CTL_FLAG_DATA_IN |
CTL_CMD_FLAG_ALLOW_ON_PR_RESV, CTL_CMD_FLAG_ALLOW_ON_PR_RESV,
@ -750,7 +768,11 @@ const struct ctl_cmd_entry ctl_cmd_table[256] =
{NULL, CTL_SERIDX_INVLD, CTL_CMD_FLAG_NONE, CTL_LUN_PAT_NONE}, {NULL, CTL_SERIDX_INVLD, CTL_CMD_FLAG_NONE, CTL_LUN_PAT_NONE},
/* 37 READ DEFECT DATA(10) */ /* 37 READ DEFECT DATA(10) */
{NULL, CTL_SERIDX_INVLD, CTL_CMD_FLAG_NONE, CTL_LUN_PAT_NONE}, {ctl_read_defect, CTL_SERIDX_MD_SNS, CTL_CMD_FLAG_OK_ON_SLUN |
CTL_FLAG_DATA_IN |
CTL_CMD_FLAG_ALLOW_ON_PR_RESV,
CTL_LUN_PAT_NONE,
10, {0, 0x1f, 0, 0, 0, 0, 0xff, 0xff, 0x07}},
/* 38 MEDIUM SCAN */ /* 38 MEDIUM SCAN */
{NULL, CTL_SERIDX_INVLD, CTL_CMD_FLAG_NONE, CTL_LUN_PAT_NONE}, {NULL, CTL_SERIDX_INVLD, CTL_CMD_FLAG_NONE, CTL_LUN_PAT_NONE},
@ -855,6 +877,7 @@ const struct ctl_cmd_entry ctl_cmd_table[256] =
{ctl_mode_select, CTL_SERIDX_MD_SEL, CTL_CMD_FLAG_OK_ON_BOTH | {ctl_mode_select, CTL_SERIDX_MD_SEL, CTL_CMD_FLAG_OK_ON_BOTH |
CTL_CMD_FLAG_OK_ON_STOPPED | CTL_CMD_FLAG_OK_ON_STOPPED |
CTL_CMD_FLAG_OK_ON_INOPERABLE | CTL_CMD_FLAG_OK_ON_INOPERABLE |
CTL_CMD_FLAG_OK_ON_OFFLINE |
CTL_CMD_FLAG_OK_ON_SECONDARY | CTL_CMD_FLAG_OK_ON_SECONDARY |
CTL_FLAG_DATA_OUT, CTL_FLAG_DATA_OUT,
CTL_LUN_PAT_NONE, 10, {0x11, 0, 0, 0, 0, 0, 0xff, 0xff, 0x07} }, CTL_LUN_PAT_NONE, 10, {0x11, 0, 0, 0, 0, 0, 0xff, 0xff, 0x07} },
@ -864,6 +887,7 @@ const struct ctl_cmd_entry ctl_cmd_table[256] =
CTL_CMD_FLAG_OK_ON_BOTH | CTL_CMD_FLAG_OK_ON_BOTH |
CTL_CMD_FLAG_OK_ON_STOPPED | CTL_CMD_FLAG_OK_ON_STOPPED |
CTL_CMD_FLAG_OK_ON_INOPERABLE | CTL_CMD_FLAG_OK_ON_INOPERABLE |
CTL_CMD_FLAG_OK_ON_OFFLINE |
CTL_CMD_FLAG_OK_ON_SECONDARY | CTL_CMD_FLAG_OK_ON_SECONDARY |
CTL_FLAG_DATA_OUT, CTL_FLAG_DATA_OUT,
CTL_LUN_PAT_NONE, 10, {0x02, 0, 0xff, 0, 0, 0, 0xff, 0xff, 0x07} }, CTL_LUN_PAT_NONE, 10, {0x02, 0, 0xff, 0, 0, 0, 0xff, 0xff, 0x07} },
@ -873,6 +897,7 @@ const struct ctl_cmd_entry ctl_cmd_table[256] =
CTL_CMD_FLAG_OK_ON_BOTH | CTL_CMD_FLAG_OK_ON_BOTH |
CTL_CMD_FLAG_OK_ON_STOPPED | CTL_CMD_FLAG_OK_ON_STOPPED |
CTL_CMD_FLAG_OK_ON_INOPERABLE | CTL_CMD_FLAG_OK_ON_INOPERABLE |
CTL_CMD_FLAG_OK_ON_OFFLINE |
CTL_CMD_FLAG_OK_ON_SECONDARY | CTL_CMD_FLAG_OK_ON_SECONDARY |
CTL_FLAG_DATA_OUT, CTL_FLAG_DATA_OUT,
CTL_LUN_PAT_NONE, 10, {0x02, 0, 0xff, 0, 0, 0, 0xff, 0xff, 0x07} }, CTL_LUN_PAT_NONE, 10, {0x02, 0, 0xff, 0, 0, 0, 0xff, 0xff, 0x07} },
@ -887,6 +912,7 @@ const struct ctl_cmd_entry ctl_cmd_table[256] =
{ctl_mode_sense, CTL_SERIDX_MD_SNS, CTL_CMD_FLAG_OK_ON_BOTH | {ctl_mode_sense, CTL_SERIDX_MD_SNS, CTL_CMD_FLAG_OK_ON_BOTH |
CTL_CMD_FLAG_OK_ON_STOPPED | CTL_CMD_FLAG_OK_ON_STOPPED |
CTL_CMD_FLAG_OK_ON_INOPERABLE | CTL_CMD_FLAG_OK_ON_INOPERABLE |
CTL_CMD_FLAG_OK_ON_OFFLINE |
CTL_CMD_FLAG_OK_ON_SECONDARY | CTL_CMD_FLAG_OK_ON_SECONDARY |
CTL_FLAG_DATA_IN | CTL_FLAG_DATA_IN |
CTL_CMD_FLAG_ALLOW_ON_PR_RESV, CTL_CMD_FLAG_ALLOW_ON_PR_RESV,
@ -1225,7 +1251,11 @@ const struct ctl_cmd_entry ctl_cmd_table[256] =
{NULL, CTL_SERIDX_INVLD, CTL_CMD_FLAG_NONE, CTL_LUN_PAT_NONE}, {NULL, CTL_SERIDX_INVLD, CTL_CMD_FLAG_NONE, CTL_LUN_PAT_NONE},
/* B7 READ DEFECT DATA(12) */ /* B7 READ DEFECT DATA(12) */
{NULL, CTL_SERIDX_INVLD, CTL_CMD_FLAG_NONE, CTL_LUN_PAT_NONE}, {ctl_read_defect, CTL_SERIDX_MD_SNS, CTL_CMD_FLAG_OK_ON_SLUN |
CTL_FLAG_DATA_IN |
CTL_CMD_FLAG_ALLOW_ON_PR_RESV,
CTL_LUN_PAT_NONE,
12, {0x1f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0, 0x07}},
/* B8 READ ELEMENT STATUS */ /* B8 READ ELEMENT STATUS */
{NULL, CTL_SERIDX_INVLD, CTL_CMD_FLAG_NONE, CTL_LUN_PAT_NONE}, {NULL, CTL_SERIDX_INVLD, CTL_CMD_FLAG_NONE, CTL_LUN_PAT_NONE},

View File

@ -1996,7 +1996,8 @@ cfiscsi_ioctl_port_create(struct ctl_req *req)
/* XXX KDM what should the real number be here? */ /* XXX KDM what should the real number be here? */
port->num_requested_ctl_io = 4096; port->num_requested_ctl_io = 4096;
port->port_name = "iscsi"; port->port_name = "iscsi";
port->virtual_port = strtoul(tag, NULL, 0); port->physical_port = strtoul(tag, NULL, 0);
port->virtual_port = ct->ct_target_id;
port->port_online = cfiscsi_online; port->port_online = cfiscsi_online;
port->port_offline = cfiscsi_offline; port->port_offline = cfiscsi_offline;
port->port_info = cfiscsi_info; port->port_info = cfiscsi_info;
@ -2029,7 +2030,7 @@ cfiscsi_ioctl_port_create(struct ctl_req *req)
SVPD_ID_TYPE_SCSI_NAME; SVPD_ID_TYPE_SCSI_NAME;
desc->length = idlen; desc->length = idlen;
snprintf(desc->identifier, idlen, "%s,t,0x%4.4x", snprintf(desc->identifier, idlen, "%s,t,0x%4.4x",
target, port->virtual_port); target, port->physical_port);
/* Generate Target ID. */ /* Generate Target ID. */
idlen = strlen(target) + 1; idlen = strlen(target) + 1;
@ -2257,6 +2258,9 @@ cfiscsi_target_find_or_create(struct cfiscsi_softc *softc, const char *name,
strlcpy(newct->ct_alias, alias, sizeof(newct->ct_alias)); strlcpy(newct->ct_alias, alias, sizeof(newct->ct_alias));
refcount_init(&newct->ct_refcount, 1); refcount_init(&newct->ct_refcount, 1);
newct->ct_softc = softc; newct->ct_softc = softc;
if (TAILQ_EMPTY(&softc->targets))
softc->last_target_id = 0;
newct->ct_target_id = ++softc->last_target_id;
TAILQ_INSERT_TAIL(&softc->targets, newct, ct_next); TAILQ_INSERT_TAIL(&softc->targets, newct, ct_next);
mtx_unlock(&softc->lock); mtx_unlock(&softc->lock);

View File

@ -45,6 +45,7 @@ struct cfiscsi_target {
char ct_alias[CTL_ISCSI_ALIAS_LEN]; char ct_alias[CTL_ISCSI_ALIAS_LEN];
int ct_state; int ct_state;
int ct_online; int ct_online;
int ct_target_id;
struct ctl_port ct_port; struct ctl_port ct_port;
}; };
@ -110,6 +111,7 @@ struct cfiscsi_softc {
struct mtx lock; struct mtx lock;
char port_name[32]; char port_name[32];
int online; int online;
int last_target_id;
unsigned int last_session_id; unsigned int last_session_id;
TAILQ_HEAD(, cfiscsi_target) targets; TAILQ_HEAD(, cfiscsi_target) targets;
TAILQ_HEAD(, cfiscsi_session) sessions; TAILQ_HEAD(, cfiscsi_session) sessions;

View File

@ -363,7 +363,8 @@ struct ctl_port_list {
typedef enum { typedef enum {
CTL_LUN_NOSTATUS, CTL_LUN_NOSTATUS,
CTL_LUN_OK, CTL_LUN_OK,
CTL_LUN_ERROR CTL_LUN_ERROR,
CTL_LUN_WARNING
} ctl_lun_status; } ctl_lun_status;
#define CTL_ERROR_STR_LEN 160 #define CTL_ERROR_STR_LEN 160

View File

@ -353,11 +353,6 @@ typedef enum {
CTL_PR_FLAG_ACTIVE_RES = 0x02 CTL_PR_FLAG_ACTIVE_RES = 0x02
} ctl_per_res_flags; } ctl_per_res_flags;
struct ctl_per_res_info {
struct scsi_per_res_key res_key;
uint8_t registered;
};
#define CTL_PR_ALL_REGISTRANTS 0xFFFFFFFF #define CTL_PR_ALL_REGISTRANTS 0xFFFFFFFF
#define CTL_PR_NO_RESERVATION 0xFFFFFFF0 #define CTL_PR_NO_RESERVATION 0xFFFFFFF0
@ -398,8 +393,8 @@ struct ctl_lun {
struct ctl_mode_pages mode_pages; struct ctl_mode_pages mode_pages;
struct ctl_lun_io_stats stats; struct ctl_lun_io_stats stats;
uint32_t res_idx; uint32_t res_idx;
struct ctl_per_res_info per_res[2*CTL_MAX_INITIATORS];
unsigned int PRGeneration; unsigned int PRGeneration;
uint64_t pr_keys[2*CTL_MAX_INITIATORS];
int pr_key_count; int pr_key_count;
uint32_t pr_res_idx; uint32_t pr_res_idx;
uint8_t res_type; uint8_t res_type;
@ -491,6 +486,7 @@ int ctl_mode_select(struct ctl_scsiio *ctsio);
int ctl_mode_sense(struct ctl_scsiio *ctsio); int ctl_mode_sense(struct ctl_scsiio *ctsio);
int ctl_read_capacity(struct ctl_scsiio *ctsio); int ctl_read_capacity(struct ctl_scsiio *ctsio);
int ctl_read_capacity_16(struct ctl_scsiio *ctsio); int ctl_read_capacity_16(struct ctl_scsiio *ctsio);
int ctl_read_defect(struct ctl_scsiio *ctsio);
int ctl_read_write(struct ctl_scsiio *ctsio); int ctl_read_write(struct ctl_scsiio *ctsio);
int ctl_cnw(struct ctl_scsiio *ctsio); int ctl_cnw(struct ctl_scsiio *ctsio);
int ctl_report_luns(struct ctl_scsiio *ctsio); int ctl_report_luns(struct ctl_scsiio *ctsio);

View File

@ -224,12 +224,13 @@ static void ctlfe_dump(void);
static struct periph_driver ctlfe_driver = static struct periph_driver ctlfe_driver =
{ {
ctlfeperiphinit, "ctl", ctlfeperiphinit, "ctl",
TAILQ_HEAD_INITIALIZER(ctlfe_driver.units), /*generation*/ 0 TAILQ_HEAD_INITIALIZER(ctlfe_driver.units), /*generation*/ 0,
CAM_PERIPH_DRV_EARLY
}; };
static struct ctl_frontend ctlfe_frontend = static struct ctl_frontend ctlfe_frontend =
{ {
.name = "camtarget", .name = "camtgt",
.init = ctlfeinitialize, .init = ctlfeinitialize,
.fe_dump = ctlfe_dump, .fe_dump = ctlfe_dump,
.shutdown = ctlfeshutdown, .shutdown = ctlfeshutdown,
@ -270,11 +271,19 @@ ctlfeperiphinit(void)
static void static void
ctlfeasync(void *callback_arg, uint32_t code, struct cam_path *path, void *arg) ctlfeasync(void *callback_arg, uint32_t code, struct cam_path *path, void *arg)
{ {
struct ctlfe_softc *softc;
#ifdef CTLFEDEBUG #ifdef CTLFEDEBUG
printf("%s: entered\n", __func__); printf("%s: entered\n", __func__);
#endif #endif
mtx_lock(&ctlfe_list_mtx);
STAILQ_FOREACH(softc, &ctlfe_softc_list, links) {
if (softc->path_id == xpt_path_path_id(path))
break;
}
mtx_unlock(&ctlfe_list_mtx);
/* /*
* When a new path gets registered, and it is capable of target * When a new path gets registered, and it is capable of target
* mode, go ahead and attach. Later on, we may need to be more * mode, go ahead and attach. Later on, we may need to be more
@ -283,7 +292,6 @@ ctlfeasync(void *callback_arg, uint32_t code, struct cam_path *path, void *arg)
switch (code) { switch (code) {
case AC_PATH_REGISTERED: { case AC_PATH_REGISTERED: {
struct ctl_port *port; struct ctl_port *port;
struct ctlfe_softc *bus_softc;
struct ccb_pathinq *cpi; struct ccb_pathinq *cpi;
int retval; int retval;
@ -298,6 +306,14 @@ ctlfeasync(void *callback_arg, uint32_t code, struct cam_path *path, void *arg)
break; break;
} }
if (softc != NULL) {
#ifdef CTLFEDEBUG
printf("%s: CTL port for CAM path %u already exists\n",
__func__, xpt_path_path_id(path));
#endif
break;
}
#ifdef CTLFE_INIT_ENABLE #ifdef CTLFE_INIT_ENABLE
if (ctlfe_num_targets >= ctlfe_max_targets) { if (ctlfe_num_targets >= ctlfe_max_targets) {
union ccb *ccb; union ccb *ccb;
@ -346,25 +362,23 @@ ctlfeasync(void *callback_arg, uint32_t code, struct cam_path *path, void *arg)
* use M_NOWAIT. Of course this means trouble if we * use M_NOWAIT. Of course this means trouble if we
* can't allocate memory. * can't allocate memory.
*/ */
bus_softc = malloc(sizeof(*bus_softc), M_CTLFE, softc = malloc(sizeof(*softc), M_CTLFE, M_NOWAIT | M_ZERO);
M_NOWAIT | M_ZERO); if (softc == NULL) {
if (bus_softc == NULL) {
printf("%s: unable to malloc %zd bytes for softc\n", printf("%s: unable to malloc %zd bytes for softc\n",
__func__, sizeof(*bus_softc)); __func__, sizeof(*softc));
return; return;
} }
bus_softc->path_id = cpi->ccb_h.path_id; softc->path_id = cpi->ccb_h.path_id;
bus_softc->sim = xpt_path_sim(path); softc->sim = xpt_path_sim(path);
if (cpi->maxio != 0) if (cpi->maxio != 0)
bus_softc->maxio = cpi->maxio; softc->maxio = cpi->maxio;
else else
bus_softc->maxio = DFLTPHYS; softc->maxio = DFLTPHYS;
mtx_init(&bus_softc->lun_softc_mtx, "LUN softc mtx", NULL, mtx_init(&softc->lun_softc_mtx, "LUN softc mtx", NULL, MTX_DEF);
MTX_DEF); STAILQ_INIT(&softc->lun_softc_list);
STAILQ_INIT(&bus_softc->lun_softc_list);
port = &bus_softc->port; port = &softc->port;
port->frontend = &ctlfe_frontend; port->frontend = &ctlfe_frontend;
/* /*
@ -379,21 +393,21 @@ ctlfeasync(void *callback_arg, uint32_t code, struct cam_path *path, void *arg)
/* XXX KDM what should the real number be here? */ /* XXX KDM what should the real number be here? */
port->num_requested_ctl_io = 4096; port->num_requested_ctl_io = 4096;
snprintf(bus_softc->port_name, sizeof(bus_softc->port_name), snprintf(softc->port_name, sizeof(softc->port_name),
"%s%d", cpi->dev_name, cpi->unit_number); "%s%d", cpi->dev_name, cpi->unit_number);
/* /*
* XXX KDM it would be nice to allocate storage in the * XXX KDM it would be nice to allocate storage in the
* frontend structure itself. * frontend structure itself.
*/ */
port->port_name = bus_softc->port_name; port->port_name = softc->port_name;
port->physical_port = cpi->unit_number; port->physical_port = cpi->bus_id;
port->virtual_port = cpi->bus_id; port->virtual_port = 0;
port->port_online = ctlfe_online; port->port_online = ctlfe_online;
port->port_offline = ctlfe_offline; port->port_offline = ctlfe_offline;
port->onoff_arg = bus_softc; port->onoff_arg = softc;
port->lun_enable = ctlfe_lun_enable; port->lun_enable = ctlfe_lun_enable;
port->lun_disable = ctlfe_lun_disable; port->lun_disable = ctlfe_lun_disable;
port->targ_lun_arg = bus_softc; port->targ_lun_arg = softc;
port->fe_datamove = ctlfe_datamove_done; port->fe_datamove = ctlfe_datamove_done;
port->fe_done = ctlfe_datamove_done; port->fe_done = ctlfe_datamove_done;
/* /*
@ -415,35 +429,28 @@ ctlfeasync(void *callback_arg, uint32_t code, struct cam_path *path, void *arg)
if (retval != 0) { if (retval != 0) {
printf("%s: ctl_port_register() failed with " printf("%s: ctl_port_register() failed with "
"error %d!\n", __func__, retval); "error %d!\n", __func__, retval);
mtx_destroy(&bus_softc->lun_softc_mtx); mtx_destroy(&softc->lun_softc_mtx);
free(bus_softc, M_CTLFE); free(softc, M_CTLFE);
break; break;
} else { } else {
mtx_lock(&ctlfe_list_mtx); mtx_lock(&ctlfe_list_mtx);
STAILQ_INSERT_TAIL(&ctlfe_softc_list, bus_softc, links); STAILQ_INSERT_TAIL(&ctlfe_softc_list, softc, links);
mtx_unlock(&ctlfe_list_mtx); mtx_unlock(&ctlfe_list_mtx);
} }
break; break;
} }
case AC_PATH_DEREGISTERED: { case AC_PATH_DEREGISTERED: {
struct ctlfe_softc *softc = NULL;
mtx_lock(&ctlfe_list_mtx);
STAILQ_FOREACH(softc, &ctlfe_softc_list, links) {
if (softc->path_id == xpt_path_path_id(path)) {
STAILQ_REMOVE(&ctlfe_softc_list, softc,
ctlfe_softc, links);
break;
}
}
mtx_unlock(&ctlfe_list_mtx);
if (softc != NULL) { if (softc != NULL) {
/* /*
* XXX KDM are we certain at this point that there * XXX KDM are we certain at this point that there
* are no outstanding commands for this frontend? * are no outstanding commands for this frontend?
*/ */
mtx_lock(&ctlfe_list_mtx);
STAILQ_REMOVE(&ctlfe_softc_list, softc, ctlfe_softc,
links);
mtx_unlock(&ctlfe_list_mtx);
ctl_port_deregister(&softc->port); ctl_port_deregister(&softc->port);
mtx_destroy(&softc->lun_softc_mtx); mtx_destroy(&softc->lun_softc_mtx);
free(softc, M_CTLFE); free(softc, M_CTLFE);
@ -458,8 +465,7 @@ ctlfeasync(void *callback_arg, uint32_t code, struct cam_path *path, void *arg)
switch (ac->contract_number) { switch (ac->contract_number) {
case AC_CONTRACT_DEV_CHG: { case AC_CONTRACT_DEV_CHG: {
struct ac_device_changed *dev_chg; struct ac_device_changed *dev_chg;
struct ctlfe_softc *softc; int retval;
int retval, found;
dev_chg = (struct ac_device_changed *)ac->contract_data; dev_chg = (struct ac_device_changed *)ac->contract_data;
@ -468,18 +474,7 @@ ctlfeasync(void *callback_arg, uint32_t code, struct cam_path *path, void *arg)
xpt_path_path_id(path), dev_chg->target, xpt_path_path_id(path), dev_chg->target,
(dev_chg->arrived == 0) ? "left" : "arrived"); (dev_chg->arrived == 0) ? "left" : "arrived");
found = 0; if (softc == NULL) {
mtx_lock(&ctlfe_list_mtx);
STAILQ_FOREACH(softc, &ctlfe_softc_list, links) {
if (softc->path_id == xpt_path_path_id(path)) {
found = 1;
break;
}
}
mtx_unlock(&ctlfe_list_mtx);
if (found == 0) {
printf("%s: CTL port for CAM path %u not " printf("%s: CTL port for CAM path %u not "
"found!\n", __func__, "found!\n", __func__,
xpt_path_path_id(path)); xpt_path_path_id(path));
@ -1518,11 +1513,6 @@ ctlfedone(struct cam_periph *periph, union ccb *done_ccb)
case CAM_MESSAGE_RECV: case CAM_MESSAGE_RECV:
switch (inot->arg) { switch (inot->arg) {
case MSG_ABORT_TASK_SET: case MSG_ABORT_TASK_SET:
/*
* XXX KDM this isn't currently
* supported by CTL. It ends up
* being a no-op.
*/
io->taskio.task_action = io->taskio.task_action =
CTL_TASK_ABORT_TASK_SET; CTL_TASK_ABORT_TASK_SET;
break; break;
@ -1539,11 +1529,6 @@ ctlfedone(struct cam_periph *periph, union ccb *done_ccb)
CTL_TASK_LUN_RESET; CTL_TASK_LUN_RESET;
break; break;
case MSG_CLEAR_TASK_SET: case MSG_CLEAR_TASK_SET:
/*
* XXX KDM this isn't currently
* supported by CTL. It ends up
* being a no-op.
*/
io->taskio.task_action = io->taskio.task_action =
CTL_TASK_CLEAR_TASK_SET; CTL_TASK_CLEAR_TASK_SET;
break; break;

View File

@ -92,28 +92,19 @@ struct scsi_reassign_blocks
struct scsi_read_defect_data_10 struct scsi_read_defect_data_10
{ {
u_int8_t opcode; uint8_t opcode;
uint8_t byte2;
/*
* The most significant 3 bits are the LUN, the other 5 are
* reserved.
*/
#define SRDD10_LUN_MASK 0xE0
u_int8_t byte2;
#define SRDD10_GLIST 0x08 #define SRDD10_GLIST 0x08
#define SRDD10_PLIST 0x10 #define SRDD10_PLIST 0x10
#define SRDD10_DLIST_FORMAT_MASK 0x07 #define SRDD10_DLIST_FORMAT_MASK 0x07
#define SRDD10_BLOCK_FORMAT 0x00 #define SRDD10_BLOCK_FORMAT 0x00
#define SRDD10_BYTES_FROM_INDEX_FORMAT 0x04 #define SRDD10_BYTES_FROM_INDEX_FORMAT 0x04
#define SRDD10_PHYSICAL_SECTOR_FORMAT 0x05 #define SRDD10_PHYSICAL_SECTOR_FORMAT 0x05
u_int8_t format; uint8_t format;
uint8_t reserved[4];
u_int8_t reserved[4]; uint8_t alloc_length[2];
u_int8_t alloc_length[2];
#define SRDD10_MAX_LENGTH 0xffff #define SRDD10_MAX_LENGTH 0xffff
uint8_t control;
u_int8_t control;
}; };
struct scsi_sanitize struct scsi_sanitize
@ -143,29 +134,18 @@ struct scsi_sanitize_parameter_list
struct scsi_read_defect_data_12 struct scsi_read_defect_data_12
{ {
u_int8_t opcode; uint8_t opcode;
/*
* The most significant 3 bits are the LUN, the other 5 are
* reserved.
*/
#define SRDD12_LUN_MASK 0xE0
u_int8_t byte2;
#define SRDD12_GLIST 0x08 #define SRDD12_GLIST 0x08
#define SRDD12_PLIST 0x10 #define SRDD12_PLIST 0x10
#define SRDD12_DLIST_FORMAT_MASK 0x07 #define SRDD12_DLIST_FORMAT_MASK 0x07
#define SRDD12_BLOCK_FORMAT 0x00 #define SRDD12_BLOCK_FORMAT 0x00
#define SRDD12_BYTES_FROM_INDEX_FORMAT 0x04 #define SRDD12_BYTES_FROM_INDEX_FORMAT 0x04
#define SRDD12_PHYSICAL_SECTOR_FORMAT 0x05 #define SRDD12_PHYSICAL_SECTOR_FORMAT 0x05
u_int8_t format; uint8_t format;
uint8_t address_descriptor_index[4];
u_int8_t reserved[4]; uint8_t alloc_length[4];
uint8_t reserved;
u_int8_t alloc_length[4]; uint8_t control;
u_int8_t control;
}; };
@ -376,6 +356,7 @@ struct scsi_read_defect_data_hdr_12
#define SRDDH12_BYTES_FROM_INDEX_FORMAT 0x04 #define SRDDH12_BYTES_FROM_INDEX_FORMAT 0x04
#define SRDDH12_PHYSICAL_SECTOR_FORMAT 0x05 #define SRDDH12_PHYSICAL_SECTOR_FORMAT 0x05
u_int8_t format; u_int8_t format;
u_int8_t generation[2];
u_int8_t length[4]; u_int8_t length[4];
}; };

View File

@ -217,6 +217,7 @@ SYSINIT(arc_free_target_init, SI_SUB_KTHREAD_PAGE, SI_ORDER_ANY,
arc_free_target_init, NULL); arc_free_target_init, NULL);
TUNABLE_QUAD("vfs.zfs.arc_meta_limit", &zfs_arc_meta_limit); TUNABLE_QUAD("vfs.zfs.arc_meta_limit", &zfs_arc_meta_limit);
TUNABLE_INT("vfs.zfs.arc_shrink_shift", &zfs_arc_shrink_shift);
SYSCTL_DECL(_vfs_zfs); SYSCTL_DECL(_vfs_zfs);
SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, arc_max, CTLFLAG_RDTUN, &zfs_arc_max, 0, SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, arc_max, CTLFLAG_RDTUN, &zfs_arc_max, 0,
"Maximum ARC size"); "Maximum ARC size");
@ -225,6 +226,10 @@ SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, arc_min, CTLFLAG_RDTUN, &zfs_arc_min, 0,
SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, arc_average_blocksize, CTLFLAG_RDTUN, SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, arc_average_blocksize, CTLFLAG_RDTUN,
&zfs_arc_average_blocksize, 0, &zfs_arc_average_blocksize, 0,
"ARC average blocksize"); "ARC average blocksize");
SYSCTL_INT(_vfs_zfs, OID_AUTO, arc_shrink_shift, CTLFLAG_RW,
&arc_shrink_shift, 0,
"log2(fraction of arc to reclaim)");
/* /*
* We don't have a tunable for arc_free_target due to the dependency on * We don't have a tunable for arc_free_target due to the dependency on
* pagedaemon initialisation. * pagedaemon initialisation.
@ -5227,7 +5232,7 @@ l2arc_write_buffers(spa_t *spa, l2arc_dev_t *dev, uint64_t target_sz,
ARCSTAT_INCR(arcstat_l2_write_bytes, write_asize); ARCSTAT_INCR(arcstat_l2_write_bytes, write_asize);
ARCSTAT_INCR(arcstat_l2_size, write_sz); ARCSTAT_INCR(arcstat_l2_size, write_sz);
ARCSTAT_INCR(arcstat_l2_asize, write_asize); ARCSTAT_INCR(arcstat_l2_asize, write_asize);
vdev_space_update(dev->l2ad_vdev, write_asize, 0, 0); vdev_space_update(dev->l2ad_vdev, write_psize, 0, 0);
/* /*
* Bump device hand to the device start if it is approaching the end. * Bump device hand to the device start if it is approaching the end.

View File

@ -3175,6 +3175,7 @@ libkern/inet_ntoa.c standard
libkern/inet_ntop.c standard libkern/inet_ntop.c standard
libkern/inet_pton.c standard libkern/inet_pton.c standard
libkern/jenkins_hash.c standard libkern/jenkins_hash.c standard
libkern/murmur3_32.c standard
libkern/mcount.c optional profiling-routine libkern/mcount.c optional profiling-routine
libkern/memcchr.c standard libkern/memcchr.c standard
libkern/memchr.c optional fdt | gdb libkern/memchr.c optional fdt | gdb

View File

@ -1,6 +1,7 @@
/* $FreeBSD$ */ /* $FreeBSD$ */
OUTPUT_FORMAT("elf32-powerpc", "elf32-powerpc", "elf32-powerpc") OUTPUT_FORMAT("elf32-powerpc-freebsd", "elf32-powerpc-freebsd",
"elf32-powerpc-freebsd")
OUTPUT_ARCH(powerpc) OUTPUT_ARCH(powerpc)
ENTRY(__start) ENTRY(__start)
SEARCH_DIR(/usr/lib); SEARCH_DIR(/usr/lib);

View File

@ -1,6 +1,7 @@
/* $FreeBSD$ */ /* $FreeBSD$ */
OUTPUT_FORMAT("elf64-powerpc", "elf64-powerpc", "elf64-powerpc") OUTPUT_FORMAT("elf64-powerpc-freebsd", "elf64-powerpc-freebsd",
"elf64-powerpc-freebsd")
OUTPUT_ARCH(powerpc:common64) OUTPUT_ARCH(powerpc:common64)
ENTRY(__start) ENTRY(__start)
SEARCH_DIR(/usr/lib); SEARCH_DIR(/usr/lib);

Some files were not shown because too many files have changed in this diff Show More