Merge ^/head r357408 through r357661.
This commit is contained in:
commit
bc02c18c48
@ -2912,6 +2912,7 @@ _cddl_lib_libctf= cddl/lib/libctf
|
||||
_cddl_lib= cddl/lib
|
||||
cddl/lib/libctf__L: lib/libz__L
|
||||
.endif
|
||||
# cddl/lib/libdtrace requires lib/libproc and lib/librtld_db
|
||||
_prebuild_libs+= lib/libprocstat lib/libproc lib/librtld_db
|
||||
lib/libprocstat__L: lib/libelf__L lib/libkvm__L lib/libutil__L
|
||||
lib/libproc__L: lib/libprocstat__L
|
||||
|
@ -272,6 +272,14 @@ OLD_FILES+=usr/lib/clang/9.0.1/lib/freebsd/libclang_rt.xray-x86_64.a
|
||||
OLD_DIRS+=usr/lib/clang/9.0.1/lib/freebsd
|
||||
OLD_DIRS+=usr/lib/clang/9.0.1/lib
|
||||
OLD_DIRS+=usr/lib/clang/9.0.1
|
||||
|
||||
# 20200206: Remove elf2aout
|
||||
OLD_FILES+=usr/bin/elf2aout
|
||||
OLD_FILES+=usr/share/man/man1/elf2aout.1.gz
|
||||
|
||||
# 20200204: simple_httpd removed
|
||||
OLD_FILES+=usr/sbin/simple_httpd
|
||||
|
||||
# 20200127: vpo removed
|
||||
OLD_FILES+=usr/share/man/man4/imm.4.gz
|
||||
OLD_FILES+=usr/share/man/man4/vpo.4.gz
|
||||
|
15
RELNOTES
15
RELNOTES
@ -10,6 +10,18 @@ newline. Entries should be separated by a newline.
|
||||
|
||||
Changes to this file should not be MFCed.
|
||||
|
||||
r357627:
|
||||
remove elf2aout.
|
||||
|
||||
r357560-r357565:
|
||||
init(8), service(8), and cron(8) will now adopt user/class environment
|
||||
variables (excluding PATH, by default, which will be overwritten) by
|
||||
default. Notably, environment variables for all cron jobs and rc
|
||||
services can now be set via login.conf(5).
|
||||
|
||||
r357455:
|
||||
sparc64 has been removed from FreeBSD.
|
||||
|
||||
r355677:
|
||||
Adds support for NFSv4.2 (RFC-7862) and Extended Attributes
|
||||
(RFC-8276) to the NFS client and server.
|
||||
@ -32,6 +44,9 @@ r355677:
|
||||
Setting vfs.nfsd.server_max_minorversion4 to 0 or 1 will disable NFSv4.2
|
||||
on the server.
|
||||
|
||||
r356263:
|
||||
armv5 support has been removed from FreeBSD.
|
||||
|
||||
r354517:
|
||||
iwm(4) now supports most Intel 9260, 9460 and 9560 Wi-Fi devices.
|
||||
|
||||
|
@ -41,7 +41,6 @@ __FBSDID("$FreeBSD$");
|
||||
|
||||
#include <err.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <signal.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
@ -687,6 +687,9 @@ dump_elf64(dtrace_hdl_t *dtp, const dof_hdr_t *dof, int fd)
|
||||
#elif defined(__mips__)
|
||||
elf_file.ehdr.e_machine = EM_MIPS;
|
||||
#elif defined(__powerpc64__)
|
||||
#if defined(_CALL_ELF) && _CALL_ELF == 2
|
||||
elf_file.ehdr.e_flags = 2;
|
||||
#endif
|
||||
elf_file.ehdr.e_machine = EM_PPC64;
|
||||
#elif defined(__sparc)
|
||||
elf_file.ehdr.e_machine = EM_SPARCV9;
|
||||
@ -1276,7 +1279,7 @@ process_obj(dtrace_hdl_t *dtp, const char *obj, int *eprobesp)
|
||||
static const char dt_symfmt[] = "%s%u.%s";
|
||||
static const char dt_weaksymfmt[] = "%s.%s";
|
||||
char probename[DTRACE_NAMELEN];
|
||||
int fd, i, ndx, eprobe, mod = 0;
|
||||
int fd, i, ndx, eprobe, uses_funcdesc = 0, mod = 0;
|
||||
Elf *elf = NULL;
|
||||
GElf_Ehdr ehdr;
|
||||
Elf_Scn *scn_rel, *scn_sym, *scn_str, *scn_tgt;
|
||||
@ -1328,6 +1331,9 @@ process_obj(dtrace_hdl_t *dtp, const char *obj, int *eprobesp)
|
||||
emachine1 = emachine2 = EM_MIPS;
|
||||
#elif defined(__powerpc__)
|
||||
emachine1 = emachine2 = EM_PPC64;
|
||||
#if !defined(_CALL_ELF) || _CALL_ELF == 1
|
||||
uses_funcdesc = 1;
|
||||
#endif
|
||||
#elif defined(__sparc)
|
||||
emachine1 = emachine2 = EM_SPARCV9;
|
||||
#elif defined(__i386) || defined(__amd64)
|
||||
@ -1473,7 +1479,7 @@ process_obj(dtrace_hdl_t *dtp, const char *obj, int *eprobesp)
|
||||
continue;
|
||||
|
||||
if (dt_symtab_lookup(data_sym, 0, isym, rela.r_offset,
|
||||
shdr_rel.sh_info, &fsym, (emachine1 == EM_PPC64),
|
||||
shdr_rel.sh_info, &fsym, uses_funcdesc,
|
||||
elf) != 0) {
|
||||
dt_strtab_destroy(strtab);
|
||||
goto err;
|
||||
@ -1644,7 +1650,7 @@ process_obj(dtrace_hdl_t *dtp, const char *obj, int *eprobesp)
|
||||
|
||||
if (dt_symtab_lookup(data_sym, osym, isym,
|
||||
rela.r_offset, shdr_rel.sh_info, &fsym,
|
||||
(emachine1 == EM_PPC64), elf) == 0) {
|
||||
uses_funcdesc, elf) == 0) {
|
||||
if (fsym.st_name > data_str->d_size)
|
||||
goto err;
|
||||
|
||||
@ -1653,7 +1659,7 @@ process_obj(dtrace_hdl_t *dtp, const char *obj, int *eprobesp)
|
||||
s = strchr(s, '.') + 1;
|
||||
} else if (dt_symtab_lookup(data_sym, 0, osym,
|
||||
rela.r_offset, shdr_rel.sh_info, &fsym,
|
||||
(emachine1 == EM_PPC64), elf) == 0) {
|
||||
uses_funcdesc, elf) == 0) {
|
||||
u_int bind;
|
||||
|
||||
bind = GELF_ST_BIND(fsym.st_info) == STB_WEAK ?
|
||||
|
@ -25,6 +25,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/tree.h>
|
||||
|
||||
#include <capsicum_helpers.h>
|
||||
#include <dwarf.h>
|
||||
@ -39,7 +40,6 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "uthash.h"
|
||||
#include "_elftc.h"
|
||||
|
||||
ELFTC_VCSID("$Id: addr2line.c 3499 2016-11-25 16:06:29Z emaste $");
|
||||
@ -57,13 +57,14 @@ struct Func {
|
||||
};
|
||||
|
||||
struct CU {
|
||||
RB_ENTRY(CU) entry;
|
||||
Dwarf_Off off;
|
||||
Dwarf_Unsigned lopc;
|
||||
Dwarf_Unsigned hipc;
|
||||
char **srcfiles;
|
||||
Dwarf_Signed nsrcfiles;
|
||||
STAILQ_HEAD(, Func) funclist;
|
||||
UT_hash_handle hh;
|
||||
Dwarf_Die die;
|
||||
};
|
||||
|
||||
static struct option longopts[] = {
|
||||
@ -80,10 +81,22 @@ static struct option longopts[] = {
|
||||
{"version", no_argument, NULL, 'V'},
|
||||
{NULL, 0, NULL, 0}
|
||||
};
|
||||
|
||||
static int demangle, func, base, inlines, print_addr, pretty_print;
|
||||
static char unknown[] = { '?', '?', '\0' };
|
||||
static Dwarf_Addr section_base;
|
||||
static struct CU *culist;
|
||||
/* Need a new curlopc that stores last lopc value. */
|
||||
static Dwarf_Unsigned curlopc = ~0ULL;
|
||||
static RB_HEAD(cutree, CU) cuhead = RB_INITIALIZER(&cuhead);
|
||||
|
||||
static int
|
||||
lopccmp(struct CU *e1, struct CU *e2)
|
||||
{
|
||||
return (e1->lopc < e2->lopc ? -1 : e1->lopc > e2->lopc);
|
||||
}
|
||||
|
||||
RB_PROTOTYPE(cutree, CU, entry, lopccmp);
|
||||
RB_GENERATE(cutree, CU, entry, lopccmp)
|
||||
|
||||
#define USAGE_MESSAGE "\
|
||||
Usage: %s [options] hexaddress...\n\
|
||||
@ -378,6 +391,26 @@ print_inlines(struct CU *cu, struct Func *f, Dwarf_Unsigned call_file,
|
||||
f->call_line);
|
||||
}
|
||||
|
||||
static struct CU *
|
||||
culookup(Dwarf_Unsigned addr)
|
||||
{
|
||||
struct CU find, *res;
|
||||
|
||||
find.lopc = addr;
|
||||
res = RB_NFIND(cutree, &cuhead, &find);
|
||||
if (res != NULL) {
|
||||
if (res->lopc != addr)
|
||||
res = RB_PREV(cutree, &cuhead, res);
|
||||
if (res != NULL && addr >= res->lopc && addr < res->hipc)
|
||||
return (res);
|
||||
} else {
|
||||
res = RB_MAX(cutree, &cuhead);
|
||||
if (res != NULL && addr >= res->lopc && addr < res->hipc)
|
||||
return (res);
|
||||
}
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
translate(Dwarf_Debug dbg, Elf *e, const char* addrstr)
|
||||
{
|
||||
@ -400,11 +433,30 @@ translate(Dwarf_Debug dbg, Elf *e, const char* addrstr)
|
||||
addr += section_base;
|
||||
lineno = 0;
|
||||
file = unknown;
|
||||
cu = NULL;
|
||||
die = NULL;
|
||||
ret = DW_DLV_OK;
|
||||
|
||||
while ((ret = dwarf_next_cu_header(dbg, NULL, NULL, NULL, NULL, NULL,
|
||||
&de)) == DW_DLV_OK) {
|
||||
cu = culookup(addr);
|
||||
if (cu != NULL) {
|
||||
die = cu->die;
|
||||
goto status_ok;
|
||||
}
|
||||
|
||||
while (true) {
|
||||
/*
|
||||
* We resume the CU scan from the last place we found a match.
|
||||
* Because when we have 2 sequential addresses, and the second
|
||||
* one is of the next CU, it is faster to just go to the next CU
|
||||
* instead of starting from the beginning.
|
||||
*/
|
||||
ret = dwarf_next_cu_header(dbg, NULL, NULL, NULL, NULL, NULL,
|
||||
&de);
|
||||
if (ret == DW_DLV_NO_ENTRY) {
|
||||
if (curlopc == ~0ULL)
|
||||
goto out;
|
||||
ret = dwarf_next_cu_header(dbg, NULL, NULL, NULL, NULL,
|
||||
NULL, &de);
|
||||
}
|
||||
die = NULL;
|
||||
while (dwarf_siblingof(dbg, die, &ret_die, &de) == DW_DLV_OK) {
|
||||
if (die != NULL)
|
||||
@ -420,12 +472,15 @@ translate(Dwarf_Debug dbg, Elf *e, const char* addrstr)
|
||||
if (tag == DW_TAG_compile_unit)
|
||||
break;
|
||||
}
|
||||
|
||||
if (ret_die == NULL) {
|
||||
warnx("could not find DW_TAG_compile_unit die");
|
||||
goto next_cu;
|
||||
}
|
||||
if (dwarf_attrval_unsigned(die, DW_AT_low_pc, &lopc, &de) ==
|
||||
DW_DLV_OK) {
|
||||
if (lopc == curlopc)
|
||||
goto out;
|
||||
if (dwarf_attrval_unsigned(die, DW_AT_high_pc, &hipc,
|
||||
&de) == DW_DLV_OK) {
|
||||
/*
|
||||
@ -440,31 +495,27 @@ translate(Dwarf_Debug dbg, Elf *e, const char* addrstr)
|
||||
hipc = ~0ULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* Record the CU in the hash table for faster lookup
|
||||
* later.
|
||||
*/
|
||||
if (dwarf_dieoffset(die, &off, &de) != DW_DLV_OK) {
|
||||
warnx("dwarf_dieoffset failed: %s",
|
||||
dwarf_errmsg(de));
|
||||
goto out;
|
||||
}
|
||||
HASH_FIND(hh, culist, &off, sizeof(off), cu);
|
||||
if (cu == NULL) {
|
||||
|
||||
if (addr >= lopc && addr < hipc) {
|
||||
if ((cu = calloc(1, sizeof(*cu))) == NULL)
|
||||
err(EXIT_FAILURE, "calloc");
|
||||
cu->off = off;
|
||||
cu->lopc = lopc;
|
||||
cu->hipc = hipc;
|
||||
cu->die = die;
|
||||
STAILQ_INIT(&cu->funclist);
|
||||
HASH_ADD(hh, culist, off, sizeof(off), cu);
|
||||
}
|
||||
RB_INSERT(cutree, &cuhead, cu);
|
||||
|
||||
if (addr >= lopc && addr < hipc)
|
||||
curlopc = lopc;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
next_cu:
|
||||
next_cu:
|
||||
if (die != NULL) {
|
||||
dwarf_dealloc(dbg, die, DW_DLA_DIE);
|
||||
die = NULL;
|
||||
@ -474,6 +525,7 @@ translate(Dwarf_Debug dbg, Elf *e, const char* addrstr)
|
||||
if (ret != DW_DLV_OK || die == NULL)
|
||||
goto out;
|
||||
|
||||
status_ok:
|
||||
switch (dwarf_srclines(die, &lbuf, &lcount, &de)) {
|
||||
case DW_DLV_OK:
|
||||
break;
|
||||
@ -572,21 +624,6 @@ translate(Dwarf_Debug dbg, Elf *e, const char* addrstr)
|
||||
cu->srcfiles != NULL && f != NULL && f->inlined_caller != NULL)
|
||||
print_inlines(cu, f->inlined_caller, f->call_file,
|
||||
f->call_line);
|
||||
|
||||
if (die != NULL)
|
||||
dwarf_dealloc(dbg, die, DW_DLA_DIE);
|
||||
|
||||
/*
|
||||
* Reset internal CU pointer, so we will start from the first CU
|
||||
* next round.
|
||||
*/
|
||||
while (ret != DW_DLV_NO_ENTRY) {
|
||||
if (ret == DW_DLV_ERROR)
|
||||
errx(EXIT_FAILURE, "dwarf_next_cu_header: %s",
|
||||
dwarf_errmsg(de));
|
||||
ret = dwarf_next_cu_header(dbg, NULL, NULL, NULL, NULL, NULL,
|
||||
&de);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -587,15 +587,19 @@ copy_from_tempfile(const char *src, const char *dst, int infd, int *outfd,
|
||||
if ((tmpfd = open(dst, O_CREAT | O_TRUNC | O_WRONLY, 0755)) < 0)
|
||||
return (-1);
|
||||
|
||||
if (elftc_copyfile(infd, tmpfd) < 0)
|
||||
if (elftc_copyfile(infd, tmpfd) < 0) {
|
||||
(void) close(tmpfd);
|
||||
return (-1);
|
||||
}
|
||||
|
||||
/*
|
||||
* Remove the temporary file from the file system
|
||||
* namespace, and close its file descriptor.
|
||||
*/
|
||||
if (unlink(src) < 0)
|
||||
if (unlink(src) < 0) {
|
||||
(void) close(tmpfd);
|
||||
return (-1);
|
||||
}
|
||||
|
||||
(void) close(infd);
|
||||
|
||||
|
@ -1137,7 +1137,7 @@ read_section(struct section *s, size_t *size)
|
||||
if (b == NULL)
|
||||
b = malloc(id->d_size);
|
||||
else
|
||||
b = malloc(sz + id->d_size);
|
||||
b = realloc(b, sz + id->d_size);
|
||||
if (b == NULL)
|
||||
err(EXIT_FAILURE, "malloc or realloc failed");
|
||||
|
||||
|
@ -46,8 +46,10 @@ dwarf_add_AT_location_expr(Dwarf_P_Debug dbg, Dwarf_P_Die die, Dwarf_Half attr,
|
||||
at->at_attrib = attr;
|
||||
at->at_expr = loc_expr;
|
||||
|
||||
if (_dwarf_expr_into_block(loc_expr, error) != DW_DLE_NONE)
|
||||
if (_dwarf_expr_into_block(loc_expr, error) != DW_DLE_NONE) {
|
||||
free(at);
|
||||
return (DW_DLV_BADADDR);
|
||||
}
|
||||
at->u[0].u64 = loc_expr->pe_length;
|
||||
at->u[1].u8p = loc_expr->pe_block;
|
||||
if (loc_expr->pe_length <= UCHAR_MAX)
|
||||
|
@ -36,10 +36,10 @@ _dwarf_add_expr(Dwarf_P_Expr expr, Dwarf_Small opcode, Dwarf_Unsigned val1,
|
||||
Dwarf_Debug dbg;
|
||||
int len;
|
||||
|
||||
dbg = expr != NULL ? expr->pe_dbg : NULL;
|
||||
dbg = expr->pe_dbg;
|
||||
|
||||
if (_dwarf_loc_expr_add_atom(expr->pe_dbg, NULL, NULL, opcode, val1,
|
||||
val2, &len, error) != DW_DLE_NONE)
|
||||
if (_dwarf_loc_expr_add_atom(dbg, NULL, NULL, opcode, val1, val2, &len,
|
||||
error) != DW_DLE_NONE)
|
||||
return (NULL);
|
||||
assert(len > 0);
|
||||
|
||||
@ -67,7 +67,7 @@ _dwarf_expr_into_block(Dwarf_P_Expr expr, Dwarf_Error *error)
|
||||
Dwarf_Debug dbg;
|
||||
int len, pos, ret;
|
||||
|
||||
dbg = expr != NULL ? expr->pe_dbg : NULL;
|
||||
dbg = expr->pe_dbg;
|
||||
|
||||
if (expr->pe_block != NULL) {
|
||||
free(expr->pe_block);
|
||||
@ -88,7 +88,7 @@ _dwarf_expr_into_block(Dwarf_P_Expr expr, Dwarf_Error *error)
|
||||
pos = 0;
|
||||
STAILQ_FOREACH(ee, &expr->pe_eelist, ee_next) {
|
||||
assert((Dwarf_Unsigned) pos < expr->pe_length);
|
||||
ret = _dwarf_loc_expr_add_atom(expr->pe_dbg,
|
||||
ret = _dwarf_loc_expr_add_atom(dbg,
|
||||
&expr->pe_block[pos], &expr->pe_block[expr->pe_length],
|
||||
ee->ee_loc.lr_atom, ee->ee_loc.lr_number,
|
||||
ee->ee_loc.lr_number2, &len, error);
|
||||
|
@ -59,9 +59,7 @@ _dwarf_abbrev_add(Dwarf_CU cu, uint64_t entry, uint64_t tag, uint8_t children,
|
||||
HASH_ADD(ab_hh, cu->cu_abbrev_hash, ab_entry,
|
||||
sizeof(ab->ab_entry), ab);
|
||||
|
||||
if (abp != NULL)
|
||||
*abp = ab;
|
||||
|
||||
*abp = ab;
|
||||
return (DW_DLE_NONE);
|
||||
}
|
||||
|
||||
|
@ -468,9 +468,9 @@ _dwarf_frame_section_init(Dwarf_Debug dbg, Dwarf_FrameSec *frame_sec,
|
||||
|
||||
if (length > ds->ds_size - offset ||
|
||||
(length == 0 && !eh_frame)) {
|
||||
DWARF_SET_ERROR(dbg, error,
|
||||
DW_DLE_DEBUG_FRAME_LENGTH_BAD);
|
||||
return (DW_DLE_DEBUG_FRAME_LENGTH_BAD);
|
||||
ret = DW_DLE_DEBUG_FRAME_LENGTH_BAD;
|
||||
DWARF_SET_ERROR(dbg, error, ret);
|
||||
goto fail_cleanup;
|
||||
}
|
||||
|
||||
/* Check terminator for .eh_frame */
|
||||
|
@ -203,11 +203,13 @@ cpp_demangle_ARM(const char *org)
|
||||
break;
|
||||
|
||||
if ((arg = vector_str_substr(&d.vec, arg_begin, d.vec.size - 1,
|
||||
&arg_len)) == NULL)
|
||||
&arg_len)) == NULL)
|
||||
goto clean;
|
||||
|
||||
if (vector_str_push(&d.arg, arg, arg_len) == false)
|
||||
if (vector_str_push(&d.arg, arg, arg_len) == false) {
|
||||
free(arg);
|
||||
goto clean;
|
||||
}
|
||||
|
||||
free(arg);
|
||||
|
||||
@ -301,12 +303,11 @@ init_demangle_data(struct demangle_data *d)
|
||||
|
||||
d->type = ENCODE_FUNC;
|
||||
|
||||
if (vector_str_init(&d->vec) == false)
|
||||
if (!vector_str_init(&d->vec))
|
||||
return (false);
|
||||
|
||||
if (vector_str_init(&d->arg) == false) {
|
||||
if (!vector_str_init(&d->arg)) {
|
||||
vector_str_dest(&d->vec);
|
||||
|
||||
return (false);
|
||||
}
|
||||
|
||||
@ -956,7 +957,7 @@ read_op_user(struct demangle_data *d)
|
||||
goto clean;
|
||||
|
||||
if (VEC_PUSH_STR(&d->vec, "::operator ") == false)
|
||||
return (false);
|
||||
goto clean;
|
||||
|
||||
if (vector_str_push(&d->vec, to_str, to_len) == false)
|
||||
goto clean;
|
||||
|
@ -216,11 +216,13 @@ cpp_demangle_gnu2(const char *org)
|
||||
break;
|
||||
|
||||
if ((arg = vector_str_substr(&d.vec, arg_begin, d.vec.size - 1,
|
||||
&arg_len)) == NULL)
|
||||
&arg_len)) == NULL)
|
||||
goto clean;
|
||||
|
||||
if (vector_str_push(&d.arg, arg, arg_len) == false)
|
||||
if (vector_str_push(&d.arg, arg, arg_len) == false) {
|
||||
free(arg);
|
||||
goto clean;
|
||||
}
|
||||
|
||||
free(arg);
|
||||
|
||||
@ -387,12 +389,11 @@ init_demangle_data(struct demangle_data *d)
|
||||
|
||||
d->type = ENCODE_FUNC;
|
||||
|
||||
if (vector_str_init(&d->vec) == false)
|
||||
if (!vector_str_init(&d->vec))
|
||||
return (false);
|
||||
|
||||
if (vector_str_init(&d->arg) == false) {
|
||||
if (!vector_str_init(&d->arg)) {
|
||||
vector_str_dest(&d->vec);
|
||||
|
||||
return (false);
|
||||
}
|
||||
|
||||
|
@ -1659,7 +1659,8 @@ cpp_demangle_read_local_name(struct cpp_demangle_data *ddata)
|
||||
if (*(++ddata->cur) == '\0')
|
||||
return (0);
|
||||
|
||||
vector_str_init(&local_name);
|
||||
if (!vector_str_init(&local_name))
|
||||
return (0);
|
||||
ddata->cur_output = &local_name;
|
||||
|
||||
if (!cpp_demangle_read_encoding(ddata)) {
|
||||
@ -3953,7 +3954,7 @@ vector_type_qualifier_init(struct vector_type_qualifier *v)
|
||||
|
||||
assert(v->q_container != NULL);
|
||||
|
||||
if (vector_str_init(&v->ext_name) == false) {
|
||||
if (!vector_str_init(&v->ext_name)) {
|
||||
free(v->q_container);
|
||||
return (0);
|
||||
}
|
||||
|
@ -5964,6 +5964,7 @@ dump_dwarf_frame_regtable(struct readelf *re, Dwarf_Fde fde, Dwarf_Addr pc,
|
||||
for (; cur_pc < end_pc; cur_pc++) {
|
||||
if (dwarf_get_fde_info_for_all_regs(fde, cur_pc, &rt, &row_pc,
|
||||
&de) != DW_DLV_OK) {
|
||||
free(vec);
|
||||
warnx("dwarf_get_fde_info_for_all_regs failed: %s\n",
|
||||
dwarf_errmsg(de));
|
||||
return (-1);
|
||||
@ -6298,8 +6299,8 @@ search_loclist_at(struct readelf *re, Dwarf_Die die, Dwarf_Unsigned lowpc,
|
||||
if (*la_list_cap == *la_list_len) {
|
||||
*la_list = realloc(*la_list,
|
||||
*la_list_cap * 2 * sizeof(**la_list));
|
||||
if (la_list == NULL)
|
||||
errx(EXIT_FAILURE, "realloc failed");
|
||||
if (*la_list == NULL)
|
||||
err(EXIT_FAILURE, "realloc failed");
|
||||
*la_list_cap *= 2;
|
||||
}
|
||||
la = &((*la_list)[*la_list_len]);
|
||||
@ -7247,7 +7248,6 @@ dump_object(struct readelf *re, int fd)
|
||||
|
||||
done:
|
||||
elf_end(re->elf);
|
||||
close(fd);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -240,7 +240,7 @@ main(int argc, char **argv)
|
||||
return (rc);
|
||||
}
|
||||
|
||||
static Elf_Data *
|
||||
static int
|
||||
xlatetom(Elf *elf, GElf_Ehdr *elfhdr, void *_src, void *_dst,
|
||||
Elf_Type type, size_t size)
|
||||
{
|
||||
@ -253,7 +253,8 @@ xlatetom(Elf *elf, GElf_Ehdr *elfhdr, void *_src, void *_dst,
|
||||
dst.d_buf = _dst;
|
||||
dst.d_version = elfhdr->e_version;
|
||||
dst.d_size = size;
|
||||
return (gelf_xlatetom(elf, &dst, &src, elfhdr->e_ident[EI_DATA]));
|
||||
return (gelf_xlatetom(elf, &dst, &src, elfhdr->e_ident[EI_DATA]) !=
|
||||
NULL ? 0 : 1);
|
||||
}
|
||||
|
||||
#define NOTE_OFFSET_32(nhdr, namesz, offset) \
|
||||
@ -314,12 +315,12 @@ handle_core_note(Elf *elf, GElf_Ehdr *elfhdr, GElf_Phdr *phdr,
|
||||
while (data != NULL && offset + sizeof(Elf32_Nhdr) < segment_end) {
|
||||
nhdr = (Elf32_Nhdr *)(uintptr_t)((char*)data + offset);
|
||||
memset(&nhdr_l, 0, sizeof(Elf32_Nhdr));
|
||||
if (!xlatetom(elf, elfhdr, &nhdr->n_type, &nhdr_l.n_type,
|
||||
ELF_T_WORD, sizeof(Elf32_Word)) ||
|
||||
!xlatetom(elf, elfhdr, &nhdr->n_descsz, &nhdr_l.n_descsz,
|
||||
ELF_T_WORD, sizeof(Elf32_Word)) ||
|
||||
!xlatetom(elf, elfhdr, &nhdr->n_namesz, &nhdr_l.n_namesz,
|
||||
ELF_T_WORD, sizeof(Elf32_Word)))
|
||||
if (xlatetom(elf, elfhdr, &nhdr->n_type, &nhdr_l.n_type,
|
||||
ELF_T_WORD, sizeof(Elf32_Word)) != 0 ||
|
||||
xlatetom(elf, elfhdr, &nhdr->n_descsz, &nhdr_l.n_descsz,
|
||||
ELF_T_WORD, sizeof(Elf32_Word)) != 0 ||
|
||||
xlatetom(elf, elfhdr, &nhdr->n_namesz, &nhdr_l.n_namesz,
|
||||
ELF_T_WORD, sizeof(Elf32_Word)) != 0)
|
||||
break;
|
||||
|
||||
if (offset + sizeof(Elf32_Nhdr) +
|
||||
@ -356,10 +357,10 @@ handle_core_note(Elf *elf, GElf_Ehdr *elfhdr, GElf_Phdr *phdr,
|
||||
pid = PID64(nhdr,
|
||||
nhdr_l.n_namesz, 40);
|
||||
}
|
||||
xlatetom(elf, elfhdr, &raw_size, &raw_size,
|
||||
ELF_T_WORD, sizeof(uint64_t));
|
||||
xlatetom(elf, elfhdr, &pid, &pid, ELF_T_WORD,
|
||||
sizeof(pid_t));
|
||||
(void)xlatetom(elf, elfhdr, &raw_size,
|
||||
&raw_size, ELF_T_WORD, sizeof(uint64_t));
|
||||
(void)xlatetom(elf, elfhdr, &pid, &pid,
|
||||
ELF_T_WORD, sizeof(pid_t));
|
||||
}
|
||||
|
||||
if (raw_size != 0 && style == STYLE_SYSV) {
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: t_o_search.c,v 1.5 2017/01/10 22:25:01 christos Exp $ */
|
||||
/* $NetBSD: t_o_search.c,v 1.9 2020/02/06 12:18:06 martin Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2012 The NetBSD Foundation, Inc.
|
||||
@ -29,13 +29,14 @@
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include <sys/cdefs.h>
|
||||
__RCSID("$NetBSD: t_o_search.c,v 1.5 2017/01/10 22:25:01 christos Exp $");
|
||||
__RCSID("$NetBSD: t_o_search.c,v 1.9 2020/02/06 12:18:06 martin Exp $");
|
||||
|
||||
#include <atf-c.h>
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include <dirent.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <limits.h>
|
||||
@ -50,7 +51,7 @@ __RCSID("$NetBSD: t_o_search.c,v 1.5 2017/01/10 22:25:01 christos Exp $");
|
||||
* until a decision is reached about the semantics of O_SEARCH and a
|
||||
* non-broken implementation is available.
|
||||
*/
|
||||
#if (O_MASK & O_SEARCH) != 0
|
||||
#if defined(__FreeBSD__) || (O_MASK & O_SEARCH) != 0
|
||||
#define USE_O_SEARCH
|
||||
#endif
|
||||
|
||||
@ -257,11 +258,76 @@ ATF_TC_BODY(o_search_notdir, tc)
|
||||
int fd;
|
||||
|
||||
ATF_REQUIRE(mkdir(DIR, 0755) == 0);
|
||||
ATF_REQUIRE((dfd = open(FILE, O_CREAT|O_RDWR|O_SEARCH, 0644)) != -1);
|
||||
ATF_REQUIRE((dfd = open(FILE, O_CREAT|O_SEARCH, 0644)) != -1);
|
||||
ATF_REQUIRE((fd = openat(dfd, BASEFILE, O_RDWR, 0)) == -1);
|
||||
ATF_REQUIRE(errno == ENOTDIR);
|
||||
ATF_REQUIRE(close(dfd) == 0);
|
||||
}
|
||||
|
||||
#ifdef USE_O_SEARCH
|
||||
ATF_TC(o_search_nord);
|
||||
ATF_TC_HEAD(o_search_nord, tc)
|
||||
{
|
||||
atf_tc_set_md_var(tc, "descr", "See that openat succeeds with no read permission");
|
||||
atf_tc_set_md_var(tc, "require.user", "unprivileged");
|
||||
}
|
||||
ATF_TC_BODY(o_search_nord, tc)
|
||||
{
|
||||
int dfd, fd;
|
||||
|
||||
ATF_REQUIRE(mkdir(DIR, 0755) == 0);
|
||||
ATF_REQUIRE((fd = open(FILE, O_CREAT|O_RDWR, 0644)) != -1);
|
||||
ATF_REQUIRE(close(fd) == 0);
|
||||
|
||||
ATF_REQUIRE(chmod(DIR, 0100) == 0);
|
||||
ATF_REQUIRE((dfd = open(DIR, O_SEARCH, 0)) != -1);
|
||||
|
||||
ATF_REQUIRE(faccessat(dfd, BASEFILE, W_OK, 0) != -1);
|
||||
|
||||
ATF_REQUIRE(close(dfd) == 0);
|
||||
}
|
||||
|
||||
ATF_TC(o_search_getdents);
|
||||
ATF_TC_HEAD(o_search_getdents, tc)
|
||||
{
|
||||
atf_tc_set_md_var(tc, "descr", "See that O_SEARCH forbids getdents");
|
||||
}
|
||||
ATF_TC_BODY(o_search_getdents, tc)
|
||||
{
|
||||
char buf[1024];
|
||||
int dfd;
|
||||
|
||||
ATF_REQUIRE(mkdir(DIR, 0755) == 0);
|
||||
ATF_REQUIRE((dfd = open(DIR, O_SEARCH, 0)) != -1);
|
||||
ATF_REQUIRE(getdents(dfd, buf, sizeof(buf)) < 0);
|
||||
ATF_REQUIRE(close(dfd) == 0);
|
||||
}
|
||||
|
||||
ATF_TC(o_search_revokex);
|
||||
ATF_TC_HEAD(o_search_revokex, tc)
|
||||
{
|
||||
atf_tc_set_md_var(tc, "descr", "See that *at behaves after chmod -x");
|
||||
atf_tc_set_md_var(tc, "require.user", "unprivileged");
|
||||
}
|
||||
ATF_TC_BODY(o_search_revokex, tc)
|
||||
{
|
||||
int dfd, fd;
|
||||
struct stat sb;
|
||||
|
||||
ATF_REQUIRE(mkdir(DIR, 0755) == 0);
|
||||
ATF_REQUIRE((fd = open(FILE, O_CREAT|O_RDWR, 0644)) != -1);
|
||||
ATF_REQUIRE(close(fd) == 0);
|
||||
|
||||
ATF_REQUIRE((dfd = open(DIR, O_SEARCH, 0)) != -1);
|
||||
|
||||
/* Drop permissions. The kernel must still not check the exec bit. */
|
||||
ATF_REQUIRE(chmod(DIR, 0000) == 0);
|
||||
ATF_REQUIRE(fstatat(dfd, BASEFILE, &sb, 0) == 0);
|
||||
|
||||
ATF_REQUIRE(close(dfd) == 0);
|
||||
}
|
||||
#endif /* USE_O_SEARCH */
|
||||
|
||||
ATF_TP_ADD_TCS(tp)
|
||||
{
|
||||
|
||||
@ -276,6 +342,11 @@ ATF_TP_ADD_TCS(tp)
|
||||
ATF_TP_ADD_TC(tp, o_search_unpriv_flag2);
|
||||
#endif
|
||||
ATF_TP_ADD_TC(tp, o_search_notdir);
|
||||
#ifdef USE_O_SEARCH
|
||||
ATF_TP_ADD_TC(tp, o_search_nord);
|
||||
ATF_TP_ADD_TC(tp, o_search_getdents);
|
||||
ATF_TP_ADD_TC(tp, o_search_revokex);
|
||||
#endif
|
||||
|
||||
return atf_no_error();
|
||||
}
|
||||
|
@ -210,12 +210,6 @@ OPTIMIZATIONS = 2
|
||||
SESSION = 0
|
||||
!ENDIF
|
||||
|
||||
# Set this to non-0 to enable support for the rbu extension.
|
||||
#
|
||||
!IFNDEF RBU
|
||||
RBU = 0
|
||||
!ENDIF
|
||||
|
||||
# Set the source code file to be used by executables and libraries when
|
||||
# they need the amalgamation.
|
||||
#
|
||||
@ -288,6 +282,7 @@ OPT_FEATURE_FLAGS = $(OPT_FEATURE_FLAGS) -DSQLITE_ENABLE_JSON1=1
|
||||
OPT_FEATURE_FLAGS = $(OPT_FEATURE_FLAGS) -DSQLITE_ENABLE_STMTVTAB=1
|
||||
OPT_FEATURE_FLAGS = $(OPT_FEATURE_FLAGS) -DSQLITE_ENABLE_DBPAGE_VTAB=1
|
||||
OPT_FEATURE_FLAGS = $(OPT_FEATURE_FLAGS) -DSQLITE_ENABLE_DBSTAT_VTAB=1
|
||||
OPT_FEATURE_FLAGS = $(OPT_FEATURE_FLAGS) -DSQLITE_INTROSPECTION_PRAGMAS=1
|
||||
OPT_FEATURE_FLAGS = $(OPT_FEATURE_FLAGS) -DSQLITE_ENABLE_DESERIALIZE=1
|
||||
!ENDIF
|
||||
OPT_FEATURE_FLAGS = $(OPT_FEATURE_FLAGS) -DSQLITE_ENABLE_COLUMN_METADATA=1
|
||||
@ -301,13 +296,6 @@ OPT_FEATURE_FLAGS = $(OPT_FEATURE_FLAGS) -DSQLITE_ENABLE_SESSION=1
|
||||
OPT_FEATURE_FLAGS = $(OPT_FEATURE_FLAGS) -DSQLITE_ENABLE_PREUPDATE_HOOK=1
|
||||
!ENDIF
|
||||
|
||||
# Should the rbu extension be enabled? If so, add compilation options
|
||||
# to enable it.
|
||||
#
|
||||
!IF $(RBU)!=0
|
||||
OPT_FEATURE_FLAGS = $(OPT_FEATURE_FLAGS) -DSQLITE_ENABLE_RBU=1
|
||||
!ENDIF
|
||||
|
||||
# These are the "extended" SQLite compilation options used when compiling for
|
||||
# the Windows 10 platform.
|
||||
#
|
||||
@ -990,7 +978,7 @@ Replace.exe:
|
||||
sqlite3.def: Replace.exe $(LIBOBJ)
|
||||
echo EXPORTS > sqlite3.def
|
||||
dumpbin /all $(LIBOBJ) \
|
||||
| .\Replace.exe "^\s+/EXPORT:_?(sqlite3(?:session|changeset|changegroup|rebaser|rbu)?_[^@,]*)(?:@\d+|,DATA)?$$" $$1 true \
|
||||
| .\Replace.exe "^\s+/EXPORT:_?(sqlite3(?:session|changeset|changegroup|rebaser)?_[^@,]*)(?:@\d+|,DATA)?$$" $$1 true \
|
||||
| sort >> sqlite3.def
|
||||
|
||||
$(SQLITE3EXE): shell.c $(SHELL_CORE_DEP) $(LIBRESOBJS) $(SHELL_CORE_SRC) $(SQLITE3H)
|
||||
|
22
contrib/sqlite3/configure
vendored
22
contrib/sqlite3/configure
vendored
@ -1,6 +1,6 @@
|
||||
#! /bin/sh
|
||||
# Guess values for system-dependent variables and create Makefiles.
|
||||
# Generated by GNU Autoconf 2.69 for sqlite 3.31.0.
|
||||
# Generated by GNU Autoconf 2.69 for sqlite 3.30.1.
|
||||
#
|
||||
# Report bugs to <http://www.sqlite.org>.
|
||||
#
|
||||
@ -590,8 +590,8 @@ MAKEFLAGS=
|
||||
# Identity of this package.
|
||||
PACKAGE_NAME='sqlite'
|
||||
PACKAGE_TARNAME='sqlite'
|
||||
PACKAGE_VERSION='3.31.0'
|
||||
PACKAGE_STRING='sqlite 3.31.0'
|
||||
PACKAGE_VERSION='3.30.1'
|
||||
PACKAGE_STRING='sqlite 3.30.1'
|
||||
PACKAGE_BUGREPORT='http://www.sqlite.org'
|
||||
PACKAGE_URL=''
|
||||
|
||||
@ -1341,7 +1341,7 @@ if test "$ac_init_help" = "long"; then
|
||||
# Omit some internal or obsolete options to make the list less imposing.
|
||||
# This message is too long to be a string in the A/UX 3.1 sh.
|
||||
cat <<_ACEOF
|
||||
\`configure' configures sqlite 3.31.0 to adapt to many kinds of systems.
|
||||
\`configure' configures sqlite 3.30.1 to adapt to many kinds of systems.
|
||||
|
||||
Usage: $0 [OPTION]... [VAR=VALUE]...
|
||||
|
||||
@ -1412,7 +1412,7 @@ fi
|
||||
|
||||
if test -n "$ac_init_help"; then
|
||||
case $ac_init_help in
|
||||
short | recursive ) echo "Configuration of sqlite 3.31.0:";;
|
||||
short | recursive ) echo "Configuration of sqlite 3.30.1:";;
|
||||
esac
|
||||
cat <<\_ACEOF
|
||||
|
||||
@ -1537,7 +1537,7 @@ fi
|
||||
test -n "$ac_init_help" && exit $ac_status
|
||||
if $ac_init_version; then
|
||||
cat <<\_ACEOF
|
||||
sqlite configure 3.31.0
|
||||
sqlite configure 3.30.1
|
||||
generated by GNU Autoconf 2.69
|
||||
|
||||
Copyright (C) 2012 Free Software Foundation, Inc.
|
||||
@ -1952,7 +1952,7 @@ cat >config.log <<_ACEOF
|
||||
This file contains any messages produced by compilers while
|
||||
running configure, to aid debugging if configure makes a mistake.
|
||||
|
||||
It was created by sqlite $as_me 3.31.0, which was
|
||||
It was created by sqlite $as_me 3.30.1, which was
|
||||
generated by GNU Autoconf 2.69. Invocation command line was
|
||||
|
||||
$ $0 $@
|
||||
@ -2818,7 +2818,7 @@ fi
|
||||
|
||||
# Define the identity of the package.
|
||||
PACKAGE='sqlite'
|
||||
VERSION='3.31.0'
|
||||
VERSION='3.30.1'
|
||||
|
||||
|
||||
cat >>confdefs.h <<_ACEOF
|
||||
@ -13653,7 +13653,7 @@ else
|
||||
fi
|
||||
|
||||
if test x"$enable_rtree" = "xyes"; then
|
||||
BUILD_CFLAGS="$BUILD_CFLAGS -DSQLITE_ENABLE_RTREE -DSQLITE_ENABLE_GEOPOLY"
|
||||
BUILD_CFLAGS="$BUILD_CFLAGS -DSQLITE_ENABLE_RTREE"
|
||||
fi
|
||||
#-----------------------------------------------------------------------
|
||||
|
||||
@ -14438,7 +14438,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
|
||||
# report actual input values of CONFIG_FILES etc. instead of their
|
||||
# values after options handling.
|
||||
ac_log="
|
||||
This file was extended by sqlite $as_me 3.31.0, which was
|
||||
This file was extended by sqlite $as_me 3.30.1, which was
|
||||
generated by GNU Autoconf 2.69. Invocation command line was
|
||||
|
||||
CONFIG_FILES = $CONFIG_FILES
|
||||
@ -14495,7 +14495,7 @@ _ACEOF
|
||||
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
|
||||
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
|
||||
ac_cs_version="\\
|
||||
sqlite config.status 3.31.0
|
||||
sqlite config.status 3.30.1
|
||||
configured by $0, generated by GNU Autoconf 2.69,
|
||||
with options \\"\$ac_cs_config\\"
|
||||
|
||||
|
@ -10,7 +10,7 @@
|
||||
#
|
||||
|
||||
AC_PREREQ(2.61)
|
||||
AC_INIT(sqlite, 3.31.0, http://www.sqlite.org)
|
||||
AC_INIT(sqlite, 3.30.1, http://www.sqlite.org)
|
||||
AC_CONFIG_SRCDIR([sqlite3.c])
|
||||
AC_CONFIG_AUX_DIR([.])
|
||||
|
||||
@ -161,7 +161,7 @@ AC_ARG_ENABLE(rtree, [AS_HELP_STRING(
|
||||
[--enable-rtree], [include rtree support [default=yes]])],
|
||||
[], [enable_rtree=yes])
|
||||
if test x"$enable_rtree" = "xyes"; then
|
||||
BUILD_CFLAGS="$BUILD_CFLAGS -DSQLITE_ENABLE_RTREE -DSQLITE_ENABLE_GEOPOLY"
|
||||
BUILD_CFLAGS="$BUILD_CFLAGS -DSQLITE_ENABLE_RTREE"
|
||||
fi
|
||||
#-----------------------------------------------------------------------
|
||||
|
||||
|
@ -2007,23 +2007,19 @@ int sqlite3_shathree_init(
|
||||
int rc = SQLITE_OK;
|
||||
SQLITE_EXTENSION_INIT2(pApi);
|
||||
(void)pzErrMsg; /* Unused parameter */
|
||||
rc = sqlite3_create_function(db, "sha3", 1,
|
||||
SQLITE_UTF8 | SQLITE_INNOCUOUS | SQLITE_DETERMINISTIC,
|
||||
0, sha3Func, 0, 0);
|
||||
rc = sqlite3_create_function(db, "sha3", 1, SQLITE_UTF8, 0,
|
||||
sha3Func, 0, 0);
|
||||
if( rc==SQLITE_OK ){
|
||||
rc = sqlite3_create_function(db, "sha3", 2,
|
||||
SQLITE_UTF8 | SQLITE_INNOCUOUS | SQLITE_DETERMINISTIC,
|
||||
0, sha3Func, 0, 0);
|
||||
rc = sqlite3_create_function(db, "sha3", 2, SQLITE_UTF8, 0,
|
||||
sha3Func, 0, 0);
|
||||
}
|
||||
if( rc==SQLITE_OK ){
|
||||
rc = sqlite3_create_function(db, "sha3_query", 1,
|
||||
SQLITE_UTF8 | SQLITE_DIRECTONLY,
|
||||
0, sha3QueryFunc, 0, 0);
|
||||
rc = sqlite3_create_function(db, "sha3_query", 1, SQLITE_UTF8, 0,
|
||||
sha3QueryFunc, 0, 0);
|
||||
}
|
||||
if( rc==SQLITE_OK ){
|
||||
rc = sqlite3_create_function(db, "sha3_query", 2,
|
||||
SQLITE_UTF8 | SQLITE_DIRECTONLY,
|
||||
0, sha3QueryFunc, 0, 0);
|
||||
rc = sqlite3_create_function(db, "sha3_query", 2, SQLITE_UTF8, 0,
|
||||
sha3QueryFunc, 0, 0);
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
@ -2617,7 +2613,6 @@ static int fsdirConnect(
|
||||
pNew = (fsdir_tab*)sqlite3_malloc( sizeof(*pNew) );
|
||||
if( pNew==0 ) return SQLITE_NOMEM;
|
||||
memset(pNew, 0, sizeof(*pNew));
|
||||
sqlite3_vtab_config(db, SQLITE_VTAB_DIRECTONLY);
|
||||
}
|
||||
*ppVtab = (sqlite3_vtab*)pNew;
|
||||
return rc;
|
||||
@ -3011,12 +3006,10 @@ int sqlite3_fileio_init(
|
||||
int rc = SQLITE_OK;
|
||||
SQLITE_EXTENSION_INIT2(pApi);
|
||||
(void)pzErrMsg; /* Unused parameter */
|
||||
rc = sqlite3_create_function(db, "readfile", 1,
|
||||
SQLITE_UTF8|SQLITE_DIRECTONLY, 0,
|
||||
rc = sqlite3_create_function(db, "readfile", 1, SQLITE_UTF8, 0,
|
||||
readfileFunc, 0, 0);
|
||||
if( rc==SQLITE_OK ){
|
||||
rc = sqlite3_create_function(db, "writefile", -1,
|
||||
SQLITE_UTF8|SQLITE_DIRECTONLY, 0,
|
||||
rc = sqlite3_create_function(db, "writefile", -1, SQLITE_UTF8, 0,
|
||||
writefileFunc, 0, 0);
|
||||
}
|
||||
if( rc==SQLITE_OK ){
|
||||
@ -3151,7 +3144,6 @@ static int completionConnect(
|
||||
#define COMPLETION_COLUMN_WHOLELINE 2 /* Entire line seen so far */
|
||||
#define COMPLETION_COLUMN_PHASE 3 /* ePhase - used for debugging only */
|
||||
|
||||
sqlite3_vtab_config(db, SQLITE_VTAB_INNOCUOUS);
|
||||
rc = sqlite3_declare_vtab(db,
|
||||
"CREATE TABLE x("
|
||||
" candidate TEXT,"
|
||||
@ -4586,7 +4578,6 @@ static int zipfileConnect(
|
||||
zipfileDequote(pNew->zFile);
|
||||
}
|
||||
}
|
||||
sqlite3_vtab_config(db, SQLITE_VTAB_DIRECTONLY);
|
||||
*ppVtab = (sqlite3_vtab*)pNew;
|
||||
return rc;
|
||||
}
|
||||
@ -5199,25 +5190,25 @@ static int zipfileDeflate(
|
||||
u8 **ppOut, int *pnOut, /* Output */
|
||||
char **pzErr /* OUT: Error message */
|
||||
){
|
||||
int rc = SQLITE_OK;
|
||||
sqlite3_int64 nAlloc;
|
||||
z_stream str;
|
||||
sqlite3_int64 nAlloc = compressBound(nIn);
|
||||
u8 *aOut;
|
||||
int rc = SQLITE_OK;
|
||||
|
||||
memset(&str, 0, sizeof(str));
|
||||
str.next_in = (Bytef*)aIn;
|
||||
str.avail_in = nIn;
|
||||
deflateInit2(&str, 9, Z_DEFLATED, -15, 8, Z_DEFAULT_STRATEGY);
|
||||
|
||||
nAlloc = deflateBound(&str, nIn);
|
||||
aOut = (u8*)sqlite3_malloc64(nAlloc);
|
||||
if( aOut==0 ){
|
||||
rc = SQLITE_NOMEM;
|
||||
}else{
|
||||
int res;
|
||||
z_stream str;
|
||||
memset(&str, 0, sizeof(str));
|
||||
str.next_in = (Bytef*)aIn;
|
||||
str.avail_in = nIn;
|
||||
str.next_out = aOut;
|
||||
str.avail_out = nAlloc;
|
||||
|
||||
deflateInit2(&str, 9, Z_DEFLATED, -15, 8, Z_DEFAULT_STRATEGY);
|
||||
res = deflate(&str, Z_FINISH);
|
||||
|
||||
if( res==Z_STREAM_END ){
|
||||
*ppOut = aOut;
|
||||
*pnOut = (int)str.total_out;
|
||||
@ -5526,10 +5517,10 @@ static int zipfileBestIndex(
|
||||
idx = i;
|
||||
}
|
||||
}
|
||||
pIdxInfo->estimatedCost = 1000.0;
|
||||
if( idx>=0 ){
|
||||
pIdxInfo->aConstraintUsage[idx].argvIndex = 1;
|
||||
pIdxInfo->aConstraintUsage[idx].omit = 1;
|
||||
pIdxInfo->estimatedCost = 1000.0;
|
||||
pIdxInfo->idxNum = 1;
|
||||
}else if( unusable ){
|
||||
return SQLITE_CONSTRAINT;
|
||||
@ -5651,8 +5642,8 @@ static int zipfileGetMode(
|
||||
** identical, ignoring any trailing '/' character in either path. */
|
||||
static int zipfileComparePath(const char *zA, const char *zB, int nB){
|
||||
int nA = (int)strlen(zA);
|
||||
if( nA>0 && zA[nA-1]=='/' ) nA--;
|
||||
if( nB>0 && zB[nB-1]=='/' ) nB--;
|
||||
if( zA[nA-1]=='/' ) nA--;
|
||||
if( zB[nB-1]=='/' ) nB--;
|
||||
if( nA==nB && memcmp(zA, zB, nA)==0 ) return 0;
|
||||
return 1;
|
||||
}
|
||||
@ -5662,10 +5653,6 @@ static int zipfileBegin(sqlite3_vtab *pVtab){
|
||||
int rc = SQLITE_OK;
|
||||
|
||||
assert( pTab->pWriteFd==0 );
|
||||
if( pTab->zFile==0 || pTab->zFile[0]==0 ){
|
||||
pTab->base.zErrMsg = sqlite3_mprintf("zipfile: missing filename");
|
||||
return SQLITE_ERROR;
|
||||
}
|
||||
|
||||
/* Open a write fd on the file. Also load the entire central directory
|
||||
** structure into memory. During the transaction any new file data is
|
||||
@ -5840,7 +5827,6 @@ static int zipfileUpdate(
|
||||
|
||||
if( rc==SQLITE_OK ){
|
||||
zPath = (const char*)sqlite3_value_text(apVal[2]);
|
||||
if( zPath==0 ) zPath = "";
|
||||
nPath = (int)strlen(zPath);
|
||||
mTime = zipfileGetTime(apVal[4]);
|
||||
}
|
||||
@ -5850,15 +5836,11 @@ static int zipfileUpdate(
|
||||
** '/'. This appears to be required for compatibility with info-zip
|
||||
** (the unzip command on unix). It does not create directories
|
||||
** otherwise. */
|
||||
if( nPath<=0 || zPath[nPath-1]!='/' ){
|
||||
if( zPath[nPath-1]!='/' ){
|
||||
zFree = sqlite3_mprintf("%s/", zPath);
|
||||
if( zFree==0 ){ rc = SQLITE_NOMEM; }
|
||||
zPath = (const char*)zFree;
|
||||
if( zFree==0 ){
|
||||
rc = SQLITE_NOMEM;
|
||||
nPath = 0;
|
||||
}else{
|
||||
nPath = (int)strlen(zPath);
|
||||
}
|
||||
nPath++;
|
||||
}
|
||||
}
|
||||
|
||||
@ -6251,19 +6233,19 @@ void zipfileStep(sqlite3_context *pCtx, int nVal, sqlite3_value **apVal){
|
||||
** at the end of the path. Or, if this is not a directory and the path
|
||||
** ends in '/' it is an error. */
|
||||
if( bIsDir==0 ){
|
||||
if( nName>0 && zName[nName-1]=='/' ){
|
||||
if( zName[nName-1]=='/' ){
|
||||
zErr = sqlite3_mprintf("non-directory name must not end with /");
|
||||
rc = SQLITE_ERROR;
|
||||
goto zipfile_step_out;
|
||||
}
|
||||
}else{
|
||||
if( nName==0 || zName[nName-1]!='/' ){
|
||||
if( zName[nName-1]!='/' ){
|
||||
zName = zFree = sqlite3_mprintf("%s/", zName);
|
||||
nName++;
|
||||
if( zName==0 ){
|
||||
rc = SQLITE_NOMEM;
|
||||
goto zipfile_step_out;
|
||||
}
|
||||
nName = (int)strlen(zName);
|
||||
}else{
|
||||
while( nName>1 && zName[nName-2]=='/' ) nName--;
|
||||
}
|
||||
@ -6519,12 +6501,10 @@ int sqlite3_sqlar_init(
|
||||
int rc = SQLITE_OK;
|
||||
SQLITE_EXTENSION_INIT2(pApi);
|
||||
(void)pzErrMsg; /* Unused parameter */
|
||||
rc = sqlite3_create_function(db, "sqlar_compress", 1,
|
||||
SQLITE_UTF8|SQLITE_INNOCUOUS, 0,
|
||||
rc = sqlite3_create_function(db, "sqlar_compress", 1, SQLITE_UTF8, 0,
|
||||
sqlarCompressFunc, 0, 0);
|
||||
if( rc==SQLITE_OK ){
|
||||
rc = sqlite3_create_function(db, "sqlar_uncompress", 2,
|
||||
SQLITE_UTF8|SQLITE_INNOCUOUS, 0,
|
||||
rc = sqlite3_create_function(db, "sqlar_uncompress", 2, SQLITE_UTF8, 0,
|
||||
sqlarUncompressFunc, 0, 0);
|
||||
}
|
||||
return rc;
|
||||
@ -6545,8 +6525,8 @@ int sqlite3_sqlar_init(
|
||||
**
|
||||
*************************************************************************
|
||||
*/
|
||||
#if !defined(SQLITEEXPERT_H)
|
||||
#define SQLITEEXPERT_H 1
|
||||
|
||||
|
||||
/* #include "sqlite3.h" */
|
||||
|
||||
typedef struct sqlite3expert sqlite3expert;
|
||||
@ -6700,7 +6680,7 @@ const char *sqlite3_expert_report(sqlite3expert*, int iStmt, int eReport);
|
||||
*/
|
||||
void sqlite3_expert_destroy(sqlite3expert*);
|
||||
|
||||
#endif /* !defined(SQLITEEXPERT_H) */
|
||||
|
||||
|
||||
/************************* End ../ext/expert/sqlite3expert.h ********************/
|
||||
/************************* Begin ../ext/expert/sqlite3expert.c ******************/
|
||||
@ -9586,7 +9566,6 @@ struct ShellState {
|
||||
int outCount; /* Revert to stdout when reaching zero */
|
||||
int cnt; /* Number of records displayed so far */
|
||||
int lineno; /* Line number of last line read from in */
|
||||
int openFlags; /* Additional flags to open. (SQLITE_OPEN_NOFOLLOW) */
|
||||
FILE *in; /* Read commands from this stream */
|
||||
FILE *out; /* Write results here */
|
||||
FILE *traceOut; /* Output for sqlite3_trace() */
|
||||
@ -10421,22 +10400,19 @@ static int shell_callback(
|
||||
const int *colWidth;
|
||||
int showHdr;
|
||||
char *rowSep;
|
||||
int nWidth;
|
||||
if( p->cMode==MODE_Column ){
|
||||
colWidth = p->colWidth;
|
||||
nWidth = ArraySize(p->colWidth);
|
||||
showHdr = p->showHeader;
|
||||
rowSep = p->rowSeparator;
|
||||
}else{
|
||||
colWidth = aExplainWidths;
|
||||
nWidth = ArraySize(aExplainWidths);
|
||||
showHdr = 1;
|
||||
rowSep = SEP_Row;
|
||||
}
|
||||
if( p->cnt++==0 ){
|
||||
for(i=0; i<nArg; i++){
|
||||
int w, n;
|
||||
if( i<nWidth ){
|
||||
if( i<ArraySize(p->colWidth) ){
|
||||
w = colWidth[i];
|
||||
}else{
|
||||
w = 0;
|
||||
@ -11326,9 +11302,6 @@ static void restore_debug_trace_modes(void){
|
||||
/* Create the TEMP table used to store parameter bindings */
|
||||
static void bind_table_init(ShellState *p){
|
||||
int wrSchema = 0;
|
||||
int defensiveMode = 0;
|
||||
sqlite3_db_config(p->db, SQLITE_DBCONFIG_DEFENSIVE, -1, &defensiveMode);
|
||||
sqlite3_db_config(p->db, SQLITE_DBCONFIG_DEFENSIVE, 0, 0);
|
||||
sqlite3_db_config(p->db, SQLITE_DBCONFIG_WRITABLE_SCHEMA, -1, &wrSchema);
|
||||
sqlite3_db_config(p->db, SQLITE_DBCONFIG_WRITABLE_SCHEMA, 1, 0);
|
||||
sqlite3_exec(p->db,
|
||||
@ -11338,7 +11311,6 @@ static void bind_table_init(ShellState *p){
|
||||
") WITHOUT ROWID;",
|
||||
0, 0, 0);
|
||||
sqlite3_db_config(p->db, SQLITE_DBCONFIG_WRITABLE_SCHEMA, wrSchema, 0);
|
||||
sqlite3_db_config(p->db, SQLITE_DBCONFIG_DEFENSIVE, defensiveMode, 0);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -12081,7 +12053,9 @@ static const char *(azHelp[]) = {
|
||||
".excel Display the output of next command in spreadsheet",
|
||||
".exit ?CODE? Exit this program with return-code CODE",
|
||||
".expert EXPERIMENTAL. Suggest indexes for queries",
|
||||
".explain ?on|off|auto? Change the EXPLAIN formatting mode. Default: auto",
|
||||
/* Because explain mode comes on automatically now, the ".explain" mode
|
||||
** is removed from the help screen. It is still supported for legacy, however */
|
||||
/*".explain ?on|off|auto? Turn EXPLAIN output mode on or off",*/
|
||||
".filectrl CMD ... Run various sqlite3_file_control() operations",
|
||||
" Run \".filectrl\" with no arguments for details",
|
||||
".fullschema ?--indent? Show schema and the content of sqlite_stat tables",
|
||||
@ -12132,7 +12106,6 @@ static const char *(azHelp[]) = {
|
||||
" --maxsize N Maximum size for --hexdb or --deserialized database",
|
||||
#endif
|
||||
" --new Initialize FILE to an empty database",
|
||||
" --nofollow Do not follow symbolic links",
|
||||
" --readonly Open FILE readonly",
|
||||
" --zip FILE is a ZIP archive",
|
||||
".output ?FILE? Send output to FILE or stdout if FILE is omitted",
|
||||
@ -12697,7 +12670,7 @@ static void open_db(ShellState *p, int openFlags){
|
||||
switch( p->openMode ){
|
||||
case SHELL_OPEN_APPENDVFS: {
|
||||
sqlite3_open_v2(p->zDbFilename, &p->db,
|
||||
SQLITE_OPEN_READWRITE|SQLITE_OPEN_CREATE|p->openFlags, "apndvfs");
|
||||
SQLITE_OPEN_READWRITE|SQLITE_OPEN_CREATE, "apndvfs");
|
||||
break;
|
||||
}
|
||||
case SHELL_OPEN_HEXDB:
|
||||
@ -12710,14 +12683,12 @@ static void open_db(ShellState *p, int openFlags){
|
||||
break;
|
||||
}
|
||||
case SHELL_OPEN_READONLY: {
|
||||
sqlite3_open_v2(p->zDbFilename, &p->db,
|
||||
SQLITE_OPEN_READONLY|p->openFlags, 0);
|
||||
sqlite3_open_v2(p->zDbFilename, &p->db, SQLITE_OPEN_READONLY, 0);
|
||||
break;
|
||||
}
|
||||
case SHELL_OPEN_UNSPEC:
|
||||
case SHELL_OPEN_NORMAL: {
|
||||
sqlite3_open_v2(p->zDbFilename, &p->db,
|
||||
SQLITE_OPEN_READWRITE|SQLITE_OPEN_CREATE|p->openFlags, 0);
|
||||
sqlite3_open(p->zDbFilename, &p->db);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -13491,7 +13462,7 @@ static unsigned int get4byteInt(unsigned char *a){
|
||||
}
|
||||
|
||||
/*
|
||||
** Implementation of the ".dbinfo" command.
|
||||
** Implementation of the ".info" command.
|
||||
**
|
||||
** Return 1 on error, 2 to exit, and 0 otherwise.
|
||||
*/
|
||||
@ -15728,22 +15699,20 @@ static int do_meta_command(char *zLine, ShellState *p){
|
||||
const char *zName;
|
||||
int op;
|
||||
} aDbConfig[] = {
|
||||
{ "defensive", SQLITE_DBCONFIG_DEFENSIVE },
|
||||
{ "dqs_ddl", SQLITE_DBCONFIG_DQS_DDL },
|
||||
{ "dqs_dml", SQLITE_DBCONFIG_DQS_DML },
|
||||
{ "enable_fkey", SQLITE_DBCONFIG_ENABLE_FKEY },
|
||||
{ "enable_qpsg", SQLITE_DBCONFIG_ENABLE_QPSG },
|
||||
{ "enable_trigger", SQLITE_DBCONFIG_ENABLE_TRIGGER },
|
||||
{ "enable_view", SQLITE_DBCONFIG_ENABLE_VIEW },
|
||||
{ "fts3_tokenizer", SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER },
|
||||
{ "legacy_alter_table", SQLITE_DBCONFIG_LEGACY_ALTER_TABLE },
|
||||
{ "legacy_file_format", SQLITE_DBCONFIG_LEGACY_FILE_FORMAT },
|
||||
{ "load_extension", SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION },
|
||||
{ "no_ckpt_on_close", SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE },
|
||||
{ "reset_database", SQLITE_DBCONFIG_RESET_DATABASE },
|
||||
{ "enable_qpsg", SQLITE_DBCONFIG_ENABLE_QPSG },
|
||||
{ "trigger_eqp", SQLITE_DBCONFIG_TRIGGER_EQP },
|
||||
{ "trusted_schema", SQLITE_DBCONFIG_TRUSTED_SCHEMA },
|
||||
{ "reset_database", SQLITE_DBCONFIG_RESET_DATABASE },
|
||||
{ "defensive", SQLITE_DBCONFIG_DEFENSIVE },
|
||||
{ "writable_schema", SQLITE_DBCONFIG_WRITABLE_SCHEMA },
|
||||
{ "legacy_alter_table", SQLITE_DBCONFIG_LEGACY_ALTER_TABLE },
|
||||
{ "dqs_dml", SQLITE_DBCONFIG_DQS_DML },
|
||||
{ "dqs_ddl", SQLITE_DBCONFIG_DQS_DDL },
|
||||
};
|
||||
int ii, v;
|
||||
open_db(p, 0);
|
||||
@ -15753,7 +15722,7 @@ static int do_meta_command(char *zLine, ShellState *p){
|
||||
sqlite3_db_config(p->db, aDbConfig[ii].op, booleanValue(azArg[2]), 0);
|
||||
}
|
||||
sqlite3_db_config(p->db, aDbConfig[ii].op, -1, &v);
|
||||
utf8_printf(p->out, "%19s %s\n", aDbConfig[ii].zName, v ? "on" : "off");
|
||||
utf8_printf(p->out, "%18s %s\n", aDbConfig[ii].zName, v ? "on" : "off");
|
||||
if( nArg>1 ) break;
|
||||
}
|
||||
if( nArg>1 && ii==ArraySize(aDbConfig) ){
|
||||
@ -16334,19 +16303,10 @@ static int do_meta_command(char *zLine, ShellState *p){
|
||||
char *zCollist = 0;
|
||||
sqlite3_stmt *pStmt;
|
||||
int tnum = 0;
|
||||
int isWO = 0; /* True if making an imposter of a WITHOUT ROWID table */
|
||||
int lenPK = 0; /* Length of the PRIMARY KEY string for isWO tables */
|
||||
int i;
|
||||
if( !(nArg==3 || (nArg==2 && sqlite3_stricmp(azArg[1],"off")==0)) ){
|
||||
utf8_printf(stderr, "Usage: .imposter INDEX IMPOSTER\n"
|
||||
" .imposter off\n");
|
||||
/* Also allowed, but not documented:
|
||||
**
|
||||
** .imposter TABLE IMPOSTER
|
||||
**
|
||||
** where TABLE is a WITHOUT ROWID table. In that case, the
|
||||
** imposter is another WITHOUT ROWID table with the columns in
|
||||
** storage order. */
|
||||
rc = 1;
|
||||
goto meta_command_exit;
|
||||
}
|
||||
@ -16355,22 +16315,19 @@ static int do_meta_command(char *zLine, ShellState *p){
|
||||
sqlite3_test_control(SQLITE_TESTCTRL_IMPOSTER, p->db, "main", 0, 1);
|
||||
goto meta_command_exit;
|
||||
}
|
||||
zSql = sqlite3_mprintf(
|
||||
"SELECT rootpage, 0 FROM sqlite_master"
|
||||
" WHERE name='%q' AND type='index'"
|
||||
"UNION ALL "
|
||||
"SELECT rootpage, 1 FROM sqlite_master"
|
||||
" WHERE name='%q' AND type='table'"
|
||||
" AND sql LIKE '%%without%%rowid%%'",
|
||||
azArg[1], azArg[1]
|
||||
);
|
||||
zSql = sqlite3_mprintf("SELECT rootpage FROM sqlite_master"
|
||||
" WHERE name='%q' AND type='index'", azArg[1]);
|
||||
sqlite3_prepare_v2(p->db, zSql, -1, &pStmt, 0);
|
||||
sqlite3_free(zSql);
|
||||
if( sqlite3_step(pStmt)==SQLITE_ROW ){
|
||||
tnum = sqlite3_column_int(pStmt, 0);
|
||||
isWO = sqlite3_column_int(pStmt, 1);
|
||||
}
|
||||
sqlite3_finalize(pStmt);
|
||||
if( tnum==0 ){
|
||||
utf8_printf(stderr, "no such index: \"%s\"\n", azArg[1]);
|
||||
rc = 1;
|
||||
goto meta_command_exit;
|
||||
}
|
||||
zSql = sqlite3_mprintf("PRAGMA index_xinfo='%q'", azArg[1]);
|
||||
rc = sqlite3_prepare_v2(p->db, zSql, -1, &pStmt, 0);
|
||||
sqlite3_free(zSql);
|
||||
@ -16387,9 +16344,6 @@ static int do_meta_command(char *zLine, ShellState *p){
|
||||
zCol = zLabel;
|
||||
}
|
||||
}
|
||||
if( isWO && lenPK==0 && sqlite3_column_int(pStmt,5)==0 && zCollist ){
|
||||
lenPK = (int)strlen(zCollist);
|
||||
}
|
||||
if( zCollist==0 ){
|
||||
zCollist = sqlite3_mprintf("\"%w\"", zCol);
|
||||
}else{
|
||||
@ -16397,16 +16351,9 @@ static int do_meta_command(char *zLine, ShellState *p){
|
||||
}
|
||||
}
|
||||
sqlite3_finalize(pStmt);
|
||||
if( i==0 || tnum==0 ){
|
||||
utf8_printf(stderr, "no such index: \"%s\"\n", azArg[1]);
|
||||
rc = 1;
|
||||
sqlite3_free(zCollist);
|
||||
goto meta_command_exit;
|
||||
}
|
||||
if( lenPK==0 ) lenPK = 100000;
|
||||
zSql = sqlite3_mprintf(
|
||||
"CREATE TABLE \"%w\"(%s,PRIMARY KEY(%.*s))WITHOUT ROWID",
|
||||
azArg[2], zCollist, lenPK, zCollist);
|
||||
"CREATE TABLE \"%w\"(%s,PRIMARY KEY(%s))WITHOUT ROWID",
|
||||
azArg[2], zCollist, zCollist);
|
||||
sqlite3_free(zCollist);
|
||||
rc = sqlite3_test_control(SQLITE_TESTCTRL_IMPOSTER, p->db, "main", 1, tnum);
|
||||
if( rc==SQLITE_OK ){
|
||||
@ -16417,8 +16364,7 @@ static int do_meta_command(char *zLine, ShellState *p){
|
||||
}else{
|
||||
utf8_printf(stdout, "%s;\n", zSql);
|
||||
raw_printf(stdout,
|
||||
"WARNING: writing to an imposter table will corrupt the \"%s\" %s!\n",
|
||||
azArg[1], isWO ? "table" : "index"
|
||||
"WARNING: writing to an imposter table will corrupt the index!\n"
|
||||
);
|
||||
}
|
||||
}else{
|
||||
@ -16616,7 +16562,6 @@ static int do_meta_command(char *zLine, ShellState *p){
|
||||
sqlite3_free(p->zFreeOnClose);
|
||||
p->zFreeOnClose = 0;
|
||||
p->openMode = SHELL_OPEN_UNSPEC;
|
||||
p->openFlags = 0;
|
||||
p->szMax = 0;
|
||||
/* Check for command-line arguments */
|
||||
for(iName=1; iName<nArg && azArg[iName][0]=='-'; iName++){
|
||||
@ -16631,8 +16576,6 @@ static int do_meta_command(char *zLine, ShellState *p){
|
||||
p->openMode = SHELL_OPEN_APPENDVFS;
|
||||
}else if( optionMatch(z, "readonly") ){
|
||||
p->openMode = SHELL_OPEN_READONLY;
|
||||
}else if( optionMatch(z, "nofollow") ){
|
||||
p->openFlags |= SQLITE_OPEN_NOFOLLOW;
|
||||
#ifdef SQLITE_ENABLE_DESERIALIZE
|
||||
}else if( optionMatch(z, "deserialize") ){
|
||||
p->openMode = SHELL_OPEN_DESERIALIZE;
|
||||
@ -17789,7 +17732,7 @@ static int do_meta_command(char *zLine, ShellState *p){
|
||||
{ "extra_schema_checks",SQLITE_TESTCTRL_EXTRA_SCHEMA_CHECKS,"BOOLEAN" },
|
||||
/*{ "fault_install", SQLITE_TESTCTRL_FAULT_INSTALL, "" },*/
|
||||
{ "imposter", SQLITE_TESTCTRL_IMPOSTER, "SCHEMA ON/OFF ROOTPAGE"},
|
||||
{ "internal_functions", SQLITE_TESTCTRL_INTERNAL_FUNCTIONS, "" },
|
||||
{ "internal_functions", SQLITE_TESTCTRL_INTERNAL_FUNCTIONS, "BOOLEAN" },
|
||||
{ "localtime_fault", SQLITE_TESTCTRL_LOCALTIME_FAULT,"BOOLEAN" },
|
||||
{ "never_corrupt", SQLITE_TESTCTRL_NEVER_CORRUPT, "BOOLEAN" },
|
||||
{ "optimizations", SQLITE_TESTCTRL_OPTIMIZATIONS, "DISABLE-MASK" },
|
||||
@ -17905,6 +17848,7 @@ static int do_meta_command(char *zLine, ShellState *p){
|
||||
/* sqlite3_test_control(int, int) */
|
||||
case SQLITE_TESTCTRL_ASSERT:
|
||||
case SQLITE_TESTCTRL_ALWAYS:
|
||||
case SQLITE_TESTCTRL_INTERNAL_FUNCTIONS:
|
||||
if( nArg==3 ){
|
||||
int opt = booleanValue(azArg[2]);
|
||||
rc2 = sqlite3_test_control(testctrl, opt);
|
||||
@ -17922,12 +17866,6 @@ static int do_meta_command(char *zLine, ShellState *p){
|
||||
}
|
||||
break;
|
||||
|
||||
/* sqlite3_test_control(sqlite3*) */
|
||||
case SQLITE_TESTCTRL_INTERNAL_FUNCTIONS:
|
||||
rc2 = sqlite3_test_control(testctrl, p->db);
|
||||
isOk = 3;
|
||||
break;
|
||||
|
||||
case SQLITE_TESTCTRL_IMPOSTER:
|
||||
if( nArg==5 ){
|
||||
rc2 = sqlite3_test_control(testctrl, p->db,
|
||||
@ -18558,7 +18496,6 @@ static const char zOptions[] =
|
||||
" -multiplex enable the multiplexor VFS\n"
|
||||
#endif
|
||||
" -newline SEP set output row separator. Default: '\\n'\n"
|
||||
" -nofollow refuse to open symbolic links to database files\n"
|
||||
" -nullvalue TEXT set text string for NULL values. Default ''\n"
|
||||
" -pagecache SIZE N use N slots of SZ bytes each for page cache memory\n"
|
||||
" -quote set output mode to 'quote'\n"
|
||||
@ -18869,8 +18806,6 @@ int SQLITE_CDECL wmain(int argc, wchar_t **wargv){
|
||||
#endif
|
||||
}else if( strcmp(z,"-readonly")==0 ){
|
||||
data.openMode = SHELL_OPEN_READONLY;
|
||||
}else if( strcmp(z,"-nofollow")==0 ){
|
||||
data.openFlags = SQLITE_OPEN_NOFOLLOW;
|
||||
#if !defined(SQLITE_OMIT_VIRTUALTABLE) && defined(SQLITE_HAVE_ZLIB)
|
||||
}else if( strncmp(z, "-A",2)==0 ){
|
||||
/* All remaining command-line arguments are passed to the ".archive"
|
||||
@ -18974,8 +18909,6 @@ int SQLITE_CDECL wmain(int argc, wchar_t **wargv){
|
||||
#endif
|
||||
}else if( strcmp(z,"-readonly")==0 ){
|
||||
data.openMode = SHELL_OPEN_READONLY;
|
||||
}else if( strcmp(z,"-nofollow")==0 ){
|
||||
data.openFlags |= SQLITE_OPEN_NOFOLLOW;
|
||||
}else if( strcmp(z,"-ascii")==0 ){
|
||||
data.mode = MODE_Ascii;
|
||||
sqlite3_snprintf(sizeof(data.colSeparator), data.colSeparator,
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -324,12 +324,6 @@ struct sqlite3_api_routines {
|
||||
int (*value_frombind)(sqlite3_value*);
|
||||
/* Version 3.30.0 and later */
|
||||
int (*drop_modules)(sqlite3*,const char**);
|
||||
/* Version 3.31.0 and later */
|
||||
sqlite3_int64 (*hard_heap_limit64)(sqlite3_int64);
|
||||
const char *(*uri_key)(const char*,int);
|
||||
const char *(*filename_database)(const char*);
|
||||
const char *(*filename_journal)(const char*);
|
||||
const char *(*filename_wal)(const char*);
|
||||
};
|
||||
|
||||
/*
|
||||
@ -624,12 +618,6 @@ typedef int (*sqlite3_loadext_entry)(
|
||||
#define sqlite3_value_frombind sqlite3_api->frombind
|
||||
/* Version 3.30.0 and later */
|
||||
#define sqlite3_drop_modules sqlite3_api->drop_modules
|
||||
/* Version 3.31.0 andn later */
|
||||
#define sqlite3_hard_heap_limit64 sqlite3_api->hard_heap_limit64
|
||||
#define sqlite3_uri_key sqlite3_api->uri_key
|
||||
#define sqlite3_filename_database sqlite3_api->filename_database
|
||||
#define sqlite3_filename_journal sqlite3_api->filename_journal
|
||||
#define sqlite3_filename_wal sqlite3_api->filename_wal
|
||||
#endif /* !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION) */
|
||||
|
||||
#if !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION)
|
||||
|
18
contrib/sqlite3/tea/configure
vendored
18
contrib/sqlite3/tea/configure
vendored
@ -1,6 +1,6 @@
|
||||
#! /bin/sh
|
||||
# Guess values for system-dependent variables and create Makefiles.
|
||||
# Generated by GNU Autoconf 2.69 for sqlite 3.31.0.
|
||||
# Generated by GNU Autoconf 2.69 for sqlite 3.30.1.
|
||||
#
|
||||
#
|
||||
# Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc.
|
||||
@ -577,8 +577,8 @@ MAKEFLAGS=
|
||||
# Identity of this package.
|
||||
PACKAGE_NAME='sqlite'
|
||||
PACKAGE_TARNAME='sqlite'
|
||||
PACKAGE_VERSION='3.31.0'
|
||||
PACKAGE_STRING='sqlite 3.31.0'
|
||||
PACKAGE_VERSION='3.30.1'
|
||||
PACKAGE_STRING='sqlite 3.30.1'
|
||||
PACKAGE_BUGREPORT=''
|
||||
PACKAGE_URL=''
|
||||
|
||||
@ -1303,7 +1303,7 @@ if test "$ac_init_help" = "long"; then
|
||||
# Omit some internal or obsolete options to make the list less imposing.
|
||||
# This message is too long to be a string in the A/UX 3.1 sh.
|
||||
cat <<_ACEOF
|
||||
\`configure' configures sqlite 3.31.0 to adapt to many kinds of systems.
|
||||
\`configure' configures sqlite 3.30.1 to adapt to many kinds of systems.
|
||||
|
||||
Usage: $0 [OPTION]... [VAR=VALUE]...
|
||||
|
||||
@ -1365,7 +1365,7 @@ fi
|
||||
|
||||
if test -n "$ac_init_help"; then
|
||||
case $ac_init_help in
|
||||
short | recursive ) echo "Configuration of sqlite 3.31.0:";;
|
||||
short | recursive ) echo "Configuration of sqlite 3.30.1:";;
|
||||
esac
|
||||
cat <<\_ACEOF
|
||||
|
||||
@ -1467,7 +1467,7 @@ fi
|
||||
test -n "$ac_init_help" && exit $ac_status
|
||||
if $ac_init_version; then
|
||||
cat <<\_ACEOF
|
||||
sqlite configure 3.31.0
|
||||
sqlite configure 3.30.1
|
||||
generated by GNU Autoconf 2.69
|
||||
|
||||
Copyright (C) 2012 Free Software Foundation, Inc.
|
||||
@ -1878,7 +1878,7 @@ cat >config.log <<_ACEOF
|
||||
This file contains any messages produced by compilers while
|
||||
running configure, to aid debugging if configure makes a mistake.
|
||||
|
||||
It was created by sqlite $as_me 3.31.0, which was
|
||||
It was created by sqlite $as_me 3.30.1, which was
|
||||
generated by GNU Autoconf 2.69. Invocation command line was
|
||||
|
||||
$ $0 $@
|
||||
@ -9373,7 +9373,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
|
||||
# report actual input values of CONFIG_FILES etc. instead of their
|
||||
# values after options handling.
|
||||
ac_log="
|
||||
This file was extended by sqlite $as_me 3.31.0, which was
|
||||
This file was extended by sqlite $as_me 3.30.1, which was
|
||||
generated by GNU Autoconf 2.69. Invocation command line was
|
||||
|
||||
CONFIG_FILES = $CONFIG_FILES
|
||||
@ -9426,7 +9426,7 @@ _ACEOF
|
||||
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
|
||||
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
|
||||
ac_cs_version="\\
|
||||
sqlite config.status 3.31.0
|
||||
sqlite config.status 3.30.1
|
||||
configured by $0, generated by GNU Autoconf 2.69,
|
||||
with options \\"\$ac_cs_config\\"
|
||||
|
||||
|
@ -19,7 +19,7 @@ dnl to configure the system for the local environment.
|
||||
# so you can encode the package version directly into the source files.
|
||||
#-----------------------------------------------------------------------
|
||||
|
||||
AC_INIT([sqlite], [3.31.0])
|
||||
AC_INIT([sqlite], [3.30.1])
|
||||
|
||||
#--------------------------------------------------------------------
|
||||
# Call TEA_INIT as the first TEA_ macro to set up initial vars.
|
||||
|
@ -2346,22 +2346,20 @@ static int SQLITE_TCLAPI DbObjCmd(
|
||||
const char *zName;
|
||||
int op;
|
||||
} aDbConfig[] = {
|
||||
{ "defensive", SQLITE_DBCONFIG_DEFENSIVE },
|
||||
{ "dqs_ddl", SQLITE_DBCONFIG_DQS_DDL },
|
||||
{ "dqs_dml", SQLITE_DBCONFIG_DQS_DML },
|
||||
{ "enable_fkey", SQLITE_DBCONFIG_ENABLE_FKEY },
|
||||
{ "enable_qpsg", SQLITE_DBCONFIG_ENABLE_QPSG },
|
||||
{ "enable_trigger", SQLITE_DBCONFIG_ENABLE_TRIGGER },
|
||||
{ "enable_view", SQLITE_DBCONFIG_ENABLE_VIEW },
|
||||
{ "fts3_tokenizer", SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER },
|
||||
{ "legacy_alter_table", SQLITE_DBCONFIG_LEGACY_ALTER_TABLE },
|
||||
{ "legacy_file_format", SQLITE_DBCONFIG_LEGACY_FILE_FORMAT },
|
||||
{ "load_extension", SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION },
|
||||
{ "no_ckpt_on_close", SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE },
|
||||
{ "reset_database", SQLITE_DBCONFIG_RESET_DATABASE },
|
||||
{ "enable_qpsg", SQLITE_DBCONFIG_ENABLE_QPSG },
|
||||
{ "trigger_eqp", SQLITE_DBCONFIG_TRIGGER_EQP },
|
||||
{ "trusted_schema", SQLITE_DBCONFIG_TRUSTED_SCHEMA },
|
||||
{ "reset_database", SQLITE_DBCONFIG_RESET_DATABASE },
|
||||
{ "defensive", SQLITE_DBCONFIG_DEFENSIVE },
|
||||
{ "writable_schema", SQLITE_DBCONFIG_WRITABLE_SCHEMA },
|
||||
{ "legacy_alter_table", SQLITE_DBCONFIG_LEGACY_ALTER_TABLE },
|
||||
{ "dqs_dml", SQLITE_DBCONFIG_DQS_DML },
|
||||
{ "dqs_ddl", SQLITE_DBCONFIG_DQS_DDL },
|
||||
};
|
||||
Tcl_Obj *pResult;
|
||||
int ii;
|
||||
@ -2825,7 +2823,6 @@ static int SQLITE_TCLAPI DbObjCmd(
|
||||
** --argcount N Function has exactly N arguments
|
||||
** --deterministic The function is pure
|
||||
** --directonly Prohibit use inside triggers and views
|
||||
** --innocuous Has no side effects or information leaks
|
||||
** --returntype TYPE Specify the return type of the function
|
||||
*/
|
||||
case DB_FUNCTION: {
|
||||
@ -2862,9 +2859,6 @@ static int SQLITE_TCLAPI DbObjCmd(
|
||||
if( n>1 && strncmp(z, "-directonly",n)==0 ){
|
||||
flags |= SQLITE_DIRECTONLY;
|
||||
}else
|
||||
if( n>1 && strncmp(z, "-innocuous",n)==0 ){
|
||||
flags |= SQLITE_INNOCUOUS;
|
||||
}else
|
||||
if( n>1 && strncmp(z, "-returntype", n)==0 ){
|
||||
const char *azType[] = {"integer", "real", "text", "blob", "any", 0};
|
||||
assert( SQLITE_INTEGER==1 && SQLITE_FLOAT==2 && SQLITE_TEXT==3 );
|
||||
@ -2881,7 +2875,7 @@ static int SQLITE_TCLAPI DbObjCmd(
|
||||
}else{
|
||||
Tcl_AppendResult(interp, "bad option \"", z,
|
||||
"\": must be -argcount, -deterministic, -directonly,"
|
||||
" -innocuous, or -returntype", (char*)0
|
||||
" or -returntype", (char*)0
|
||||
);
|
||||
return TCL_ERROR;
|
||||
}
|
||||
@ -3681,7 +3675,6 @@ static int sqliteCmdUsage(
|
||||
){
|
||||
Tcl_WrongNumArgs(interp, 1, objv,
|
||||
"HANDLE ?FILENAME? ?-vfs VFSNAME? ?-readonly BOOLEAN? ?-create BOOLEAN?"
|
||||
" ?-nofollow BOOLEAN?"
|
||||
" ?-nomutex BOOLEAN? ?-fullmutex BOOLEAN? ?-uri BOOLEAN?"
|
||||
#if defined(SQLITE_HAS_CODEC) && !defined(SQLITE_OMIT_CODEC_FROM_TCL)
|
||||
" ?-key CODECKEY?"
|
||||
@ -3693,7 +3686,6 @@ static int sqliteCmdUsage(
|
||||
/*
|
||||
** sqlite3 DBNAME FILENAME ?-vfs VFSNAME? ?-key KEY? ?-readonly BOOLEAN?
|
||||
** ?-create BOOLEAN? ?-nomutex BOOLEAN?
|
||||
** ?-nofollow BOOLEAN?
|
||||
**
|
||||
** This is the main Tcl command. When the "sqlite" Tcl command is
|
||||
** invoked, this routine runs to process that command.
|
||||
@ -3792,14 +3784,6 @@ static int SQLITE_TCLAPI DbMain(
|
||||
}else{
|
||||
flags &= ~SQLITE_OPEN_CREATE;
|
||||
}
|
||||
}else if( strcmp(zArg, "-nofollow")==0 ){
|
||||
int b;
|
||||
if( Tcl_GetBooleanFromObj(interp, objv[i], &b) ) return TCL_ERROR;
|
||||
if( b ){
|
||||
flags |= SQLITE_OPEN_NOFOLLOW;
|
||||
}else{
|
||||
flags &= ~SQLITE_OPEN_NOFOLLOW;
|
||||
}
|
||||
}else if( strcmp(zArg, "-nomutex")==0 ){
|
||||
int b;
|
||||
if( Tcl_GetBooleanFromObj(interp, objv[i], &b) ) return TCL_ERROR;
|
||||
|
@ -153,7 +153,7 @@ Please `cd` to its location first.
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
|
||||
PROJECT = tclsqlite3
|
||||
PROJECT = sqlite3
|
||||
!include "rules.vc"
|
||||
|
||||
# nmakehelp -V <file> <tag> will search the file for tag, skips until a
|
||||
@ -162,15 +162,18 @@ PROJECT = tclsqlite3
|
||||
|
||||
!if [echo REM = This file is generated from Makefile.vc > versions.vc]
|
||||
!endif
|
||||
# get project version from row "AC_INIT([sqlite], [3.x.y])"
|
||||
# get project version from row "AC_INIT([sqlite], [3.7.14])"
|
||||
!if [echo DOTVERSION = \>> versions.vc] \
|
||||
&& [nmakehlp -V ..\configure.ac AC_INIT >> versions.vc]
|
||||
&& [nmakehlp -V ..\configure.in AC_INIT >> versions.vc]
|
||||
!endif
|
||||
!include "versions.vc"
|
||||
|
||||
VERSION = $(DOTVERSION:.=)
|
||||
STUBPREFIX = $(PROJECT)stub
|
||||
|
||||
DLLOBJS = \
|
||||
$(TMP_DIR)\tclsqlite3.obj
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
# Target names and paths ( shouldn't need changing )
|
||||
#-------------------------------------------------------------------------
|
||||
@ -179,7 +182,7 @@ BINROOT = .
|
||||
ROOT = ..
|
||||
|
||||
PRJIMPLIB = $(OUT_DIR)\$(PROJECT)$(VERSION)$(SUFX).lib
|
||||
PRJLIBNAME = $(PROJECT).$(EXT)
|
||||
PRJLIBNAME = $(PROJECT)$(VERSION)$(SUFX).$(EXT)
|
||||
PRJLIB = $(OUT_DIR)\$(PRJLIBNAME)
|
||||
|
||||
PRJSTUBLIBNAME = $(STUBPREFIX)$(VERSION).lib
|
||||
@ -201,17 +204,6 @@ DOCDIR = $(ROOT)\doc
|
||||
TOOLSDIR = $(ROOT)\tools
|
||||
COMPATDIR = $(ROOT)\compat
|
||||
|
||||
### Figure out where the primary source code file(s) is/are.
|
||||
!if exist("$(ROOT)\..\..\sqlite3.c") && exist("$(ROOT)\..\..\src\tclsqlite.c")
|
||||
SQL_INCLUDES = -I"$(ROOT)\..\.."
|
||||
SQLITE_SRCDIR = $(ROOT)\..\..
|
||||
TCLSQLITE_SRCDIR = $(ROOT)\..\..\src
|
||||
DLLOBJS = $(TMP_DIR)\sqlite3.obj $(TMP_DIR)\tclsqlite.obj
|
||||
!else
|
||||
TCLSQLITE_SRCDIR = $(ROOT)\generic
|
||||
DLLOBJS = $(TMP_DIR)\tclsqlite3.obj
|
||||
!endif
|
||||
|
||||
#---------------------------------------------------------------------
|
||||
# Compile flags
|
||||
#---------------------------------------------------------------------
|
||||
@ -231,7 +223,7 @@ cdebug = -Z7 -WX -Od -GZ
|
||||
!endif
|
||||
|
||||
### Declarations common to all compiler options
|
||||
cflags = -nologo -c -W3 -D_CRT_SECURE_NO_WARNINGS -YX -Fp$(TMP_DIR)^\
|
||||
cflags = -nologo -c -W3 -YX -Fp$(TMP_DIR)^\
|
||||
|
||||
!if $(MSVCRT)
|
||||
!if $(DEBUG)
|
||||
@ -247,8 +239,8 @@ crt = -MT
|
||||
!endif
|
||||
!endif
|
||||
|
||||
INCLUDES = $(SQL_INCLUDES) $(TCL_INCLUDES) -I"$(WINDIR)" \
|
||||
-I"$(GENERICDIR)" -I"$(ROOT)\.."
|
||||
INCLUDES = $(TCL_INCLUDES) -I"$(WINDIR)" -I"$(GENERICDIR)" \
|
||||
-I"$(ROOT)\.."
|
||||
BASE_CLFAGS = $(cflags) $(cdebug) $(crt) $(INCLUDES) \
|
||||
-DSQLITE_3_SUFFIX_ONLY=1 -DSQLITE_ENABLE_RTREE=1 \
|
||||
-DSQLITE_ENABLE_FTS3=1 -DSQLITE_OMIT_DEPRECATED=1
|
||||
@ -349,17 +341,20 @@ $(PRJSTUBLIB): $(PRJSTUBOBJS)
|
||||
# Implicit rules
|
||||
#---------------------------------------------------------------------
|
||||
|
||||
$(TMP_DIR)\sqlite3.obj: $(SQLITE_SRCDIR)\sqlite3.c
|
||||
$(cc32) $(TCL_CFLAGS) -DBUILD_$(PROJECT) -Fo$(TMP_DIR)\ \
|
||||
-c $(SQLITE_SRCDIR)\sqlite3.c
|
||||
{$(WINDIR)}.c{$(TMP_DIR)}.obj::
|
||||
$(cc32) $(TCL_CFLAGS) -DBUILD_$(PROJECT) -Fo$(TMP_DIR)\ @<<
|
||||
$<
|
||||
<<
|
||||
|
||||
$(TMP_DIR)\tclsqlite.obj: $(TCLSQLITE_SRCDIR)\tclsqlite.c
|
||||
$(cc32) $(TCL_CFLAGS) -DBUILD_$(PROJECT) -Fo$(TMP_DIR)\ \
|
||||
-c $(TCLSQLITE_SRCDIR)\tclsqlite.c
|
||||
{$(GENERICDIR)}.c{$(TMP_DIR)}.obj::
|
||||
$(cc32) $(TCL_CFLAGS) -DBUILD_$(PROJECT) -Fo$(TMP_DIR)\ @<<
|
||||
$<
|
||||
<<
|
||||
|
||||
$(TMP_DIR)\tclsqlite3.obj: $(TCLSQLITE_SRCDIR)\tclsqlite3.c
|
||||
$(cc32) $(TCL_CFLAGS) -DBUILD_$(PROJECT) -Fo$(TMP_DIR)\ \
|
||||
-c $(TCLSQLITE_SRCDIR)\tclsqlite3.c
|
||||
{$(COMPATDIR)}.c{$(TMP_DIR)}.obj::
|
||||
$(cc32) $(TCL_CFLAGS) -DBUILD_$(PROJECT) -Fo$(TMP_DIR)\ @<<
|
||||
$<
|
||||
<<
|
||||
|
||||
{$(WINDIR)}.rc{$(TMP_DIR)}.res:
|
||||
$(rc32) -fo $@ -r -i "$(GENERICDIR)" -D__WIN32__ \
|
||||
|
@ -45,7 +45,6 @@
|
||||
# include <sys/systemcfg.h>
|
||||
|
||||
#elif defined(TUKLIB_PHYSMEM_SYSCONF)
|
||||
# include <limits.h>
|
||||
# include <unistd.h>
|
||||
|
||||
#elif defined(TUKLIB_PHYSMEM_SYSCTL)
|
||||
@ -146,16 +145,13 @@ tuklib_physmem(void)
|
||||
#elif defined(TUKLIB_PHYSMEM_SYSCONF)
|
||||
const long pagesize = sysconf(_SC_PAGESIZE);
|
||||
const long pages = sysconf(_SC_PHYS_PAGES);
|
||||
if (pagesize != -1 && pages != -1) {
|
||||
if (pagesize != -1 && pages != -1)
|
||||
// According to docs, pagesize * pages can overflow.
|
||||
// Simple case is 32-bit box with 4 GiB or more RAM,
|
||||
// which may report exactly 4 GiB of RAM, and "long"
|
||||
// being 32-bit will overflow. Casting to uint64_t
|
||||
// hopefully avoids overflows in the near future.
|
||||
ret = (uint64_t)pagesize * (uint64_t)pages;
|
||||
if (ret > SIZE_T_MAX)
|
||||
ret = SIZE_T_MAX;
|
||||
}
|
||||
|
||||
#elif defined(TUKLIB_PHYSMEM_SYSCTL)
|
||||
int name[2] = {
|
||||
|
@ -68,9 +68,39 @@ hardware_memlimit_set(uint64_t new_memlimit,
|
||||
new_memlimit = (uint32_t)new_memlimit * total_ram / 100;
|
||||
}
|
||||
|
||||
if (set_compress)
|
||||
if (set_compress) {
|
||||
memlimit_compress = new_memlimit;
|
||||
|
||||
#if SIZE_MAX == UINT32_MAX
|
||||
// FIXME?
|
||||
//
|
||||
// When running a 32-bit xz on a system with a lot of RAM and
|
||||
// using a percentage-based memory limit, the result can be
|
||||
// bigger than the 32-bit address space. Limiting the limit
|
||||
// below SIZE_MAX for compression (not decompression) makes
|
||||
// xz lower the compression settings (or number of threads)
|
||||
// to a level that *might* work. In practice it has worked
|
||||
// when using a 64-bit kernel that gives full 4 GiB address
|
||||
// space to 32-bit programs. In other situations this might
|
||||
// still be too high, like 32-bit kernels that may give much
|
||||
// less than 4 GiB to a single application.
|
||||
//
|
||||
// So this is an ugly hack but I will keep it here while
|
||||
// it does more good than bad.
|
||||
//
|
||||
// Use a value less than SIZE_MAX so that there's some room
|
||||
// for the xz program and so on. Don't use 4000 MiB because
|
||||
// it could look like someone mixed up base-2 and base-10.
|
||||
const uint64_t limit_max = UINT64_C(4020) << 20;
|
||||
|
||||
// UINT64_MAX is a special case for the string "max" so
|
||||
// that has to be handled specially.
|
||||
if (memlimit_compress != UINT64_MAX
|
||||
&& memlimit_compress > limit_max)
|
||||
memlimit_compress = limit_max;
|
||||
#endif
|
||||
}
|
||||
|
||||
if (set_decompress)
|
||||
memlimit_decompress = new_memlimit;
|
||||
|
||||
|
@ -1005,6 +1005,25 @@ instead of
|
||||
until the details have been decided.
|
||||
.RE
|
||||
.IP ""
|
||||
For 32-bit
|
||||
.BR xz
|
||||
there is a special case: if the
|
||||
.I limit
|
||||
would be over
|
||||
.BR "4020\ MiB" ,
|
||||
the
|
||||
.I limit
|
||||
is set to
|
||||
.BR "4020\ MiB" .
|
||||
(The values
|
||||
.B 0
|
||||
and
|
||||
.B max
|
||||
aren't affected by this.
|
||||
A similar feature doesn't exist for decompression.)
|
||||
This can be helpful when a 32-bit executable has access
|
||||
to 4\ GiB address space while hopefully doing no harm in other situations.
|
||||
.IP ""
|
||||
See also the section
|
||||
.BR "Memory usage" .
|
||||
.TP
|
||||
|
@ -1,74 +0,0 @@
|
||||
# $FreeBSD$
|
||||
|
||||
.include <src.opts.mk>
|
||||
MK_SSP= no
|
||||
|
||||
GCCDIR= ${SRCTOP}/contrib/gcc
|
||||
GCCLIB= ${SRCTOP}/contrib/gcclibs
|
||||
CCDIR= ${SRCTOP}/gnu/usr.bin/cc
|
||||
.include "${CCDIR}/Makefile.tgt"
|
||||
.include "${CCDIR}/cc_tools/Makefile.hdrs"
|
||||
|
||||
.PATH: ${GCCDIR}/config/${GCC_CPU} ${GCCDIR}
|
||||
|
||||
SRCS= crtstuff.c ${COMMONHDRS}
|
||||
OBJS= crtbegin.o crtend.o crtbeginT.o
|
||||
SOBJS= crtbeginS.o crtendS.o
|
||||
DEPENDOBJS+= ${OBJS} ${SOBJS}
|
||||
CSTD?= gnu89
|
||||
CFLAGS+= -DIN_GCC -DHAVE_LD_EH_FRAME_HDR -DDT_CONFIG -D__GLIBC__=3
|
||||
CFLAGS.gcc+= -finhibit-size-directive -fno-toplevel-reorder
|
||||
CFLAGS+= -fno-inline-functions -fno-exceptions \
|
||||
-fno-zero-initialized-in-bss -fno-asynchronous-unwind-tables \
|
||||
-fno-omit-frame-pointer
|
||||
CFLAGS+= -I${GCCLIB}/include -I${GCCDIR}/config -I${GCCDIR} -I. \
|
||||
-I${CCDIR}/cc_tools
|
||||
CRTS_CFLAGS= -DCRTSTUFFS_O -DSHARED ${PICFLAG}
|
||||
|
||||
.if ${TARGET_CPUARCH} == "arm"
|
||||
CFLAGS+= -DTARGET_ARM_EABI
|
||||
.endif
|
||||
|
||||
.if ${MACHINE_CPUARCH} == "sparc64"
|
||||
TGTOBJS= crtfastmath.o
|
||||
SRCS+= crtfastmath.c
|
||||
.endif
|
||||
BEGINSRC?= crtstuff.c
|
||||
ENDSRC?= crtstuff.c
|
||||
|
||||
FILES= ${OBJS} ${SOBJS} ${TGTOBJS}
|
||||
FILESMODE= ${LIBMODE}
|
||||
FILESOWN= ${LIBOWN}
|
||||
FILESGRP= ${LIBGRP}
|
||||
FILESDIR= ${LIBDIR}
|
||||
# These FILES qualify as libraries for the purpose of LIBRARIES_ONLY.
|
||||
.undef LIBRARIES_ONLY
|
||||
|
||||
${OBJS} ${SOBJS}: ${SRCS:M*.h}
|
||||
|
||||
CLEANFILES= ${OBJS} ${SOBJS} ${TGTOBJS}
|
||||
|
||||
crtbegin.o: ${BEGINSRC}
|
||||
${CC} ${CFLAGS} -g0 -DCRT_BEGIN \
|
||||
-c -o ${.TARGET} ${.ALLSRC:N*.h:[1]}
|
||||
|
||||
crtbeginT.o: ${BEGINSRC}
|
||||
${CC} ${CFLAGS} -g0 -DCRT_BEGIN -DCRTSTUFFT_O \
|
||||
-c -o ${.TARGET} ${.ALLSRC:N*.h:[1]}
|
||||
|
||||
crtbeginS.o: ${BEGINSRC}
|
||||
${CC} ${CFLAGS} -g0 -DCRT_BEGIN ${CRTS_CFLAGS} \
|
||||
-c -o ${.TARGET} ${.ALLSRC:N*.h:[1]}
|
||||
|
||||
crtend.o: ${ENDSRC}
|
||||
${CC} ${CFLAGS} -g0 -DCRT_END \
|
||||
-c -o ${.TARGET} ${.ALLSRC:N*.h:[1]}
|
||||
|
||||
crtendS.o: ${ENDSRC}
|
||||
${CC} ${CFLAGS} -g0 -DCRT_END ${CRTS_CFLAGS} \
|
||||
-c -o ${.TARGET} ${.ALLSRC:N*.h:[1]}
|
||||
|
||||
COMMONHDRS+= tm.h tconfig.h options.h
|
||||
CLEANFILES+= ${COMMONHDRS} optionlist cs-tconfig.h cs-tm.h
|
||||
|
||||
.include <bsd.lib.mk>
|
@ -1,13 +0,0 @@
|
||||
# $FreeBSD$
|
||||
# Autogenerated - do NOT edit!
|
||||
|
||||
DIRDEPS = \
|
||||
include \
|
||||
include/xlocale \
|
||||
|
||||
|
||||
.include <dirdeps.mk>
|
||||
|
||||
.if ${DEP_RELDIR} == ${_DEP_RELDIR}
|
||||
# local dependencies - needed for -jN in clean tree
|
||||
.endif
|
@ -348,6 +348,7 @@ int feof_unlocked(FILE *);
|
||||
int ferror_unlocked(FILE *);
|
||||
int fflush_unlocked(FILE *);
|
||||
int fileno_unlocked(FILE *);
|
||||
int fputc_unlocked(int, FILE *);
|
||||
int fputs_unlocked(const char * __restrict, FILE * __restrict);
|
||||
size_t fread_unlocked(void * __restrict, size_t, size_t, FILE * __restrict);
|
||||
size_t fwrite_unlocked(const void * __restrict, size_t, size_t,
|
||||
|
@ -31,7 +31,8 @@ CFLAGS+=-DNO__SCCSID -DNO__RCSID
|
||||
|
||||
LIB=c
|
||||
SHLIB_MAJOR= 7
|
||||
.if ${MK_SSP} != "no"
|
||||
.if ${MK_SSP} != "no" && \
|
||||
(${LIBC_ARCH} == "i386" || ${MACHINE_ARCH:Mpower*} != "")
|
||||
SHLIB_LDSCRIPT=libc.ldscript
|
||||
.else
|
||||
SHLIB_LDSCRIPT=libc_nossp.ldscript
|
||||
@ -59,7 +60,8 @@ CFLAGS+=${CANCELPOINTS_CFLAGS}
|
||||
LDFLAGS+= -nodefaultlibs
|
||||
LIBADD+= compiler_rt
|
||||
|
||||
.if ${MK_SSP} != "no"
|
||||
.if ${MK_SSP} != "no" && \
|
||||
(${LIBC_ARCH} == "i386" || ${MACHINE_ARCH:Mpower*} != "")
|
||||
LIBADD+= ssp_nonshared
|
||||
.endif
|
||||
|
||||
|
@ -438,8 +438,8 @@ iruserok_sa(const void *ra, int rlen, int superuser, const char *ruser,
|
||||
struct sockaddr_storage ss;
|
||||
|
||||
/* avoid alignment issue */
|
||||
if (rlen > sizeof(ss))
|
||||
return(-1);
|
||||
if (rlen <= 0 || rlen > sizeof(ss))
|
||||
return (-1);
|
||||
memcpy(&ss, ra, rlen);
|
||||
raddr = (struct sockaddr *)&ss;
|
||||
|
||||
|
@ -38,13 +38,14 @@ __FBSDID("$FreeBSD$");
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <machine/sysarch.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
/* NB: size of 'struct tcb'. */
|
||||
#define TP_OFFSET (sizeof(void *) * 2)
|
||||
|
||||
void
|
||||
_set_tp(void *tp)
|
||||
{
|
||||
|
||||
__asm __volatile("mv tp, %0" :: "r"((char*)tp + 0x10));
|
||||
__asm __volatile("addi tp, %0, %1" :: "r" (tp), "I" (TP_OFFSET));
|
||||
}
|
||||
|
@ -54,29 +54,28 @@ xdr_rpcbs_addrlist(XDR *xdrs, rpcbs_addrlist *objp)
|
||||
{
|
||||
struct rpcbs_addrlist **pnext;
|
||||
|
||||
if (!xdr_rpcprog(xdrs, &objp->prog)) {
|
||||
if (!xdr_rpcprog(xdrs, &objp->prog)) {
|
||||
return (FALSE);
|
||||
}
|
||||
if (!xdr_rpcvers(xdrs, &objp->vers)) {
|
||||
}
|
||||
if (!xdr_rpcvers(xdrs, &objp->vers)) {
|
||||
return (FALSE);
|
||||
}
|
||||
if (!xdr_int(xdrs, &objp->success)) {
|
||||
}
|
||||
if (!xdr_int(xdrs, &objp->success)) {
|
||||
return (FALSE);
|
||||
}
|
||||
if (!xdr_int(xdrs, &objp->failure)) {
|
||||
}
|
||||
if (!xdr_int(xdrs, &objp->failure)) {
|
||||
return (FALSE);
|
||||
}
|
||||
if (!xdr_string(xdrs, &objp->netid, RPC_MAXDATASIZE)) {
|
||||
}
|
||||
if (!xdr_string(xdrs, &objp->netid, RPC_MAXDATASIZE)) {
|
||||
return (FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
pnext = &objp->next;
|
||||
|
||||
if (!xdr_pointer(xdrs, (char **) pnext,
|
||||
pnext = &objp->next;
|
||||
if (!xdr_pointer(xdrs, (char **) pnext,
|
||||
sizeof (rpcbs_addrlist),
|
||||
(xdrproc_t)xdr_rpcbs_addrlist)) {
|
||||
return (FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
return (TRUE);
|
||||
}
|
||||
@ -86,86 +85,86 @@ xdr_rpcbs_addrlist(XDR *xdrs, rpcbs_addrlist *objp)
|
||||
bool_t
|
||||
xdr_rpcbs_rmtcalllist(XDR *xdrs, rpcbs_rmtcalllist *objp)
|
||||
{
|
||||
int32_t *buf;
|
||||
struct rpcbs_rmtcalllist **pnext;
|
||||
int32_t *buf;
|
||||
|
||||
if (xdrs->x_op == XDR_ENCODE) {
|
||||
buf = XDR_INLINE(xdrs, 6 * BYTES_PER_XDR_UNIT);
|
||||
if (buf == NULL) {
|
||||
if (!xdr_rpcprog(xdrs, &objp->prog)) {
|
||||
return (FALSE);
|
||||
}
|
||||
if (!xdr_rpcvers(xdrs, &objp->vers)) {
|
||||
return (FALSE);
|
||||
}
|
||||
if (!xdr_rpcproc(xdrs, &objp->proc)) {
|
||||
return (FALSE);
|
||||
}
|
||||
if (!xdr_int(xdrs, &objp->success)) {
|
||||
return (FALSE);
|
||||
}
|
||||
if (!xdr_int(xdrs, &objp->failure)) {
|
||||
return (FALSE);
|
||||
}
|
||||
if (!xdr_int(xdrs, &objp->indirect)) {
|
||||
return (FALSE);
|
||||
}
|
||||
} else {
|
||||
IXDR_PUT_U_INT32(buf, objp->prog);
|
||||
IXDR_PUT_U_INT32(buf, objp->vers);
|
||||
IXDR_PUT_U_INT32(buf, objp->proc);
|
||||
IXDR_PUT_INT32(buf, objp->success);
|
||||
IXDR_PUT_INT32(buf, objp->failure);
|
||||
IXDR_PUT_INT32(buf, objp->indirect);
|
||||
}
|
||||
if (!xdr_string(xdrs, &objp->netid, RPC_MAXDATASIZE)) {
|
||||
return (FALSE);
|
||||
}
|
||||
pnext = &objp->next;
|
||||
if (!xdr_pointer(xdrs, (char **) pnext,
|
||||
sizeof (rpcbs_rmtcalllist),
|
||||
(xdrproc_t)xdr_rpcbs_rmtcalllist)) {
|
||||
return (FALSE);
|
||||
}
|
||||
return (TRUE);
|
||||
if (xdrs->x_op == XDR_ENCODE) {
|
||||
buf = XDR_INLINE(xdrs, 6 * BYTES_PER_XDR_UNIT);
|
||||
if (buf == NULL) {
|
||||
if (!xdr_rpcprog(xdrs, &objp->prog)) {
|
||||
return (FALSE);
|
||||
}
|
||||
if (!xdr_rpcvers(xdrs, &objp->vers)) {
|
||||
return (FALSE);
|
||||
}
|
||||
if (!xdr_rpcproc(xdrs, &objp->proc)) {
|
||||
return (FALSE);
|
||||
}
|
||||
if (!xdr_int(xdrs, &objp->success)) {
|
||||
return (FALSE);
|
||||
}
|
||||
if (!xdr_int(xdrs, &objp->failure)) {
|
||||
return (FALSE);
|
||||
}
|
||||
if (!xdr_int(xdrs, &objp->indirect)) {
|
||||
return (FALSE);
|
||||
}
|
||||
} else {
|
||||
IXDR_PUT_U_INT32(buf, objp->prog);
|
||||
IXDR_PUT_U_INT32(buf, objp->vers);
|
||||
IXDR_PUT_U_INT32(buf, objp->proc);
|
||||
IXDR_PUT_INT32(buf, objp->success);
|
||||
IXDR_PUT_INT32(buf, objp->failure);
|
||||
IXDR_PUT_INT32(buf, objp->indirect);
|
||||
}
|
||||
if (!xdr_string(xdrs, &objp->netid, RPC_MAXDATASIZE)) {
|
||||
return (FALSE);
|
||||
}
|
||||
if (!xdr_pointer(xdrs, (char **) pnext,
|
||||
sizeof (rpcbs_rmtcalllist),
|
||||
(xdrproc_t)xdr_rpcbs_rmtcalllist)) {
|
||||
return (FALSE);
|
||||
}
|
||||
return (TRUE);
|
||||
} else if (xdrs->x_op == XDR_DECODE) {
|
||||
buf = XDR_INLINE(xdrs, 6 * BYTES_PER_XDR_UNIT);
|
||||
if (buf == NULL) {
|
||||
if (!xdr_rpcprog(xdrs, &objp->prog)) {
|
||||
buf = XDR_INLINE(xdrs, 6 * BYTES_PER_XDR_UNIT);
|
||||
if (buf == NULL) {
|
||||
if (!xdr_rpcprog(xdrs, &objp->prog)) {
|
||||
return (FALSE);
|
||||
}
|
||||
if (!xdr_rpcvers(xdrs, &objp->vers)) {
|
||||
return (FALSE);
|
||||
}
|
||||
if (!xdr_rpcproc(xdrs, &objp->proc)) {
|
||||
return (FALSE);
|
||||
}
|
||||
if (!xdr_int(xdrs, &objp->success)) {
|
||||
return (FALSE);
|
||||
}
|
||||
if (!xdr_int(xdrs, &objp->failure)) {
|
||||
return (FALSE);
|
||||
}
|
||||
if (!xdr_int(xdrs, &objp->indirect)) {
|
||||
return (FALSE);
|
||||
}
|
||||
} else {
|
||||
objp->prog = (rpcprog_t)IXDR_GET_U_INT32(buf);
|
||||
objp->vers = (rpcvers_t)IXDR_GET_U_INT32(buf);
|
||||
objp->proc = (rpcproc_t)IXDR_GET_U_INT32(buf);
|
||||
objp->success = (int)IXDR_GET_INT32(buf);
|
||||
objp->failure = (int)IXDR_GET_INT32(buf);
|
||||
objp->indirect = (int)IXDR_GET_INT32(buf);
|
||||
}
|
||||
if (!xdr_string(xdrs, &objp->netid, RPC_MAXDATASIZE)) {
|
||||
return (FALSE);
|
||||
}
|
||||
if (!xdr_rpcvers(xdrs, &objp->vers)) {
|
||||
if (!xdr_pointer(xdrs, (char **) pnext,
|
||||
sizeof (rpcbs_rmtcalllist),
|
||||
(xdrproc_t)xdr_rpcbs_rmtcalllist)) {
|
||||
return (FALSE);
|
||||
}
|
||||
if (!xdr_rpcproc(xdrs, &objp->proc)) {
|
||||
return (FALSE);
|
||||
}
|
||||
if (!xdr_int(xdrs, &objp->success)) {
|
||||
return (FALSE);
|
||||
}
|
||||
if (!xdr_int(xdrs, &objp->failure)) {
|
||||
return (FALSE);
|
||||
}
|
||||
if (!xdr_int(xdrs, &objp->indirect)) {
|
||||
return (FALSE);
|
||||
}
|
||||
} else {
|
||||
objp->prog = (rpcprog_t)IXDR_GET_U_INT32(buf);
|
||||
objp->vers = (rpcvers_t)IXDR_GET_U_INT32(buf);
|
||||
objp->proc = (rpcproc_t)IXDR_GET_U_INT32(buf);
|
||||
objp->success = (int)IXDR_GET_INT32(buf);
|
||||
objp->failure = (int)IXDR_GET_INT32(buf);
|
||||
objp->indirect = (int)IXDR_GET_INT32(buf);
|
||||
}
|
||||
if (!xdr_string(xdrs, &objp->netid, RPC_MAXDATASIZE)) {
|
||||
return (FALSE);
|
||||
}
|
||||
if (!xdr_pointer(xdrs, (char **) pnext,
|
||||
sizeof (rpcbs_rmtcalllist),
|
||||
(xdrproc_t)xdr_rpcbs_rmtcalllist)) {
|
||||
return (FALSE);
|
||||
}
|
||||
return (TRUE);
|
||||
return (TRUE);
|
||||
}
|
||||
if (!xdr_rpcprog(xdrs, &objp->prog)) {
|
||||
return (FALSE);
|
||||
|
@ -173,6 +173,7 @@ FBSD_1.5 {
|
||||
|
||||
FBSD_1.6 {
|
||||
fflush_unlocked;
|
||||
fputc_unlocked;
|
||||
fputs_unlocked;
|
||||
fread_unlocked;
|
||||
fwrite_unlocked;
|
||||
|
@ -46,14 +46,22 @@ __FBSDID("$FreeBSD$");
|
||||
|
||||
#undef fputc_unlocked
|
||||
|
||||
int
|
||||
fputc_unlocked(int c, FILE *fp)
|
||||
{
|
||||
|
||||
/* Orientation set by __sputc() when buffer is full. */
|
||||
/* ORIENT(fp, -1); */
|
||||
return (__sputc(c, fp));
|
||||
}
|
||||
|
||||
int
|
||||
fputc(int c, FILE *fp)
|
||||
{
|
||||
int retval;
|
||||
|
||||
FLOCKFILE_CANCELSAFE(fp);
|
||||
/* Orientation set by __sputc() when buffer is full. */
|
||||
/* ORIENT(fp, -1); */
|
||||
retval = __sputc(c, fp);
|
||||
retval = fputc_unlocked(c, fp);
|
||||
FUNLOCKFILE_CANCELSAFE();
|
||||
return (retval);
|
||||
}
|
||||
|
@ -28,7 +28,7 @@
|
||||
.\" @(#)open.2 8.2 (Berkeley) 11/16/93
|
||||
.\" $FreeBSD$
|
||||
.\"
|
||||
.Dd September 28, 2019
|
||||
.Dd January 31, 2020
|
||||
.Dt OPEN 2
|
||||
.Os
|
||||
.Sh NAME
|
||||
@ -166,6 +166,7 @@ O_RDONLY open for reading only
|
||||
O_WRONLY open for writing only
|
||||
O_RDWR open for reading and writing
|
||||
O_EXEC open for execute only
|
||||
O_SEARCH open for search only, an alias for O_EXEC
|
||||
O_NONBLOCK do not block on open
|
||||
O_APPEND append on each write
|
||||
O_CREAT create file if it does not exist
|
||||
@ -326,6 +327,19 @@ If the specified path is absolute,
|
||||
allows arbitrary prefix that ends up at the topping directory,
|
||||
after which all further resolved components must be under it.
|
||||
.Pp
|
||||
When
|
||||
.Fa fd
|
||||
is opened with
|
||||
.Dv O_SEARCH ,
|
||||
execute permissions are checked at open time.
|
||||
The
|
||||
.Fa fd
|
||||
may not be used for any read operations like
|
||||
.Xr getdirentries 2 .
|
||||
The primary use for this descriptor will be as the lookup descriptor for the
|
||||
.Fn *at
|
||||
family of functions.
|
||||
.Pp
|
||||
If successful,
|
||||
.Fn open
|
||||
returns a non-negative integer, termed a file descriptor.
|
||||
@ -518,9 +532,12 @@ An attempt was made to open a descriptor with an illegal combination
|
||||
of
|
||||
.Dv O_RDONLY ,
|
||||
.Dv O_WRONLY ,
|
||||
.Dv O_RDWR
|
||||
or
|
||||
.Dv O_RDWR ,
|
||||
and
|
||||
.Dv O_EXEC .
|
||||
.Dv O_EXEC
|
||||
or
|
||||
.Dv O_SEARCH .
|
||||
.It Bq Er EBADF
|
||||
The
|
||||
.Fa path
|
||||
|
@ -1,7 +1,5 @@
|
||||
# $FreeBSD$
|
||||
|
||||
#TODO: t_o_search
|
||||
|
||||
NETBSD_ATF_TESTS_C= faccessat_test
|
||||
NETBSD_ATF_TESTS_C+= fchmodat_test
|
||||
NETBSD_ATF_TESTS_C+= fchownat_test
|
||||
@ -11,6 +9,7 @@ NETBSD_ATF_TESTS_C+= linkat_test
|
||||
NETBSD_ATF_TESTS_C+= mkdirat_test
|
||||
NETBSD_ATF_TESTS_C+= mkfifoat_test
|
||||
NETBSD_ATF_TESTS_C+= mknodat_test
|
||||
NETBSD_ATF_TESTS_C+= o_search_test
|
||||
NETBSD_ATF_TESTS_C+= openat_test
|
||||
NETBSD_ATF_TESTS_C+= readlinkat_test
|
||||
NETBSD_ATF_TESTS_C+= renameat_test
|
||||
|
@ -41,7 +41,7 @@ static char *sccsid = "@(#)xdr_array.c 2.1 88/07/29 4.0 RPCSRC";
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
/*
|
||||
* xdr_array.c, Generic XDR routines impelmentation.
|
||||
* xdr_array.c, Generic XDR routines implementation.
|
||||
*
|
||||
* These are the "non-trivial" xdr primitives used to serialize and de-serialize
|
||||
* arrays. See xdr.h for more info on the interface to xdr.
|
||||
|
@ -41,7 +41,7 @@ static char *sccsid = "@(#)xdr_reference.c 2.1 88/07/29 4.0 RPCSRC";
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
/*
|
||||
* xdr_reference.c, Generic XDR routines impelmentation.
|
||||
* xdr_reference.c, Generic XDR routines implementation.
|
||||
*
|
||||
* These are the "non-trivial" xdr primitives used to serialize and de-serialize
|
||||
* "pointers". See xdr.h for more info on the interface to xdr.
|
||||
|
@ -327,6 +327,9 @@ fetch_pctdecode(char *dst, const char *src, size_t dlen)
|
||||
(d2 = fetch_hexval(s[2])) >= 0 && (d1 > 0 || d2 > 0)) {
|
||||
c = d1 << 4 | d2;
|
||||
s += 2;
|
||||
} else if (s[0] == '%') {
|
||||
/* Invalid escape sequence. */
|
||||
return (NULL);
|
||||
} else {
|
||||
c = *s;
|
||||
}
|
||||
|
@ -19,15 +19,14 @@ SRCS= kvm.c kvm_cptime.c kvm_getloadavg.c \
|
||||
kvm_minidump_mips.c \
|
||||
kvm_powerpc.c kvm_powerpc64.c \
|
||||
kvm_minidump_riscv.c \
|
||||
kvm_minidump_powerpc64.c kvm_minidump_powerpc64_hpt.c \
|
||||
kvm_sparc64.c
|
||||
kvm_minidump_powerpc64.c kvm_minidump_powerpc64_hpt.c
|
||||
INCS= kvm.h
|
||||
|
||||
LIBADD= elf
|
||||
|
||||
MAN= kvm.3 kvm_getcptime.3 kvm_geterr.3 kvm_getloadavg.3 \
|
||||
kvm_getpcpu.3 kvm_getprocs.3 kvm_getswapinfo.3 kvm_native.3 \
|
||||
kvm_nlist.3 kvm_open.3 kvm_read.3
|
||||
kvm_getpcpu.3 kvm_getprocs.3 kvm_getswapinfo.3 kvm_kerndisp.3 \
|
||||
kvm_native.3 kvm_nlist.3 kvm_open.3 kvm_read.3
|
||||
|
||||
MLINKS+=kvm_getpcpu.3 kvm_getmaxcpu.3 \
|
||||
kvm_getpcpu.3 kvm_dpcpu_setcpu.3 \
|
||||
|
@ -32,7 +32,7 @@
|
||||
.\" @(#)kvm.3 8.1 (Berkeley) 6/4/93
|
||||
.\" $FreeBSD$
|
||||
.\"
|
||||
.Dd April 30, 2016
|
||||
.Dd February 5, 2020
|
||||
.Dt KVM 3
|
||||
.Os
|
||||
.Sh NAME
|
||||
@ -133,7 +133,8 @@ respectively.
|
||||
Finally, only a limited subset of operations are supported for non-native
|
||||
crash dumps:
|
||||
.Fn kvm_close ,
|
||||
.Fn kvm_geterr
|
||||
.Fn kvm_geterr ,
|
||||
.Fn kvm_kerndisp ,
|
||||
.Fn kvm_open2 ,
|
||||
.Fn kvm_native ,
|
||||
.Fn kvm_nlist2 ,
|
||||
@ -147,6 +148,7 @@ and
|
||||
.Xr kvm_getloadavg 3 ,
|
||||
.Xr kvm_getprocs 3 ,
|
||||
.Xr kvm_getswapinfo 3 ,
|
||||
.Xr kvm_kerndisp 3 ,
|
||||
.Xr kvm_native 3 ,
|
||||
.Xr kvm_nlist 3 ,
|
||||
.Xr kvm_nlist2 3 ,
|
||||
|
@ -46,6 +46,7 @@ __SCCSID("@(#)kvm.c 8.2 (Berkeley) 2/13/94");
|
||||
#include <sys/linker.h>
|
||||
#include <sys/pcpu.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/sysctl.h>
|
||||
#include <sys/mman.h>
|
||||
|
||||
#include <net/vnet.h>
|
||||
@ -499,3 +500,32 @@ kvm_walk_pages(kvm_t *kd, kvm_walk_pages_cb_t *cb, void *closure)
|
||||
|
||||
return (kd->arch->ka_walk_pages(kd, cb, closure));
|
||||
}
|
||||
|
||||
kssize_t
|
||||
kvm_kerndisp(kvm_t *kd)
|
||||
{
|
||||
unsigned long kernbase, rel_kernbase;
|
||||
size_t kernbase_len = sizeof(kernbase);
|
||||
size_t rel_kernbase_len = sizeof(rel_kernbase);
|
||||
|
||||
if (ISALIVE(kd)) {
|
||||
if (sysctlbyname("kern.base_address", &kernbase,
|
||||
&kernbase_len, NULL, 0) == -1) {
|
||||
_kvm_syserr(kd, kd->program,
|
||||
"failed to get kernel base address");
|
||||
return (0);
|
||||
}
|
||||
if (sysctlbyname("kern.relbase_address", &rel_kernbase,
|
||||
&rel_kernbase_len, NULL, 0) == -1) {
|
||||
_kvm_syserr(kd, kd->program,
|
||||
"failed to get relocated kernel base address");
|
||||
return (0);
|
||||
}
|
||||
return (rel_kernbase - kernbase);
|
||||
}
|
||||
|
||||
if (kd->arch->ka_kerndisp == NULL)
|
||||
return (0);
|
||||
|
||||
return (kd->arch->ka_kerndisp(kd));
|
||||
}
|
||||
|
@ -124,6 +124,7 @@ ssize_t kvm_read(kvm_t *, unsigned long, void *, size_t);
|
||||
ssize_t kvm_read_zpcpu(kvm_t *, unsigned long, void *, size_t, int);
|
||||
ssize_t kvm_read2(kvm_t *, kvaddr_t, void *, size_t);
|
||||
ssize_t kvm_write(kvm_t *, unsigned long, const void *, size_t);
|
||||
kssize_t kvm_kerndisp(kvm_t *);
|
||||
|
||||
typedef int kvm_walk_pages_cb_t(struct kvm_page *, void *);
|
||||
int kvm_walk_pages(kvm_t *, kvm_walk_pages_cb_t *, void *);
|
||||
|
@ -1,5 +1,5 @@
|
||||
.\" Copyright (c) 2008 Tom Rhodes
|
||||
.\" All rights reserved.
|
||||
.\"
|
||||
.\" Copyright (c) 2020 Leandro Lupori <luporl@FreeBSD.org>
|
||||
.\"
|
||||
.\" Redistribution and use in source and binary forms, with or without
|
||||
.\" modification, are permitted provided that the following conditions
|
||||
@ -24,41 +24,34 @@
|
||||
.\"
|
||||
.\" $FreeBSD$
|
||||
.\"
|
||||
.Dd December 23, 2008
|
||||
.Dt ELF2AOUT 1
|
||||
.Dd February 5, 2020
|
||||
.Dt KVM_KERNDISP 3
|
||||
.Os
|
||||
.Sh NAME
|
||||
.Nm elf2aout
|
||||
.Nd "Convert ELF binary to a.out format"
|
||||
.Nm kvm_kerndisp
|
||||
.Nd get kernel displacement
|
||||
.Sh LIBRARY
|
||||
.Lb libkvm
|
||||
.Sh SYNOPSIS
|
||||
.Nm
|
||||
.Op Fl o Ar outfile
|
||||
.Ar infile
|
||||
.In kvm.h
|
||||
.Ft kssize_t
|
||||
.Fn kvm_kerndisp "kvm_t *kd"
|
||||
.Sh DESCRIPTION
|
||||
The
|
||||
.Nm
|
||||
utility is used to convert an ELF formatted binary,
|
||||
namely a kernel, to an a.out formatted one.
|
||||
Most
|
||||
.Tn OpenBoot
|
||||
firmware require an a.out format or FCode boot image
|
||||
and this utility is designed to accommodate.
|
||||
If
|
||||
.Ar infile
|
||||
is not in ELF format, an error message will be presented.
|
||||
.Fn kvm_kerndisp
|
||||
returns the number of bytes by which the kernel referenced by
|
||||
.Fa kd
|
||||
is displaced.
|
||||
This is the difference between the kernel's base virtual address at run time
|
||||
and the kernel base virtual address specified in the kernel image file.
|
||||
.Pp
|
||||
Note that if the kernel is moved to a lower memory address,
|
||||
the displacement will be negative.
|
||||
.Sh RETURN VALUES
|
||||
.Fn kvm_kerndisp
|
||||
returns the number of bytes by which the kernel is displaced.
|
||||
If the kernel is not displaced or if it is not possible to find the
|
||||
displacement then 0 is returned.
|
||||
.Sh SEE ALSO
|
||||
.Xr elf 3 ,
|
||||
.Xr a.out 5
|
||||
.Sh HISTORY
|
||||
The
|
||||
.Nm
|
||||
utility first appeared in
|
||||
.Fx 4.6 .
|
||||
.Sh AUTHORS
|
||||
.An -nosplit
|
||||
The
|
||||
.Nm
|
||||
utility was written by
|
||||
.An Jake Burkholder Aq Mt jake@FreeBSD.org .
|
||||
This manual page was written by
|
||||
.An Tom Rhodes Aq Mt trhodes@FreeBSD.org .
|
||||
.Xr kvm 3 ,
|
||||
.Xr kvm_close 3 ,
|
||||
.Xr kvm_open 3
|
@ -184,6 +184,12 @@ _powerpc64_native(kvm_t *kd __unused)
|
||||
#endif
|
||||
}
|
||||
|
||||
static kssize_t
|
||||
_powerpc64_kerndisp(kvm_t *kd)
|
||||
{
|
||||
return (kd->vmst->hdr.startkernel - PPC64_KERNBASE);
|
||||
}
|
||||
|
||||
static int
|
||||
_powerpc64_minidump_walk_pages(kvm_t *kd, kvm_walk_pages_cb_t *cb, void *arg)
|
||||
{
|
||||
@ -197,6 +203,7 @@ static struct kvm_arch kvm_powerpc64_minidump = {
|
||||
.ka_kvatop = _powerpc64_minidump_kvatop,
|
||||
.ka_walk_pages = _powerpc64_minidump_walk_pages,
|
||||
.ka_native = _powerpc64_native,
|
||||
.ka_kerndisp = _powerpc64_kerndisp,
|
||||
};
|
||||
|
||||
KVM_ARCH(kvm_powerpc64_minidump);
|
||||
|
@ -47,6 +47,7 @@ struct kvm_arch {
|
||||
int (*ka_kvatop)(kvm_t *, kvaddr_t, off_t *);
|
||||
int (*ka_native)(kvm_t *);
|
||||
int (*ka_walk_pages)(kvm_t *, kvm_walk_pages_cb_t *, void *);
|
||||
kssize_t (*ka_kerndisp)(kvm_t *);
|
||||
};
|
||||
|
||||
#define KVM_ARCH(ka) DATA_SET(kvm_arch, ka)
|
||||
|
@ -459,9 +459,9 @@ memstat_kvm_uma(struct memory_type_list *list, void *kvm_handle)
|
||||
if (ret != 0)
|
||||
continue;
|
||||
for (ubp =
|
||||
TAILQ_FIRST(&uzd.uzd_buckets);
|
||||
STAILQ_FIRST(&uzd.uzd_buckets);
|
||||
ubp != NULL;
|
||||
ubp = TAILQ_NEXT(&ub, ub_link)) {
|
||||
ubp = STAILQ_NEXT(&ub, ub_link)) {
|
||||
ret = kread(kvm, ubp, &ub,
|
||||
sizeof(ub), 0);
|
||||
if (ret != 0)
|
||||
|
@ -19,7 +19,7 @@
|
||||
.\"
|
||||
.\" $FreeBSD$
|
||||
.\"
|
||||
.Dd July 8, 2011
|
||||
.Dd January 19, 2020
|
||||
.Dt LOGIN.CONF 5
|
||||
.Os
|
||||
.Sh NAME
|
||||
@ -237,6 +237,7 @@ for details.
|
||||
.It "label string Default MAC policy; see"
|
||||
.Xr maclabel 7 .
|
||||
.It "lang string Set $LANG environment variable to the specified value."
|
||||
.It "mail string Set $MAIL environment variable to the specified value."
|
||||
.It "manpath path Default search path for manpages."
|
||||
.It "nocheckmail bool false Display mail status at login."
|
||||
.It "nologin file If the file exists it will be displayed and"
|
||||
|
@ -131,6 +131,7 @@ static struct login_vars {
|
||||
}, envars[] = {
|
||||
{ "lang", "LANG", NULL, 1},
|
||||
{ "charset", "MM_CHARSET", NULL, 1},
|
||||
{ "mail", "MAIL", NULL, 1},
|
||||
{ "timezone", "TZ", NULL, 1},
|
||||
{ "term", "TERM", NULL, 0},
|
||||
{ NULL, NULL, NULL, 0}
|
||||
|
@ -217,7 +217,7 @@ feholdexcept(fenv_t *__envp)
|
||||
union __fpscr __r;
|
||||
|
||||
__mffs(&__r);
|
||||
*__envp = __r.__d;
|
||||
*__envp = __r.__bits.__reg;
|
||||
__r.__bits.__reg &= ~(FE_ALL_EXCEPT | _ENABLE_MASK);
|
||||
__mtfsf(__r);
|
||||
return (0);
|
||||
|
@ -26,7 +26,9 @@ auditd_stop()
|
||||
{
|
||||
|
||||
/usr/sbin/audit -t
|
||||
sleep 1
|
||||
if [ -n "$rc_pid" ]; then
|
||||
wait_for_pids $rc_pid
|
||||
fi
|
||||
}
|
||||
|
||||
load_rc_config $name
|
||||
|
@ -1,4 +0,0 @@
|
||||
# $FreeBSD$
|
||||
|
||||
SUBDIR += bsdlabel
|
||||
SUBDIR += sunlabel
|
@ -28,7 +28,7 @@
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
__RCSID("$NetBSD: boot.c,v 1.21 2018/02/08 09:05:17 dholland Exp $");
|
||||
__RCSID("$NetBSD: boot.c,v 1.22 2020/01/11 16:29:07 christos Exp $");
|
||||
static const char rcsid[] =
|
||||
"$FreeBSD$";
|
||||
#endif /* not lint */
|
||||
@ -267,10 +267,11 @@ readboot(int dosfs, struct bootblock *boot)
|
||||
}
|
||||
|
||||
/*
|
||||
* The number of clusters is derived from available data sectors, divided
|
||||
* by sectors per cluster.
|
||||
* The number of clusters is derived from available data sectors,
|
||||
* divided by sectors per cluster.
|
||||
*/
|
||||
boot->NumClusters = (boot->NumSectors - boot->FirstCluster) / boot->bpbSecPerClust;
|
||||
boot->NumClusters =
|
||||
(boot->NumSectors - boot->FirstCluster) / boot->bpbSecPerClust;
|
||||
|
||||
if (boot->flags & FAT32) {
|
||||
if (boot->NumClusters > (CLUST_RSRVD & CLUST32_MASK)) {
|
||||
@ -320,8 +321,8 @@ readboot(int dosfs, struct bootblock *boot)
|
||||
}
|
||||
|
||||
/*
|
||||
* There are two reserved clusters. To avoid adding CLUST_FIRST every time
|
||||
* when we perform boundary checks, we increment the NumClusters by 2,
|
||||
* There are two reserved clusters. To avoid adding CLUST_FIRST every
|
||||
* time we perform boundary checks, we increment the NumClusters by 2,
|
||||
* which is CLUST_FIRST to denote the first out-of-range cluster number.
|
||||
*/
|
||||
boot->NumClusters += CLUST_FIRST;
|
||||
|
@ -2053,6 +2053,7 @@ setprocresources(const char *cname)
|
||||
login_cap_t *lc;
|
||||
if ((lc = login_getclassbyname(cname, NULL)) != NULL) {
|
||||
setusercontext(lc, (struct passwd*)NULL, 0,
|
||||
LOGIN_SETENV |
|
||||
LOGIN_SETPRIORITY | LOGIN_SETRESOURCES |
|
||||
LOGIN_SETLOGINCLASS | LOGIN_SETCPUMASK);
|
||||
login_close(lc);
|
||||
|
@ -1,20 +0,0 @@
|
||||
# $FreeBSD$
|
||||
|
||||
PROG= sunlabel
|
||||
SRCS= sunlabel.c sunlabel_enc.c
|
||||
MAN= sunlabel.8
|
||||
|
||||
.if ${MACHINE_CPUARCH} == "sparc64"
|
||||
LINKS= ${BINDIR}/sunlabel ${BINDIR}/disklabel
|
||||
MLINKS= sunlabel.8 disklabel.8
|
||||
.endif
|
||||
|
||||
LIBADD= geom
|
||||
|
||||
.include <bsd.prog.mk>
|
||||
|
||||
test: ${PROG}
|
||||
sh ${.CURDIR}/runtest.sh
|
||||
|
||||
testx: ${PROG}
|
||||
sh -x ${.CURDIR}/runtest.sh
|
@ -1,16 +0,0 @@
|
||||
# $FreeBSD$
|
||||
# Autogenerated - do NOT edit!
|
||||
|
||||
DIRDEPS = \
|
||||
include \
|
||||
include/xlocale \
|
||||
lib/${CSU_DIR} \
|
||||
lib/libc \
|
||||
lib/libgeom \
|
||||
|
||||
|
||||
.include <dirdeps.mk>
|
||||
|
||||
.if ${DEP_RELDIR} == ${_DEP_RELDIR}
|
||||
# local dependencies - needed for -jN in clean tree
|
||||
.endif
|
@ -1,157 +0,0 @@
|
||||
#!/bin/sh
|
||||
# $FreeBSD$
|
||||
|
||||
TMP=/tmp/$$.
|
||||
set -e
|
||||
MD=`mdconfig -a -t malloc -s 2m`
|
||||
trap "exec 7</dev/null; rm -f ${TMP}* ; mdconfig -d -u ${MD}" EXIT INT TERM
|
||||
|
||||
./sunlabel -r -w $MD auto
|
||||
|
||||
dd if=/dev/$MD of=${TMP}i0 count=16 > /dev/null 2>&1
|
||||
./sunlabel $MD > ${TMP}l0
|
||||
|
||||
sed '
|
||||
/ c:/{
|
||||
p
|
||||
s/c:/a:/
|
||||
s/3969/1024/
|
||||
}
|
||||
' ${TMP}l0 > ${TMP}l1
|
||||
|
||||
./sunlabel -R $MD ${TMP}l1
|
||||
if [ -c /dev/${MD}a ] ; then
|
||||
echo "PASS: Created a: partition" 1>&2
|
||||
else
|
||||
echo "FAIL: Did not create a: partition" 1>&2
|
||||
exit 2
|
||||
fi
|
||||
|
||||
# Spoil and rediscover
|
||||
|
||||
true > /dev/${MD}
|
||||
if [ -c /dev/${MD}a ] ; then
|
||||
echo "PASS: Recreated a: partition after spoilage" 1>&2
|
||||
else
|
||||
echo "FAIL: Did not recreate a: partition after spoilage" 1>&2
|
||||
exit 2
|
||||
fi
|
||||
|
||||
dd if=/dev/$MD of=${TMP}i1 count=16 > /dev/null 2>&1
|
||||
sed '
|
||||
/ c:/{
|
||||
p
|
||||
s/c:/a:/
|
||||
s/3969/2048/
|
||||
}
|
||||
' ${TMP}l0 > ${TMP}l2
|
||||
|
||||
./sunlabel -R $MD ${TMP}l2
|
||||
dd if=/dev/$MD of=${TMP}i2 count=16 > /dev/null 2>&1
|
||||
|
||||
exec 7< /dev/${MD}a
|
||||
|
||||
for t in a c
|
||||
do
|
||||
if dd if=${TMP}i2 of=/dev/${MD}$t 2>/dev/null ; then
|
||||
echo "PASS: Could rewrite same label to ...$t while ...a open" 1>&2
|
||||
else
|
||||
echo "FAIL: Could not rewrite same label to ...$t while ...a open" 1>&2
|
||||
exit 2
|
||||
fi
|
||||
|
||||
if dd if=${TMP}i1 of=/dev/${MD}$t 2>/dev/null ; then
|
||||
echo "FAIL: Could label with smaller ...a to ...$t while ...a open" 1>&2
|
||||
exit 2
|
||||
else
|
||||
echo "PASS: Could not label with smaller ...a to ...$t while ...a open" 1>&2
|
||||
fi
|
||||
|
||||
if dd if=${TMP}i0 of=/dev/${MD}$t 2>/dev/null ; then
|
||||
echo "FAIL: Could write label missing ...a to ...$t while ...a open" 1>&2
|
||||
exit 2
|
||||
else
|
||||
echo "PASS: Could not write label missing ...a to ...$t while ...a open" 1>&2
|
||||
fi
|
||||
done
|
||||
|
||||
exec 7< /dev/null
|
||||
|
||||
if dd if=${TMP}i0 of=/dev/${MD}c 2>/dev/null ; then
|
||||
echo "PASS: Could write missing ...a label to ...c" 1>&2
|
||||
else
|
||||
echo "FAIL: Could not write missing ...a label to ...c" 1>&2
|
||||
exit 2
|
||||
fi
|
||||
|
||||
if dd if=${TMP}i2 of=/dev/${MD}c 2>/dev/null ; then
|
||||
echo "PASS: Could write large ...a label to ...c" 1>&2
|
||||
else
|
||||
echo "FAIL: Could not write large ...a label to ...c" 1>&2
|
||||
exit 2
|
||||
fi
|
||||
|
||||
if dd if=${TMP}i1 of=/dev/${MD}c 2>/dev/null ; then
|
||||
echo "PASS: Could write small ...a label to ...c" 1>&2
|
||||
else
|
||||
echo "FAIL: Could not write small ...a label to ...c" 1>&2
|
||||
exit 2
|
||||
fi
|
||||
|
||||
if dd if=${TMP}i2 of=/dev/${MD}a 2>/dev/null ; then
|
||||
echo "PASS: Could increase size of ...a by writing to ...a" 1>&2
|
||||
else
|
||||
echo "FAIL: Could not increase size of ...a by writing to ...a" 1>&2
|
||||
exit 2
|
||||
fi
|
||||
|
||||
if dd if=${TMP}i1 of=/dev/${MD}a 2>/dev/null ; then
|
||||
echo "FAIL: Could decrease size of ...a by writing to ...a" 1>&2
|
||||
exit 2
|
||||
else
|
||||
echo "PASS: Could not decrease size of ...a by writing to ...a" 1>&2
|
||||
fi
|
||||
|
||||
if dd if=${TMP}i0 of=/dev/${MD}a 2>/dev/null ; then
|
||||
echo "FAIL: Could delete ...a by writing to ...a" 1>&2
|
||||
exit 2
|
||||
else
|
||||
echo "PASS: Could not delete ...a by writing to ...a" 1>&2
|
||||
fi
|
||||
|
||||
if ./sunlabel -B -b ${TMP}i0 ${MD} ; then
|
||||
if [ ! -c /dev/${MD}a ] ; then
|
||||
echo "FAILED: Writing bootcode killed ...a" 1>&2
|
||||
exit 2
|
||||
else
|
||||
echo "PASS: Could write bootcode while closed" 1>&2
|
||||
fi
|
||||
else
|
||||
echo "FAILED: Could not write bootcode while closed" 1>&2
|
||||
exit 2
|
||||
fi
|
||||
|
||||
exec 7> /dev/${MD}c
|
||||
if ktrace ./sunlabel -B -b ${TMP}i0 ${MD} ; then
|
||||
if [ ! -c /dev/${MD}a ] ; then
|
||||
echo "FAILED: Writing bootcode killed ...a" 1>&2
|
||||
exit 2
|
||||
else
|
||||
echo "PASS: Could write bootcode while open" 1>&2
|
||||
fi
|
||||
else
|
||||
echo "FAILED: Could not write bootcode while open" 1>&2
|
||||
exit 2
|
||||
fi
|
||||
exec 7> /dev/null
|
||||
|
||||
if dd if=${TMP}i0 of=/dev/${MD}c 2>/dev/null ; then
|
||||
echo "PASS: Could delete ...a by writing to ...c" 1>&2
|
||||
else
|
||||
echo "FAIL: Could not delete ...a by writing to ...c" 1>&2
|
||||
exit 2
|
||||
fi
|
||||
|
||||
# XXX: need to add a 'b' partition and check for overlaps.
|
||||
|
||||
exit 0
|
@ -1,125 +0,0 @@
|
||||
/*-
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*
|
||||
* Copyright (c) 1992, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
* Copyright (c) 2004,2005 Joerg Wunsch
|
||||
*
|
||||
* This software was developed by the Computer Systems Engineering group
|
||||
* at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
|
||||
* contributed to Berkeley.
|
||||
*
|
||||
* 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.
|
||||
* 3. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
|
||||
*
|
||||
* @(#)sun_disklabel.h 8.1 (Berkeley) 6/11/93
|
||||
* $NetBSD: disklabel.h,v 1.2 1998/08/22 14:55:28 mrg Exp $
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
#ifndef _SYS_SUN_DISKLABEL_H_
|
||||
#define _SYS_SUN_DISKLABEL_H_
|
||||
|
||||
/*
|
||||
* SunOS/Solaris disk label layout (partial).
|
||||
*
|
||||
* Suns disk label format contains a lot of historical baggage which we
|
||||
* ignore entirely. The structure below contains the relevant bits and the
|
||||
* _enc/_dec functions encode/decode only these fields.
|
||||
*/
|
||||
|
||||
#define SUN_DKMAGIC 55998
|
||||
#define SUN_NPART 8
|
||||
#define SUN_RAWPART 2
|
||||
#define SUN_SIZE 512
|
||||
#define SUN_VTOC_VERSION 1
|
||||
#define SUN_VTOC_SANE 0x600DDEEE /* SVR4-compatible VTOC is "sane". */
|
||||
#define SUN_VOLNAME_LEN 8
|
||||
/*
|
||||
* XXX: I am actually not sure if this should be "16 sectors" or "8192 bytes".
|
||||
* XXX: Considering that Sun went to the effort of getting 512 byte compatible
|
||||
* XXX: CDROM drives produced my guess is that Sun computers stand little or
|
||||
* XXX: even no chance of running, much less booting on !=512 byte media.
|
||||
* XXX: Define this is in terms of bytes since that is easier for us.
|
||||
*/
|
||||
#define SUN_BOOTSIZE 8192
|
||||
|
||||
/* partition info */
|
||||
struct sun_dkpart {
|
||||
u_int32_t sdkp_cyloffset; /* starting cylinder */
|
||||
u_int32_t sdkp_nsectors; /* number of sectors */
|
||||
};
|
||||
|
||||
struct sun_vtoc_info {
|
||||
u_int16_t svtoc_tag; /* partition tag */
|
||||
u_int16_t svtoc_flag; /* partition flags */
|
||||
};
|
||||
|
||||
/* known partition tag values */
|
||||
#define VTOC_UNASSIGNED 0x00
|
||||
#define VTOC_BOOT 0x01
|
||||
#define VTOC_ROOT 0x02
|
||||
#define VTOC_SWAP 0x03
|
||||
#define VTOC_USR 0x04
|
||||
#define VTOC_BACKUP 0x05 /* "c" partition, covers entire disk */
|
||||
#define VTOC_STAND 0x06
|
||||
#define VTOC_VAR 0x07
|
||||
#define VTOC_HOME 0x08
|
||||
#define VTOC_ALTSCTR 0x09 /* alternate sector partition */
|
||||
#define VTOC_CACHE 0x0a /* Solaris cachefs partition */
|
||||
#define VTOC_VXVM_PUB 0x0e /* VxVM public region */
|
||||
#define VTOC_VXVM_PRIV 0x0f /* VxVM private region */
|
||||
|
||||
/* VTOC partition flags */
|
||||
#define VTOC_UNMNT 0x01 /* unmountable partition */
|
||||
#define VTOC_RONLY 0x10 /* partition is read/only */
|
||||
|
||||
struct sun_disklabel {
|
||||
char sl_text[128];
|
||||
|
||||
/* SVR4 VTOC information */
|
||||
u_int32_t sl_vtoc_vers; /* == SUN_VTOC_VERSION */
|
||||
char sl_vtoc_volname[SUN_VOLNAME_LEN];
|
||||
u_int16_t sl_vtoc_nparts; /* == SUN_NPART */
|
||||
struct sun_vtoc_info sl_vtoc_map[SUN_NPART]; /* partition tag/flag */
|
||||
u_int32_t sl_vtoc_sane; /* == SUN_VTOC_SANE */
|
||||
|
||||
/* Sun label information */
|
||||
u_int16_t sl_rpm; /* rotational speed */
|
||||
u_int16_t sl_pcylinders; /* number of physical cyls */
|
||||
u_int16_t sl_sparespercyl; /* spare sectors per cylinder */
|
||||
u_int16_t sl_interleave; /* interleave factor */
|
||||
u_int16_t sl_ncylinders; /* data cylinders */
|
||||
u_int16_t sl_acylinders; /* alternate cylinders */
|
||||
u_int16_t sl_ntracks; /* tracks per cylinder */
|
||||
u_int16_t sl_nsectors; /* sectors per track */
|
||||
struct sun_dkpart sl_part[SUN_NPART]; /* partition layout */
|
||||
u_int16_t sl_magic; /* == SUN_DKMAGIC */
|
||||
};
|
||||
|
||||
int sunlabel_dec(void const *pp, struct sun_disklabel *sl);
|
||||
void sunlabel_enc(void *pp, struct sun_disklabel *sl);
|
||||
|
||||
#endif /* _SYS_SUN_DISKLABEL_H_ */
|
@ -1,432 +0,0 @@
|
||||
.\" Copyright (c) 2004
|
||||
.\" David E. O'Brien. All rights reserved.
|
||||
.\" Copyright (c) 2004, 2005
|
||||
.\" Joerg Wunsch. 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 March 30, 2005
|
||||
.Dt SUNLABEL 8
|
||||
.Os
|
||||
.Sh NAME
|
||||
.Nm sunlabel
|
||||
.Nd read and write disk pack label suitable for Sun's OpenBoot PROM
|
||||
.Sh SYNOPSIS
|
||||
.Nm
|
||||
.Op Fl r
|
||||
.Op Fl c No \&| Fl h
|
||||
.Ar disk
|
||||
.Nm
|
||||
.Fl B
|
||||
.Op Fl b Ar boot1
|
||||
.Op Fl n
|
||||
.Ar disk
|
||||
.Nm
|
||||
.Fl R
|
||||
.Op Fl B Op Fl b Ar boot1
|
||||
.Op Fl r
|
||||
.Op Fl n
|
||||
.Op Fl c
|
||||
.Ar disk protofile
|
||||
.Nm
|
||||
.Fl e
|
||||
.Op Fl B Op Fl b Ar boot1
|
||||
.Op Fl r
|
||||
.Op Fl n
|
||||
.Op Fl c
|
||||
.Ar disk
|
||||
.Nm
|
||||
.Fl w
|
||||
.Op Fl B Op Fl b Ar boot1
|
||||
.Op Fl r
|
||||
.Op Fl n
|
||||
.Op Fl c
|
||||
.Ar disk type
|
||||
.Sh DESCRIPTION
|
||||
The
|
||||
.Nm
|
||||
utility
|
||||
installs, examines or modifies the
|
||||
.Em Sun OpenBoot PROM
|
||||
label on a disk.
|
||||
In addition,
|
||||
.Nm
|
||||
can install bootstrap code.
|
||||
.Ss Introduction
|
||||
The label occupies the first sector (i.e., 512 bytes) of each disk.
|
||||
It starts with a textual description which by convention also mentions
|
||||
the disk geometry in textual form (number of cylinders, alternate
|
||||
cylinders, heads, and sectors per track), optionally followed by a
|
||||
table of SVR4-compatible VTOC tags and flags per partition, followed
|
||||
by the partition table itself.
|
||||
Finally, a checksum is recorded to ensure the label has not been
|
||||
tampered with.
|
||||
.Pp
|
||||
The
|
||||
.Em Sun OpenBoot PROM
|
||||
label allows for 8 disk partitions.
|
||||
The partition table lists the starting cylinder of the partition,
|
||||
plus the size of the partition in 512-byte sectors.
|
||||
Thus, partitions in the
|
||||
.Em Sun OpenBoot PROM
|
||||
must always start at a cylinder boundary (for whatever geometry
|
||||
emulation has been chosen).
|
||||
.Pp
|
||||
The optional SVR4-compatible VTOC tag and flags table is not used
|
||||
by the
|
||||
.Fx
|
||||
kernel.
|
||||
It is maintained solely for compatibility with the
|
||||
.Tn Solaris
|
||||
operating system that might share disks with
|
||||
.Fx
|
||||
on the same hardware platform.
|
||||
.Pp
|
||||
The
|
||||
.Em Sun OpenBoot PROM
|
||||
label is natively understood by the underlying hardware, which can
|
||||
bootstrap from a single partition entry, as opposed to the very first
|
||||
block(s) of the entire disk as on many other hardware platforms.
|
||||
.Pp
|
||||
Note that the hardware platform mandates that two cylinders are set
|
||||
aside as
|
||||
.Em alternate cylinders
|
||||
which are not available to user programs (and not even through the
|
||||
.Dq Li backup
|
||||
partition).
|
||||
.Ss Options
|
||||
Options are listed in alphabetical order here.
|
||||
Note that only those option combinations listed under
|
||||
.Sx SYNOPSIS
|
||||
are allowable.
|
||||
.Bl -tag -width ".Fl b Ar bootpath"
|
||||
.It Fl b Ar bootpath
|
||||
Specify that
|
||||
.Ar bootpath
|
||||
is to be used as the boot image, rather than the default of
|
||||
.Pa /boot/boot1 .
|
||||
.It Fl B
|
||||
Install bootstrap code onto the disk.
|
||||
Note that since the underlying hardware platform bootstraps from
|
||||
partitions, not disks, this operation is only useful if there is
|
||||
a partition starting at offset 0.
|
||||
.It Fl c
|
||||
Use cylinders for partition size display rather than
|
||||
(512-byte) sectors.
|
||||
This also changes the default interpretation of the partition
|
||||
size entries when editing the label, or reading from a prototype
|
||||
file.
|
||||
Thus, prototype files are only compatible when both, obtaining
|
||||
the file and re-installing it is done using the same
|
||||
.Fl c
|
||||
option setting.
|
||||
.It Fl e
|
||||
Enter edit mode.
|
||||
See
|
||||
.Sx Edit mode
|
||||
below for a more detailed explanation.
|
||||
.It Fl h
|
||||
When displaying the label, make the partition size and offset
|
||||
values
|
||||
.Dq human readable .
|
||||
The displayed numbers will get a suffix of
|
||||
.Ql B
|
||||
for bytes,
|
||||
.Ql K
|
||||
for 1024 bytes each,
|
||||
.Ql M
|
||||
for 1048576 bytes each, or
|
||||
.Ql G
|
||||
for 1073741824 bytes each appended.
|
||||
Note that due to possible rounding errors, prototype files
|
||||
obtained using the
|
||||
.Fl h
|
||||
option are not suited for re-installing using the
|
||||
.Fl R
|
||||
option.
|
||||
.It Fl n
|
||||
No changes.
|
||||
All operations, checks etc., are performed normally, but nothing
|
||||
is written to disk.
|
||||
.It Fl r
|
||||
Obsolete option that used to indicate that the operation should
|
||||
be done directly on disk, as opposed through the respective kernel
|
||||
services.
|
||||
Ignored.
|
||||
.It Fl R
|
||||
Restore label from the prototype in
|
||||
.Ar protofile .
|
||||
A prototype file is simply the textual representation of the
|
||||
label as printed using the first form of the
|
||||
.Nm
|
||||
utility shown in the
|
||||
.Sx SYNOPSIS .
|
||||
Note that the
|
||||
.Fl c
|
||||
option used to obtain the prototype must match the option used
|
||||
when restoring the label (both present, or both absent).
|
||||
.It Fl w
|
||||
Write mode.
|
||||
Suitable to write an initial label to disk.
|
||||
The
|
||||
.Ar type
|
||||
argument used to be an entry into a table of predefined labels,
|
||||
but this functionality is not supported by
|
||||
.Nm .
|
||||
Instead, the only allowable
|
||||
.Ar type
|
||||
argument is the string
|
||||
.Dq Li auto ,
|
||||
indicating that an automatically created label should be written
|
||||
to disk.
|
||||
This automatism will try to create an initial label that fits as
|
||||
best as possible into the available disk capacity.
|
||||
.El
|
||||
.Pp
|
||||
If neither of the
|
||||
.Fl e , R ,
|
||||
or
|
||||
.Fl w
|
||||
options are present, the existing label for
|
||||
.Ar disk
|
||||
will be printed to standard output.
|
||||
.Pp
|
||||
The
|
||||
.Ar disk
|
||||
argument
|
||||
must be given as a plain disk name, without any leading
|
||||
.Pa /dev/ .
|
||||
.Ss Edit mode
|
||||
In edit mode, the existing label from
|
||||
.Ar disk
|
||||
will be read, and put into a template file.
|
||||
The command referenced by the
|
||||
.Ev EDITOR
|
||||
environmental variable will be started to allow the user
|
||||
to edit the label.
|
||||
The label is then checked and examined for any errors.
|
||||
If no errors have been found, the new label is written to disk.
|
||||
If there were any errors, a message is printed to standard
|
||||
error output, and the user is given the opportunity to edit
|
||||
the template file again.
|
||||
If accepted, editing starts over.
|
||||
If declined, no changes will
|
||||
be written to disk.
|
||||
.Pp
|
||||
The label presented for editing is the same as the standard
|
||||
printout, with some added hints about the possible options to
|
||||
specify the sector size and starting cylinder.
|
||||
The following areas in the template can be edited:
|
||||
.Bl -tag -width indent
|
||||
.It Sy Textual label, geometry emulation
|
||||
The line
|
||||
.D1 Li text: Ar XXXX Li cyl Ar CC Li alt 2 hd Ar HH Li sec Ar SS
|
||||
represents the label text.
|
||||
It must be retained exactly in the form shown.
|
||||
The editable text
|
||||
.Ar XXXX
|
||||
is a simple (non-whitespace) text describing the disk.
|
||||
By convention, this text mentions the approximate size of the
|
||||
disk, as in
|
||||
.Dq Li SUN9.0G
|
||||
for a 9 GB disk shipped by Sun.
|
||||
.Pp
|
||||
The values
|
||||
.Ar CC ,
|
||||
.Ar HH ,
|
||||
and
|
||||
.Ar SS
|
||||
describe the number of cylinders, heads (tracks per
|
||||
cylinder), and sectors per track respectively.
|
||||
They might be modified to change the geometry emulation.
|
||||
Each number must be between 1 and 65535.
|
||||
The product
|
||||
.D1 Em (CC + 2) * HH * SS
|
||||
must be less than or equal to the total number of sectors of the
|
||||
disk (which is given as a hint in a comment field).
|
||||
.It Sy Volume name
|
||||
The volume name (if present) is introduced by the string
|
||||
.Dq "volume name:" .
|
||||
It can be up to 8 characters long, and might be useful to distinguish
|
||||
different disks in a system.
|
||||
Note that volume names require the VTOC elements to be present, so
|
||||
any of the VTOC constraints described below need to be obeyed as well
|
||||
if a volume name is to be set.
|
||||
Setting an empty volume name will delete it from the label.
|
||||
.It Sy Partition entries
|
||||
Partition entries start with a letter from
|
||||
.Ql a
|
||||
through
|
||||
.Ql h ,
|
||||
immediately followed by a colon, followed by the size of this
|
||||
partition, and the starting cylinder of the partition.
|
||||
The unit of the size field defaults to sectors, or to cylinders
|
||||
if the
|
||||
.Fl c
|
||||
option is in effect.
|
||||
Alternatively, a different unit may be specified by appending
|
||||
.Ql s
|
||||
for (512-byte) sectors,
|
||||
.Ql c
|
||||
for cylinders,
|
||||
.Ql k
|
||||
for kilobytes,
|
||||
.Ql m
|
||||
for megabytes, or
|
||||
.Ql g
|
||||
for gigabytes.
|
||||
The last partition entry may specify the size as
|
||||
.Ql *
|
||||
to indicate that this entry should consume the rest of disk not
|
||||
consumed by any other partition so far.
|
||||
.Pp
|
||||
The start of partition is always taken as a cylinder number (starting
|
||||
at 0) since this is what the underlying hardware uses.
|
||||
Alternatively, specifying it as
|
||||
.Ql *
|
||||
will make the computation automatically chose the nearest possible
|
||||
cylinder boundary.
|
||||
.Pp
|
||||
Partition
|
||||
.Ql c
|
||||
must always be present, must start at 0, and must cover the entire
|
||||
disk (without considering the alternate cylinders though).
|
||||
.Pp
|
||||
Optionally, each partition entry may be followed by an SVR4-compatible
|
||||
VTOC tag name, and a flag description.
|
||||
The following VTOC tag names are known:
|
||||
.Bl -column -offset indent ".Li unassigned" ".Sy value" ".Sy comment"
|
||||
.It Sy name Ta Sy value Ta Sy comment
|
||||
.It Li unassigned Ta No 0x00 Ta \&
|
||||
.It Li boot Ta No 0x01 Ta \&
|
||||
.It Li root Ta No 0x02 Ta \&
|
||||
.It Li swap Ta No 0x03 Ta \&
|
||||
.It Li usr Ta No 0x04 Ta \&
|
||||
.It Li backup Ta No 0x05 Ta c partition, entire disk
|
||||
.It Li stand Ta No 0x06 Ta \&
|
||||
.It Li var Ta No 0x07 Ta \&
|
||||
.It Li home Ta No 0x08 Ta \&
|
||||
.It Li altsctr Ta No 0x09 Ta alternate sector partition
|
||||
.It Li cache Ta No 0x0a Ta Solaris cachefs partition
|
||||
.It Li VxVM_pub Ta No 0x0e Ta VxVM public region
|
||||
.It Li VxVM_priv Ta No 0x0f Ta VxVM private region
|
||||
.El
|
||||
.Pp
|
||||
The following VTOC flags are known:
|
||||
.Bl -column -offset indent ".Sy name" ".Sy value" ".Sy comment"
|
||||
.It Sy name Ta Sy value Ta Sy comment
|
||||
.It Li wm Ta No 0x00 Ta read/write, mountable
|
||||
.It Li wu Ta No 0x01 Ta read/write, unmountable
|
||||
.It Li rm Ta No 0x10 Ta read/only, mountable
|
||||
.It Li ru Ta No 0x11 Ta read/only, unmountable
|
||||
.El
|
||||
.Pp
|
||||
Optionally, both the tag and/or the flag name may be specified
|
||||
numerically, using standard
|
||||
.Ql C
|
||||
numerical notation (prefix
|
||||
.Ql 0x
|
||||
for hexadecimal numbers,
|
||||
.Ql 0
|
||||
for octal numbers).
|
||||
If the flag field is omitted, it defaults to
|
||||
.Ql wm .
|
||||
If the tag field is also omitted, it defaults to
|
||||
.Dq Li unassigned .
|
||||
If none of the partitions lists any VTOC tag/flags, no
|
||||
SVR4-compatible VTOC elements will be written to disk.
|
||||
If VTOC-style elements are present, partition
|
||||
.Ql c
|
||||
must be marked as
|
||||
.Dq Li backup
|
||||
(and should be marked
|
||||
.Ql wu ) .
|
||||
.El
|
||||
.Pp
|
||||
When checking the label, partition
|
||||
.Ql c
|
||||
is checked for presence, and for the mentioned restrictions.
|
||||
All other partitions are checked for possible overlaps, as
|
||||
well as for not extending past the end of unit.
|
||||
If VTOC-style elements are present, overlaps of unmountable
|
||||
partitions against other partitions will be warned still but
|
||||
do not cause a rejection of the label.
|
||||
That way,
|
||||
.Em encapsulated disks
|
||||
of volume management software are acceptable as long as the
|
||||
volume management partitions are clearly marked as unmountable.
|
||||
.Pp
|
||||
Any other fields in the label template are informational only,
|
||||
and will not be parsed when reading the label.
|
||||
.Pp
|
||||
Note that when changing the geometry emulation by editing the
|
||||
textual description line, all partition entries will be
|
||||
considered based on the new geometry emulation.
|
||||
.Sh ENVIRONMENT
|
||||
.Bl -tag -width ".Ev EDITOR" -compact
|
||||
.It Ev EDITOR
|
||||
Name of the command to edit the template file in edit-mode.
|
||||
Defaults to
|
||||
.Xr vi 1 .
|
||||
.El
|
||||
.Sh FILES
|
||||
.Bl -tag -width ".Pa /boot/boot1" -compact
|
||||
.It Pa /boot/boot1
|
||||
Default boot image.
|
||||
.El
|
||||
.Sh SEE ALSO
|
||||
.Xr vi 1 ,
|
||||
.Xr geom 4 ,
|
||||
.Xr bsdlabel 8
|
||||
.Sh HISTORY
|
||||
The
|
||||
.Nm
|
||||
utility appeared in
|
||||
.Fx 5.1 .
|
||||
.Sh AUTHORS
|
||||
The
|
||||
.Nm
|
||||
utility was written by
|
||||
.An Jake Burkholder ,
|
||||
modeling it after the
|
||||
.Xr bsdlabel 8
|
||||
command available on other architectures.
|
||||
.Pp
|
||||
.An -nosplit
|
||||
This man page was initially written by
|
||||
.An David O'Brien ,
|
||||
and later substantially updated by
|
||||
.An J\(:org Wunsch .
|
||||
.Sh BUGS
|
||||
Installing bootstrap code onto an entire disk is merely pointless.
|
||||
.Nm
|
||||
should rather support installing bootstrap code into a partition
|
||||
instead.
|
||||
.Pp
|
||||
The
|
||||
.Dq auto
|
||||
layout algorithm could be smarter.
|
||||
By now, it tends to emulate fairly large cylinders which due to
|
||||
the two reserved alternate cylinders causes a fair amount of
|
||||
wasted disk space.
|
File diff suppressed because it is too large
Load Diff
@ -1,184 +0,0 @@
|
||||
/*-
|
||||
* SPDX-License-Identifier: BSD-2-Clause-FreeBSD
|
||||
*
|
||||
* Copyright (c) 2003 Jake Burkholder
|
||||
* Copyright (c) 2003 Poul-Henning Kamp
|
||||
* Copyright (c) 2004,2005 Joerg Wunsch
|
||||
* 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.
|
||||
*/
|
||||
/* Functions to encode or decode struct sun_disklabel into a bytestream
|
||||
* of correct endianness and packing.
|
||||
*
|
||||
* NB! This file must be usable both in kernel and userland.
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/endian.h>
|
||||
#include <sys/errno.h>
|
||||
#ifdef _KERNEL
|
||||
#include <sys/systm.h>
|
||||
#else
|
||||
#include <string.h>
|
||||
#endif
|
||||
#include "sun_disklabel.h"
|
||||
|
||||
#define SL_TEXT 0x0
|
||||
#define SL_TEXT_SIZEOF 0x80
|
||||
#define SL_VTOC_VERS 0x80
|
||||
#define SL_VTOC_VOLNAME 0x84
|
||||
#define SL_VTOC_NPART 0x8c
|
||||
#define SL_VTOC_MAP 0x8e
|
||||
#define SL_VTOC_SANITY 0xbc
|
||||
#define SL_RPM 0x1a4
|
||||
#define SL_PCYLINDERS 0x1a6
|
||||
#define SL_SPARESPERCYL 0x1a8
|
||||
#define SL_INTERLEAVE 0x1ae
|
||||
#define SL_NCYLINDERS 0x1b0
|
||||
#define SL_ACYLINDERS 0x1b2
|
||||
#define SL_NTRACKS 0x1b4
|
||||
#define SL_NSECTORS 0x1b6
|
||||
#define SL_PART 0x1bc
|
||||
#define SL_MAGIC 0x1fc
|
||||
#define SL_CKSUM 0x1fe
|
||||
|
||||
#define SDKP_CYLOFFSET 0
|
||||
#define SDKP_NSECTORS 0x4
|
||||
#define SDKP_SIZEOF 0x8 /* size of a partition entry */
|
||||
|
||||
#define SVTOC_TAG 0
|
||||
#define SVTOC_FLAG 0x2
|
||||
#define SVTOC_SIZEOF 0x4 /* size of a VTOC tag/flag entry */
|
||||
|
||||
/*
|
||||
* Decode the relevant fields of a sun disk label, and return zero if the
|
||||
* magic and checksum works out OK.
|
||||
*/
|
||||
int
|
||||
sunlabel_dec(void const *pp, struct sun_disklabel *sl)
|
||||
{
|
||||
const uint8_t *p;
|
||||
size_t i;
|
||||
u_int u;
|
||||
uint32_t vtocsane;
|
||||
uint16_t npart;
|
||||
|
||||
p = pp;
|
||||
for (i = 0; i < sizeof(sl->sl_text); i++)
|
||||
sl->sl_text[i] = p[SL_TEXT + i];
|
||||
sl->sl_rpm = be16dec(p + SL_RPM);
|
||||
sl->sl_pcylinders = be16dec(p + SL_PCYLINDERS);
|
||||
sl->sl_sparespercyl = be16dec(p + SL_SPARESPERCYL);
|
||||
sl->sl_interleave = be16dec(p + SL_INTERLEAVE);
|
||||
sl->sl_ncylinders = be16dec(p + SL_NCYLINDERS);
|
||||
sl->sl_acylinders = be16dec(p + SL_ACYLINDERS);
|
||||
sl->sl_ntracks = be16dec(p + SL_NTRACKS);
|
||||
sl->sl_nsectors = be16dec(p + SL_NSECTORS);
|
||||
for (i = 0; i < SUN_NPART; i++) {
|
||||
sl->sl_part[i].sdkp_cyloffset = be32dec(p + SL_PART +
|
||||
(i * SDKP_SIZEOF) + SDKP_CYLOFFSET);
|
||||
sl->sl_part[i].sdkp_nsectors = be32dec(p + SL_PART +
|
||||
(i * SDKP_SIZEOF) + SDKP_NSECTORS);
|
||||
}
|
||||
sl->sl_magic = be16dec(p + SL_MAGIC);
|
||||
vtocsane = be32dec(p + SL_VTOC_SANITY);
|
||||
npart = be16dec(p + SL_VTOC_NPART);
|
||||
if (vtocsane == SUN_VTOC_SANE && npart == SUN_NPART) {
|
||||
/*
|
||||
* Seems we've got SVR4-compatible VTOC information
|
||||
* as well, decode it.
|
||||
*/
|
||||
sl->sl_vtoc_sane = vtocsane;
|
||||
sl->sl_vtoc_vers = be32dec(p + SL_VTOC_VERS);
|
||||
memcpy(sl->sl_vtoc_volname, p + SL_VTOC_VOLNAME,
|
||||
SUN_VOLNAME_LEN);
|
||||
sl->sl_vtoc_nparts = SUN_NPART;
|
||||
for (i = 0; i < SUN_NPART; i++) {
|
||||
sl->sl_vtoc_map[i].svtoc_tag = be16dec(p +
|
||||
SL_VTOC_MAP + (i * SVTOC_SIZEOF) + SVTOC_TAG);
|
||||
sl->sl_vtoc_map[i].svtoc_flag = be16dec(p +
|
||||
SL_VTOC_MAP + (i * SVTOC_SIZEOF) + SVTOC_FLAG);
|
||||
}
|
||||
}
|
||||
for (i = u = 0; i < SUN_SIZE; i += 2)
|
||||
u ^= be16dec(p + i);
|
||||
if (u == 0 && sl->sl_magic == SUN_DKMAGIC)
|
||||
return (0);
|
||||
else
|
||||
return (EINVAL);
|
||||
}
|
||||
|
||||
/*
|
||||
* Encode the relevant fields into a sun disklabel, compute new checksum.
|
||||
*/
|
||||
void
|
||||
sunlabel_enc(void *pp, struct sun_disklabel *sl)
|
||||
{
|
||||
uint8_t *p;
|
||||
size_t i;
|
||||
u_int u;
|
||||
|
||||
p = pp;
|
||||
for (i = 0; i < SL_TEXT_SIZEOF; i++)
|
||||
p[SL_TEXT + i] = sl->sl_text[i];
|
||||
be16enc(p + SL_RPM, sl->sl_rpm);
|
||||
be16enc(p + SL_PCYLINDERS, sl->sl_pcylinders);
|
||||
be16enc(p + SL_SPARESPERCYL, sl->sl_sparespercyl);
|
||||
be16enc(p + SL_INTERLEAVE, sl->sl_interleave);
|
||||
be16enc(p + SL_NCYLINDERS, sl->sl_ncylinders);
|
||||
be16enc(p + SL_ACYLINDERS, sl->sl_acylinders);
|
||||
be16enc(p + SL_NTRACKS, sl->sl_ntracks);
|
||||
be16enc(p + SL_NSECTORS, sl->sl_nsectors);
|
||||
for (i = 0; i < SUN_NPART; i++) {
|
||||
be32enc(p + SL_PART + (i * SDKP_SIZEOF) + SDKP_CYLOFFSET,
|
||||
sl->sl_part[i].sdkp_cyloffset);
|
||||
be32enc(p + SL_PART + (i * SDKP_SIZEOF) + SDKP_NSECTORS,
|
||||
sl->sl_part[i].sdkp_nsectors);
|
||||
}
|
||||
be16enc(p + SL_MAGIC, sl->sl_magic);
|
||||
if (sl->sl_vtoc_sane == SUN_VTOC_SANE
|
||||
&& sl->sl_vtoc_nparts == SUN_NPART) {
|
||||
/*
|
||||
* Write SVR4-compatible VTOC elements.
|
||||
*/
|
||||
be32enc(p + SL_VTOC_VERS, sl->sl_vtoc_vers);
|
||||
be32enc(p + SL_VTOC_SANITY, SUN_VTOC_SANE);
|
||||
memcpy(p + SL_VTOC_VOLNAME, sl->sl_vtoc_volname,
|
||||
SUN_VOLNAME_LEN);
|
||||
be16enc(p + SL_VTOC_NPART, SUN_NPART);
|
||||
for (i = 0; i < SUN_NPART; i++) {
|
||||
be16enc(p + SL_VTOC_MAP + (i * SVTOC_SIZEOF)
|
||||
+ SVTOC_TAG,
|
||||
sl->sl_vtoc_map[i].svtoc_tag);
|
||||
be16enc(p + SL_VTOC_MAP + (i * SVTOC_SIZEOF)
|
||||
+ SVTOC_FLAG,
|
||||
sl->sl_vtoc_map[i].svtoc_flag);
|
||||
}
|
||||
}
|
||||
for (i = u = 0; i < SUN_SIZE; i += 2)
|
||||
u ^= be16dec(p + i);
|
||||
be16enc(p + SL_CKSUM, u);
|
||||
}
|
@ -317,11 +317,6 @@ Allow the hardware to deliver multiple frames in the same receive buffer
|
||||
opportunistically.
|
||||
The default is -1 which lets the driver decide.
|
||||
0 or 1 explicitly disable or enable this feature.
|
||||
.It Va hw.cxgbe.allow_mbufs_in_cluster
|
||||
1 allows the driver to lay down one or more mbufs within the receive buffer
|
||||
opportunistically.
|
||||
This is the default.
|
||||
0 prohibits the driver from doing so.
|
||||
.It Va hw.cxgbe.largest_rx_cluster
|
||||
.It Va hw.cxgbe.safest_rx_cluster
|
||||
Sizes of rx clusters.
|
||||
|
@ -574,7 +574,7 @@ Use with caution as a make install will overwrite any existing
|
||||
.Pa /etc/mail/sendmail.cf .
|
||||
Note that
|
||||
.Va SENDMAIL_CF
|
||||
is now deprecated.
|
||||
is deprecated.
|
||||
.It Va SENDMAIL_SET_USER_ID
|
||||
.Pq Vt bool
|
||||
If set, install
|
||||
|
@ -1317,12 +1317,12 @@ ifconfig_em0_alias3="inet 192.0.2.1-5/28"
|
||||
.Pp
|
||||
and so on.
|
||||
.Pp
|
||||
Note that
|
||||
Note that deprecated
|
||||
.Va ipv4_addrs_ Ns Aq Ar interface
|
||||
variable was supported for IPv4 CIDR address notation.
|
||||
It is now deprecated because the functionality was integrated into
|
||||
The
|
||||
.Va ifconfig_ Ns Ao Ar interface Ac Ns Va _alias Ns Aq Ar n
|
||||
though
|
||||
variable replaces it, though
|
||||
.Va ipv4_addrs_ Ns Aq Ar interface
|
||||
is still supported for backward compatibility.
|
||||
.Pp
|
||||
|
@ -1,6 +1,6 @@
|
||||
.\" DO NOT EDIT-- this file is @generated by tools/build/options/makeman.
|
||||
.\" $FreeBSD$
|
||||
.Dd January 31, 2020
|
||||
.Dd February 6, 2020
|
||||
.Dt SRC.CONF 5
|
||||
.Os
|
||||
.Sh NAME
|
||||
@ -198,15 +198,15 @@ and
|
||||
on powerpc as part of the normal system build.
|
||||
.Pp
|
||||
This is a default setting on
|
||||
amd64/amd64, arm/armv6, arm/armv7, i386/i386, mips/mipsel, mips/mips, mips/mips64el, mips/mips64, mips/mipsn32, mips/mipselhf, mips/mipshf, mips/mips64elhf, mips/mips64hf, powerpc/powerpc, powerpc/powerpc64 and sparc64/sparc64.
|
||||
amd64/amd64, arm/armv6, arm/armv7, i386/i386, mips/mipsel, mips/mips, mips/mips64el, mips/mips64, mips/mipsn32, mips/mipselhf, mips/mipshf, mips/mips64elhf, mips/mips64hf, powerpc/powerpc and powerpc/powerpc64.
|
||||
.It Va WITHOUT_BINUTILS_BOOTSTRAP
|
||||
Do not build binutils (as, ld.bfd, and objdump)
|
||||
Do not build GNU binutils
|
||||
as part of the bootstrap process.
|
||||
.Pp
|
||||
This is a default setting on
|
||||
arm/armv6, arm/armv7, arm64/aarch64, mips/mipsel, mips/mips, mips/mips64el, mips/mips64, mips/mipsn32, mips/mipselhf, mips/mipshf, mips/mips64elhf, mips/mips64hf, riscv/riscv64, riscv/riscv64sf and sparc64/sparc64.
|
||||
arm/armv6, arm/armv7, arm64/aarch64, mips/mipsel, mips/mips, mips/mips64el, mips/mips64, mips/mipsn32, mips/mipselhf, mips/mipshf, mips/mips64elhf, mips/mips64hf, riscv/riscv64 and riscv/riscv64sf.
|
||||
.It Va WITH_BINUTILS_BOOTSTRAP
|
||||
Build binutils (as on i386 and amd64, objdump, and ld on powerpc)
|
||||
Build GNU binutils
|
||||
as part of the bootstrap process.
|
||||
.Pp
|
||||
This is a default setting on
|
||||
@ -344,9 +344,6 @@ When set, it enforces these options:
|
||||
.El
|
||||
.It Va WITHOUT_CLANG
|
||||
Set to not build the Clang C/C++ compiler during the regular phase of the build.
|
||||
.Pp
|
||||
This is a default setting on
|
||||
sparc64/sparc64.
|
||||
When set, it enforces these options:
|
||||
.Pp
|
||||
.Bl -item -compact
|
||||
@ -357,11 +354,6 @@ When set, it enforces these options:
|
||||
.It
|
||||
.Va WITHOUT_LLVM_COV
|
||||
.El
|
||||
.It Va WITH_CLANG
|
||||
Set to build the Clang C/C++ compiler during the normal phase of the build.
|
||||
.Pp
|
||||
This is a default setting on
|
||||
amd64/amd64, arm/armv6, arm/armv7, arm64/aarch64, i386/i386, mips/mipsel, mips/mips, mips/mips64el, mips/mips64, mips/mipsn32, mips/mipselhf, mips/mipshf, mips/mips64elhf, mips/mips64hf, powerpc/powerpc, powerpc/powerpc64, riscv/riscv64 and riscv/riscv64sf.
|
||||
.It Va WITHOUT_CLANG_BOOTSTRAP
|
||||
Set to not build the Clang C/C++ compiler during the bootstrap phase of
|
||||
the build.
|
||||
@ -369,7 +361,7 @@ To be able to build the system, either gcc or clang bootstrap must be
|
||||
enabled unless an alternate compiler is provided via XCC.
|
||||
.Pp
|
||||
This is a default setting on
|
||||
mips/mipsel, mips/mips, mips/mips64el, mips/mips64, mips/mipsn32, mips/mipselhf, mips/mipshf, mips/mips64elhf, mips/mips64hf and sparc64/sparc64.
|
||||
mips/mipsel, mips/mips, mips/mips64el, mips/mips64, mips/mipsn32, mips/mipselhf, mips/mipshf, mips/mips64elhf and mips/mips64hf.
|
||||
.It Va WITH_CLANG_BOOTSTRAP
|
||||
Set to build the Clang C/C++ compiler during the bootstrap phase of the build.
|
||||
.Pp
|
||||
@ -381,15 +373,6 @@ clang-format.
|
||||
.It Va WITHOUT_CLANG_FULL
|
||||
Set to avoid building the ARCMigrate, Rewriter and StaticAnalyzer components of
|
||||
the Clang C/C++ compiler.
|
||||
.Pp
|
||||
This is a default setting on
|
||||
sparc64/sparc64.
|
||||
.It Va WITH_CLANG_FULL
|
||||
Set to build the ARCMigrate, Rewriter and StaticAnalyzer components of the
|
||||
Clang C/C++ compiler.
|
||||
.Pp
|
||||
This is a default setting on
|
||||
amd64/amd64, arm/armv6, arm/armv7, arm64/aarch64, i386/i386, mips/mipsel, mips/mips, mips/mips64el, mips/mips64, mips/mipsn32, mips/mipselhf, mips/mipshf, mips/mips64elhf, mips/mips64hf, powerpc/powerpc, powerpc/powerpc64, riscv/riscv64 and riscv/riscv64sf.
|
||||
.It Va WITHOUT_CLANG_IS_CC
|
||||
Do not install links to the Clang C/C++ compiler as
|
||||
.Pa /usr/bin/cc ,
|
||||
@ -401,7 +384,7 @@ If
|
||||
is set then links to the GCC C/C++ compiler will be installed instead.
|
||||
.Pp
|
||||
This is a default setting on
|
||||
mips/mipsel, mips/mips, mips/mips64el, mips/mips64, mips/mipsn32, mips/mipselhf, mips/mipshf, mips/mips64elhf, mips/mips64hf and sparc64/sparc64.
|
||||
mips/mipsel, mips/mips, mips/mips64el, mips/mips64, mips/mipsn32, mips/mipselhf, mips/mipshf, mips/mips64elhf and mips/mips64hf.
|
||||
.It Va WITH_CLANG_IS_CC
|
||||
Install links to the Clang C/C++ compiler as
|
||||
.Pa /usr/bin/cc ,
|
||||
@ -489,7 +472,7 @@ Set to build
|
||||
.Xr cxgbetool 8
|
||||
.Pp
|
||||
This is a default setting on
|
||||
amd64/amd64, arm64/aarch64, i386/i386, powerpc/powerpc64 and sparc64/sparc64.
|
||||
amd64/amd64, arm64/aarch64, i386/i386 and powerpc/powerpc64.
|
||||
.It Va WITHOUT_CXX
|
||||
Set to not build
|
||||
.Xr c++ 1
|
||||
@ -646,7 +629,7 @@ and
|
||||
.Xr efivar 8 .
|
||||
.Pp
|
||||
This is a default setting on
|
||||
mips/mipsel, mips/mips, mips/mips64el, mips/mips64, mips/mipsn32, mips/mipselhf, mips/mipshf, mips/mips64elhf, mips/mips64hf, powerpc/powerpc, powerpc/powerpc64, riscv/riscv64, riscv/riscv64sf and sparc64/sparc64.
|
||||
mips/mipsel, mips/mips, mips/mips64el, mips/mips64, mips/mipsn32, mips/mipselhf, mips/mipshf, mips/mips64elhf, mips/mips64hf, powerpc/powerpc, powerpc/powerpc64, riscv/riscv64 and riscv/riscv64sf.
|
||||
.It Va WITH_EFI
|
||||
Set to build
|
||||
.Xr efivar 3
|
||||
@ -737,28 +720,12 @@ Set to build
|
||||
.Xr gdb 1 .
|
||||
.Pp
|
||||
This is a default setting on
|
||||
amd64/amd64, arm/armv6, arm/armv7, i386/i386, mips/mipsel, mips/mips, mips/mips64el, mips/mips64, mips/mipsn32, mips/mipselhf, mips/mipshf, mips/mips64elhf, mips/mips64hf, powerpc/powerpc, powerpc/powerpc64 and sparc64/sparc64.
|
||||
amd64/amd64, arm/armv6, arm/armv7, i386/i386, mips/mipsel, mips/mips, mips/mips64el, mips/mips64, mips/mipsn32, mips/mipselhf, mips/mipshf, mips/mips64elhf, mips/mips64hf, powerpc/powerpc and powerpc/powerpc64.
|
||||
.It Va WITHOUT_GDB_LIBEXEC
|
||||
Set to install
|
||||
.Xr gdb 1
|
||||
into
|
||||
.Pa /usr/bin .
|
||||
.Pp
|
||||
This is a default setting on
|
||||
sparc64/sparc64.
|
||||
.It Va WITH_GDB_LIBEXEC
|
||||
Set to install
|
||||
.Xr gdb 1
|
||||
into
|
||||
.Pa /usr/libexec .
|
||||
This permits
|
||||
.Xr gdb 1
|
||||
to be used as a fallback for
|
||||
.Xr crashinfo 8
|
||||
if a newer version is not installed.
|
||||
.Pp
|
||||
This is a default setting on
|
||||
amd64/amd64, arm/armv6, arm/armv7, arm64/aarch64, i386/i386, mips/mipsel, mips/mips, mips/mips64el, mips/mips64, mips/mipsn32, mips/mipselhf, mips/mipshf, mips/mips64elhf, mips/mips64hf, powerpc/powerpc, powerpc/powerpc64, riscv/riscv64 and riscv/riscv64sf.
|
||||
.It Va WITH_GNUCXX
|
||||
Build the GNU C++ stack (g++, libstdc++).
|
||||
This option is deprecated and will be removed before
|
||||
@ -797,13 +764,11 @@ and related utilities.
|
||||
Set to build Hesiod support.
|
||||
.It Va WITHOUT_HTML
|
||||
Set to not build HTML docs.
|
||||
.It Va WITH_HTTPD
|
||||
Set to build and install simple_httpd
|
||||
.It Va WITHOUT_HYPERV
|
||||
Set to not build or install HyperV utilities.
|
||||
.Pp
|
||||
This is a default setting on
|
||||
arm/armv6, arm/armv7, arm64/aarch64, mips/mipsel, mips/mips, mips/mips64el, mips/mips64, mips/mipsn32, mips/mipselhf, mips/mipshf, mips/mips64elhf, mips/mips64hf, powerpc/powerpc, powerpc/powerpc64, riscv/riscv64, riscv/riscv64sf and sparc64/sparc64.
|
||||
arm/armv6, arm/armv7, arm64/aarch64, mips/mipsel, mips/mips, mips/mips64el, mips/mips64, mips/mipsn32, mips/mipselhf, mips/mipshf, mips/mips64elhf, mips/mips64hf, powerpc/powerpc, powerpc/powerpc64, riscv/riscv64 and riscv/riscv64sf.
|
||||
.It Va WITH_HYPERV
|
||||
Set to build or install HyperV utilities.
|
||||
.Pp
|
||||
@ -957,7 +922,7 @@ On 64-bit platforms, set to not build 32-bit library set and a
|
||||
runtime linker.
|
||||
.Pp
|
||||
This is a default setting on
|
||||
arm/armv6, arm/armv7, arm64/aarch64, i386/i386, mips/mipsel, mips/mips, mips/mipsn32, mips/mipselhf, mips/mipshf, powerpc/powerpc, riscv/riscv64, riscv/riscv64sf and sparc64/sparc64.
|
||||
arm/armv6, arm/armv7, arm64/aarch64, i386/i386, mips/mipsel, mips/mips, mips/mipsn32, mips/mipselhf, mips/mipshf, powerpc/powerpc, riscv/riscv64 and riscv/riscv64sf.
|
||||
.It Va WITHOUT_LIBCPLUSPLUS
|
||||
Set to avoid building libcxxrt and libc++.
|
||||
.It Va WITHOUT_LIBPTHREAD
|
||||
@ -981,19 +946,11 @@ Set to not build the
|
||||
library.
|
||||
.It Va WITHOUT_LLD
|
||||
Set to not build LLVM's lld linker.
|
||||
.Pp
|
||||
This is a default setting on
|
||||
sparc64/sparc64.
|
||||
.It Va WITH_LLD
|
||||
Set to build LLVM's lld linker.
|
||||
.Pp
|
||||
This is a default setting on
|
||||
amd64/amd64, arm/armv6, arm/armv7, arm64/aarch64, i386/i386, mips/mipsel, mips/mips, mips/mips64el, mips/mips64, mips/mipsn32, mips/mipselhf, mips/mipshf, mips/mips64elhf, mips/mips64hf, powerpc/powerpc, powerpc/powerpc64, riscv/riscv64 and riscv/riscv64sf.
|
||||
.It Va WITHOUT_LLDB
|
||||
Set to not build the LLDB debugger.
|
||||
.Pp
|
||||
This is a default setting on
|
||||
arm/armv6, arm/armv7, mips/mipsel, mips/mips, mips/mips64el, mips/mips64, mips/mipsn32, mips/mipselhf, mips/mipshf, mips/mips64elhf, mips/mips64hf, powerpc/powerpc, powerpc/powerpc64, riscv/riscv64, riscv/riscv64sf and sparc64/sparc64.
|
||||
arm/armv6, arm/armv7, mips/mipsel, mips/mips, mips/mips64el, mips/mips64, mips/mipsn32, mips/mipselhf, mips/mipshf, mips/mips64elhf, mips/mips64hf, powerpc/powerpc, powerpc/powerpc64, riscv/riscv64 and riscv/riscv64sf.
|
||||
.It Va WITH_LLDB
|
||||
Set to build the LLDB debugger.
|
||||
.Pp
|
||||
@ -1006,7 +963,7 @@ To be able to build the system, either Binutils or LLD bootstrap must be
|
||||
enabled unless an alternate linker is provided via XLD.
|
||||
.Pp
|
||||
This is a default setting on
|
||||
mips/mipsel, mips/mips, mips/mips64el, mips/mips64, mips/mipsn32, mips/mipselhf, mips/mipshf, mips/mips64elhf, mips/mips64hf, powerpc/powerpc and sparc64/sparc64.
|
||||
mips/mipsel, mips/mips, mips/mips64el, mips/mips64, mips/mipsn32, mips/mipselhf, mips/mipshf, mips/mips64elhf, mips/mips64hf and powerpc/powerpc.
|
||||
.It Va WITH_LLD_BOOTSTRAP
|
||||
Set to build the LLD linker during the bootstrap phase of the build,
|
||||
and use it during buildworld and buildkernel.
|
||||
@ -1017,7 +974,7 @@ amd64/amd64, arm/armv6, arm/armv7, arm64/aarch64, i386/i386, powerpc/powerpc64,
|
||||
Set to use GNU binutils ld as the system linker, instead of LLVM's LLD.
|
||||
.Pp
|
||||
This is a default setting on
|
||||
mips/mipsel, mips/mips, mips/mips64el, mips/mips64, mips/mipsn32, mips/mipselhf, mips/mipshf, mips/mips64elhf, mips/mips64hf, powerpc/powerpc and sparc64/sparc64.
|
||||
mips/mipsel, mips/mips, mips/mips64el, mips/mips64, mips/mipsn32, mips/mipselhf, mips/mipshf, mips/mips64elhf, mips/mips64hf and powerpc/powerpc.
|
||||
.It Va WITH_LLD_IS_LD
|
||||
Set to use LLVM's LLD as the system linker, instead of GNU binutils ld.
|
||||
.Pp
|
||||
@ -1027,26 +984,8 @@ amd64/amd64, arm/armv6, arm/armv7, arm64/aarch64, i386/i386, powerpc/powerpc64,
|
||||
Set to not build the
|
||||
.Xr llvm-cov 1
|
||||
tool.
|
||||
.Pp
|
||||
This is a default setting on
|
||||
sparc64/sparc64.
|
||||
.It Va WITH_LLVM_COV
|
||||
Set to build the
|
||||
.Xr llvm-cov 1
|
||||
tool.
|
||||
.Pp
|
||||
This is a default setting on
|
||||
amd64/amd64, arm/armv6, arm/armv7, arm64/aarch64, i386/i386, mips/mipsel, mips/mips, mips/mips64el, mips/mips64, mips/mipsn32, mips/mipselhf, mips/mipshf, mips/mips64elhf, mips/mips64hf, powerpc/powerpc, powerpc/powerpc64, riscv/riscv64 and riscv/riscv64sf.
|
||||
.It Va WITHOUT_LLVM_LIBUNWIND
|
||||
Set to use GCC's stack unwinder (instead of LLVM's libunwind).
|
||||
.Pp
|
||||
This is a default setting on
|
||||
sparc64/sparc64.
|
||||
.It Va WITH_LLVM_LIBUNWIND
|
||||
Set to use LLVM's libunwind stack unwinder (instead of GCC's unwinder).
|
||||
.Pp
|
||||
This is a default setting on
|
||||
amd64/amd64, arm/armv6, arm/armv7, arm64/aarch64, i386/i386, mips/mipsel, mips/mips, mips/mips64el, mips/mips64, mips/mipsn32, mips/mipselhf, mips/mipshf, mips/mips64elhf, mips/mips64hf, powerpc/powerpc, powerpc/powerpc64, riscv/riscv64 and riscv/riscv64sf.
|
||||
.It Va WITHOUT_LLVM_TARGET_AARCH64
|
||||
Set to not build LLVM target support for AArch64.
|
||||
The
|
||||
@ -1133,7 +1072,7 @@ endian mode.
|
||||
Disable inclusion of GELI crypto support in the boot chain binaries.
|
||||
.Pp
|
||||
This is a default setting on
|
||||
powerpc/powerpc, powerpc/powerpc64 and sparc64/sparc64.
|
||||
powerpc/powerpc and powerpc/powerpc64.
|
||||
.It Va WITH_LOADER_GELI
|
||||
Set to build GELI bootloader support.
|
||||
.Pp
|
||||
@ -1143,7 +1082,7 @@ amd64/amd64, arm/armv6, arm/armv7, arm64/aarch64, i386/i386, mips/mipsel, mips/m
|
||||
Set to not build LUA bindings for the boot loader.
|
||||
.Pp
|
||||
This is a default setting on
|
||||
powerpc/powerpc, powerpc/powerpc64 and sparc64/sparc64.
|
||||
powerpc/powerpc and powerpc/powerpc64.
|
||||
.It Va WITH_LOADER_LUA
|
||||
Set to build LUA bindings for the boot loader.
|
||||
.Pp
|
||||
@ -1158,12 +1097,12 @@ amd64/amd64, arm/armv6, arm/armv7, arm64/aarch64, i386/i386, mips/mipsel, mips/m
|
||||
Set to build openfirmware bootloader components.
|
||||
.Pp
|
||||
This is a default setting on
|
||||
powerpc/powerpc, powerpc/powerpc64 and sparc64/sparc64.
|
||||
powerpc/powerpc and powerpc/powerpc64.
|
||||
.It Va WITHOUT_LOADER_UBOOT
|
||||
Disable building of ubldr.
|
||||
.Pp
|
||||
This is a default setting on
|
||||
amd64/amd64, arm64/aarch64, i386/i386, riscv/riscv64, riscv/riscv64sf and sparc64/sparc64.
|
||||
amd64/amd64, arm64/aarch64, i386/i386, riscv/riscv64 and riscv/riscv64sf.
|
||||
.It Va WITH_LOADER_UBOOT
|
||||
Set to build ubldr.
|
||||
.Pp
|
||||
@ -1334,7 +1273,7 @@ Set to build
|
||||
.Xr mlx5tool 8
|
||||
.Pp
|
||||
This is a default setting on
|
||||
amd64/amd64, arm64/aarch64, i386/i386, powerpc/powerpc64 and sparc64/sparc64.
|
||||
amd64/amd64, arm64/aarch64, i386/i386 and powerpc/powerpc64.
|
||||
.It Va WITHOUT_NDIS
|
||||
Set to not build programs and libraries
|
||||
related to NDIS emulation support.
|
||||
@ -1399,7 +1338,7 @@ and related programs.
|
||||
Set to not build nvme related tools and kernel modules.
|
||||
.Pp
|
||||
This is a default setting on
|
||||
arm/armv6, arm/armv7, mips/mipsel, mips/mips, mips/mips64el, mips/mips64, mips/mipsn32, mips/mipselhf, mips/mipshf, mips/mips64elhf, mips/mips64hf, powerpc/powerpc, riscv/riscv64, riscv/riscv64sf and sparc64/sparc64.
|
||||
arm/armv6, arm/armv7, mips/mipsel, mips/mips, mips/mips64el, mips/mips64, mips/mipsn32, mips/mipselhf, mips/mipshf, mips/mips64elhf, mips/mips64hf, powerpc/powerpc, riscv/riscv64 and riscv/riscv64sf.
|
||||
.It Va WITH_NVME
|
||||
Set to build nvme related tools and kernel modules.
|
||||
|
||||
@ -1420,7 +1359,7 @@ Enable building openldap support for kerberos.
|
||||
Set to not build LLVM's OpenMP runtime.
|
||||
.Pp
|
||||
This is a default setting on
|
||||
arm/armv6, arm/armv7, arm64/aarch64, mips/mipsel, mips/mips, mips/mips64el, mips/mips64, mips/mipsn32, mips/mipselhf, mips/mipshf, mips/mips64elhf, mips/mips64hf, powerpc/powerpc, riscv/riscv64, riscv/riscv64sf and sparc64/sparc64.
|
||||
arm/armv6, arm/armv7, arm64/aarch64, mips/mipsel, mips/mips, mips/mips64el, mips/mips64, mips/mipsn32, mips/mipselhf, mips/mipshf, mips/mips64elhf, mips/mips64hf, powerpc/powerpc, riscv/riscv64 and riscv/riscv64sf.
|
||||
.It Va WITH_OPENMP
|
||||
Set to build LLVM's OpenMP runtime.
|
||||
.Pp
|
||||
@ -1519,7 +1458,7 @@ Set to build profiled libraries for use with
|
||||
.Xr gprof 8 .
|
||||
.Pp
|
||||
This is a default setting on
|
||||
amd64/amd64, arm/armv6, arm/armv7, arm64/aarch64, i386/i386, mips/mipsel, mips/mips, mips/mipsn32, mips/mipselhf, mips/mipshf, powerpc/powerpc, powerpc/powerpc64, riscv/riscv64, riscv/riscv64sf and sparc64/sparc64.
|
||||
amd64/amd64, arm/armv6, arm/armv7, arm64/aarch64, i386/i386, mips/mipsel, mips/mips, mips/mipsn32, mips/mipselhf, mips/mipshf, powerpc/powerpc, powerpc/powerpc64, riscv/riscv64 and riscv/riscv64sf.
|
||||
.It Va WITHOUT_QUOTAS
|
||||
Set to not build
|
||||
.Xr quota 1
|
||||
@ -1609,7 +1548,7 @@ mips/mipsel, mips/mips, mips/mips64el, mips/mips64, mips/mipsn32, mips/mipselhf,
|
||||
Set to build world with propolice stack smashing protection.
|
||||
.Pp
|
||||
This is a default setting on
|
||||
amd64/amd64, arm/armv6, arm/armv7, arm64/aarch64, i386/i386, powerpc/powerpc, powerpc/powerpc64, riscv/riscv64, riscv/riscv64sf and sparc64/sparc64.
|
||||
amd64/amd64, arm/armv6, arm/armv7, arm64/aarch64, i386/i386, powerpc/powerpc, powerpc/powerpc64, riscv/riscv64 and riscv/riscv64sf.
|
||||
.It Va WITH_STAGING
|
||||
Enable staging of files to a stage tree.
|
||||
This can be best thought of as auto-install to
|
||||
|
@ -25,7 +25,7 @@
|
||||
.\"
|
||||
.\" $FreeBSD$
|
||||
.\"
|
||||
.Dd March 12, 2019
|
||||
.Dd February 4, 2020
|
||||
.Dt PORTS 7
|
||||
.Os
|
||||
.Sh NAME
|
||||
@ -592,7 +592,7 @@ build its dependencies.
|
||||
Instead, the dependencies are downloaded via
|
||||
.Xr pkg 8 .
|
||||
.Bd -literal -offset 2n
|
||||
.Li # Ic make missing | xargs pkg install --automatic --yes
|
||||
.Li # Ic make install-missing-packages
|
||||
.Li # Ic make install
|
||||
.Ed
|
||||
.Pp
|
||||
|
@ -28,7 +28,7 @@
|
||||
.\"
|
||||
.\" $FreeBSD$
|
||||
.\"
|
||||
.Dd December 11, 2019
|
||||
.Dd February 4, 2020
|
||||
.Dt SECURITY 7
|
||||
.Os
|
||||
.Sh NAME
|
||||
@ -272,8 +272,8 @@ also add an additional layer of protection to the key pair by password
|
||||
protecting the keypair when you create it with
|
||||
.Xr ssh-keygen 1 .
|
||||
Being able
|
||||
to *-out the passwords for staff accounts also guarantees that staff members
|
||||
can only log in through secure access methods that you have set up.
|
||||
to star-out the passwords for staff accounts also guarantees that staff
|
||||
members can only log in through secure access methods that you have set up.
|
||||
You can
|
||||
thus force all staff members to use secure, encrypted connections for
|
||||
all their sessions which closes an important hole used by many intruders: that
|
||||
|
@ -25,7 +25,7 @@
|
||||
.\"
|
||||
.\" $FreeBSD$
|
||||
.\"
|
||||
.Dd January 8, 2020
|
||||
.Dd February 4, 2020
|
||||
.Dt UMA 9
|
||||
.Os
|
||||
.Sh NAME
|
||||
@ -340,6 +340,10 @@ was allocated will cause mixing in per-CPU caches.
|
||||
See
|
||||
.Xr numa 4
|
||||
for more details.
|
||||
.It Dv UMA_ZONE_CONTIG
|
||||
Items in this zone must be contiguous in physical address space.
|
||||
Items will follow normal alignment constraints and may span page boundaries
|
||||
between pages with contiguous physical addresses.
|
||||
.El
|
||||
.Pp
|
||||
Zones can be destroyed using
|
||||
@ -465,12 +469,8 @@ and
|
||||
.Fn uma_zone_set_freef
|
||||
functions allow a zone's default slab allocation and free functions to be
|
||||
overridden.
|
||||
This is useful if the zone's items have special memory allocation constraints.
|
||||
For example, if multi-page objects are required to be physically contiguous,
|
||||
an
|
||||
.Fa allocf
|
||||
function which requests contiguous memory from the kernel's page allocator
|
||||
may be used.
|
||||
This is useful if memory with special constraints such as attributes,
|
||||
alignment, or address ranges must be used.
|
||||
.Pp
|
||||
The
|
||||
.Fn uma_zone_set_max
|
||||
|
@ -65,7 +65,7 @@ _ld_version!= (${${ld}} --version || echo none) | sed -n 1p
|
||||
.if ${_ld_version:[1..2]} == "GNU ld"
|
||||
${X_}LINKER_TYPE= bfd
|
||||
${X_}LINKER_FREEBSD_VERSION= 0
|
||||
_v= ${_ld_version:M[1-9].[0-9]*:[1]}
|
||||
_v= ${_ld_version:M[1-9]*.[0-9]*:[1]}
|
||||
.elif ${_ld_version:[1]} == "LLD"
|
||||
${X_}LINKER_TYPE= lld
|
||||
_v= ${_ld_version:[2]}
|
||||
@ -77,7 +77,7 @@ ${X_}LINKER_FREEBSD_VERSION!= \
|
||||
${X_}LINKER_TYPE= bfd
|
||||
_v= 2.17.50
|
||||
.endif
|
||||
${X_}LINKER_VERSION!= echo "${_v:M[1-9].[0-9]*}" | \
|
||||
${X_}LINKER_VERSION!= echo "${_v:M[1-9]*.[0-9]*}" | \
|
||||
awk -F. '{print $$1 * 10000 + $$2 * 100 + $$3;}'
|
||||
.undef _ld_version
|
||||
.undef _v
|
||||
|
@ -344,7 +344,8 @@ _DP_xo= util
|
||||
# The libc dependencies are not strictly needed but are defined to make the
|
||||
# assert happy.
|
||||
_DP_c= compiler_rt
|
||||
.if ${MK_SSP} != "no"
|
||||
.if ${MK_SSP} != "no" && \
|
||||
(${MACHINE_ARCH} == "i386" || ${MACHINE_ARCH:Mpower*} != "")
|
||||
_DP_c+= ssp_nonshared
|
||||
.endif
|
||||
_DP_stats= sbuf pthread
|
||||
|
@ -205,7 +205,6 @@ __DEFAULT_NO_OPTIONS = \
|
||||
GNU_GREP_COMPAT \
|
||||
GPL_DTC \
|
||||
HESIOD \
|
||||
HTTPD \
|
||||
LIBSOFT \
|
||||
LOADER_FIREWIRE \
|
||||
LOADER_FORCE_LE \
|
||||
|
@ -49,55 +49,6 @@ __FBSDID("$FreeBSD$");
|
||||
#include "geliboot.h"
|
||||
#endif
|
||||
|
||||
#if defined(__sparc64__)
|
||||
#include <openfirm.h>
|
||||
|
||||
extern struct tlb_entry *dtlb_store;
|
||||
extern struct tlb_entry *itlb_store;
|
||||
|
||||
extern int dtlb_slot;
|
||||
extern int itlb_slot;
|
||||
|
||||
static int
|
||||
md_bootserial(void)
|
||||
{
|
||||
char buf[64];
|
||||
ihandle_t inst;
|
||||
phandle_t input;
|
||||
phandle_t node;
|
||||
phandle_t output;
|
||||
|
||||
if ((node = OF_finddevice("/options")) == -1)
|
||||
return(-1);
|
||||
if (OF_getprop(node, "input-device", buf, sizeof(buf)) == -1)
|
||||
return(-1);
|
||||
input = OF_finddevice(buf);
|
||||
if (OF_getprop(node, "output-device", buf, sizeof(buf)) == -1)
|
||||
return(-1);
|
||||
output = OF_finddevice(buf);
|
||||
if (input == -1 || output == -1 ||
|
||||
OF_getproplen(input, "keyboard") >= 0) {
|
||||
if ((node = OF_finddevice("/chosen")) == -1)
|
||||
return(-1);
|
||||
if (OF_getprop(node, "stdin", &inst, sizeof(inst)) == -1)
|
||||
return(-1);
|
||||
if ((input = OF_instance_to_package(inst)) == -1)
|
||||
return(-1);
|
||||
if (OF_getprop(node, "stdout", &inst, sizeof(inst)) == -1)
|
||||
return(-1);
|
||||
if ((output = OF_instance_to_package(inst)) == -1)
|
||||
return(-1);
|
||||
}
|
||||
if (input != output)
|
||||
return(-1);
|
||||
if (OF_getprop(input, "device_type", buf, sizeof(buf)) == -1)
|
||||
return(-1);
|
||||
if (strcmp(buf, "serial") != 0)
|
||||
return(-1);
|
||||
return(0);
|
||||
}
|
||||
#endif
|
||||
|
||||
static int
|
||||
md_getboothowto(char *kargs)
|
||||
{
|
||||
@ -106,15 +57,10 @@ md_getboothowto(char *kargs)
|
||||
/* Parse kargs */
|
||||
howto = boot_parse_cmdline(kargs);
|
||||
howto |= boot_env_to_howto();
|
||||
#if defined(__sparc64__)
|
||||
if (md_bootserial() != -1)
|
||||
howto |= RB_SERIAL;
|
||||
#else
|
||||
if (!strcmp(getenv("console"), "comconsole"))
|
||||
howto |= RB_SERIAL;
|
||||
if (!strcmp(getenv("console"), "nullconsole"))
|
||||
howto |= RB_MUTE;
|
||||
#endif
|
||||
return(howto);
|
||||
}
|
||||
|
||||
@ -362,16 +308,6 @@ md_load_dual(char *args, vm_offset_t *modulep, vm_offset_t *dtb, int kern64)
|
||||
#ifdef LOADER_GELI_SUPPORT
|
||||
geli_export_key_metadata(kfp);
|
||||
#endif
|
||||
#if defined(__sparc64__)
|
||||
file_addmetadata(kfp, MODINFOMD_DTLB_SLOTS,
|
||||
sizeof dtlb_slot, &dtlb_slot);
|
||||
file_addmetadata(kfp, MODINFOMD_ITLB_SLOTS,
|
||||
sizeof itlb_slot, &itlb_slot);
|
||||
file_addmetadata(kfp, MODINFOMD_DTLB,
|
||||
dtlb_slot * sizeof(*dtlb_store), dtlb_store);
|
||||
file_addmetadata(kfp, MODINFOMD_ITLB,
|
||||
itlb_slot * sizeof(*itlb_store), itlb_store);
|
||||
#endif
|
||||
|
||||
*modulep = addr;
|
||||
size = md_copymodules(0, kern64);
|
||||
@ -411,15 +347,13 @@ md_load_dual(char *args, vm_offset_t *modulep, vm_offset_t *dtb, int kern64)
|
||||
return(0);
|
||||
}
|
||||
|
||||
#if !defined(__sparc64__)
|
||||
int
|
||||
md_load(char *args, vm_offset_t *modulep, vm_offset_t *dtb)
|
||||
{
|
||||
return (md_load_dual(args, modulep, dtb, 0));
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(__mips__) || defined(__powerpc__) || defined(__sparc64__)
|
||||
#if defined(__mips__) || defined(__powerpc__)
|
||||
int
|
||||
md_load64(char *args, vm_offset_t *modulep, vm_offset_t *dtb)
|
||||
{
|
||||
|
@ -1,99 +0,0 @@
|
||||
/*******************************************************************
|
||||
** s y s d e p . c
|
||||
** Forth Inspired Command Language
|
||||
** Author: John Sadler (john_sadler@alum.mit.edu)
|
||||
** Created: 16 Oct 1997
|
||||
** Implementations of FICL external interface functions...
|
||||
**
|
||||
*******************************************************************/
|
||||
|
||||
/* $FreeBSD$ */
|
||||
|
||||
#ifdef TESTMAIN
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#else
|
||||
#include <stand.h>
|
||||
#endif
|
||||
#include "ficl.h"
|
||||
|
||||
/*
|
||||
******************* FreeBSD P O R T B E G I N S H E R E ******************** Michael Smith
|
||||
*/
|
||||
|
||||
#if PORTABLE_LONGMULDIV == 0
|
||||
DPUNS ficlLongMul(FICL_UNS x, FICL_UNS y)
|
||||
{
|
||||
DPUNS q;
|
||||
uint64_t qx;
|
||||
|
||||
qx = (uint64_t)x * (uint64_t) y;
|
||||
|
||||
q.hi = (uint32_t)( qx >> 32 );
|
||||
q.lo = (uint32_t)( qx & 0xFFFFFFFFL);
|
||||
|
||||
return q;
|
||||
}
|
||||
|
||||
UNSQR ficlLongDiv(DPUNS q, FICL_UNS y)
|
||||
{
|
||||
UNSQR result;
|
||||
uint64_t qx, qh;
|
||||
|
||||
qh = q.hi;
|
||||
qx = (qh << 32) | q.lo;
|
||||
|
||||
result.quot = qx / y;
|
||||
result.rem = qx % y;
|
||||
|
||||
return result;
|
||||
}
|
||||
#endif
|
||||
|
||||
void ficlTextOut(FICL_VM *pVM, char *msg, int fNewline)
|
||||
{
|
||||
IGNORE(pVM);
|
||||
|
||||
while(*msg != 0)
|
||||
putchar(*(msg++));
|
||||
if (fNewline)
|
||||
putchar('\n');
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void *ficlMalloc (size_t size)
|
||||
{
|
||||
return malloc(size);
|
||||
}
|
||||
|
||||
void *ficlRealloc (void *p, size_t size)
|
||||
{
|
||||
return realloc(p, size);
|
||||
}
|
||||
|
||||
void ficlFree (void *p)
|
||||
{
|
||||
free(p);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
** Stub function for dictionary access control - does nothing
|
||||
** by default, user can redefine to guarantee exclusive dict
|
||||
** access to a single thread for updates. All dict update code
|
||||
** is guaranteed to be bracketed as follows:
|
||||
** ficlLockDictionary(TRUE);
|
||||
** <code that updates dictionary>
|
||||
** ficlLockDictionary(FALSE);
|
||||
**
|
||||
** Returns zero if successful, nonzero if unable to acquire lock
|
||||
** befor timeout (optional - could also block forever)
|
||||
*/
|
||||
#if FICL_MULTITHREAD
|
||||
int ficlLockDictionary(short fLock)
|
||||
{
|
||||
IGNORE(fLock);
|
||||
return 0;
|
||||
}
|
||||
#endif /* FICL_MULTITHREAD */
|
@ -1,412 +0,0 @@
|
||||
/*******************************************************************
|
||||
s y s d e p . h
|
||||
** Forth Inspired Command Language
|
||||
** Author: John Sadler (john_sadler@alum.mit.edu)
|
||||
** Created: 16 Oct 1997
|
||||
** Ficl system dependent types and prototypes...
|
||||
**
|
||||
** Note: Ficl also depends on the use of "assert" when
|
||||
** FICL_ROBUST is enabled. This may require some consideration
|
||||
** in firmware systems since assert often
|
||||
** assumes stderr/stdout.
|
||||
** $Id: sysdep.h,v 1.6 2001-04-26 21:41:55-07 jsadler Exp jsadler $
|
||||
*******************************************************************/
|
||||
/*
|
||||
** Copyright (c) 1997-2001 John Sadler (john_sadler@alum.mit.edu)
|
||||
** All rights reserved.
|
||||
**
|
||||
** Get the latest Ficl release at http://ficl.sourceforge.net
|
||||
**
|
||||
** L I C E N S E and D I S C L A I M E R
|
||||
**
|
||||
** 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.
|
||||
**
|
||||
** I am interested in hearing from anyone who uses ficl. If you have
|
||||
** a problem, a success story, a defect, an enhancement request, or
|
||||
** if you would like to contribute to the ficl release, please send
|
||||
** contact me by email at the address above.
|
||||
**
|
||||
** $Id: sysdep.h,v 1.6 2001-04-26 21:41:55-07 jsadler Exp jsadler $
|
||||
*/
|
||||
|
||||
/* $FreeBSD$ */
|
||||
|
||||
#if !defined (__SYSDEP_H__)
|
||||
#define __SYSDEP_H__
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <stddef.h> /* size_t, NULL */
|
||||
#include <setjmp.h>
|
||||
#include <assert.h>
|
||||
|
||||
#if !defined IGNORE /* Macro to silence unused param warnings */
|
||||
#define IGNORE(x) &x
|
||||
#endif
|
||||
|
||||
/*
|
||||
** TRUE and FALSE for C boolean operations, and
|
||||
** portable 32 bit types for CELLs
|
||||
**
|
||||
*/
|
||||
#if !defined TRUE
|
||||
#define TRUE 1
|
||||
#endif
|
||||
#if !defined FALSE
|
||||
#define FALSE 0
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
** System dependent data type declarations...
|
||||
*/
|
||||
#if !defined INT32
|
||||
#define INT32 int
|
||||
#endif
|
||||
|
||||
#if !defined UNS32
|
||||
#define UNS32 unsigned int
|
||||
#endif
|
||||
|
||||
#if !defined UNS16
|
||||
#define UNS16 unsigned short
|
||||
#endif
|
||||
|
||||
#if !defined UNS8
|
||||
#define UNS8 unsigned char
|
||||
#endif
|
||||
|
||||
#if !defined NULL
|
||||
#define NULL ((void *)0)
|
||||
#endif
|
||||
|
||||
/*
|
||||
** FICL_UNS and FICL_INT must have the same size as a void* on
|
||||
** the target system. A CELL is a union of void*, FICL_UNS, and
|
||||
** FICL_INT.
|
||||
** (11/2000: same for FICL_FLOAT)
|
||||
*/
|
||||
#if !defined FICL_INT
|
||||
#define FICL_INT long
|
||||
#endif
|
||||
|
||||
#if !defined FICL_UNS
|
||||
#define FICL_UNS unsigned long
|
||||
#endif
|
||||
|
||||
#if !defined FICL_FLOAT
|
||||
#define FICL_FLOAT float
|
||||
#endif
|
||||
|
||||
/*
|
||||
** Ficl presently supports values of 32 and 64 for BITS_PER_CELL
|
||||
*/
|
||||
#if !defined BITS_PER_CELL
|
||||
#define BITS_PER_CELL 64
|
||||
#endif
|
||||
|
||||
#if ((BITS_PER_CELL != 32) && (BITS_PER_CELL != 64))
|
||||
Error!
|
||||
#endif
|
||||
|
||||
typedef struct
|
||||
{
|
||||
FICL_UNS hi;
|
||||
FICL_UNS lo;
|
||||
} DPUNS;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
FICL_UNS quot;
|
||||
FICL_UNS rem;
|
||||
} UNSQR;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
FICL_INT hi;
|
||||
FICL_INT lo;
|
||||
} DPINT;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
FICL_INT quot;
|
||||
FICL_INT rem;
|
||||
} INTQR;
|
||||
|
||||
|
||||
/*
|
||||
** B U I L D C O N T R O L S
|
||||
*/
|
||||
|
||||
#if !defined (FICL_MINIMAL)
|
||||
#define FICL_MINIMAL 0
|
||||
#endif
|
||||
#if (FICL_MINIMAL)
|
||||
#define FICL_WANT_SOFTWORDS 0
|
||||
#define FICL_WANT_FLOAT 0
|
||||
#define FICL_WANT_USER 0
|
||||
#define FICL_WANT_LOCALS 0
|
||||
#define FICL_WANT_DEBUGGER 0
|
||||
#define FICL_WANT_OOP 0
|
||||
#define FICL_PLATFORM_EXTEND 0
|
||||
#define FICL_MULTITHREAD 0
|
||||
#define FICL_ROBUST 0
|
||||
#define FICL_EXTENDED_PREFIX 0
|
||||
#endif
|
||||
|
||||
/*
|
||||
** FICL_PLATFORM_EXTEND
|
||||
** Includes words defined in ficlCompilePlatform
|
||||
*/
|
||||
#if !defined (FICL_PLATFORM_EXTEND)
|
||||
#define FICL_PLATFORM_EXTEND 1
|
||||
#endif
|
||||
|
||||
/*
|
||||
** FICL_WANT_FLOAT
|
||||
** Includes a floating point stack for the VM, and words to do float operations.
|
||||
** Contributed by Guy Carver
|
||||
*/
|
||||
#if !defined (FICL_WANT_FLOAT)
|
||||
#define FICL_WANT_FLOAT 0
|
||||
#endif
|
||||
|
||||
/*
|
||||
** FICL_WANT_DEBUGGER
|
||||
** Inludes a simple source level debugger
|
||||
*/
|
||||
#if !defined (FICL_WANT_DEBUGGER)
|
||||
#define FICL_WANT_DEBUGGER 1
|
||||
#endif
|
||||
|
||||
/*
|
||||
** User variables: per-instance variables bound to the VM.
|
||||
** Kinda like thread-local storage. Could be implemented in a
|
||||
** VM private dictionary, but I've chosen the lower overhead
|
||||
** approach of an array of CELLs instead.
|
||||
*/
|
||||
#if !defined FICL_WANT_USER
|
||||
#define FICL_WANT_USER 1
|
||||
#endif
|
||||
|
||||
#if !defined FICL_USER_CELLS
|
||||
#define FICL_USER_CELLS 16
|
||||
#endif
|
||||
|
||||
/*
|
||||
** FICL_WANT_LOCALS controls the creation of the LOCALS wordset and
|
||||
** a private dictionary for local variable compilation.
|
||||
*/
|
||||
#if !defined FICL_WANT_LOCALS
|
||||
#define FICL_WANT_LOCALS 1
|
||||
#endif
|
||||
|
||||
/* Max number of local variables per definition */
|
||||
#if !defined FICL_MAX_LOCALS
|
||||
#define FICL_MAX_LOCALS 16
|
||||
#endif
|
||||
|
||||
/*
|
||||
** FICL_WANT_OOP
|
||||
** Inludes object oriented programming support (in softwords)
|
||||
** OOP support requires locals and user variables!
|
||||
*/
|
||||
#if !(FICL_WANT_LOCALS) || !(FICL_WANT_USER)
|
||||
#if !defined (FICL_WANT_OOP)
|
||||
#define FICL_WANT_OOP 0
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if !defined (FICL_WANT_OOP)
|
||||
#define FICL_WANT_OOP 1
|
||||
#endif
|
||||
|
||||
/*
|
||||
** FICL_WANT_SOFTWORDS
|
||||
** Controls inclusion of all softwords in softcore.c
|
||||
*/
|
||||
#if !defined (FICL_WANT_SOFTWORDS)
|
||||
#define FICL_WANT_SOFTWORDS 1
|
||||
#endif
|
||||
|
||||
/*
|
||||
** FICL_MULTITHREAD enables dictionary mutual exclusion
|
||||
** wia the ficlLockDictionary system dependent function.
|
||||
** Note: this implementation is experimental and poorly
|
||||
** tested. Further, it's unnecessary unless you really
|
||||
** intend to have multiple SESSIONS (poor choice of name
|
||||
** on my part) - that is, threads that modify the dictionary
|
||||
** at the same time.
|
||||
*/
|
||||
#if !defined FICL_MULTITHREAD
|
||||
#define FICL_MULTITHREAD 0
|
||||
#endif
|
||||
|
||||
/*
|
||||
** PORTABLE_LONGMULDIV causes ficlLongMul and ficlLongDiv to be
|
||||
** defined in C in sysdep.c. Use this if you cannot easily
|
||||
** generate an inline asm definition
|
||||
*/
|
||||
#if !defined (PORTABLE_LONGMULDIV)
|
||||
#define PORTABLE_LONGMULDIV 0
|
||||
#endif
|
||||
|
||||
/*
|
||||
** INLINE_INNER_LOOP causes the inner interpreter to be inline code
|
||||
** instead of a function call. This is mainly because MS VC++ 5
|
||||
** chokes with an internal compiler error on the function version.
|
||||
** in release mode. Sheesh.
|
||||
*/
|
||||
#if !defined INLINE_INNER_LOOP
|
||||
#if defined _DEBUG
|
||||
#define INLINE_INNER_LOOP 0
|
||||
#else
|
||||
#define INLINE_INNER_LOOP 1
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/*
|
||||
** FICL_ROBUST enables bounds checking of stacks and the dictionary.
|
||||
** This will detect stack over and underflows and dictionary overflows.
|
||||
** Any exceptional condition will result in an assertion failure.
|
||||
** (As generated by the ANSI assert macro)
|
||||
** FICL_ROBUST == 1 --> stack checking in the outer interpreter
|
||||
** FICL_ROBUST == 2 also enables checking in many primitives
|
||||
*/
|
||||
|
||||
#if !defined FICL_ROBUST
|
||||
#define FICL_ROBUST 2
|
||||
#endif
|
||||
|
||||
/*
|
||||
** FICL_DEFAULT_STACK Specifies the default size (in CELLs) of
|
||||
** a new virtual machine's stacks, unless overridden at
|
||||
** create time.
|
||||
*/
|
||||
#if !defined FICL_DEFAULT_STACK
|
||||
#define FICL_DEFAULT_STACK 128
|
||||
#endif
|
||||
|
||||
/*
|
||||
** FICL_DEFAULT_DICT specifies the number of CELLs to allocate
|
||||
** for the system dictionary by default. The value
|
||||
** can be overridden at startup time as well.
|
||||
** FICL_DEFAULT_ENV specifies the number of cells to allot
|
||||
** for the environment-query dictionary.
|
||||
*/
|
||||
#if !defined FICL_DEFAULT_DICT
|
||||
#define FICL_DEFAULT_DICT 12288
|
||||
#endif
|
||||
|
||||
#if !defined FICL_DEFAULT_ENV
|
||||
#define FICL_DEFAULT_ENV 260
|
||||
#endif
|
||||
|
||||
/*
|
||||
** FICL_DEFAULT_VOCS specifies the maximum number of wordlists in
|
||||
** the dictionary search order. See Forth DPANS sec 16.3.3
|
||||
** (file://dpans16.htm#16.3.3)
|
||||
*/
|
||||
#if !defined FICL_DEFAULT_VOCS
|
||||
#define FICL_DEFAULT_VOCS 16
|
||||
#endif
|
||||
|
||||
/*
|
||||
** FICL_MAX_PARSE_STEPS controls the size of an array in the FICL_SYSTEM structure
|
||||
** that stores pointers to parser extension functions. I would never expect to have
|
||||
** more than 8 of these, so that's the default limit. Too many of these functions
|
||||
** will probably exact a nasty performance penalty.
|
||||
*/
|
||||
#if !defined FICL_MAX_PARSE_STEPS
|
||||
#define FICL_MAX_PARSE_STEPS 8
|
||||
#endif
|
||||
|
||||
/*
|
||||
** FICL_EXTENDED_PREFIX enables a bunch of extra prefixes in prefix.c and prefix.fr (if
|
||||
** included as part of softcore.c)
|
||||
*/
|
||||
#if !defined FICL_EXTENDED_PREFIX
|
||||
#define FICL_EXTENDED_PREFIX 0
|
||||
#endif
|
||||
|
||||
/*
|
||||
** FICL_ALIGN is the power of two to which the dictionary
|
||||
** pointer address must be aligned. This value is usually
|
||||
** either 1 or 2, depending on the memory architecture
|
||||
** of the target system; 2 is safe on any 16 or 32 bit
|
||||
** machine. 3 would be appropriate for a 64 bit machine.
|
||||
*/
|
||||
#if !defined FICL_ALIGN
|
||||
#define FICL_ALIGN 3
|
||||
#define FICL_ALIGN_ADD ((1 << FICL_ALIGN) - 1)
|
||||
#endif
|
||||
|
||||
/*
|
||||
** System dependent routines --
|
||||
** edit the implementations in sysdep.c to be compatible
|
||||
** with your runtime environment...
|
||||
** ficlTextOut sends a NULL terminated string to the
|
||||
** default output device - used for system error messages
|
||||
** ficlMalloc and ficlFree have the same semantics as malloc and free
|
||||
** in standard C
|
||||
** ficlLongMul multiplies two UNS32s and returns a 64 bit unsigned
|
||||
** product
|
||||
** ficlLongDiv divides an UNS64 by an UNS32 and returns UNS32 quotient
|
||||
** and remainder
|
||||
*/
|
||||
struct vm;
|
||||
void ficlTextOut(struct vm *pVM, char *msg, int fNewline);
|
||||
void *ficlMalloc (size_t size);
|
||||
void ficlFree (void *p);
|
||||
void *ficlRealloc(void *p, size_t size);
|
||||
/*
|
||||
** Stub function for dictionary access control - does nothing
|
||||
** by default, user can redefine to guarantee exclusive dict
|
||||
** access to a single thread for updates. All dict update code
|
||||
** must be bracketed as follows:
|
||||
** ficlLockDictionary(TRUE);
|
||||
** <code that updates dictionary>
|
||||
** ficlLockDictionary(FALSE);
|
||||
**
|
||||
** Returns zero if successful, nonzero if unable to acquire lock
|
||||
** before timeout (optional - could also block forever)
|
||||
**
|
||||
** NOTE: this function must be implemented with lock counting
|
||||
** semantics: nested calls must behave properly.
|
||||
*/
|
||||
#if FICL_MULTITHREAD
|
||||
int ficlLockDictionary(short fLock);
|
||||
#else
|
||||
#define ficlLockDictionary(x) 0 /* ignore */
|
||||
#endif
|
||||
|
||||
/*
|
||||
** 64 bit integer math support routines: multiply two UNS32s
|
||||
** to get a 64 bit product, & divide the product by an UNS32
|
||||
** to get an UNS32 quotient and remainder. Much easier in asm
|
||||
** on a 32 bit CPU than in C, which usually doesn't support
|
||||
** the double length result (but it should).
|
||||
*/
|
||||
DPUNS ficlLongMul(FICL_UNS x, FICL_UNS y);
|
||||
UNSQR ficlLongDiv(DPUNS q, FICL_UNS y);
|
||||
|
||||
#endif /*__SYSDEP_H__*/
|
@ -98,6 +98,7 @@ struct specification_packet {
|
||||
uint16_t sp_sectorcount;
|
||||
uint16_t sp_cylsec;
|
||||
uint8_t sp_head;
|
||||
uint8_t sp_dummy[16]; /* Avoid memory corruption */
|
||||
};
|
||||
|
||||
/*
|
||||
@ -372,53 +373,91 @@ cd_init(void)
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
* Information from bootable CD-ROM.
|
||||
*/
|
||||
static int
|
||||
bd_get_diskinfo_cd(struct bdinfo *bd)
|
||||
{
|
||||
struct specification_packet bc_sp;
|
||||
int ret = -1;
|
||||
|
||||
(void) memset(&bc_sp, 0, sizeof (bc_sp));
|
||||
/* Set sp_size as per specification. */
|
||||
bc_sp.sp_size = sizeof (bc_sp) - sizeof (bc_sp.sp_dummy);
|
||||
|
||||
v86.ctl = V86_FLAGS;
|
||||
v86.addr = DISK_BIOS;
|
||||
v86.eax = CMD_CD_GET_STATUS;
|
||||
v86.edx = bd->bd_unit;
|
||||
v86.ds = VTOPSEG(&bc_sp);
|
||||
v86.esi = VTOPOFF(&bc_sp);
|
||||
v86int();
|
||||
|
||||
if ((v86.eax & 0xff00) == 0 &&
|
||||
bc_sp.sp_drive == bd->bd_unit) {
|
||||
bd->bd_cyl = ((bc_sp.sp_cylsec & 0xc0) << 2) +
|
||||
((bc_sp.sp_cylsec & 0xff00) >> 8) + 1;
|
||||
bd->bd_sec = bc_sp.sp_cylsec & 0x3f;
|
||||
bd->bd_hds = bc_sp.sp_head + 1;
|
||||
bd->bd_sectors = (uint64_t)bd->bd_cyl * bd->bd_hds * bd->bd_sec;
|
||||
|
||||
if (bc_sp.sp_bootmedia & 0x0F) {
|
||||
/* Floppy or hard-disk emulation */
|
||||
bd->bd_sectorsize = BIOSDISK_SECSIZE;
|
||||
return (-1);
|
||||
} else {
|
||||
bd->bd_sectorsize = 2048;
|
||||
bd->bd_flags = BD_MODEEDD | BD_CDROM;
|
||||
ret = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* If this is the boot_drive, default to non-emulation bootable CD-ROM.
|
||||
*/
|
||||
if (ret != 0 && bd->bd_unit >= 0x88) {
|
||||
bd->bd_cyl = 0;
|
||||
bd->bd_hds = 1;
|
||||
bd->bd_sec = 15;
|
||||
bd->bd_sectorsize = 2048;
|
||||
bd->bd_flags = BD_MODEEDD | BD_CDROM;
|
||||
bd->bd_sectors = 0;
|
||||
ret = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Note we can not use bd_get_diskinfo_ext() nor bd_get_diskinfo_std()
|
||||
* here - some systems do get hung with those.
|
||||
*/
|
||||
/*
|
||||
* Still no size? use 7.961GB. The size does not really matter
|
||||
* as long as it is reasonably large to make our reads to pass
|
||||
* the sector count check.
|
||||
*/
|
||||
if (bd->bd_sectors == 0)
|
||||
bd->bd_sectors = 4173824;
|
||||
|
||||
return (ret);
|
||||
}
|
||||
|
||||
int
|
||||
bc_add(int biosdev)
|
||||
{
|
||||
bdinfo_t *bd;
|
||||
struct specification_packet bc_sp;
|
||||
int nbcinfo = 0;
|
||||
|
||||
if (!STAILQ_EMPTY(&cdinfo))
|
||||
return (-1);
|
||||
|
||||
v86.ctl = V86_FLAGS;
|
||||
v86.addr = DISK_BIOS;
|
||||
v86.eax = CMD_CD_GET_STATUS;
|
||||
v86.edx = biosdev;
|
||||
v86.ds = VTOPSEG(&bc_sp);
|
||||
v86.esi = VTOPOFF(&bc_sp);
|
||||
v86int();
|
||||
if ((v86.eax & 0xff00) != 0)
|
||||
return (-1);
|
||||
|
||||
if ((bd = calloc(1, sizeof(*bd))) == NULL)
|
||||
return (-1);
|
||||
|
||||
bd->bd_flags = BD_CDROM;
|
||||
bd->bd_unit = biosdev;
|
||||
bd->bd_sectorsize = 2048;
|
||||
|
||||
/*
|
||||
* Ignore result from bd_int13probe(), we will use local
|
||||
* workaround below.
|
||||
*/
|
||||
(void)bd_int13probe(bd);
|
||||
|
||||
if (bd->bd_cyl == 0) {
|
||||
bd->bd_cyl = ((bc_sp.sp_cylsec & 0xc0) << 2) +
|
||||
((bc_sp.sp_cylsec & 0xff00) >> 8) + 1;
|
||||
if (bd_get_diskinfo_cd(bd) < 0) {
|
||||
free(bd);
|
||||
return (-1);
|
||||
}
|
||||
if (bd->bd_hds == 0)
|
||||
bd->bd_hds = bc_sp.sp_head + 1;
|
||||
if (bd->bd_sec == 0)
|
||||
bd->bd_sec = bc_sp.sp_cylsec & 0x3f;
|
||||
if (bd->bd_sectors == 0)
|
||||
bd->bd_sectors = (uint64_t)bd->bd_cyl * bd->bd_hds * bd->bd_sec;
|
||||
|
||||
/* Still no size? use 7.961GB */
|
||||
if (bd->bd_sectors == 0)
|
||||
bd->bd_sectors = 4173824;
|
||||
|
||||
STAILQ_INSERT_TAIL(&cdinfo, bd, bd_link);
|
||||
printf("BIOS CD is cd%d\n", nbcinfo);
|
||||
@ -499,22 +538,32 @@ bd_get_diskinfo_std(struct bdinfo *bd)
|
||||
|
||||
/*
|
||||
* Read EDD info. Return 0 on success, error otherwise.
|
||||
*
|
||||
* Avoid stack corruption on some systems by adding extra bytes to
|
||||
* params block.
|
||||
*/
|
||||
static int
|
||||
bd_get_diskinfo_ext(struct bdinfo *bd)
|
||||
{
|
||||
struct edd_params params;
|
||||
struct disk_params {
|
||||
struct edd_params head;
|
||||
struct edd_device_path_v3 device_path;
|
||||
uint8_t dummy[16];
|
||||
} __packed dparams;
|
||||
struct edd_params *params;
|
||||
uint64_t total;
|
||||
|
||||
params = &dparams.head;
|
||||
|
||||
/* Get disk params */
|
||||
bzero(¶ms, sizeof(params));
|
||||
params.len = sizeof(params);
|
||||
bzero(&dparams, sizeof(dparams));
|
||||
params->len = sizeof(struct edd_params_v3);
|
||||
v86.ctl = V86_FLAGS;
|
||||
v86.addr = DISK_BIOS;
|
||||
v86.eax = CMD_EXT_PARAM;
|
||||
v86.edx = bd->bd_unit;
|
||||
v86.ds = VTOPSEG(¶ms);
|
||||
v86.esi = VTOPOFF(¶ms);
|
||||
v86.ds = VTOPSEG(&dparams);
|
||||
v86.esi = VTOPOFF(&dparams);
|
||||
v86int();
|
||||
|
||||
if (V86_CY(v86.efl) && ((v86.eax & 0xff00) != 0))
|
||||
@ -526,20 +575,20 @@ bd_get_diskinfo_ext(struct bdinfo *bd)
|
||||
* powerof2(params.sector_size).
|
||||
* 16K is largest read buffer we can use at this time.
|
||||
*/
|
||||
if (params.sector_size >= 512 &&
|
||||
params.sector_size <= 16384 &&
|
||||
(params.sector_size % BIOSDISK_SECSIZE) == 0)
|
||||
bd->bd_sectorsize = params.sector_size;
|
||||
if (params->sector_size >= 512 &&
|
||||
params->sector_size <= 16384 &&
|
||||
(params->sector_size % BIOSDISK_SECSIZE) == 0)
|
||||
bd->bd_sectorsize = params->sector_size;
|
||||
|
||||
bd->bd_cyl = params.cylinders;
|
||||
bd->bd_hds = params.heads;
|
||||
bd->bd_sec = params.sectors_per_track;
|
||||
bd->bd_cyl = params->cylinders;
|
||||
bd->bd_hds = params->heads;
|
||||
bd->bd_sec = params->sectors_per_track;
|
||||
|
||||
if (params.sectors != 0) {
|
||||
total = params.sectors;
|
||||
if (params->sectors != 0) {
|
||||
total = params->sectors;
|
||||
} else {
|
||||
total = (uint64_t)params.cylinders *
|
||||
params.heads * params.sectors_per_track;
|
||||
total = (uint64_t)params->cylinders *
|
||||
params->heads * params->sectors_per_track;
|
||||
}
|
||||
bd->bd_sectors = total;
|
||||
|
||||
@ -556,6 +605,10 @@ bd_int13probe(bdinfo_t *bd)
|
||||
|
||||
bd->bd_flags &= ~BD_NO_MEDIA;
|
||||
|
||||
if ((bd->bd_flags & BD_CDROM) != 0) {
|
||||
return (bd_get_diskinfo_cd(bd) == 0);
|
||||
}
|
||||
|
||||
edd = bd_check_extensions(bd->bd_unit);
|
||||
if (edd == 0)
|
||||
bd->bd_flags |= BD_MODEINT13;
|
||||
@ -604,10 +657,6 @@ bd_int13probe(bdinfo_t *bd)
|
||||
}
|
||||
|
||||
if (ret != 0) {
|
||||
/* CD is special case, bc_add() has its own fallback. */
|
||||
if ((bd->bd_flags & BD_CDROM) != 0)
|
||||
return (true);
|
||||
|
||||
if (bd->bd_sectors != 0 && edd != 0) {
|
||||
bd->bd_sec = 63;
|
||||
bd->bd_hds = 255;
|
||||
@ -619,8 +668,6 @@ bd_int13probe(bdinfo_t *bd)
|
||||
|
||||
if ((bd->bd_flags & BD_FLOPPY) != 0)
|
||||
dv_name = biosfd.dv_name;
|
||||
else if ((bd->bd_flags & BD_CDROM) != 0)
|
||||
dv_name = bioscd.dv_name;
|
||||
else
|
||||
dv_name = bioshd.dv_name;
|
||||
|
||||
|
@ -317,30 +317,41 @@ static int
|
||||
vdev_read_pad2(vdev_t *vdev, char *buf, size_t size)
|
||||
{
|
||||
blkptr_t bp;
|
||||
char *tmp = zap_scratch;
|
||||
char *tmp;
|
||||
off_t off = offsetof(vdev_label_t, vl_pad2);
|
||||
int rc;
|
||||
|
||||
if (size > VDEV_PAD_SIZE)
|
||||
size = VDEV_PAD_SIZE;
|
||||
|
||||
tmp = malloc(VDEV_PAD_SIZE);
|
||||
if (tmp == NULL)
|
||||
return (ENOMEM);
|
||||
|
||||
BP_ZERO(&bp);
|
||||
BP_SET_LSIZE(&bp, VDEV_PAD_SIZE);
|
||||
BP_SET_PSIZE(&bp, VDEV_PAD_SIZE);
|
||||
BP_SET_CHECKSUM(&bp, ZIO_CHECKSUM_LABEL);
|
||||
BP_SET_COMPRESS(&bp, ZIO_COMPRESS_OFF);
|
||||
DVA_SET_OFFSET(BP_IDENTITY(&bp), off);
|
||||
if (vdev_read_phys(vdev, &bp, tmp, off, 0))
|
||||
return (EIO);
|
||||
memcpy(buf, tmp, size);
|
||||
return (0);
|
||||
rc = vdev_read_phys(vdev, &bp, tmp, off, 0);
|
||||
if (rc == 0)
|
||||
memcpy(buf, tmp, size);
|
||||
free(tmp);
|
||||
return (rc);
|
||||
}
|
||||
|
||||
static int
|
||||
vdev_clear_pad2(vdev_t *vdev)
|
||||
{
|
||||
char *zeroes = zap_scratch;
|
||||
char *zeroes;
|
||||
uint64_t *end;
|
||||
off_t off = offsetof(vdev_label_t, vl_pad2);
|
||||
int rc;
|
||||
|
||||
zeroes = malloc(VDEV_PAD_SIZE);
|
||||
if (zeroes == NULL)
|
||||
return (ENOMEM);
|
||||
|
||||
memset(zeroes, 0, VDEV_PAD_SIZE);
|
||||
end = (uint64_t *)(zeroes + VDEV_PAD_SIZE);
|
||||
@ -350,9 +361,9 @@ vdev_clear_pad2(vdev_t *vdev)
|
||||
end[-3] = 0xaf909f1658aacefc;
|
||||
end[-2] = 0xcbd1ea57ff6db48b;
|
||||
end[-1] = 0x6ec692db0d465fab;
|
||||
if (vdev_write(vdev, vdev->v_read_priv, off, zeroes, VDEV_PAD_SIZE))
|
||||
return (EIO);
|
||||
return (0);
|
||||
rc = vdev_write(vdev, vdev->v_read_priv, off, zeroes, VDEV_PAD_SIZE);
|
||||
free(zeroes);
|
||||
return (rc);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -62,9 +62,7 @@ struct preloaded_file;
|
||||
struct file_format;
|
||||
|
||||
/* MD code implementing MI interfaces */
|
||||
#if !defined(__sparc64__)
|
||||
vm_offset_t md_load(char *args, vm_offset_t *modulep, vm_offset_t *dtb);
|
||||
#endif
|
||||
vm_offset_t md_load64(char *args, vm_offset_t *modulep, vm_offset_t *dtb);
|
||||
|
||||
extern void reboot(void);
|
||||
|
@ -1,94 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 1992, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* This software was developed by the Computer Systems Engineering group
|
||||
* at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
|
||||
* contributed to Berkeley.
|
||||
*
|
||||
* 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.
|
||||
* 3. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
|
||||
*
|
||||
* $Header: _setjmp.s,v 1.1 91/07/06 16:45:53 torek Exp
|
||||
*/
|
||||
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
#if 0
|
||||
.asciz "@(#)_setjmp.s 8.1 (Berkeley) 6/4/93"
|
||||
#else
|
||||
RCSID("$NetBSD: _setjmp.S,v 1.4 1998/10/08 02:27:59 eeh Exp $")
|
||||
#endif
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include <machine/asm.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#define _JB_FP 0x0
|
||||
#define _JB_PC 0x8
|
||||
#define _JB_SP 0x10
|
||||
|
||||
.register %g2,#ignore
|
||||
.register %g3,#ignore
|
||||
|
||||
/*
|
||||
* C library -- setjmp, longjmp
|
||||
*
|
||||
* longjmp(a,v)
|
||||
* will generate a "return(v?v:1)" from
|
||||
* the last call to
|
||||
* setjmp(a)
|
||||
* by restoring the previous context.
|
||||
*/
|
||||
|
||||
ENTRY(_setjmp)
|
||||
stx %sp, [%o0 + _JB_SP]
|
||||
stx %o7, [%o0 + _JB_PC]
|
||||
stx %fp, [%o0 + _JB_FP]
|
||||
retl
|
||||
clr %o0
|
||||
END(_setjmp)
|
||||
|
||||
ENTRY(_longjmp)
|
||||
mov 1, %g1
|
||||
movrnz %o1, %o1, %g1
|
||||
mov %o0, %g2
|
||||
ldx [%g2 + _JB_FP], %g3
|
||||
1: cmp %fp, %g3
|
||||
bl,a 1b
|
||||
restore
|
||||
be,a 2f
|
||||
ldx [%g2 + _JB_SP], %o0
|
||||
|
||||
.Lbotch:
|
||||
illtrap
|
||||
|
||||
2: cmp %o0, %sp
|
||||
bge,a 3f
|
||||
mov %o0, %sp
|
||||
b,a .Lbotch
|
||||
nop
|
||||
3: ldx [%g2 + _JB_PC], %o7
|
||||
retl
|
||||
mov %g1, %o0
|
||||
END(_longjmp)
|
@ -138,7 +138,6 @@ static spa_list_t zfs_pools;
|
||||
static const dnode_phys_t *dnode_cache_obj;
|
||||
static uint64_t dnode_cache_bn;
|
||||
static char *dnode_cache_buf;
|
||||
static char *zap_scratch;
|
||||
static char *zfs_temp_buf, *zfs_temp_end, *zfs_temp_ptr;
|
||||
|
||||
#define TEMP_SIZE (1024 * 1024)
|
||||
@ -172,7 +171,6 @@ zfs_init(void)
|
||||
zfs_temp_end = zfs_temp_buf + TEMP_SIZE;
|
||||
zfs_temp_ptr = zfs_temp_buf;
|
||||
dnode_cache_buf = malloc(SPA_MAXBLOCKSIZE);
|
||||
zap_scratch = malloc(SPA_MAXBLOCKSIZE);
|
||||
|
||||
zfs_init_crc();
|
||||
}
|
||||
@ -2296,26 +2294,20 @@ dnode_read(const spa_t *spa, const dnode_phys_t *dnode, off_t offset,
|
||||
}
|
||||
|
||||
/*
|
||||
* Lookup a value in a microzap directory. Assumes that the zap
|
||||
* scratch buffer contains the directory contents.
|
||||
* Lookup a value in a microzap directory.
|
||||
*/
|
||||
static int
|
||||
mzap_lookup(const dnode_phys_t *dnode, const char *name, uint64_t *value)
|
||||
mzap_lookup(const mzap_phys_t *mz, size_t size, const char *name,
|
||||
uint64_t *value)
|
||||
{
|
||||
const mzap_phys_t *mz;
|
||||
const mzap_ent_phys_t *mze;
|
||||
size_t size;
|
||||
int chunks, i;
|
||||
|
||||
/*
|
||||
* Microzap objects use exactly one block. Read the whole
|
||||
* thing.
|
||||
*/
|
||||
size = dnode->dn_datablkszsec * 512;
|
||||
|
||||
mz = (const mzap_phys_t *) zap_scratch;
|
||||
chunks = size / MZAP_ENT_LEN - 1;
|
||||
|
||||
for (i = 0; i < chunks; i++) {
|
||||
mze = &mz->mz_chunk[i];
|
||||
if (strcmp(mze->mze_name, name) == 0) {
|
||||
@ -2458,89 +2450,166 @@ fzap_check_size(uint64_t integer_size, uint64_t num_integers)
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
* Lookup a value in a fatzap directory. Assumes that the zap scratch
|
||||
* buffer contains the directory header.
|
||||
*/
|
||||
static void
|
||||
zap_leaf_free(zap_leaf_t *leaf)
|
||||
{
|
||||
free(leaf->l_phys);
|
||||
free(leaf);
|
||||
}
|
||||
|
||||
static int
|
||||
fzap_lookup(const spa_t *spa, const dnode_phys_t *dnode, const char *name,
|
||||
zap_get_leaf_byblk(fat_zap_t *zap, uint64_t blk, zap_leaf_t **lp)
|
||||
{
|
||||
int bs = FZAP_BLOCK_SHIFT(zap);
|
||||
int err;
|
||||
|
||||
*lp = malloc(sizeof(**lp));
|
||||
if (*lp == NULL)
|
||||
return (ENOMEM);
|
||||
|
||||
(*lp)->l_bs = bs;
|
||||
(*lp)->l_phys = malloc(1 << bs);
|
||||
|
||||
if ((*lp)->l_phys == NULL) {
|
||||
free(*lp);
|
||||
return (ENOMEM);
|
||||
}
|
||||
err = dnode_read(zap->zap_spa, zap->zap_dnode, blk << bs, (*lp)->l_phys,
|
||||
1 << bs);
|
||||
if (err != 0) {
|
||||
zap_leaf_free(*lp);
|
||||
}
|
||||
return (err);
|
||||
}
|
||||
|
||||
static int
|
||||
zap_table_load(fat_zap_t *zap, zap_table_phys_t *tbl, uint64_t idx,
|
||||
uint64_t *valp)
|
||||
{
|
||||
int bs = FZAP_BLOCK_SHIFT(zap);
|
||||
uint64_t blk = idx >> (bs - 3);
|
||||
uint64_t off = idx & ((1 << (bs - 3)) - 1);
|
||||
uint64_t *buf;
|
||||
int rc;
|
||||
|
||||
buf = malloc(1 << zap->zap_block_shift);
|
||||
if (buf == NULL)
|
||||
return (ENOMEM);
|
||||
rc = dnode_read(zap->zap_spa, zap->zap_dnode, (tbl->zt_blk + blk) << bs,
|
||||
buf, 1 << zap->zap_block_shift);
|
||||
if (rc == 0)
|
||||
*valp = buf[off];
|
||||
free(buf);
|
||||
return (rc);
|
||||
}
|
||||
|
||||
static int
|
||||
zap_idx_to_blk(fat_zap_t *zap, uint64_t idx, uint64_t *valp)
|
||||
{
|
||||
if (zap->zap_phys->zap_ptrtbl.zt_numblks == 0) {
|
||||
*valp = ZAP_EMBEDDED_PTRTBL_ENT(zap, idx);
|
||||
return (0);
|
||||
} else {
|
||||
return (zap_table_load(zap, &zap->zap_phys->zap_ptrtbl,
|
||||
idx, valp));
|
||||
}
|
||||
}
|
||||
|
||||
#define ZAP_HASH_IDX(hash, n) (((n) == 0) ? 0 : ((hash) >> (64 - (n))))
|
||||
static int
|
||||
zap_deref_leaf(fat_zap_t *zap, uint64_t h, zap_leaf_t **lp)
|
||||
{
|
||||
uint64_t idx, blk;
|
||||
int err;
|
||||
|
||||
idx = ZAP_HASH_IDX(h, zap->zap_phys->zap_ptrtbl.zt_shift);
|
||||
err = zap_idx_to_blk(zap, idx, &blk);
|
||||
if (err != 0)
|
||||
return (err);
|
||||
return (zap_get_leaf_byblk(zap, blk, lp));
|
||||
}
|
||||
|
||||
#define CHAIN_END 0xffff /* end of the chunk chain */
|
||||
#define LEAF_HASH(l, h) \
|
||||
((ZAP_LEAF_HASH_NUMENTRIES(l)-1) & \
|
||||
((h) >> \
|
||||
(64 - ZAP_LEAF_HASH_SHIFT(l) - (l)->l_phys->l_hdr.lh_prefix_len)))
|
||||
#define LEAF_HASH_ENTPTR(l, h) (&(l)->l_phys->l_hash[LEAF_HASH(l, h)])
|
||||
|
||||
static int
|
||||
zap_leaf_lookup(zap_leaf_t *zl, uint64_t hash, const char *name,
|
||||
uint64_t integer_size, uint64_t num_integers, void *value)
|
||||
{
|
||||
int rc;
|
||||
uint16_t *chunkp;
|
||||
struct zap_leaf_entry *le;
|
||||
|
||||
/*
|
||||
* Make sure this chunk matches our hash.
|
||||
*/
|
||||
if (zl->l_phys->l_hdr.lh_prefix_len > 0 &&
|
||||
zl->l_phys->l_hdr.lh_prefix !=
|
||||
hash >> (64 - zl->l_phys->l_hdr.lh_prefix_len))
|
||||
return (EIO);
|
||||
|
||||
rc = ENOENT;
|
||||
for (chunkp = LEAF_HASH_ENTPTR(zl, hash);
|
||||
*chunkp != CHAIN_END; chunkp = &le->le_next) {
|
||||
zap_leaf_chunk_t *zc;
|
||||
uint16_t chunk = *chunkp;
|
||||
|
||||
le = ZAP_LEAF_ENTRY(zl, chunk);
|
||||
if (le->le_hash != hash)
|
||||
continue;
|
||||
zc = &ZAP_LEAF_CHUNK(zl, chunk);
|
||||
if (fzap_name_equal(zl, zc, name)) {
|
||||
if (zc->l_entry.le_value_intlen > integer_size) {
|
||||
rc = EINVAL;
|
||||
} else {
|
||||
fzap_leaf_array(zl, zc, integer_size,
|
||||
num_integers, value);
|
||||
rc = 0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
return (rc);
|
||||
}
|
||||
|
||||
/*
|
||||
* Lookup a value in a fatzap directory.
|
||||
*/
|
||||
static int
|
||||
fzap_lookup(const spa_t *spa, const dnode_phys_t *dnode, zap_phys_t *zh,
|
||||
const char *name, uint64_t integer_size, uint64_t num_integers,
|
||||
void *value)
|
||||
{
|
||||
int bsize = dnode->dn_datablkszsec << SPA_MINBLOCKSHIFT;
|
||||
zap_phys_t zh = *(zap_phys_t *)zap_scratch;
|
||||
fat_zap_t z;
|
||||
uint64_t *ptrtbl;
|
||||
zap_leaf_t *zl;
|
||||
uint64_t hash;
|
||||
int rc;
|
||||
|
||||
if (zh.zap_magic != ZAP_MAGIC)
|
||||
if (zh->zap_magic != ZAP_MAGIC)
|
||||
return (EIO);
|
||||
|
||||
if ((rc = fzap_check_size(integer_size, num_integers)) != 0)
|
||||
return (rc);
|
||||
|
||||
z.zap_block_shift = ilog2(bsize);
|
||||
z.zap_phys = (zap_phys_t *)zap_scratch;
|
||||
z.zap_phys = zh;
|
||||
z.zap_spa = spa;
|
||||
z.zap_dnode = dnode;
|
||||
|
||||
/*
|
||||
* Figure out where the pointer table is and read it in if necessary.
|
||||
*/
|
||||
if (zh.zap_ptrtbl.zt_blk) {
|
||||
rc = dnode_read(spa, dnode, zh.zap_ptrtbl.zt_blk * bsize,
|
||||
zap_scratch, bsize);
|
||||
if (rc)
|
||||
return (rc);
|
||||
ptrtbl = (uint64_t *)zap_scratch;
|
||||
} else {
|
||||
ptrtbl = &ZAP_EMBEDDED_PTRTBL_ENT(&z, 0);
|
||||
}
|
||||
|
||||
hash = zap_hash(zh.zap_salt, name);
|
||||
|
||||
zap_leaf_t zl;
|
||||
zl.l_bs = z.zap_block_shift;
|
||||
|
||||
off_t off = ptrtbl[hash >> (64 - zh.zap_ptrtbl.zt_shift)] << zl.l_bs;
|
||||
zap_leaf_chunk_t *zc;
|
||||
|
||||
rc = dnode_read(spa, dnode, off, zap_scratch, bsize);
|
||||
if (rc)
|
||||
hash = zap_hash(zh->zap_salt, name);
|
||||
rc = zap_deref_leaf(&z, hash, &zl);
|
||||
if (rc != 0)
|
||||
return (rc);
|
||||
|
||||
zl.l_phys = (zap_leaf_phys_t *)zap_scratch;
|
||||
rc = zap_leaf_lookup(zl, hash, name, integer_size, num_integers, value);
|
||||
|
||||
/*
|
||||
* Make sure this chunk matches our hash.
|
||||
*/
|
||||
if (zl.l_phys->l_hdr.lh_prefix_len > 0 &&
|
||||
zl.l_phys->l_hdr.lh_prefix !=
|
||||
hash >> (64 - zl.l_phys->l_hdr.lh_prefix_len))
|
||||
return (ENOENT);
|
||||
|
||||
/*
|
||||
* Hash within the chunk to find our entry.
|
||||
*/
|
||||
int shift = (64 - ZAP_LEAF_HASH_SHIFT(&zl) -
|
||||
zl.l_phys->l_hdr.lh_prefix_len);
|
||||
int h = (hash >> shift) & ((1 << ZAP_LEAF_HASH_SHIFT(&zl)) - 1);
|
||||
h = zl.l_phys->l_hash[h];
|
||||
if (h == 0xffff)
|
||||
return (ENOENT);
|
||||
zc = &ZAP_LEAF_CHUNK(&zl, h);
|
||||
while (zc->l_entry.le_hash != hash) {
|
||||
if (zc->l_entry.le_next == 0xffff)
|
||||
return (ENOENT);
|
||||
zc = &ZAP_LEAF_CHUNK(&zl, zc->l_entry.le_next);
|
||||
}
|
||||
if (fzap_name_equal(&zl, zc, name)) {
|
||||
if (zc->l_entry.le_value_intlen * zc->l_entry.le_value_numints >
|
||||
integer_size * num_integers)
|
||||
return (E2BIG);
|
||||
fzap_leaf_array(&zl, zc, integer_size, num_integers, value);
|
||||
return (0);
|
||||
}
|
||||
|
||||
return (ENOENT);
|
||||
zap_leaf_free(zl);
|
||||
return (rc);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -2551,74 +2620,80 @@ zap_lookup(const spa_t *spa, const dnode_phys_t *dnode, const char *name,
|
||||
uint64_t integer_size, uint64_t num_integers, void *value)
|
||||
{
|
||||
int rc;
|
||||
uint64_t zap_type;
|
||||
zap_phys_t *zap;
|
||||
size_t size = dnode->dn_datablkszsec << SPA_MINBLOCKSHIFT;
|
||||
|
||||
rc = dnode_read(spa, dnode, 0, zap_scratch, size);
|
||||
if (rc)
|
||||
return (rc);
|
||||
zap = malloc(size);
|
||||
if (zap == NULL)
|
||||
return (ENOMEM);
|
||||
|
||||
zap_type = *(uint64_t *)zap_scratch;
|
||||
if (zap_type == ZBT_MICRO)
|
||||
return (mzap_lookup(dnode, name, value));
|
||||
else if (zap_type == ZBT_HEADER) {
|
||||
return (fzap_lookup(spa, dnode, name, integer_size,
|
||||
num_integers, value));
|
||||
rc = dnode_read(spa, dnode, 0, zap, size);
|
||||
if (rc)
|
||||
goto done;
|
||||
|
||||
switch (zap->zap_block_type) {
|
||||
case ZBT_MICRO:
|
||||
rc = mzap_lookup((const mzap_phys_t *)zap, size, name, value);
|
||||
break;
|
||||
case ZBT_HEADER:
|
||||
rc = fzap_lookup(spa, dnode, zap, name, integer_size,
|
||||
num_integers, value);
|
||||
break;
|
||||
default:
|
||||
printf("ZFS: invalid zap_type=%" PRIx64 "\n",
|
||||
zap->zap_block_type);
|
||||
rc = EIO;
|
||||
}
|
||||
printf("ZFS: invalid zap_type=%d\n", (int)zap_type);
|
||||
return (EIO);
|
||||
done:
|
||||
free(zap);
|
||||
return (rc);
|
||||
}
|
||||
|
||||
/*
|
||||
* List a microzap directory. Assumes that the zap scratch buffer contains
|
||||
* the directory contents.
|
||||
* List a microzap directory.
|
||||
*/
|
||||
static int
|
||||
mzap_list(const dnode_phys_t *dnode, int (*callback)(const char *, uint64_t))
|
||||
mzap_list(const mzap_phys_t *mz, size_t size,
|
||||
int (*callback)(const char *, uint64_t))
|
||||
{
|
||||
const mzap_phys_t *mz;
|
||||
const mzap_ent_phys_t *mze;
|
||||
size_t size;
|
||||
int chunks, i, rc;
|
||||
|
||||
/*
|
||||
* Microzap objects use exactly one block. Read the whole
|
||||
* thing.
|
||||
*/
|
||||
size = dnode->dn_datablkszsec * 512;
|
||||
mz = (const mzap_phys_t *) zap_scratch;
|
||||
rc = 0;
|
||||
chunks = size / MZAP_ENT_LEN - 1;
|
||||
|
||||
for (i = 0; i < chunks; i++) {
|
||||
mze = &mz->mz_chunk[i];
|
||||
if (mze->mze_name[0]) {
|
||||
rc = callback(mze->mze_name, mze->mze_value);
|
||||
if (rc != 0)
|
||||
return (rc);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return (0);
|
||||
return (rc);
|
||||
}
|
||||
|
||||
/*
|
||||
* List a fatzap directory. Assumes that the zap scratch buffer contains
|
||||
* the directory header.
|
||||
* List a fatzap directory.
|
||||
*/
|
||||
static int
|
||||
fzap_list(const spa_t *spa, const dnode_phys_t *dnode,
|
||||
fzap_list(const spa_t *spa, const dnode_phys_t *dnode, zap_phys_t *zh,
|
||||
int (*callback)(const char *, uint64_t))
|
||||
{
|
||||
int bsize = dnode->dn_datablkszsec << SPA_MINBLOCKSHIFT;
|
||||
zap_phys_t zh = *(zap_phys_t *)zap_scratch;
|
||||
fat_zap_t z;
|
||||
int i, j, rc;
|
||||
uint64_t i;
|
||||
int j, rc;
|
||||
|
||||
if (zh.zap_magic != ZAP_MAGIC)
|
||||
if (zh->zap_magic != ZAP_MAGIC)
|
||||
return (EIO);
|
||||
|
||||
z.zap_block_shift = ilog2(bsize);
|
||||
z.zap_phys = (zap_phys_t *)zap_scratch;
|
||||
z.zap_phys = zh;
|
||||
|
||||
/*
|
||||
* This assumes that the leaf blocks start at block 1. The
|
||||
@ -2626,15 +2701,19 @@ fzap_list(const spa_t *spa, const dnode_phys_t *dnode,
|
||||
*/
|
||||
zap_leaf_t zl;
|
||||
zl.l_bs = z.zap_block_shift;
|
||||
for (i = 0; i < zh.zap_num_leafs; i++) {
|
||||
zl.l_phys = malloc(bsize);
|
||||
if (zl.l_phys == NULL)
|
||||
return (ENOMEM);
|
||||
|
||||
for (i = 0; i < zh->zap_num_leafs; i++) {
|
||||
off_t off = ((off_t)(i + 1)) << zl.l_bs;
|
||||
char name[256], *p;
|
||||
uint64_t value;
|
||||
|
||||
if (dnode_read(spa, dnode, off, zap_scratch, bsize))
|
||||
if (dnode_read(spa, dnode, off, zl.l_phys, bsize)) {
|
||||
free(zl.l_phys);
|
||||
return (EIO);
|
||||
|
||||
zl.l_phys = (zap_leaf_phys_t *)zap_scratch;
|
||||
}
|
||||
|
||||
for (j = 0; j < ZAP_LEAF_NUMCHUNKS(&zl); j++) {
|
||||
zap_leaf_chunk_t *zc, *nc;
|
||||
@ -2671,11 +2750,14 @@ fzap_list(const spa_t *spa, const dnode_phys_t *dnode,
|
||||
|
||||
/* printf("%s 0x%jx\n", name, (uintmax_t)value); */
|
||||
rc = callback((const char *)name, value);
|
||||
if (rc != 0)
|
||||
if (rc != 0) {
|
||||
free(zl.l_phys);
|
||||
return (rc);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
free(zl.l_phys);
|
||||
return (0);
|
||||
}
|
||||
|
||||
@ -2693,17 +2775,24 @@ static int zfs_printf(const char *name, uint64_t value __unused)
|
||||
static int
|
||||
zap_list(const spa_t *spa, const dnode_phys_t *dnode)
|
||||
{
|
||||
uint64_t zap_type;
|
||||
size_t size = dnode->dn_datablkszsec * 512;
|
||||
zap_phys_t *zap;
|
||||
size_t size = dnode->dn_datablkszsec << SPA_MINBLOCKSHIFT;
|
||||
int rc;
|
||||
|
||||
if (dnode_read(spa, dnode, 0, zap_scratch, size))
|
||||
return (EIO);
|
||||
zap = malloc(size);
|
||||
if (zap == NULL)
|
||||
return (ENOMEM);
|
||||
|
||||
zap_type = *(uint64_t *)zap_scratch;
|
||||
if (zap_type == ZBT_MICRO)
|
||||
return (mzap_list(dnode, zfs_printf));
|
||||
else
|
||||
return (fzap_list(spa, dnode, zfs_printf));
|
||||
rc = dnode_read(spa, dnode, 0, zap, size);
|
||||
if (rc == 0) {
|
||||
if (zap->zap_block_type == ZBT_MICRO)
|
||||
rc = mzap_list((const mzap_phys_t *)zap, size,
|
||||
zfs_printf);
|
||||
else
|
||||
rc = fzap_list(spa, dnode, zap, zfs_printf);
|
||||
}
|
||||
free(zap);
|
||||
return (rc);
|
||||
}
|
||||
|
||||
static int
|
||||
@ -2717,24 +2806,20 @@ objset_get_dnode(const spa_t *spa, const objset_phys_t *os, uint64_t objnum,
|
||||
dnode, sizeof(dnode_phys_t));
|
||||
}
|
||||
|
||||
/*
|
||||
* Lookup a name in a microzap directory.
|
||||
*/
|
||||
static int
|
||||
mzap_rlookup(const spa_t *spa, const dnode_phys_t *dnode, char *name,
|
||||
uint64_t value)
|
||||
mzap_rlookup(const mzap_phys_t *mz, size_t size, char *name, uint64_t value)
|
||||
{
|
||||
const mzap_phys_t *mz;
|
||||
const mzap_ent_phys_t *mze;
|
||||
size_t size;
|
||||
int chunks, i;
|
||||
|
||||
/*
|
||||
* Microzap objects use exactly one block. Read the whole
|
||||
* thing.
|
||||
*/
|
||||
size = dnode->dn_datablkszsec * 512;
|
||||
|
||||
mz = (const mzap_phys_t *)zap_scratch;
|
||||
chunks = size / MZAP_ENT_LEN - 1;
|
||||
|
||||
for (i = 0; i < chunks; i++) {
|
||||
mze = &mz->mz_chunk[i];
|
||||
if (value == mze->mze_value) {
|
||||
@ -2772,19 +2857,19 @@ fzap_name_copy(const zap_leaf_t *zl, const zap_leaf_chunk_t *zc, char *name)
|
||||
}
|
||||
|
||||
static int
|
||||
fzap_rlookup(const spa_t *spa, const dnode_phys_t *dnode, char *name,
|
||||
uint64_t value)
|
||||
fzap_rlookup(const spa_t *spa, const dnode_phys_t *dnode, zap_phys_t *zh,
|
||||
char *name, uint64_t value)
|
||||
{
|
||||
int bsize = dnode->dn_datablkszsec << SPA_MINBLOCKSHIFT;
|
||||
zap_phys_t zh = *(zap_phys_t *)zap_scratch;
|
||||
fat_zap_t z;
|
||||
int i, j;
|
||||
uint64_t i;
|
||||
int j, rc;
|
||||
|
||||
if (zh.zap_magic != ZAP_MAGIC)
|
||||
if (zh->zap_magic != ZAP_MAGIC)
|
||||
return (EIO);
|
||||
|
||||
z.zap_block_shift = ilog2(bsize);
|
||||
z.zap_phys = (zap_phys_t *)zap_scratch;
|
||||
z.zap_phys = zh;
|
||||
|
||||
/*
|
||||
* This assumes that the leaf blocks start at block 1. The
|
||||
@ -2792,13 +2877,16 @@ fzap_rlookup(const spa_t *spa, const dnode_phys_t *dnode, char *name,
|
||||
*/
|
||||
zap_leaf_t zl;
|
||||
zl.l_bs = z.zap_block_shift;
|
||||
for (i = 0; i < zh.zap_num_leafs; i++) {
|
||||
zl.l_phys = malloc(bsize);
|
||||
if (zl.l_phys == NULL)
|
||||
return (ENOMEM);
|
||||
|
||||
for (i = 0; i < zh->zap_num_leafs; i++) {
|
||||
off_t off = ((off_t)(i + 1)) << zl.l_bs;
|
||||
|
||||
if (dnode_read(spa, dnode, off, zap_scratch, bsize))
|
||||
return (EIO);
|
||||
|
||||
zl.l_phys = (zap_leaf_phys_t *)zap_scratch;
|
||||
rc = dnode_read(spa, dnode, off, zl.l_phys, bsize);
|
||||
if (rc != 0)
|
||||
goto done;
|
||||
|
||||
for (j = 0; j < ZAP_LEAF_NUMCHUNKS(&zl); j++) {
|
||||
zap_leaf_chunk_t *zc;
|
||||
@ -2812,31 +2900,39 @@ fzap_rlookup(const spa_t *spa, const dnode_phys_t *dnode, char *name,
|
||||
|
||||
if (fzap_leaf_value(&zl, zc) == value) {
|
||||
fzap_name_copy(&zl, zc, name);
|
||||
return (0);
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return (ENOENT);
|
||||
rc = ENOENT;
|
||||
done:
|
||||
free(zl.l_phys);
|
||||
return (rc);
|
||||
}
|
||||
|
||||
static int
|
||||
zap_rlookup(const spa_t *spa, const dnode_phys_t *dnode, char *name,
|
||||
uint64_t value)
|
||||
{
|
||||
zap_phys_t *zap;
|
||||
size_t size = dnode->dn_datablkszsec << SPA_MINBLOCKSHIFT;
|
||||
int rc;
|
||||
uint64_t zap_type;
|
||||
size_t size = dnode->dn_datablkszsec * 512;
|
||||
|
||||
rc = dnode_read(spa, dnode, 0, zap_scratch, size);
|
||||
if (rc)
|
||||
return (rc);
|
||||
zap = malloc(size);
|
||||
if (zap == NULL)
|
||||
return (ENOMEM);
|
||||
|
||||
zap_type = *(uint64_t *)zap_scratch;
|
||||
if (zap_type == ZBT_MICRO)
|
||||
return (mzap_rlookup(spa, dnode, name, value));
|
||||
else
|
||||
return (fzap_rlookup(spa, dnode, name, value));
|
||||
rc = dnode_read(spa, dnode, 0, zap, size);
|
||||
if (rc == 0) {
|
||||
if (zap->zap_block_type == ZBT_MICRO)
|
||||
rc = mzap_rlookup((const mzap_phys_t *)zap, size,
|
||||
name, value);
|
||||
else
|
||||
rc = fzap_rlookup(spa, dnode, zap, name, value);
|
||||
}
|
||||
free(zap);
|
||||
return (rc);
|
||||
}
|
||||
|
||||
static int
|
||||
@ -2988,10 +3084,12 @@ int
|
||||
zfs_callback_dataset(const spa_t *spa, uint64_t objnum,
|
||||
int (*callback)(const char *, uint64_t))
|
||||
{
|
||||
uint64_t dir_obj, child_dir_zapobj, zap_type;
|
||||
uint64_t dir_obj, child_dir_zapobj;
|
||||
dnode_phys_t child_dir_zap, dir, dataset;
|
||||
dsl_dataset_phys_t *ds;
|
||||
dsl_dir_phys_t *dd;
|
||||
zap_phys_t *zap;
|
||||
size_t size;
|
||||
int err;
|
||||
|
||||
err = objset_get_dnode(spa, &spa->spa_mos, objnum, &dataset);
|
||||
@ -3017,16 +3115,24 @@ zfs_callback_dataset(const spa_t *spa, uint64_t objnum,
|
||||
return (err);
|
||||
}
|
||||
|
||||
err = dnode_read(spa, &child_dir_zap, 0, zap_scratch,
|
||||
child_dir_zap.dn_datablkszsec * 512);
|
||||
if (err != 0)
|
||||
return (err);
|
||||
size = child_dir_zap.dn_datablkszsec << SPA_MINBLOCKSHIFT;
|
||||
zap = malloc(size);
|
||||
if (zap != NULL) {
|
||||
err = dnode_read(spa, &child_dir_zap, 0, zap, size);
|
||||
if (err != 0)
|
||||
goto done;
|
||||
|
||||
zap_type = *(uint64_t *)zap_scratch;
|
||||
if (zap_type == ZBT_MICRO)
|
||||
return (mzap_list(&child_dir_zap, callback));
|
||||
else
|
||||
return (fzap_list(spa, &child_dir_zap, callback));
|
||||
if (zap->zap_block_type == ZBT_MICRO)
|
||||
err = mzap_list((const mzap_phys_t *)zap, size,
|
||||
callback);
|
||||
else
|
||||
err = fzap_list(spa, &child_dir_zap, zap, callback);
|
||||
} else {
|
||||
err = ENOMEM;
|
||||
}
|
||||
done:
|
||||
free(zap);
|
||||
return (err);
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -3158,7 +3264,8 @@ static int
|
||||
check_mos_features(const spa_t *spa)
|
||||
{
|
||||
dnode_phys_t dir;
|
||||
uint64_t objnum, zap_type;
|
||||
zap_phys_t *zap;
|
||||
uint64_t objnum;
|
||||
size_t size;
|
||||
int rc;
|
||||
|
||||
@ -3180,16 +3287,22 @@ check_mos_features(const spa_t *spa)
|
||||
if (dir.dn_type != DMU_OTN_ZAP_METADATA)
|
||||
return (EIO);
|
||||
|
||||
size = dir.dn_datablkszsec * 512;
|
||||
if (dnode_read(spa, &dir, 0, zap_scratch, size))
|
||||
size = dir.dn_datablkszsec << SPA_MINBLOCKSHIFT;
|
||||
zap = malloc(size);
|
||||
if (zap == NULL)
|
||||
return (ENOMEM);
|
||||
|
||||
if (dnode_read(spa, &dir, 0, zap, size)) {
|
||||
free(zap);
|
||||
return (EIO);
|
||||
}
|
||||
|
||||
zap_type = *(uint64_t *)zap_scratch;
|
||||
if (zap_type == ZBT_MICRO)
|
||||
rc = mzap_list(&dir, check_feature);
|
||||
if (zap->zap_block_type == ZBT_MICRO)
|
||||
rc = mzap_list((const mzap_phys_t *)zap, size, check_feature);
|
||||
else
|
||||
rc = fzap_list(spa, &dir, check_feature);
|
||||
rc = fzap_list(spa, &dir, zap, check_feature);
|
||||
|
||||
free(zap);
|
||||
return (rc);
|
||||
}
|
||||
|
||||
|
@ -19,9 +19,6 @@ SRCS+= load_elf32.c reloc_elf32.c
|
||||
SRCS+= load_elf32.c reloc_elf32.c
|
||||
SRCS+= load_elf64.c reloc_elf64.c
|
||||
SRCS+= metadata.c
|
||||
.elif ${MACHINE_CPUARCH} == "sparc64"
|
||||
SRCS+= load_elf64.c reloc_elf64.c
|
||||
SRCS+= metadata.c
|
||||
.elif ${MACHINE_ARCH:Mmips64*} != ""
|
||||
SRCS+= load_elf64.c reloc_elf64.c
|
||||
SRCS+= metadata.c
|
||||
|
@ -632,7 +632,7 @@ Modifies kernel option
|
||||
Limits the amount of KVM reserved for use by the
|
||||
buffer cache, specified in bytes.
|
||||
The default maximum is 200MB on i386,
|
||||
and 400MB on amd64 and sparc64.
|
||||
and 400MB on amd64.
|
||||
This parameter is used to
|
||||
prevent the buffer cache from eating too much
|
||||
KVM in large-memory machine configurations.
|
||||
|
@ -1,10 +0,0 @@
|
||||
# $FreeBSD$
|
||||
|
||||
NO_OBJ=t
|
||||
|
||||
.include <bsd.init.mk>
|
||||
|
||||
SUBDIR.yes= boot1 loader
|
||||
SUBDIR.${MK_LOADER_ZFS}+=zfsboot
|
||||
|
||||
.include <bsd.subdir.mk>
|
@ -1,5 +0,0 @@
|
||||
# $FreeBSD$
|
||||
|
||||
LDFLAGS+= -nostdlib
|
||||
|
||||
.include "../Makefile.inc"
|
@ -1,29 +0,0 @@
|
||||
# $FreeBSD$
|
||||
|
||||
.include <bsd.init.mk>
|
||||
|
||||
PROG= boot1.elf
|
||||
INTERNALPROG=
|
||||
FILES?= boot1
|
||||
SRCS= _start.s boot1.c
|
||||
CLEANFILES+=${FILES} boot1.aout
|
||||
|
||||
BOOTBLOCKBASE= 0x4000
|
||||
|
||||
CFLAGS.clang+=-mcmodel=small
|
||||
CFLAGS.gcc+=-mcmodel=medlow
|
||||
CFLAGS+=-Os -I${LDRSRC}
|
||||
LDFLAGS+=-Ttext ${BOOTBLOCKBASE} -Wl,-N
|
||||
|
||||
# Construct boot1. sunlabel expects it to contain zeroed-out space for the
|
||||
# label, and to be of the correct size.
|
||||
${FILES}: boot1.aout
|
||||
@set -- `ls -l ${.ALLSRC}`; x=$$((7680-$$5)); \
|
||||
echo "$$x bytes available"; test $$x -ge 0
|
||||
${DD} if=/dev/zero of=${.TARGET} bs=512 count=16
|
||||
${DD} if=${.ALLSRC} of=${.TARGET} bs=512 oseek=1 conv=notrunc
|
||||
|
||||
boot1.aout: boot1.elf
|
||||
elf2aout -o ${.TARGET} ${.ALLSRC}
|
||||
|
||||
.include <bsd.prog.mk>
|
@ -1,8 +0,0 @@
|
||||
/* $FreeBSD$ */
|
||||
|
||||
.text
|
||||
.globl _start
|
||||
_start:
|
||||
call ofw_init
|
||||
nop
|
||||
sir
|
@ -1,751 +0,0 @@
|
||||
/*-
|
||||
* Copyright (c) 1998 Robert Nordier
|
||||
* All rights reserved.
|
||||
* Copyright (c) 2001 Robert Drehmel
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms are freely
|
||||
* permitted provided that the above copyright notice and this
|
||||
* paragraph and the following disclaimer are duplicated in all
|
||||
* such forms.
|
||||
*
|
||||
* This software is provided "AS IS" and without any express or
|
||||
* implied warranties, including, without limitation, the implied
|
||||
* warranties of merchantability and fitness for a particular
|
||||
* purpose.
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/dirent.h>
|
||||
|
||||
#include <machine/elf.h>
|
||||
#include <machine/stdarg.h>
|
||||
|
||||
#include "paths.h"
|
||||
|
||||
#define READ_BUF_SIZE 8192
|
||||
|
||||
typedef int putc_func_t(char c, void *arg);
|
||||
typedef int32_t ofwh_t;
|
||||
|
||||
struct sp_data {
|
||||
char *sp_buf;
|
||||
u_int sp_len;
|
||||
u_int sp_size;
|
||||
};
|
||||
|
||||
static const char digits[] = "0123456789abcdef";
|
||||
|
||||
static char bootpath[128];
|
||||
static char bootargs[128];
|
||||
|
||||
static ofwh_t bootdev;
|
||||
|
||||
static uint32_t fs_off;
|
||||
|
||||
int main(int ac, char **av);
|
||||
static void exit(int) __dead2;
|
||||
static void usage(void);
|
||||
|
||||
#ifdef ZFSBOOT
|
||||
static void loadzfs(void);
|
||||
static int zbread(char *buf, off_t off, size_t bytes);
|
||||
#else
|
||||
static void load(const char *);
|
||||
#endif
|
||||
|
||||
static void bcopy(const void *src, void *dst, size_t len);
|
||||
static void bzero(void *b, size_t len);
|
||||
|
||||
static int domount(const char *device);
|
||||
static int dskread(void *buf, uint64_t lba, int nblk);
|
||||
|
||||
static void panic(const char *fmt, ...) __dead2;
|
||||
static int printf(const char *fmt, ...);
|
||||
static int putchar(char c, void *arg);
|
||||
static int vprintf(const char *fmt, va_list ap);
|
||||
static int vsnprintf(char *str, size_t sz, const char *fmt, va_list ap);
|
||||
|
||||
static int __printf(const char *fmt, putc_func_t *putc, void *arg, va_list ap);
|
||||
static int __puts(const char *s, putc_func_t *putc, void *arg);
|
||||
static int __sputc(char c, void *arg);
|
||||
static char *__uitoa(char *buf, u_int val, int base);
|
||||
static char *__ultoa(char *buf, u_long val, int base);
|
||||
|
||||
/*
|
||||
* Open Firmware interface functions
|
||||
*/
|
||||
typedef uint64_t ofwcell_t;
|
||||
typedef uint32_t u_ofwh_t;
|
||||
typedef int (*ofwfp_t)(ofwcell_t []);
|
||||
static ofwfp_t ofw; /* the PROM Open Firmware entry */
|
||||
|
||||
void ofw_init(int, int, int, int, ofwfp_t);
|
||||
static ofwh_t ofw_finddevice(const char *);
|
||||
static ofwh_t ofw_open(const char *);
|
||||
static int ofw_getprop(ofwh_t, const char *, void *, size_t);
|
||||
static int ofw_read(ofwh_t, void *, size_t);
|
||||
static int ofw_write(ofwh_t, const void *, size_t);
|
||||
static int ofw_seek(ofwh_t, uint64_t);
|
||||
static void ofw_exit(void) __dead2;
|
||||
|
||||
static ofwh_t stdinh, stdouth;
|
||||
|
||||
/*
|
||||
* This has to stay here, as the PROM seems to ignore the
|
||||
* entry point specified in the a.out header. (or elftoaout is broken)
|
||||
*/
|
||||
|
||||
void
|
||||
ofw_init(int d, int d1, int d2, int d3, ofwfp_t ofwaddr)
|
||||
{
|
||||
ofwh_t chosenh;
|
||||
char *av[16];
|
||||
char *p;
|
||||
int ac;
|
||||
|
||||
ofw = ofwaddr;
|
||||
|
||||
chosenh = ofw_finddevice("/chosen");
|
||||
ofw_getprop(chosenh, "stdin", &stdinh, sizeof(stdinh));
|
||||
ofw_getprop(chosenh, "stdout", &stdouth, sizeof(stdouth));
|
||||
ofw_getprop(chosenh, "bootargs", bootargs, sizeof(bootargs));
|
||||
ofw_getprop(chosenh, "bootpath", bootpath, sizeof(bootpath));
|
||||
|
||||
bootargs[sizeof(bootargs) - 1] = '\0';
|
||||
bootpath[sizeof(bootpath) - 1] = '\0';
|
||||
|
||||
ac = 0;
|
||||
p = bootargs;
|
||||
for (;;) {
|
||||
while (*p == ' ' && *p != '\0')
|
||||
p++;
|
||||
if (*p == '\0' || ac >= 16)
|
||||
break;
|
||||
av[ac++] = p;
|
||||
while (*p != ' ' && *p != '\0')
|
||||
p++;
|
||||
if (*p != '\0')
|
||||
*p++ = '\0';
|
||||
}
|
||||
|
||||
exit(main(ac, av));
|
||||
}
|
||||
|
||||
static ofwh_t
|
||||
ofw_finddevice(const char *name)
|
||||
{
|
||||
ofwcell_t args[] = {
|
||||
(ofwcell_t)"finddevice",
|
||||
1,
|
||||
1,
|
||||
(ofwcell_t)name,
|
||||
0
|
||||
};
|
||||
|
||||
if ((*ofw)(args)) {
|
||||
printf("ofw_finddevice: name=\"%s\"\n", name);
|
||||
return (1);
|
||||
}
|
||||
return (args[4]);
|
||||
}
|
||||
|
||||
static int
|
||||
ofw_getprop(ofwh_t ofwh, const char *name, void *buf, size_t len)
|
||||
{
|
||||
ofwcell_t args[] = {
|
||||
(ofwcell_t)"getprop",
|
||||
4,
|
||||
1,
|
||||
(u_ofwh_t)ofwh,
|
||||
(ofwcell_t)name,
|
||||
(ofwcell_t)buf,
|
||||
len,
|
||||
0
|
||||
};
|
||||
|
||||
if ((*ofw)(args)) {
|
||||
printf("ofw_getprop: ofwh=0x%x buf=%p len=%u\n",
|
||||
ofwh, buf, len);
|
||||
return (1);
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
static ofwh_t
|
||||
ofw_open(const char *path)
|
||||
{
|
||||
ofwcell_t args[] = {
|
||||
(ofwcell_t)"open",
|
||||
1,
|
||||
1,
|
||||
(ofwcell_t)path,
|
||||
0
|
||||
};
|
||||
|
||||
if ((*ofw)(args)) {
|
||||
printf("ofw_open: path=\"%s\"\n", path);
|
||||
return (-1);
|
||||
}
|
||||
return (args[4]);
|
||||
}
|
||||
|
||||
static int
|
||||
ofw_close(ofwh_t devh)
|
||||
{
|
||||
ofwcell_t args[] = {
|
||||
(ofwcell_t)"close",
|
||||
1,
|
||||
0,
|
||||
(u_ofwh_t)devh
|
||||
};
|
||||
|
||||
if ((*ofw)(args)) {
|
||||
printf("ofw_close: devh=0x%x\n", devh);
|
||||
return (1);
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
static int
|
||||
ofw_read(ofwh_t devh, void *buf, size_t len)
|
||||
{
|
||||
ofwcell_t args[] = {
|
||||
(ofwcell_t)"read",
|
||||
3,
|
||||
1,
|
||||
(u_ofwh_t)devh,
|
||||
(ofwcell_t)buf,
|
||||
len,
|
||||
0
|
||||
};
|
||||
|
||||
if ((*ofw)(args)) {
|
||||
printf("ofw_read: devh=0x%x buf=%p len=%u\n", devh, buf, len);
|
||||
return (1);
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
static int
|
||||
ofw_write(ofwh_t devh, const void *buf, size_t len)
|
||||
{
|
||||
ofwcell_t args[] = {
|
||||
(ofwcell_t)"write",
|
||||
3,
|
||||
1,
|
||||
(u_ofwh_t)devh,
|
||||
(ofwcell_t)buf,
|
||||
len,
|
||||
0
|
||||
};
|
||||
|
||||
if ((*ofw)(args)) {
|
||||
printf("ofw_write: devh=0x%x buf=%p len=%u\n", devh, buf, len);
|
||||
return (1);
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
static int
|
||||
ofw_seek(ofwh_t devh, uint64_t off)
|
||||
{
|
||||
ofwcell_t args[] = {
|
||||
(ofwcell_t)"seek",
|
||||
3,
|
||||
1,
|
||||
(u_ofwh_t)devh,
|
||||
off >> 32,
|
||||
off,
|
||||
0
|
||||
};
|
||||
|
||||
if ((*ofw)(args)) {
|
||||
printf("ofw_seek: devh=0x%x off=0x%lx\n", devh, off);
|
||||
return (1);
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
static void
|
||||
ofw_exit(void)
|
||||
{
|
||||
ofwcell_t args[3];
|
||||
|
||||
args[0] = (ofwcell_t)"exit";
|
||||
args[1] = 0;
|
||||
args[2] = 0;
|
||||
|
||||
for (;;)
|
||||
(*ofw)(args);
|
||||
}
|
||||
|
||||
static void
|
||||
bcopy(const void *src, void *dst, size_t len)
|
||||
{
|
||||
const char *s = src;
|
||||
char *d = dst;
|
||||
|
||||
while (len-- != 0)
|
||||
*d++ = *s++;
|
||||
}
|
||||
|
||||
static void
|
||||
memcpy(void *dst, const void *src, size_t len)
|
||||
{
|
||||
|
||||
bcopy(src, dst, len);
|
||||
}
|
||||
|
||||
static void
|
||||
bzero(void *b, size_t len)
|
||||
{
|
||||
char *p = b;
|
||||
|
||||
while (len-- != 0)
|
||||
*p++ = 0;
|
||||
}
|
||||
|
||||
static int
|
||||
strcmp(const char *s1, const char *s2)
|
||||
{
|
||||
|
||||
for (; *s1 == *s2 && *s1; s1++, s2++)
|
||||
;
|
||||
return ((u_char)*s1 - (u_char)*s2);
|
||||
}
|
||||
|
||||
int
|
||||
main(int ac, char **av)
|
||||
{
|
||||
const char *path;
|
||||
int i;
|
||||
|
||||
path = PATH_LOADER;
|
||||
for (i = 0; i < ac; i++) {
|
||||
switch (av[i][0]) {
|
||||
case '-':
|
||||
switch (av[i][1]) {
|
||||
default:
|
||||
usage();
|
||||
}
|
||||
break;
|
||||
default:
|
||||
path = av[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef ZFSBOOT
|
||||
printf(" \n>> FreeBSD/sparc64 ZFS boot block\n Boot path: %s\n",
|
||||
bootpath);
|
||||
#else
|
||||
printf(" \n>> FreeBSD/sparc64 boot block\n Boot path: %s\n"
|
||||
" Boot loader: %s\n", bootpath, path);
|
||||
#endif
|
||||
|
||||
if (domount(bootpath) == -1)
|
||||
panic("domount");
|
||||
|
||||
#ifdef ZFSBOOT
|
||||
loadzfs();
|
||||
#else
|
||||
load(path);
|
||||
#endif
|
||||
return (1);
|
||||
}
|
||||
|
||||
static void
|
||||
usage(void)
|
||||
{
|
||||
|
||||
printf("usage: boot device [/path/to/loader]\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
static void
|
||||
exit(int code)
|
||||
{
|
||||
|
||||
ofw_exit();
|
||||
}
|
||||
|
||||
#ifdef ZFSBOOT
|
||||
|
||||
#define VDEV_BOOT_OFFSET (2 * 256 * 1024)
|
||||
static char zbuf[READ_BUF_SIZE];
|
||||
|
||||
static int
|
||||
zbread(char *buf, off_t off, size_t bytes)
|
||||
{
|
||||
size_t len;
|
||||
off_t poff;
|
||||
off_t soff;
|
||||
char *p;
|
||||
unsigned int nb;
|
||||
unsigned int lb;
|
||||
|
||||
p = buf;
|
||||
soff = VDEV_BOOT_OFFSET + off;
|
||||
lb = howmany(soff + bytes, DEV_BSIZE);
|
||||
poff = soff;
|
||||
while (poff < soff + bytes) {
|
||||
nb = lb - poff / DEV_BSIZE;
|
||||
if (nb > READ_BUF_SIZE / DEV_BSIZE)
|
||||
nb = READ_BUF_SIZE / DEV_BSIZE;
|
||||
if (dskread(zbuf, poff / DEV_BSIZE, nb))
|
||||
break;
|
||||
if ((poff / DEV_BSIZE + nb) * DEV_BSIZE > soff + bytes)
|
||||
len = soff + bytes - poff;
|
||||
else
|
||||
len = (poff / DEV_BSIZE + nb) * DEV_BSIZE - poff;
|
||||
memcpy(p, zbuf + poff % DEV_BSIZE, len);
|
||||
p += len;
|
||||
poff += len;
|
||||
}
|
||||
return (poff - soff);
|
||||
}
|
||||
|
||||
static void
|
||||
loadzfs(void)
|
||||
{
|
||||
Elf64_Ehdr eh;
|
||||
Elf64_Phdr ph;
|
||||
caddr_t p;
|
||||
int i;
|
||||
|
||||
if (zbread((char *)&eh, 0, sizeof(eh)) != sizeof(eh)) {
|
||||
printf("Can't read elf header\n");
|
||||
return;
|
||||
}
|
||||
if (!IS_ELF(eh)) {
|
||||
printf("Not an ELF file\n");
|
||||
return;
|
||||
}
|
||||
for (i = 0; i < eh.e_phnum; i++) {
|
||||
fs_off = eh.e_phoff + i * eh.e_phentsize;
|
||||
if (zbread((char *)&ph, fs_off, sizeof(ph)) != sizeof(ph)) {
|
||||
printf("Can't read program header %d\n", i);
|
||||
return;
|
||||
}
|
||||
if (ph.p_type != PT_LOAD)
|
||||
continue;
|
||||
fs_off = ph.p_offset;
|
||||
p = (caddr_t)ph.p_vaddr;
|
||||
if (zbread(p, fs_off, ph.p_filesz) != ph.p_filesz) {
|
||||
printf("Can't read content of section %d\n", i);
|
||||
return;
|
||||
}
|
||||
if (ph.p_filesz != ph.p_memsz)
|
||||
bzero(p + ph.p_filesz, ph.p_memsz - ph.p_filesz);
|
||||
}
|
||||
ofw_close(bootdev);
|
||||
(*(void (*)(int, int, int, int, ofwfp_t))eh.e_entry)(0, 0, 0, 0, ofw);
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
#include "ufsread.c"
|
||||
|
||||
static struct dmadat __dmadat;
|
||||
|
||||
static void
|
||||
load(const char *fname)
|
||||
{
|
||||
Elf64_Ehdr eh;
|
||||
Elf64_Phdr ph;
|
||||
caddr_t p;
|
||||
ufs_ino_t ino;
|
||||
int i;
|
||||
|
||||
if ((ino = lookup(fname)) == 0) {
|
||||
printf("File %s not found\n", fname);
|
||||
return;
|
||||
}
|
||||
if (fsread(ino, &eh, sizeof(eh)) != sizeof(eh)) {
|
||||
printf("Can't read elf header\n");
|
||||
return;
|
||||
}
|
||||
if (!IS_ELF(eh)) {
|
||||
printf("Not an ELF file\n");
|
||||
return;
|
||||
}
|
||||
for (i = 0; i < eh.e_phnum; i++) {
|
||||
fs_off = eh.e_phoff + i * eh.e_phentsize;
|
||||
if (fsread(ino, &ph, sizeof(ph)) != sizeof(ph)) {
|
||||
printf("Can't read program header %d\n", i);
|
||||
return;
|
||||
}
|
||||
if (ph.p_type != PT_LOAD)
|
||||
continue;
|
||||
fs_off = ph.p_offset;
|
||||
p = (caddr_t)ph.p_vaddr;
|
||||
if (fsread(ino, p, ph.p_filesz) != ph.p_filesz) {
|
||||
printf("Can't read content of section %d\n", i);
|
||||
return;
|
||||
}
|
||||
if (ph.p_filesz != ph.p_memsz)
|
||||
bzero(p + ph.p_filesz, ph.p_memsz - ph.p_filesz);
|
||||
}
|
||||
ofw_close(bootdev);
|
||||
(*(void (*)(int, int, int, int, ofwfp_t))eh.e_entry)(0, 0, 0, 0, ofw);
|
||||
}
|
||||
|
||||
#endif /* ZFSBOOT */
|
||||
|
||||
static int
|
||||
domount(const char *device)
|
||||
{
|
||||
|
||||
if ((bootdev = ofw_open(device)) == -1) {
|
||||
printf("domount: can't open device\n");
|
||||
return (-1);
|
||||
}
|
||||
#ifndef ZFSBOOT
|
||||
dmadat = &__dmadat;
|
||||
if (fsread(0, NULL, 0)) {
|
||||
printf("domount: can't read superblock\n");
|
||||
return (-1);
|
||||
}
|
||||
#endif
|
||||
return (0);
|
||||
}
|
||||
|
||||
static int
|
||||
dskread(void *buf, uint64_t lba, int nblk)
|
||||
{
|
||||
|
||||
/*
|
||||
* The Open Firmware should open the correct partition for us.
|
||||
* That means, if we read from offset zero on an open instance handle,
|
||||
* we should read from offset zero of that partition.
|
||||
*/
|
||||
ofw_seek(bootdev, lba * DEV_BSIZE);
|
||||
ofw_read(bootdev, buf, nblk * DEV_BSIZE);
|
||||
return (0);
|
||||
}
|
||||
|
||||
static void
|
||||
panic(const char *fmt, ...)
|
||||
{
|
||||
char buf[128];
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, fmt);
|
||||
vsnprintf(buf, sizeof buf, fmt, ap);
|
||||
printf("panic: %s\n", buf);
|
||||
va_end(ap);
|
||||
|
||||
exit(1);
|
||||
}
|
||||
|
||||
static int
|
||||
printf(const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
int ret;
|
||||
|
||||
va_start(ap, fmt);
|
||||
ret = vprintf(fmt, ap);
|
||||
va_end(ap);
|
||||
return (ret);
|
||||
}
|
||||
|
||||
static int
|
||||
putchar(char c, void *arg)
|
||||
{
|
||||
char buf;
|
||||
|
||||
if (c == '\n') {
|
||||
buf = '\r';
|
||||
ofw_write(stdouth, &buf, 1);
|
||||
}
|
||||
buf = c;
|
||||
ofw_write(stdouth, &buf, 1);
|
||||
return (1);
|
||||
}
|
||||
|
||||
static int
|
||||
vprintf(const char *fmt, va_list ap)
|
||||
{
|
||||
int ret;
|
||||
|
||||
ret = __printf(fmt, putchar, 0, ap);
|
||||
return (ret);
|
||||
}
|
||||
|
||||
static int
|
||||
vsnprintf(char *str, size_t sz, const char *fmt, va_list ap)
|
||||
{
|
||||
struct sp_data sp;
|
||||
int ret;
|
||||
|
||||
sp.sp_buf = str;
|
||||
sp.sp_len = 0;
|
||||
sp.sp_size = sz;
|
||||
ret = __printf(fmt, __sputc, &sp, ap);
|
||||
return (ret);
|
||||
}
|
||||
|
||||
static int
|
||||
__printf(const char *fmt, putc_func_t *putc, void *arg, va_list ap)
|
||||
{
|
||||
char buf[(sizeof(long) * 8) + 1];
|
||||
char *nbuf;
|
||||
u_long ul;
|
||||
u_int ui;
|
||||
int lflag;
|
||||
int sflag;
|
||||
char *s;
|
||||
int pad;
|
||||
int ret;
|
||||
int c;
|
||||
|
||||
nbuf = &buf[sizeof buf - 1];
|
||||
ret = 0;
|
||||
while ((c = *fmt++) != 0) {
|
||||
if (c != '%') {
|
||||
ret += putc(c, arg);
|
||||
continue;
|
||||
}
|
||||
lflag = 0;
|
||||
sflag = 0;
|
||||
pad = 0;
|
||||
reswitch: c = *fmt++;
|
||||
switch (c) {
|
||||
case '#':
|
||||
sflag = 1;
|
||||
goto reswitch;
|
||||
case '%':
|
||||
ret += putc('%', arg);
|
||||
break;
|
||||
case 'c':
|
||||
c = va_arg(ap, int);
|
||||
ret += putc(c, arg);
|
||||
break;
|
||||
case 'd':
|
||||
if (lflag == 0) {
|
||||
ui = (u_int)va_arg(ap, int);
|
||||
if (ui < (int)ui) {
|
||||
ui = -ui;
|
||||
ret += putc('-', arg);
|
||||
}
|
||||
s = __uitoa(nbuf, ui, 10);
|
||||
} else {
|
||||
ul = (u_long)va_arg(ap, long);
|
||||
if (ul < (long)ul) {
|
||||
ul = -ul;
|
||||
ret += putc('-', arg);
|
||||
}
|
||||
s = __ultoa(nbuf, ul, 10);
|
||||
}
|
||||
ret += __puts(s, putc, arg);
|
||||
break;
|
||||
case 'l':
|
||||
lflag = 1;
|
||||
goto reswitch;
|
||||
case 'o':
|
||||
if (lflag == 0) {
|
||||
ui = (u_int)va_arg(ap, u_int);
|
||||
s = __uitoa(nbuf, ui, 8);
|
||||
} else {
|
||||
ul = (u_long)va_arg(ap, u_long);
|
||||
s = __ultoa(nbuf, ul, 8);
|
||||
}
|
||||
ret += __puts(s, putc, arg);
|
||||
break;
|
||||
case 'p':
|
||||
ul = (u_long)va_arg(ap, void *);
|
||||
s = __ultoa(nbuf, ul, 16);
|
||||
ret += __puts("0x", putc, arg);
|
||||
ret += __puts(s, putc, arg);
|
||||
break;
|
||||
case 's':
|
||||
s = va_arg(ap, char *);
|
||||
ret += __puts(s, putc, arg);
|
||||
break;
|
||||
case 'u':
|
||||
if (lflag == 0) {
|
||||
ui = va_arg(ap, u_int);
|
||||
s = __uitoa(nbuf, ui, 10);
|
||||
} else {
|
||||
ul = va_arg(ap, u_long);
|
||||
s = __ultoa(nbuf, ul, 10);
|
||||
}
|
||||
ret += __puts(s, putc, arg);
|
||||
break;
|
||||
case 'x':
|
||||
if (lflag == 0) {
|
||||
ui = va_arg(ap, u_int);
|
||||
s = __uitoa(nbuf, ui, 16);
|
||||
} else {
|
||||
ul = va_arg(ap, u_long);
|
||||
s = __ultoa(nbuf, ul, 16);
|
||||
}
|
||||
if (sflag)
|
||||
ret += __puts("0x", putc, arg);
|
||||
ret += __puts(s, putc, arg);
|
||||
break;
|
||||
case '0': case '1': case '2': case '3': case '4':
|
||||
case '5': case '6': case '7': case '8': case '9':
|
||||
pad = pad * 10 + c - '0';
|
||||
goto reswitch;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
return (ret);
|
||||
}
|
||||
|
||||
static int
|
||||
__sputc(char c, void *arg)
|
||||
{
|
||||
struct sp_data *sp;
|
||||
|
||||
sp = arg;
|
||||
if (sp->sp_len < sp->sp_size)
|
||||
sp->sp_buf[sp->sp_len++] = c;
|
||||
sp->sp_buf[sp->sp_len] = '\0';
|
||||
return (1);
|
||||
}
|
||||
|
||||
static int
|
||||
__puts(const char *s, putc_func_t *putc, void *arg)
|
||||
{
|
||||
const char *p;
|
||||
int ret;
|
||||
|
||||
ret = 0;
|
||||
for (p = s; *p != '\0'; p++)
|
||||
ret += putc(*p, arg);
|
||||
return (ret);
|
||||
}
|
||||
|
||||
static char *
|
||||
__uitoa(char *buf, u_int ui, int base)
|
||||
{
|
||||
char *p;
|
||||
|
||||
p = buf;
|
||||
*p = '\0';
|
||||
do
|
||||
*--p = digits[ui % base];
|
||||
while ((ui /= base) != 0);
|
||||
return (p);
|
||||
}
|
||||
|
||||
static char *
|
||||
__ultoa(char *buf, u_long ul, int base)
|
||||
{
|
||||
char *p;
|
||||
|
||||
p = buf;
|
||||
*p = '\0';
|
||||
do
|
||||
*--p = digits[ul % base];
|
||||
while ((ul /= base) != 0);
|
||||
return (p);
|
||||
}
|
@ -1,56 +0,0 @@
|
||||
# $FreeBSD$
|
||||
|
||||
HAVE_ZFS= ${MK_LOADER_ZFS}
|
||||
|
||||
LOADER_DISK_SUPPORT?= yes
|
||||
LOADER_UFS_SUPPORT?= yes
|
||||
LOADER_CD9660_SUPPORT?= yes
|
||||
LOADER_EXT2FS_SUPPORT?= no
|
||||
LOADER_MSDOS_SUPPORT?= no
|
||||
LOADER_NET_SUPPORT?= yes
|
||||
LOADER_NFS_SUPPORT?= yes
|
||||
LOADER_TFTP_SUPPORT?= yes
|
||||
LOADER_GZIP_SUPPORT?= yes
|
||||
LOADER_BZIP2_SUPPORT?= no
|
||||
LOADER_DEBUG?= no
|
||||
|
||||
.include <bsd.init.mk>
|
||||
|
||||
PROG?= loader
|
||||
NEWVERSWHAT?= "bootstrap loader" sparc64
|
||||
VERSION_FILE= ${.CURDIR}/../loader/version
|
||||
INSTALLFLAGS= -b
|
||||
|
||||
.if ${MK_LOADER_ZFS} != "no"
|
||||
HAVE_ZFS= yes
|
||||
.endif
|
||||
|
||||
# Architecture-specific loader code
|
||||
.PATH: ${BOOTSRC}/sparc64/loader
|
||||
SRCS= locore.S main.c vers.c
|
||||
|
||||
.if ${LOADER_DEBUG} == "yes"
|
||||
CFLAGS+= -DLOADER_DEBUG
|
||||
.endif
|
||||
|
||||
.if exists(${.CURDIR}/help.sparc64)
|
||||
HELP_FILES= ${.CURDIR}/help.sparc64
|
||||
.endif
|
||||
|
||||
# Always add MI sources
|
||||
.include "${BOOTSRC}/loader.mk"
|
||||
|
||||
LDFLAGS+= -static
|
||||
|
||||
.if ${MK_LOADER_ZFS} == "yes"
|
||||
LINKS= ${BINDIR}/loader ${BINDIR}/zfsloader
|
||||
.endif
|
||||
|
||||
# Open Firmware standalone support library
|
||||
LIBOFW= ${BOOTOBJ}/libofw/libofw.a
|
||||
CFLAGS+= -I${BOOTSRC}/libofw
|
||||
|
||||
DPADD= ${LDR_INTERP} ${LIBOFW} ${LIBSA}
|
||||
LDADD= ${LDR_INTERP} ${LIBOFW} ${LIBSA}
|
||||
|
||||
.include <bsd.prog.mk>
|
@ -1,42 +0,0 @@
|
||||
/*-
|
||||
* Initial implementation:
|
||||
* Copyright (c) 2001 Robert Drehmel
|
||||
* All rights reserved.
|
||||
*
|
||||
* As long as the above copyright statement and this notice remain
|
||||
* unchanged, you can do what ever you want with this file.
|
||||
*/
|
||||
|
||||
#include <machine/asm.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#define LOCORE
|
||||
|
||||
#include <machine/frame.h>
|
||||
#include <machine/fsr.h>
|
||||
#include <machine/intr_machdep.h>
|
||||
#include <machine/pstate.h>
|
||||
|
||||
#define PAGE_SIZE 8192
|
||||
#define PAGE_SHIFT 13
|
||||
|
||||
#define STACK_SIZE (2 * PAGE_SIZE)
|
||||
|
||||
ENTRY(_start)
|
||||
/* Limit interrupts. */
|
||||
wrpr %g0, PIL_TICK - 1, %pil
|
||||
|
||||
/*
|
||||
* PSTATE: privileged, interrupts enabled, floating point
|
||||
* unit enabled
|
||||
*/
|
||||
wrpr %g0, PSTATE_PRIV | PSTATE_IE | PSTATE_PEF, %pstate
|
||||
wr %g0, FPRS_FEF, %fprs
|
||||
|
||||
setx stack + STACK_SIZE - SPOFF - CCFSZ, %l7, %l6
|
||||
mov %l6, %sp
|
||||
call main
|
||||
mov %o4, %o0
|
||||
sir
|
||||
|
||||
.comm stack, STACK_SIZE, 32
|
@ -1,986 +0,0 @@
|
||||
/*-
|
||||
* Initial implementation:
|
||||
* Copyright (c) 2001 Robert Drehmel
|
||||
* All rights reserved.
|
||||
*
|
||||
* As long as the above copyright statement and this notice remain
|
||||
* unchanged, you can do what ever you want with this file.
|
||||
*/
|
||||
/*-
|
||||
* Copyright (c) 2008 - 2012 Marius Strobl <marius@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$");
|
||||
|
||||
/*
|
||||
* FreeBSD/sparc64 kernel loader - machine dependent part
|
||||
*
|
||||
* - implements copyin and readin functions that map kernel
|
||||
* pages on demand. The machine independent code does not
|
||||
* know the size of the kernel early enough to pre-enter
|
||||
* TTEs and install just one 4MB mapping seemed to limiting
|
||||
* to me.
|
||||
*/
|
||||
|
||||
#include <stand.h>
|
||||
#include <sys/param.h>
|
||||
#include <sys/exec.h>
|
||||
#include <sys/linker.h>
|
||||
#include <sys/queue.h>
|
||||
#include <sys/types.h>
|
||||
#ifdef LOADER_ZFS_SUPPORT
|
||||
#include <sys/vtoc.h>
|
||||
#include "libzfs.h"
|
||||
#endif
|
||||
|
||||
#include <vm/vm.h>
|
||||
#include <machine/asi.h>
|
||||
#include <machine/cmt.h>
|
||||
#include <machine/cpufunc.h>
|
||||
#include <machine/elf.h>
|
||||
#include <machine/fireplane.h>
|
||||
#include <machine/jbus.h>
|
||||
#include <machine/lsu.h>
|
||||
#include <machine/metadata.h>
|
||||
#include <machine/tte.h>
|
||||
#include <machine/tlb.h>
|
||||
#include <machine/upa.h>
|
||||
#include <machine/ver.h>
|
||||
#include <machine/vmparam.h>
|
||||
|
||||
#include "bootstrap.h"
|
||||
#include "libofw.h"
|
||||
#include "dev_net.h"
|
||||
|
||||
enum {
|
||||
HEAPVA = 0x800000,
|
||||
HEAPSZ = 0x3000000,
|
||||
LOADSZ = 0x1000000 /* for kernel and modules */
|
||||
};
|
||||
|
||||
/* At least Sun Fire V1280 require page sized allocations to be claimed. */
|
||||
CTASSERT(HEAPSZ % PAGE_SIZE == 0);
|
||||
|
||||
static struct mmu_ops {
|
||||
void (*tlb_init)(void);
|
||||
int (*mmu_mapin)(vm_offset_t va, vm_size_t len);
|
||||
} *mmu_ops;
|
||||
|
||||
typedef void kernel_entry_t(vm_offset_t mdp, u_long o1, u_long o2, u_long o3,
|
||||
void *openfirmware);
|
||||
|
||||
static inline u_long dtlb_get_data_sun4u(u_int, u_int);
|
||||
static int dtlb_enter_sun4u(u_int, u_long data, vm_offset_t);
|
||||
static vm_offset_t dtlb_va_to_pa_sun4u(vm_offset_t);
|
||||
static inline u_long itlb_get_data_sun4u(u_int, u_int);
|
||||
static int itlb_enter_sun4u(u_int, u_long data, vm_offset_t);
|
||||
static vm_offset_t itlb_va_to_pa_sun4u(vm_offset_t);
|
||||
static void itlb_relocate_locked0_sun4u(void);
|
||||
static int sparc64_autoload(void);
|
||||
static ssize_t sparc64_readin(const int, vm_offset_t, const size_t);
|
||||
static ssize_t sparc64_copyin(const void *, vm_offset_t, size_t);
|
||||
static vm_offset_t claim_virt(vm_offset_t, size_t, int);
|
||||
static vm_offset_t alloc_phys(size_t, int);
|
||||
static int map_phys(int, size_t, vm_offset_t, vm_offset_t);
|
||||
static void release_phys(vm_offset_t, u_int);
|
||||
static int __elfN(exec)(struct preloaded_file *);
|
||||
static int mmu_mapin_sun4u(vm_offset_t, vm_size_t);
|
||||
static vm_offset_t init_heap(void);
|
||||
static phandle_t find_bsp_sun4u(phandle_t, uint32_t);
|
||||
const char *cpu_cpuid_prop_sun4u(void);
|
||||
uint32_t cpu_get_mid_sun4u(void);
|
||||
static void tlb_init_sun4u(void);
|
||||
|
||||
#ifdef LOADER_DEBUG
|
||||
typedef uint64_t tte_t;
|
||||
|
||||
static void pmap_print_tlb_sun4u(void);
|
||||
static void pmap_print_tte_sun4u(tte_t, tte_t);
|
||||
#endif
|
||||
|
||||
static struct mmu_ops mmu_ops_sun4u = { tlb_init_sun4u, mmu_mapin_sun4u };
|
||||
|
||||
/* sun4u */
|
||||
struct tlb_entry *dtlb_store;
|
||||
struct tlb_entry *itlb_store;
|
||||
u_int dtlb_slot;
|
||||
u_int itlb_slot;
|
||||
static int cpu_impl;
|
||||
static u_int dtlb_slot_max;
|
||||
static u_int itlb_slot_max;
|
||||
static u_int tlb_locked;
|
||||
|
||||
static vm_offset_t curkva = 0;
|
||||
static vm_offset_t heapva;
|
||||
|
||||
static char bootpath[64];
|
||||
static phandle_t root;
|
||||
|
||||
#ifdef LOADER_ZFS_SUPPORT
|
||||
static struct zfs_devdesc zfs_currdev;
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Machine dependent structures that the machine independent
|
||||
* loader part uses.
|
||||
*/
|
||||
struct devsw *devsw[] = {
|
||||
#ifdef LOADER_DISK_SUPPORT
|
||||
&ofwdisk,
|
||||
#endif
|
||||
#ifdef LOADER_NET_SUPPORT
|
||||
&netdev,
|
||||
#endif
|
||||
#ifdef LOADER_ZFS_SUPPORT
|
||||
&zfs_dev,
|
||||
#endif
|
||||
NULL
|
||||
};
|
||||
|
||||
struct arch_switch archsw;
|
||||
|
||||
static struct file_format sparc64_elf = {
|
||||
__elfN(loadfile),
|
||||
__elfN(exec)
|
||||
};
|
||||
|
||||
struct file_format *file_formats[] = {
|
||||
&sparc64_elf,
|
||||
NULL
|
||||
};
|
||||
|
||||
struct fs_ops *file_system[] = {
|
||||
#ifdef LOADER_ZFS_SUPPORT
|
||||
&zfs_fsops,
|
||||
#endif
|
||||
#ifdef LOADER_UFS_SUPPORT
|
||||
&ufs_fsops,
|
||||
#endif
|
||||
#ifdef LOADER_CD9660_SUPPORT
|
||||
&cd9660_fsops,
|
||||
#endif
|
||||
#ifdef LOADER_ZIP_SUPPORT
|
||||
&zipfs_fsops,
|
||||
#endif
|
||||
#ifdef LOADER_GZIP_SUPPORT
|
||||
&gzipfs_fsops,
|
||||
#endif
|
||||
#ifdef LOADER_BZIP2_SUPPORT
|
||||
&bzipfs_fsops,
|
||||
#endif
|
||||
#ifdef LOADER_NFS_SUPPORT
|
||||
&nfs_fsops,
|
||||
#endif
|
||||
#ifdef LOADER_TFTP_SUPPORT
|
||||
&tftp_fsops,
|
||||
#endif
|
||||
NULL
|
||||
};
|
||||
|
||||
struct netif_driver *netif_drivers[] = {
|
||||
#ifdef LOADER_NET_SUPPORT
|
||||
&ofwnet,
|
||||
#endif
|
||||
NULL
|
||||
};
|
||||
|
||||
extern struct console ofwconsole;
|
||||
struct console *consoles[] = {
|
||||
&ofwconsole,
|
||||
NULL
|
||||
};
|
||||
|
||||
#ifdef LOADER_DEBUG
|
||||
static int
|
||||
watch_phys_set_mask(vm_offset_t pa, u_long mask)
|
||||
{
|
||||
u_long lsucr;
|
||||
|
||||
stxa(AA_DMMU_PWPR, ASI_DMMU, pa & (((2UL << 38) - 1) << 3));
|
||||
lsucr = ldxa(0, ASI_LSU_CTL_REG);
|
||||
lsucr = ((lsucr | LSU_PW) & ~LSU_PM_MASK) |
|
||||
(mask << LSU_PM_SHIFT);
|
||||
stxa(0, ASI_LSU_CTL_REG, lsucr);
|
||||
return (0);
|
||||
}
|
||||
|
||||
static int
|
||||
watch_phys_set(vm_offset_t pa, int sz)
|
||||
{
|
||||
u_long off;
|
||||
|
||||
off = (u_long)pa & 7;
|
||||
/* Test for misaligned watch points. */
|
||||
if (off + sz > 8)
|
||||
return (-1);
|
||||
return (watch_phys_set_mask(pa, ((1 << sz) - 1) << off));
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
watch_virt_set_mask(vm_offset_t va, u_long mask)
|
||||
{
|
||||
u_long lsucr;
|
||||
|
||||
stxa(AA_DMMU_VWPR, ASI_DMMU, va & (((2UL << 41) - 1) << 3));
|
||||
lsucr = ldxa(0, ASI_LSU_CTL_REG);
|
||||
lsucr = ((lsucr | LSU_VW) & ~LSU_VM_MASK) |
|
||||
(mask << LSU_VM_SHIFT);
|
||||
stxa(0, ASI_LSU_CTL_REG, lsucr);
|
||||
return (0);
|
||||
}
|
||||
|
||||
static int
|
||||
watch_virt_set(vm_offset_t va, int sz)
|
||||
{
|
||||
u_long off;
|
||||
|
||||
off = (u_long)va & 7;
|
||||
/* Test for misaligned watch points. */
|
||||
if (off + sz > 8)
|
||||
return (-1);
|
||||
return (watch_virt_set_mask(va, ((1 << sz) - 1) << off));
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* archsw functions
|
||||
*/
|
||||
static int
|
||||
sparc64_autoload(void)
|
||||
{
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
static ssize_t
|
||||
sparc64_readin(const int fd, vm_offset_t va, const size_t len)
|
||||
{
|
||||
|
||||
mmu_ops->mmu_mapin(va, len);
|
||||
return (read(fd, (void *)va, len));
|
||||
}
|
||||
|
||||
static ssize_t
|
||||
sparc64_copyin(const void *src, vm_offset_t dest, size_t len)
|
||||
{
|
||||
|
||||
mmu_ops->mmu_mapin(dest, len);
|
||||
memcpy((void *)dest, src, len);
|
||||
return (len);
|
||||
}
|
||||
|
||||
/*
|
||||
* other MD functions
|
||||
*/
|
||||
static vm_offset_t
|
||||
claim_virt(vm_offset_t virt, size_t size, int align)
|
||||
{
|
||||
vm_offset_t mva;
|
||||
|
||||
if (OF_call_method("claim", mmu, 3, 1, virt, size, align, &mva) == -1)
|
||||
return ((vm_offset_t)-1);
|
||||
return (mva);
|
||||
}
|
||||
|
||||
static vm_offset_t
|
||||
alloc_phys(size_t size, int align)
|
||||
{
|
||||
cell_t phys_hi, phys_low;
|
||||
|
||||
if (OF_call_method("claim", memory, 2, 2, size, align, &phys_low,
|
||||
&phys_hi) == -1)
|
||||
return ((vm_offset_t)-1);
|
||||
return ((vm_offset_t)phys_hi << 32 | phys_low);
|
||||
}
|
||||
|
||||
static int
|
||||
map_phys(int mode, size_t size, vm_offset_t virt, vm_offset_t phys)
|
||||
{
|
||||
|
||||
return (OF_call_method("map", mmu, 5, 0, (uint32_t)phys,
|
||||
(uint32_t)(phys >> 32), virt, size, mode));
|
||||
}
|
||||
|
||||
static void
|
||||
release_phys(vm_offset_t phys, u_int size)
|
||||
{
|
||||
|
||||
(void)OF_call_method("release", memory, 3, 0, (uint32_t)phys,
|
||||
(uint32_t)(phys >> 32), size);
|
||||
}
|
||||
|
||||
static int
|
||||
__elfN(exec)(struct preloaded_file *fp)
|
||||
{
|
||||
struct file_metadata *fmp;
|
||||
vm_offset_t mdp;
|
||||
Elf_Addr entry;
|
||||
Elf_Ehdr *e;
|
||||
int error;
|
||||
|
||||
if ((fmp = file_findmetadata(fp, MODINFOMD_ELFHDR)) == 0)
|
||||
return (EFTYPE);
|
||||
e = (Elf_Ehdr *)&fmp->md_data;
|
||||
|
||||
if ((error = md_load64(fp->f_args, &mdp, NULL)) != 0)
|
||||
return (error);
|
||||
|
||||
printf("jumping to kernel entry at %#lx.\n", e->e_entry);
|
||||
#ifdef LOADER_DEBUG
|
||||
pmap_print_tlb_sun4u();
|
||||
#endif
|
||||
|
||||
dev_cleanup();
|
||||
|
||||
entry = e->e_entry;
|
||||
|
||||
OF_release((void *)heapva, HEAPSZ);
|
||||
|
||||
((kernel_entry_t *)entry)(mdp, 0, 0, 0, openfirmware);
|
||||
|
||||
panic("%s: exec returned", __func__);
|
||||
}
|
||||
|
||||
static inline u_long
|
||||
dtlb_get_data_sun4u(u_int tlb, u_int slot)
|
||||
{
|
||||
u_long data, pstate;
|
||||
|
||||
slot = TLB_DAR_SLOT(tlb, slot);
|
||||
/*
|
||||
* We read ASI_DTLB_DATA_ACCESS_REG twice back-to-back in order to
|
||||
* work around errata of USIII and beyond.
|
||||
*/
|
||||
pstate = rdpr(pstate);
|
||||
wrpr(pstate, pstate & ~PSTATE_IE, 0);
|
||||
(void)ldxa(slot, ASI_DTLB_DATA_ACCESS_REG);
|
||||
data = ldxa(slot, ASI_DTLB_DATA_ACCESS_REG);
|
||||
wrpr(pstate, pstate, 0);
|
||||
return (data);
|
||||
}
|
||||
|
||||
static inline u_long
|
||||
itlb_get_data_sun4u(u_int tlb, u_int slot)
|
||||
{
|
||||
u_long data, pstate;
|
||||
|
||||
slot = TLB_DAR_SLOT(tlb, slot);
|
||||
/*
|
||||
* We read ASI_DTLB_DATA_ACCESS_REG twice back-to-back in order to
|
||||
* work around errata of USIII and beyond.
|
||||
*/
|
||||
pstate = rdpr(pstate);
|
||||
wrpr(pstate, pstate & ~PSTATE_IE, 0);
|
||||
(void)ldxa(slot, ASI_ITLB_DATA_ACCESS_REG);
|
||||
data = ldxa(slot, ASI_ITLB_DATA_ACCESS_REG);
|
||||
wrpr(pstate, pstate, 0);
|
||||
return (data);
|
||||
}
|
||||
|
||||
static vm_offset_t
|
||||
dtlb_va_to_pa_sun4u(vm_offset_t va)
|
||||
{
|
||||
u_long pstate, reg;
|
||||
u_int i, tlb;
|
||||
|
||||
pstate = rdpr(pstate);
|
||||
wrpr(pstate, pstate & ~PSTATE_IE, 0);
|
||||
for (i = 0; i < dtlb_slot_max; i++) {
|
||||
reg = ldxa(TLB_DAR_SLOT(tlb_locked, i),
|
||||
ASI_DTLB_TAG_READ_REG);
|
||||
if (TLB_TAR_VA(reg) != va)
|
||||
continue;
|
||||
reg = dtlb_get_data_sun4u(tlb_locked, i);
|
||||
wrpr(pstate, pstate, 0);
|
||||
reg >>= TD_PA_SHIFT;
|
||||
if (cpu_impl == CPU_IMPL_SPARC64V ||
|
||||
cpu_impl >= CPU_IMPL_ULTRASPARCIII)
|
||||
return (reg & TD_PA_CH_MASK);
|
||||
return (reg & TD_PA_SF_MASK);
|
||||
}
|
||||
wrpr(pstate, pstate, 0);
|
||||
return (-1);
|
||||
}
|
||||
|
||||
static vm_offset_t
|
||||
itlb_va_to_pa_sun4u(vm_offset_t va)
|
||||
{
|
||||
u_long pstate, reg;
|
||||
int i;
|
||||
|
||||
pstate = rdpr(pstate);
|
||||
wrpr(pstate, pstate & ~PSTATE_IE, 0);
|
||||
for (i = 0; i < itlb_slot_max; i++) {
|
||||
reg = ldxa(TLB_DAR_SLOT(tlb_locked, i),
|
||||
ASI_ITLB_TAG_READ_REG);
|
||||
if (TLB_TAR_VA(reg) != va)
|
||||
continue;
|
||||
reg = itlb_get_data_sun4u(tlb_locked, i);
|
||||
wrpr(pstate, pstate, 0);
|
||||
reg >>= TD_PA_SHIFT;
|
||||
if (cpu_impl == CPU_IMPL_SPARC64V ||
|
||||
cpu_impl >= CPU_IMPL_ULTRASPARCIII)
|
||||
return (reg & TD_PA_CH_MASK);
|
||||
return (reg & TD_PA_SF_MASK);
|
||||
}
|
||||
wrpr(pstate, pstate, 0);
|
||||
return (-1);
|
||||
}
|
||||
|
||||
static int
|
||||
dtlb_enter_sun4u(u_int index, u_long data, vm_offset_t virt)
|
||||
{
|
||||
|
||||
return (OF_call_method("SUNW,dtlb-load", mmu, 3, 0, index, data,
|
||||
virt));
|
||||
}
|
||||
|
||||
static int
|
||||
itlb_enter_sun4u(u_int index, u_long data, vm_offset_t virt)
|
||||
{
|
||||
|
||||
if (cpu_impl == CPU_IMPL_ULTRASPARCIIIp && index == 0 &&
|
||||
(data & TD_L) != 0)
|
||||
panic("%s: won't enter locked TLB entry at index 0 on USIII+",
|
||||
__func__);
|
||||
return (OF_call_method("SUNW,itlb-load", mmu, 3, 0, index, data,
|
||||
virt));
|
||||
}
|
||||
|
||||
static void
|
||||
itlb_relocate_locked0_sun4u(void)
|
||||
{
|
||||
u_long data, pstate, tag;
|
||||
int i;
|
||||
|
||||
if (cpu_impl != CPU_IMPL_ULTRASPARCIIIp)
|
||||
return;
|
||||
|
||||
pstate = rdpr(pstate);
|
||||
wrpr(pstate, pstate & ~PSTATE_IE, 0);
|
||||
|
||||
data = itlb_get_data_sun4u(tlb_locked, 0);
|
||||
if ((data & (TD_V | TD_L)) != (TD_V | TD_L)) {
|
||||
wrpr(pstate, pstate, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Flush the mapping of slot 0. */
|
||||
tag = ldxa(TLB_DAR_SLOT(tlb_locked, 0), ASI_ITLB_TAG_READ_REG);
|
||||
stxa(TLB_DEMAP_VA(TLB_TAR_VA(tag)) | TLB_DEMAP_PRIMARY |
|
||||
TLB_DEMAP_PAGE, ASI_IMMU_DEMAP, 0);
|
||||
flush(0); /* The USIII-family ignores the address. */
|
||||
|
||||
/*
|
||||
* Search a replacement slot != 0 and enter the data and tag
|
||||
* that formerly were in slot 0.
|
||||
*/
|
||||
for (i = 1; i < itlb_slot_max; i++) {
|
||||
if ((itlb_get_data_sun4u(tlb_locked, i) & TD_V) != 0)
|
||||
continue;
|
||||
|
||||
stxa(AA_IMMU_TAR, ASI_IMMU, tag);
|
||||
stxa(TLB_DAR_SLOT(tlb_locked, i), ASI_ITLB_DATA_ACCESS_REG,
|
||||
data);
|
||||
flush(0); /* The USIII-family ignores the address. */
|
||||
break;
|
||||
}
|
||||
wrpr(pstate, pstate, 0);
|
||||
if (i == itlb_slot_max)
|
||||
panic("%s: could not find a replacement slot", __func__);
|
||||
}
|
||||
|
||||
static int
|
||||
mmu_mapin_sun4u(vm_offset_t va, vm_size_t len)
|
||||
{
|
||||
vm_offset_t pa, mva;
|
||||
u_long data;
|
||||
u_int index;
|
||||
|
||||
if (va + len > curkva)
|
||||
curkva = va + len;
|
||||
|
||||
pa = (vm_offset_t)-1;
|
||||
len += va & PAGE_MASK_4M;
|
||||
va &= ~PAGE_MASK_4M;
|
||||
while (len) {
|
||||
if (dtlb_va_to_pa_sun4u(va) == (vm_offset_t)-1 ||
|
||||
itlb_va_to_pa_sun4u(va) == (vm_offset_t)-1) {
|
||||
/* Allocate a physical page, claim the virtual area. */
|
||||
if (pa == (vm_offset_t)-1) {
|
||||
pa = alloc_phys(PAGE_SIZE_4M, PAGE_SIZE_4M);
|
||||
if (pa == (vm_offset_t)-1)
|
||||
panic("%s: out of memory", __func__);
|
||||
mva = claim_virt(va, PAGE_SIZE_4M, 0);
|
||||
if (mva != va)
|
||||
panic("%s: can't claim virtual page "
|
||||
"(wanted %#lx, got %#lx)",
|
||||
__func__, va, mva);
|
||||
/*
|
||||
* The mappings may have changed, be paranoid.
|
||||
*/
|
||||
continue;
|
||||
}
|
||||
/*
|
||||
* Actually, we can only allocate two pages less at
|
||||
* most (depending on the kernel TSB size).
|
||||
*/
|
||||
if (dtlb_slot >= dtlb_slot_max)
|
||||
panic("%s: out of dtlb_slots", __func__);
|
||||
if (itlb_slot >= itlb_slot_max)
|
||||
panic("%s: out of itlb_slots", __func__);
|
||||
data = TD_V | TD_4M | TD_PA(pa) | TD_L | TD_CP |
|
||||
TD_CV | TD_P | TD_W;
|
||||
dtlb_store[dtlb_slot].te_pa = pa;
|
||||
dtlb_store[dtlb_slot].te_va = va;
|
||||
index = dtlb_slot_max - dtlb_slot - 1;
|
||||
if (dtlb_enter_sun4u(index, data, va) < 0)
|
||||
panic("%s: can't enter dTLB slot %d data "
|
||||
"%#lx va %#lx", __func__, index, data,
|
||||
va);
|
||||
dtlb_slot++;
|
||||
itlb_store[itlb_slot].te_pa = pa;
|
||||
itlb_store[itlb_slot].te_va = va;
|
||||
index = itlb_slot_max - itlb_slot - 1;
|
||||
if (itlb_enter_sun4u(index, data, va) < 0)
|
||||
panic("%s: can't enter iTLB slot %d data "
|
||||
"%#lx va %#lxd", __func__, index, data,
|
||||
va);
|
||||
itlb_slot++;
|
||||
pa = (vm_offset_t)-1;
|
||||
}
|
||||
len -= len > PAGE_SIZE_4M ? PAGE_SIZE_4M : len;
|
||||
va += PAGE_SIZE_4M;
|
||||
}
|
||||
if (pa != (vm_offset_t)-1)
|
||||
release_phys(pa, PAGE_SIZE_4M);
|
||||
return (0);
|
||||
}
|
||||
|
||||
static vm_offset_t
|
||||
init_heap(void)
|
||||
{
|
||||
|
||||
/* There is no need for continuous physical heap memory. */
|
||||
heapva = (vm_offset_t)OF_claim((void *)HEAPVA, HEAPSZ, 32);
|
||||
return (heapva);
|
||||
}
|
||||
|
||||
static phandle_t
|
||||
find_bsp_sun4u(phandle_t node, uint32_t bspid)
|
||||
{
|
||||
char type[sizeof("cpu")];
|
||||
phandle_t child;
|
||||
uint32_t cpuid;
|
||||
|
||||
for (; node > 0; node = OF_peer(node)) {
|
||||
child = OF_child(node);
|
||||
if (child > 0) {
|
||||
child = find_bsp_sun4u(child, bspid);
|
||||
if (child > 0)
|
||||
return (child);
|
||||
} else {
|
||||
if (OF_getprop(node, "device_type", type,
|
||||
sizeof(type)) <= 0)
|
||||
continue;
|
||||
if (strcmp(type, "cpu") != 0)
|
||||
continue;
|
||||
if (OF_getprop(node, cpu_cpuid_prop_sun4u(), &cpuid,
|
||||
sizeof(cpuid)) <= 0)
|
||||
continue;
|
||||
if (cpuid == bspid)
|
||||
return (node);
|
||||
}
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
const char *
|
||||
cpu_cpuid_prop_sun4u(void)
|
||||
{
|
||||
|
||||
switch (cpu_impl) {
|
||||
case CPU_IMPL_SPARC64:
|
||||
case CPU_IMPL_SPARC64V:
|
||||
case CPU_IMPL_ULTRASPARCI:
|
||||
case CPU_IMPL_ULTRASPARCII:
|
||||
case CPU_IMPL_ULTRASPARCIIi:
|
||||
case CPU_IMPL_ULTRASPARCIIe:
|
||||
return ("upa-portid");
|
||||
case CPU_IMPL_ULTRASPARCIII:
|
||||
case CPU_IMPL_ULTRASPARCIIIp:
|
||||
case CPU_IMPL_ULTRASPARCIIIi:
|
||||
case CPU_IMPL_ULTRASPARCIIIip:
|
||||
return ("portid");
|
||||
case CPU_IMPL_ULTRASPARCIV:
|
||||
case CPU_IMPL_ULTRASPARCIVp:
|
||||
return ("cpuid");
|
||||
default:
|
||||
return ("");
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t
|
||||
cpu_get_mid_sun4u(void)
|
||||
{
|
||||
|
||||
switch (cpu_impl) {
|
||||
case CPU_IMPL_SPARC64:
|
||||
case CPU_IMPL_SPARC64V:
|
||||
case CPU_IMPL_ULTRASPARCI:
|
||||
case CPU_IMPL_ULTRASPARCII:
|
||||
case CPU_IMPL_ULTRASPARCIIi:
|
||||
case CPU_IMPL_ULTRASPARCIIe:
|
||||
return (UPA_CR_GET_MID(ldxa(0, ASI_UPA_CONFIG_REG)));
|
||||
case CPU_IMPL_ULTRASPARCIII:
|
||||
case CPU_IMPL_ULTRASPARCIIIp:
|
||||
return (FIREPLANE_CR_GET_AID(ldxa(AA_FIREPLANE_CONFIG,
|
||||
ASI_FIREPLANE_CONFIG_REG)));
|
||||
case CPU_IMPL_ULTRASPARCIIIi:
|
||||
case CPU_IMPL_ULTRASPARCIIIip:
|
||||
return (JBUS_CR_GET_JID(ldxa(0, ASI_JBUS_CONFIG_REG)));
|
||||
case CPU_IMPL_ULTRASPARCIV:
|
||||
case CPU_IMPL_ULTRASPARCIVp:
|
||||
return (INTR_ID_GET_ID(ldxa(AA_INTR_ID, ASI_INTR_ID)));
|
||||
default:
|
||||
return (0);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
tlb_init_sun4u(void)
|
||||
{
|
||||
phandle_t bsp;
|
||||
|
||||
cpu_impl = VER_IMPL(rdpr(ver));
|
||||
switch (cpu_impl) {
|
||||
case CPU_IMPL_SPARC64:
|
||||
case CPU_IMPL_ULTRASPARCI:
|
||||
case CPU_IMPL_ULTRASPARCII:
|
||||
case CPU_IMPL_ULTRASPARCIIi:
|
||||
case CPU_IMPL_ULTRASPARCIIe:
|
||||
tlb_locked = TLB_DAR_T32;
|
||||
break;
|
||||
case CPU_IMPL_ULTRASPARCIII:
|
||||
case CPU_IMPL_ULTRASPARCIIIp:
|
||||
case CPU_IMPL_ULTRASPARCIIIi:
|
||||
case CPU_IMPL_ULTRASPARCIIIip:
|
||||
case CPU_IMPL_ULTRASPARCIV:
|
||||
case CPU_IMPL_ULTRASPARCIVp:
|
||||
tlb_locked = TLB_DAR_T16;
|
||||
break;
|
||||
case CPU_IMPL_SPARC64V:
|
||||
tlb_locked = TLB_DAR_FTLB;
|
||||
break;
|
||||
}
|
||||
bsp = find_bsp_sun4u(OF_child(root), cpu_get_mid_sun4u());
|
||||
if (bsp == 0)
|
||||
panic("%s: no node for bootcpu?!?!", __func__);
|
||||
|
||||
if (OF_getprop(bsp, "#dtlb-entries", &dtlb_slot_max,
|
||||
sizeof(dtlb_slot_max)) == -1 ||
|
||||
OF_getprop(bsp, "#itlb-entries", &itlb_slot_max,
|
||||
sizeof(itlb_slot_max)) == -1)
|
||||
panic("%s: can't get TLB slot max.", __func__);
|
||||
|
||||
if (cpu_impl == CPU_IMPL_ULTRASPARCIIIp) {
|
||||
#ifdef LOADER_DEBUG
|
||||
printf("pre fixup:\n");
|
||||
pmap_print_tlb_sun4u();
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Relocate the locked entry in it16 slot 0 (if existent)
|
||||
* as part of working around Cheetah+ erratum 34.
|
||||
*/
|
||||
itlb_relocate_locked0_sun4u();
|
||||
|
||||
#ifdef LOADER_DEBUG
|
||||
printf("post fixup:\n");
|
||||
pmap_print_tlb_sun4u();
|
||||
#endif
|
||||
}
|
||||
|
||||
dtlb_store = malloc(dtlb_slot_max * sizeof(*dtlb_store));
|
||||
itlb_store = malloc(itlb_slot_max * sizeof(*itlb_store));
|
||||
if (dtlb_store == NULL || itlb_store == NULL)
|
||||
panic("%s: can't allocate TLB store", __func__);
|
||||
}
|
||||
|
||||
#ifdef LOADER_ZFS_SUPPORT
|
||||
|
||||
static void
|
||||
sparc64_zfs_probe(void)
|
||||
{
|
||||
struct vtoc8 vtoc;
|
||||
char alias[64], devname[sizeof(alias) + sizeof(":x") - 1];
|
||||
char type[sizeof("device_type")];
|
||||
char *bdev, *dev, *odev;
|
||||
uint64_t guid, *guidp;
|
||||
int fd, len, part;
|
||||
phandle_t aliases, options;
|
||||
|
||||
guid = 0;
|
||||
|
||||
/*
|
||||
* Get the GUIDs of the ZFS pools on any additional disks listed in
|
||||
* the boot-device environment variable.
|
||||
*/
|
||||
if ((aliases = OF_finddevice("/aliases")) == -1)
|
||||
goto out;
|
||||
options = OF_finddevice("/options");
|
||||
len = OF_getproplen(options, "boot-device");
|
||||
if (len <= 0)
|
||||
goto out;
|
||||
bdev = odev = malloc(len + 1);
|
||||
if (bdev == NULL)
|
||||
goto out;
|
||||
if (OF_getprop(options, "boot-device", bdev, len) <= 0)
|
||||
goto out;
|
||||
bdev[len] = '\0';
|
||||
while ((dev = strsep(&bdev, " ")) != NULL) {
|
||||
if (*dev == '\0')
|
||||
continue;
|
||||
strcpy(alias, dev);
|
||||
(void)OF_getprop(aliases, dev, alias, sizeof(alias));
|
||||
if (OF_getprop(OF_finddevice(alias), "device_type", type,
|
||||
sizeof(type)) == -1)
|
||||
continue;
|
||||
if (strcmp(type, "block") != 0)
|
||||
continue;
|
||||
|
||||
/* Find freebsd-zfs slices in the VTOC. */
|
||||
fd = open(alias, O_RDONLY);
|
||||
if (fd == -1)
|
||||
continue;
|
||||
lseek(fd, 0, SEEK_SET);
|
||||
if (read(fd, &vtoc, sizeof(vtoc)) != sizeof(vtoc)) {
|
||||
close(fd);
|
||||
continue;
|
||||
}
|
||||
close(fd);
|
||||
|
||||
for (part = 0; part < 8; part++) {
|
||||
if (part == 2 || vtoc.part[part].tag !=
|
||||
VTOC_TAG_FREEBSD_ZFS)
|
||||
continue;
|
||||
(void)sprintf(devname, "%s:%c", alias, part + 'a');
|
||||
/* Get the GUID of the ZFS pool on the boot device. */
|
||||
if (strcmp(devname, bootpath) == 0)
|
||||
guidp = &guid;
|
||||
else
|
||||
guidp = NULL;
|
||||
if (zfs_probe_dev(devname, guidp) == ENXIO)
|
||||
break;
|
||||
}
|
||||
}
|
||||
free(odev);
|
||||
|
||||
out:
|
||||
if (guid != 0) {
|
||||
zfs_currdev.pool_guid = guid;
|
||||
zfs_currdev.root_guid = 0;
|
||||
zfs_currdev.dd.d_dev = &zfs_dev;
|
||||
}
|
||||
}
|
||||
#endif /* LOADER_ZFS_SUPPORT */
|
||||
|
||||
int
|
||||
main(int (*openfirm)(void *))
|
||||
{
|
||||
char compatible[32];
|
||||
struct devsw **dp;
|
||||
|
||||
/*
|
||||
* Tell the Open Firmware functions where they find the OFW gate.
|
||||
*/
|
||||
OF_init(openfirm);
|
||||
|
||||
archsw.arch_getdev = ofw_getdev;
|
||||
archsw.arch_copyin = sparc64_copyin;
|
||||
archsw.arch_copyout = ofw_copyout;
|
||||
archsw.arch_readin = sparc64_readin;
|
||||
archsw.arch_autoload = sparc64_autoload;
|
||||
#ifdef LOADER_ZFS_SUPPORT
|
||||
archsw.arch_zfs_probe = sparc64_zfs_probe;
|
||||
#endif
|
||||
|
||||
if (init_heap() == (vm_offset_t)-1)
|
||||
OF_exit();
|
||||
setheap((void *)heapva, (void *)(heapva + HEAPSZ));
|
||||
|
||||
/*
|
||||
* Probe for a console.
|
||||
*/
|
||||
cons_probe();
|
||||
|
||||
if ((root = OF_peer(0)) == -1)
|
||||
panic("%s: can't get root phandle", __func__);
|
||||
OF_getprop(root, "compatible", compatible, sizeof(compatible));
|
||||
mmu_ops = &mmu_ops_sun4u;
|
||||
|
||||
mmu_ops->tlb_init();
|
||||
|
||||
/*
|
||||
* Set up the current device.
|
||||
*/
|
||||
OF_getprop(chosen, "bootpath", bootpath, sizeof(bootpath));
|
||||
|
||||
/*
|
||||
* Initialize devices.
|
||||
*/
|
||||
for (dp = devsw; *dp != NULL; dp++)
|
||||
if ((*dp)->dv_init != 0)
|
||||
(*dp)->dv_init();
|
||||
|
||||
#ifdef LOADER_ZFS_SUPPORT
|
||||
if (zfs_currdev.pool_guid != 0) {
|
||||
(void)strncpy(bootpath, zfs_fmtdev(&zfs_currdev),
|
||||
sizeof(bootpath) - 1);
|
||||
bootpath[sizeof(bootpath) - 1] = '\0';
|
||||
} else
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Sun compatible bootable CD-ROMs have a disk label placed before
|
||||
* the ISO 9660 data, with the actual file system being in the first
|
||||
* partition, while the other partitions contain pseudo disk labels
|
||||
* with embedded boot blocks for different architectures, which may
|
||||
* be followed by UFS file systems.
|
||||
* The firmware will set the boot path to the partition it boots from
|
||||
* ('f' in the sun4u/sun4v case), but we want the kernel to be loaded
|
||||
* from the ISO 9660 file system ('a'), so the boot path needs to be
|
||||
* altered.
|
||||
*/
|
||||
if (bootpath[strlen(bootpath) - 2] == ':' &&
|
||||
bootpath[strlen(bootpath) - 1] == 'f')
|
||||
bootpath[strlen(bootpath) - 1] = 'a';
|
||||
|
||||
env_setenv("currdev", EV_VOLATILE, bootpath,
|
||||
ofw_setcurrdev, env_nounset);
|
||||
env_setenv("loaddev", EV_VOLATILE, bootpath,
|
||||
env_noset, env_nounset);
|
||||
|
||||
printf("\n%s", bootprog_info);
|
||||
printf("bootpath=\"%s\"\n", bootpath);
|
||||
|
||||
/* Give control to the machine independent loader code. */
|
||||
interact();
|
||||
return (1);
|
||||
}
|
||||
|
||||
COMMAND_SET(heap, "heap", "show heap usage", command_heap);
|
||||
|
||||
static int
|
||||
command_heap(int argc, char *argv[])
|
||||
{
|
||||
|
||||
mallocstats();
|
||||
printf("heap base at %p, top at %p, upper limit at %p\n", heapva,
|
||||
sbrk(0), heapva + HEAPSZ);
|
||||
return(CMD_OK);
|
||||
}
|
||||
|
||||
COMMAND_SET(reboot, "reboot", "reboot the system", command_reboot);
|
||||
|
||||
static int
|
||||
command_reboot(int argc, char *argv[])
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; devsw[i] != NULL; ++i)
|
||||
if (devsw[i]->dv_cleanup != NULL)
|
||||
(devsw[i]->dv_cleanup)();
|
||||
|
||||
printf("Rebooting...\n");
|
||||
OF_exit();
|
||||
}
|
||||
|
||||
/* provide this for panic, as it's not in the startup code */
|
||||
void
|
||||
exit(int code)
|
||||
{
|
||||
|
||||
OF_exit();
|
||||
}
|
||||
|
||||
#ifdef LOADER_DEBUG
|
||||
static const char *const page_sizes[] = {
|
||||
" 8k", " 64k", "512k", " 4m"
|
||||
};
|
||||
|
||||
static void
|
||||
pmap_print_tte_sun4u(tte_t tag, tte_t tte)
|
||||
{
|
||||
|
||||
printf("%s %s ",
|
||||
page_sizes[(tte >> TD_SIZE_SHIFT) & TD_SIZE_MASK],
|
||||
tag & TD_G ? "G" : " ");
|
||||
printf(tte & TD_W ? "W " : " ");
|
||||
printf(tte & TD_P ? "\e[33mP\e[0m " : " ");
|
||||
printf(tte & TD_E ? "E " : " ");
|
||||
printf(tte & TD_CV ? "CV " : " ");
|
||||
printf(tte & TD_CP ? "CP " : " ");
|
||||
printf(tte & TD_L ? "\e[32mL\e[0m " : " ");
|
||||
printf(tte & TD_IE ? "IE " : " ");
|
||||
printf(tte & TD_NFO ? "NFO " : " ");
|
||||
printf("pa=0x%lx va=0x%lx ctx=%ld\n",
|
||||
TD_PA(tte), TLB_TAR_VA(tag), TLB_TAR_CTX(tag));
|
||||
}
|
||||
|
||||
static void
|
||||
pmap_print_tlb_sun4u(void)
|
||||
{
|
||||
tte_t tag, tte;
|
||||
u_long pstate;
|
||||
int i;
|
||||
|
||||
pstate = rdpr(pstate);
|
||||
for (i = 0; i < itlb_slot_max; i++) {
|
||||
wrpr(pstate, pstate & ~PSTATE_IE, 0);
|
||||
tte = itlb_get_data_sun4u(tlb_locked, i);
|
||||
wrpr(pstate, pstate, 0);
|
||||
if (!(tte & TD_V))
|
||||
continue;
|
||||
tag = ldxa(TLB_DAR_SLOT(tlb_locked, i),
|
||||
ASI_ITLB_TAG_READ_REG);
|
||||
printf("iTLB-%2u: ", i);
|
||||
pmap_print_tte_sun4u(tag, tte);
|
||||
}
|
||||
for (i = 0; i < dtlb_slot_max; i++) {
|
||||
wrpr(pstate, pstate & ~PSTATE_IE, 0);
|
||||
tte = dtlb_get_data_sun4u(tlb_locked, i);
|
||||
wrpr(pstate, pstate, 0);
|
||||
if (!(tte & TD_V))
|
||||
continue;
|
||||
tag = ldxa(TLB_DAR_SLOT(tlb_locked, i),
|
||||
ASI_DTLB_TAG_READ_REG);
|
||||
printf("dTLB-%2u: ", i);
|
||||
pmap_print_tte_sun4u(tag, tte);
|
||||
}
|
||||
}
|
||||
#endif
|
@ -1,6 +0,0 @@
|
||||
$FreeBSD$
|
||||
|
||||
NOTE ANY CHANGES YOU MAKE TO THE BOOTBLOCKS HERE. The format of this
|
||||
file is important. Make sure the current version number is on line 6.
|
||||
|
||||
1.0: I hate the loader.
|
@ -1,9 +0,0 @@
|
||||
# $FreeBSD$
|
||||
|
||||
.PATH: ${.CURDIR}/../boot1
|
||||
|
||||
PROGNAME= zfsboot
|
||||
CFLAGS+= -DZFSBOOT
|
||||
FILES= zfsboot
|
||||
|
||||
.include "${.CURDIR}/../boot1/Makefile"
|
@ -8,7 +8,7 @@ CSCOPEDIRS= bsm cam cddl compat conf contrib crypto ddb dev fs gdb \
|
||||
rpc security sys ufs vm xdr xen ${CSCOPE_ARCHDIR}
|
||||
.if !defined(CSCOPE_ARCHDIR)
|
||||
.if defined(ALL_ARCH)
|
||||
CSCOPE_ARCHDIR = amd64 arm arm64 i386 mips powerpc riscv sparc64 x86
|
||||
CSCOPE_ARCHDIR = amd64 arm arm64 i386 mips powerpc riscv x86
|
||||
.else
|
||||
CSCOPE_ARCHDIR = ${MACHINE}
|
||||
.if ${MACHINE} != ${MACHINE_CPUARCH}
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user