MFH
Sponsored by: The FreeBSD Foundation
This commit is contained in:
commit
0e186c0aab
@ -2841,8 +2841,11 @@ Do not actually receive the stream. This can be useful in conjunction with the
|
||||
option to verify the name the receive operation would use.
|
||||
.It Fl o Sy origin Ns = Ns Ar snapshot
|
||||
Forces the stream to be received as a clone of the given snapshot.
|
||||
This is only valid if the stream is an incremental stream whose source
|
||||
is the same as the provided origin.
|
||||
If the stream is a full send stream, this will create the filesystem
|
||||
described by the stream as a clone of the specified snapshot. Which
|
||||
snapshot was specified will not affect the success or failure of the
|
||||
receive, as long as the snapshot does exist. If the stream is an
|
||||
incremental send stream, all the normal verification will be performed.
|
||||
.It Fl F
|
||||
Force a rollback of the file system to the most recent snapshot before
|
||||
performing the receive operation. If receiving an incremental replication
|
||||
|
@ -26,6 +26,7 @@
|
||||
* Copyright (c) 2012 Pawel Jakub Dawidek <pawel@dawidek.net>.
|
||||
* All rights reserved.
|
||||
* Copyright (c) 2013 Steven Hartland. All rights reserved.
|
||||
* Copyright 2015, OmniTI Computer Consulting, Inc. All rights reserved.
|
||||
*/
|
||||
|
||||
#include <assert.h>
|
||||
@ -67,7 +68,7 @@ extern void zfs_setprop_error(libzfs_handle_t *, zfs_prop_t, int, char *);
|
||||
|
||||
static int zfs_receive_impl(libzfs_handle_t *, const char *, const char *,
|
||||
recvflags_t *, int, const char *, nvlist_t *, avl_tree_t *, char **, int,
|
||||
uint64_t *);
|
||||
uint64_t *, const char *);
|
||||
static int guid_to_name(libzfs_handle_t *, const char *,
|
||||
uint64_t, boolean_t, char *);
|
||||
|
||||
@ -2602,6 +2603,7 @@ zfs_receive_package(libzfs_handle_t *hdl, int fd, const char *destname,
|
||||
nvlist_t *stream_nv = NULL;
|
||||
avl_tree_t *stream_avl = NULL;
|
||||
char *fromsnap = NULL;
|
||||
char *sendsnap = NULL;
|
||||
char *cp;
|
||||
char tofs[ZFS_MAXNAMELEN];
|
||||
char sendfs[ZFS_MAXNAMELEN];
|
||||
@ -2750,8 +2752,16 @@ zfs_receive_package(libzfs_handle_t *hdl, int fd, const char *destname,
|
||||
*/
|
||||
(void) strlcpy(sendfs, drr->drr_u.drr_begin.drr_toname,
|
||||
ZFS_MAXNAMELEN);
|
||||
if ((cp = strchr(sendfs, '@')) != NULL)
|
||||
if ((cp = strchr(sendfs, '@')) != NULL) {
|
||||
*cp = '\0';
|
||||
/*
|
||||
* Find the "sendsnap", the final snapshot in a replication
|
||||
* stream. zfs_receive_one() handles certain errors
|
||||
* differently, depending on if the contained stream is the
|
||||
* last one or not.
|
||||
*/
|
||||
sendsnap = (cp + 1);
|
||||
}
|
||||
|
||||
/* Finally, receive each contained stream */
|
||||
do {
|
||||
@ -2764,7 +2774,7 @@ zfs_receive_package(libzfs_handle_t *hdl, int fd, const char *destname,
|
||||
*/
|
||||
error = zfs_receive_impl(hdl, destname, NULL, flags, fd,
|
||||
sendfs, stream_nv, stream_avl, top_zfs, cleanup_fd,
|
||||
action_handlep);
|
||||
action_handlep, sendsnap);
|
||||
if (error == ENODATA) {
|
||||
error = 0;
|
||||
break;
|
||||
@ -2930,7 +2940,7 @@ zfs_receive_one(libzfs_handle_t *hdl, int infd, const char *tosnap,
|
||||
const char *originsnap, recvflags_t *flags, dmu_replay_record_t *drr,
|
||||
dmu_replay_record_t *drr_noswap, const char *sendfs, nvlist_t *stream_nv,
|
||||
avl_tree_t *stream_avl, char **top_zfs, int cleanup_fd,
|
||||
uint64_t *action_handlep)
|
||||
uint64_t *action_handlep, const char *finalsnap)
|
||||
{
|
||||
zfs_cmd_t zc = { 0 };
|
||||
time_t begin_time;
|
||||
@ -2947,6 +2957,7 @@ zfs_receive_one(libzfs_handle_t *hdl, int infd, const char *tosnap,
|
||||
nvlist_t *snapprops_nvlist = NULL;
|
||||
zprop_errflags_t prop_errflags;
|
||||
boolean_t recursive;
|
||||
char *snapname = NULL;
|
||||
|
||||
begin_time = time(NULL);
|
||||
|
||||
@ -2957,7 +2968,6 @@ zfs_receive_one(libzfs_handle_t *hdl, int infd, const char *tosnap,
|
||||
ENOENT);
|
||||
|
||||
if (stream_avl != NULL) {
|
||||
char *snapname;
|
||||
nvlist_t *fs = fsavl_find(stream_avl, drrb->drr_toguid,
|
||||
&snapname);
|
||||
nvlist_t *props;
|
||||
@ -3313,7 +3323,21 @@ zfs_receive_one(libzfs_handle_t *hdl, int infd, const char *tosnap,
|
||||
ZPROP_N_MORE_ERRORS) == 0) {
|
||||
trunc_prop_errs(intval);
|
||||
break;
|
||||
} else {
|
||||
} else if (snapname == NULL || finalsnap == NULL ||
|
||||
strcmp(finalsnap, snapname) == 0 ||
|
||||
strcmp(nvpair_name(prop_err),
|
||||
zfs_prop_to_name(ZFS_PROP_REFQUOTA)) != 0) {
|
||||
/*
|
||||
* Skip the special case of, for example,
|
||||
* "refquota", errors on intermediate
|
||||
* snapshots leading up to a final one.
|
||||
* That's why we have all of the checks above.
|
||||
*
|
||||
* See zfs_ioctl.c's extract_delay_props() for
|
||||
* a list of props which can fail on
|
||||
* intermediate snapshots, but shouldn't
|
||||
* affect the overall receive.
|
||||
*/
|
||||
(void) snprintf(tbuf, sizeof (tbuf),
|
||||
dgettext(TEXT_DOMAIN,
|
||||
"cannot receive %s property on %s"),
|
||||
@ -3498,7 +3522,7 @@ static int
|
||||
zfs_receive_impl(libzfs_handle_t *hdl, const char *tosnap,
|
||||
const char *originsnap, recvflags_t *flags, int infd, const char *sendfs,
|
||||
nvlist_t *stream_nv, avl_tree_t *stream_avl, char **top_zfs, int cleanup_fd,
|
||||
uint64_t *action_handlep)
|
||||
uint64_t *action_handlep, const char *finalsnap)
|
||||
{
|
||||
int err;
|
||||
dmu_replay_record_t drr, drr_noswap;
|
||||
@ -3594,10 +3618,11 @@ zfs_receive_impl(libzfs_handle_t *hdl, const char *tosnap,
|
||||
if ((cp = strchr(nonpackage_sendfs, '@')) != NULL)
|
||||
*cp = '\0';
|
||||
sendfs = nonpackage_sendfs;
|
||||
VERIFY(finalsnap == NULL);
|
||||
}
|
||||
return (zfs_receive_one(hdl, infd, tosnap, originsnap, flags,
|
||||
&drr, &drr_noswap, sendfs, stream_nv, stream_avl, top_zfs,
|
||||
cleanup_fd, action_handlep));
|
||||
cleanup_fd, action_handlep, finalsnap));
|
||||
} else {
|
||||
assert(DMU_GET_STREAM_HDRTYPE(drrb->drr_versioninfo) ==
|
||||
DMU_COMPOUNDSTREAM);
|
||||
@ -3632,7 +3657,7 @@ zfs_receive(libzfs_handle_t *hdl, const char *tosnap, nvlist_t *props,
|
||||
VERIFY(cleanup_fd >= 0);
|
||||
|
||||
err = zfs_receive_impl(hdl, tosnap, originsnap, flags, infd, NULL, NULL,
|
||||
stream_avl, &top_zfs, cleanup_fd, &action_handle);
|
||||
stream_avl, &top_zfs, cleanup_fd, &action_handle, NULL);
|
||||
|
||||
VERIFY(0 == close(cleanup_fd));
|
||||
|
||||
|
@ -45,10 +45,10 @@ struct tcp_index {
|
||||
};
|
||||
|
||||
static uint64_t tcp_tick;
|
||||
static uint64_t tcp_stats_tick;
|
||||
static struct tcpstat tcpstat;
|
||||
static struct xinpgen *xinpgen;
|
||||
static size_t xinpgen_len;
|
||||
static u_int tcp_count;
|
||||
static u_int tcp_total;
|
||||
|
||||
static u_int oidnum;
|
||||
@ -64,13 +64,9 @@ tcp_compare(const void *p1, const void *p2)
|
||||
}
|
||||
|
||||
static int
|
||||
fetch_tcp(void)
|
||||
fetch_tcp_stats(void)
|
||||
{
|
||||
size_t len;
|
||||
struct xinpgen *ptr;
|
||||
struct xtcpcb *tp;
|
||||
struct tcp_index *oid;
|
||||
in_addr_t inaddr;
|
||||
|
||||
len = sizeof(tcpstat);
|
||||
if (sysctlbyname("net.inet.tcp.stats", &tcpstat, &len, NULL, 0) == -1) {
|
||||
@ -82,6 +78,20 @@ fetch_tcp(void)
|
||||
return (-1);
|
||||
}
|
||||
|
||||
tcp_stats_tick = get_ticks();
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
static int
|
||||
fetch_tcp(void)
|
||||
{
|
||||
size_t len;
|
||||
struct xinpgen *ptr;
|
||||
struct xtcpcb *tp;
|
||||
struct tcp_index *oid;
|
||||
in_addr_t inaddr;
|
||||
|
||||
len = 0;
|
||||
if (sysctlbyname("net.inet.tcp.pcblist", NULL, &len, NULL, 0) == -1) {
|
||||
syslog(LOG_ERR, "net.inet.tcp.pcblist: %m");
|
||||
@ -102,7 +112,6 @@ fetch_tcp(void)
|
||||
|
||||
tcp_tick = get_ticks();
|
||||
|
||||
tcp_count = 0;
|
||||
tcp_total = 0;
|
||||
for (ptr = (struct xinpgen *)(void *)((char *)xinpgen + xinpgen->xig_len);
|
||||
ptr->xig_len > sizeof(struct xinpgen);
|
||||
@ -114,10 +123,6 @@ fetch_tcp(void)
|
||||
|
||||
if (tp->xt_inp.inp_vflag & INP_IPV4)
|
||||
tcp_total++;
|
||||
|
||||
if (tp->xt_tp.t_state == TCPS_ESTABLISHED ||
|
||||
tp->xt_tp.t_state == TCPS_CLOSE_WAIT)
|
||||
tcp_count++;
|
||||
}
|
||||
|
||||
if (oidnum < tcp_total) {
|
||||
@ -184,8 +189,8 @@ op_tcp(struct snmp_context *ctx __unused, struct snmp_value *value,
|
||||
abort();
|
||||
}
|
||||
|
||||
if (tcp_tick < this_tick)
|
||||
if (fetch_tcp() == -1)
|
||||
if (tcp_stats_tick < this_tick)
|
||||
if (fetch_tcp_stats() == -1)
|
||||
return (SNMP_ERR_GENERR);
|
||||
|
||||
switch (value->var.subs[sub - 1]) {
|
||||
@ -226,7 +231,8 @@ op_tcp(struct snmp_context *ctx __unused, struct snmp_value *value,
|
||||
break;
|
||||
|
||||
case LEAF_tcpCurrEstab:
|
||||
value->v.uint32 = tcp_count;
|
||||
value->v.uint32 = tcpstat.tcps_states[TCPS_ESTABLISHED] +
|
||||
tcpstat.tcps_states[TCPS_CLOSE_WAIT];
|
||||
break;
|
||||
|
||||
case LEAF_tcpInSegs:
|
||||
|
@ -206,7 +206,8 @@ ATF_TC_BODY(mincore_resid, tc)
|
||||
"might be low on memory");
|
||||
|
||||
#ifdef __FreeBSD__
|
||||
ATF_REQUIRE(mlock(addr, npgs * page) == 0);
|
||||
ATF_REQUIRE_MSG(mlock(addr, npgs * page) == 0, "mlock failed: %s",
|
||||
strerror(errno));
|
||||
#endif
|
||||
ATF_REQUIRE(check_residency(addr, npgs) == npgs);
|
||||
ATF_REQUIRE(munmap(addr, npgs * page) == 0);
|
||||
|
@ -47,12 +47,89 @@ __RCSID("$NetBSD: t_mlock.c,v 1.5 2014/02/26 20:49:26 martin Exp $");
|
||||
#include <unistd.h>
|
||||
|
||||
#ifdef __FreeBSD__
|
||||
#include <limits.h>
|
||||
#define _KMEMUSER
|
||||
#include <machine/vmparam.h>
|
||||
#endif
|
||||
|
||||
static long page = 0;
|
||||
|
||||
#ifdef __FreeBSD__
|
||||
#define VM_MAX_WIRED "vm.max_wired"
|
||||
|
||||
static void
|
||||
vm_max_wired_sysctl(int *old_value, int *new_value)
|
||||
{
|
||||
size_t old_len;
|
||||
size_t new_len = (new_value == NULL ? 0 : sizeof(int));
|
||||
|
||||
if (old_value == NULL)
|
||||
printf("Setting the new value to %d\n", *new_value);
|
||||
else {
|
||||
ATF_REQUIRE_MSG(sysctlbyname(VM_MAX_WIRED, NULL, &old_len,
|
||||
new_value, new_len) == 0,
|
||||
"sysctlbyname(%s) failed: %s", VM_MAX_WIRED, strerror(errno));
|
||||
}
|
||||
|
||||
ATF_REQUIRE_MSG(sysctlbyname(VM_MAX_WIRED, old_value, &old_len,
|
||||
new_value, new_len) == 0,
|
||||
"sysctlbyname(%s) failed: %s", VM_MAX_WIRED, strerror(errno));
|
||||
|
||||
if (old_value != NULL)
|
||||
printf("Saved the old value (%d)\n", *old_value);
|
||||
}
|
||||
|
||||
static void
|
||||
set_vm_max_wired(int new_value)
|
||||
{
|
||||
FILE *fp;
|
||||
int old_value;
|
||||
|
||||
fp = fopen(VM_MAX_WIRED, "w");
|
||||
if (fp == NULL) {
|
||||
atf_tc_skip("could not open %s for writing: %s",
|
||||
VM_MAX_WIRED, strerror(errno));
|
||||
return;
|
||||
}
|
||||
|
||||
vm_max_wired_sysctl(&old_value, NULL);
|
||||
|
||||
ATF_REQUIRE_MSG(fprintf(fp, "%d", old_value) > 0,
|
||||
"saving %s failed", VM_MAX_WIRED);
|
||||
|
||||
fclose(fp);
|
||||
|
||||
vm_max_wired_sysctl(NULL, &new_value);
|
||||
}
|
||||
|
||||
static void
|
||||
restore_vm_max_wired(void)
|
||||
{
|
||||
FILE *fp;
|
||||
int saved_max_wired;
|
||||
|
||||
fp = fopen(VM_MAX_WIRED, "r");
|
||||
if (fp == NULL) {
|
||||
perror("fopen failed\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if (fscanf(fp, "%d", &saved_max_wired) != 1) {
|
||||
perror("fscanf failed\n");
|
||||
fclose(fp);
|
||||
return;
|
||||
}
|
||||
|
||||
fclose(fp);
|
||||
printf("old value in %s: %d\n", VM_MAX_WIRED, saved_max_wired);
|
||||
|
||||
if (saved_max_wired == 0) /* This will cripple the test host */
|
||||
return;
|
||||
|
||||
vm_max_wired_sysctl(NULL, &saved_max_wired);
|
||||
}
|
||||
#endif
|
||||
|
||||
ATF_TC(mlock_clip);
|
||||
ATF_TC_HEAD(mlock_clip, tc)
|
||||
{
|
||||
@ -78,11 +155,19 @@ ATF_TC_BODY(mlock_clip, tc)
|
||||
free(buf);
|
||||
}
|
||||
|
||||
#ifdef __FreeBSD__
|
||||
ATF_TC_WITH_CLEANUP(mlock_err);
|
||||
#else
|
||||
ATF_TC(mlock_err);
|
||||
#endif
|
||||
ATF_TC_HEAD(mlock_err, tc)
|
||||
{
|
||||
atf_tc_set_md_var(tc, "descr",
|
||||
"Test error conditions in mlock(2) and munlock(2)");
|
||||
#ifdef __FreeBSD__
|
||||
atf_tc_set_md_var(tc, "require.config", "allow_sysctl_side_effects");
|
||||
atf_tc_set_md_var(tc, "require.user", "root");
|
||||
#endif
|
||||
}
|
||||
|
||||
ATF_TC_BODY(mlock_err, tc)
|
||||
@ -99,6 +184,8 @@ ATF_TC_BODY(mlock_err, tc)
|
||||
if ((uintptr_t)VM_MIN_ADDRESS > 0)
|
||||
null_errno = EINVAL; /* NULL is not inside user VM */
|
||||
#endif
|
||||
/* Set max_wired really really high to avoid EAGAIN */
|
||||
set_vm_max_wired(INT_MAX);
|
||||
#else
|
||||
if (sysctlbyname("vm.minaddress", &vmin, &len, NULL, 0) != 0)
|
||||
atf_tc_fail("failed to read vm.minaddress");
|
||||
@ -139,6 +226,14 @@ ATF_TC_BODY(mlock_err, tc)
|
||||
ATF_REQUIRE_ERRNO(ENOMEM, munlock(invalid_ptr, page) == -1);
|
||||
}
|
||||
|
||||
#ifdef __FreeBSD__
|
||||
ATF_TC_CLEANUP(mlock_err, tc)
|
||||
{
|
||||
|
||||
restore_vm_max_wired();
|
||||
}
|
||||
#endif
|
||||
|
||||
ATF_TC(mlock_limits);
|
||||
ATF_TC_HEAD(mlock_limits, tc)
|
||||
{
|
||||
@ -200,10 +295,18 @@ ATF_TC_BODY(mlock_limits, tc)
|
||||
free(buf);
|
||||
}
|
||||
|
||||
#ifdef __FreeBSD__
|
||||
ATF_TC_WITH_CLEANUP(mlock_mmap);
|
||||
#else
|
||||
ATF_TC(mlock_mmap);
|
||||
#endif
|
||||
ATF_TC_HEAD(mlock_mmap, tc)
|
||||
{
|
||||
atf_tc_set_md_var(tc, "descr", "Test mlock(2)-mmap(2) interaction");
|
||||
#ifdef __FreeBSD__
|
||||
atf_tc_set_md_var(tc, "require.config", "allow_sysctl_side_effects");
|
||||
atf_tc_set_md_var(tc, "require.user", "root");
|
||||
#endif
|
||||
}
|
||||
|
||||
ATF_TC_BODY(mlock_mmap, tc)
|
||||
@ -215,6 +318,11 @@ ATF_TC_BODY(mlock_mmap, tc)
|
||||
#endif
|
||||
void *buf;
|
||||
|
||||
#ifdef __FreeBSD__
|
||||
/* Set max_wired really really high to avoid EAGAIN */
|
||||
set_vm_max_wired(INT_MAX);
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Make a wired RW mapping and check that mlock(2)
|
||||
* does not fail for the (already locked) mapping.
|
||||
@ -248,11 +356,27 @@ ATF_TC_BODY(mlock_mmap, tc)
|
||||
ATF_REQUIRE(munmap(buf, page) == 0);
|
||||
}
|
||||
|
||||
#ifdef __FreeBSD__
|
||||
ATF_TC_CLEANUP(mlock_mmap, tc)
|
||||
{
|
||||
|
||||
restore_vm_max_wired();
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef __FreeBSD__
|
||||
ATF_TC_WITH_CLEANUP(mlock_nested);
|
||||
#else
|
||||
ATF_TC(mlock_nested);
|
||||
#endif
|
||||
ATF_TC_HEAD(mlock_nested, tc)
|
||||
{
|
||||
atf_tc_set_md_var(tc, "descr",
|
||||
"Test that consecutive mlock(2) calls succeed");
|
||||
#ifdef __FreeBSD__
|
||||
atf_tc_set_md_var(tc, "require.config", "allow_sysctl_side_effects");
|
||||
atf_tc_set_md_var(tc, "require.user", "root");
|
||||
#endif
|
||||
}
|
||||
|
||||
ATF_TC_BODY(mlock_nested, tc)
|
||||
@ -260,6 +384,11 @@ ATF_TC_BODY(mlock_nested, tc)
|
||||
const size_t maxiter = 100;
|
||||
void *buf;
|
||||
|
||||
#ifdef __FreeBSD__
|
||||
/* Set max_wired really really high to avoid EAGAIN */
|
||||
set_vm_max_wired(INT_MAX);
|
||||
#endif
|
||||
|
||||
buf = malloc(page);
|
||||
ATF_REQUIRE(buf != NULL);
|
||||
|
||||
@ -270,6 +399,14 @@ ATF_TC_BODY(mlock_nested, tc)
|
||||
free(buf);
|
||||
}
|
||||
|
||||
#ifdef __FreeBSD__
|
||||
ATF_TC_CLEANUP(mlock_nested, tc)
|
||||
{
|
||||
|
||||
restore_vm_max_wired();
|
||||
}
|
||||
#endif
|
||||
|
||||
ATF_TP_ADD_TCS(tp)
|
||||
{
|
||||
|
||||
|
@ -5,7 +5,8 @@
|
||||
PROG= rping
|
||||
MAN=
|
||||
SRCS= rping.c
|
||||
LDADD+= -libverbs -lrdmacm -lpthread
|
||||
LDADD+= -lmlx4
|
||||
LIBADD+= ibverbs rdmacm pthread
|
||||
LIBADD+= mlx4
|
||||
LIBADD+= cxgb4
|
||||
|
||||
.include <bsd.prog.mk>
|
||||
|
@ -117,6 +117,7 @@
|
||||
- PasswordAuthentication defaults to "no".
|
||||
- VersionAddendum defaults to "FreeBSD-YYYYMMDD".
|
||||
- PrivilegeSeparation defaults to "sandbox".
|
||||
- UseDNS defaults to "yes".
|
||||
|
||||
2) Modified client-side defaults
|
||||
|
||||
|
@ -320,7 +320,7 @@ fill_default_server_options(ServerOptions *options)
|
||||
if (options->max_sessions == -1)
|
||||
options->max_sessions = DEFAULT_SESSIONS_MAX;
|
||||
if (options->use_dns == -1)
|
||||
options->use_dns = 0;
|
||||
options->use_dns = 1;
|
||||
if (options->client_alive_interval == -1)
|
||||
options->client_alive_interval = 0;
|
||||
if (options->client_alive_count_max == -1)
|
||||
|
@ -115,7 +115,7 @@
|
||||
#Compression delayed
|
||||
#ClientAliveInterval 0
|
||||
#ClientAliveCountMax 3
|
||||
#UseDNS no
|
||||
#UseDNS yes
|
||||
#PidFile /var/run/sshd.pid
|
||||
#MaxStartups 10:30:100
|
||||
#PermitTunnel no
|
||||
|
@ -1541,8 +1541,8 @@ the resolved host name for the remote IP address maps back to the
|
||||
very same IP address.
|
||||
.Pp
|
||||
If this option is set to
|
||||
.Dq no
|
||||
(the default) then only addresses and not host names may be used in
|
||||
.Dq no ,
|
||||
then only addresses and not host names may be used in
|
||||
.Pa ~/.ssh/known_hosts
|
||||
.Cm from
|
||||
and
|
||||
@ -1550,6 +1550,8 @@ and
|
||||
.Cm Match
|
||||
.Cm Host
|
||||
directives.
|
||||
The default is
|
||||
.Dq yes .
|
||||
.It Cm UseLogin
|
||||
Specifies whether
|
||||
.Xr login 1
|
||||
|
@ -134,6 +134,11 @@ daily_status_mail_rejects_enable="YES" # Check mail rejects
|
||||
daily_status_mail_rejects_logs=3 # How many logs to check
|
||||
daily_status_mail_rejects_shorten="NO" # Shorten output
|
||||
|
||||
# 480.leapfile-ntpd
|
||||
daily_ntpd_leapfile_enable="NO" # Fetch NTP leapfile
|
||||
daily_ntpd_avoid_congestion="YES" # Avoid congesting
|
||||
# leapfile sources
|
||||
|
||||
# 480.status-ntpd
|
||||
daily_status_ntpd_enable="NO" # Check NTP status
|
||||
|
||||
|
@ -362,6 +362,17 @@ ntpd_config="/etc/ntp.conf" # ntpd(8) configuration file
|
||||
ntpd_sync_on_start="NO" # Sync time on ntpd startup, even if offset is high
|
||||
ntpd_flags="-p /var/run/ntpd.pid -f /var/db/ntpd.drift"
|
||||
# Flags to ntpd (if enabled).
|
||||
ntp_src_leapfile="/etc/ntp/leap-seconds"
|
||||
# Initial source for ntpd leapfile
|
||||
ntp_db_leapfile="/var/db/ntpd.leap-seconds.list"
|
||||
# Working copy (updated weekly) leapfile
|
||||
ntp_leapfile_sources="https://www.ietf.org/timezones/data/leap-seconds.list"
|
||||
# Source from which to fetch leapfile
|
||||
ntp_leapfile_fetch_opts="-mq" # Options to use for ntp leapfile fetch,
|
||||
# e.g. --no-verify-peer
|
||||
ntp_leapfile_expiry_days=30 # Check for new leapfile 30 days prior to
|
||||
# expiry.
|
||||
ntp_leapfile_fetch_verbose="NO" # Be verbose during NTP leapfile fetch
|
||||
|
||||
# Network Information Services (NIS) options: All need rpcbind_enable="YES" ###
|
||||
nis_client_enable="NO" # We're an NIS client (or NO).
|
||||
|
@ -29,6 +29,7 @@ dialer:*:68:
|
||||
network:*:69:
|
||||
audit:*:77:
|
||||
www:*:80:
|
||||
_ypldap:*:160:
|
||||
hast:*:845:
|
||||
nogroup:*:65533:
|
||||
nobody:*:65534:
|
||||
|
@ -22,6 +22,6 @@ uucp:*:66:66::0:0:UUCP pseudo-user:/var/spool/uucppublic:/usr/local/libexec/uucp
|
||||
pop:*:68:6::0:0:Post Office Owner:/nonexistent:/usr/sbin/nologin
|
||||
auditdistd:*:78:77::0:0:Auditdistd unprivileged user:/var/empty:/usr/sbin/nologin
|
||||
www:*:80:80::0:0:World Wide Web Owner:/nonexistent:/usr/sbin/nologin
|
||||
_ypldap:*:93:93::0:0:YP Ldap unprivileged user:/var/empty:/usr/sbin/nologin
|
||||
_ypldap:*:160:160::0:0:YP Ldap unprivileged user:/var/empty:/usr/sbin/nologin
|
||||
hast:*:845:845::0:0:HAST unprivileged user:/var/empty:/usr/sbin/nologin
|
||||
nobody:*:65534:65534::0:0:Unprivileged user:/nonexistent:/usr/sbin/nologin
|
||||
|
@ -81,4 +81,6 @@ restrict 127.127.1.0
|
||||
# See http://support.ntp.org/bin/view/Support/ConfiguringNTP#Section_6.14.
|
||||
# for documentation regarding leapfile. Updates to the file can be obtained
|
||||
# from ftp://time.nist.gov/pub/ or ftp://tycho.usno.navy.mil/pub/ntp/.
|
||||
leapfile "/etc/ntp/leap-seconds"
|
||||
# Use either leapfile in /etc/ntp or weekly updated leapfile in /var/db.
|
||||
#leapfile "/etc/ntp/leap-seconds"
|
||||
leapfile "/var/db/ntpd.leap-seconds.list"
|
||||
|
28
etc/periodic/daily/480.leapfile-ntpd
Executable file
28
etc/periodic/daily/480.leapfile-ntpd
Executable file
@ -0,0 +1,28 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# $FreeBSD$
|
||||
#
|
||||
|
||||
# If there is a global system configuration file, suck it in.
|
||||
#
|
||||
if [ -r /etc/defaults/periodic.conf ]
|
||||
then
|
||||
. /etc/defaults/periodic.conf
|
||||
source_periodic_confs
|
||||
fi
|
||||
|
||||
case "$daily_ntpd_leapfile_enable" in
|
||||
[Yy][Ee][Ss])
|
||||
case "$daily_ntpd_avoid_congestion" in
|
||||
[Yy][Ee][Ss])
|
||||
# Avoid dogpiling
|
||||
(sleep $(jot -r 1 0 86400); service ntpd fetch) &
|
||||
;;
|
||||
*)
|
||||
service ntpd fetch
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
|
||||
exit $rc
|
@ -35,7 +35,8 @@ FILES+= 130.clean-msgs
|
||||
.endif
|
||||
|
||||
.if ${MK_NTP} != "no"
|
||||
FILES+= 480.status-ntpd
|
||||
FILES+= 480.status-ntpd \
|
||||
480.leapfile-ntpd
|
||||
.endif
|
||||
|
||||
.if ${MK_RCMDS} != "no"
|
||||
|
@ -32,7 +32,7 @@ need_dad_wait=
|
||||
# Extract value from ${jail_$jv_$name} or ${jail_$name} and
|
||||
# set it to $param. If not defined, $defval is used.
|
||||
# When $num is [0-9]*, ${jail_$jv_$name$num} are looked up and
|
||||
# $param is set by using +=.
|
||||
# $param is set by using +=. $num=0 is optional (params may start at 1).
|
||||
# When $num is YN or NY, the value is interpret as boolean.
|
||||
extract_var()
|
||||
{
|
||||
@ -72,7 +72,7 @@ extract_var()
|
||||
eval _tmpargs=\"\${$_name1:-\${$_name2:-$_def}}\"
|
||||
if [ -n "$_tmpargs" ]; then
|
||||
echo " $_param += \"$_tmpargs\";"
|
||||
else
|
||||
elif [ $i != 0 ]; then
|
||||
break;
|
||||
fi
|
||||
i=$(($i + 1))
|
||||
@ -202,7 +202,7 @@ parse_options()
|
||||
extract_var $_jv exec_poststop exec.poststop 0 ""
|
||||
|
||||
echo " exec.start += \"$_exec_start\";"
|
||||
extract_var $_jv exec_afterstart exec.start 1 ""
|
||||
extract_var $_jv exec_afterstart exec.start 0 ""
|
||||
echo " exec.stop = \"$_exec_stop\";"
|
||||
|
||||
extract_var $_jv consolelog exec.consolelog - \
|
||||
|
@ -14,6 +14,8 @@ name="ntpd"
|
||||
rcvar="ntpd_enable"
|
||||
command="/usr/sbin/${name}"
|
||||
pidfile="/var/run/${name}.pid"
|
||||
extra_commands="fetch"
|
||||
fetch_cmd="ntpd_fetch_leapfile"
|
||||
start_precmd="ntpd_precmd"
|
||||
|
||||
load_rc_config $name
|
||||
@ -30,6 +32,10 @@ ntpd_precmd()
|
||||
return 0;
|
||||
fi
|
||||
|
||||
if [ ! -f $ntp_db_leapfile ]; then
|
||||
ntpd_fetch_leapfile
|
||||
fi
|
||||
|
||||
# If running in a chroot cage, ensure that the appropriate files
|
||||
# exist inside the cage, as well as helper symlinks into the cage
|
||||
# from outside.
|
||||
@ -44,10 +50,71 @@ ntpd_precmd()
|
||||
( cd /dev ; /bin/pax -rw -pe clockctl "${ntpd_chrootdir}/dev" )
|
||||
fi
|
||||
ln -fs "${ntpd_chrootdir}/var/db/ntp.drift" /var/db/ntp.drift
|
||||
ln -fs "${ntpd_chrootdir}${ntp_tmp_leapfile}" ${ntp_tmp_leapfile}
|
||||
|
||||
# Change run_rc_commands()'s internal copy of $ntpd_flags
|
||||
#
|
||||
rc_flags="-u ntpd:ntpd -i ${ntpd_chrootdir} $rc_flags"
|
||||
}
|
||||
|
||||
current_ntp_ts() {
|
||||
# Seconds between 1900-01-01 and 1970-01-01
|
||||
# echo $(((70*365+17)*86400))
|
||||
ntp_to_unix=2208988800
|
||||
|
||||
echo $(($(date -u +%s)+$ntp_to_unix))
|
||||
}
|
||||
|
||||
get_ntp_leapfile_ver() {
|
||||
expr "$(awk '$1 == "#$" { print $2 }' "$1" 2>/dev/null)" : \
|
||||
'^\([1-9][0-9]*\)$' \| 0
|
||||
}
|
||||
|
||||
get_ntp_leapfile_expiry() {
|
||||
expr "$(awk '$1 == "#@" { print $2 }' "$1" 2>/dev/null)" : \
|
||||
'^\([1-9][0-9]*\)$' \| 0
|
||||
}
|
||||
|
||||
ntpd_fetch_leapfile() {
|
||||
local ntp_tmp_leapfile rc verbose
|
||||
|
||||
if checkyesno ntp_leapfile_fetch_verbose; then
|
||||
verbose=echo
|
||||
else
|
||||
verbose=:
|
||||
fi
|
||||
|
||||
ntp_tmp_leapfile="/var/run/ntpd.leap-seconds.list"
|
||||
|
||||
ntp_ver_no_src=$(get_ntp_leapfile_ver $ntp_src_leapfile)
|
||||
ntp_ver_no_db=$(get_ntp_leapfile_ver $ntp_db_leapfile)
|
||||
$verbose ntp_src_leapfile version is $ntp_ver_no_src
|
||||
$verbose ntp_db_leapfile version is $ntp_ver_no_db
|
||||
|
||||
if [ "$ntp_ver_no_src" -gt "$ntp_ver_no_db" ]; then
|
||||
$verbose replacing $ntp_db_leapfile with $ntp_src_leapfile
|
||||
cp -p $ntp_src_leapfile $ntp_db_leapfile
|
||||
ntp_ver_no_db=$ntp_ver_no_src
|
||||
else
|
||||
$verbose not replacing $ntp_db_leapfile with $ntp_src_leapfile
|
||||
fi
|
||||
ntp_leap_expiry=$(get_ntp_leapfile_expiry $ntp_db_leapfile)
|
||||
ntp_leapfile_expiry_seconds=$((ntp_leapfile_expiry_days*86400))
|
||||
ntp_leap_fetch_date=$((ntp_leap_expiry-ntp_leapfile_expiry_seconds))
|
||||
if [ $(current_ntp_ts) -ge $ntp_leap_fetch_date ]; then
|
||||
$verbose Within ntp leapfile expiry limit, initiating fetch
|
||||
for url in $ntp_leapfile_sources ; do
|
||||
$verbose fetching $url
|
||||
fetch $ntp_leapfile_fetch_opts -o $ntp_tmp_leapfile $url && break
|
||||
done
|
||||
ntp_ver_no_tmp=$(get_ntp_leapfile_ver $ntp_tmp_leapfile)
|
||||
if [ "$ntp_ver_no_tmp" -gt "$ntp_ver_no_db" ]; then
|
||||
$verbose using $url as $ntp_db_leapfile
|
||||
mv $ntp_tmp_leapfile $ntp_db_leapfile
|
||||
else
|
||||
$verbose using existing $ntp_db_leapfile
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
run_rc_command "$1"
|
||||
|
@ -58,8 +58,10 @@ LIB2FUNCS+= _fixuns${mode}si
|
||||
.endfor
|
||||
|
||||
# Likewise double-word routines.
|
||||
.if ${TARGET_CPUARCH} != "aarch64" && ${TARGET_CPUARCH} != "arm"
|
||||
# These are implemented in an ARM specific file but will not be filtered out
|
||||
.if ${TARGET_CPUARCH} != "aarch64" && ${TARGET_CPUARCH} != "arm" && \
|
||||
${TARGET_CPUARCH} != "riscv64"
|
||||
# These are implemented in an ARM specific file but will not be filtered out.
|
||||
# RISCVTODO: can't compile
|
||||
.for mode in sf df xf tf
|
||||
LIB2FUNCS+= _fix${mode}di _fixuns${mode}di
|
||||
LIB2FUNCS+= _floatdi${mode} _floatundi${mode}
|
||||
@ -322,7 +324,10 @@ EH_OBJS_T = ${LIB2ADDEHSTATIC:R:S/$/.o/}
|
||||
EH_OBJS_P = ${LIB2ADDEHSTATIC:R:S/$/.po/}
|
||||
EH_OBJS_S = ${LIB2ADDEHSHARED:R:S/$/.So/}
|
||||
EH_CFLAGS = -fexceptions -D__GLIBC__=3 -DElfW=__ElfN
|
||||
.if ${TARGET_CPUARCH} != "riscv64"
|
||||
# RISCVTODO: unwinding support
|
||||
SOBJS += ${EH_OBJS_S}
|
||||
.endif
|
||||
|
||||
.for _src in ${LIB2ADDEHSTATIC:M*.c}
|
||||
${_src:R:S/$/.o/}: ${_src} ${COMMONHDRS}
|
||||
|
@ -169,15 +169,15 @@ SUBDIR+= tests
|
||||
.if !defined(_SKIP_BUILD)
|
||||
# We need libutil.h, get it directly to avoid
|
||||
# recording a build dependency
|
||||
CFLAGS+= -I${.CURDIR:H}/libutil
|
||||
CFLAGS+= -I${SRCTOP}/lib/libutil
|
||||
# Same issue with libm
|
||||
MSUN_ARCH_SUBDIR != ${MAKE} -B -C ${.CURDIR:H}/msun -V ARCH_SUBDIR
|
||||
MSUN_ARCH_SUBDIR != ${MAKE} -B -C ${SRCTOP}/lib/msun -V ARCH_SUBDIR
|
||||
# unfortunately msun/src contains both private and public headers
|
||||
CFLAGS+= -I${.CURDIR:H}/msun/${MSUN_ARCH_SUBDIR}
|
||||
CFLAGS+= -I${SRCTOP}/lib/msun/${MSUN_ARCH_SUBDIR}
|
||||
.if ${MACHINE_CPUARCH} == "i386" || ${MACHINE_CPUARCH} == "amd64"
|
||||
CFLAGS+= -I${.CURDIR:H}/msun/x86
|
||||
CFLAGS+= -I${SRCTOP}/lib/msun/x86
|
||||
.endif
|
||||
CFLAGS+= -I${.CURDIR:H}/msun/src
|
||||
CFLAGS+= -I${SRCTOP}/lib/msun/src
|
||||
# and we do not want to record a dependency on msun
|
||||
.if ${.MAKE.LEVEL} > 0
|
||||
GENDIRDEPS_FILTER+= N${RELDIR:H}/msun
|
||||
|
@ -12,7 +12,7 @@ SRCS+= base64.c ether_addr.c eui64.c \
|
||||
getproto.c getprotoent.c getprotoname.c getservent.c \
|
||||
if_indextoname.c if_nameindex.c if_nametoindex.c \
|
||||
ip6opt.c linkaddr.c map_v4v6.c name6.c ntoh.c \
|
||||
nsdispatch.c nslexer.c nsparser.y nss_compat.c \
|
||||
nsdispatch.c nslexer.l nsparser.y nss_compat.c \
|
||||
rcmd.c rcmdsh.c recv.c rthdr.c sctp_sys_calls.c send.c \
|
||||
sockatmark.c sourcefilter.c vars.c
|
||||
|
||||
@ -34,13 +34,8 @@ CFLAGS+=-I${LIBC_SRCTOP}/resolv
|
||||
YFLAGS+=-p_nsyy
|
||||
LFLAGS+=-P_nsyy
|
||||
|
||||
CLEANFILES+=nslexer.c nslexer.c.*
|
||||
|
||||
nslexer.c: nslexer.l nsparser.h
|
||||
${LEX} ${LFLAGS} -o${.TARGET}.tmp1 ${.IMPSRC}
|
||||
sed -e '/YY_BUF_SIZE/s/16384/1024/' ${.TARGET}.tmp1 >${.TARGET}.tmp2
|
||||
rm -f ${.TARGET}.tmp1
|
||||
mv -f ${.TARGET}.tmp2 ${.TARGET}
|
||||
CFLAGS.nslexer.c= -DYY_BUF_SIZE=1024
|
||||
CFLAGS+= ${CFLAGS.${.IMPSRC:T}}
|
||||
|
||||
MAN+= byteorder.3 ethers.3 eui64.3 \
|
||||
getaddrinfo.3 gai_strerror.3 gethostbyname.3 \
|
||||
|
@ -31,7 +31,7 @@
|
||||
.\" @(#)revoke.2 8.1 (Berkeley) 6/4/93
|
||||
.\" $FreeBSD$
|
||||
.\"
|
||||
.Dd June 4, 1993
|
||||
.Dd Jan 25, 2016
|
||||
.Dt REVOKE 2
|
||||
.Os
|
||||
.Sh NAME
|
||||
@ -59,7 +59,8 @@ and a
|
||||
system call will succeed.
|
||||
If the file is a special file for a device which is open,
|
||||
the device close function
|
||||
is called as if all open references to the file had been closed.
|
||||
is called as if all open references to the file had been closed
|
||||
using a special close method which does not block.
|
||||
.Pp
|
||||
Access to a file may be revoked only by its owner or the super user.
|
||||
The
|
||||
@ -104,3 +105,6 @@ The
|
||||
.Fn revoke
|
||||
system call first appeared in
|
||||
.Bx 4.3 Reno .
|
||||
.Sh BUGS
|
||||
The non-blocking close method is only correctly implemented for
|
||||
terminal devices.
|
||||
|
@ -110,8 +110,8 @@ struct devinfo_dev {
|
||||
|
||||
struct devinfo_rman {
|
||||
devinfo_handle_t dm_handle; /* resource manager handle */
|
||||
u_long dm_start; /* resource start */
|
||||
u_long dm_size; /* resource size */
|
||||
rman_res_t dm_start; /* resource start */
|
||||
rman_res_t dm_size; /* resource size */
|
||||
char *dm_desc; /* resource description */
|
||||
};
|
||||
|
||||
@ -119,8 +119,8 @@ struct devinfo_res {
|
||||
devinfo_handle_t dr_handle; /* resource handle */
|
||||
devinfo_handle_t dr_rman; /* resource manager handle */
|
||||
devinfo_handle_t dr_device; /* owning device */
|
||||
u_long dr_start; /* region start */
|
||||
u_long dr_size; /* region size */
|
||||
rman_res_t dr_start; /* region start */
|
||||
rman_res_t dr_size; /* region size */
|
||||
};
|
||||
.Ed
|
||||
.Pp
|
||||
|
@ -56,8 +56,8 @@ struct devinfo_dev {
|
||||
struct devinfo_rman {
|
||||
devinfo_handle_t dm_handle; /* resource manager handle */
|
||||
|
||||
unsigned long dm_start; /* resource start */
|
||||
unsigned long dm_size; /* resource size */
|
||||
rman_res_t dm_start; /* resource start */
|
||||
rman_res_t dm_size; /* resource size */
|
||||
|
||||
char *dm_desc; /* resource description */
|
||||
};
|
||||
@ -67,8 +67,8 @@ struct devinfo_res {
|
||||
devinfo_handle_t dr_rman; /* resource manager handle */
|
||||
devinfo_handle_t dr_device; /* owning device */
|
||||
|
||||
unsigned long dr_start; /* region start */
|
||||
unsigned long dr_size; /* region size */
|
||||
rman_res_t dr_start; /* region start */
|
||||
rman_res_t dr_size; /* region size */
|
||||
/* XXX add flags */
|
||||
};
|
||||
|
||||
|
@ -261,6 +261,13 @@ dialog_spawn_gauge(char *init_prompt, pid_t *pid)
|
||||
errx(EXIT_FAILURE, "Out of memory?!");
|
||||
sprintf(dargv[n++], "--title");
|
||||
dargv[n++] = title;
|
||||
} else {
|
||||
if ((dargv[n] = malloc(8)) == NULL)
|
||||
errx(EXIT_FAILURE, "Out of memory?!");
|
||||
sprintf(dargv[n++], "--title");
|
||||
if ((dargv[n] = malloc(8)) == NULL)
|
||||
errx(EXIT_FAILURE, "Out of memory?!");
|
||||
sprintf(dargv[n++], "");
|
||||
}
|
||||
if (backtitle != NULL) {
|
||||
if ((dargv[n] = malloc(12)) == NULL)
|
||||
|
@ -55,7 +55,6 @@ extern int dheight, dwidth;
|
||||
|
||||
__BEGIN_DECLS
|
||||
uint8_t dialog_prompt_nlstate(const char *_prompt);
|
||||
void dialog_gauge_free(void);
|
||||
void dialog_maxsize_free(void);
|
||||
char *dialog_prompt_lastline(char *_prompt, uint8_t _nlstate);
|
||||
int dialog_maxcols(void);
|
||||
|
@ -1,4 +1,4 @@
|
||||
.\" Copyright (c) 2013-2015 Devin Teske
|
||||
.\" Copyright (c) 2013-2016 Devin Teske
|
||||
.\" All rights reserved.
|
||||
.\"
|
||||
.\" Redistribution and use in source and binary forms, with or without
|
||||
@ -24,7 +24,7 @@
|
||||
.\"
|
||||
.\" $FreeBSD$
|
||||
.\"
|
||||
.Dd Oct 22, 2015
|
||||
.Dd Jan 26, 2016
|
||||
.Dt DPV 3
|
||||
.Os
|
||||
.Sh NAME
|
||||
@ -64,6 +64,7 @@ argument contains the following properties for configuring global display
|
||||
features:
|
||||
.Bd -literal -offset indent
|
||||
struct dpv_config {
|
||||
uint8_t keep_tite; /* Cleaner exit for scripts */
|
||||
enum dpv_display display_type; /* Def. DPV_DISPLAY_LIBDIALOG */
|
||||
enum dpv_output output_type; /* Default DPV_OUTPUT_NONE */
|
||||
int debug; /* Enable debug on stderr */
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*-
|
||||
* Copyright (c) 2013-2014 Devin Teske <dteske@FreeBSD.org>
|
||||
* Copyright (c) 2013-2016 Devin Teske <dteske@FreeBSD.org>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@ -69,6 +69,7 @@ long long dpv_overall_read = 0;
|
||||
static char pathbuf[PATH_MAX];
|
||||
|
||||
/* Extra display information */
|
||||
uint8_t keep_tite = FALSE; /* dpv_config.keep_tite */
|
||||
uint8_t no_labels = FALSE; /* dpv_config.options & DPV_NO_LABELS */
|
||||
uint8_t wide = FALSE; /* dpv_config.options & DPV_WIDE_MODE */
|
||||
char *aprompt = NULL; /* dpv_config.aprompt */
|
||||
@ -150,6 +151,7 @@ dpv(struct dpv_config *config, struct dpv_file_node *file_list)
|
||||
dialog_updates_per_second = DIALOG_UPDATES_PER_SEC;
|
||||
display_limit = DISPLAY_LIMIT_DEFAULT;
|
||||
display_type = DPV_DISPLAY_LIBDIALOG;
|
||||
keep_tite = FALSE;
|
||||
label_size = LABEL_SIZE_DEFAULT;
|
||||
msg_done = NULL;
|
||||
msg_fail = NULL;
|
||||
@ -193,6 +195,7 @@ dpv(struct dpv_config *config, struct dpv_file_node *file_list)
|
||||
dialog_updates_per_second = config->dialog_updates_per_second;
|
||||
display_limit = config->display_limit;
|
||||
display_type = config->display_type;
|
||||
keep_tite = config->keep_tite;
|
||||
label_size = config->label_size;
|
||||
msg_done = (char *)config->msg_done;
|
||||
msg_fail = (char *)config->msg_fail;
|
||||
@ -695,7 +698,7 @@ dpv(struct dpv_config *config, struct dpv_file_node *file_list)
|
||||
close(dialog_out);
|
||||
waitpid(pid, (int *)NULL, 0);
|
||||
}
|
||||
if (!dpv_interrupt)
|
||||
if (!keep_tite && !dpv_interrupt)
|
||||
printf("\n");
|
||||
} else
|
||||
warnx("%s: %lli overall read", __func__, dpv_overall_read);
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*-
|
||||
* Copyright (c) 2013-2014 Devin Teske <dteske@FreeBSD.org>
|
||||
* Copyright (c) 2013-2016 Devin Teske <dteske@FreeBSD.org>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@ -97,6 +97,7 @@ struct dpv_file_node {
|
||||
* Anatomy of config option to pass as dpv() config argument
|
||||
*/
|
||||
struct dpv_config {
|
||||
uint8_t keep_tite; /* Prevent visually distracting exit */
|
||||
enum dpv_display display_type; /* Display (default TYPE_LIBDIALOG) */
|
||||
enum dpv_output output_type; /* Output (default TYPE_NONE) */
|
||||
int debug; /* Enable debugging output on stderr */
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*-
|
||||
* Copyright (c) 2013-2014 Devin Teske <dteske@FreeBSD.org>
|
||||
* Copyright (c) 2013-2016 Devin Teske <dteske@FreeBSD.org>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@ -38,6 +38,7 @@ extern uint8_t debug;
|
||||
extern unsigned int dpv_nfiles;
|
||||
|
||||
/* Extra display information */
|
||||
extern uint8_t keep_tite;
|
||||
extern uint8_t no_labels;
|
||||
extern uint8_t wide;
|
||||
extern char *msg_done, *msg_fail, *msg_pending;
|
||||
|
@ -4,11 +4,14 @@
|
||||
|
||||
LIB= sysdecode
|
||||
|
||||
SRCS= ioctl.c utrace.c
|
||||
SRCS= ioctl.c syscallnames.c utrace.c
|
||||
INCS= sysdecode.h
|
||||
|
||||
CFLAGS+= -I${.CURDIR}/../../sys
|
||||
|
||||
MAN+= sysdecode.3 \
|
||||
sysdecode_ioctlname.3 \
|
||||
sysdecode_syscallnames.3 \
|
||||
sysdecode_utrace.3
|
||||
|
||||
CLEANFILES= ioctl.c
|
||||
@ -23,6 +26,10 @@ CFLAGS+=-DPF
|
||||
|
||||
# Workaround duplicate declarations in <netinet/ip_compat.h>
|
||||
CFLAGS.gcc.ioctl.c+= -Wno-redundant-decls
|
||||
|
||||
# Workaround warning for unused ssi_cables[] in <dev/lmc/if_lmc.h>
|
||||
CFLAGS.gcc.ioctl.c+= -Wno-unused
|
||||
|
||||
CFLAGS.gcc+= ${CFLAGS.gcc.${.IMPSRC}}
|
||||
|
||||
ioctl.c: mkioctls
|
||||
|
105
lib/libsysdecode/syscallnames.c
Normal file
105
lib/libsysdecode/syscallnames.c
Normal file
@ -0,0 +1,105 @@
|
||||
/*-
|
||||
* Copyright (c) 2015 John H. Baldwin <jhb@FreeBSD.org>
|
||||
* 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 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$");
|
||||
|
||||
/*
|
||||
* Map system call codes to names for the supported ABIs on each
|
||||
* platform. Rather than regnerating system call name tables locally
|
||||
* during the build, use the generated tables in the kernel source
|
||||
* tree.
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <stdio.h>
|
||||
#include <sysdecode.h>
|
||||
|
||||
static
|
||||
#include <kern/syscalls.c>
|
||||
|
||||
#if defined(__amd64__) || defined(__powerpc64__)
|
||||
static
|
||||
#include <compat/freebsd32/freebsd32_syscalls.c>
|
||||
#endif
|
||||
|
||||
#if defined(__amd64__) || defined(__i386__)
|
||||
static
|
||||
#ifdef __amd64__
|
||||
#include <amd64/linux/linux_syscalls.c>
|
||||
#else
|
||||
#include <i386/linux/linux_syscalls.c>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef __amd64__
|
||||
static
|
||||
#include <amd64/linux32/linux32_syscalls.c>
|
||||
#endif
|
||||
|
||||
#if defined(__amd64__) || defined(__aarch64__)
|
||||
static
|
||||
#include <compat/cloudabi64/cloudabi64_syscalls.c>
|
||||
#endif
|
||||
|
||||
const char *
|
||||
sysdecode_syscallname(enum sysdecode_abi abi, unsigned int code)
|
||||
{
|
||||
|
||||
switch (abi) {
|
||||
case FREEBSD:
|
||||
if (code < nitems(syscallnames))
|
||||
return (syscallnames[code]);
|
||||
break;
|
||||
#if defined(__amd64__) || defined(__powerpc64__)
|
||||
case FREEBSD32:
|
||||
if (code < nitems(freebsd32_syscallnames))
|
||||
return (freebsd32_syscallnames[code]);
|
||||
break;
|
||||
#endif
|
||||
#if defined(__amd64__) || defined(__i386__)
|
||||
case LINUX:
|
||||
if (code < nitems(linux_syscallnames))
|
||||
return (linux_syscallnames[code]);
|
||||
break;
|
||||
#endif
|
||||
#ifdef __amd64__
|
||||
case LINUX32:
|
||||
if (code < nitems(linux32_syscallnames))
|
||||
return (linux32_syscallnames[code]);
|
||||
break;
|
||||
#endif
|
||||
#if defined(__amd64__) || defined(__aarch64__)
|
||||
case CLOUDABI64:
|
||||
if (code < nitems(cloudabi64_syscallnames))
|
||||
return (cloudabi64_syscallnames[code]);
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return (NULL);
|
||||
}
|
@ -25,7 +25,7 @@
|
||||
.\"
|
||||
.\" $FreeBSD$
|
||||
.\"
|
||||
.Dd December 10, 2015
|
||||
.Dd January 24, 2016
|
||||
.Dt SYSDECODE 3
|
||||
.Os
|
||||
.Sh NAME
|
||||
@ -38,8 +38,34 @@ The
|
||||
.Nm
|
||||
library includes several functions that provide descriptive names of
|
||||
values associated with system calls.
|
||||
.Ss Supported ABIs
|
||||
Some functions in this library provide ABI-specific descriptions.
|
||||
The supported ABIs are named by the
|
||||
.Vt enum sysdecode_abi
|
||||
enumeration.
|
||||
.Pp
|
||||
.Bl -tag -width "Li UNKNOWN_ABI" -compact
|
||||
.It Li FREEBSD
|
||||
Native FreeBSD binaries.
|
||||
Supported on all platforms.
|
||||
.It Li FREEBSD32
|
||||
32-bit FreeBSD binaries.
|
||||
Supported on amd64 and powerpc64.
|
||||
.It Li LINUX
|
||||
Linux binaries of the same platform.
|
||||
Supported on amd64 and i386.
|
||||
.It Li LINUX32
|
||||
32-bit Linux binaries.
|
||||
Supported on amd64.
|
||||
.It Li CLOUDABI64
|
||||
64-bit CloudABI binaries.
|
||||
Supported on aarch64 and amd64.
|
||||
.It Li UNKNOWN_ABI
|
||||
A placeholder for use when the ABI is not known.
|
||||
.El
|
||||
.Sh SEE ALSO
|
||||
.Xr sysdecode_ioctlname 3 ,
|
||||
.Xr sysdecode_syscallnames 3 ,
|
||||
.Xr sysdecode_utrace 3
|
||||
.Sh HISTORY
|
||||
The
|
||||
|
@ -29,7 +29,17 @@
|
||||
#ifndef __SYSDECODE_H__
|
||||
#define __SYSDECODE_H__
|
||||
|
||||
enum sysdecode_abi {
|
||||
UNKNOWN_ABI = 0,
|
||||
FREEBSD,
|
||||
FREEBSD32,
|
||||
LINUX,
|
||||
LINUX32,
|
||||
CLOUDABI64
|
||||
};
|
||||
|
||||
const char *sysdecode_ioctlname(unsigned long _val);
|
||||
const char *sysdecode_syscallname(enum sysdecode_abi _abi, unsigned int _code);
|
||||
int sysdecode_utrace(FILE *_fp, void *_buf, size_t _len);
|
||||
|
||||
#endif /* !__SYSDECODE_H__ */
|
||||
|
67
lib/libsysdecode/sysdecode_syscallnames.3
Normal file
67
lib/libsysdecode/sysdecode_syscallnames.3
Normal file
@ -0,0 +1,67 @@
|
||||
.\"
|
||||
.\" Copyright (c) 2016 John Baldwin <jhb@FreeBSD.org>
|
||||
.\" 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 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.
|
||||
.\"
|
||||
.\" $FreeBSD$
|
||||
.\"
|
||||
.Dd January 24, 2016
|
||||
.Dt sysdecode_syscallnames 3
|
||||
.Os
|
||||
.Sh NAME
|
||||
.Nm sysdecode_syscallnames
|
||||
.Nd lookup name of system calls
|
||||
.Sh LIBRARY
|
||||
.Lb libsysdecode
|
||||
.Sh SYNOPSIS
|
||||
.Ft const char *
|
||||
.Fn sysdecode_syscallnames "enum sysdecode_abi abi" "unsigned int code"
|
||||
.Sh DESCRIPTION
|
||||
This function returns a pointer to the name of a system call identified by
|
||||
.Fa code
|
||||
for the process ABI
|
||||
.Fa abi .
|
||||
If
|
||||
.Fa code
|
||||
specifies an unknown system call or
|
||||
.Fa abi
|
||||
is an unsupported ABI,
|
||||
.Nm
|
||||
returns
|
||||
.Dv NULL .
|
||||
.Pp
|
||||
For the list of supported ABIs,
|
||||
see
|
||||
.Xr sysdecode 3 .
|
||||
.Sh RETURN VALUES
|
||||
The
|
||||
.Nm
|
||||
function returns a pointer to a string on success or
|
||||
.Dv NULL
|
||||
if either
|
||||
.Fa code
|
||||
or
|
||||
.Fa ABI
|
||||
is invalid .
|
||||
.Sh SEE ALSO
|
||||
.Xr sysdecode 3
|
92
lib/libthr/arch/riscv/include/pthread_md.h
Normal file
92
lib/libthr/arch/riscv/include/pthread_md.h
Normal file
@ -0,0 +1,92 @@
|
||||
/*-
|
||||
* Copyright (c) 2005 David Xu <davidxu@freebsd.org>
|
||||
* Copyright (c) 2015 Ruslan Bukin <br@bsdpad.com>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Portions of this software were 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.
|
||||
*
|
||||
* Portions of this software were developed by the University of Cambridge
|
||||
* Computer Laboratory as part of the CTSRD Project, with support from the
|
||||
* UK Higher Education Innovation Fund (HEIF).
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
/*
|
||||
* Machine-dependent thread prototypes/definitions.
|
||||
*/
|
||||
#ifndef _PTHREAD_MD_H_
|
||||
#define _PTHREAD_MD_H_
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#define CPU_SPINWAIT
|
||||
#define DTV_OFFSET offsetof(struct tcb, tcb_dtv)
|
||||
#define TP_OFFSET 0x10
|
||||
|
||||
/*
|
||||
* Variant I tcb. The structure layout is fixed, don't blindly
|
||||
* change it!
|
||||
*/
|
||||
struct tcb {
|
||||
void *tcb_dtv;
|
||||
struct pthread *tcb_thread;
|
||||
};
|
||||
|
||||
/* Called from the thread to set its private data. */
|
||||
static __inline void
|
||||
_tcb_set(struct tcb *tcb)
|
||||
{
|
||||
|
||||
__asm __volatile("mv tp, %0" :: "r"((uint8_t *)tcb + TP_OFFSET));
|
||||
}
|
||||
|
||||
/*
|
||||
* Get the current tcb.
|
||||
*/
|
||||
static __inline struct tcb *
|
||||
_tcb_get(void)
|
||||
{
|
||||
register uint8_t *_tp;
|
||||
|
||||
__asm __volatile("mv %0, tp" : "=r"(_tp));
|
||||
|
||||
return ((struct tcb *)(_tp - TP_OFFSET));
|
||||
}
|
||||
|
||||
extern struct pthread *_thr_initial;
|
||||
|
||||
static __inline struct pthread *
|
||||
_get_curthread(void)
|
||||
{
|
||||
|
||||
if (_thr_initial)
|
||||
return (_tcb_get()->tcb_thread);
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
#endif /* _PTHREAD_MD_H_ */
|
104
lib/libthread_db/arch/riscv/libpthread_md.c
Normal file
104
lib/libthread_db/arch/riscv/libpthread_md.c
Normal file
@ -0,0 +1,104 @@
|
||||
/*-
|
||||
* Copyright (c) 2015 Ruslan Bukin <br@bsdpad.com>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Portions of this software were 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.
|
||||
*
|
||||
* Portions of this software were developed by the University of Cambridge
|
||||
* Computer Laboratory as part of the CTSRD Project, with support from the
|
||||
* UK Higher Education Innovation Fund (HEIF).
|
||||
*
|
||||
* 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/types.h>
|
||||
#include <string.h>
|
||||
#include <thread_db.h>
|
||||
|
||||
#include "libpthread_db.h"
|
||||
|
||||
void
|
||||
pt_reg_to_ucontext(const struct reg *r, ucontext_t *uc)
|
||||
{
|
||||
mcontext_t *mc;
|
||||
|
||||
mc = &uc->uc_mcontext;
|
||||
|
||||
memcpy(mc->mc_gpregs.gp_t, r->t, sizeof(mc->mc_gpregs.gp_t));
|
||||
memcpy(mc->mc_gpregs.gp_s, r->s, sizeof(mc->mc_gpregs.gp_s));
|
||||
memcpy(mc->mc_gpregs.gp_a, r->a, sizeof(mc->mc_gpregs.gp_a));
|
||||
mc->mc_gpregs.gp_ra = r->ra;
|
||||
mc->mc_gpregs.gp_sp = r->sp;
|
||||
mc->mc_gpregs.gp_gp = r->gp;
|
||||
mc->mc_gpregs.gp_tp = r->tp;
|
||||
mc->mc_gpregs.gp_sepc = r->sepc;
|
||||
mc->mc_gpregs.gp_sstatus = r->sstatus;
|
||||
}
|
||||
|
||||
void
|
||||
pt_ucontext_to_reg(const ucontext_t *uc, struct reg *r)
|
||||
{
|
||||
const mcontext_t *mc;
|
||||
|
||||
mc = &uc->uc_mcontext;
|
||||
|
||||
memcpy(r->t, mc->mc_gpregs.gp_t, sizeof(mc->mc_gpregs.gp_t));
|
||||
memcpy(r->s, mc->mc_gpregs.gp_s, sizeof(mc->mc_gpregs.gp_s));
|
||||
memcpy(r->a, mc->mc_gpregs.gp_a, sizeof(mc->mc_gpregs.gp_a));
|
||||
r->ra = mc->mc_gpregs.gp_ra;
|
||||
r->sp = mc->mc_gpregs.gp_sp;
|
||||
r->gp = mc->mc_gpregs.gp_gp;
|
||||
r->tp = mc->mc_gpregs.gp_tp;
|
||||
r->sepc = mc->mc_gpregs.gp_sepc;
|
||||
r->sstatus = mc->mc_gpregs.gp_sstatus;
|
||||
}
|
||||
|
||||
void
|
||||
pt_fpreg_to_ucontext(const struct fpreg *r __unused, ucontext_t *uc __unused)
|
||||
{
|
||||
|
||||
/* RISCVTODO */
|
||||
}
|
||||
|
||||
void
|
||||
pt_ucontext_to_fpreg(const ucontext_t *uc __unused, struct fpreg *r __unused)
|
||||
{
|
||||
|
||||
/* RISCVTODO */
|
||||
}
|
||||
|
||||
void
|
||||
pt_md_init(void)
|
||||
{
|
||||
}
|
||||
|
||||
int
|
||||
pt_reg_sstep(struct reg *reg __unused, int step __unused)
|
||||
{
|
||||
|
||||
return (0);
|
||||
}
|
52
lib/msun/riscv/fenv.c
Normal file
52
lib/msun/riscv/fenv.c
Normal file
@ -0,0 +1,52 @@
|
||||
/*-
|
||||
* Copyright (c) 2004 David Schultz <das@FreeBSD.ORG>
|
||||
* 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 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.
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
#define __fenv_static
|
||||
#include "fenv.h"
|
||||
|
||||
#ifdef __GNUC_GNU_INLINE__
|
||||
#error "This file must be compiled with C99 'inline' semantics"
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Hopefully the system ID byte is immutable, so it's valid to use
|
||||
* this as a default environment.
|
||||
*/
|
||||
const fenv_t __fe_dfl_env = 0;
|
||||
|
||||
extern inline int feclearexcept(int __excepts);
|
||||
extern inline int fegetexceptflag(fexcept_t *__flagp, int __excepts);
|
||||
extern inline int fesetexceptflag(const fexcept_t *__flagp, int __excepts);
|
||||
extern inline int feraiseexcept(int __excepts);
|
||||
extern inline int fetestexcept(int __excepts);
|
||||
extern inline int fegetround(void);
|
||||
extern inline int fesetround(int __round);
|
||||
extern inline int fegetenv(fenv_t *__envp);
|
||||
extern inline int feholdexcept(fenv_t *__envp);
|
||||
extern inline int fesetenv(const fenv_t *__envp);
|
||||
extern inline int feupdateenv(const fenv_t *__envp);
|
254
secure/lib/libcrypto/opensslconf-riscv.h
Normal file
254
secure/lib/libcrypto/opensslconf-riscv.h
Normal file
@ -0,0 +1,254 @@
|
||||
/* $FreeBSD$ */
|
||||
/* opensslconf.h */
|
||||
/* RISCVTODO: generate from opensslconf.h.in by Configure. */
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
/* OpenSSL was configured with the following options: */
|
||||
#ifndef OPENSSL_DOING_MAKEDEPEND
|
||||
|
||||
|
||||
#ifndef OPENSSL_NO_EC_NISTP_64_GCC_128
|
||||
# define OPENSSL_NO_EC_NISTP_64_GCC_128
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_GMP
|
||||
# define OPENSSL_NO_GMP
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_JPAKE
|
||||
# define OPENSSL_NO_JPAKE
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_KRB5
|
||||
# define OPENSSL_NO_KRB5
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_LIBUNBOUND
|
||||
# define OPENSSL_NO_LIBUNBOUND
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_MD2
|
||||
# define OPENSSL_NO_MD2
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_SCTP
|
||||
# define OPENSSL_NO_SCTP
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_SSL_TRACE
|
||||
# define OPENSSL_NO_SSL_TRACE
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_SSL2
|
||||
# define OPENSSL_NO_SSL2
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_STORE
|
||||
# define OPENSSL_NO_STORE
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_UNIT_TEST
|
||||
# define OPENSSL_NO_UNIT_TEST
|
||||
#endif
|
||||
|
||||
#endif /* OPENSSL_DOING_MAKEDEPEND */
|
||||
|
||||
#ifndef OPENSSL_THREADS
|
||||
# define OPENSSL_THREADS
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_ASM
|
||||
# define OPENSSL_NO_ASM
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_STATIC_ENGINE
|
||||
# define OPENSSL_NO_STATIC_ENGINE
|
||||
#endif
|
||||
|
||||
/* The OPENSSL_NO_* macros are also defined as NO_* if the application
|
||||
asks for it. This is a transient feature that is provided for those
|
||||
who haven't had the time to do the appropriate changes in their
|
||||
applications. */
|
||||
#ifdef OPENSSL_ALGORITHM_DEFINES
|
||||
# if defined(OPENSSL_NO_EC_NISTP_64_GCC_128) && !defined(NO_EC_NISTP_64_GCC_128)
|
||||
# define NO_EC_NISTP_64_GCC_128
|
||||
# endif
|
||||
# if defined(OPENSSL_NO_GMP) && !defined(NO_GMP)
|
||||
# define NO_GMP
|
||||
# endif
|
||||
# if defined(OPENSSL_NO_JPAKE) && !defined(NO_JPAKE)
|
||||
# define NO_JPAKE
|
||||
# endif
|
||||
# if defined(OPENSSL_NO_KRB5) && !defined(NO_KRB5)
|
||||
# define NO_KRB5
|
||||
# endif
|
||||
# if defined(OPENSSL_NO_LIBUNBOUND) && !defined(NO_LIBUNBOUND)
|
||||
# define NO_LIBUNBOUND
|
||||
# endif
|
||||
# if defined(OPENSSL_NO_MD2) && !defined(NO_MD2)
|
||||
# define NO_MD2
|
||||
# endif
|
||||
# if defined(OPENSSL_NO_SCTP) && !defined(NO_SCTP)
|
||||
# define NO_SCTP
|
||||
# endif
|
||||
# if defined(OPENSSL_NO_SSL_TRACE) && !defined(NO_SSL_TRACE)
|
||||
# define NO_SSL_TRACE
|
||||
# endif
|
||||
# if defined(OPENSSL_NO_SSL2) && !defined(NO_SSL2)
|
||||
# define NO_SSL2
|
||||
# endif
|
||||
# if defined(OPENSSL_NO_STORE) && !defined(NO_STORE)
|
||||
# define NO_STORE
|
||||
# endif
|
||||
# if defined(OPENSSL_NO_UNIT_TEST) && !defined(NO_UNIT_TEST)
|
||||
# define NO_UNIT_TEST
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* crypto/opensslconf.h.in */
|
||||
|
||||
/* Generate 80386 code? */
|
||||
#undef I386_ONLY
|
||||
|
||||
#if !(defined(VMS) || defined(__VMS)) /* VMS uses logical names instead */
|
||||
#if defined(HEADER_CRYPTLIB_H) && !defined(OPENSSLDIR)
|
||||
#define ENGINESDIR "/usr/lib/engines"
|
||||
#define OPENSSLDIR "/etc/ssl"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#undef OPENSSL_UNISTD
|
||||
#define OPENSSL_UNISTD <unistd.h>
|
||||
|
||||
#undef OPENSSL_EXPORT_VAR_AS_FUNCTION
|
||||
|
||||
#if defined(HEADER_IDEA_H) && !defined(IDEA_INT)
|
||||
#define IDEA_INT unsigned int
|
||||
#endif
|
||||
|
||||
#if defined(HEADER_MD2_H) && !defined(MD2_INT)
|
||||
#define MD2_INT unsigned int
|
||||
#endif
|
||||
|
||||
#if defined(HEADER_RC2_H) && !defined(RC2_INT)
|
||||
/* I need to put in a mod for the alpha - eay */
|
||||
#define RC2_INT unsigned int
|
||||
#endif
|
||||
|
||||
#if defined(HEADER_RC4_H)
|
||||
#if !defined(RC4_INT)
|
||||
/* using int types make the structure larger but make the code faster
|
||||
* on most boxes I have tested - up to %20 faster. */
|
||||
/*
|
||||
* I don't know what does "most" mean, but declaring "int" is a must on:
|
||||
* - Intel P6 because partial register stalls are very expensive;
|
||||
* - elder Alpha because it lacks byte load/store instructions;
|
||||
*/
|
||||
#define RC4_INT unsigned int
|
||||
#endif
|
||||
#if !defined(RC4_CHUNK)
|
||||
/*
|
||||
* This enables code handling data aligned at natural CPU word
|
||||
* boundary. See crypto/rc4/rc4_enc.c for further details.
|
||||
*/
|
||||
#undef RC4_CHUNK
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if (defined(HEADER_NEW_DES_H) || defined(HEADER_DES_H)) && !defined(DES_LONG)
|
||||
/* If this is set to 'unsigned int' on a DEC Alpha, this gives about a
|
||||
* %20 speed up (longs are 8 bytes, int's are 4). */
|
||||
#ifndef DES_LONG
|
||||
#define DES_LONG unsigned int
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(HEADER_BN_H) && !defined(CONFIG_HEADER_BN_H)
|
||||
#define CONFIG_HEADER_BN_H
|
||||
#undef BN_LLONG
|
||||
|
||||
/* Should we define BN_DIV2W here? */
|
||||
|
||||
/* Only one for the following should be defined */
|
||||
#define SIXTY_FOUR_BIT_LONG
|
||||
#undef SIXTY_FOUR_BIT
|
||||
#undef THIRTY_TWO_BIT
|
||||
#endif
|
||||
|
||||
#if defined(HEADER_RC4_LOCL_H) && !defined(CONFIG_HEADER_RC4_LOCL_H)
|
||||
#define CONFIG_HEADER_RC4_LOCL_H
|
||||
/* if this is defined data[i] is used instead of *data, this is a %20
|
||||
* speedup on x86 */
|
||||
#define RC4_INDEX
|
||||
#endif
|
||||
|
||||
#if defined(HEADER_BF_LOCL_H) && !defined(CONFIG_HEADER_BF_LOCL_H)
|
||||
#define CONFIG_HEADER_BF_LOCL_H
|
||||
#undef BF_PTR
|
||||
#endif /* HEADER_BF_LOCL_H */
|
||||
|
||||
#if defined(HEADER_DES_LOCL_H) && !defined(CONFIG_HEADER_DES_LOCL_H)
|
||||
#define CONFIG_HEADER_DES_LOCL_H
|
||||
#ifndef DES_DEFAULT_OPTIONS
|
||||
/* the following is tweaked from a config script, that is why it is a
|
||||
* protected undef/define */
|
||||
#ifndef DES_PTR
|
||||
#define DES_PTR
|
||||
#endif
|
||||
|
||||
/* This helps C compiler generate the correct code for multiple functional
|
||||
* units. It reduces register dependancies at the expense of 2 more
|
||||
* registers */
|
||||
#ifndef DES_RISC1
|
||||
#define DES_RISC1
|
||||
#endif
|
||||
|
||||
#ifndef DES_RISC2
|
||||
#undef DES_RISC2
|
||||
#endif
|
||||
|
||||
#if defined(DES_RISC1) && defined(DES_RISC2)
|
||||
#error YOU SHOULD NOT HAVE BOTH DES_RISC1 AND DES_RISC2 DEFINED!!!!!
|
||||
#endif
|
||||
|
||||
/* Unroll the inner loop, this sometimes helps, sometimes hinders.
|
||||
* Very mucy CPU dependant */
|
||||
#ifndef DES_UNROLL
|
||||
#define DES_UNROLL
|
||||
#endif
|
||||
|
||||
/* These default values were supplied by
|
||||
* Peter Gutman <pgut001@cs.auckland.ac.nz>
|
||||
* They are only used if nothing else has been defined */
|
||||
#if !defined(DES_PTR) && !defined(DES_RISC1) && !defined(DES_RISC2) && !defined(DES_UNROLL)
|
||||
/* Special defines which change the way the code is built depending on the
|
||||
CPU and OS. For SGI machines you can use _MIPS_SZLONG (32 or 64) to find
|
||||
even newer MIPS CPU's, but at the moment one size fits all for
|
||||
optimization options. Older Sparc's work better with only UNROLL, but
|
||||
there's no way to tell at compile time what it is you're running on */
|
||||
|
||||
#if defined( sun ) /* Newer Sparc's */
|
||||
# define DES_PTR
|
||||
# define DES_RISC1
|
||||
# define DES_UNROLL
|
||||
#elif defined( __ultrix ) /* Older MIPS */
|
||||
# define DES_PTR
|
||||
# define DES_RISC2
|
||||
# define DES_UNROLL
|
||||
#elif defined( __osf1__ ) /* Alpha */
|
||||
# define DES_PTR
|
||||
# define DES_RISC2
|
||||
#elif defined ( _AIX ) /* RS6000 */
|
||||
/* Unknown */
|
||||
#elif defined( __hpux ) /* HP-PA */
|
||||
/* Unknown */
|
||||
#elif defined( __aux ) /* 68K */
|
||||
/* Unknown */
|
||||
#elif defined( __dgux ) /* 88K (but P6 in latest boxes) */
|
||||
# define DES_UNROLL
|
||||
#elif defined( __sgi ) /* Newer MIPS */
|
||||
# define DES_PTR
|
||||
# define DES_RISC2
|
||||
# define DES_UNROLL
|
||||
#elif defined(i386) || defined(__i386__) /* x86 boxes, should be gcc */
|
||||
# define DES_PTR
|
||||
# define DES_RISC1
|
||||
# define DES_UNROLL
|
||||
#endif /* Systems-specific speed defines */
|
||||
#endif
|
||||
|
||||
#endif /* DES_DEFAULT_OPTIONS */
|
||||
#endif /* HEADER_DES_LOCL_H */
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
@ -41,7 +41,8 @@
|
||||
.In sys/rman.h
|
||||
.In machine/resource.h
|
||||
.Ft int
|
||||
.Fn bus_adjust_resource "device_t dev" "int type" "struct resource *r" "u_long start" "u_long end"
|
||||
.Fo bus_adjust_resource
|
||||
.Fa "device_t dev" "int type" "struct resource *r" "rman_res_t start" "rman_res_t end"
|
||||
.Sh DESCRIPTION
|
||||
This function is used to ask the parent bus to adjust the resource range
|
||||
assigned to an allocated resource.
|
||||
|
@ -43,7 +43,10 @@
|
||||
.In sys/rman.h
|
||||
.In machine/resource.h
|
||||
.Ft struct resource *
|
||||
.Fn bus_alloc_resource "device_t dev" "int type" "int *rid" "u_long start" "u_long end" "u_long count" "u_int flags"
|
||||
.Fo bus_alloc_resource
|
||||
.Fa "device_t dev" "int type" "int *rid" "rman_res_t start" "rman_res_t end"
|
||||
.Fa "rman_res_t count" "u_int flags"
|
||||
.Fc
|
||||
.Ft struct resource *
|
||||
.Fn bus_alloc_resource_any "device_t dev" "int type" "int *rid" "u_int flags"
|
||||
.Sh DESCRIPTION
|
||||
|
@ -44,7 +44,7 @@
|
||||
.In sys/rman.h
|
||||
.Ft int
|
||||
.Fo bus_get_resource
|
||||
.Fa "device_t dev" "int type" "int rid" "u_long *startp" "u_long *countp"
|
||||
.Fa "device_t dev" "int type" "int rid" "rman_res_t *startp" "rman_res_t *countp"
|
||||
.Fc
|
||||
.Sh DESCRIPTION
|
||||
The
|
||||
|
@ -43,7 +43,7 @@
|
||||
.In machine/resource.h
|
||||
.Ft int
|
||||
.Fo bus_set_resource
|
||||
.Fa "device_t dev" "int type" "int rid" "u_long start" "u_long count"
|
||||
.Fa "device_t dev" "int type" "int rid" "rman_res_t start" "rman_res_t count"
|
||||
.Fc
|
||||
.Sh DESCRIPTION
|
||||
The
|
||||
|
@ -65,7 +65,7 @@
|
||||
.Ft int
|
||||
.Fn rman_activate_resource "struct resource *r"
|
||||
.Ft int
|
||||
.Fn rman_adjust_resource "struct resource *r" "u_long start" "u_long end"
|
||||
.Fn rman_adjust_resource "struct resource *r" "rman_res_t start" "rman_res_t end"
|
||||
.Ft int
|
||||
.Fn rman_await_resource "struct resource *r" "int pri2" "int timo"
|
||||
.Ft int
|
||||
@ -79,32 +79,32 @@
|
||||
.Ft int
|
||||
.Fn rman_is_region_manager "struct resource *r" "struct rman *rm"
|
||||
.Ft int
|
||||
.Fn rman_manage_region "struct rman *rm" "u_long start" "u_long end"
|
||||
.Fn rman_manage_region "struct rman *rm" "rman_res_t start" "rman_res_t end"
|
||||
.Ft int
|
||||
.Fn rman_first_free_region "struct rman *rm" "u_long *start" "u_long *end"
|
||||
.Fn rman_first_free_region "struct rman *rm" "rman_res_t *start" "rman_res_t *end"
|
||||
.Ft int
|
||||
.Fn rman_last_free_region "struct rman *rm" "u_long *start" "u_long *end"
|
||||
.Fn rman_last_free_region "struct rman *rm" "rman_res_t *start" "rman_res_t *end"
|
||||
.Ft int
|
||||
.Fn rman_release_resource "struct resource *r"
|
||||
.Ft "struct resource *"
|
||||
.Fo rman_reserve_resource
|
||||
.Fa "struct rman *rm" "u_long start" "u_long end" "u_long count"
|
||||
.Fa "struct rman *rm" "rman_res_t start" "rman_res_t end" "rman_res_t count"
|
||||
.Fa "u_int flags" "struct device *dev"
|
||||
.Fc
|
||||
.Ft "struct resource *"
|
||||
.Fo rman_reserve_resource_bound
|
||||
.Fa "struct rman *rm" "u_long start" "u_long end" "u_long count"
|
||||
.Fa "u_long bound" "u_int flags" "struct device *dev"
|
||||
.Fa "struct rman *rm" "rman_res_t start" "rman_res_t end" "rman_res_t count"
|
||||
.Fa "rman_res_t bound" "u_int flags" "struct device *dev"
|
||||
.Fc
|
||||
.Ft uint32_t
|
||||
.Fn rman_make_alignment_flags "uint32_t size"
|
||||
.Ft u_long
|
||||
.Ft rman_res_t
|
||||
.Fn rman_get_start "struct resource *r"
|
||||
.Ft u_long
|
||||
.Ft rman_res_t
|
||||
.Fn rman_get_end "struct resource *r"
|
||||
.Ft "struct device *"
|
||||
.Fn rman_get_device "struct resource *r"
|
||||
.Ft u_long
|
||||
.Ft rman_res_t
|
||||
.Fn rman_get_size "struct resource *r"
|
||||
.Ft u_int
|
||||
.Fn rman_get_flags "struct resource *r"
|
||||
|
@ -1,5 +1,5 @@
|
||||
# $FreeBSD$
|
||||
# $Id: auto.obj.mk,v 1.10 2015/04/16 16:59:00 sjg Exp $
|
||||
# $Id: auto.obj.mk,v 1.12 2015/12/16 01:57:06 sjg Exp $
|
||||
#
|
||||
# @(#) Copyright (c) 2004, Simon J. Gerraty
|
||||
#
|
||||
@ -41,12 +41,12 @@ MKOBJDIRS= auto
|
||||
.if !defined(NOOBJ) && !defined(NO_OBJ) && ${MKOBJDIRS:Uno} == auto
|
||||
# Use __objdir here so it is easier to tweak without impacting
|
||||
# the logic.
|
||||
.if !empty(MAKEOBJDIRPREFIX) && exists(${MAKEOBJDIRPREFIX})
|
||||
.if !empty(MAKEOBJDIRPREFIX)
|
||||
__objdir?= ${MAKEOBJDIRPREFIX}${.CURDIR}
|
||||
.endif
|
||||
__objdir?= ${MAKEOBJDIR:Uobj}
|
||||
__objdir:= ${__objdir:tA}
|
||||
.if ${.OBJDIR} != ${__objdir}
|
||||
__objdir:= ${__objdir}
|
||||
.if ${.OBJDIR:tA} != ${__objdir:tA}
|
||||
# We need to chdir, make the directory if needed
|
||||
.if !exists(${__objdir}/) && \
|
||||
(${.TARGETS} == "" || ${.TARGETS:Nclean*:N*clean:Ndestroy*} != "")
|
||||
@ -54,11 +54,10 @@ __objdir:= ${__objdir:tA}
|
||||
__objdir_made != echo ${__objdir}/; umask ${OBJDIR_UMASK:U002}; \
|
||||
${ECHO_TRACE} "[Creating objdir ${__objdir}...]" >&2; \
|
||||
${Mkdirs}; Mkdirs ${__objdir}
|
||||
__objdir:= ${__objdir:tA}
|
||||
.endif
|
||||
# This causes make to use the specified directory as .OBJDIR
|
||||
.OBJDIR: ${__objdir}
|
||||
.if ${.OBJDIR} != ${__objdir} && ${__objdir_made:Uno:M${__objdir}/*} != ""
|
||||
.if ${.OBJDIR:tA} != ${__objdir:tA} && ${__objdir_made:Uno:M${__objdir}/*} != ""
|
||||
.error could not use ${__objdir}: .OBJDIR=${.OBJDIR}
|
||||
.endif
|
||||
.endif
|
||||
|
@ -56,6 +56,9 @@ _MKDEPCC+= ${DEPFLAGS}
|
||||
.endif
|
||||
MKDEPCMD?= CC='${_MKDEPCC}' mkdep
|
||||
DEPENDFILE?= .depend
|
||||
.if ${MK_DIRDEPS_BUILD} == "no"
|
||||
.MAKE.DEPENDFILE= ${DEPENDFILE}
|
||||
.endif
|
||||
DEPENDFILES= ${DEPENDFILE}
|
||||
|
||||
# Keep `tags' here, before SRCS are mangled below for `depend'.
|
||||
@ -107,8 +110,8 @@ ${_YC} y.tab.h: ${_YSRC}
|
||||
CLEANFILES+= y.tab.c y.tab.h
|
||||
.elif !empty(YFLAGS:M-d)
|
||||
.for _YH in ${_YC:R}.h
|
||||
${_YH}: ${_YC}
|
||||
${_YC}: ${_YSRC}
|
||||
.ORDER: ${_YC} ${_YH}
|
||||
${_YC} ${_YH}: ${_YSRC}
|
||||
${YACC} ${YFLAGS} -o ${_YC} ${.ALLSRC}
|
||||
SRCS+= ${_YH}
|
||||
CLEANFILES+= ${_YH}
|
||||
@ -129,25 +132,26 @@ CFLAGS+= -I${.OBJDIR}
|
||||
.endif
|
||||
.for _DSRC in ${SRCS:M*.d:N*/*}
|
||||
.for _D in ${_DSRC:R}
|
||||
DHDRS+= ${_D}.h
|
||||
SRCS+= ${_D}.h
|
||||
${_D}.h: ${_DSRC}
|
||||
${DTRACE} ${DTRACEFLAGS} -h -s ${.ALLSRC}
|
||||
SRCS:= ${SRCS:S/^${_DSRC}$//}
|
||||
OBJS+= ${_D}.o
|
||||
CLEANFILES+= ${_D}.h ${_D}.o
|
||||
${_D}.o: ${_DSRC} ${OBJS:S/^${_D}.o$//}
|
||||
${DTRACE} ${DTRACEFLAGS} -G -o ${.TARGET} -s ${.ALLSRC}
|
||||
@rm -f ${.TARGET}
|
||||
${DTRACE} ${DTRACEFLAGS} -G -o ${.TARGET} -s ${.ALLSRC:N*.h}
|
||||
.if defined(LIB)
|
||||
CLEANFILES+= ${_D}.So ${_D}.po
|
||||
${_D}.So: ${_DSRC} ${SOBJS:S/^${_D}.So$//}
|
||||
${DTRACE} ${DTRACEFLAGS} -G -o ${.TARGET} -s ${.ALLSRC}
|
||||
@rm -f ${.TARGET}
|
||||
${DTRACE} ${DTRACEFLAGS} -G -o ${.TARGET} -s ${.ALLSRC:N*.h}
|
||||
${_D}.po: ${_DSRC} ${POBJS:S/^${_D}.po$//}
|
||||
${DTRACE} ${DTRACEFLAGS} -G -o ${.TARGET} -s ${.ALLSRC}
|
||||
@rm -f ${.TARGET}
|
||||
${DTRACE} ${DTRACEFLAGS} -G -o ${.TARGET} -s ${.ALLSRC:N*.h}
|
||||
.endif
|
||||
.endfor
|
||||
.endfor
|
||||
beforedepend: ${DHDRS}
|
||||
beforebuild: ${DHDRS}
|
||||
|
||||
|
||||
.if ${MK_FAST_DEPEND} == "yes" && \
|
||||
|
@ -119,7 +119,7 @@ x.$p= PROG_CXX=$p
|
||||
$p ${p}_p: .PHONY .MAKE
|
||||
(cd ${.CURDIR} && \
|
||||
DEPENDFILE=.depend.$p \
|
||||
NO_SUBDIR=1 ${MAKE} -f ${MAKEFILE} _RECURSING_PROGS= \
|
||||
NO_SUBDIR=1 ${MAKE} -f ${MAKEFILE} _RECURSING_PROGS=t \
|
||||
PROG=$p ${x.$p})
|
||||
|
||||
# Pseudo targets for PROG, such as 'install'.
|
||||
@ -127,7 +127,7 @@ $p ${p}_p: .PHONY .MAKE
|
||||
$p.$t: .PHONY .MAKE
|
||||
(cd ${.CURDIR} && \
|
||||
DEPENDFILE=.depend.$p \
|
||||
NO_SUBDIR=1 ${MAKE} -f ${MAKEFILE} _RECURSING_PROGS= \
|
||||
NO_SUBDIR=1 ${MAKE} -f ${MAKEFILE} _RECURSING_PROGS=t \
|
||||
PROG=$p ${x.$p} ${@:E})
|
||||
.endfor
|
||||
.endfor
|
||||
|
@ -1,5 +1,5 @@
|
||||
# $FreeBSD$
|
||||
# $Id: gendirdeps.mk,v 1.27 2015/06/08 20:55:11 sjg Exp $
|
||||
# $Id: gendirdeps.mk,v 1.29 2015/10/03 05:00:46 sjg Exp $
|
||||
|
||||
# Copyright (c) 2010-2013, Juniper Networks, Inc.
|
||||
# All rights reserved.
|
||||
@ -158,7 +158,7 @@ M2D_OBJROOTS += ${SB_BACKING_SB}/${SB_OBJPREFIX}
|
||||
.endif
|
||||
|
||||
# we are only interested in the dirs
|
||||
# sepecifically those we read something from.
|
||||
# specifically those we read something from.
|
||||
# we canonicalize them to keep things simple
|
||||
# if we are using a split-fs sandbox, it gets a little messier.
|
||||
_objtop := ${_OBJTOP:tA}
|
||||
|
@ -1,6 +1,6 @@
|
||||
# $FreeBSD$
|
||||
# RCSid:
|
||||
# $Id: host-target.mk,v 1.7 2014/05/16 17:54:52 sjg Exp $
|
||||
# $Id: host-target.mk,v 1.11 2015/10/25 00:07:20 sjg Exp $
|
||||
|
||||
# Host platform information; may be overridden
|
||||
.if !defined(_HOST_OSNAME)
|
||||
@ -11,24 +11,33 @@ _HOST_OSNAME != uname -s
|
||||
_HOST_OSREL != uname -r
|
||||
.export _HOST_OSREL
|
||||
.endif
|
||||
.if !defined(_HOST_MACHINE)
|
||||
_HOST_MACHINE != uname -m
|
||||
.export _HOST_MACHINE
|
||||
.endif
|
||||
.if !defined(_HOST_ARCH)
|
||||
_HOST_ARCH != uname -p 2>/dev/null || uname -m
|
||||
# for NetBSD prefer $MACHINE (amd64 rather than x86_64)
|
||||
.if ${_HOST_OSNAME:NNetBSD} == ""
|
||||
_HOST_ARCH := ${_HOST_MACHINE}
|
||||
.else
|
||||
_HOST_ARCH != uname -p 2> /dev/null || uname -m
|
||||
# uname -p may produce garbage on linux
|
||||
.if ${_HOST_ARCH:[\#]} > 1
|
||||
_HOST_ARCH != uname -m
|
||||
.if ${_HOST_ARCH:[\#]} > 1 || ${_HOST_ARCH:Nunknown} == ""
|
||||
_HOST_ARCH := ${_HOST_MACHINE}
|
||||
.endif
|
||||
.endif
|
||||
.export _HOST_ARCH
|
||||
.endif
|
||||
.if !defined(HOST_MACHINE)
|
||||
HOST_MACHINE != uname -m
|
||||
HOST_MACHINE := ${_HOST_MACHINE}
|
||||
.export HOST_MACHINE
|
||||
.endif
|
||||
|
||||
HOST_OSMAJOR := ${_HOST_OSREL:C/[^0-9].*//}
|
||||
HOST_OSTYPE := ${_HOST_OSNAME}-${_HOST_OSREL:C/\([^\)]*\)//}-${_HOST_ARCH}
|
||||
HOST_OSTYPE := ${_HOST_OSNAME:S,/,,g}-${_HOST_OSREL:C/\([^\)]*\)//}-${_HOST_ARCH}
|
||||
HOST_OS := ${_HOST_OSNAME}
|
||||
host_os := ${_HOST_OSNAME:tl}
|
||||
HOST_TARGET := ${host_os}${HOST_OSMAJOR}-${_HOST_ARCH}
|
||||
HOST_TARGET := ${host_os:S,/,,g}${HOST_OSMAJOR}-${_HOST_ARCH}
|
||||
|
||||
# tr is insanely non-portable, accommodate the lowest common denominator
|
||||
TR ?= tr
|
||||
|
@ -1,5 +1,5 @@
|
||||
# $FreeBSD$
|
||||
# $Id: meta.subdir.mk,v 1.10 2012/07/03 05:26:46 sjg Exp $
|
||||
# $Id: meta.subdir.mk,v 1.11 2015/11/24 22:26:51 sjg Exp $
|
||||
|
||||
#
|
||||
# @(#) Copyright (c) 2010, Simon J. Gerraty
|
||||
@ -63,7 +63,7 @@ _subdeps != cd ${.CURDIR} && \
|
||||
DIRDEPS =
|
||||
.else
|
||||
# clean up if needed
|
||||
DIRDEPS := ${DIRDEPS:S,^./,,:S,/./,/,g:${SUBDIREPS_FILTER:Uu}}
|
||||
DIRDEPS := ${DIRDEPS:S,^./,,:S,/./,/,g:${SUBDIRDEPS_FILTER:Uu}}
|
||||
.endif
|
||||
# we just dealt with it, if we leave it defined,
|
||||
# dirdeps.mk will compute some interesting combinations.
|
||||
|
@ -271,6 +271,7 @@ elf_linux_fixup(register_t **stack_base, struct image_params *imgp)
|
||||
Elf_Addr *pos;
|
||||
struct ps_strings *arginfo;
|
||||
struct proc *p;
|
||||
int issetugid;
|
||||
|
||||
p = imgp->proc;
|
||||
arginfo = (struct ps_strings *)p->p_sysent->sv_psstrings;
|
||||
@ -281,6 +282,7 @@ elf_linux_fixup(register_t **stack_base, struct image_params *imgp)
|
||||
args = (Elf64_Auxargs *)imgp->auxargs;
|
||||
pos = base + (imgp->args->argc + imgp->args->envc + 2);
|
||||
|
||||
issetugid = p->p_flag & P_SUGID ? 1 : 0;
|
||||
AUXARGS_ENTRY(pos, LINUX_AT_SYSINFO_EHDR,
|
||||
imgp->proc->p_sysent->sv_shared_page_base);
|
||||
AUXARGS_ENTRY(pos, LINUX_AT_HWCAP, cpu_feature);
|
||||
@ -296,7 +298,7 @@ elf_linux_fixup(register_t **stack_base, struct image_params *imgp)
|
||||
AUXARGS_ENTRY(pos, AT_EUID, imgp->proc->p_ucred->cr_svuid);
|
||||
AUXARGS_ENTRY(pos, AT_GID, imgp->proc->p_ucred->cr_rgid);
|
||||
AUXARGS_ENTRY(pos, AT_EGID, imgp->proc->p_ucred->cr_svgid);
|
||||
AUXARGS_ENTRY(pos, LINUX_AT_SECURE, 0);
|
||||
AUXARGS_ENTRY(pos, LINUX_AT_SECURE, issetugid);
|
||||
AUXARGS_ENTRY(pos, LINUX_AT_PLATFORM, PTROUT(linux_platform));
|
||||
AUXARGS_ENTRY(pos, LINUX_AT_RANDOM, imgp->canary);
|
||||
if (imgp->execpathp != 0)
|
||||
|
@ -230,6 +230,7 @@ elf_linux_fixup(register_t **stack_base, struct image_params *imgp)
|
||||
Elf32_Addr *base;
|
||||
Elf32_Addr *pos;
|
||||
struct linux32_ps_strings *arginfo;
|
||||
int issetugid;
|
||||
|
||||
arginfo = (struct linux32_ps_strings *)LINUX32_PS_STRINGS;
|
||||
|
||||
@ -239,6 +240,7 @@ elf_linux_fixup(register_t **stack_base, struct image_params *imgp)
|
||||
args = (Elf32_Auxargs *)imgp->auxargs;
|
||||
pos = base + (imgp->args->argc + imgp->args->envc + 2);
|
||||
|
||||
issetugid = imgp->proc->p_flag & P_SUGID ? 1 : 0;
|
||||
AUXARGS_ENTRY_32(pos, LINUX_AT_SYSINFO_EHDR,
|
||||
imgp->proc->p_sysent->sv_shared_page_base);
|
||||
AUXARGS_ENTRY_32(pos, LINUX_AT_SYSINFO, linux32_vsyscall);
|
||||
@ -261,7 +263,7 @@ elf_linux_fixup(register_t **stack_base, struct image_params *imgp)
|
||||
AUXARGS_ENTRY_32(pos, AT_FLAGS, args->flags);
|
||||
AUXARGS_ENTRY_32(pos, AT_ENTRY, args->entry);
|
||||
AUXARGS_ENTRY_32(pos, AT_BASE, args->base);
|
||||
AUXARGS_ENTRY_32(pos, LINUX_AT_SECURE, 0);
|
||||
AUXARGS_ENTRY_32(pos, LINUX_AT_SECURE, issetugid);
|
||||
AUXARGS_ENTRY_32(pos, AT_UID, imgp->proc->p_ucred->cr_ruid);
|
||||
AUXARGS_ENTRY_32(pos, AT_EUID, imgp->proc->p_ucred->cr_svuid);
|
||||
AUXARGS_ENTRY_32(pos, AT_GID, imgp->proc->p_ucred->cr_rgid);
|
||||
|
@ -28,6 +28,7 @@
|
||||
* any improvements or extensions that they make and grant Carnegie the
|
||||
* rights to redistribute these changes.
|
||||
*/
|
||||
#include "opt_ddb.h"
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
@ -43,6 +44,7 @@ __FBSDID("$FreeBSD$");
|
||||
#include <machine/asm.h>
|
||||
#include <machine/cpufunc.h>
|
||||
#include <machine/db_machdep.h>
|
||||
#include <machine/debug_monitor.h>
|
||||
#include <machine/pcb.h>
|
||||
#include <machine/stack.h>
|
||||
#include <machine/vmparam.h>
|
||||
@ -127,22 +129,25 @@ db_stack_trace_cmd(struct unwind_state *state)
|
||||
}
|
||||
}
|
||||
|
||||
/* XXX stubs */
|
||||
void
|
||||
db_md_list_watchpoints()
|
||||
{
|
||||
|
||||
dbg_show_watchpoint();
|
||||
}
|
||||
|
||||
int
|
||||
db_md_clr_watchpoint(db_expr_t addr, db_expr_t size)
|
||||
{
|
||||
return (0);
|
||||
|
||||
return (dbg_remove_watchpoint(addr, size));
|
||||
}
|
||||
|
||||
int
|
||||
db_md_set_watchpoint(db_expr_t addr, db_expr_t size)
|
||||
{
|
||||
return (0);
|
||||
|
||||
return (dbg_setup_watchpoint(addr, size, HW_WATCHPOINT_RW));
|
||||
}
|
||||
|
||||
int
|
||||
|
943
sys/arm/arm/debug_monitor.c
Normal file
943
sys/arm/arm/debug_monitor.c
Normal file
@ -0,0 +1,943 @@
|
||||
/*
|
||||
* Copyright (c) 2015 Juniper Networks Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Developed by Semihalf.
|
||||
*
|
||||
* 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 "opt_ddb.h"
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/kdb.h>
|
||||
#include <sys/pcpu.h>
|
||||
#include <sys/systm.h>
|
||||
|
||||
#include <machine/armreg.h>
|
||||
#include <machine/cpu.h>
|
||||
#include <machine/debug_monitor.h>
|
||||
#include <machine/kdb.h>
|
||||
#include <machine/param.h>
|
||||
#include <machine/pcb.h>
|
||||
|
||||
#include <ddb/ddb.h>
|
||||
#include <ddb/db_access.h>
|
||||
#include <ddb/db_sym.h>
|
||||
|
||||
enum dbg_t {
|
||||
DBG_TYPE_BREAKPOINT = 0,
|
||||
DBG_TYPE_WATCHPOINT = 1,
|
||||
};
|
||||
|
||||
struct dbg_wb_conf {
|
||||
enum dbg_t type;
|
||||
enum dbg_access_t access;
|
||||
db_addr_t address;
|
||||
db_expr_t size;
|
||||
u_int slot;
|
||||
};
|
||||
|
||||
static int dbg_reset_state(void);
|
||||
static int dbg_setup_breakpoint(db_expr_t, db_expr_t, u_int);
|
||||
static int dbg_remove_breakpoint(u_int);
|
||||
static u_int dbg_find_slot(enum dbg_t, db_expr_t);
|
||||
static boolean_t dbg_check_slot_free(enum dbg_t, u_int);
|
||||
|
||||
static int dbg_remove_xpoint(struct dbg_wb_conf *);
|
||||
static int dbg_setup_xpoint(struct dbg_wb_conf *);
|
||||
|
||||
static boolean_t dbg_capable; /* Indicates that machine is capable of using
|
||||
HW watchpoints/breakpoints */
|
||||
static boolean_t dbg_ready[MAXCPU]; /* Debug arch. reset performed on this CPU */
|
||||
|
||||
static uint32_t dbg_model; /* Debug Arch. Model */
|
||||
static boolean_t dbg_ossr; /* OS Save and Restore implemented */
|
||||
|
||||
static uint32_t dbg_watchpoint_num;
|
||||
static uint32_t dbg_breakpoint_num;
|
||||
|
||||
static int dbg_ref_count_mme[MAXCPU]; /* Times monitor mode was enabled */
|
||||
|
||||
/* ID_DFR0 - Debug Feature Register 0 */
|
||||
#define ID_DFR0_CP_DEBUG_M_SHIFT 0
|
||||
#define ID_DFR0_CP_DEBUG_M_MASK (0xF << ID_DFR0_CP_DEBUG_M_SHIFT)
|
||||
#define ID_DFR0_CP_DEBUG_M_NS (0x0) /* Not supported */
|
||||
#define ID_DFR0_CP_DEBUG_M_V6 (0x2) /* v6 Debug arch. CP14 access */
|
||||
#define ID_DFR0_CP_DEBUG_M_V6_1 (0x3) /* v6.1 Debug arch. CP14 access */
|
||||
#define ID_DFR0_CP_DEBUG_M_V7 (0x4) /* v7 Debug arch. CP14 access */
|
||||
#define ID_DFR0_CP_DEBUG_M_V7_1 (0x5) /* v7.1 Debug arch. CP14 access */
|
||||
|
||||
/* DBGDIDR - Debug ID Register */
|
||||
#define DBGDIDR_WRPS_SHIFT 28
|
||||
#define DBGDIDR_WRPS_MASK (0xF << DBGDIDR_WRPS_SHIFT)
|
||||
#define DBGDIDR_WRPS_NUM(reg) \
|
||||
((((reg) & DBGDIDR_WRPS_MASK) >> DBGDIDR_WRPS_SHIFT) + 1)
|
||||
|
||||
#define DBGDIDR_BRPS_SHIFT 24
|
||||
#define DBGDIDR_BRPS_MASK (0xF << DBGDIDR_BRPS_SHIFT)
|
||||
#define DBGDIDR_BRPS_NUM(reg) \
|
||||
((((reg) & DBGDIDR_BRPS_MASK) >> DBGDIDR_BRPS_SHIFT) + 1)
|
||||
|
||||
/* DBGPRSR - Device Powerdown and Reset Status Register */
|
||||
#define DBGPRSR_PU (1 << 0) /* Powerup status */
|
||||
|
||||
/* DBGOSLSR - OS Lock Status Register */
|
||||
#define DBGOSLSR_OSLM0 (1 << 0)
|
||||
|
||||
/* DBGOSDLR - OS Double Lock Register */
|
||||
#define DBGPRSR_DLK (1 << 0) /* OS Double Lock set */
|
||||
|
||||
/* DBGDSCR - Debug Status and Control Register */
|
||||
#define DBGSCR_MDBG_EN (1 << 15) /* Monitor debug-mode enable */
|
||||
|
||||
/* DBGWVR - Watchpoint Value Register */
|
||||
#define DBGWVR_ADDR_MASK (~0x3U)
|
||||
|
||||
/* Watchpoints/breakpoints control register bitfields */
|
||||
#define DBG_WB_CTRL_LEN_1 (0x1 << 5)
|
||||
#define DBG_WB_CTRL_LEN_2 (0x3 << 5)
|
||||
#define DBG_WB_CTRL_LEN_4 (0xf << 5)
|
||||
#define DBG_WB_CTRL_LEN_8 (0xff << 5)
|
||||
#define DBG_WB_CTRL_LEN_MASK(x) ((x) & (0xff << 5))
|
||||
#define DBG_WB_CTRL_EXEC (0x0 << 3)
|
||||
#define DBG_WB_CTRL_LOAD (0x1 << 3)
|
||||
#define DBG_WB_CTRL_STORE (0x2 << 3)
|
||||
#define DBG_WB_CTRL_ACCESS_MASK(x) ((x) & (0x3 << 3))
|
||||
|
||||
/* Common for breakpoint and watchpoint */
|
||||
#define DBG_WB_CTRL_PL1 (0x1 << 1)
|
||||
#define DBG_WB_CTRL_PL0 (0x2 << 1)
|
||||
#define DBG_WB_CTRL_PLX_MASK(x) ((x) & (0x3 << 1))
|
||||
#define DBG_WB_CTRL_E (0x1 << 0)
|
||||
|
||||
/*
|
||||
* Watchpoint/breakpoint helpers
|
||||
*/
|
||||
#define DBG_BKPT_BT_SLOT 0 /* Slot for branch taken */
|
||||
#define DBG_BKPT_BNT_SLOT 1 /* Slot for branch not taken */
|
||||
|
||||
#define OP2_SHIFT 4
|
||||
|
||||
/* Opc2 numbers for coprocessor instructions */
|
||||
#define DBG_WB_BVR 4
|
||||
#define DBG_WB_BCR 5
|
||||
#define DBG_WB_WVR 6
|
||||
#define DBG_WB_WCR 7
|
||||
|
||||
#define DBG_REG_BASE_BVR (DBG_WB_BVR << OP2_SHIFT)
|
||||
#define DBG_REG_BASE_BCR (DBG_WB_BCR << OP2_SHIFT)
|
||||
#define DBG_REG_BASE_WVR (DBG_WB_WVR << OP2_SHIFT)
|
||||
#define DBG_REG_BASE_WCR (DBG_WB_WCR << OP2_SHIFT)
|
||||
|
||||
#define DBG_WB_READ(cn, cm, op2, val) do { \
|
||||
__asm __volatile("mrc p14, 0, %0, " #cn "," #cm "," #op2 : "=r" (val)); \
|
||||
} while (0)
|
||||
|
||||
#define DBG_WB_WRITE(cn, cm, op2, val) do { \
|
||||
__asm __volatile("mcr p14, 0, %0, " #cn "," #cm "," #op2 :: "r" (val)); \
|
||||
} while (0)
|
||||
|
||||
#define READ_WB_REG_CASE(op2, m, val) \
|
||||
case (((op2) << OP2_SHIFT) + m): \
|
||||
DBG_WB_READ(c0, c ## m, op2, val); \
|
||||
break
|
||||
|
||||
#define WRITE_WB_REG_CASE(op2, m, val) \
|
||||
case (((op2) << OP2_SHIFT) + m): \
|
||||
DBG_WB_WRITE(c0, c ## m, op2, val); \
|
||||
break
|
||||
|
||||
#define SWITCH_CASES_READ_WB_REG(op2, val) \
|
||||
READ_WB_REG_CASE(op2, 0, val); \
|
||||
READ_WB_REG_CASE(op2, 1, val); \
|
||||
READ_WB_REG_CASE(op2, 2, val); \
|
||||
READ_WB_REG_CASE(op2, 3, val); \
|
||||
READ_WB_REG_CASE(op2, 4, val); \
|
||||
READ_WB_REG_CASE(op2, 5, val); \
|
||||
READ_WB_REG_CASE(op2, 6, val); \
|
||||
READ_WB_REG_CASE(op2, 7, val); \
|
||||
READ_WB_REG_CASE(op2, 8, val); \
|
||||
READ_WB_REG_CASE(op2, 9, val); \
|
||||
READ_WB_REG_CASE(op2, 10, val); \
|
||||
READ_WB_REG_CASE(op2, 11, val); \
|
||||
READ_WB_REG_CASE(op2, 12, val); \
|
||||
READ_WB_REG_CASE(op2, 13, val); \
|
||||
READ_WB_REG_CASE(op2, 14, val); \
|
||||
READ_WB_REG_CASE(op2, 15, val)
|
||||
|
||||
#define SWITCH_CASES_WRITE_WB_REG(op2, val) \
|
||||
WRITE_WB_REG_CASE(op2, 0, val); \
|
||||
WRITE_WB_REG_CASE(op2, 1, val); \
|
||||
WRITE_WB_REG_CASE(op2, 2, val); \
|
||||
WRITE_WB_REG_CASE(op2, 3, val); \
|
||||
WRITE_WB_REG_CASE(op2, 4, val); \
|
||||
WRITE_WB_REG_CASE(op2, 5, val); \
|
||||
WRITE_WB_REG_CASE(op2, 6, val); \
|
||||
WRITE_WB_REG_CASE(op2, 7, val); \
|
||||
WRITE_WB_REG_CASE(op2, 8, val); \
|
||||
WRITE_WB_REG_CASE(op2, 9, val); \
|
||||
WRITE_WB_REG_CASE(op2, 10, val); \
|
||||
WRITE_WB_REG_CASE(op2, 11, val); \
|
||||
WRITE_WB_REG_CASE(op2, 12, val); \
|
||||
WRITE_WB_REG_CASE(op2, 13, val); \
|
||||
WRITE_WB_REG_CASE(op2, 14, val); \
|
||||
WRITE_WB_REG_CASE(op2, 15, val)
|
||||
|
||||
static uint32_t
|
||||
dbg_wb_read_reg(int reg, int n)
|
||||
{
|
||||
uint32_t val;
|
||||
|
||||
val = 0;
|
||||
|
||||
switch (reg + n) {
|
||||
SWITCH_CASES_READ_WB_REG(DBG_WB_WVR, val);
|
||||
SWITCH_CASES_READ_WB_REG(DBG_WB_WCR, val);
|
||||
SWITCH_CASES_READ_WB_REG(DBG_WB_BVR, val);
|
||||
SWITCH_CASES_READ_WB_REG(DBG_WB_BCR, val);
|
||||
default:
|
||||
db_printf(
|
||||
"trying to read from CP14 reg. using wrong opc2 %d\n",
|
||||
reg >> OP2_SHIFT);
|
||||
}
|
||||
|
||||
return (val);
|
||||
}
|
||||
|
||||
static void
|
||||
dbg_wb_write_reg(int reg, int n, uint32_t val)
|
||||
{
|
||||
|
||||
switch (reg + n) {
|
||||
SWITCH_CASES_WRITE_WB_REG(DBG_WB_WVR, val);
|
||||
SWITCH_CASES_WRITE_WB_REG(DBG_WB_WCR, val);
|
||||
SWITCH_CASES_WRITE_WB_REG(DBG_WB_BVR, val);
|
||||
SWITCH_CASES_WRITE_WB_REG(DBG_WB_BCR, val);
|
||||
default:
|
||||
db_printf(
|
||||
"trying to write to CP14 reg. using wrong opc2 %d\n",
|
||||
reg >> OP2_SHIFT);
|
||||
}
|
||||
isb();
|
||||
}
|
||||
|
||||
boolean_t
|
||||
kdb_cpu_pc_is_singlestep(db_addr_t pc)
|
||||
{
|
||||
|
||||
if (dbg_find_slot(DBG_TYPE_BREAKPOINT, pc) != ~0U)
|
||||
return (TRUE);
|
||||
|
||||
return (FALSE);
|
||||
}
|
||||
|
||||
void
|
||||
kdb_cpu_set_singlestep(void)
|
||||
{
|
||||
db_expr_t inst;
|
||||
db_addr_t pc, brpc;
|
||||
uint32_t wcr;
|
||||
u_int i;
|
||||
|
||||
/*
|
||||
* Disable watchpoints, e.g. stepping over watched instruction will
|
||||
* trigger break exception instead of single-step exception and locks
|
||||
* CPU on that instruction for ever.
|
||||
*/
|
||||
for (i = 0; i < dbg_watchpoint_num; i++) {
|
||||
wcr = dbg_wb_read_reg(DBG_REG_BASE_WCR, i);
|
||||
if ((wcr & DBG_WB_CTRL_E) != 0) {
|
||||
dbg_wb_write_reg(DBG_REG_BASE_WCR, i,
|
||||
(wcr & ~DBG_WB_CTRL_E));
|
||||
}
|
||||
}
|
||||
|
||||
pc = PC_REGS();
|
||||
|
||||
inst = db_get_value(pc, sizeof(pc), FALSE);
|
||||
if (inst_branch(inst) || inst_call(inst) || inst_return(inst)) {
|
||||
brpc = branch_taken(inst, pc);
|
||||
dbg_setup_breakpoint(brpc, INSN_SIZE, DBG_BKPT_BT_SLOT);
|
||||
}
|
||||
pc = next_instr_address(pc, 0);
|
||||
dbg_setup_breakpoint(pc, INSN_SIZE, DBG_BKPT_BNT_SLOT);
|
||||
}
|
||||
|
||||
void
|
||||
kdb_cpu_clear_singlestep(void)
|
||||
{
|
||||
uint32_t wvr, wcr;
|
||||
u_int i;
|
||||
|
||||
dbg_remove_breakpoint(DBG_BKPT_BT_SLOT);
|
||||
dbg_remove_breakpoint(DBG_BKPT_BNT_SLOT);
|
||||
|
||||
/* Restore all watchpoints */
|
||||
for (i = 0; i < dbg_watchpoint_num; i++) {
|
||||
wcr = dbg_wb_read_reg(DBG_REG_BASE_WCR, i);
|
||||
wvr = dbg_wb_read_reg(DBG_REG_BASE_WVR, i);
|
||||
/* Watchpoint considered not empty if address value is not 0 */
|
||||
if ((wvr & DBGWVR_ADDR_MASK) != 0) {
|
||||
dbg_wb_write_reg(DBG_REG_BASE_WCR, i,
|
||||
(wcr | DBG_WB_CTRL_E));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
dbg_setup_watchpoint(db_expr_t addr, db_expr_t size, enum dbg_access_t access)
|
||||
{
|
||||
struct dbg_wb_conf conf;
|
||||
|
||||
if (access == HW_BREAKPOINT_X) {
|
||||
db_printf("Invalid access type for watchpoint: %d\n", access);
|
||||
return (EINVAL);
|
||||
}
|
||||
|
||||
conf.address = addr;
|
||||
conf.size = size;
|
||||
conf.access = access;
|
||||
conf.type = DBG_TYPE_WATCHPOINT;
|
||||
|
||||
return (dbg_setup_xpoint(&conf));
|
||||
}
|
||||
|
||||
int
|
||||
dbg_remove_watchpoint(db_expr_t addr, db_expr_t size __unused)
|
||||
{
|
||||
struct dbg_wb_conf conf;
|
||||
|
||||
conf.address = addr;
|
||||
conf.type = DBG_TYPE_WATCHPOINT;
|
||||
|
||||
return (dbg_remove_xpoint(&conf));
|
||||
}
|
||||
|
||||
static int
|
||||
dbg_setup_breakpoint(db_expr_t addr, db_expr_t size, u_int slot)
|
||||
{
|
||||
struct dbg_wb_conf conf;
|
||||
|
||||
conf.address = addr;
|
||||
conf.size = size;
|
||||
conf.access = HW_BREAKPOINT_X;
|
||||
conf.type = DBG_TYPE_BREAKPOINT;
|
||||
conf.slot = slot;
|
||||
|
||||
return (dbg_setup_xpoint(&conf));
|
||||
}
|
||||
|
||||
static int
|
||||
dbg_remove_breakpoint(u_int slot)
|
||||
{
|
||||
struct dbg_wb_conf conf;
|
||||
|
||||
/* Slot already cleared. Don't recurse */
|
||||
if (dbg_check_slot_free(DBG_TYPE_BREAKPOINT, slot))
|
||||
return (0);
|
||||
|
||||
conf.slot = slot;
|
||||
conf.type = DBG_TYPE_BREAKPOINT;
|
||||
|
||||
return (dbg_remove_xpoint(&conf));
|
||||
}
|
||||
|
||||
static const char *
|
||||
dbg_watchtype_str(uint32_t type)
|
||||
{
|
||||
|
||||
switch (type) {
|
||||
case DBG_WB_CTRL_EXEC:
|
||||
return ("execute");
|
||||
case DBG_WB_CTRL_STORE:
|
||||
return ("write");
|
||||
case DBG_WB_CTRL_LOAD:
|
||||
return ("read");
|
||||
case DBG_WB_CTRL_LOAD | DBG_WB_CTRL_STORE:
|
||||
return ("read/write");
|
||||
default:
|
||||
return ("invalid");
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
dbg_watchtype_len(uint32_t len)
|
||||
{
|
||||
|
||||
switch (len) {
|
||||
case DBG_WB_CTRL_LEN_1:
|
||||
return (1);
|
||||
case DBG_WB_CTRL_LEN_2:
|
||||
return (2);
|
||||
case DBG_WB_CTRL_LEN_4:
|
||||
return (4);
|
||||
case DBG_WB_CTRL_LEN_8:
|
||||
return (8);
|
||||
default:
|
||||
return (0);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
dbg_show_watchpoint(void)
|
||||
{
|
||||
uint32_t wcr, len, type;
|
||||
uint32_t addr;
|
||||
boolean_t is_enabled;
|
||||
int i;
|
||||
|
||||
if (!dbg_capable) {
|
||||
db_printf("Architecture does not support HW "
|
||||
"breakpoints/watchpoints\n");
|
||||
return;
|
||||
}
|
||||
|
||||
db_printf("\nhardware watchpoints:\n");
|
||||
db_printf(" watch status type len address symbol\n");
|
||||
db_printf(" ----- -------- ---------- --- ---------- ------------------\n");
|
||||
for (i = 0; i < dbg_watchpoint_num; i++) {
|
||||
wcr = dbg_wb_read_reg(DBG_REG_BASE_WCR, i);
|
||||
if ((wcr & DBG_WB_CTRL_E) != 0)
|
||||
is_enabled = TRUE;
|
||||
else
|
||||
is_enabled = FALSE;
|
||||
|
||||
type = DBG_WB_CTRL_ACCESS_MASK(wcr);
|
||||
len = DBG_WB_CTRL_LEN_MASK(wcr);
|
||||
addr = dbg_wb_read_reg(DBG_REG_BASE_WVR, i) & DBGWVR_ADDR_MASK;
|
||||
db_printf(" %-5d %-8s %10s %3d 0x%08x ", i,
|
||||
is_enabled ? "enabled" : "disabled",
|
||||
is_enabled ? dbg_watchtype_str(type) : "",
|
||||
is_enabled ? dbg_watchtype_len(len) : 0,
|
||||
addr);
|
||||
db_printsym((db_addr_t)addr, DB_STGY_ANY);
|
||||
db_printf("\n");
|
||||
}
|
||||
}
|
||||
|
||||
static boolean_t
|
||||
dbg_check_slot_free(enum dbg_t type, u_int slot)
|
||||
{
|
||||
uint32_t cr, vr;
|
||||
uint32_t max;
|
||||
|
||||
switch(type) {
|
||||
case DBG_TYPE_BREAKPOINT:
|
||||
max = dbg_breakpoint_num;
|
||||
cr = DBG_REG_BASE_BCR;
|
||||
vr = DBG_REG_BASE_BVR;
|
||||
break;
|
||||
case DBG_TYPE_WATCHPOINT:
|
||||
max = dbg_watchpoint_num;
|
||||
cr = DBG_REG_BASE_WCR;
|
||||
vr = DBG_REG_BASE_WVR;
|
||||
break;
|
||||
default:
|
||||
db_printf("%s: Unsupported event type %d\n", __func__, type);
|
||||
return (FALSE);
|
||||
}
|
||||
|
||||
if (slot >= max) {
|
||||
db_printf("%s: Invalid slot number %d, max %d\n",
|
||||
__func__, slot, max - 1);
|
||||
return (FALSE);
|
||||
}
|
||||
|
||||
if ((dbg_wb_read_reg(cr, slot) & DBG_WB_CTRL_E) == 0 &&
|
||||
(dbg_wb_read_reg(vr, slot) & DBGWVR_ADDR_MASK) == 0)
|
||||
return (TRUE);
|
||||
|
||||
return (FALSE);
|
||||
}
|
||||
|
||||
static u_int
|
||||
dbg_find_free_slot(enum dbg_t type)
|
||||
{
|
||||
u_int max, i;
|
||||
|
||||
switch(type) {
|
||||
case DBG_TYPE_BREAKPOINT:
|
||||
max = dbg_breakpoint_num;
|
||||
break;
|
||||
case DBG_TYPE_WATCHPOINT:
|
||||
max = dbg_watchpoint_num;
|
||||
break;
|
||||
default:
|
||||
db_printf("Unsupported debug type\n");
|
||||
return (~0U);
|
||||
}
|
||||
|
||||
for (i = 0; i < max; i++) {
|
||||
if (dbg_check_slot_free(type, i))
|
||||
return (i);
|
||||
}
|
||||
|
||||
return (~0U);
|
||||
}
|
||||
|
||||
static u_int
|
||||
dbg_find_slot(enum dbg_t type, db_expr_t addr)
|
||||
{
|
||||
uint32_t reg_addr, reg_ctrl;
|
||||
u_int max, i;
|
||||
|
||||
switch(type) {
|
||||
case DBG_TYPE_BREAKPOINT:
|
||||
max = dbg_breakpoint_num;
|
||||
reg_addr = DBG_REG_BASE_BVR;
|
||||
reg_ctrl = DBG_REG_BASE_BCR;
|
||||
break;
|
||||
case DBG_TYPE_WATCHPOINT:
|
||||
max = dbg_watchpoint_num;
|
||||
reg_addr = DBG_REG_BASE_WVR;
|
||||
reg_ctrl = DBG_REG_BASE_WCR;
|
||||
break;
|
||||
default:
|
||||
db_printf("Unsupported debug type\n");
|
||||
return (~0U);
|
||||
}
|
||||
|
||||
for (i = 0; i < max; i++) {
|
||||
if ((dbg_wb_read_reg(reg_addr, i) == addr) &&
|
||||
((dbg_wb_read_reg(reg_ctrl, i) & DBG_WB_CTRL_E) != 0))
|
||||
return (i);
|
||||
}
|
||||
|
||||
return (~0U);
|
||||
}
|
||||
|
||||
static __inline boolean_t
|
||||
dbg_monitor_is_enabled(void)
|
||||
{
|
||||
|
||||
return ((cp14_dbgdscrint_get() & DBGSCR_MDBG_EN) != 0);
|
||||
}
|
||||
|
||||
static int
|
||||
dbg_enable_monitor(void)
|
||||
{
|
||||
uint32_t dbg_dscr;
|
||||
|
||||
/* Already enabled? Just increment reference counter and return */
|
||||
if (dbg_monitor_is_enabled()) {
|
||||
dbg_ref_count_mme[PCPU_GET(cpuid)]++;
|
||||
return (0);
|
||||
}
|
||||
|
||||
dbg_dscr = cp14_dbgdscrint_get();
|
||||
|
||||
switch (dbg_model) {
|
||||
case ID_DFR0_CP_DEBUG_M_V6:
|
||||
case ID_DFR0_CP_DEBUG_M_V6_1: /* fall through */
|
||||
cp14_dbgdscr_v6_set(dbg_dscr | DBGSCR_MDBG_EN);
|
||||
break;
|
||||
case ID_DFR0_CP_DEBUG_M_V7: /* fall through */
|
||||
case ID_DFR0_CP_DEBUG_M_V7_1:
|
||||
cp14_dbgdscr_v7_set(dbg_dscr | DBGSCR_MDBG_EN);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
isb();
|
||||
|
||||
/* Verify that Monitor mode is set */
|
||||
if (dbg_monitor_is_enabled()) {
|
||||
dbg_ref_count_mme[PCPU_GET(cpuid)]++;
|
||||
return (0);
|
||||
}
|
||||
|
||||
return (ENXIO);
|
||||
}
|
||||
|
||||
static int
|
||||
dbg_disable_monitor(void)
|
||||
{
|
||||
uint32_t dbg_dscr;
|
||||
|
||||
if (!dbg_monitor_is_enabled())
|
||||
return (0);
|
||||
|
||||
if (--dbg_ref_count_mme[PCPU_GET(cpuid)] > 0)
|
||||
return (0);
|
||||
|
||||
dbg_dscr = cp14_dbgdscrint_get();
|
||||
switch (dbg_model) {
|
||||
case ID_DFR0_CP_DEBUG_M_V6:
|
||||
case ID_DFR0_CP_DEBUG_M_V6_1: /* fall through */
|
||||
dbg_dscr &= ~DBGSCR_MDBG_EN;
|
||||
cp14_dbgdscr_v6_set(dbg_dscr);
|
||||
break;
|
||||
case ID_DFR0_CP_DEBUG_M_V7: /* fall through */
|
||||
case ID_DFR0_CP_DEBUG_M_V7_1:
|
||||
dbg_dscr &= ~DBGSCR_MDBG_EN;
|
||||
cp14_dbgdscr_v7_set(dbg_dscr);
|
||||
break;
|
||||
default:
|
||||
return (ENXIO);
|
||||
}
|
||||
isb();
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
static int
|
||||
dbg_setup_xpoint(struct dbg_wb_conf *conf)
|
||||
{
|
||||
const char *typestr;
|
||||
uint32_t cr_size, cr_priv, cr_access;
|
||||
uint32_t reg_ctrl, reg_addr, ctrl, addr;
|
||||
boolean_t is_bkpt;
|
||||
u_int cpuid;
|
||||
u_int i;
|
||||
int err;
|
||||
|
||||
if (!dbg_capable)
|
||||
return (ENXIO);
|
||||
|
||||
is_bkpt = (conf->type == DBG_TYPE_BREAKPOINT);
|
||||
typestr = is_bkpt ? "breakpoint" : "watchpoint";
|
||||
|
||||
cpuid = PCPU_GET(cpuid);
|
||||
if (!dbg_ready[cpuid]) {
|
||||
err = dbg_reset_state();
|
||||
if (err != 0)
|
||||
return (err);
|
||||
dbg_ready[cpuid] = TRUE;
|
||||
}
|
||||
|
||||
if (is_bkpt) {
|
||||
if (dbg_breakpoint_num == 0) {
|
||||
db_printf("Breakpoints not supported on this architecture\n");
|
||||
return (ENXIO);
|
||||
}
|
||||
i = conf->slot;
|
||||
if (!dbg_check_slot_free(DBG_TYPE_BREAKPOINT, i)) {
|
||||
/*
|
||||
* This should never happen. If it does it means that
|
||||
* there is an erroneus scenario somewhere. Still, it can
|
||||
* be done but let's inform the user.
|
||||
*/
|
||||
db_printf("ERROR: Breakpoint already set. Replacing...\n");
|
||||
}
|
||||
} else {
|
||||
i = dbg_find_free_slot(DBG_TYPE_WATCHPOINT);
|
||||
if (i == ~0U) {
|
||||
db_printf("Can not find slot for %s, max %d slots supported\n",
|
||||
typestr, dbg_watchpoint_num);
|
||||
return (ENXIO);
|
||||
}
|
||||
}
|
||||
|
||||
/* Kernel access only */
|
||||
cr_priv = DBG_WB_CTRL_PL1;
|
||||
|
||||
switch(conf->size) {
|
||||
case 1:
|
||||
cr_size = DBG_WB_CTRL_LEN_1;
|
||||
break;
|
||||
case 2:
|
||||
cr_size = DBG_WB_CTRL_LEN_2;
|
||||
break;
|
||||
case 4:
|
||||
cr_size = DBG_WB_CTRL_LEN_4;
|
||||
break;
|
||||
case 8:
|
||||
cr_size = DBG_WB_CTRL_LEN_8;
|
||||
break;
|
||||
default:
|
||||
db_printf("Unsupported address size for %s\n", typestr);
|
||||
return (EINVAL);
|
||||
}
|
||||
|
||||
if (is_bkpt) {
|
||||
cr_access = DBG_WB_CTRL_EXEC;
|
||||
reg_ctrl = DBG_REG_BASE_BCR;
|
||||
reg_addr = DBG_REG_BASE_BVR;
|
||||
/* Always unlinked BKPT */
|
||||
ctrl = (cr_size | cr_access | cr_priv | DBG_WB_CTRL_E);
|
||||
} else {
|
||||
switch(conf->access) {
|
||||
case HW_WATCHPOINT_R:
|
||||
cr_access = DBG_WB_CTRL_LOAD;
|
||||
break;
|
||||
case HW_WATCHPOINT_W:
|
||||
cr_access = DBG_WB_CTRL_STORE;
|
||||
break;
|
||||
case HW_WATCHPOINT_RW:
|
||||
cr_access = DBG_WB_CTRL_LOAD | DBG_WB_CTRL_STORE;
|
||||
break;
|
||||
default:
|
||||
db_printf("Unsupported exception level for %s\n", typestr);
|
||||
return (EINVAL);
|
||||
}
|
||||
|
||||
reg_ctrl = DBG_REG_BASE_WCR;
|
||||
reg_addr = DBG_REG_BASE_WVR;
|
||||
ctrl = (cr_size | cr_access | cr_priv | DBG_WB_CTRL_E);
|
||||
}
|
||||
|
||||
addr = conf->address;
|
||||
|
||||
dbg_wb_write_reg(reg_addr, i, addr);
|
||||
dbg_wb_write_reg(reg_ctrl, i, ctrl);
|
||||
|
||||
return (dbg_enable_monitor());
|
||||
}
|
||||
|
||||
static int
|
||||
dbg_remove_xpoint(struct dbg_wb_conf *conf)
|
||||
{
|
||||
uint32_t reg_ctrl, reg_addr, addr;
|
||||
u_int cpuid;
|
||||
u_int i;
|
||||
int err;
|
||||
|
||||
if (!dbg_capable)
|
||||
return (ENXIO);
|
||||
|
||||
cpuid = PCPU_GET(cpuid);
|
||||
if (!dbg_ready[cpuid]) {
|
||||
err = dbg_reset_state();
|
||||
if (err != 0)
|
||||
return (err);
|
||||
dbg_ready[cpuid] = TRUE;
|
||||
}
|
||||
|
||||
addr = conf->address;
|
||||
|
||||
if (conf->type == DBG_TYPE_BREAKPOINT) {
|
||||
i = conf->slot;
|
||||
reg_ctrl = DBG_REG_BASE_BCR;
|
||||
reg_addr = DBG_REG_BASE_BVR;
|
||||
} else {
|
||||
i = dbg_find_slot(DBG_TYPE_WATCHPOINT, addr);
|
||||
if (i == ~0U) {
|
||||
db_printf("Can not find watchpoint for address 0%x\n", addr);
|
||||
return (EINVAL);
|
||||
}
|
||||
reg_ctrl = DBG_REG_BASE_WCR;
|
||||
reg_addr = DBG_REG_BASE_WVR;
|
||||
}
|
||||
|
||||
dbg_wb_write_reg(reg_ctrl, i, 0);
|
||||
dbg_wb_write_reg(reg_addr, i, 0);
|
||||
|
||||
return (dbg_disable_monitor());
|
||||
}
|
||||
|
||||
static __inline uint32_t
|
||||
dbg_get_debug_model(void)
|
||||
{
|
||||
uint32_t dbg_m;
|
||||
|
||||
dbg_m = ((cpuinfo.id_dfr0 & ID_DFR0_CP_DEBUG_M_MASK) >>
|
||||
ID_DFR0_CP_DEBUG_M_SHIFT);
|
||||
|
||||
return (dbg_m);
|
||||
}
|
||||
|
||||
static __inline boolean_t
|
||||
dbg_get_ossr(void)
|
||||
{
|
||||
|
||||
switch (dbg_model) {
|
||||
case ID_DFR0_CP_DEBUG_M_V6_1:
|
||||
if ((cp14_dbgoslsr_get() & DBGOSLSR_OSLM0) != 0)
|
||||
return (TRUE);
|
||||
|
||||
return (FALSE);
|
||||
case ID_DFR0_CP_DEBUG_M_V7_1:
|
||||
return (TRUE);
|
||||
default:
|
||||
return (FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
static __inline boolean_t
|
||||
dbg_arch_supported(void)
|
||||
{
|
||||
|
||||
switch (dbg_model) {
|
||||
case ID_DFR0_CP_DEBUG_M_V6:
|
||||
case ID_DFR0_CP_DEBUG_M_V6_1:
|
||||
case ID_DFR0_CP_DEBUG_M_V7:
|
||||
case ID_DFR0_CP_DEBUG_M_V7_1: /* fall through */
|
||||
return (TRUE);
|
||||
default:
|
||||
/* We only support valid v6.x/v7.x modes through CP14 */
|
||||
return (FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
static __inline uint32_t
|
||||
dbg_get_wrp_num(void)
|
||||
{
|
||||
uint32_t dbg_didr;
|
||||
|
||||
dbg_didr = cp14_dbgdidr_get();
|
||||
|
||||
return (DBGDIDR_WRPS_NUM(dbg_didr));
|
||||
}
|
||||
|
||||
static __inline uint32_t
|
||||
dgb_get_brp_num(void)
|
||||
{
|
||||
uint32_t dbg_didr;
|
||||
|
||||
dbg_didr = cp14_dbgdidr_get();
|
||||
|
||||
return (DBGDIDR_BRPS_NUM(dbg_didr));
|
||||
}
|
||||
|
||||
static int
|
||||
dbg_reset_state(void)
|
||||
{
|
||||
u_int cpuid;
|
||||
size_t i;
|
||||
int err;
|
||||
|
||||
cpuid = PCPU_GET(cpuid);
|
||||
err = 0;
|
||||
|
||||
switch (dbg_model) {
|
||||
case ID_DFR0_CP_DEBUG_M_V6:
|
||||
/* v6 Debug logic reset upon power-up */
|
||||
return (0);
|
||||
case ID_DFR0_CP_DEBUG_M_V6_1:
|
||||
/* Is core power domain powered up? */
|
||||
if ((cp14_dbgprsr_get() & DBGPRSR_PU) == 0)
|
||||
err = ENXIO;
|
||||
|
||||
if (err != 0)
|
||||
break;
|
||||
|
||||
if (dbg_ossr)
|
||||
goto vectr_clr;
|
||||
break;
|
||||
case ID_DFR0_CP_DEBUG_M_V7:
|
||||
break;
|
||||
case ID_DFR0_CP_DEBUG_M_V7_1:
|
||||
/* Is double lock set? */
|
||||
if ((cp14_dbgosdlr_get() & DBGPRSR_DLK) != 0)
|
||||
err = ENXIO;
|
||||
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (err != 0) {
|
||||
db_printf("Debug facility locked (CPU%d)\n", cpuid);
|
||||
return (err);
|
||||
}
|
||||
|
||||
/*
|
||||
* DBGOSLAR is always implemented for v7.1 Debug Arch. however is
|
||||
* optional for v7 (depends on OS save and restore support).
|
||||
*/
|
||||
if (((dbg_model & ID_DFR0_CP_DEBUG_M_V7_1) != 0) || dbg_ossr) {
|
||||
/*
|
||||
* Clear OS lock.
|
||||
* Writing any other value than 0xC5ACCESS will unlock.
|
||||
*/
|
||||
cp14_dbgoslar_set(0);
|
||||
isb();
|
||||
}
|
||||
|
||||
vectr_clr:
|
||||
/*
|
||||
* After reset we must ensure that DBGVCR has a defined value.
|
||||
* Disable all vector catch events. Safe to use - required in all
|
||||
* implementations.
|
||||
*/
|
||||
cp14_dbgvcr_set(0);
|
||||
isb();
|
||||
|
||||
/*
|
||||
* We have limited number of {watch,break}points, each consists of
|
||||
* two registers:
|
||||
* - wcr/bcr regsiter configurates corresponding {watch,break}point
|
||||
* behaviour
|
||||
* - wvr/bvr register keeps address we are hunting for
|
||||
*
|
||||
* Reset all breakpoints and watchpoints.
|
||||
*/
|
||||
for (i = 0; i < dbg_watchpoint_num; ++i) {
|
||||
dbg_wb_write_reg(DBG_REG_BASE_WCR, i, 0);
|
||||
dbg_wb_write_reg(DBG_REG_BASE_WVR, i, 0);
|
||||
}
|
||||
|
||||
for (i = 0; i < dbg_breakpoint_num; ++i) {
|
||||
dbg_wb_write_reg(DBG_REG_BASE_BCR, i, 0);
|
||||
dbg_wb_write_reg(DBG_REG_BASE_BVR, i, 0);
|
||||
}
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
void
|
||||
dbg_monitor_init(void)
|
||||
{
|
||||
int err;
|
||||
|
||||
/* Fetch ARM Debug Architecture model */
|
||||
dbg_model = dbg_get_debug_model();
|
||||
|
||||
if (!dbg_arch_supported()) {
|
||||
db_printf("ARM Debug Architecture not supported\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if (bootverbose) {
|
||||
db_printf("ARM Debug Architecture %s\n",
|
||||
(dbg_model == ID_DFR0_CP_DEBUG_M_V6) ? "v6" :
|
||||
(dbg_model == ID_DFR0_CP_DEBUG_M_V6_1) ? "v6.1" :
|
||||
(dbg_model == ID_DFR0_CP_DEBUG_M_V7) ? "v7" :
|
||||
(dbg_model == ID_DFR0_CP_DEBUG_M_V7_1) ? "v7.1" : "unknown");
|
||||
}
|
||||
|
||||
/* Do we have OS Save and Restore mechanism? */
|
||||
dbg_ossr = dbg_get_ossr();
|
||||
|
||||
/* Find out many breakpoints and watchpoints we can use */
|
||||
dbg_watchpoint_num = dbg_get_wrp_num();
|
||||
dbg_breakpoint_num = dgb_get_brp_num();
|
||||
|
||||
if (bootverbose) {
|
||||
db_printf("%d watchpoints and %d breakpoints supported\n",
|
||||
dbg_watchpoint_num, dbg_breakpoint_num);
|
||||
}
|
||||
|
||||
err = dbg_reset_state();
|
||||
if (err == 0) {
|
||||
dbg_capable = TRUE;
|
||||
return;
|
||||
}
|
||||
|
||||
db_printf("HW Breakpoints/Watchpoints not enabled on CPU%d\n",
|
||||
PCPU_GET(cpuid));
|
||||
}
|
@ -96,6 +96,7 @@ __FBSDID("$FreeBSD$");
|
||||
#include <machine/atags.h>
|
||||
#include <machine/cpu.h>
|
||||
#include <machine/cpuinfo.h>
|
||||
#include <machine/debug_monitor.h>
|
||||
#include <machine/db_machdep.h>
|
||||
#include <machine/devmap.h>
|
||||
#include <machine/frame.h>
|
||||
@ -1710,6 +1711,7 @@ initarm(struct arm_boot_params *abp)
|
||||
arm_physmem_init_kernel_globals();
|
||||
|
||||
init_param2(physmem);
|
||||
dbg_monitor_init();
|
||||
kdb_init();
|
||||
|
||||
return ((void *)(kernelstack.pv_va + USPACE_SVC_STACK_TOP -
|
||||
@ -1897,6 +1899,7 @@ initarm(struct arm_boot_params *abp)
|
||||
init_param2(physmem);
|
||||
/* Init message buffer. */
|
||||
msgbufinit(msgbufp, msgbufsize);
|
||||
dbg_monitor_init();
|
||||
kdb_init();
|
||||
return ((void *)STACKALIGN(thread0.td_pcb));
|
||||
|
||||
|
@ -82,7 +82,7 @@ static int nexus_attach(device_t);
|
||||
static int nexus_print_child(device_t, device_t);
|
||||
static device_t nexus_add_child(device_t, u_int, const char *, int);
|
||||
static struct resource *nexus_alloc_resource(device_t, device_t, int, int *,
|
||||
u_long, u_long, u_long, u_int);
|
||||
rman_res_t, rman_res_t, rman_res_t, u_int);
|
||||
static int nexus_activate_resource(device_t, device_t, int, int,
|
||||
struct resource *);
|
||||
#ifdef ARM_INTRNG
|
||||
@ -212,7 +212,7 @@ nexus_add_child(device_t bus, u_int order, const char *name, int unit)
|
||||
*/
|
||||
static struct resource *
|
||||
nexus_alloc_resource(device_t bus, device_t child, int type, int *rid,
|
||||
u_long start, u_long end, u_long count, u_int flags)
|
||||
rman_res_t start, rman_res_t end, rman_res_t count, u_int flags)
|
||||
{
|
||||
struct resource *rv;
|
||||
struct rman *rm;
|
||||
|
@ -49,6 +49,8 @@ __FBSDID("$FreeBSD$");
|
||||
#define MAX_HWCNT 10
|
||||
#define MAX_EXCNT 10
|
||||
|
||||
#define MAX_PHYS_ADDR 0xFFFFFFFFull
|
||||
|
||||
struct region {
|
||||
vm_paddr_t addr;
|
||||
vm_size_t size;
|
||||
@ -273,14 +275,25 @@ insert_region(struct region *regions, size_t rcnt, vm_paddr_t addr,
|
||||
* Add a hardware memory region.
|
||||
*/
|
||||
void
|
||||
arm_physmem_hardware_region(vm_paddr_t pa, vm_size_t sz)
|
||||
arm_physmem_hardware_region(uint64_t pa, uint64_t sz)
|
||||
{
|
||||
vm_offset_t adj;
|
||||
|
||||
/*
|
||||
* Filter out the page at PA 0x00000000. The VM can't handle it, as
|
||||
* pmap_extract() == 0 means failure.
|
||||
*
|
||||
*/
|
||||
if (pa == 0) {
|
||||
if (sz <= PAGE_SIZE)
|
||||
return;
|
||||
pa = PAGE_SIZE;
|
||||
sz -= PAGE_SIZE;
|
||||
} else if (pa > MAX_PHYS_ADDR) {
|
||||
/* This range is past usable memory, ignore it */
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* Also filter out the page at the end of the physical address space --
|
||||
* if addr is non-zero and addr+size is zero we wrapped to the next byte
|
||||
* beyond what vm_paddr_t can express. That leads to a NULL pointer
|
||||
@ -291,12 +304,8 @@ arm_physmem_hardware_region(vm_paddr_t pa, vm_size_t sz)
|
||||
* pointer deref in _vm_map_lock_read(). Better to give up a megabyte
|
||||
* than leave some folks with an unusable system while we investigate.
|
||||
*/
|
||||
if (pa == 0) {
|
||||
if (sz <= PAGE_SIZE)
|
||||
return;
|
||||
pa = PAGE_SIZE;
|
||||
sz -= PAGE_SIZE;
|
||||
} else if (pa + sz == 0) {
|
||||
if ((pa + sz) > (MAX_PHYS_ADDR - 1024 * 1024)) {
|
||||
sz = MAX_PHYS_ADDR - pa + 1;
|
||||
if (sz <= 1024 * 1024)
|
||||
return;
|
||||
sz -= 1024 * 1024;
|
||||
|
@ -3799,14 +3799,19 @@ pmap_enter(pmap_t pmap, vm_offset_t va, vm_page_t m, vm_prot_t prot,
|
||||
* is set. Do it now, before the mapping is stored and made
|
||||
* valid for hardware table walk. If done later, there is a race
|
||||
* for other threads of current process in lazy loading case.
|
||||
* Don't do it for kernel memory which is mapped with exec
|
||||
* permission even if the memory isn't going to hold executable
|
||||
* code. The only time when icache sync is needed is after
|
||||
* kernel module is loaded and the relocation info is processed.
|
||||
* And it's done in elf_cpu_load_file().
|
||||
*
|
||||
* QQQ: (1) Does it exist any better way where
|
||||
* or how to sync icache?
|
||||
* (2) Now, we do it on a page basis.
|
||||
*/
|
||||
if ((prot & VM_PROT_EXECUTE) &&
|
||||
(m->md.pat_mode == PTE2_ATTR_WB_WA) &&
|
||||
((opa != pa) || (opte2 & PTE2_NX)))
|
||||
if ((prot & VM_PROT_EXECUTE) && pmap != kernel_pmap &&
|
||||
m->md.pat_mode == PTE2_ATTR_WB_WA &&
|
||||
(opa != pa || (opte2 & PTE2_NX)))
|
||||
cache_icache_sync_fresh(va, pa, PAGE_SIZE);
|
||||
|
||||
npte2 |= PTE2_A;
|
||||
@ -4405,7 +4410,7 @@ pmap_enter_quick_locked(pmap_t pmap, vm_offset_t va, vm_page_t m,
|
||||
l2prot |= PTE2_U | PTE2_NG;
|
||||
if ((prot & VM_PROT_EXECUTE) == 0)
|
||||
l2prot |= PTE2_NX;
|
||||
else if (m->md.pat_mode == PTE2_ATTR_WB_WA) {
|
||||
else if (m->md.pat_mode == PTE2_ATTR_WB_WA && pmap != kernel_pmap) {
|
||||
/*
|
||||
* Sync icache if exec permission and attribute PTE2_ATTR_WB_WA
|
||||
* is set. QQQ: For more info, see comments in pmap_enter().
|
||||
@ -4476,7 +4481,7 @@ pmap_enter_pte1(pmap_t pmap, vm_offset_t va, vm_page_t m, vm_prot_t prot)
|
||||
l1prot |= PTE1_U | PTE1_NG;
|
||||
if ((prot & VM_PROT_EXECUTE) == 0)
|
||||
l1prot |= PTE1_NX;
|
||||
else if (m->md.pat_mode == PTE2_ATTR_WB_WA) {
|
||||
else if (m->md.pat_mode == PTE2_ATTR_WB_WA && pmap != kernel_pmap) {
|
||||
/*
|
||||
* Sync icache if exec permission and attribute PTE2_ATTR_WB_WA
|
||||
* is set. QQQ: For more info, see comments in pmap_enter().
|
||||
@ -6146,7 +6151,7 @@ pmap_fault(pmap_t pmap, vm_offset_t far, uint32_t fsr, int idx, bool usermode)
|
||||
__func__, pmap, pmap->pm_pt1, far);
|
||||
panic("%s: pm_pt1 abort", __func__);
|
||||
}
|
||||
return (EFAULT);
|
||||
return (KERN_INVALID_ADDRESS);
|
||||
}
|
||||
if (__predict_false(IN_RANGE2(far, PT2MAP, PT2MAP_SIZE))) {
|
||||
/*
|
||||
@ -6162,7 +6167,7 @@ pmap_fault(pmap_t pmap, vm_offset_t far, uint32_t fsr, int idx, bool usermode)
|
||||
__func__, pmap, PT2MAP, far);
|
||||
panic("%s: PT2MAP abort", __func__);
|
||||
}
|
||||
return (EFAULT);
|
||||
return (KERN_INVALID_ADDRESS);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -6182,7 +6187,7 @@ pmap_fault(pmap_t pmap, vm_offset_t far, uint32_t fsr, int idx, bool usermode)
|
||||
if (!pte2_cmpset(pte2p, pte2, pte2 | PTE2_A)) {
|
||||
goto pte2_seta;
|
||||
}
|
||||
return (0);
|
||||
return (KERN_SUCCESS);
|
||||
}
|
||||
}
|
||||
if (idx == FAULT_ACCESS_L1) {
|
||||
@ -6193,7 +6198,7 @@ pmap_fault(pmap_t pmap, vm_offset_t far, uint32_t fsr, int idx, bool usermode)
|
||||
if (!pte1_cmpset(pte1p, pte1, pte1 | PTE1_A)) {
|
||||
goto pte1_seta;
|
||||
}
|
||||
return (0);
|
||||
return (KERN_SUCCESS);
|
||||
}
|
||||
}
|
||||
|
||||
@ -6217,7 +6222,7 @@ pmap_fault(pmap_t pmap, vm_offset_t far, uint32_t fsr, int idx, bool usermode)
|
||||
goto pte2_setrw;
|
||||
}
|
||||
tlb_flush(trunc_page(far));
|
||||
return (0);
|
||||
return (KERN_SUCCESS);
|
||||
}
|
||||
}
|
||||
if ((fsr & FSR_WNR) && (idx == FAULT_PERM_L1)) {
|
||||
@ -6230,7 +6235,7 @@ pmap_fault(pmap_t pmap, vm_offset_t far, uint32_t fsr, int idx, bool usermode)
|
||||
goto pte1_setrw;
|
||||
}
|
||||
tlb_flush(pte1_trunc(far));
|
||||
return (0);
|
||||
return (KERN_SUCCESS);
|
||||
}
|
||||
}
|
||||
|
||||
@ -6269,7 +6274,7 @@ pmap_fault(pmap_t pmap, vm_offset_t far, uint32_t fsr, int idx, bool usermode)
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return (EAGAIN);
|
||||
return (KERN_FAILURE);
|
||||
}
|
||||
|
||||
/* !!!! REMOVE !!!! */
|
||||
|
@ -3446,14 +3446,10 @@ pmap_extract_locked(pmap_t pmap, vm_offset_t va)
|
||||
pte = ptep[l2pte_index(va)];
|
||||
if (pte == 0)
|
||||
return (0);
|
||||
switch (pte & L2_TYPE_MASK) {
|
||||
case L2_TYPE_L:
|
||||
if ((pte & L2_TYPE_MASK) == L2_TYPE_L)
|
||||
pa = (pte & L2_L_FRAME) | (va & L2_L_OFFSET);
|
||||
break;
|
||||
default:
|
||||
else
|
||||
pa = (pte & L2_S_FRAME) | (va & L2_S_OFFSET);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return (pa);
|
||||
}
|
||||
@ -3515,20 +3511,15 @@ pmap_extract_and_hold(pmap_t pmap, vm_offset_t va, vm_prot_t prot)
|
||||
PMAP_UNLOCK(pmap);
|
||||
return (NULL);
|
||||
} else {
|
||||
switch (pte & L2_TYPE_MASK) {
|
||||
case L2_TYPE_L:
|
||||
if ((pte & L2_TYPE_MASK) == L2_TYPE_L)
|
||||
panic("extract and hold section mapping");
|
||||
break;
|
||||
default:
|
||||
else
|
||||
pa = (pte & L2_S_FRAME) | (va & L2_S_OFFSET);
|
||||
break;
|
||||
}
|
||||
if (vm_page_pa_tryrelock(pmap, pa & PG_FRAME, &paddr))
|
||||
goto retry;
|
||||
m = PHYS_TO_VM_PAGE(pa);
|
||||
vm_page_hold(m);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
PMAP_UNLOCK(pmap);
|
||||
@ -3567,14 +3558,10 @@ pmap_dump_kextract(vm_offset_t va, pt2_entry_t *pte2p)
|
||||
pa = 0;
|
||||
goto out;
|
||||
}
|
||||
switch (pte & L2_TYPE_MASK) {
|
||||
case L2_TYPE_L:
|
||||
if ((pte & L2_TYPE_MASK) == L2_TYPE_L)
|
||||
pa = (pte & L2_L_FRAME) | (va & L2_L_OFFSET);
|
||||
break;
|
||||
default:
|
||||
else
|
||||
pa = (pte & L2_S_FRAME) | (va & L2_S_OFFSET);
|
||||
break;
|
||||
}
|
||||
}
|
||||
out:
|
||||
if (pte2p != NULL)
|
||||
|
@ -2787,18 +2787,14 @@ pmap_kremove(vm_offset_t va)
|
||||
pte = &l2b->l2b_kva[l2pte_index(va)];
|
||||
opte = *pte;
|
||||
if (l2pte_valid(opte)) {
|
||||
/* pa = vtophs(va) taken from pmap_extract() */
|
||||
switch (opte & L2_TYPE_MASK) {
|
||||
case L2_TYPE_L:
|
||||
/* pa = vtophs(va) taken from pmap_extract() */
|
||||
if ((opte & L2_TYPE_MASK) == L2_TYPE_L)
|
||||
pa = (opte & L2_L_FRAME) | (va & L2_L_OFFSET);
|
||||
break;
|
||||
default:
|
||||
else
|
||||
pa = (opte & L2_S_FRAME) | (va & L2_S_OFFSET);
|
||||
break;
|
||||
}
|
||||
/* note: should never have to remove an allocation
|
||||
* before the pvzone is initialized.
|
||||
*/
|
||||
/* note: should never have to remove an allocation
|
||||
* before the pvzone is initialized.
|
||||
*/
|
||||
rw_wlock(&pvh_global_lock);
|
||||
PMAP_LOCK(pmap_kernel());
|
||||
if (pvzone != NULL && (m = vm_phys_paddr_to_vm_page(pa)) &&
|
||||
@ -3645,14 +3641,10 @@ pmap_extract_locked(pmap_t pmap, vm_offset_t va)
|
||||
pte = ptep[l2pte_index(va)];
|
||||
if (pte == 0)
|
||||
return (0);
|
||||
switch (pte & L2_TYPE_MASK) {
|
||||
case L2_TYPE_L:
|
||||
if ((pte & L2_TYPE_MASK) == L2_TYPE_L)
|
||||
pa = (pte & L2_L_FRAME) | (va & L2_L_OFFSET);
|
||||
break;
|
||||
default:
|
||||
else
|
||||
pa = (pte & L2_S_FRAME) | (va & L2_S_OFFSET);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return (pa);
|
||||
}
|
||||
@ -3717,15 +3709,10 @@ pmap_extract_and_hold(pmap_t pmap, vm_offset_t va, vm_prot_t prot)
|
||||
return (NULL);
|
||||
}
|
||||
if (pte & L2_S_PROT_W || (prot & VM_PROT_WRITE) == 0) {
|
||||
switch (pte & L2_TYPE_MASK) {
|
||||
case L2_TYPE_L:
|
||||
if ((pte & L2_TYPE_MASK) == L2_TYPE_L)
|
||||
pa = (pte & L2_L_FRAME) | (va & L2_L_OFFSET);
|
||||
break;
|
||||
|
||||
default:
|
||||
else
|
||||
pa = (pte & L2_S_FRAME) | (va & L2_S_OFFSET);
|
||||
break;
|
||||
}
|
||||
if (vm_page_pa_tryrelock(pmap, pa & PG_FRAME, &paddr))
|
||||
goto retry;
|
||||
m = PHYS_TO_VM_PAGE(pa);
|
||||
@ -3769,14 +3756,10 @@ pmap_dump_kextract(vm_offset_t va, pt2_entry_t *pte2p)
|
||||
pa = 0;
|
||||
goto out;
|
||||
}
|
||||
switch (pte & L2_TYPE_MASK) {
|
||||
case L2_TYPE_L:
|
||||
if ((pte & L2_TYPE_MASK) == L2_TYPE_L)
|
||||
pa = (pte & L2_L_FRAME) | (va & L2_L_OFFSET);
|
||||
break;
|
||||
default:
|
||||
else
|
||||
pa = (pte & L2_S_FRAME) | (va & L2_S_OFFSET);
|
||||
break;
|
||||
}
|
||||
}
|
||||
out:
|
||||
if (pte2p != NULL)
|
||||
|
@ -259,7 +259,7 @@ abort_debug(struct trapframe *tf, u_int fsr, u_int prefetch, bool usermode,
|
||||
userret(td, tf);
|
||||
} else {
|
||||
#ifdef KDB
|
||||
kdb_trap(T_BREAKPOINT, 0, tf);
|
||||
kdb_trap((prefetch) ? T_BREAKPOINT : T_WATCHPOINT, 0, tf);
|
||||
#else
|
||||
printf("No debugger in kernel.\n");
|
||||
#endif
|
||||
@ -336,14 +336,10 @@ abort_handler(struct trapframe *tf, int prefetch)
|
||||
|
||||
#ifdef ARM_NEW_PMAP
|
||||
rv = pmap_fault(PCPU_GET(curpmap), far, fsr, idx, usermode);
|
||||
if (rv == 0) {
|
||||
if (rv == KERN_SUCCESS)
|
||||
return;
|
||||
} else if (rv == EFAULT) {
|
||||
|
||||
call_trapsignal(td, SIGSEGV, SEGV_MAPERR, far);
|
||||
userret(td, tf);
|
||||
return;
|
||||
}
|
||||
if (rv == KERN_INVALID_ADDRESS)
|
||||
goto nogo;
|
||||
#endif
|
||||
/*
|
||||
* Now, when we handled imprecise and debug aborts, the rest of
|
||||
@ -452,7 +448,6 @@ abort_handler(struct trapframe *tf, int prefetch)
|
||||
*/
|
||||
|
||||
/* fusubailout is used by [fs]uswintr to avoid page faulting. */
|
||||
pcb = td->td_pcb;
|
||||
if (__predict_false(pcb->pcb_onfault == fusubailout)) {
|
||||
tf->tf_r0 = EFAULT;
|
||||
tf->tf_pc = (register_t)pcb->pcb_onfault;
|
||||
|
@ -147,7 +147,7 @@ at91_attach(device_t dev)
|
||||
|
||||
static struct resource *
|
||||
at91_alloc_resource(device_t dev, device_t child, int type, int *rid,
|
||||
u_long start, u_long end, u_long count, u_int flags)
|
||||
rman_res_t start, rman_res_t end, rman_res_t count, u_int flags)
|
||||
{
|
||||
struct at91_softc *sc = device_get_softc(dev);
|
||||
struct resource_list_entry *rle;
|
||||
@ -255,7 +255,7 @@ at91_activate_resource(device_t bus, device_t child, int type, int rid,
|
||||
struct resource *r)
|
||||
{
|
||||
#if 0
|
||||
u_long p;
|
||||
rman_res_t p;
|
||||
int error;
|
||||
|
||||
if (type == SYS_RES_MEMORY) {
|
||||
|
@ -408,7 +408,7 @@ econa_attach(device_t dev)
|
||||
|
||||
static struct resource *
|
||||
econa_alloc_resource(device_t dev, device_t child, int type, int *rid,
|
||||
u_long start, u_long end, u_long count, u_int flags)
|
||||
rman_res_t start, rman_res_t end, rman_res_t count, u_int flags)
|
||||
{
|
||||
struct econa_softc *sc = device_get_softc(dev);
|
||||
struct resource_list_entry *rle;
|
||||
|
@ -138,6 +138,18 @@ _WF1(_CP15_ICIMVAU, CP15_ICIMVAU(%0)) /* Instruction cache invalidate */
|
||||
* Publicly accessible functions
|
||||
*/
|
||||
|
||||
/* CP14 Debug Registers */
|
||||
_RF0(cp14_dbgdidr_get, CP14_DBGDIDR(%0))
|
||||
_RF0(cp14_dbgprsr_get, CP14_DBGPRSR(%0))
|
||||
_RF0(cp14_dbgoslsr_get, CP14_DBGOSLSR(%0))
|
||||
_RF0(cp14_dbgosdlr_get, CP14_DBGOSDLR(%0))
|
||||
_RF0(cp14_dbgdscrint_get, CP14_DBGDSCRint(%0))
|
||||
|
||||
_WF1(cp14_dbgdscr_v6_set, CP14_DBGDSCRext_V6(%0))
|
||||
_WF1(cp14_dbgdscr_v7_set, CP14_DBGDSCRext_V7(%0))
|
||||
_WF1(cp14_dbgvcr_set, CP14_DBGVCR(%0))
|
||||
_WF1(cp14_dbgoslar_set, CP14_DBGOSLAR(%0))
|
||||
|
||||
/* Various control registers */
|
||||
|
||||
_RF0(cp15_cpacr_get, CP15_CPACR(%0))
|
||||
|
@ -33,8 +33,10 @@
|
||||
#include <machine/frame.h>
|
||||
#include <machine/trap.h>
|
||||
#include <machine/armreg.h>
|
||||
#include <machine/acle-compat.h>
|
||||
|
||||
#define T_BREAKPOINT (1)
|
||||
#define T_WATCHPOINT (2)
|
||||
typedef vm_offset_t db_addr_t;
|
||||
typedef int db_expr_t;
|
||||
|
||||
@ -48,11 +50,16 @@ typedef int db_expr_t;
|
||||
kdb_frame->tf_pc += BKPT_SIZE; \
|
||||
} while (0)
|
||||
|
||||
#define SOFTWARE_SSTEP 1
|
||||
#if __ARM_ARCH >= 6
|
||||
#define db_clear_single_step kdb_cpu_clear_singlestep
|
||||
#define db_set_single_step kdb_cpu_set_singlestep
|
||||
#define db_pc_is_singlestep kdb_cpu_pc_is_singlestep
|
||||
#else
|
||||
#define SOFTWARE_SSTEP 1
|
||||
#endif
|
||||
|
||||
#define IS_BREAKPOINT_TRAP(type, code) (type == T_BREAKPOINT)
|
||||
#define IS_WATCHPOINT_TRAP(type, code) (0)
|
||||
|
||||
#define IS_WATCHPOINT_TRAP(type, code) (type == T_WATCHPOINT)
|
||||
|
||||
#define inst_trap_return(ins) (0)
|
||||
/* ldmxx reg, {..., pc}
|
||||
|
80
sys/arm/include/debug_monitor.h
Normal file
80
sys/arm/include/debug_monitor.h
Normal file
@ -0,0 +1,80 @@
|
||||
/*-
|
||||
* Copyright (c) 2014 The FreeBSD Foundation
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software was developed by Semihalf under
|
||||
* the sponsorship of the FreeBSD Foundation.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
#ifndef _MACHINE_DEBUG_MONITOR_H_
|
||||
#define _MACHINE_DEBUG_MONITOR_H_
|
||||
|
||||
#ifdef DDB
|
||||
|
||||
#include <machine/db_machdep.h>
|
||||
|
||||
enum dbg_access_t {
|
||||
HW_BREAKPOINT_X = 0,
|
||||
HW_WATCHPOINT_R = 1,
|
||||
HW_WATCHPOINT_W = 2,
|
||||
HW_WATCHPOINT_RW = HW_WATCHPOINT_R | HW_WATCHPOINT_W,
|
||||
};
|
||||
|
||||
#if __ARM_ARCH >= 6
|
||||
void dbg_monitor_init(void);
|
||||
void dbg_show_watchpoint(void);
|
||||
int dbg_setup_watchpoint(db_expr_t, db_expr_t, enum dbg_access_t);
|
||||
int dbg_remove_watchpoint(db_expr_t, db_expr_t);
|
||||
#else /* __ARM_ARCH >= 6 */
|
||||
static __inline void
|
||||
dbg_show_watchpoint(void)
|
||||
{
|
||||
}
|
||||
static __inline int
|
||||
dbg_setup_watchpoint(db_expr_t addr __unused, db_expr_t size __unused,
|
||||
enum dbg_access_t access __unused)
|
||||
{
|
||||
return (ENXIO);
|
||||
}
|
||||
static __inline int
|
||||
dbg_remove_watchpoint(db_expr_t addr __unused, db_expr_t size __unused)
|
||||
{
|
||||
return (ENXIO);
|
||||
}
|
||||
static __inline void
|
||||
dbg_monitor_init(void)
|
||||
{
|
||||
}
|
||||
#endif /* __ARM_ARCH < 6 */
|
||||
|
||||
#else /* DDB */
|
||||
static __inline void
|
||||
dbg_monitor_init(void)
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _MACHINE_DEBUG_MONITOR_H_ */
|
@ -32,9 +32,15 @@
|
||||
#include <machine/frame.h>
|
||||
#include <machine/psl.h>
|
||||
#include <machine/cpufunc.h>
|
||||
#include <machine/db_machdep.h>
|
||||
|
||||
#define KDB_STOPPEDPCB(pc) &stoppcbs[pc->pc_cpuid]
|
||||
|
||||
#if __ARM_ARCH >= 6
|
||||
extern void kdb_cpu_clear_singlestep(void);
|
||||
extern void kdb_cpu_set_singlestep(void);
|
||||
boolean_t kdb_cpu_pc_is_singlestep(db_addr_t);
|
||||
#else
|
||||
static __inline void
|
||||
kdb_cpu_clear_singlestep(void)
|
||||
{
|
||||
@ -44,6 +50,7 @@ static __inline void
|
||||
kdb_cpu_set_singlestep(void)
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
static __inline void
|
||||
kdb_cpu_sync_icache(unsigned char *addr, size_t size)
|
||||
|
@ -40,8 +40,8 @@
|
||||
typedef uint32_t cell_t;
|
||||
|
||||
struct mem_region {
|
||||
vm_offset_t mr_start;
|
||||
vm_size_t mr_size;
|
||||
uint64_t mr_start;
|
||||
uint64_t mr_size;
|
||||
};
|
||||
|
||||
#endif /* _MACHINE_OFW_MACHDEP_H_ */
|
||||
|
@ -52,7 +52,7 @@ extern vm_paddr_t arm_physmem_kernaddr;
|
||||
#define EXFLAG_NODUMP 0x01
|
||||
#define EXFLAG_NOALLOC 0x02
|
||||
|
||||
void arm_physmem_hardware_region(vm_paddr_t pa, vm_size_t sz);
|
||||
void arm_physmem_hardware_region(uint64_t pa, uint64_t sz);
|
||||
void arm_physmem_exclude_region(vm_paddr_t pa, vm_size_t sz, uint32_t flags);
|
||||
void arm_physmem_init_kernel_globals(void);
|
||||
void arm_physmem_print_tables(void);
|
||||
|
@ -41,6 +41,24 @@
|
||||
|
||||
#include <machine/acle-compat.h>
|
||||
|
||||
/*
|
||||
* CP14 registers
|
||||
*/
|
||||
#if __ARM_ARCH >= 6
|
||||
|
||||
#define CP14_DBGDIDR(rr) p14, 0, rr, c0, c0, 0 /* Debug ID Register */
|
||||
#define CP14_DBGDSCRext_V6(rr) p14, 0, rr, c0, c1, 0 /* Debug Status and Ctrl Register v6 */
|
||||
#define CP14_DBGDSCRext_V7(rr) p14, 0, rr, c0, c2, 2 /* Debug Status and Ctrl Register v7 */
|
||||
#define CP14_DBGVCR(rr) p14, 0, rr, c0, c7, 0 /* Vector Catch Register */
|
||||
#define CP14_DBGOSLAR(rr) p14, 0, rr, c1, c0, 4 /* OS Lock Access Register */
|
||||
#define CP14_DBGOSLSR(rr) p14, 0, rr, c1, c1, 4 /* OS Lock Status Register */
|
||||
#define CP14_DBGOSDLR(rr) p14, 0, rr, c1, c3, 4 /* OS Double Lock Register */
|
||||
#define CP14_DBGPRSR(rr) p14, 0, rr, c1, c5, 4 /* Device Powerdown and Reset Status */
|
||||
|
||||
#define CP14_DBGDSCRint(rr) CP14_DBGDSCRext_V6(rr) /* Debug Status and Ctrl internal view */
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
* CP15 C0 registers
|
||||
*/
|
||||
|
@ -100,7 +100,7 @@ static int localbus_attach(device_t);
|
||||
static int localbus_print_child(device_t, device_t);
|
||||
|
||||
static struct resource *localbus_alloc_resource(device_t, device_t, int,
|
||||
int *, u_long, u_long, u_long, u_int);
|
||||
int *, rman_res_t, rman_res_t, rman_res_t, u_int);
|
||||
static struct resource_list *localbus_get_resource_list(device_t, device_t);
|
||||
|
||||
static ofw_bus_get_devinfo_t localbus_get_devinfo;
|
||||
@ -332,7 +332,7 @@ localbus_print_child(device_t dev, device_t child)
|
||||
|
||||
static struct resource *
|
||||
localbus_alloc_resource(device_t bus, device_t child, int type, int *rid,
|
||||
u_long start, u_long end, u_long count, u_int flags)
|
||||
rman_res_t start, rman_res_t end, rman_res_t count, u_int flags)
|
||||
{
|
||||
struct localbus_devinfo *di;
|
||||
struct resource_list_entry *rle;
|
||||
|
@ -332,7 +332,7 @@ static int mv_pcib_probe(device_t);
|
||||
static int mv_pcib_attach(device_t);
|
||||
|
||||
static struct resource *mv_pcib_alloc_resource(device_t, device_t, int, int *,
|
||||
u_long, u_long, u_long, u_int);
|
||||
rman_res_t, rman_res_t, rman_res_t, u_int);
|
||||
static int mv_pcib_release_resource(device_t, device_t, int, int,
|
||||
struct resource *);
|
||||
static int mv_pcib_read_ivar(device_t, device_t, int, uintptr_t *);
|
||||
@ -830,7 +830,7 @@ mv_pcib_init_all_bars(struct mv_pcib_softc *sc, int bus, int slot,
|
||||
|
||||
static struct resource *
|
||||
mv_pcib_alloc_resource(device_t dev, device_t child, int type, int *rid,
|
||||
u_long start, u_long end, u_long count, u_int flags)
|
||||
rman_res_t start, rman_res_t end, rman_res_t count, u_int flags)
|
||||
{
|
||||
struct mv_pcib_softc *sc = device_get_softc(dev);
|
||||
struct rman *rm = NULL;
|
||||
|
@ -305,7 +305,7 @@ versatile_pci_write_ivar(device_t dev, device_t child, int which,
|
||||
|
||||
static struct resource *
|
||||
versatile_pci_alloc_resource(device_t bus, device_t child, int type, int *rid,
|
||||
u_long start, u_long end, u_long count, u_int flags)
|
||||
rman_res_t start, rman_res_t end, rman_res_t count, u_int flags)
|
||||
{
|
||||
|
||||
struct versatile_pci_softc *sc = device_get_softc(bus);
|
||||
|
@ -409,7 +409,7 @@ i81342_attach(device_t dev)
|
||||
|
||||
static struct resource *
|
||||
i81342_alloc_resource(device_t dev, device_t child, int type, int *rid,
|
||||
u_long start, u_long end, u_long count, u_int flags)
|
||||
rman_res_t start, rman_res_t end, rman_res_t count, u_int flags)
|
||||
{
|
||||
struct i81342_softc *sc = device_get_softc(dev);
|
||||
struct resource *rv;
|
||||
|
@ -328,7 +328,7 @@ i81342_pci_write_config(device_t dev, u_int bus, u_int slot, u_int func,
|
||||
|
||||
static struct resource *
|
||||
i81342_pci_alloc_resource(device_t bus, device_t child, int type, int *rid,
|
||||
u_long start, u_long end, u_long count, u_int flags)
|
||||
rman_res_t start, rman_res_t end, rman_res_t count, u_int flags)
|
||||
{
|
||||
struct i81342_pci_softc *sc = device_get_softc(bus);
|
||||
struct resource *rv;
|
||||
@ -383,7 +383,7 @@ static int
|
||||
i81342_pci_activate_resource(device_t bus, device_t child, int type, int rid,
|
||||
struct resource *r)
|
||||
{
|
||||
u_long p;
|
||||
bus_space_handle_t p;
|
||||
int error;
|
||||
|
||||
if (type == SYS_RES_MEMORY) {
|
||||
|
@ -91,7 +91,7 @@ obio_attach(device_t dev)
|
||||
|
||||
static struct resource *
|
||||
obio_alloc_resource(device_t bus, device_t child, int type, int *rid,
|
||||
u_long start, u_long end, u_long count, u_int flags)
|
||||
rman_res_t start, rman_res_t end, rman_res_t count, u_int flags)
|
||||
{
|
||||
struct resource *rv;
|
||||
struct rman *rm;
|
||||
|
@ -282,7 +282,7 @@ ata_avila_intr(void *xsc)
|
||||
|
||||
static struct resource *
|
||||
ata_avila_alloc_resource(device_t dev, device_t child, int type, int *rid,
|
||||
u_long start, u_long end, u_long count, u_int flags)
|
||||
rman_res_t start, rman_res_t end, rman_res_t count, u_int flags)
|
||||
{
|
||||
struct ata_avila_softc *sc = device_get_softc(dev);
|
||||
|
||||
|
@ -496,7 +496,7 @@ getvbase(uint32_t hwbase, uint32_t size, uint32_t *vbase)
|
||||
|
||||
static struct resource *
|
||||
ixp425_alloc_resource(device_t dev, device_t child, int type, int *rid,
|
||||
u_long start, u_long end, u_long count, u_int flags)
|
||||
rman_res_t start, rman_res_t end, rman_res_t count, u_int flags)
|
||||
{
|
||||
struct ixp425_softc *sc = device_get_softc(dev);
|
||||
const struct hwvtrans *vtrans;
|
||||
|
@ -269,7 +269,7 @@ ixppcib_teardown_intr(device_t dev, device_t child, struct resource *vec,
|
||||
|
||||
static struct resource *
|
||||
ixppcib_alloc_resource(device_t bus, device_t child, int type, int *rid,
|
||||
u_long start, u_long end, u_long count, u_int flags)
|
||||
rman_res_t start, rman_res_t end, rman_res_t count, u_int flags)
|
||||
{
|
||||
struct ixppcib_softc *sc = device_get_softc(bus);
|
||||
struct rman *rmanp;
|
||||
|
@ -50,14 +50,14 @@ static int pxa_read_ivar(device_t, device_t, int, uintptr_t *);
|
||||
|
||||
static struct resource_list * pxa_get_resource_list(device_t, device_t);
|
||||
static struct resource * pxa_alloc_resource(device_t, device_t, int,
|
||||
int *, u_long, u_long, u_long, u_int);
|
||||
int *, rman_res_t, rman_res_t, rman_res_t, u_int);
|
||||
static int pxa_release_resource(device_t, device_t, int,
|
||||
int, struct resource *);
|
||||
static int pxa_activate_resource(device_t, device_t,
|
||||
int, int, struct resource *);
|
||||
|
||||
static struct resource * pxa_alloc_gpio_irq(device_t, device_t, int,
|
||||
int *, u_long, u_long, u_long, u_int);
|
||||
int *, rman_res_t, rman_res_t, rman_res_t, u_int);
|
||||
|
||||
struct obio_device {
|
||||
const char *od_name;
|
||||
@ -224,7 +224,7 @@ pxa_get_resource_list(device_t dev, device_t child)
|
||||
|
||||
static struct resource *
|
||||
pxa_alloc_resource(device_t dev, device_t child, int type, int *rid,
|
||||
u_long start, u_long end, u_long count, u_int flags)
|
||||
rman_res_t start, rman_res_t end, rman_res_t count, u_int flags)
|
||||
{
|
||||
struct obio_softc *sc;
|
||||
struct obio_device *od;
|
||||
@ -351,7 +351,7 @@ DRIVER_MODULE(pxa, nexus, pxa_driver, pxa_devclass, 0, 0);
|
||||
|
||||
static struct resource *
|
||||
pxa_alloc_gpio_irq(device_t dev, device_t child, int type, int *rid,
|
||||
u_long start, u_long end, u_long count, u_int flags)
|
||||
rman_res_t start, rman_res_t end, rman_res_t count, u_int flags)
|
||||
{
|
||||
struct obio_softc *sc;
|
||||
struct obio_device *od;
|
||||
|
@ -70,7 +70,7 @@ static int pxa_smi_print_child(device_t, device_t);
|
||||
static int pxa_smi_read_ivar(device_t, device_t, int, uintptr_t *);
|
||||
|
||||
static struct resource * pxa_smi_alloc_resource(device_t, device_t,
|
||||
int, int *, u_long, u_long, u_long, u_int);
|
||||
int, int *, rman_res_t, rman_res_t, rman_res_t, u_int);
|
||||
static int pxa_smi_release_resource(device_t, device_t,
|
||||
int, int, struct resource *);
|
||||
static int pxa_smi_activate_resource(device_t, device_t,
|
||||
@ -176,7 +176,7 @@ pxa_smi_read_ivar(device_t dev, device_t child, int which, uintptr_t *result)
|
||||
|
||||
static struct resource *
|
||||
pxa_smi_alloc_resource(device_t dev, device_t child, int type, int *rid,
|
||||
u_long start, u_long end, u_long count, u_int flags)
|
||||
rman_res_t start, rman_res_t end, rman_res_t count, u_int flags)
|
||||
{
|
||||
struct pxa_smi_softc *sc;
|
||||
struct smi_ivars *smid;
|
||||
|
@ -355,22 +355,6 @@ DEFINE_CLASS_0(gic, arm_gic_driver, arm_gic_methods,
|
||||
#define GICv2M_MSI_SETSPI_NS 0x040
|
||||
#define GICV2M_MSI_IIDR 0xFCC
|
||||
|
||||
struct gicv2m_softc {
|
||||
struct resource *sc_mem;
|
||||
struct mtx sc_mutex;
|
||||
u_int sc_spi_start;
|
||||
u_int sc_spi_count;
|
||||
u_int sc_spi_offset;
|
||||
};
|
||||
|
||||
static int
|
||||
gicv2m_probe(device_t dev)
|
||||
{
|
||||
|
||||
device_set_desc(dev, "ARM Generic Interrupt Controller MSI/MSIX");
|
||||
return (BUS_PROBE_DEFAULT);
|
||||
}
|
||||
|
||||
static int
|
||||
gicv2m_attach(device_t dev)
|
||||
{
|
||||
@ -478,7 +462,6 @@ gicv2m_map_msi(device_t dev, device_t pci_dev, int irq, uint64_t *addr,
|
||||
|
||||
static device_method_t arm_gicv2m_methods[] = {
|
||||
/* Device interface */
|
||||
DEVMETHOD(device_probe, gicv2m_probe),
|
||||
DEVMETHOD(device_attach, gicv2m_attach),
|
||||
|
||||
/* MSI/MSI-X */
|
||||
@ -489,9 +472,5 @@ static device_method_t arm_gicv2m_methods[] = {
|
||||
{ 0, 0 }
|
||||
};
|
||||
|
||||
static devclass_t arm_gicv2m_devclass;
|
||||
|
||||
DEFINE_CLASS_0(gicv2m, arm_gicv2m_driver, arm_gicv2m_methods,
|
||||
sizeof(struct gicv2m_softc));
|
||||
EARLY_DRIVER_MODULE(gicv2m, gic, arm_gicv2m_driver, arm_gicv2m_devclass,
|
||||
0, 0, BUS_PASS_INTERRUPT + BUS_PASS_ORDER_MIDDLE);
|
||||
|
@ -51,6 +51,16 @@ struct arm_gic_softc {
|
||||
uint32_t nirqs;
|
||||
};
|
||||
|
||||
DECLARE_CLASS(arm_gicv2m_driver);
|
||||
|
||||
struct gicv2m_softc {
|
||||
struct resource *sc_mem;
|
||||
struct mtx sc_mutex;
|
||||
u_int sc_spi_start;
|
||||
u_int sc_spi_count;
|
||||
u_int sc_spi_offset;
|
||||
};
|
||||
|
||||
int arm_gic_attach(device_t);
|
||||
|
||||
#endif
|
||||
|
@ -290,3 +290,38 @@ EARLY_DRIVER_MODULE(gic, simplebus, arm_gic_fdt_driver,
|
||||
arm_gic_fdt_devclass, 0, 0, BUS_PASS_INTERRUPT + BUS_PASS_ORDER_MIDDLE);
|
||||
EARLY_DRIVER_MODULE(gic, ofwbus, arm_gic_fdt_driver, arm_gic_fdt_devclass,
|
||||
0, 0, BUS_PASS_INTERRUPT + BUS_PASS_ORDER_MIDDLE);
|
||||
|
||||
static struct ofw_compat_data gicv2m_compat_data[] = {
|
||||
{"arm,gic-v2m-frame", true},
|
||||
{NULL, false}
|
||||
};
|
||||
|
||||
static int
|
||||
arm_gicv2m_fdt_probe(device_t dev)
|
||||
{
|
||||
|
||||
if (!ofw_bus_status_okay(dev))
|
||||
return (ENXIO);
|
||||
|
||||
if (!ofw_bus_search_compatible(dev, gicv2m_compat_data)->ocd_data)
|
||||
return (ENXIO);
|
||||
|
||||
device_set_desc(dev, "ARM Generic Interrupt Controller MSI/MSIX");
|
||||
return (BUS_PROBE_DEFAULT);
|
||||
}
|
||||
|
||||
static device_method_t arm_gicv2m_fdt_methods[] = {
|
||||
/* Device interface */
|
||||
DEVMETHOD(device_probe, arm_gicv2m_fdt_probe),
|
||||
|
||||
/* End */
|
||||
DEVMETHOD_END
|
||||
};
|
||||
|
||||
DEFINE_CLASS_1(gicv2m, arm_gicv2m_fdt_driver, arm_gicv2m_fdt_methods,
|
||||
sizeof(struct gicv2m_softc), arm_gicv2m_driver);
|
||||
|
||||
static devclass_t arm_gicv2m_fdt_devclass;
|
||||
|
||||
EARLY_DRIVER_MODULE(gicv2m, gic, arm_gicv2m_fdt_driver,
|
||||
arm_gicv2m_fdt_devclass, 0, 0, BUS_PASS_INTERRUPT + BUS_PASS_ORDER_MIDDLE);
|
||||
|
@ -84,7 +84,7 @@ static device_method_t gic_v3_methods[] = {
|
||||
DEVMETHOD_END
|
||||
};
|
||||
|
||||
DEFINE_CLASS_0(gic_v3, gic_v3_driver, gic_v3_methods,
|
||||
DEFINE_CLASS_0(gic, gic_v3_driver, gic_v3_methods,
|
||||
sizeof(struct gic_v3_softc));
|
||||
|
||||
/*
|
||||
|
@ -54,7 +54,7 @@ static int gic_v3_fdt_probe(device_t);
|
||||
static int gic_v3_fdt_attach(device_t);
|
||||
|
||||
static struct resource *gic_v3_ofw_bus_alloc_res(device_t, device_t, int, int *,
|
||||
u_long, u_long, u_long, u_int);
|
||||
rman_res_t, rman_res_t, rman_res_t, u_int);
|
||||
static const struct ofw_bus_devinfo *gic_v3_ofw_get_devinfo(device_t, device_t);
|
||||
|
||||
static device_method_t gic_v3_fdt_methods[] = {
|
||||
@ -78,7 +78,7 @@ static device_method_t gic_v3_fdt_methods[] = {
|
||||
DEVMETHOD_END
|
||||
};
|
||||
|
||||
DEFINE_CLASS_1(gic_v3, gic_v3_fdt_driver, gic_v3_fdt_methods,
|
||||
DEFINE_CLASS_1(gic, gic_v3_fdt_driver, gic_v3_fdt_methods,
|
||||
sizeof(struct gic_v3_softc), gic_v3_driver);
|
||||
|
||||
static devclass_t gic_v3_fdt_devclass;
|
||||
@ -174,7 +174,7 @@ gic_v3_ofw_get_devinfo(device_t bus __unused, device_t child)
|
||||
|
||||
static struct resource *
|
||||
gic_v3_ofw_bus_alloc_res(device_t bus, device_t child, int type, int *rid,
|
||||
u_long start, u_long end, u_long count, u_int flags)
|
||||
rman_res_t start, rman_res_t end, rman_res_t count, u_int flags)
|
||||
{
|
||||
struct gic_v3_ofw_devinfo *di;
|
||||
struct resource_list_entry *rle;
|
||||
@ -287,12 +287,12 @@ static device_method_t gic_v3_its_fdt_methods[] = {
|
||||
DEVMETHOD_END
|
||||
};
|
||||
|
||||
DEFINE_CLASS_1(gic_v3_its, gic_v3_its_fdt_driver, gic_v3_its_fdt_methods,
|
||||
DEFINE_CLASS_1(its, gic_v3_its_fdt_driver, gic_v3_its_fdt_methods,
|
||||
sizeof(struct gic_v3_its_softc), gic_v3_its_driver);
|
||||
|
||||
static devclass_t gic_v3_its_fdt_devclass;
|
||||
|
||||
EARLY_DRIVER_MODULE(gic_v3_its, gic_v3, gic_v3_its_fdt_driver,
|
||||
EARLY_DRIVER_MODULE(its, gic, gic_v3_its_fdt_driver,
|
||||
gic_v3_its_fdt_devclass, 0, 0, BUS_PASS_INTERRUPT + BUS_PASS_ORDER_MIDDLE);
|
||||
|
||||
static int
|
||||
|
@ -82,7 +82,7 @@ static device_method_t gic_v3_its_methods[] = {
|
||||
DEVMETHOD_END
|
||||
};
|
||||
|
||||
DEFINE_CLASS_0(gic_v3_its, gic_v3_its_driver, gic_v3_its_methods,
|
||||
DEFINE_CLASS_0(its, gic_v3_its_driver, gic_v3_its_methods,
|
||||
sizeof(struct gic_v3_its_softc));
|
||||
|
||||
MALLOC_DEFINE(M_GIC_V3_ITS, "GICv3 ITS", GIC_V3_ITS_DEVSTR);
|
||||
|
@ -99,13 +99,14 @@ static device_attach_t nexus_acpi_attach;
|
||||
static int nexus_print_child(device_t, device_t);
|
||||
static device_t nexus_add_child(device_t, u_int, const char *, int);
|
||||
static struct resource *nexus_alloc_resource(device_t, device_t, int, int *,
|
||||
u_long, u_long, u_long, u_int);
|
||||
rman_res_t, rman_res_t, rman_res_t, u_int);
|
||||
static int nexus_activate_resource(device_t, device_t, int, int,
|
||||
struct resource *);
|
||||
static int nexus_config_intr(device_t dev, int irq, enum intr_trigger trig,
|
||||
enum intr_polarity pol);
|
||||
static struct resource_list *nexus_get_reslist(device_t, device_t);
|
||||
static int nexus_set_resource(device_t, device_t, int, int, u_long, u_long);
|
||||
static int nexus_set_resource(device_t, device_t, int, int,
|
||||
rman_res_t, rman_res_t);
|
||||
static int nexus_deactivate_resource(device_t, device_t, int, int,
|
||||
struct resource *);
|
||||
|
||||
@ -201,7 +202,7 @@ nexus_add_child(device_t bus, u_int order, const char *name, int unit)
|
||||
*/
|
||||
static struct resource *
|
||||
nexus_alloc_resource(device_t bus, device_t child, int type, int *rid,
|
||||
u_long start, u_long end, u_long count, u_int flags)
|
||||
rman_res_t start, rman_res_t end, rman_res_t count, u_int flags)
|
||||
{
|
||||
struct nexus_device *ndev = DEVTONX(child);
|
||||
struct resource *rv;
|
||||
@ -332,7 +333,7 @@ nexus_get_reslist(device_t dev, device_t child)
|
||||
|
||||
static int
|
||||
nexus_set_resource(device_t dev, device_t child, int type, int rid,
|
||||
u_long start, u_long count)
|
||||
rman_res_t start, rman_res_t count)
|
||||
{
|
||||
struct nexus_device *ndev = DEVTONX(child);
|
||||
struct resource_list *rl = &ndev->nx_resources;
|
||||
|
@ -110,7 +110,7 @@ SYSCTL_INT(_hw, OID_AUTO, thunder_pcie_max_vfs, CTLFLAG_RWTUN,
|
||||
|
||||
/* Forward prototypes */
|
||||
static struct resource *thunder_pcie_alloc_resource(device_t,
|
||||
device_t, int, int *, u_long, u_long, u_long, u_int);
|
||||
device_t, int, int *, rman_res_t, rman_res_t, rman_res_t, u_int);
|
||||
static int thunder_pcie_attach(device_t);
|
||||
static int thunder_pcie_identify_pcib(device_t);
|
||||
static int thunder_pcie_maxslots(device_t);
|
||||
@ -431,7 +431,7 @@ thunder_pcie_release_resource(device_t dev, device_t child, int type, int rid,
|
||||
|
||||
static struct resource *
|
||||
thunder_pcie_alloc_resource(device_t dev, device_t child, int type, int *rid,
|
||||
u_long start, u_long end, u_long count, u_int flags)
|
||||
rman_res_t start, rman_res_t end, rman_res_t count, u_int flags)
|
||||
{
|
||||
struct thunder_pcie_softc *sc = device_get_softc(dev);
|
||||
struct rman *rm = NULL;
|
||||
@ -519,7 +519,7 @@ static int
|
||||
thunder_pcie_identify_pcib(device_t dev)
|
||||
{
|
||||
struct thunder_pcie_softc *sc;
|
||||
u_long start;
|
||||
rman_res_t start;
|
||||
|
||||
sc = device_get_softc(dev);
|
||||
start = bus_get_resource_start(dev, SYS_RES_MEMORY, 0);
|
||||
|
@ -126,7 +126,7 @@ struct thunder_pem_softc {
|
||||
};
|
||||
|
||||
static struct resource * thunder_pem_alloc_resource(device_t, device_t, int,
|
||||
int *, u_long, u_long, u_long, u_int);
|
||||
int *, rman_res_t, rman_res_t, rman_res_t, u_int);
|
||||
static int thunder_pem_attach(device_t);
|
||||
static int thunder_pem_detach(device_t);
|
||||
static uint64_t thunder_pem_config_reg_read(struct thunder_pem_softc *, int);
|
||||
@ -230,7 +230,7 @@ static int
|
||||
thunder_pem_identify(device_t dev)
|
||||
{
|
||||
struct thunder_pem_softc *sc;
|
||||
u_long start;
|
||||
rman_res_t start;
|
||||
|
||||
sc = device_get_softc(dev);
|
||||
start = rman_get_start(sc->reg);
|
||||
@ -426,7 +426,7 @@ thunder_pem_write_config(device_t dev, u_int bus, u_int slot,
|
||||
|
||||
static struct resource *
|
||||
thunder_pem_alloc_resource(device_t dev, device_t child, int type, int *rid,
|
||||
u_long start, u_long end, u_long count, u_int flags)
|
||||
rman_res_t start, rman_res_t end, rman_res_t count, u_int flags)
|
||||
{
|
||||
struct thunder_pem_softc *sc = device_get_softc(dev);
|
||||
struct rman *rm = NULL;
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*-
|
||||
* Copyright (c) 2008 John Hay
|
||||
* Copyright (c) 2006 Warner Losh
|
||||
* Copyright (c) 2006 M Warner Losh <imp@freebsd.org>
|
||||
* Copyright (c) 1998 Robert Nordier
|
||||
* All rights reserved.
|
||||
*
|
||||
@ -30,52 +30,16 @@ __FBSDID("$FreeBSD$");
|
||||
|
||||
#include "lib.h"
|
||||
#include "board.h"
|
||||
#include "paths.h"
|
||||
#include "rbx.h"
|
||||
|
||||
#define RBX_ASKNAME 0x0 /* -a */
|
||||
#define RBX_SINGLE 0x1 /* -s */
|
||||
/* 0x2 is reserved for log2(RB_NOSYNC). */
|
||||
/* 0x3 is reserved for log2(RB_HALT). */
|
||||
/* 0x4 is reserved for log2(RB_INITNAME). */
|
||||
#define RBX_DFLTROOT 0x5 /* -r */
|
||||
/* #define RBX_KDB 0x6 -d */
|
||||
/* 0x7 is reserved for log2(RB_RDONLY). */
|
||||
/* 0x8 is reserved for log2(RB_DUMP). */
|
||||
/* 0x9 is reserved for log2(RB_MINIROOT). */
|
||||
#define RBX_CONFIG 0xa /* -c */
|
||||
#define RBX_VERBOSE 0xb /* -v */
|
||||
/* #define RBX_SERIAL 0xc -h */
|
||||
/* #define RBX_CDROM 0xd -C */
|
||||
/* 0xe is reserved for log2(RB_POWEROFF). */
|
||||
#define RBX_GDB 0xf /* -g */
|
||||
/* #define RBX_MUTE 0x10 -m */
|
||||
/* 0x11 is reserved for log2(RB_SELFTEST). */
|
||||
/* 0x12 is reserved for boot programs. */
|
||||
/* 0x13 is reserved for boot programs. */
|
||||
/* #define RBX_PAUSE 0x14 -p */
|
||||
/* #define RBX_QUIET 0x15 -q */
|
||||
#define RBX_NOINTR 0x1c /* -n */
|
||||
/* 0x1d is reserved for log2(RB_MULTIPLE) and is just misnamed here. */
|
||||
/* #define RBX_DUAL 0x1d -D */
|
||||
/* 0x1f is reserved for log2(RB_BOOTINFO). */
|
||||
|
||||
/* pass: -a, -s, -r, -v, -g */
|
||||
#define RBX_MASK (OPT_SET(RBX_ASKNAME) | OPT_SET(RBX_SINGLE) | \
|
||||
OPT_SET(RBX_DFLTROOT) | \
|
||||
OPT_SET(RBX_VERBOSE) | \
|
||||
OPT_SET(RBX_GDB))
|
||||
|
||||
#define PATH_DOTCONFIG "/boot.config"
|
||||
#define PATH_CONFIG "/boot/config"
|
||||
//#define PATH_KERNEL "/boot/kernel/kernel"
|
||||
#undef PATH_KERNEL
|
||||
#define PATH_KERNEL "/boot/kernel/kernel.gz.tramp"
|
||||
|
||||
extern uint32_t _end;
|
||||
|
||||
#define NOPT 6
|
||||
|
||||
#define OPT_SET(opt) (1 << (opt))
|
||||
#define OPT_CHECK(opt) ((opts) & OPT_SET(opt))
|
||||
|
||||
static const char optstr[NOPT] = "agnrsv";
|
||||
static const unsigned char bootflags[NOPT] = {
|
||||
RBX_ASKNAME,
|
||||
|
@ -28,51 +28,13 @@ __FBSDID("$FreeBSD$");
|
||||
#include <stdarg.h>
|
||||
|
||||
#include "lib.h"
|
||||
|
||||
#define RBX_ASKNAME 0x0 /* -a */
|
||||
#define RBX_SINGLE 0x1 /* -s */
|
||||
/* 0x2 is reserved for log2(RB_NOSYNC). */
|
||||
/* 0x3 is reserved for log2(RB_HALT). */
|
||||
/* 0x4 is reserved for log2(RB_INITNAME). */
|
||||
#define RBX_DFLTROOT 0x5 /* -r */
|
||||
/* #define RBX_KDB 0x6 -d */
|
||||
/* 0x7 is reserved for log2(RB_RDONLY). */
|
||||
/* 0x8 is reserved for log2(RB_DUMP). */
|
||||
/* 0x9 is reserved for log2(RB_MINIROOT). */
|
||||
#define RBX_CONFIG 0xa /* -c */
|
||||
#define RBX_VERBOSE 0xb /* -v */
|
||||
/* #define RBX_SERIAL 0xc -h */
|
||||
/* #define RBX_CDROM 0xd -C */
|
||||
/* 0xe is reserved for log2(RB_POWEROFF). */
|
||||
#define RBX_GDB 0xf /* -g */
|
||||
/* #define RBX_MUTE 0x10 -m */
|
||||
/* 0x11 is reserved for log2(RB_SELFTEST). */
|
||||
/* 0x12 is reserved for boot programs. */
|
||||
/* 0x13 is reserved for boot programs. */
|
||||
/* #define RBX_PAUSE 0x14 -p */
|
||||
/* #define RBX_QUIET 0x15 -q */
|
||||
#define RBX_NOINTR 0x1c /* -n */
|
||||
/* 0x1d is reserved for log2(RB_MULTIPLE) and is just misnamed here. */
|
||||
/* #define RBX_DUAL 0x1d -D */
|
||||
/* 0x1f is reserved for log2(RB_BOOTINFO). */
|
||||
|
||||
/* pass: -a, -s, -r, -v, -g */
|
||||
#define RBX_MASK (OPT_SET(RBX_ASKNAME) | OPT_SET(RBX_SINGLE) | \
|
||||
OPT_SET(RBX_DFLTROOT) | \
|
||||
OPT_SET(RBX_VERBOSE) | \
|
||||
OPT_SET(RBX_GDB))
|
||||
|
||||
#define PATH_DOTCONFIG "/boot.config"
|
||||
#define PATH_CONFIG "/boot/config"
|
||||
#define PATH_KERNEL "/boot/kernel/kernel"
|
||||
#include "paths.h"
|
||||
#include "rbx.h"
|
||||
|
||||
extern uint32_t _end;
|
||||
|
||||
#define NOPT 6
|
||||
|
||||
#define OPT_SET(opt) (1 << (opt))
|
||||
#define OPT_CHECK(opt) ((opts) & OPT_SET(opt))
|
||||
|
||||
static const char optstr[NOPT] = "agnrsv";
|
||||
static const unsigned char flags[NOPT] = {
|
||||
RBX_ASKNAME,
|
||||
|
39
sys/boot/common/paths.h
Normal file
39
sys/boot/common/paths.h
Normal file
@ -0,0 +1,39 @@
|
||||
/*-
|
||||
* Copyright (c) 2016 M. Warner Losh <imp@freebsd.org>
|
||||
* 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 THE AUTHORS 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 AUTHORS 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 _PATHS_H_
|
||||
#define _PATHS_H_
|
||||
|
||||
#define PATH_DOTCONFIG "/boot.config"
|
||||
#define PATH_CONFIG "/boot/config"
|
||||
#define PATH_BOOT3 "/boot/loader"
|
||||
#define PATH_LOADER "/boot/loader"
|
||||
#define PATH_LOADER_EFI "/boot/loader.efi"
|
||||
#define PATH_KERNEL "/boot/kernel/kernel"
|
||||
|
||||
#endif /* _PATHS_H_ */
|
@ -31,8 +31,7 @@ __FBSDID("$FreeBSD$");
|
||||
#include <eficonsctl.h>
|
||||
|
||||
#include "boot_module.h"
|
||||
|
||||
#define _PATH_LOADER "/boot/loader.efi"
|
||||
#include "paths.h"
|
||||
|
||||
static const boot_module_t *boot_modules[] =
|
||||
{
|
||||
@ -92,20 +91,48 @@ Free(void *buf, const char *file __unused, int line __unused)
|
||||
void
|
||||
try_load(const boot_module_t *mod)
|
||||
{
|
||||
size_t bufsize;
|
||||
size_t bufsize, cmdsize;
|
||||
void *buf;
|
||||
char *cmd;
|
||||
dev_info_t *dev;
|
||||
EFI_HANDLE loaderhandle;
|
||||
EFI_LOADED_IMAGE *loaded_image;
|
||||
EFI_STATUS status;
|
||||
|
||||
status = mod->load(_PATH_LOADER, &dev, &buf, &bufsize);
|
||||
/*
|
||||
* Read in and parse the command line from /boot.config or /boot/config,
|
||||
* if present. We'll pass it the next stage via a simple ASCII
|
||||
* string. loader.efi has a hack for ASCII strings, so we'll use that to
|
||||
* keep the size down here. We only try to read the alternate file if
|
||||
* we get EFI_NOT_FOUND because all other errors mean that the boot_module
|
||||
* had troubles with the filesystem. We could return early, but we'll let
|
||||
* loading the actual kernel sort all that out. Since these files are
|
||||
* optional, we don't report errors in trying to read them.
|
||||
*/
|
||||
cmd = NULL;
|
||||
cmdsize = 0;
|
||||
status = mod->load(PATH_DOTCONFIG, &dev, &buf, &bufsize);
|
||||
if (status == EFI_NOT_FOUND)
|
||||
status = mod->load(PATH_CONFIG, &dev, &buf, &bufsize);
|
||||
if (status == EFI_SUCCESS) {
|
||||
cmdsize = bufsize + 1;
|
||||
cmd = malloc(cmdsize);
|
||||
if (cmd == NULL) {
|
||||
free(buf);
|
||||
return;
|
||||
}
|
||||
memcpy(cmd, buf, bufsize);
|
||||
cmd[bufsize] = '\0';
|
||||
free(buf);
|
||||
}
|
||||
|
||||
status = mod->load(PATH_LOADER_EFI, &dev, &buf, &bufsize);
|
||||
if (status == EFI_NOT_FOUND)
|
||||
return;
|
||||
|
||||
if (status != EFI_SUCCESS) {
|
||||
printf("%s failed to load %s (%lu)\n", mod->name, _PATH_LOADER,
|
||||
EFI_ERROR_CODE(status));
|
||||
printf("%s failed to load %s (%lu)\n", mod->name,
|
||||
PATH_LOADER_EFI, EFI_ERROR_CODE(status));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -116,6 +143,9 @@ try_load(const boot_module_t *mod)
|
||||
return;
|
||||
}
|
||||
|
||||
if (cmd != NULL)
|
||||
printf(" command args: %s\n", cmd);
|
||||
|
||||
if ((status = bs->HandleProtocol(loaderhandle, &LoadedImageGUID,
|
||||
(VOID**)&loaded_image)) != EFI_SUCCESS) {
|
||||
printf("Failed to query LoadedImage provided by %s (%lu)\n",
|
||||
@ -124,11 +154,16 @@ try_load(const boot_module_t *mod)
|
||||
}
|
||||
|
||||
loaded_image->DeviceHandle = dev->devhandle;
|
||||
loaded_image->LoadOptionsSize = cmdsize;
|
||||
loaded_image->LoadOptions = cmd;
|
||||
|
||||
if ((status = bs->StartImage(loaderhandle, NULL, NULL)) !=
|
||||
EFI_SUCCESS) {
|
||||
printf("Failed to start image provided by %s (%lu)\n",
|
||||
mod->name, EFI_ERROR_CODE(status));
|
||||
free(cmd);
|
||||
loaded_image->LoadOptionsSize = 0;
|
||||
loaded_image->LoadOptions = NULL;
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -174,7 +209,7 @@ efi_main(EFI_HANDLE Ximage, EFI_SYSTEM_TABLE *Xsystab)
|
||||
conout->ClearScreen(conout);
|
||||
|
||||
printf("\n>> FreeBSD EFI boot block\n");
|
||||
printf(" Loader path: %s\n\n", _PATH_LOADER);
|
||||
printf(" Loader path: %s\n\n", PATH_LOADER_EFI);
|
||||
printf(" Initializing modules:");
|
||||
for (i = 0; i < NUM_BOOT_MODULES; i++) {
|
||||
if (boot_modules[i] == NULL)
|
||||
|
@ -44,7 +44,7 @@ static CHAR16 *
|
||||
arg_skipsep(CHAR16 *argp)
|
||||
{
|
||||
|
||||
while (*argp == ' ' || *argp == '\t')
|
||||
while (*argp == ' ' || *argp == '\t' || *argp == '\n')
|
||||
argp++;
|
||||
return (argp);
|
||||
}
|
||||
@ -53,7 +53,7 @@ static CHAR16 *
|
||||
arg_skipword(CHAR16 *argp)
|
||||
{
|
||||
|
||||
while (*argp && *argp != ' ' && *argp != '\t')
|
||||
while (*argp && *argp != ' ' && *argp != '\t' && *argp != '\n')
|
||||
argp++;
|
||||
return (argp);
|
||||
}
|
||||
|
@ -29,6 +29,8 @@
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/reboot.h>
|
||||
#include <sys/boot.h>
|
||||
#include <stand.h>
|
||||
#include <string.h>
|
||||
#include <setjmp.h>
|
||||
@ -83,13 +85,22 @@ print_str16(const CHAR16 *str)
|
||||
printf("%c", (char)str[i]);
|
||||
}
|
||||
|
||||
static void
|
||||
cp16to8(const CHAR16 *src, char *dst, size_t len)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
for (i = 0; i < len && src[i]; i++)
|
||||
dst[i] = (char)src[i];
|
||||
}
|
||||
|
||||
EFI_STATUS
|
||||
main(int argc, CHAR16 *argv[])
|
||||
{
|
||||
char var[128];
|
||||
EFI_LOADED_IMAGE *img;
|
||||
EFI_GUID *guid;
|
||||
int i, j, vargood, unit;
|
||||
int i, j, vargood, unit, howto;
|
||||
struct devsw *dev;
|
||||
uint64_t pool_guid;
|
||||
UINTN k;
|
||||
@ -113,27 +124,97 @@ main(int argc, CHAR16 *argv[])
|
||||
cons_probe();
|
||||
|
||||
/*
|
||||
* Parse the args to set the console settings, etc
|
||||
* boot1.efi passes these in, if it can read /boot.config or /boot/config
|
||||
* or iPXE may be setup to pass these in.
|
||||
*
|
||||
* Loop through the args, and for each one that contains an '=' that is
|
||||
* not the first character, add it to the environment. This allows
|
||||
* loader and kernel env vars to be passed on the command line. Convert
|
||||
* args from UCS-2 to ASCII (16 to 8 bit) as they are copied.
|
||||
*/
|
||||
howto = 0;
|
||||
for (i = 1; i < argc; i++) {
|
||||
vargood = 0;
|
||||
for (j = 0; argv[i][j] != 0; j++) {
|
||||
if (j == sizeof(var)) {
|
||||
vargood = 0;
|
||||
break;
|
||||
if (argv[i][0] == '-') {
|
||||
for (j = 1; argv[i][j] != 0; j++) {
|
||||
int ch;
|
||||
|
||||
ch = argv[i][j];
|
||||
switch (ch) {
|
||||
case 'a':
|
||||
howto |= RB_ASKNAME;
|
||||
break;
|
||||
case 'd':
|
||||
howto |= RB_KDB;
|
||||
break;
|
||||
case 'D':
|
||||
howto |= RB_MULTIPLE;
|
||||
break;
|
||||
case 'm':
|
||||
howto |= RB_MUTE;
|
||||
break;
|
||||
case 'h':
|
||||
howto |= RB_SERIAL;
|
||||
break;
|
||||
case 'p':
|
||||
howto |= RB_PAUSE;
|
||||
break;
|
||||
case 'r':
|
||||
howto |= RB_DFLTROOT;
|
||||
break;
|
||||
case 's':
|
||||
howto |= RB_SINGLE;
|
||||
break;
|
||||
case 'S':
|
||||
if (argv[i][j + 1] == 0) {
|
||||
if (i + 1 == argc) {
|
||||
setenv("comconsole_speed", "115200", 1);
|
||||
} else {
|
||||
cp16to8(&argv[i + 1][0], var,
|
||||
sizeof(var));
|
||||
setenv("comconsole_speedspeed", var, 1);
|
||||
}
|
||||
i++;
|
||||
break;
|
||||
} else {
|
||||
cp16to8(&argv[i][j + 1], var,
|
||||
sizeof(var));
|
||||
setenv("comconsole_speed", var, 1);
|
||||
break;
|
||||
}
|
||||
case 'v':
|
||||
howto |= RB_VERBOSE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
vargood = 0;
|
||||
for (j = 0; argv[i][j] != 0; j++) {
|
||||
if (j == sizeof(var)) {
|
||||
vargood = 0;
|
||||
break;
|
||||
}
|
||||
if (j > 0 && argv[i][j] == '=')
|
||||
vargood = 1;
|
||||
var[j] = (char)argv[i][j];
|
||||
}
|
||||
if (vargood) {
|
||||
var[j] = 0;
|
||||
putenv(var);
|
||||
}
|
||||
if (j > 0 && argv[i][j] == '=')
|
||||
vargood = 1;
|
||||
var[j] = (char)argv[i][j];
|
||||
}
|
||||
if (vargood) {
|
||||
var[j] = 0;
|
||||
putenv(var);
|
||||
}
|
||||
}
|
||||
for (i = 0; howto_names[i].ev != NULL; i++)
|
||||
if (howto & howto_names[i].mask)
|
||||
setenv(howto_names[i].ev, "YES", 1);
|
||||
if (howto & RB_MULTIPLE) {
|
||||
if (howto & RB_SERIAL)
|
||||
setenv("console", "comconsole efi" , 1);
|
||||
else
|
||||
setenv("console", "efi comconsole" , 1);
|
||||
} else if (howto & RB_SERIAL) {
|
||||
setenv("console", "comconsole" , 1);
|
||||
}
|
||||
|
||||
if (efi_copy_init()) {
|
||||
printf("failed to allocate staging area\n");
|
||||
|
@ -33,6 +33,8 @@ __FBSDID("$FreeBSD$");
|
||||
|
||||
#include "boot2.h"
|
||||
#include "lib.h"
|
||||
#include "paths.h"
|
||||
#include "rbx.h"
|
||||
|
||||
/* Define to 0 to omit serial support */
|
||||
#ifndef SERIAL
|
||||
@ -52,46 +54,6 @@ __FBSDID("$FreeBSD$");
|
||||
|
||||
#define SECOND 18 /* Circa that many ticks in a second. */
|
||||
|
||||
#define RBX_ASKNAME 0x0 /* -a */
|
||||
#define RBX_SINGLE 0x1 /* -s */
|
||||
/* 0x2 is reserved for log2(RB_NOSYNC). */
|
||||
/* 0x3 is reserved for log2(RB_HALT). */
|
||||
/* 0x4 is reserved for log2(RB_INITNAME). */
|
||||
#define RBX_DFLTROOT 0x5 /* -r */
|
||||
#define RBX_KDB 0x6 /* -d */
|
||||
/* 0x7 is reserved for log2(RB_RDONLY). */
|
||||
/* 0x8 is reserved for log2(RB_DUMP). */
|
||||
/* 0x9 is reserved for log2(RB_MINIROOT). */
|
||||
#define RBX_CONFIG 0xa /* -c */
|
||||
#define RBX_VERBOSE 0xb /* -v */
|
||||
#define RBX_SERIAL 0xc /* -h */
|
||||
#define RBX_CDROM 0xd /* -C */
|
||||
/* 0xe is reserved for log2(RB_POWEROFF). */
|
||||
#define RBX_GDB 0xf /* -g */
|
||||
#define RBX_MUTE 0x10 /* -m */
|
||||
/* 0x11 is reserved for log2(RB_SELFTEST). */
|
||||
/* 0x12 is reserved for boot programs. */
|
||||
/* 0x13 is reserved for boot programs. */
|
||||
#define RBX_PAUSE 0x14 /* -p */
|
||||
#define RBX_QUIET 0x15 /* -q */
|
||||
#define RBX_NOINTR 0x1c /* -n */
|
||||
/* 0x1d is reserved for log2(RB_MULTIPLE) and is just misnamed here. */
|
||||
#define RBX_DUAL 0x1d /* -D */
|
||||
/* 0x1f is reserved for log2(RB_BOOTINFO). */
|
||||
|
||||
/* pass: -a, -s, -r, -d, -c, -v, -h, -C, -g, -m, -p, -D */
|
||||
#define RBX_MASK (OPT_SET(RBX_ASKNAME) | OPT_SET(RBX_SINGLE) | \
|
||||
OPT_SET(RBX_DFLTROOT) | OPT_SET(RBX_KDB ) | \
|
||||
OPT_SET(RBX_CONFIG) | OPT_SET(RBX_VERBOSE) | \
|
||||
OPT_SET(RBX_SERIAL) | OPT_SET(RBX_CDROM) | \
|
||||
OPT_SET(RBX_GDB ) | OPT_SET(RBX_MUTE) | \
|
||||
OPT_SET(RBX_PAUSE) | OPT_SET(RBX_DUAL))
|
||||
|
||||
#define PATH_DOTCONFIG "/boot.config"
|
||||
#define PATH_CONFIG "/boot/config"
|
||||
#define PATH_BOOT3 "/boot/loader"
|
||||
#define PATH_KERNEL "/boot/kernel/kernel"
|
||||
|
||||
#define ARGS 0x900
|
||||
#define NOPT 14
|
||||
#define NDEV 3
|
||||
@ -106,9 +68,6 @@ __FBSDID("$FreeBSD$");
|
||||
#define TYPE_MAXHARD TYPE_DA
|
||||
#define TYPE_FD 2
|
||||
|
||||
#define OPT_SET(opt) (1 << (opt))
|
||||
#define OPT_CHECK(opt) ((opts) & OPT_SET(opt))
|
||||
|
||||
extern uint32_t _end;
|
||||
|
||||
static const char optstr[NOPT] = "DhaCcdgmnpqrsv"; /* Also 'P', 'S' */
|
||||
@ -143,7 +102,7 @@ static struct dsk {
|
||||
} dsk;
|
||||
static char cmd[512], cmddup[512], knamebuf[1024];
|
||||
static const char *kname;
|
||||
static uint32_t opts;
|
||||
uint32_t opts;
|
||||
static struct bootinfo bootinfo;
|
||||
#if SERIAL
|
||||
static int comspeed = SIOSPD;
|
||||
|
@ -37,11 +37,7 @@ __FBSDID("$FreeBSD$");
|
||||
#include "util.h"
|
||||
#include "cons.h"
|
||||
#include "gpt.h"
|
||||
|
||||
#define PATH_DOTCONFIG "/boot.config"
|
||||
#define PATH_CONFIG "/boot/config"
|
||||
#define PATH_BOOT3 "/boot/loader"
|
||||
#define PATH_KERNEL "/boot/kernel/kernel"
|
||||
#include "paths.h"
|
||||
|
||||
#define ARGS 0x900
|
||||
#define NOPT 14
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user