diff --git a/Makefile.inc1 b/Makefile.inc1 index 5433eb958204..4f7aaae6d654 100644 --- a/Makefile.inc1 +++ b/Makefile.inc1 @@ -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 diff --git a/ObsoleteFiles.inc b/ObsoleteFiles.inc index 4aebf8a83601..82c95ac28f96 100644 --- a/ObsoleteFiles.inc +++ b/ObsoleteFiles.inc @@ -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 diff --git a/RELNOTES b/RELNOTES index 65e68b60449a..176c02824e1a 100644 --- a/RELNOTES +++ b/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. diff --git a/bin/pwait/pwait.c b/bin/pwait/pwait.c index 900bc96d0025..f39922b48eb9 100644 --- a/bin/pwait/pwait.c +++ b/bin/pwait/pwait.c @@ -41,7 +41,6 @@ __FBSDID("$FreeBSD$"); #include #include -#include #include #include #include diff --git a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_link.c b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_link.c index 7828da651977..b8d5b75291ca 100644 --- a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_link.c +++ b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_link.c @@ -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 ? diff --git a/contrib/elftoolchain/addr2line/addr2line.c b/contrib/elftoolchain/addr2line/addr2line.c index c6cd5a87712b..e19bd8498876 100644 --- a/contrib/elftoolchain/addr2line/addr2line.c +++ b/contrib/elftoolchain/addr2line/addr2line.c @@ -25,6 +25,7 @@ */ #include +#include #include #include @@ -39,7 +40,6 @@ #include #include -#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 diff --git a/contrib/elftoolchain/elfcopy/main.c b/contrib/elftoolchain/elfcopy/main.c index 2efdbda33bf3..7348bbd28156 100644 --- a/contrib/elftoolchain/elfcopy/main.c +++ b/contrib/elftoolchain/elfcopy/main.c @@ -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); diff --git a/contrib/elftoolchain/elfcopy/sections.c b/contrib/elftoolchain/elfcopy/sections.c index 3ffa3858eba5..a3ebfe126721 100644 --- a/contrib/elftoolchain/elfcopy/sections.c +++ b/contrib/elftoolchain/elfcopy/sections.c @@ -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"); diff --git a/contrib/elftoolchain/libdwarf/dwarf_pro_attr.c b/contrib/elftoolchain/libdwarf/dwarf_pro_attr.c index f46672bba504..6d5fb4d687b2 100644 --- a/contrib/elftoolchain/libdwarf/dwarf_pro_attr.c +++ b/contrib/elftoolchain/libdwarf/dwarf_pro_attr.c @@ -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) diff --git a/contrib/elftoolchain/libdwarf/dwarf_pro_expr.c b/contrib/elftoolchain/libdwarf/dwarf_pro_expr.c index eb1f59c7eb3e..6f8ed35f820e 100644 --- a/contrib/elftoolchain/libdwarf/dwarf_pro_expr.c +++ b/contrib/elftoolchain/libdwarf/dwarf_pro_expr.c @@ -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); diff --git a/contrib/elftoolchain/libdwarf/libdwarf_abbrev.c b/contrib/elftoolchain/libdwarf/libdwarf_abbrev.c index 9e4b6ab6108f..ff3a385f197f 100644 --- a/contrib/elftoolchain/libdwarf/libdwarf_abbrev.c +++ b/contrib/elftoolchain/libdwarf/libdwarf_abbrev.c @@ -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); } diff --git a/contrib/elftoolchain/libdwarf/libdwarf_frame.c b/contrib/elftoolchain/libdwarf/libdwarf_frame.c index cfa69714b302..9c2a623b43d0 100644 --- a/contrib/elftoolchain/libdwarf/libdwarf_frame.c +++ b/contrib/elftoolchain/libdwarf/libdwarf_frame.c @@ -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 */ diff --git a/contrib/elftoolchain/libelftc/libelftc_dem_arm.c b/contrib/elftoolchain/libelftc/libelftc_dem_arm.c index 5550505d59f1..ec87f6f7a11b 100644 --- a/contrib/elftoolchain/libelftc/libelftc_dem_arm.c +++ b/contrib/elftoolchain/libelftc/libelftc_dem_arm.c @@ -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; diff --git a/contrib/elftoolchain/libelftc/libelftc_dem_gnu2.c b/contrib/elftoolchain/libelftc/libelftc_dem_gnu2.c index 5c77b67ce848..a414c7cdab80 100644 --- a/contrib/elftoolchain/libelftc/libelftc_dem_gnu2.c +++ b/contrib/elftoolchain/libelftc/libelftc_dem_gnu2.c @@ -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); } diff --git a/contrib/elftoolchain/libelftc/libelftc_dem_gnu3.c b/contrib/elftoolchain/libelftc/libelftc_dem_gnu3.c index 73ed371a1cfc..8127919f1cf6 100644 --- a/contrib/elftoolchain/libelftc/libelftc_dem_gnu3.c +++ b/contrib/elftoolchain/libelftc/libelftc_dem_gnu3.c @@ -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); } diff --git a/contrib/elftoolchain/readelf/readelf.c b/contrib/elftoolchain/readelf/readelf.c index 57f35c9a460b..3df4660d2c6c 100644 --- a/contrib/elftoolchain/readelf/readelf.c +++ b/contrib/elftoolchain/readelf/readelf.c @@ -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 diff --git a/contrib/elftoolchain/size/size.c b/contrib/elftoolchain/size/size.c index b9b5041b1c21..b6309d0b9d21 100644 --- a/contrib/elftoolchain/size/size.c +++ b/contrib/elftoolchain/size/size.c @@ -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) { diff --git a/contrib/netbsd-tests/lib/libc/c063/t_o_search.c b/contrib/netbsd-tests/lib/libc/c063/t_o_search.c index 10e4607ab1a0..714305e2a0ad 100644 --- a/contrib/netbsd-tests/lib/libc/c063/t_o_search.c +++ b/contrib/netbsd-tests/lib/libc/c063/t_o_search.c @@ -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 -__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 -#include +#include #include +#include #include #include #include @@ -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(); } diff --git a/contrib/sqlite3/Makefile.msc b/contrib/sqlite3/Makefile.msc index 37a3c1b18a8d..2a7042efb064 100644 --- a/contrib/sqlite3/Makefile.msc +++ b/contrib/sqlite3/Makefile.msc @@ -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) diff --git a/contrib/sqlite3/configure b/contrib/sqlite3/configure index 54eda11b9119..e4755326f3f8 100755 --- a/contrib/sqlite3/configure +++ b/contrib/sqlite3/configure @@ -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 . # @@ -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\\" diff --git a/contrib/sqlite3/configure.ac b/contrib/sqlite3/configure.ac index 9586dd900678..26f96a6e48a7 100644 --- a/contrib/sqlite3/configure.ac +++ b/contrib/sqlite3/configure.ac @@ -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 #----------------------------------------------------------------------- diff --git a/contrib/sqlite3/shell.c b/contrib/sqlite3/shell.c index 4e3d3979b644..053180cc560c 100644 --- a/contrib/sqlite3/shell.c +++ b/contrib/sqlite3/shell.c @@ -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; icolWidth) ){ 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; iNameopenMode = 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, diff --git a/contrib/sqlite3/sqlite3.c b/contrib/sqlite3/sqlite3.c index c3e9f317fce3..8fd740b30015 100644 --- a/contrib/sqlite3/sqlite3.c +++ b/contrib/sqlite3/sqlite3.c @@ -1,6 +1,6 @@ /****************************************************************************** ** This file is an amalgamation of many separate C source files from SQLite -** version 3.31.0. By combining all the individual C code files into this +** version 3.30.1. By combining all the individual C code files into this ** single large file, the entire code can be compiled as a single translation ** unit. This allows many compilers to do optimizations that would not be ** possible if the files were compiled separately. Performance improvements @@ -1165,9 +1165,9 @@ extern "C" { ** [sqlite3_libversion_number()], [sqlite3_sourceid()], ** [sqlite_version()] and [sqlite_source_id()]. */ -#define SQLITE_VERSION "3.31.0" -#define SQLITE_VERSION_NUMBER 3031000 -#define SQLITE_SOURCE_ID "2020-01-22 18:38:59 f6affdd41608946fcfcea914ece149038a8b25a62bbe719ed2561c649b86d824" +#define SQLITE_VERSION "3.30.1" +#define SQLITE_VERSION_NUMBER 3030001 +#define SQLITE_SOURCE_ID "2019-10-10 20:19:45 18db032d058f1436ce3dea84081f4ee5a0f2259ad97301d43c426bc7f3df1b0b" /* ** CAPI3REF: Run-Time Library Version Numbers @@ -1558,7 +1558,6 @@ SQLITE_API int sqlite3_exec( #define SQLITE_CANTOPEN_FULLPATH (SQLITE_CANTOPEN | (3<<8)) #define SQLITE_CANTOPEN_CONVPATH (SQLITE_CANTOPEN | (4<<8)) #define SQLITE_CANTOPEN_DIRTYWAL (SQLITE_CANTOPEN | (5<<8)) /* Not Used */ -#define SQLITE_CANTOPEN_SYMLINK (SQLITE_CANTOPEN | (6<<8)) #define SQLITE_CORRUPT_VTAB (SQLITE_CORRUPT | (1<<8)) #define SQLITE_CORRUPT_SEQUENCE (SQLITE_CORRUPT | (2<<8)) #define SQLITE_READONLY_RECOVERY (SQLITE_READONLY | (1<<8)) @@ -1578,13 +1577,11 @@ SQLITE_API int sqlite3_exec( #define SQLITE_CONSTRAINT_UNIQUE (SQLITE_CONSTRAINT | (8<<8)) #define SQLITE_CONSTRAINT_VTAB (SQLITE_CONSTRAINT | (9<<8)) #define SQLITE_CONSTRAINT_ROWID (SQLITE_CONSTRAINT |(10<<8)) -#define SQLITE_CONSTRAINT_PINNED (SQLITE_CONSTRAINT |(11<<8)) #define SQLITE_NOTICE_RECOVER_WAL (SQLITE_NOTICE | (1<<8)) #define SQLITE_NOTICE_RECOVER_ROLLBACK (SQLITE_NOTICE | (2<<8)) #define SQLITE_WARNING_AUTOINDEX (SQLITE_WARNING | (1<<8)) #define SQLITE_AUTH_USER (SQLITE_AUTH | (1<<8)) #define SQLITE_OK_LOAD_PERMANENTLY (SQLITE_OK | (1<<8)) -#define SQLITE_OK_SYMLINK (SQLITE_OK | (2<<8)) /* ** CAPI3REF: Flags For File Open Operations @@ -1613,7 +1610,6 @@ SQLITE_API int sqlite3_exec( #define SQLITE_OPEN_SHAREDCACHE 0x00020000 /* Ok for sqlite3_open_v2() */ #define SQLITE_OPEN_PRIVATECACHE 0x00040000 /* Ok for sqlite3_open_v2() */ #define SQLITE_OPEN_WAL 0x00080000 /* VFS only */ -#define SQLITE_OPEN_NOFOLLOW 0x01000000 /* Ok for sqlite3_open_v2() */ /* Reserved: 0x00F00000 */ @@ -2025,16 +2021,16 @@ struct sqlite3_io_methods { ** ^The [SQLITE_FCNTL_BUSYHANDLER] ** file-control may be invoked by SQLite on the database file handle ** shortly after it is opened in order to provide a custom VFS with access -** to the connection's busy-handler callback. The argument is of type (void**) +** to the connections busy-handler callback. The argument is of type (void **) ** - an array of two (void *) values. The first (void *) actually points -** to a function of type (int (*)(void *)). In order to invoke the connection's +** to a function of type (int (*)(void *)). In order to invoke the connections ** busy-handler, this function should be invoked with the second (void *) in ** the array as the only argument. If it returns non-zero, then the operation ** should be retried. If it returns zero, the custom VFS should abandon the ** current operation. ** **
  • [[SQLITE_FCNTL_TEMPFILENAME]] -** ^Applications can invoke the [SQLITE_FCNTL_TEMPFILENAME] file-control +** ^Application can invoke the [SQLITE_FCNTL_TEMPFILENAME] file-control ** to have SQLite generate a ** temporary filename using the same algorithm that is followed to generate ** temporary filenames for TEMP tables and other internal uses. The @@ -2147,18 +2143,12 @@ struct sqlite3_io_methods { ** not provide a mechanism to detect changes to MAIN only. Also, the ** [sqlite3_total_changes()] interface responds to internal changes only and ** omits changes made by other database connections. The -** [PRAGMA data_version] command provides a mechanism to detect changes to +** [PRAGMA data_version] command provide a mechanism to detect changes to ** a single attached database that occur due to other database connections, ** but omits changes implemented by the database connection on which it is ** called. This file control is the only mechanism to detect changes that ** happen either internally or externally and that are associated with ** a particular attached database. -** -**
  • [[SQLITE_FCNTL_CKPT_DONE]] -** The [SQLITE_FCNTL_CKPT_DONE] opcode is invoked from within a checkpoint -** in wal mode after the client has finished copying pages from the wal -** file to the database file, but before the *-shm file is updated to -** record the fact that the pages have been checkpointed. ** */ #define SQLITE_FCNTL_LOCKSTATE 1 @@ -2196,7 +2186,6 @@ struct sqlite3_io_methods { #define SQLITE_FCNTL_LOCK_TIMEOUT 34 #define SQLITE_FCNTL_DATA_VERSION 35 #define SQLITE_FCNTL_SIZE_LIMIT 36 -#define SQLITE_FCNTL_CKPT_DONE 37 /* deprecated names */ #define SQLITE_GET_LOCKPROXYFILE SQLITE_FCNTL_GET_LOCKPROXYFILE @@ -2242,10 +2231,10 @@ typedef struct sqlite3_api_routines sqlite3_api_routines; ** to 3 with SQLite [version 3.7.6] on [dateof:3.7.6]. Additional fields ** may be appended to the sqlite3_vfs object and the iVersion value ** may increase again in future versions of SQLite. -** Note that due to an oversight, the structure -** of the sqlite3_vfs object changed in the transition from +** Note that the structure +** of the sqlite3_vfs object changes in the transition from ** SQLite [version 3.5.9] to [version 3.6.0] on [dateof:3.6.0] -** and yet the iVersion field was not increased. +** and yet the iVersion field was not modified. ** ** The szOsFile field is the size of the subclassed [sqlite3_file] ** structure used by this VFS. mxPathname is the maximum length of @@ -2336,7 +2325,7 @@ typedef struct sqlite3_api_routines sqlite3_api_routines; ** for exclusive access. ** ** ^At least szOsFile bytes of memory are allocated by SQLite -** to hold the [sqlite3_file] structure passed as the third +** to hold the [sqlite3_file] structure passed as the third ** argument to xOpen. The xOpen method does not have to ** allocate the structure; it should just fill it in. Note that ** the xOpen method must set the sqlite3_file.pMethods to either @@ -2673,7 +2662,7 @@ SQLITE_API int sqlite3_db_config(sqlite3*, int op, ...); ** that causes the corresponding memory allocation to fail. ** ** The xInit method initializes the memory allocator. For example, -** it might allocate any required mutexes or initialize internal data +** it might allocate any require mutexes or initialize internal data ** structures. The xShutdown method is invoked (indirectly) by ** [sqlite3_shutdown()] and should deallocate any resources acquired ** by xInit. The pAppData pointer is used as the only parameter to @@ -2795,7 +2784,6 @@ struct sqlite3_mem_methods { ** memory allocation statistics. ^(When memory allocation statistics are ** disabled, the following SQLite interfaces become non-operational: **
      -**
    • [sqlite3_hard_heap_limit64()] **
    • [sqlite3_memory_used()] **
    • [sqlite3_memory_highwater()] **
    • [sqlite3_soft_heap_limit64()] @@ -2814,7 +2802,7 @@ struct sqlite3_mem_methods { **
      ^The SQLITE_CONFIG_PAGECACHE option specifies a memory pool ** that SQLite can use for the database page cache with the default page ** cache implementation. -** This configuration option is a no-op if an application-defined page +** This configuration option is a no-op if an application-define page ** cache implementation is loaded using the [SQLITE_CONFIG_PCACHE2]. ** ^There are three arguments to SQLITE_CONFIG_PAGECACHE: A pointer to ** 8-byte aligned memory (pMem), the size of each page cache line (sz), @@ -3299,7 +3287,7 @@ struct sqlite3_mem_methods { ** [[SQLITE_DBCONFIG_DQS_DML]] **
      SQLITE_DBCONFIG_DQS_DML **
      The SQLITE_DBCONFIG_DQS_DML option activates or deactivates -** the legacy [double-quoted string literal] misfeature for DML statements +** the legacy [double-quoted string literal] misfeature for DML statement ** only, that is DELETE, INSERT, SELECT, and UPDATE statements. The ** default value of this setting is determined by the [-DSQLITE_DQS] ** compile-time option. @@ -3313,49 +3301,6 @@ struct sqlite3_mem_methods { ** default value of this setting is determined by the [-DSQLITE_DQS] ** compile-time option. **
      -** -** [[SQLITE_DBCONFIG_TRUSTED_SCHEMA]] -**
      SQLITE_DBCONFIG_TRUSTED_SCHEMA -**
      The SQLITE_DBCONFIG_TRUSTED_SCHEMA option tells SQLite to -** assume that database schemas (the contents of the [sqlite_master] tables) -** are untainted by malicious content. -** When the SQLITE_DBCONFIG_TRUSTED_SCHEMA option is disabled, SQLite -** takes additional defensive steps to protect the application from harm -** including: -**
        -**
      • Prohibit the use of SQL functions inside triggers, views, -** CHECK constraints, DEFAULT clauses, expression indexes, -** partial indexes, or generated columns -** unless those functions are tagged with [SQLITE_INNOCUOUS]. -**
      • Prohibit the use of virtual tables inside of triggers or views -** unless those virtual tables are tagged with [SQLITE_VTAB_INNOCUOUS]. -**
      -** This setting defaults to "on" for legacy compatibility, however -** all applications are advised to turn it off if possible. This setting -** can also be controlled using the [PRAGMA trusted_schema] statement. -**
      -** -** [[SQLITE_DBCONFIG_LEGACY_FILE_FORMAT]] -**
      SQLITE_DBCONFIG_LEGACY_FILE_FORMAT -**
      The SQLITE_DBCONFIG_LEGACY_FILE_FORMAT option activates or deactivates -** the legacy file format flag. When activated, this flag causes all newly -** created database file to have a schema format version number (the 4-byte -** integer found at offset 44 into the database header) of 1. This in turn -** means that the resulting database file will be readable and writable by -** any SQLite version back to 3.0.0 ([dateof:3.0.0]). Without this setting, -** newly created databases are generally not understandable by SQLite versions -** prior to 3.3.0 ([dateof:3.3.0]). As these words are written, there -** is now scarcely any need to generated database files that are compatible -** all the way back to version 3.0.0, and so this setting is of little -** practical use, but is provided so that SQLite can continue to claim the -** ability to generate new database files that are compatible with version -** 3.0.0. -**

      Note that when the SQLITE_DBCONFIG_LEGACY_FILE_FORMAT setting is on, -** the [VACUUM] command will fail with an obscure error when attempting to -** process a table with generated columns and a descending index. This is -** not considered a bug since SQLite versions 3.3.0 and earlier do not support -** either generated columns or decending indexes. -**

      ** */ #define SQLITE_DBCONFIG_MAINDBNAME 1000 /* const char* */ @@ -3374,9 +3319,7 @@ struct sqlite3_mem_methods { #define SQLITE_DBCONFIG_DQS_DML 1013 /* int int* */ #define SQLITE_DBCONFIG_DQS_DDL 1014 /* int int* */ #define SQLITE_DBCONFIG_ENABLE_VIEW 1015 /* int int* */ -#define SQLITE_DBCONFIG_LEGACY_FILE_FORMAT 1016 /* int int* */ -#define SQLITE_DBCONFIG_TRUSTED_SCHEMA 1017 /* int int* */ -#define SQLITE_DBCONFIG_MAX 1017 /* Largest DBCONFIG */ +#define SQLITE_DBCONFIG_MAX 1015 /* Largest DBCONFIG */ /* ** CAPI3REF: Enable Or Disable Extended Result Codes @@ -3582,7 +3525,7 @@ SQLITE_API int sqlite3_total_changes(sqlite3*); ** ^The sqlite3_interrupt(D) call is in effect until all currently running ** SQL statements on [database connection] D complete. ^Any new SQL statements ** that are started after the sqlite3_interrupt() call and before the -** running statement count reaches zero are interrupted as if they had been +** running statements reaches zero are interrupted as if they had been ** running prior to the sqlite3_interrupt() call. ^New SQL statements ** that are started after the running statement count reaches zero are ** not effected by the sqlite3_interrupt(). @@ -3750,9 +3693,9 @@ SQLITE_API int sqlite3_busy_timeout(sqlite3*, int ms); ** Cindy | 21 ** ** -** There are two columns (M==2) and three rows (N==3). Thus the +** There are two column (M==2) and three rows (N==3). Thus the ** result table has 8 entries. Suppose the result table is stored -** in an array named azResult. Then azResult holds this content: +** in an array names azResult. Then azResult holds this content: ** **
       **        azResult[0] = "Name";
      @@ -3845,7 +3788,7 @@ SQLITE_API char *sqlite3_vsnprintf(int,char*,const char*, va_list);
       **
       ** The SQLite core uses these three routines for all of its own
       ** internal memory allocation needs. "Core" in the previous sentence
      -** does not include operating-system specific [VFS] implementation.  The
      +** does not include operating-system specific VFS implementation.  The
       ** Windows VFS uses native malloc() and free() for some operations.
       **
       ** ^The sqlite3_malloc() routine returns a pointer to a block
      @@ -3906,6 +3849,19 @@ SQLITE_API char *sqlite3_vsnprintf(int,char*,const char*, va_list);
       ** 4 byte boundary if the [SQLITE_4_BYTE_ALIGNED_MALLOC] compile-time
       ** option is used.
       **
      +** In SQLite version 3.5.0 and 3.5.1, it was possible to define
      +** the SQLITE_OMIT_MEMORY_ALLOCATION which would cause the built-in
      +** implementation of these routines to be omitted.  That capability
      +** is no longer provided.  Only built-in memory allocators can be used.
      +**
      +** Prior to SQLite version 3.7.10, the Windows OS interface layer called
      +** the system malloc() and free() directly when converting
      +** filenames between the UTF-8 encoding used by SQLite
      +** and whatever filename encoding is used by the particular Windows
      +** installation.  Memory allocation errors were detected, but
      +** they were reported back as [SQLITE_CANTOPEN] or
      +** [SQLITE_IOERR] rather than [SQLITE_NOMEM].
      +**
       ** The pointer arguments to [sqlite3_free()] and [sqlite3_realloc()]
       ** must be either NULL or else pointers obtained from a prior
       ** invocation of [sqlite3_malloc()] or [sqlite3_realloc()] that have
      @@ -3954,7 +3910,7 @@ SQLITE_API sqlite3_int64 sqlite3_memory_highwater(int resetFlag);
       ** SQLite contains a high-quality pseudo-random number generator (PRNG) used to
       ** select random [ROWID | ROWIDs] when inserting new records into a table that
       ** already uses the largest possible [ROWID].  The PRNG is also used for
      -** the built-in random() and randomblob() SQL functions.  This interface allows
      +** the build-in random() and randomblob() SQL functions.  This interface allows
       ** applications to access the same PRNG for other purposes.
       **
       ** ^A call to this routine stores N bytes of randomness into buffer P.
      @@ -4328,8 +4284,10 @@ SQLITE_API void sqlite3_progress_handler(sqlite3*, int, int(*)(void*), void*);
       ** The sqlite3_open_v2() interface works like sqlite3_open()
       ** except that it accepts two additional parameters for additional control
       ** over the new database connection.  ^(The flags parameter to
      -** sqlite3_open_v2() must include, at a minimum, one of the following
      -** three flag combinations:)^
      +** sqlite3_open_v2() can take one of
      +** the following three values, optionally combined with the 
      +** [SQLITE_OPEN_NOMUTEX], [SQLITE_OPEN_FULLMUTEX], [SQLITE_OPEN_SHAREDCACHE],
      +** [SQLITE_OPEN_PRIVATECACHE], and/or [SQLITE_OPEN_URI] flags:)^
       **
       ** 
      ** ^(
      [SQLITE_OPEN_READONLY]
      @@ -4347,51 +4305,23 @@ SQLITE_API void sqlite3_progress_handler(sqlite3*, int, int(*)(void*), void*); ** sqlite3_open() and sqlite3_open16().)^ **
      ** -** In addition to the required flags, the following optional flags are -** also supported: -** -**
      -** ^(
      [SQLITE_OPEN_URI]
      -**
      The filename can be interpreted as a URI if this flag is set.
      )^ -** -** ^(
      [SQLITE_OPEN_MEMORY]
      -**
      The database will be opened as an in-memory database. The database -** is named by the "filename" argument for the purposes of cache-sharing, -** if shared cache mode is enabled, but the "filename" is otherwise ignored. -**
      )^ -** -** ^(
      [SQLITE_OPEN_NOMUTEX]
      -**
      The new database connection will use the "multi-thread" -** [threading mode].)^ This means that separate threads are allowed -** to use SQLite at the same time, as long as each thread is using -** a different [database connection]. -** -** ^(
      [SQLITE_OPEN_FULLMUTEX]
      -**
      The new database connection will use the "serialized" -** [threading mode].)^ This means the multiple threads can safely -** attempt to use the same database connection at the same time. -** (Mutexes will block any actual concurrency, but in this mode -** there is no harm in trying.) -** -** ^(
      [SQLITE_OPEN_SHAREDCACHE]
      -**
      The database is opened [shared cache] enabled, overriding -** the default shared cache setting provided by -** [sqlite3_enable_shared_cache()].)^ -** -** ^(
      [SQLITE_OPEN_PRIVATECACHE]
      -**
      The database is opened [shared cache] disabled, overriding -** the default shared cache setting provided by -** [sqlite3_enable_shared_cache()].)^ -** -** [[OPEN_NOFOLLOW]] ^(
      [SQLITE_OPEN_NOFOLLOW]
      -**
      The database filename is not allowed to be a symbolic link
      -**
      )^ -** ** If the 3rd parameter to sqlite3_open_v2() is not one of the -** required combinations shown above optionally combined with other +** combinations shown above optionally combined with other ** [SQLITE_OPEN_READONLY | SQLITE_OPEN_* bits] ** then the behavior is undefined. ** +** ^If the [SQLITE_OPEN_NOMUTEX] flag is set, then the database connection +** opens in the multi-thread [threading mode] as long as the single-thread +** mode has not been set at compile-time or start-time. ^If the +** [SQLITE_OPEN_FULLMUTEX] flag is set then the database connection opens +** in the serialized [threading mode] unless single-thread was +** previously selected at compile-time or start-time. +** ^The [SQLITE_OPEN_SHAREDCACHE] flag causes the database connection to be +** eligible to use [shared cache mode], regardless of whether or not shared +** cache is enabled using [sqlite3_enable_shared_cache()]. ^The +** [SQLITE_OPEN_PRIVATECACHE] flag causes the database connection to not +** participate in [shared cache mode] even if it is enabled. +** ** ^The fourth parameter to sqlite3_open_v2() is the name of the ** [sqlite3_vfs] object that defines the operating system interface that ** the new database connection should use. ^If the fourth parameter is @@ -4571,16 +4501,17 @@ SQLITE_API int sqlite3_open_v2( /* ** CAPI3REF: Obtain Values For URI Parameters ** -** These are utility routines, useful to [VFS|custom VFS implementations], -** that check if a database file was a URI that contained a specific query +** These are utility routines, useful to VFS implementations, that check +** to see if a database file was a URI that contained a specific query ** parameter, and if so obtains the value of that query parameter. ** ** If F is the database filename pointer passed into the xOpen() method of -** a VFS implementation or it is the return value of [sqlite3_db_filename()] -** and if P is the name of the query parameter, then +** a VFS implementation when the flags parameter to xOpen() has one or +** more of the [SQLITE_OPEN_URI] or [SQLITE_OPEN_MAIN_DB] bits set and +** P is the name of the query parameter, then ** sqlite3_uri_parameter(F,P) returns the value of the P ** parameter if it exists or a NULL pointer if P does not appear as a -** query parameter on F. If P is a query parameter of F and it +** query parameter on F. If P is a query parameter of F ** has no explicit value, then sqlite3_uri_parameter(F,P) returns ** a pointer to an empty string. ** @@ -4592,72 +4523,25 @@ SQLITE_API int sqlite3_open_v2( ** sqlite3_uri_boolean(F,P,B) routines returns false (0) if the value of ** query parameter P is one of "no", "false", or "off" in any case or ** if the value begins with a numeric zero. If P is not a query -** parameter on F or if the value of P does not match any of the +** parameter on F or if the value of P is does not match any of the ** above, then sqlite3_uri_boolean(F,P,B) returns (B!=0). ** ** The sqlite3_uri_int64(F,P,D) routine converts the value of P into a ** 64-bit signed integer and returns that integer, or D if P does not ** exist. If the value of P is something other than an integer, then ** zero is returned. -** -** The sqlite3_uri_key(F,N) returns a pointer to the name (not -** the value) of the N-th query parameter for filename F, or a NULL -** pointer if N is less than zero or greater than the number of query -** parameters minus 1. The N value is zero-based so N should be 0 to obtain -** the name of the first query parameter, 1 for the second parameter, and -** so forth. ** ** If F is a NULL pointer, then sqlite3_uri_parameter(F,P) returns NULL and ** sqlite3_uri_boolean(F,P,B) returns B. If F is not a NULL pointer and -** is not a database file pathname pointer that the SQLite core passed -** into the xOpen VFS method, then the behavior of this routine is undefined -** and probably undesirable. -** -** Beginning with SQLite [version 3.31.0] ([dateof:3.31.0]) the input F -** parameter can also be the name of a rollback journal file or WAL file -** in addition to the main database file. Prior to version 3.31.0, these -** routines would only work if F was the name of the main database file. -** When the F parameter is the name of the rollback journal or WAL file, -** it has access to all the same query parameters as were found on the -** main database file. +** is not a database file pathname pointer that SQLite passed into the xOpen +** VFS method, then the behavior of this routine is undefined and probably +** undesirable. ** ** See the [URI filename] documentation for additional information. */ SQLITE_API const char *sqlite3_uri_parameter(const char *zFilename, const char *zParam); SQLITE_API int sqlite3_uri_boolean(const char *zFile, const char *zParam, int bDefault); SQLITE_API sqlite3_int64 sqlite3_uri_int64(const char*, const char*, sqlite3_int64); -SQLITE_API const char *sqlite3_uri_key(const char *zFilename, int N); - -/* -** CAPI3REF: Translate filenames -** -** These routines are available to [VFS|custom VFS implementations] for -** translating filenames between the main database file, the journal file, -** and the WAL file. -** -** If F is the name of an sqlite database file, journal file, or WAL file -** passed by the SQLite core into the VFS, then sqlite3_filename_database(F) -** returns the name of the corresponding database file. -** -** If F is the name of an sqlite database file, journal file, or WAL file -** passed by the SQLite core into the VFS, or if F is a database filename -** obtained from [sqlite3_db_filename()], then sqlite3_filename_journal(F) -** returns the name of the corresponding rollback journal file. -** -** If F is the name of an sqlite database file, journal file, or WAL file -** that was passed by the SQLite core into the VFS, or if F is a database -** filename obtained from [sqlite3_db_filename()], then -** sqlite3_filename_wal(F) returns the name of the corresponding -** WAL file. -** -** In all of the above, if F is not the name of a database, journal or WAL -** filename passed into the VFS from the SQLite core and F is not the -** return value from [sqlite3_db_filename()], then the result is -** undefined and is likely a memory access violation. -*/ -SQLITE_API const char *sqlite3_filename_database(const char*); -SQLITE_API const char *sqlite3_filename_journal(const char*); -SQLITE_API const char *sqlite3_filename_wal(const char*); /* @@ -4976,12 +4860,12 @@ SQLITE_API int sqlite3_limit(sqlite3*, int id, int newVal); **
    • ** **
    • -** ^If the specific value bound to a [parameter | host parameter] in the +** ^If the specific value bound to [parameter | host parameter] in the ** WHERE clause might influence the choice of query plan for a statement, ** then the statement will be automatically recompiled, as if there had been -** a schema change, on the first [sqlite3_step()] call following any change +** a schema change, on the first [sqlite3_step()] call following any change ** to the [sqlite3_bind_text | bindings] of that [parameter]. -** ^The specific value of a WHERE-clause [parameter] might influence the +** ^The specific value of WHERE-clause [parameter] might influence the ** choice of query plan if the parameter is the left-hand side of a [LIKE] ** or [GLOB] operator or if the parameter is compared to an indexed column ** and the [SQLITE_ENABLE_STAT4] compile-time option is enabled. @@ -5490,7 +5374,7 @@ SQLITE_API const void *sqlite3_column_name16(sqlite3_stmt*, int N); ** ** ^If the Nth column returned by the statement is an expression or ** subquery and is not a column value, then all of these functions return -** NULL. ^These routines might also return NULL if a memory allocation error +** NULL. ^These routine might also return NULL if a memory allocation error ** occurs. ^Otherwise, they return the name of the attached database, table, ** or column that query result column was extracted from. ** @@ -5500,6 +5384,10 @@ SQLITE_API const void *sqlite3_column_name16(sqlite3_stmt*, int N); ** ^These APIs are only available if the library was compiled with the ** [SQLITE_ENABLE_COLUMN_METADATA] C-preprocessor symbol. ** +** If two or more threads call one or more of these routines against the same +** prepared statement and column at the same time then the results are +** undefined. +** ** If two or more threads call one or more ** [sqlite3_column_database_name | column metadata interfaces] ** for the same [prepared statement] and result column @@ -5636,7 +5524,7 @@ SQLITE_API int sqlite3_step(sqlite3_stmt*); ** ^The sqlite3_data_count(P) interface returns the number of columns in the ** current row of the result set of [prepared statement] P. ** ^If prepared statement P does not have results ready to return -** (via calls to the [sqlite3_column_int | sqlite3_column()] family of +** (via calls to the [sqlite3_column_int | sqlite3_column_*()] of ** interfaces) then sqlite3_data_count(P) returns 0. ** ^The sqlite3_data_count(P) routine also returns 0 if P is a NULL pointer. ** ^The sqlite3_data_count(P) routine returns 0 if the previous call to @@ -5960,6 +5848,8 @@ SQLITE_API int sqlite3_reset(sqlite3_stmt *pStmt); /* ** CAPI3REF: Create Or Redefine SQL Functions ** KEYWORDS: {function creation routines} +** KEYWORDS: {application-defined SQL function} +** KEYWORDS: {application-defined SQL functions} ** METHOD: sqlite3 ** ** ^These functions (collectively known as "function creation routines") @@ -6015,20 +5905,9 @@ SQLITE_API int sqlite3_reset(sqlite3_stmt *pStmt); ** ** ^The fourth parameter may also optionally include the [SQLITE_DIRECTONLY] ** flag, which if present prevents the function from being invoked from -** within VIEWs, TRIGGERs, CHECK constraints, generated column expressions, -** index expressions, or the WHERE clause of partial indexes. -** -** -** For best security, the [SQLITE_DIRECTONLY] flag is recommended for -** all application-defined SQL functions that do not need to be -** used inside of triggers, view, CHECK constraints, or other elements of -** the database schema. This flags is especially recommended for SQL -** functions that have side effects or reveal internal application state. -** Without this flag, an attacker might be able to modify the schema of -** a database file to include invocations of the function with parameters -** chosen by the attacker, which the application will then execute when -** the database file is opened and read. -** +** within VIEWs or TRIGGERs. For security reasons, the [SQLITE_DIRECTONLY] +** flag is recommended for any application-defined SQL function that has +** side-effects. ** ** ^(The fifth parameter is an arbitrary pointer. The implementation of the ** function can gain access to this pointer using [sqlite3_user_data()].)^ @@ -6147,53 +6026,18 @@ SQLITE_API int sqlite3_create_window_function( ** to [sqlite3_create_function()], [sqlite3_create_function16()], or ** [sqlite3_create_function_v2()]. ** -**
      -** [[SQLITE_DETERMINISTIC]]
      SQLITE_DETERMINISTIC
      -** The SQLITE_DETERMINISTIC flag means that the new function always gives -** the same output when the input parameters are the same. -** The [abs|abs() function] is deterministic, for example, but -** [randomblob|randomblob()] is not. Functions must -** be deterministic in order to be used in certain contexts such as -** with the WHERE clause of [partial indexes] or in [generated columns]. -** SQLite might also optimize deterministic functions by factoring them -** out of inner loops. -**
      -** -** [[SQLITE_DIRECTONLY]]
      SQLITE_DIRECTONLY
      +** The SQLITE_DETERMINISTIC flag means that the new function will always +** maps the same inputs into the same output. The abs() function is +** deterministic, for example, but randomblob() is not. +** ** The SQLITE_DIRECTONLY flag means that the function may only be invoked -** from top-level SQL, and cannot be used in VIEWs or TRIGGERs nor in -** schema structures such as [CHECK constraints], [DEFAULT clauses], -** [expression indexes], [partial indexes], or [generated columns]. -** The SQLITE_DIRECTONLY flags is a security feature which is recommended -** for all [application-defined SQL functions], and especially for functions -** that have side-effects or that could potentially leak sensitive -** information. -**
      +** from top-level SQL, and cannot be used in VIEWs or TRIGGERs. This is +** a security feature which is recommended for all +** [application-defined SQL functions] that have side-effects. This flag +** prevents an attacker from adding triggers and views to a schema then +** tricking a high-privilege application into causing unintended side-effects +** while performing ordinary queries. ** -** [[SQLITE_INNOCUOUS]]
      SQLITE_INNOCUOUS
      -** The SQLITE_INNOCUOUS flag means that the function is unlikely -** to cause problems even if misused. An innocuous function should have -** no side effects and should not depend on any values other than its -** input parameters. The [abs|abs() function] is an example of an -** innocuous function. -** The [load_extension() SQL function] is not innocuous because of its -** side effects. -**

      SQLITE_INNOCUOUS is similar to SQLITE_DETERMINISTIC, but is not -** exactly the same. The [random|random() function] is an example of a -** function that is innocuous but not deterministic. -**

      Some heightened security settings -** ([SQLITE_DBCONFIG_TRUSTED_SCHEMA] and [PRAGMA trusted_schema=OFF]) -** disable the use of SQL functions inside views and triggers and in -** schema structures such as [CHECK constraints], [DEFAULT clauses], -** [expression indexes], [partial indexes], and [generated columns] unless -** the function is tagged with SQLITE_INNOCUOUS. Most built-in functions -** are innocuous. Developers are advised to avoid using the -** SQLITE_INNOCUOUS flag for application-defined functions unless the -** function has been carefully audited and found to be free of potentially -** security-adverse side-effects and information-leaks. -**

      -** -** [[SQLITE_SUBTYPE]]
      SQLITE_SUBTYPE
      ** The SQLITE_SUBTYPE flag indicates to SQLite that a function may call ** [sqlite3_value_subtype()] to inspect the sub-types of its arguments. ** Specifying this flag makes no difference for scalar or aggregate user @@ -6201,13 +6045,10 @@ SQLITE_API int sqlite3_create_window_function( ** function, then any sub-types belonging to arguments passed to the window ** function may be discarded before the window function is called (i.e. ** sqlite3_value_subtype() will always return 0). -**
      -**
      */ #define SQLITE_DETERMINISTIC 0x000000800 #define SQLITE_DIRECTONLY 0x000080000 #define SQLITE_SUBTYPE 0x000100000 -#define SQLITE_INNOCUOUS 0x000200000 /* ** CAPI3REF: Deprecated Functions @@ -6266,8 +6107,8 @@ SQLITE_API SQLITE_DEPRECATED int sqlite3_memory_alarm(void(*)(void*,sqlite3_int6 ** ** These routines extract type, size, and content information from ** [protected sqlite3_value] objects. Protected sqlite3_value objects -** are used to pass parameter information into the functions that -** implement [application-defined SQL functions] and [virtual tables]. +** are used to pass parameter information into implementation of +** [application-defined SQL functions] and [virtual tables]. ** ** These routines work only with [protected sqlite3_value] objects. ** Any attempt to use these routines on an [unprotected sqlite3_value] @@ -6324,7 +6165,7 @@ SQLITE_API SQLITE_DEPRECATED int sqlite3_memory_alarm(void(*)(void*,sqlite3_int6 ** ^The sqlite3_value_frombind(X) interface returns non-zero if the ** value X originated from one of the [sqlite3_bind_int|sqlite3_bind()] ** interfaces. ^If X comes from an SQL literal value, or a table column, -** or an expression, then sqlite3_value_frombind(X) returns zero. +** and expression, then sqlite3_value_frombind(X) returns zero. ** ** Please pay particular attention to the fact that the pointer returned ** from [sqlite3_value_blob()], [sqlite3_value_text()], or @@ -6410,8 +6251,8 @@ SQLITE_API void sqlite3_value_free(sqlite3_value*); ** routine to allocate memory for storing their state. ** ** ^The first time the sqlite3_aggregate_context(C,N) routine is called -** for a particular aggregate function, SQLite allocates -** N bytes of memory, zeroes out that memory, and returns a pointer +** for a particular aggregate function, SQLite +** allocates N of memory, zeroes out that memory, and returns a pointer ** to the new memory. ^On second and subsequent calls to ** sqlite3_aggregate_context() for the same aggregate function instance, ** the same buffer is returned. Sqlite3_aggregate_context() is normally @@ -6428,7 +6269,7 @@ SQLITE_API void sqlite3_value_free(sqlite3_value*); ** ** ^(The amount of space allocated by sqlite3_aggregate_context(C,N) is ** determined by the N parameter on first successful call. Changing the -** value of N in any subsequents call to sqlite3_aggregate_context() within +** value of N in subsequent call to sqlite3_aggregate_context() within ** the same aggregate function instance will not resize the memory ** allocation.)^ Within the xFinal callback, it is customary to set ** N=0 in calls to sqlite3_aggregate_context(C,N) so that no @@ -6739,7 +6580,7 @@ SQLITE_API void sqlite3_result_subtype(sqlite3_context*,unsigned int); **
    • [SQLITE_UTF16_ALIGNED]. **
    )^ ** ^The eTextRep argument determines the encoding of strings passed -** to the collating function callback, xCompare. +** to the collating function callback, xCallback. ** ^The [SQLITE_UTF16] and [SQLITE_UTF16_ALIGNED] values for eTextRep ** force strings to be UTF16 with native byte order. ** ^The [SQLITE_UTF16_ALIGNED] value for eTextRep forces strings to begin @@ -6748,19 +6589,18 @@ SQLITE_API void sqlite3_result_subtype(sqlite3_context*,unsigned int); ** ^The fourth argument, pArg, is an application data pointer that is passed ** through as the first argument to the collating function callback. ** -** ^The fifth argument, xCompare, is a pointer to the collating function. +** ^The fifth argument, xCallback, is a pointer to the collating function. ** ^Multiple collating functions can be registered using the same name but ** with different eTextRep parameters and SQLite will use whichever ** function requires the least amount of data transformation. -** ^If the xCompare argument is NULL then the collating function is +** ^If the xCallback argument is NULL then the collating function is ** deleted. ^When all collating functions having the same name are deleted, ** that collation is no longer usable. ** ** ^The collating function callback is invoked with a copy of the pArg ** application data pointer and with two strings in the encoding specified -** by the eTextRep argument. The two integer parameters to the collating -** function callback are the length of the two strings, in bytes. The collating -** function must return an integer that is negative, zero, or positive +** by the eTextRep argument. The collating function must return an +** integer that is negative, zero, or positive ** if the first string is less than, equal to, or greater than the second, ** respectively. A collating function must always return the same answer ** given the same inputs. If two or more collating functions are registered @@ -6777,7 +6617,7 @@ SQLITE_API void sqlite3_result_subtype(sqlite3_context*,unsigned int); ** ** ** If a collating function fails any of the above constraints and that -** collating function is registered and used, then the behavior of SQLite +** collating function is registered and used, then the behavior of SQLite ** is undefined. ** ** ^The sqlite3_create_collation_v2() works like sqlite3_create_collation() @@ -7104,31 +6944,16 @@ SQLITE_API sqlite3 *sqlite3_db_handle(sqlite3_stmt*); ** CAPI3REF: Return The Filename For A Database Connection ** METHOD: sqlite3 ** -** ^The sqlite3_db_filename(D,N) interface returns a pointer to the filename -** associated with database N of connection D. -** ^If there is no attached database N on the database +** ^The sqlite3_db_filename(D,N) interface returns a pointer to a filename +** associated with database N of connection D. ^The main database file +** has the name "main". If there is no attached database N on the database ** connection D, or if database N is a temporary or in-memory database, then ** this function will return either a NULL pointer or an empty string. ** -** ^The string value returned by this routine is owned and managed by -** the database connection. ^The value will be valid until the database N -** is [DETACH]-ed or until the database connection closes. -** ** ^The filename returned by this function is the output of the ** xFullPathname method of the [VFS]. ^In other words, the filename ** will be an absolute pathname, even if the filename used ** to open the database originally was a URI or relative pathname. -** -** If the filename pointer returned by this routine is not NULL, then it -** can be used as the filename input parameter to these routines: -**
      -**
    • [sqlite3_uri_parameter()] -**
    • [sqlite3_uri_boolean()] -**
    • [sqlite3_uri_int64()] -**
    • [sqlite3_filename_database()] -**
    • [sqlite3_filename_journal()] -**
    • [sqlite3_filename_wal()] -**
    */ SQLITE_API const char *sqlite3_db_filename(sqlite3 *db, const char *zDbName); @@ -7278,19 +7103,15 @@ SQLITE_API void *sqlite3_update_hook( ** ** ^(The cache sharing mode set by this interface effects all subsequent ** calls to [sqlite3_open()], [sqlite3_open_v2()], and [sqlite3_open16()]. -** Existing database connections continue to use the sharing mode +** Existing database connections continue use the sharing mode ** that was in effect at the time they were opened.)^ ** ** ^(This routine returns [SQLITE_OK] if shared cache was enabled or disabled ** successfully. An [error code] is returned otherwise.)^ ** -** ^Shared cache is disabled by default. It is recommended that it stay -** that way. In other words, do not use this routine. This interface -** continues to be provided for historical compatibility, but its use is -** discouraged. Any use of shared cache is discouraged. If shared cache -** must be used, it is recommended that shared cache only be enabled for -** individual database connections using the [sqlite3_open_v2()] interface -** with the [SQLITE_OPEN_SHAREDCACHE] flag. +** ^Shared cache is disabled by default. But this might change in +** future releases of SQLite. Applications that care about shared +** cache setting should set it explicitly. ** ** Note: This method is disabled on MacOS X 10.7 and iOS version 5.0 ** and will always return SQLITE_MISUSE. On those systems, @@ -7337,9 +7158,6 @@ SQLITE_API int sqlite3_db_release_memory(sqlite3*); /* ** CAPI3REF: Impose A Limit On Heap Size ** -** These interfaces impose limits on the amount of heap memory that will be -** by all database connections within a single process. -** ** ^The sqlite3_soft_heap_limit64() interface sets and/or queries the ** soft limit on the amount of heap memory that may be allocated by SQLite. ** ^SQLite strives to keep heap memory utilization below the soft heap @@ -7350,41 +7168,20 @@ SQLITE_API int sqlite3_db_release_memory(sqlite3*); ** an [SQLITE_NOMEM] error. In other words, the soft heap limit ** is advisory only. ** -** ^The sqlite3_hard_heap_limit64(N) interface sets a hard upper bound of -** N bytes on the amount of memory that will be allocated. ^The -** sqlite3_hard_heap_limit64(N) interface is similar to -** sqlite3_soft_heap_limit64(N) except that memory allocations will fail -** when the hard heap limit is reached. -** -** ^The return value from both sqlite3_soft_heap_limit64() and -** sqlite3_hard_heap_limit64() is the size of -** the heap limit prior to the call, or negative in the case of an +** ^The return value from sqlite3_soft_heap_limit64() is the size of +** the soft heap limit prior to the call, or negative in the case of an ** error. ^If the argument N is negative -** then no change is made to the heap limit. Hence, the current -** size of heap limits can be determined by invoking -** sqlite3_soft_heap_limit64(-1) or sqlite3_hard_heap_limit(-1). +** then no change is made to the soft heap limit. Hence, the current +** size of the soft heap limit can be determined by invoking +** sqlite3_soft_heap_limit64() with a negative argument. ** -** ^Setting the heap limits to zero disables the heap limiter mechanism. +** ^If the argument N is zero then the soft heap limit is disabled. ** -** ^The soft heap limit may not be greater than the hard heap limit. -** ^If the hard heap limit is enabled and if sqlite3_soft_heap_limit(N) -** is invoked with a value of N that is greater than the hard heap limit, -** the the soft heap limit is set to the value of the hard heap limit. -** ^The soft heap limit is automatically enabled whenever the hard heap -** limit is enabled. ^When sqlite3_hard_heap_limit64(N) is invoked and -** the soft heap limit is outside the range of 1..N, then the soft heap -** limit is set to N. ^Invoking sqlite3_soft_heap_limit64(0) when the -** hard heap limit is enabled makes the soft heap limit equal to the -** hard heap limit. -** -** The memory allocation limits can also be adjusted using -** [PRAGMA soft_heap_limit] and [PRAGMA hard_heap_limit]. -** -** ^(The heap limits are not enforced in the current implementation +** ^(The soft heap limit is not enforced in the current implementation ** if one or more of following conditions are true: ** **
      -**
    • The limit value is set to zero. +**
    • The soft heap limit is set to zero. **
    • Memory accounting is disabled using a combination of the ** [sqlite3_config]([SQLITE_CONFIG_MEMSTATUS],...) start-time option and ** the [SQLITE_DEFAULT_MEMSTATUS] compile-time option. @@ -7395,11 +7192,21 @@ SQLITE_API int sqlite3_db_release_memory(sqlite3*); ** from the heap. **
    )^ ** -** The circumstances under which SQLite will enforce the heap limits may +** Beginning with SQLite [version 3.7.3] ([dateof:3.7.3]), +** the soft heap limit is enforced +** regardless of whether or not the [SQLITE_ENABLE_MEMORY_MANAGEMENT] +** compile-time option is invoked. With [SQLITE_ENABLE_MEMORY_MANAGEMENT], +** the soft heap limit is enforced on every memory allocation. Without +** [SQLITE_ENABLE_MEMORY_MANAGEMENT], the soft heap limit is only enforced +** when memory is allocated by the page cache. Testing suggests that because +** the page cache is the predominate memory user in SQLite, most +** applications will achieve adequate soft heap limit enforcement without +** the use of [SQLITE_ENABLE_MEMORY_MANAGEMENT]. +** +** The circumstances under which SQLite will enforce the soft heap limit may ** changes in future releases of SQLite. */ SQLITE_API sqlite3_int64 sqlite3_soft_heap_limit64(sqlite3_int64 N); -SQLITE_API sqlite3_int64 sqlite3_hard_heap_limit64(sqlite3_int64 N); /* ** CAPI3REF: Deprecated Soft Heap Limit Interface @@ -7423,7 +7230,7 @@ SQLITE_API SQLITE_DEPRECATED void sqlite3_soft_heap_limit(int N); ** interface returns SQLITE_OK and fills in the non-NULL pointers in ** the final five arguments with appropriate values if the specified ** column exists. ^The sqlite3_table_column_metadata() interface returns -** SQLITE_ERROR if the specified column does not exist. +** SQLITE_ERROR and if the specified column does not exist. ** ^If the column-name parameter to sqlite3_table_column_metadata() is a ** NULL pointer, then this routine simply checks for the existence of the ** table and returns SQLITE_OK if the table exists and SQLITE_ERROR if it @@ -7565,7 +7372,7 @@ SQLITE_API int sqlite3_load_extension( ** to enable or disable only the C-API.)^ ** ** Security warning: It is recommended that extension loading -** be enabled using the [SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION] method +** be disabled using the [SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION] method ** rather than this interface, so the [load_extension()] SQL function ** remains disabled. This will prevent SQL injections from giving attackers ** access to extension loading capabilities. @@ -7652,7 +7459,7 @@ typedef struct sqlite3_module sqlite3_module; ** KEYWORDS: sqlite3_module {virtual table module} ** ** This structure, sometimes called a "virtual table module", -** defines the implementation of a [virtual table]. +** defines the implementation of a [virtual tables]. ** This structure consists mostly of methods for the module. ** ** ^A virtual table module is created by filling in a persistent @@ -7749,13 +7556,7 @@ struct sqlite3_module { ** the right-hand side of the corresponding aConstraint[] is evaluated ** and becomes the argvIndex-th entry in argv. ^(If aConstraintUsage[].omit ** is true, then the constraint is assumed to be fully handled by the -** virtual table and might not be checked again by the byte code.)^ ^(The -** aConstraintUsage[].omit flag is an optimization hint. When the omit flag -** is left in its default setting of false, the constraint will always be -** checked separately in byte code. If the omit flag is change to true, then -** the constraint may or may not be checked in byte code. In other words, -** when the omit flag is true there is no guarantee that the constraint will -** not be checked again using byte code.)^ +** virtual table and is not checked again by SQLite.)^ ** ** ^The idxNum and idxPtr values are recorded and passed into the ** [xFilter] method. @@ -7795,7 +7596,7 @@ struct sqlite3_module { ** If a virtual table extension is ** used with an SQLite version earlier than 3.8.2, the results of attempting ** to read or write the estimatedRows field are undefined (but are likely -** to include crashing the application). The estimatedRows field should +** to included crashing the application). The estimatedRows field should ** therefore only be used if [sqlite3_libversion_number()] returns a ** value greater than or equal to 3008002. Similarly, the idxFlags field ** was added for [version 3.9.0] ([dateof:3.9.0]). @@ -7847,7 +7648,7 @@ struct sqlite3_index_info { /* ** CAPI3REF: Virtual Table Constraint Operator Codes ** -** These macros define the allowed values for the +** These macros defined the allowed values for the ** [sqlite3_index_info].aConstraint[].op field. Each value represents ** an operator that is part of a constraint term in the wHERE clause of ** a query that uses a [virtual table]. @@ -8457,7 +8258,7 @@ SQLITE_API void sqlite3_mutex_leave(sqlite3_mutex*); ** The only difference is that the public sqlite3_XXX functions enumerated ** above silently ignore any invocations that pass a NULL pointer instead ** of a valid mutex handle. The implementations of the methods defined -** by this structure are not required to handle this case. The results +** by this structure are not required to handle this case, the results ** of passing a NULL pointer instead of a valid mutex handle are undefined ** (i.e. it is acceptable to provide an implementation that segfaults if ** it is passed a NULL pointer). @@ -8930,7 +8731,7 @@ SQLITE_API int sqlite3_status64( ** ** [[SQLITE_STATUS_PAGECACHE_SIZE]] ^(
    SQLITE_STATUS_PAGECACHE_SIZE
    **
    This parameter records the largest memory allocation request -** handed to the [pagecache memory allocator]. Only the value returned in the +** handed to [pagecache memory allocator]. Only the value returned in the ** *pHighwater parameter to [sqlite3_status()] is of interest. ** The value written into the *pCurrent parameter is undefined.
    )^ ** @@ -9006,7 +8807,7 @@ SQLITE_API int sqlite3_db_status(sqlite3*, int op, int *pCur, int *pHiwtr, int r ** checked out.)^ ** ** [[SQLITE_DBSTATUS_LOOKASIDE_HIT]] ^(
    SQLITE_DBSTATUS_LOOKASIDE_HIT
    -**
    This parameter returns the number of malloc attempts that were +**
    This parameter returns the number malloc attempts that were ** satisfied using lookaside memory. Only the high-water value is meaningful; ** the current value is always zero.)^ ** @@ -9088,7 +8889,7 @@ SQLITE_API int sqlite3_db_status(sqlite3*, int op, int *pCur, int *pHiwtr, int r ** cache overflowing. Transactions are more efficient if they are written ** to disk all at once. When pages spill mid-transaction, that introduces ** additional overhead. This parameter can be used help identify -** inefficiencies that can be resolved by increasing the cache size. +** inefficiencies that can be resolve by increasing the cache size. **
    ** ** [[SQLITE_DBSTATUS_DEFERRED_FKS]] ^(
    SQLITE_DBSTATUS_DEFERRED_FKS
    @@ -9177,7 +8978,7 @@ SQLITE_API int sqlite3_stmt_status(sqlite3_stmt*, int op,int resetFlg); ** ** [[SQLITE_STMTSTATUS_REPREPARE]]
    SQLITE_STMTSTATUS_REPREPARE
    **
    ^This is the number of times that the prepare statement has been -** automatically regenerated due to schema changes or changes to +** automatically regenerated due to schema changes or change to ** [bound parameters] that might affect the query plan. ** ** [[SQLITE_STMTSTATUS_RUN]]
    SQLITE_STMTSTATUS_RUN
    @@ -9348,7 +9149,7 @@ struct sqlite3_pcache_page { ** ** ^(SQLite will normally invoke xFetch() with a createFlag of 0 or 1. SQLite ** will only use a createFlag of 2 after a prior call with a createFlag of 1 -** failed.)^ In between the xFetch() calls, SQLite may +** failed.)^ In between the to xFetch() calls, SQLite may ** attempt to unpin one or more cache pages by spilling the content of ** pinned pages to disk and synching the operating system disk cache. ** @@ -9666,7 +9467,7 @@ SQLITE_API int sqlite3_backup_pagecount(sqlite3_backup *p); ** the first argument to register for a callback that will be invoked ** when the blocking connections current transaction is concluded. ^The ** callback is invoked from within the [sqlite3_step] or [sqlite3_close] -** call that concludes the blocking connection's transaction. +** call that concludes the blocking connections transaction. ** ** ^(If sqlite3_unlock_notify() is called in a multi-threaded application, ** there is a chance that the blocking connection will have already @@ -9704,7 +9505,7 @@ SQLITE_API int sqlite3_backup_pagecount(sqlite3_backup *p); ** an unlock-notify callback is a pointer to an array of void* pointers, ** and the second is the number of entries in the array. ** -** When a blocking connection's transaction is concluded, there may be +** When a blocking connections transaction is concluded, there may be ** more than one blocked connection that has registered for an unlock-notify ** callback. ^If two or more such blocked connections have specified the ** same callback function, then instead of invoking the callback function @@ -10052,20 +9853,14 @@ SQLITE_API int sqlite3_wal_checkpoint_v2( ** If this interface is invoked outside the context of an xConnect or ** xCreate virtual table method then the behavior is undefined. ** -** In the call sqlite3_vtab_config(D,C,...) the D parameter is the -** [database connection] in which the virtual table is being created and -** which is passed in as the first argument to the [xConnect] or [xCreate] -** method that is invoking sqlite3_vtab_config(). The C parameter is one -** of the [virtual table configuration options]. The presence and meaning -** of parameters after C depend on which [virtual table configuration option] -** is used. +** At present, there is only one option that may be configured using +** this function. (See [SQLITE_VTAB_CONSTRAINT_SUPPORT].) Further options +** may be added in the future. */ SQLITE_API int sqlite3_vtab_config(sqlite3*, int op, ...); /* ** CAPI3REF: Virtual Table Configuration Options -** KEYWORDS: {virtual table configuration options} -** KEYWORDS: {virtual table configuration option} ** ** These macros define the various options to the ** [sqlite3_vtab_config()] interface that [virtual table] implementations @@ -10073,7 +9868,7 @@ SQLITE_API int sqlite3_vtab_config(sqlite3*, int op, ...); ** **
    ** [[SQLITE_VTAB_CONSTRAINT_SUPPORT]] -**
    SQLITE_VTAB_CONSTRAINT_SUPPORT
    +**
    SQLITE_VTAB_CONSTRAINT_SUPPORT **
    Calls of the form ** [sqlite3_vtab_config](db,SQLITE_VTAB_CONSTRAINT_SUPPORT,X) are supported, ** where X is an integer. If X is zero, then the [virtual table] whose @@ -10102,31 +9897,9 @@ SQLITE_API int sqlite3_vtab_config(sqlite3*, int op, ...); ** return SQLITE_OK. Or, if this is not possible, it may return ** SQLITE_CONSTRAINT, in which case SQLite falls back to OR ABORT ** constraint handling. -**
    -** -** [[SQLITE_VTAB_DIRECTONLY]]
    SQLITE_VTAB_DIRECTONLY
    -**
    Calls of the form -** [sqlite3_vtab_config](db,SQLITE_VTAB_DIRECTONLY) from within the -** the [xConnect] or [xCreate] methods of a [virtual table] implmentation -** prohibits that virtual table from being used from within triggers and -** views. -**
    -** -** [[SQLITE_VTAB_INNOCUOUS]]
    SQLITE_VTAB_INNOCUOUS
    -**
    Calls of the form -** [sqlite3_vtab_config](db,SQLITE_VTAB_INNOCUOUS) from within the -** the [xConnect] or [xCreate] methods of a [virtual table] implmentation -** identify that virtual table as being safe to use from within triggers -** and views. Conceptually, the SQLITE_VTAB_INNOCUOUS tag means that the -** virtual table can do no serious harm even if it is controlled by a -** malicious hacker. Developers should avoid setting the SQLITE_VTAB_INNOCUOUS -** flag unless absolutely necessary. -**
    **
    */ #define SQLITE_VTAB_CONSTRAINT_SUPPORT 1 -#define SQLITE_VTAB_INNOCUOUS 2 -#define SQLITE_VTAB_DIRECTONLY 3 /* ** CAPI3REF: Determine The Virtual Table Conflict Policy @@ -10206,15 +9979,15 @@ SQLITE_API SQLITE_EXPERIMENTAL const char *sqlite3_vtab_collation(sqlite3_index_ ** **
    ** [[SQLITE_SCANSTAT_NLOOP]]
    SQLITE_SCANSTAT_NLOOP
    -**
    ^The [sqlite3_int64] variable pointed to by the V parameter will be +**
    ^The [sqlite3_int64] variable pointed to by the T parameter will be ** set to the total number of times that the X-th loop has run.
    ** ** [[SQLITE_SCANSTAT_NVISIT]]
    SQLITE_SCANSTAT_NVISIT
    -**
    ^The [sqlite3_int64] variable pointed to by the V parameter will be set +**
    ^The [sqlite3_int64] variable pointed to by the T parameter will be set ** to the total number of rows examined by all iterations of the X-th loop.
    ** ** [[SQLITE_SCANSTAT_EST]]
    SQLITE_SCANSTAT_EST
    -**
    ^The "double" variable pointed to by the V parameter will be set to the +**
    ^The "double" variable pointed to by the T parameter will be set to the ** query planner's estimate for the average number of rows output from each ** iteration of the X-th loop. If the query planner's estimates was accurate, ** then this value will approximate the quotient NVISIT/NLOOP and the @@ -10222,17 +9995,17 @@ SQLITE_API SQLITE_EXPERIMENTAL const char *sqlite3_vtab_collation(sqlite3_index_ ** be the NLOOP value for the current loop. ** ** [[SQLITE_SCANSTAT_NAME]]
    SQLITE_SCANSTAT_NAME
    -**
    ^The "const char *" variable pointed to by the V parameter will be set +**
    ^The "const char *" variable pointed to by the T parameter will be set ** to a zero-terminated UTF-8 string containing the name of the index or table ** used for the X-th loop. ** ** [[SQLITE_SCANSTAT_EXPLAIN]]
    SQLITE_SCANSTAT_EXPLAIN
    -**
    ^The "const char *" variable pointed to by the V parameter will be set +**
    ^The "const char *" variable pointed to by the T parameter will be set ** to a zero-terminated UTF-8 string containing the [EXPLAIN QUERY PLAN] ** description for the X-th loop. ** ** [[SQLITE_SCANSTAT_SELECTID]]
    SQLITE_SCANSTAT_SELECT
    -**
    ^The "int" variable pointed to by the V parameter will be set to the +**
    ^The "int" variable pointed to by the T parameter will be set to the ** "select-id" for the X-th loop. The select-id identifies which query or ** subquery the loop is part of. The main query has a select-id of zero. ** The select-id is the same value as is output in the first column @@ -11087,7 +10860,7 @@ SQLITE_API int sqlite3session_attach( ** The second argument (xFilter) is the "filter callback". For changes to rows ** in tables that are not attached to the Session object, the filter is called ** to determine whether changes to the table's rows should be tracked or not. -** If xFilter returns 0, changes are not tracked. Note that once a table is +** If xFilter returns 0, changes is not tracked. Note that once a table is ** attached, xFilter will not be called again. */ SQLITE_API void sqlite3session_table_filter( @@ -11261,7 +11034,7 @@ SQLITE_API int sqlite3session_changeset( ** It an error if database zFrom does not exist or does not contain the ** required compatible table. ** -** If the operation is successful, SQLITE_OK is returned. Otherwise, an SQLite +** If the operation successful, SQLITE_OK is returned. Otherwise, an SQLite ** error code. In this case, if argument pzErrMsg is not NULL, *pzErrMsg ** may be set to point to a buffer containing an English language error ** message. It is the responsibility of the caller to free this buffer using @@ -11398,7 +11171,7 @@ SQLITE_API int sqlite3changeset_start_v2( ** CAPI3REF: Advance A Changeset Iterator ** METHOD: sqlite3_changeset_iter ** -** This function may only be used with iterators created by the function +** This function may only be used with iterators created by function ** [sqlite3changeset_start()]. If it is called on an iterator passed to ** a conflict-handler callback by [sqlite3changeset_apply()], SQLITE_MISUSE ** is returned and the call has no effect. @@ -11814,8 +11587,8 @@ SQLITE_API int sqlite3changegroup_new(sqlite3_changegroup **pp); ** case, this function fails with SQLITE_SCHEMA. If the input changeset ** appears to be corrupt and the corruption is detected, SQLITE_CORRUPT is ** returned. Or, if an out-of-memory condition occurs during processing, this -** function returns SQLITE_NOMEM. In all cases, if an error occurs the state -** of the final contents of the changegroup is undefined. +** function returns SQLITE_NOMEM. In all cases, if an error occurs the +** final contents of the changegroup is undefined. ** ** If no error occurs, SQLITE_OK is returned. */ @@ -11990,7 +11763,7 @@ SQLITE_API void sqlite3changegroup_delete(sqlite3_changegroup*); ** ** It is safe to execute SQL statements, including those that write to the ** table that the callback related to, from within the xConflict callback. -** This can be used to further customize the application's conflict +** This can be used to further customize the applications conflict ** resolution strategy. ** ** All changes made by these functions are enclosed in a savepoint transaction. @@ -12300,7 +12073,7 @@ SQLITE_API int sqlite3rebaser_configure( ** ** Argument pIn must point to a buffer containing a changeset nIn bytes ** in size. This function allocates and populates a buffer with a copy -** of the changeset rebased according to the configuration of the +** of the changeset rebased rebased according to the configuration of the ** rebaser object passed as the first argument. If successful, (*ppOut) ** is set to point to the new buffer containing the rebased changeset and ** (*pnOut) to its size in bytes and SQLITE_OK returned. It is the @@ -12708,7 +12481,7 @@ struct Fts5PhraseIter { ** ** xSetAuxdata(pFts5, pAux, xDelete) ** -** Save the pointer passed as the second argument as the extension function's +** Save the pointer passed as the second argument as the extension functions ** "auxiliary data". The pointer may then be retrieved by the current or any ** future invocation of the same fts5 extension function made as part of ** the same MATCH query using the xGetAuxdata() API. @@ -12950,8 +12723,8 @@ struct Fts5ExtensionApi { ** ** There are several ways to approach this in FTS5: ** -**
    1. By mapping all synonyms to a single token. In this case, using -** the above example, this means that the tokenizer returns the +**
      1. By mapping all synonyms to a single token. In this case, the +** In the above example, this means that the tokenizer returns the ** same token for inputs "first" and "1st". Say that token is in ** fact "first", so that when the user inserts the document "I won ** 1st place" entries are added to the index for tokens "i", "won", @@ -13623,26 +13396,6 @@ SQLITE_PRIVATE void sqlite3Coverage(int); # define NEVER(X) (X) #endif -/* -** The harmless(X) macro indicates that expression X is usually false -** but can be true without causing any problems, but we don't know of -** any way to cause X to be true. -** -** In debugging and testing builds, this macro will abort if X is ever -** true. In this way, developers are alerted to a possible test case -** that causes X to be true. If a harmless macro ever fails, that is -** an opportunity to change the macro into a testcase() and add a new -** test case to the test suite. -** -** For normal production builds, harmless(X) is a no-op, since it does -** not matter whether expression X is true or false. -*/ -#ifdef SQLITE_DEBUG -# define harmless(X) assert(!(X)); -#else -# define harmless(X) -#endif - /* ** Some conditionals are optimizations only. In other words, if the ** conditionals are replaced with a constant 1 (true) or 0 (false) then @@ -13920,92 +13673,90 @@ SQLITE_PRIVATE void sqlite3HashClear(Hash*); #define TK_GROUPS 92 #define TK_OTHERS 93 #define TK_TIES 94 -#define TK_GENERATED 95 -#define TK_ALWAYS 96 -#define TK_REINDEX 97 -#define TK_RENAME 98 -#define TK_CTIME_KW 99 -#define TK_ANY 100 -#define TK_BITAND 101 -#define TK_BITOR 102 -#define TK_LSHIFT 103 -#define TK_RSHIFT 104 -#define TK_PLUS 105 -#define TK_MINUS 106 -#define TK_STAR 107 -#define TK_SLASH 108 -#define TK_REM 109 -#define TK_CONCAT 110 -#define TK_COLLATE 111 -#define TK_BITNOT 112 -#define TK_ON 113 -#define TK_INDEXED 114 -#define TK_STRING 115 -#define TK_JOIN_KW 116 -#define TK_CONSTRAINT 117 -#define TK_DEFAULT 118 -#define TK_NULL 119 -#define TK_PRIMARY 120 -#define TK_UNIQUE 121 -#define TK_CHECK 122 -#define TK_REFERENCES 123 -#define TK_AUTOINCR 124 -#define TK_INSERT 125 -#define TK_DELETE 126 -#define TK_UPDATE 127 -#define TK_SET 128 -#define TK_DEFERRABLE 129 -#define TK_FOREIGN 130 -#define TK_DROP 131 -#define TK_UNION 132 -#define TK_ALL 133 -#define TK_EXCEPT 134 -#define TK_INTERSECT 135 -#define TK_SELECT 136 -#define TK_VALUES 137 -#define TK_DISTINCT 138 -#define TK_DOT 139 -#define TK_FROM 140 -#define TK_JOIN 141 -#define TK_USING 142 -#define TK_ORDER 143 -#define TK_GROUP 144 -#define TK_HAVING 145 -#define TK_LIMIT 146 -#define TK_WHERE 147 -#define TK_INTO 148 -#define TK_NOTHING 149 -#define TK_FLOAT 150 -#define TK_BLOB 151 -#define TK_INTEGER 152 -#define TK_VARIABLE 153 -#define TK_CASE 154 -#define TK_WHEN 155 -#define TK_THEN 156 -#define TK_ELSE 157 -#define TK_INDEX 158 -#define TK_ALTER 159 -#define TK_ADD 160 -#define TK_WINDOW 161 -#define TK_OVER 162 -#define TK_FILTER 163 -#define TK_COLUMN 164 -#define TK_AGG_FUNCTION 165 -#define TK_AGG_COLUMN 166 -#define TK_TRUEFALSE 167 -#define TK_ISNOT 168 -#define TK_FUNCTION 169 -#define TK_UMINUS 170 -#define TK_UPLUS 171 -#define TK_TRUTH 172 -#define TK_REGISTER 173 -#define TK_VECTOR 174 -#define TK_SELECT_COLUMN 175 -#define TK_IF_NULL_ROW 176 -#define TK_ASTERISK 177 -#define TK_SPAN 178 -#define TK_SPACE 179 -#define TK_ILLEGAL 180 +#define TK_REINDEX 95 +#define TK_RENAME 96 +#define TK_CTIME_KW 97 +#define TK_ANY 98 +#define TK_BITAND 99 +#define TK_BITOR 100 +#define TK_LSHIFT 101 +#define TK_RSHIFT 102 +#define TK_PLUS 103 +#define TK_MINUS 104 +#define TK_STAR 105 +#define TK_SLASH 106 +#define TK_REM 107 +#define TK_CONCAT 108 +#define TK_COLLATE 109 +#define TK_BITNOT 110 +#define TK_ON 111 +#define TK_INDEXED 112 +#define TK_STRING 113 +#define TK_JOIN_KW 114 +#define TK_CONSTRAINT 115 +#define TK_DEFAULT 116 +#define TK_NULL 117 +#define TK_PRIMARY 118 +#define TK_UNIQUE 119 +#define TK_CHECK 120 +#define TK_REFERENCES 121 +#define TK_AUTOINCR 122 +#define TK_INSERT 123 +#define TK_DELETE 124 +#define TK_UPDATE 125 +#define TK_SET 126 +#define TK_DEFERRABLE 127 +#define TK_FOREIGN 128 +#define TK_DROP 129 +#define TK_UNION 130 +#define TK_ALL 131 +#define TK_EXCEPT 132 +#define TK_INTERSECT 133 +#define TK_SELECT 134 +#define TK_VALUES 135 +#define TK_DISTINCT 136 +#define TK_DOT 137 +#define TK_FROM 138 +#define TK_JOIN 139 +#define TK_USING 140 +#define TK_ORDER 141 +#define TK_GROUP 142 +#define TK_HAVING 143 +#define TK_LIMIT 144 +#define TK_WHERE 145 +#define TK_INTO 146 +#define TK_NOTHING 147 +#define TK_FLOAT 148 +#define TK_BLOB 149 +#define TK_INTEGER 150 +#define TK_VARIABLE 151 +#define TK_CASE 152 +#define TK_WHEN 153 +#define TK_THEN 154 +#define TK_ELSE 155 +#define TK_INDEX 156 +#define TK_ALTER 157 +#define TK_ADD 158 +#define TK_WINDOW 159 +#define TK_OVER 160 +#define TK_FILTER 161 +#define TK_COLUMN 162 +#define TK_AGG_FUNCTION 163 +#define TK_AGG_COLUMN 164 +#define TK_TRUEFALSE 165 +#define TK_ISNOT 166 +#define TK_FUNCTION 167 +#define TK_UMINUS 168 +#define TK_UPLUS 169 +#define TK_TRUTH 170 +#define TK_REGISTER 171 +#define TK_VECTOR 172 +#define TK_SELECT_COLUMN 173 +#define TK_IF_NULL_ROW 174 +#define TK_ASTERISK 175 +#define TK_SPAN 176 +#define TK_SPACE 177 +#define TK_ILLEGAL 178 /************** End of parse.h ***********************************************/ /************** Continuing where we left off in sqliteInt.h ******************/ @@ -14603,7 +14354,6 @@ typedef struct With With; ** A bit in a Bitmask */ #define MASKBIT(n) (((Bitmask)1)<<(n)) -#define MASKBIT64(n) (((u64)1)<<(n)) #define MASKBIT32(n) (((unsigned int)1)<<(n)) #define ALLBITS ((Bitmask)-1) @@ -14930,8 +14680,6 @@ SQLITE_PRIVATE int sqlite3BtreeNext(BtCursor*, int flags); SQLITE_PRIVATE int sqlite3BtreeEof(BtCursor*); SQLITE_PRIVATE int sqlite3BtreePrevious(BtCursor*, int flags); SQLITE_PRIVATE i64 sqlite3BtreeIntegerKey(BtCursor*); -SQLITE_PRIVATE void sqlite3BtreeCursorPin(BtCursor*); -SQLITE_PRIVATE void sqlite3BtreeCursorUnpin(BtCursor*); #ifdef SQLITE_ENABLE_OFFSET_SQL_FUNC SQLITE_PRIVATE i64 sqlite3BtreeOffset(BtCursor*); #endif @@ -14940,7 +14688,7 @@ SQLITE_PRIVATE const void *sqlite3BtreePayloadFetch(BtCursor*, u32 *pAmt); SQLITE_PRIVATE u32 sqlite3BtreePayloadSize(BtCursor*); SQLITE_PRIVATE sqlite3_int64 sqlite3BtreeMaxRecordSize(BtCursor*); -SQLITE_PRIVATE char *sqlite3BtreeIntegrityCheck(sqlite3*,Btree*,int*aRoot,int nRoot,int,int*); +SQLITE_PRIVATE char *sqlite3BtreeIntegrityCheck(Btree*, int *aRoot, int nRoot, int, int*); SQLITE_PRIVATE struct Pager *sqlite3BtreePager(Btree*); SQLITE_PRIVATE i64 sqlite3BtreeRowCountEst(BtCursor*); @@ -14961,7 +14709,7 @@ SQLITE_PRIVATE int sqlite3BtreeCursorIsValid(BtCursor*); SQLITE_PRIVATE int sqlite3BtreeCursorIsValidNN(BtCursor*); #ifndef SQLITE_OMIT_BTREECOUNT -SQLITE_PRIVATE int sqlite3BtreeCount(sqlite3*, BtCursor*, i64*); +SQLITE_PRIVATE int sqlite3BtreeCount(BtCursor *, i64 *); #endif #ifdef SQLITE_TEST @@ -15218,30 +14966,30 @@ typedef struct VdbeOpList VdbeOpList; #define OP_SeekLE 23 /* jump, synopsis: key=r[P3@P4] */ #define OP_SeekGE 24 /* jump, synopsis: key=r[P3@P4] */ #define OP_SeekGT 25 /* jump, synopsis: key=r[P3@P4] */ -#define OP_IfNotOpen 26 /* jump, synopsis: if( !csr[P1] ) goto P2 */ -#define OP_IfNoHope 27 /* jump, synopsis: key=r[P3@P4] */ -#define OP_NoConflict 28 /* jump, synopsis: key=r[P3@P4] */ -#define OP_NotFound 29 /* jump, synopsis: key=r[P3@P4] */ -#define OP_Found 30 /* jump, synopsis: key=r[P3@P4] */ -#define OP_SeekRowid 31 /* jump, synopsis: intkey=r[P3] */ -#define OP_NotExists 32 /* jump, synopsis: intkey=r[P3] */ -#define OP_Last 33 /* jump */ -#define OP_IfSmaller 34 /* jump */ -#define OP_SorterSort 35 /* jump */ -#define OP_Sort 36 /* jump */ -#define OP_Rewind 37 /* jump */ -#define OP_IdxLE 38 /* jump, synopsis: key=r[P3@P4] */ -#define OP_IdxGT 39 /* jump, synopsis: key=r[P3@P4] */ -#define OP_IdxLT 40 /* jump, synopsis: key=r[P3@P4] */ -#define OP_IdxGE 41 /* jump, synopsis: key=r[P3@P4] */ -#define OP_RowSetRead 42 /* jump, synopsis: r[P3]=rowset(P1) */ +#define OP_IfNoHope 26 /* jump, synopsis: key=r[P3@P4] */ +#define OP_NoConflict 27 /* jump, synopsis: key=r[P3@P4] */ +#define OP_NotFound 28 /* jump, synopsis: key=r[P3@P4] */ +#define OP_Found 29 /* jump, synopsis: key=r[P3@P4] */ +#define OP_SeekRowid 30 /* jump, synopsis: intkey=r[P3] */ +#define OP_NotExists 31 /* jump, synopsis: intkey=r[P3] */ +#define OP_Last 32 /* jump */ +#define OP_IfSmaller 33 /* jump */ +#define OP_SorterSort 34 /* jump */ +#define OP_Sort 35 /* jump */ +#define OP_Rewind 36 /* jump */ +#define OP_IdxLE 37 /* jump, synopsis: key=r[P3@P4] */ +#define OP_IdxGT 38 /* jump, synopsis: key=r[P3@P4] */ +#define OP_IdxLT 39 /* jump, synopsis: key=r[P3@P4] */ +#define OP_IdxGE 40 /* jump, synopsis: key=r[P3@P4] */ +#define OP_RowSetRead 41 /* jump, synopsis: r[P3]=rowset(P1) */ +#define OP_RowSetTest 42 /* jump, synopsis: if r[P3] in rowset(P1) goto P2 */ #define OP_Or 43 /* same as TK_OR, synopsis: r[P3]=(r[P1] || r[P2]) */ #define OP_And 44 /* same as TK_AND, synopsis: r[P3]=(r[P1] && r[P2]) */ -#define OP_RowSetTest 45 /* jump, synopsis: if r[P3] in rowset(P1) goto P2 */ -#define OP_Program 46 /* jump */ -#define OP_FkIfZero 47 /* jump, synopsis: if fkctr[P1]==0 goto P2 */ -#define OP_IfPos 48 /* jump, synopsis: if r[P1]>0 then r[P1]-=P3, goto P2 */ -#define OP_IfNotZero 49 /* jump, synopsis: if r[P1]!=0 then r[P1]--, goto P2 */ +#define OP_Program 45 /* jump */ +#define OP_FkIfZero 46 /* jump, synopsis: if fkctr[P1]==0 goto P2 */ +#define OP_IfPos 47 /* jump, synopsis: if r[P1]>0 then r[P1]-=P3, goto P2 */ +#define OP_IfNotZero 48 /* jump, synopsis: if r[P1]!=0 then r[P1]--, goto P2 */ +#define OP_DecrJumpZero 49 /* jump, synopsis: if (--r[P1])==0 goto P2 */ #define OP_IsNull 50 /* jump, same as TK_ISNULL, synopsis: if r[P1]==NULL goto P2 */ #define OP_NotNull 51 /* jump, same as TK_NOTNULL, synopsis: if r[P1]!=NULL goto P2 */ #define OP_Ne 52 /* jump, same as TK_NE, synopsis: IF r[P3]!=r[P1] */ @@ -15251,83 +14999,83 @@ typedef struct VdbeOpList VdbeOpList; #define OP_Lt 56 /* jump, same as TK_LT, synopsis: IF r[P3]=r[P1] */ #define OP_ElseNotEq 58 /* jump, same as TK_ESCAPE */ -#define OP_DecrJumpZero 59 /* jump, synopsis: if (--r[P1])==0 goto P2 */ -#define OP_IncrVacuum 60 /* jump */ -#define OP_VNext 61 /* jump */ -#define OP_Init 62 /* jump, synopsis: Start at P2 */ -#define OP_PureFunc 63 /* synopsis: r[P3]=func(r[P2@P5]) */ -#define OP_Function 64 /* synopsis: r[P3]=func(r[P2@P5]) */ -#define OP_Return 65 -#define OP_EndCoroutine 66 -#define OP_HaltIfNull 67 /* synopsis: if r[P3]=null halt */ -#define OP_Halt 68 -#define OP_Integer 69 /* synopsis: r[P2]=P1 */ -#define OP_Int64 70 /* synopsis: r[P2]=P4 */ -#define OP_String 71 /* synopsis: r[P2]='P4' (len=P1) */ -#define OP_Null 72 /* synopsis: r[P2..P3]=NULL */ -#define OP_SoftNull 73 /* synopsis: r[P1]=NULL */ -#define OP_Blob 74 /* synopsis: r[P2]=P4 (len=P1) */ -#define OP_Variable 75 /* synopsis: r[P2]=parameter(P1,P4) */ -#define OP_Move 76 /* synopsis: r[P2@P3]=r[P1@P3] */ -#define OP_Copy 77 /* synopsis: r[P2@P3+1]=r[P1@P3+1] */ -#define OP_SCopy 78 /* synopsis: r[P2]=r[P1] */ -#define OP_IntCopy 79 /* synopsis: r[P2]=r[P1] */ -#define OP_ResultRow 80 /* synopsis: output=r[P1@P2] */ -#define OP_CollSeq 81 -#define OP_AddImm 82 /* synopsis: r[P1]=r[P1]+P2 */ -#define OP_RealAffinity 83 -#define OP_Cast 84 /* synopsis: affinity(r[P1]) */ -#define OP_Permutation 85 -#define OP_Compare 86 /* synopsis: r[P1@P3] <-> r[P2@P3] */ -#define OP_IsTrue 87 /* synopsis: r[P2] = coalesce(r[P1]==TRUE,P3) ^ P4 */ -#define OP_Offset 88 /* synopsis: r[P3] = sqlite_offset(P1) */ -#define OP_Column 89 /* synopsis: r[P3]=PX */ -#define OP_Affinity 90 /* synopsis: affinity(r[P1@P2]) */ -#define OP_MakeRecord 91 /* synopsis: r[P3]=mkrec(r[P1@P2]) */ -#define OP_Count 92 /* synopsis: r[P2]=count() */ -#define OP_ReadCookie 93 -#define OP_SetCookie 94 -#define OP_ReopenIdx 95 /* synopsis: root=P2 iDb=P3 */ -#define OP_OpenRead 96 /* synopsis: root=P2 iDb=P3 */ -#define OP_OpenWrite 97 /* synopsis: root=P2 iDb=P3 */ -#define OP_OpenDup 98 -#define OP_OpenAutoindex 99 /* synopsis: nColumn=P2 */ -#define OP_OpenEphemeral 100 /* synopsis: nColumn=P2 */ -#define OP_BitAnd 101 /* same as TK_BITAND, synopsis: r[P3]=r[P1]&r[P2] */ -#define OP_BitOr 102 /* same as TK_BITOR, synopsis: r[P3]=r[P1]|r[P2] */ -#define OP_ShiftLeft 103 /* same as TK_LSHIFT, synopsis: r[P3]=r[P2]<>r[P1] */ -#define OP_Add 105 /* same as TK_PLUS, synopsis: r[P3]=r[P1]+r[P2] */ -#define OP_Subtract 106 /* same as TK_MINUS, synopsis: r[P3]=r[P2]-r[P1] */ -#define OP_Multiply 107 /* same as TK_STAR, synopsis: r[P3]=r[P1]*r[P2] */ -#define OP_Divide 108 /* same as TK_SLASH, synopsis: r[P3]=r[P2]/r[P1] */ -#define OP_Remainder 109 /* same as TK_REM, synopsis: r[P3]=r[P2]%r[P1] */ -#define OP_Concat 110 /* same as TK_CONCAT, synopsis: r[P3]=r[P2]+r[P1] */ -#define OP_SorterOpen 111 -#define OP_BitNot 112 /* same as TK_BITNOT, synopsis: r[P2]= ~r[P1] */ -#define OP_SequenceTest 113 /* synopsis: if( cursor[P1].ctr++ ) pc = P2 */ -#define OP_OpenPseudo 114 /* synopsis: P3 columns in r[P2] */ -#define OP_String8 115 /* same as TK_STRING, synopsis: r[P2]='P4' */ -#define OP_Close 116 -#define OP_ColumnsUsed 117 -#define OP_SeekHit 118 /* synopsis: seekHit=P2 */ -#define OP_Sequence 119 /* synopsis: r[P2]=cursor[P1].ctr++ */ -#define OP_NewRowid 120 /* synopsis: r[P2]=rowid */ -#define OP_Insert 121 /* synopsis: intkey=r[P3] data=r[P2] */ -#define OP_Delete 122 -#define OP_ResetCount 123 -#define OP_SorterCompare 124 /* synopsis: if key(P1)!=trim(r[P3],P4) goto P2 */ -#define OP_SorterData 125 /* synopsis: r[P2]=data */ -#define OP_RowData 126 /* synopsis: r[P2]=data */ -#define OP_Rowid 127 /* synopsis: r[P2]=rowid */ -#define OP_NullRow 128 -#define OP_SeekEnd 129 -#define OP_SorterInsert 130 /* synopsis: key=r[P2] */ -#define OP_IdxInsert 131 /* synopsis: key=r[P2] */ -#define OP_IdxDelete 132 /* synopsis: key=r[P2@P3] */ -#define OP_DeferredSeek 133 /* synopsis: Move P3 to P1.rowid if needed */ -#define OP_IdxRowid 134 /* synopsis: r[P2]=rowid */ -#define OP_FinishSeek 135 +#define OP_IncrVacuum 59 /* jump */ +#define OP_VNext 60 /* jump */ +#define OP_Init 61 /* jump, synopsis: Start at P2 */ +#define OP_PureFunc0 62 +#define OP_Function0 63 /* synopsis: r[P3]=func(r[P2@P5]) */ +#define OP_PureFunc 64 +#define OP_Function 65 /* synopsis: r[P3]=func(r[P2@P5]) */ +#define OP_Return 66 +#define OP_EndCoroutine 67 +#define OP_HaltIfNull 68 /* synopsis: if r[P3]=null halt */ +#define OP_Halt 69 +#define OP_Integer 70 /* synopsis: r[P2]=P1 */ +#define OP_Int64 71 /* synopsis: r[P2]=P4 */ +#define OP_String 72 /* synopsis: r[P2]='P4' (len=P1) */ +#define OP_Null 73 /* synopsis: r[P2..P3]=NULL */ +#define OP_SoftNull 74 /* synopsis: r[P1]=NULL */ +#define OP_Blob 75 /* synopsis: r[P2]=P4 (len=P1) */ +#define OP_Variable 76 /* synopsis: r[P2]=parameter(P1,P4) */ +#define OP_Move 77 /* synopsis: r[P2@P3]=r[P1@P3] */ +#define OP_Copy 78 /* synopsis: r[P2@P3+1]=r[P1@P3+1] */ +#define OP_SCopy 79 /* synopsis: r[P2]=r[P1] */ +#define OP_IntCopy 80 /* synopsis: r[P2]=r[P1] */ +#define OP_ResultRow 81 /* synopsis: output=r[P1@P2] */ +#define OP_CollSeq 82 +#define OP_AddImm 83 /* synopsis: r[P1]=r[P1]+P2 */ +#define OP_RealAffinity 84 +#define OP_Cast 85 /* synopsis: affinity(r[P1]) */ +#define OP_Permutation 86 +#define OP_Compare 87 /* synopsis: r[P1@P3] <-> r[P2@P3] */ +#define OP_IsTrue 88 /* synopsis: r[P2] = coalesce(r[P1]==TRUE,P3) ^ P4 */ +#define OP_Offset 89 /* synopsis: r[P3] = sqlite_offset(P1) */ +#define OP_Column 90 /* synopsis: r[P3]=PX */ +#define OP_Affinity 91 /* synopsis: affinity(r[P1@P2]) */ +#define OP_MakeRecord 92 /* synopsis: r[P3]=mkrec(r[P1@P2]) */ +#define OP_Count 93 /* synopsis: r[P2]=count() */ +#define OP_ReadCookie 94 +#define OP_SetCookie 95 +#define OP_ReopenIdx 96 /* synopsis: root=P2 iDb=P3 */ +#define OP_OpenRead 97 /* synopsis: root=P2 iDb=P3 */ +#define OP_OpenWrite 98 /* synopsis: root=P2 iDb=P3 */ +#define OP_BitAnd 99 /* same as TK_BITAND, synopsis: r[P3]=r[P1]&r[P2] */ +#define OP_BitOr 100 /* same as TK_BITOR, synopsis: r[P3]=r[P1]|r[P2] */ +#define OP_ShiftLeft 101 /* same as TK_LSHIFT, synopsis: r[P3]=r[P2]<>r[P1] */ +#define OP_Add 103 /* same as TK_PLUS, synopsis: r[P3]=r[P1]+r[P2] */ +#define OP_Subtract 104 /* same as TK_MINUS, synopsis: r[P3]=r[P2]-r[P1] */ +#define OP_Multiply 105 /* same as TK_STAR, synopsis: r[P3]=r[P1]*r[P2] */ +#define OP_Divide 106 /* same as TK_SLASH, synopsis: r[P3]=r[P2]/r[P1] */ +#define OP_Remainder 107 /* same as TK_REM, synopsis: r[P3]=r[P2]%r[P1] */ +#define OP_Concat 108 /* same as TK_CONCAT, synopsis: r[P3]=r[P2]+r[P1] */ +#define OP_OpenDup 109 +#define OP_BitNot 110 /* same as TK_BITNOT, synopsis: r[P2]= ~r[P1] */ +#define OP_OpenAutoindex 111 /* synopsis: nColumn=P2 */ +#define OP_OpenEphemeral 112 /* synopsis: nColumn=P2 */ +#define OP_String8 113 /* same as TK_STRING, synopsis: r[P2]='P4' */ +#define OP_SorterOpen 114 +#define OP_SequenceTest 115 /* synopsis: if( cursor[P1].ctr++ ) pc = P2 */ +#define OP_OpenPseudo 116 /* synopsis: P3 columns in r[P2] */ +#define OP_Close 117 +#define OP_ColumnsUsed 118 +#define OP_SeekHit 119 /* synopsis: seekHit=P2 */ +#define OP_Sequence 120 /* synopsis: r[P2]=cursor[P1].ctr++ */ +#define OP_NewRowid 121 /* synopsis: r[P2]=rowid */ +#define OP_Insert 122 /* synopsis: intkey=r[P3] data=r[P2] */ +#define OP_Delete 123 +#define OP_ResetCount 124 +#define OP_SorterCompare 125 /* synopsis: if key(P1)!=trim(r[P3],P4) goto P2 */ +#define OP_SorterData 126 /* synopsis: r[P2]=data */ +#define OP_RowData 127 /* synopsis: r[P2]=data */ +#define OP_Rowid 128 /* synopsis: r[P2]=rowid */ +#define OP_NullRow 129 +#define OP_SeekEnd 130 +#define OP_SorterInsert 131 /* synopsis: key=r[P2] */ +#define OP_IdxInsert 132 /* synopsis: key=r[P2] */ +#define OP_IdxDelete 133 /* synopsis: key=r[P2@P3] */ +#define OP_DeferredSeek 134 /* synopsis: Move P3 to P1.rowid if needed */ +#define OP_IdxRowid 135 /* synopsis: r[P2]=rowid */ #define OP_Destroy 136 #define OP_Clear 137 #define OP_ResetSorter 138 @@ -15340,9 +15088,9 @@ typedef struct VdbeOpList VdbeOpList; #define OP_DropTrigger 145 #define OP_IntegrityCk 146 #define OP_RowSetAdd 147 /* synopsis: rowset(P1)=r[P2] */ -#define OP_Param 148 -#define OP_FkCounter 149 /* synopsis: fkctr[P1]+=P2 */ -#define OP_Real 150 /* same as TK_FLOAT, synopsis: r[P2]=P4 */ +#define OP_Real 148 /* same as TK_FLOAT, synopsis: r[P2]=P4 */ +#define OP_Param 149 +#define OP_FkCounter 150 /* synopsis: fkctr[P1]+=P2 */ #define OP_MemMax 151 /* synopsis: r[P1]=max(r[P1],r[P2]) */ #define OP_OffsetLimit 152 /* synopsis: if r[P1]>0 then r[P2]=r[P1]+max(0,r[P3]) else r[P2]=(-1) */ #define OP_AggInverse 153 /* synopsis: accum=r[P3] inverse(r[P2@P5]) */ @@ -15351,23 +15099,20 @@ typedef struct VdbeOpList VdbeOpList; #define OP_AggValue 156 /* synopsis: r[P3]=value N=P2 */ #define OP_AggFinal 157 /* synopsis: accum=r[P1] N=P2 */ #define OP_Expire 158 -#define OP_CursorLock 159 -#define OP_CursorUnlock 160 -#define OP_TableLock 161 /* synopsis: iDb=P1 root=P2 write=P3 */ -#define OP_VBegin 162 -#define OP_VCreate 163 -#define OP_VDestroy 164 -#define OP_VOpen 165 -#define OP_VColumn 166 /* synopsis: r[P3]=vcolumn(P2) */ -#define OP_VRename 167 -#define OP_Pagecount 168 -#define OP_MaxPgcnt 169 -#define OP_Trace 170 -#define OP_CursorHint 171 -#define OP_ReleaseReg 172 /* synopsis: release r[P1@P2] mask P3 */ -#define OP_Noop 173 -#define OP_Explain 174 -#define OP_Abortable 175 +#define OP_TableLock 159 /* synopsis: iDb=P1 root=P2 write=P3 */ +#define OP_VBegin 160 +#define OP_VCreate 161 +#define OP_VDestroy 162 +#define OP_VOpen 163 +#define OP_VColumn 164 /* synopsis: r[P3]=vcolumn(P2) */ +#define OP_VRename 165 +#define OP_Pagecount 166 +#define OP_MaxPgcnt 167 +#define OP_Trace 168 +#define OP_CursorHint 169 +#define OP_Noop 170 +#define OP_Explain 171 +#define OP_Abortable 172 /* Properties such as "out2" or "jump" that are specified in ** comments following the "case" for each opcode in the vdbe.c @@ -15383,26 +15128,25 @@ typedef struct VdbeOpList VdbeOpList; /* 0 */ 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x10,\ /* 8 */ 0x00, 0x01, 0x00, 0x01, 0x01, 0x01, 0x03, 0x03,\ /* 16 */ 0x01, 0x01, 0x03, 0x12, 0x03, 0x01, 0x09, 0x09,\ -/* 24 */ 0x09, 0x09, 0x01, 0x09, 0x09, 0x09, 0x09, 0x09,\ -/* 32 */ 0x09, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,\ -/* 40 */ 0x01, 0x01, 0x23, 0x26, 0x26, 0x0b, 0x01, 0x01,\ +/* 24 */ 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09,\ +/* 32 */ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,\ +/* 40 */ 0x01, 0x23, 0x0b, 0x26, 0x26, 0x01, 0x01, 0x03,\ /* 48 */ 0x03, 0x03, 0x03, 0x03, 0x0b, 0x0b, 0x0b, 0x0b,\ -/* 56 */ 0x0b, 0x0b, 0x01, 0x03, 0x01, 0x01, 0x01, 0x00,\ -/* 64 */ 0x00, 0x02, 0x02, 0x08, 0x00, 0x10, 0x10, 0x10,\ -/* 72 */ 0x10, 0x00, 0x10, 0x10, 0x00, 0x00, 0x10, 0x10,\ -/* 80 */ 0x00, 0x00, 0x02, 0x02, 0x02, 0x00, 0x00, 0x12,\ -/* 88 */ 0x20, 0x00, 0x00, 0x00, 0x10, 0x10, 0x00, 0x00,\ -/* 96 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x26, 0x26, 0x26,\ -/* 104 */ 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x00,\ -/* 112 */ 0x12, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x10,\ -/* 120 */ 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10,\ -/* 128 */ 0x00, 0x00, 0x04, 0x04, 0x00, 0x00, 0x10, 0x00,\ +/* 56 */ 0x0b, 0x0b, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00,\ +/* 64 */ 0x00, 0x00, 0x02, 0x02, 0x08, 0x00, 0x10, 0x10,\ +/* 72 */ 0x10, 0x10, 0x00, 0x10, 0x10, 0x00, 0x00, 0x10,\ +/* 80 */ 0x10, 0x00, 0x00, 0x02, 0x02, 0x02, 0x00, 0x00,\ +/* 88 */ 0x12, 0x20, 0x00, 0x00, 0x00, 0x10, 0x10, 0x00,\ +/* 96 */ 0x00, 0x00, 0x00, 0x26, 0x26, 0x26, 0x26, 0x26,\ +/* 104 */ 0x26, 0x26, 0x26, 0x26, 0x26, 0x00, 0x12, 0x00,\ +/* 112 */ 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\ +/* 120 */ 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\ +/* 128 */ 0x10, 0x00, 0x00, 0x04, 0x04, 0x00, 0x00, 0x10,\ /* 136 */ 0x10, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00,\ -/* 144 */ 0x00, 0x00, 0x00, 0x06, 0x10, 0x00, 0x10, 0x04,\ +/* 144 */ 0x00, 0x00, 0x00, 0x06, 0x10, 0x10, 0x00, 0x04,\ /* 152 */ 0x1a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\ -/* 160 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\ -/* 168 */ 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\ -} +/* 160 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x10,\ +/* 168 */ 0x00, 0x00, 0x00, 0x00, 0x00,} /* The sqlite3P2Values() routine is able to run faster if it knows ** the value of the largest JUMP opcode. The smaller the maximum @@ -15410,7 +15154,7 @@ typedef struct VdbeOpList VdbeOpList; ** generated this include file strives to group all JUMP opcodes ** together near the beginning of the list. */ -#define SQLITE_MX_JUMP_OPCODE 62 /* Maximum JUMP opcode */ +#define SQLITE_MX_JUMP_OPCODE 61 /* Maximum JUMP opcode */ /************** End of opcodes.h *********************************************/ /************** Continuing where we left off in vdbe.h ***********************/ @@ -15426,7 +15170,6 @@ typedef struct VdbeOpList VdbeOpList; ** for a description of what each of these routines does. */ SQLITE_PRIVATE Vdbe *sqlite3VdbeCreate(Parse*); -SQLITE_PRIVATE Parse *sqlite3VdbeParser(Vdbe*); SQLITE_PRIVATE int sqlite3VdbeAddOp0(Vdbe*,int); SQLITE_PRIVATE int sqlite3VdbeAddOp1(Vdbe*,int,int); SQLITE_PRIVATE int sqlite3VdbeAddOp2(Vdbe*,int,int,int); @@ -15437,7 +15180,6 @@ SQLITE_PRIVATE int sqlite3VdbeAddOp3(Vdbe*,int,int,int,int); SQLITE_PRIVATE int sqlite3VdbeAddOp4(Vdbe*,int,int,int,int,const char *zP4,int); SQLITE_PRIVATE int sqlite3VdbeAddOp4Dup8(Vdbe*,int,int,int,int,const u8*,int); SQLITE_PRIVATE int sqlite3VdbeAddOp4Int(Vdbe*,int,int,int,int,int); -SQLITE_PRIVATE int sqlite3VdbeAddFunctionCall(Parse*,int,int,int,int,const FuncDef*,int); SQLITE_PRIVATE void sqlite3VdbeEndCoroutine(Vdbe*,int); #if defined(SQLITE_DEBUG) && !defined(SQLITE_TEST_REALLOC_STRESS) SQLITE_PRIVATE void sqlite3VdbeVerifyNoMallocRequired(Vdbe *p, int N); @@ -15479,11 +15221,6 @@ SQLITE_PRIVATE void sqlite3VdbeChangeP5(Vdbe*, u16 P5); SQLITE_PRIVATE void sqlite3VdbeJumpHere(Vdbe*, int addr); SQLITE_PRIVATE int sqlite3VdbeChangeToNoop(Vdbe*, int addr); SQLITE_PRIVATE int sqlite3VdbeDeletePriorOpcode(Vdbe*, u8 op); -#ifdef SQLITE_DEBUG -SQLITE_PRIVATE void sqlite3VdbeReleaseRegisters(Parse*,int addr, int n, u32 mask, int); -#else -# define sqlite3VdbeReleaseRegisters(P,A,N,M,F) -#endif SQLITE_PRIVATE void sqlite3VdbeChangeP4(Vdbe*, int addr, const char *zP4, int N); SQLITE_PRIVATE void sqlite3VdbeAppendP4(Vdbe*, void *pP4, int p4type); SQLITE_PRIVATE void sqlite3VdbeSetP4KeyInfo(Parse*, Index*); @@ -15532,8 +15269,9 @@ SQLITE_PRIVATE UnpackedRecord *sqlite3VdbeAllocUnpackedRecord(KeyInfo*); typedef int (*RecordCompare)(int,const void*,UnpackedRecord*); SQLITE_PRIVATE RecordCompare sqlite3VdbeFindCompare(UnpackedRecord*); +#ifndef SQLITE_OMIT_TRIGGER SQLITE_PRIVATE void sqlite3VdbeLinkSubProgram(Vdbe *, SubProgram *); -SQLITE_PRIVATE int sqlite3VdbeHasSubProgram(Vdbe*); +#endif SQLITE_PRIVATE int sqlite3NotPureFunc(sqlite3_context*); @@ -15847,7 +15585,7 @@ SQLITE_PRIVATE u32 sqlite3PagerDataVersion(Pager*); SQLITE_PRIVATE int sqlite3PagerRefcount(Pager*); #endif SQLITE_PRIVATE int sqlite3PagerMemUsed(Pager*); -SQLITE_PRIVATE const char *sqlite3PagerFilename(const Pager*, int); +SQLITE_PRIVATE const char *sqlite3PagerFilename(Pager*, int); SQLITE_PRIVATE sqlite3_vfs *sqlite3PagerVfs(Pager*); SQLITE_PRIVATE sqlite3_file *sqlite3PagerFile(Pager*); SQLITE_PRIVATE sqlite3_file *sqlite3PagerJrnlFile(Pager*); @@ -16567,47 +16305,15 @@ struct Schema { ** is shared by multiple database connections. Therefore, while parsing ** schema information, the Lookaside.bEnabled flag is cleared so that ** lookaside allocations are not used to construct the schema objects. -** -** New lookaside allocations are only allowed if bDisable==0. When -** bDisable is greater than zero, sz is set to zero which effectively -** disables lookaside without adding a new test for the bDisable flag -** in a performance-critical path. sz should be set by to szTrue whenever -** bDisable changes back to zero. -** -** Lookaside buffers are initially held on the pInit list. As they are -** used and freed, they are added back to the pFree list. New allocations -** come off of pFree first, then pInit as a fallback. This dual-list -** allows use to compute a high-water mark - the maximum number of allocations -** outstanding at any point in the past - by subtracting the number of -** allocations on the pInit list from the total number of allocations. -** -** Enhancement on 2019-12-12: Two-size-lookaside -** The default lookaside configuration is 100 slots of 1200 bytes each. -** The larger slot sizes are important for performance, but they waste -** a lot of space, as most lookaside allocations are less than 128 bytes. -** The two-size-lookaside enhancement breaks up the lookaside allocation -** into two pools: One of 128-byte slots and the other of the default size -** (1200-byte) slots. Allocations are filled from the small-pool first, -** failing over to the full-size pool if that does not work. Thus more -** lookaside slots are available while also using less memory. -** This enhancement can be omitted by compiling with -** SQLITE_OMIT_TWOSIZE_LOOKASIDE. */ struct Lookaside { u32 bDisable; /* Only operate the lookaside when zero */ u16 sz; /* Size of each buffer in bytes */ - u16 szTrue; /* True value of sz, even if disabled */ u8 bMalloced; /* True if pStart obtained from sqlite3_malloc() */ u32 nSlot; /* Number of lookaside slots allocated */ u32 anStat[3]; /* 0: hits. 1: size misses. 2: full misses */ LookasideSlot *pInit; /* List of buffers not previously used */ LookasideSlot *pFree; /* List of available buffers */ -#ifndef SQLITE_OMIT_TWOSIZE_LOOKASIDE - LookasideSlot *pSmallInit; /* List of small buffers not prediously used */ - LookasideSlot *pSmallFree; /* List of available small buffers */ - void *pMiddle; /* First byte past end of full-size buffers and - ** the first byte of LOOKASIDE_SMALL buffers */ -#endif /* SQLITE_OMIT_TWOSIZE_LOOKASIDE */ void *pStart; /* First byte of available memory space */ void *pEnd; /* First byte past end of available space */ }; @@ -16615,17 +16321,6 @@ struct LookasideSlot { LookasideSlot *pNext; /* Next buffer in the list of free buffers */ }; -#define DisableLookaside db->lookaside.bDisable++;db->lookaside.sz=0 -#define EnableLookaside db->lookaside.bDisable--;\ - db->lookaside.sz=db->lookaside.bDisable?0:db->lookaside.szTrue - -/* Size of the smaller allocations in two-size lookside */ -#ifdef SQLITE_OMIT_TWOSIZE_LOOKASIDE -# define LOOKASIDE_SMALL 0 -#else -# define LOOKASIDE_SMALL 128 -#endif - /* ** A hash table for built-in function definitions. (Application-defined ** functions use a regular table table from hash.h.) @@ -16834,13 +16529,6 @@ struct sqlite3 { #define SCHEMA_ENC(db) ((db)->aDb[0].pSchema->enc) #define ENC(db) ((db)->enc) -/* -** A u64 constant where the lower 32 bits are all zeros. Only the -** upper 32 bits are included in the argument. Necessary because some -** C-compilers still do not accept LL integer literals. -*/ -#define HI(X) ((u64)(X)<<32) - /* ** Possible values for the sqlite3.flags. ** @@ -16856,8 +16544,9 @@ struct sqlite3 { #define SQLITE_CkptFullFSync 0x00000010 /* Use full fsync for checkpoint */ #define SQLITE_CacheSpill 0x00000020 /* OK to spill pager cache */ #define SQLITE_ShortColNames 0x00000040 /* Show short columns names */ -#define SQLITE_TrustedSchema 0x00000080 /* Allow unsafe functions and - ** vtabs in the schema definition */ +#define SQLITE_CountRows 0x00000080 /* Count rows changed by INSERT, */ + /* DELETE, or UPDATE and return */ + /* the count using a callback. */ #define SQLITE_NullCallback 0x00000100 /* Invoke the callback once if the */ /* result set is empty */ #define SQLITE_IgnoreChecks 0x00000200 /* Do not enforce check constraints */ @@ -16883,11 +16572,9 @@ struct sqlite3 { #define SQLITE_DqsDDL 0x20000000 /* dbl-quoted strings allowed in DDL*/ #define SQLITE_DqsDML 0x40000000 /* dbl-quoted strings allowed in DML*/ #define SQLITE_EnableView 0x80000000 /* Enable the use of views */ -#define SQLITE_CountRows HI(0x00001) /* Count rows changed by INSERT, */ - /* DELETE, or UPDATE and return */ - /* the count using a callback. */ /* Flags used only if debugging */ +#define HI(X) ((u64)(X)<<32) #ifdef SQLITE_DEBUG #define SQLITE_SqlTrace HI(0x0100000) /* Debug print SQL as it executes */ #define SQLITE_VdbeListing HI(0x0200000) /* Debug listings of VDBE progs */ @@ -16905,7 +16592,6 @@ struct sqlite3 { #define DBFLAG_Vacuum 0x0004 /* Currently in a VACUUM */ #define DBFLAG_VacuumInto 0x0008 /* Currently running VACUUM INTO */ #define DBFLAG_SchemaKnownOk 0x0010 /* Schema is known to be valid */ -#define DBFLAG_InternalFunc 0x0020 /* Allow use of internal functions */ /* ** Bits of the sqlite3.dbOptFlags field that are used by the @@ -17013,7 +16699,6 @@ struct FuncDestructor { ** SQLITE_FUNC_TYPEOF == OPFLAG_TYPEOFARG ** SQLITE_FUNC_CONSTANT == SQLITE_DETERMINISTIC from the API ** SQLITE_FUNC_DIRECT == SQLITE_DIRECTONLY from the API -** SQLITE_FUNC_UNSAFE == SQLITE_INNOCUOUS ** SQLITE_FUNC_ENCMASK depends on SQLITE_UTF* macros in the API */ #define SQLITE_FUNC_ENCMASK 0x0003 /* SQLITE_UTF8, SQLITE_UTF16BE or UTF16LE */ @@ -17030,22 +16715,12 @@ struct FuncDestructor { #define SQLITE_FUNC_MINMAX 0x1000 /* True for min() and max() aggregates */ #define SQLITE_FUNC_SLOCHNG 0x2000 /* "Slow Change". Value constant during a ** single query - might change over time */ -#define SQLITE_FUNC_TEST 0x4000 /* Built-in testing functions */ +#define SQLITE_FUNC_AFFINITY 0x4000 /* Built-in affinity() function */ #define SQLITE_FUNC_OFFSET 0x8000 /* Built-in sqlite_offset() function */ #define SQLITE_FUNC_WINDOW 0x00010000 /* Built-in window-only function */ #define SQLITE_FUNC_INTERNAL 0x00040000 /* For use by NestedParse() only */ #define SQLITE_FUNC_DIRECT 0x00080000 /* Not for use in TRIGGERs or VIEWs */ #define SQLITE_FUNC_SUBTYPE 0x00100000 /* Result likely to have sub-type */ -#define SQLITE_FUNC_UNSAFE 0x00200000 /* Function has side effects */ -#define SQLITE_FUNC_INLINE 0x00400000 /* Functions implemented in-line */ - -/* Identifier numbers for each in-line function */ -#define INLINEFUNC_coalesce 0 -#define INLINEFUNC_implies_nonnull_row 1 -#define INLINEFUNC_expr_implies_expr 2 -#define INLINEFUNC_expr_compare 3 -#define INLINEFUNC_affinity 4 -#define INLINEFUNC_unlikely 99 /* Default case */ /* ** The following three macros, FUNCTION(), LIKEFUNC() and AGGREGATE() are @@ -17061,22 +16736,6 @@ struct FuncDestructor { ** VFUNCTION(zName, nArg, iArg, bNC, xFunc) ** Like FUNCTION except it omits the SQLITE_FUNC_CONSTANT flag. ** -** SFUNCTION(zName, nArg, iArg, bNC, xFunc) -** Like FUNCTION except it omits the SQLITE_FUNC_CONSTANT flag and -** adds the SQLITE_DIRECTONLY flag. -** -** INLINE_FUNC(zName, nArg, iFuncId, mFlags) -** zName is the name of a function that is implemented by in-line -** byte code rather than by the usual callbacks. The iFuncId -** parameter determines the function id. The mFlags parameter is -** optional SQLITE_FUNC_ flags for this function. -** -** TEST_FUNC(zName, nArg, iFuncId, mFlags) -** zName is the name of a test-only function implemented by in-line -** byte code rather than by the usual callbacks. The iFuncId -** parameter determines the function id. The mFlags parameter is -** optional SQLITE_FUNC_ flags for this function. -** ** DFUNCTION(zName, nArg, iArg, bNC, xFunc) ** Like FUNCTION except it omits the SQLITE_FUNC_CONSTANT flag and ** adds the SQLITE_FUNC_SLOCHNG flag. Used for date & time functions @@ -17116,16 +16775,6 @@ struct FuncDestructor { #define VFUNCTION(zName, nArg, iArg, bNC, xFunc) \ {nArg, SQLITE_UTF8|(bNC*SQLITE_FUNC_NEEDCOLL), \ SQLITE_INT_TO_PTR(iArg), 0, xFunc, 0, 0, 0, #zName, {0} } -#define SFUNCTION(zName, nArg, iArg, bNC, xFunc) \ - {nArg, SQLITE_UTF8|SQLITE_DIRECTONLY|SQLITE_FUNC_UNSAFE, \ - SQLITE_INT_TO_PTR(iArg), 0, xFunc, 0, 0, 0, #zName, {0} } -#define INLINE_FUNC(zName, nArg, iArg, mFlags) \ - {nArg, SQLITE_UTF8|SQLITE_FUNC_INLINE|SQLITE_FUNC_CONSTANT|(mFlags), \ - SQLITE_INT_TO_PTR(iArg), 0, noopFunc, 0, 0, 0, #zName, {0} } -#define TEST_FUNC(zName, nArg, iArg, mFlags) \ - {nArg, SQLITE_UTF8|SQLITE_FUNC_INTERNAL|SQLITE_FUNC_TEST| \ - SQLITE_FUNC_INLINE|SQLITE_FUNC_CONSTANT|(mFlags), \ - SQLITE_INT_TO_PTR(iArg), 0, noopFunc, 0, 0, 0, #zName, {0} } #define DFUNCTION(zName, nArg, iArg, bNC, xFunc) \ {nArg, SQLITE_FUNC_SLOCHNG|SQLITE_UTF8, \ 0, 0, xFunc, 0, 0, 0, #zName, {0} } @@ -17141,6 +16790,12 @@ struct FuncDestructor { #define LIKEFUNC(zName, nArg, arg, flags) \ {nArg, SQLITE_FUNC_CONSTANT|SQLITE_UTF8|flags, \ (void *)arg, 0, likeFunc, 0, 0, 0, #zName, {0} } +#define AGGREGATE(zName, nArg, arg, nc, xStep, xFinal, xValue) \ + {nArg, SQLITE_UTF8|(nc*SQLITE_FUNC_NEEDCOLL), \ + SQLITE_INT_TO_PTR(arg), 0, xStep,xFinal,xValue,0,#zName, {0}} +#define AGGREGATE2(zName, nArg, arg, nc, xStep, xFinal, extraFlags) \ + {nArg, SQLITE_UTF8|(nc*SQLITE_FUNC_NEEDCOLL)|extraFlags, \ + SQLITE_INT_TO_PTR(arg), 0, xStep,xFinal,xFinal,0,#zName, {0}} #define WAGGREGATE(zName, nArg, arg, nc, xStep, xFinal, xValue, xInverse, f) \ {nArg, SQLITE_UTF8|(nc*SQLITE_FUNC_NEEDCOLL)|f, \ SQLITE_INT_TO_PTR(arg), 0, xStep,xFinal,xValue,xInverse,#zName, {0}} @@ -17186,45 +16841,26 @@ struct Module { }; /* -** Information about each column of an SQL table is held in an instance -** of the Column structure, in the Table.aCol[] array. -** -** Definitions: -** -** "table column index" This is the index of the column in the -** Table.aCol[] array, and also the index of -** the column in the original CREATE TABLE stmt. -** -** "storage column index" This is the index of the column in the -** record BLOB generated by the OP_MakeRecord -** opcode. The storage column index is less than -** or equal to the table column index. It is -** equal if and only if there are no VIRTUAL -** columns to the left. +** information about each column of an SQL table is held in an instance +** of this structure. */ struct Column { char *zName; /* Name of this column, \000, then the type */ - Expr *pDflt; /* Default value or GENERATED ALWAYS AS value */ + Expr *pDflt; /* Default value of this column */ char *zColl; /* Collating sequence. If NULL, use the default */ u8 notNull; /* An OE_ code for handling a NOT NULL constraint */ char affinity; /* One of the SQLITE_AFF_... values */ u8 szEst; /* Estimated size of value in this column. sizeof(INT)==1 */ - u16 colFlags; /* Boolean properties. See COLFLAG_ defines below */ + u8 colFlags; /* Boolean properties. See COLFLAG_ defines below */ }; /* Allowed values for Column.colFlags: */ -#define COLFLAG_PRIMKEY 0x0001 /* Column is part of the primary key */ -#define COLFLAG_HIDDEN 0x0002 /* A hidden column in a virtual table */ -#define COLFLAG_HASTYPE 0x0004 /* Type name follows column name */ -#define COLFLAG_UNIQUE 0x0008 /* Column def contains "UNIQUE" or "PK" */ +#define COLFLAG_PRIMKEY 0x0001 /* Column is part of the primary key */ +#define COLFLAG_HIDDEN 0x0002 /* A hidden column in a virtual table */ +#define COLFLAG_HASTYPE 0x0004 /* Type name follows column name */ +#define COLFLAG_UNIQUE 0x0008 /* Column def contains "UNIQUE" or "PK" */ #define COLFLAG_SORTERREF 0x0010 /* Use sorter-refs with this column */ -#define COLFLAG_VIRTUAL 0x0020 /* GENERATED ALWAYS AS ... VIRTUAL */ -#define COLFLAG_STORED 0x0040 /* GENERATED ALWAYS AS ... STORED */ -#define COLFLAG_NOTAVAIL 0x0080 /* STORED column not yet calculated */ -#define COLFLAG_BUSY 0x0100 /* Blocks recursion on GENERATED columns */ -#define COLFLAG_GENERATED 0x0060 /* Combo: _STORED, _VIRTUAL */ -#define COLFLAG_NOINSERT 0x0062 /* Combo: _HIDDEN, _STORED, _VIRTUAL */ /* ** A "Collating Sequence" is defined by an instance of the following @@ -17342,17 +16978,10 @@ struct VTable { sqlite3_vtab *pVtab; /* Pointer to vtab instance */ int nRef; /* Number of pointers to this structure */ u8 bConstraint; /* True if constraints are supported */ - u8 eVtabRisk; /* Riskiness of allowing hacker access */ int iSavepoint; /* Depth of the SAVEPOINT stack */ VTable *pNext; /* Next in linked list (see above) */ }; -/* Allowed values for VTable.eVtabRisk -*/ -#define SQLITE_VTABRISK_Low 0 -#define SQLITE_VTABRISK_Normal 1 -#define SQLITE_VTABRISK_High 2 - /* ** The schema for each SQL table and view is represented in memory ** by an instance of the following structure. @@ -17371,7 +17000,6 @@ struct Table { u32 tabFlags; /* Mask of TF_* values */ i16 iPKey; /* If not negative, use aCol[iPKey] as the rowid */ i16 nCol; /* Number of columns in this table */ - i16 nNVCol; /* Number of columns that are not VIRTUAL */ LogEst nRowLogEst; /* Estimated rows in table - from sqlite_stat1 table */ LogEst szTabRow; /* Estimated size of each table row in bytes */ #ifdef SQLITE_ENABLE_COSTMULT @@ -17398,28 +17026,20 @@ struct Table { ** followed by non-hidden columns. Example: "CREATE VIRTUAL TABLE x USING ** vtab1(a HIDDEN, b);". Since "b" is a non-hidden column but "a" is hidden, ** the TF_OOOHidden attribute would apply in this case. Such tables require -** special handling during INSERT processing. The "OOO" means "Out Of Order". -** -** Constraints: -** -** TF_HasVirtual == COLFLAG_Virtual -** TF_HasStored == COLFLAG_Stored +** special handling during INSERT processing. */ #define TF_Readonly 0x0001 /* Read-only system table */ #define TF_Ephemeral 0x0002 /* An ephemeral table */ #define TF_HasPrimaryKey 0x0004 /* Table has a primary key */ #define TF_Autoincrement 0x0008 /* Integer primary key is autoincrement */ #define TF_HasStat1 0x0010 /* nRowLogEst set from sqlite_stat1 */ -#define TF_HasVirtual 0x0020 /* Has one or more VIRTUAL columns */ -#define TF_HasStored 0x0040 /* Has one or more STORED columns */ -#define TF_HasGenerated 0x0060 /* Combo: HasVirtual + HasStored */ -#define TF_WithoutRowid 0x0080 /* No rowid. PRIMARY KEY is the key */ +#define TF_WithoutRowid 0x0020 /* No rowid. PRIMARY KEY is the key */ +#define TF_NoVisibleRowid 0x0040 /* No user-visible "rowid" column */ +#define TF_OOOHidden 0x0080 /* Out-of-Order hidden columns */ #define TF_StatsUsed 0x0100 /* Query planner decisions affected by ** Index.aiRowLogEst[] values */ -#define TF_NoVisibleRowid 0x0200 /* No user-visible "rowid" column */ -#define TF_OOOHidden 0x0400 /* Out-of-Order hidden columns */ -#define TF_HasNotNull 0x0800 /* Contains NOT NULL constraints */ -#define TF_Shadow 0x1000 /* True for a shadow table */ +#define TF_HasNotNull 0x0200 /* Contains NOT NULL constraints */ +#define TF_Shadow 0x0400 /* True for a shadow table */ /* ** Test to see whether or not a table is a virtual table. This is @@ -17670,7 +17290,6 @@ struct Index { unsigned hasStat1:1; /* aiRowLogEst values come from sqlite_stat1 */ unsigned bNoQuery:1; /* Do not use this index to optimize queries */ unsigned bAscKeyBug:1; /* True if the bba7b69f9849b5bf bug applies */ - unsigned bHasVCol:1; /* Index references one or more VIRTUAL columns */ #ifdef SQLITE_ENABLE_STAT4 int nSample; /* Number of elements in aSample[] */ int nSampleCol; /* Size of IndexSample.anEq[] and so on */ @@ -17862,10 +17481,6 @@ typedef int ynVar; struct Expr { u8 op; /* Operation performed by this node */ char affExpr; /* affinity, or RAISE type */ - u8 op2; /* TK_REGISTER/TK_TRUTH: original value of Expr.op - ** TK_COLUMN: the value of p5 for OP_Column - ** TK_AGG_FUNCTION: nesting depth - ** TK_FUNCTION: NC_SelfRef flag if needs OP_PureFunc */ u32 flags; /* Various flags. EP_* See below */ union { char *zToken; /* Token value. Zero terminated and dequoted */ @@ -17904,6 +17519,9 @@ struct Expr { ** TK_SELECT_COLUMN: column of the result vector */ i16 iAgg; /* Which entry in pAggInfo->aCol[] or ->aFunc[] */ i16 iRightJoinTable; /* If EP_FromJoin, the right table of the join */ + u8 op2; /* TK_REGISTER/TK_TRUTH: original value of Expr.op + ** TK_COLUMN: the value of p5 for OP_Column + ** TK_AGG_FUNCTION: nesting depth */ AggInfo *pAggInfo; /* Used by TK_AGG_COLUMN and TK_AGG_FUNCTION */ union { Table *pTab; /* TK_COLUMN: Table containing column. Can be NULL @@ -17932,7 +17550,7 @@ struct Expr { #define EP_DblQuoted 0x000040 /* token.z was originally in "..." */ #define EP_InfixFunc 0x000080 /* True for an infix function: LIKE, GLOB, etc */ #define EP_Collate 0x000100 /* Tree contains a TK_COLLATE operator */ -#define EP_Commuted 0x000200 /* Comparison operator has been commuted */ + /* 0x000200 Available for reuse */ #define EP_IntValue 0x000400 /* Integer value contained in u.iValue */ #define EP_xIsSelect 0x000800 /* x.pSelect is valid (otherwise x.pList is) */ #define EP_Skip 0x001000 /* Operator does not contribute to affinity */ @@ -17953,7 +17571,7 @@ struct Expr { #define EP_Static 0x8000000 /* Held in memory not obtained from malloc() */ #define EP_IsTrue 0x10000000 /* Always has boolean value of TRUE */ #define EP_IsFalse 0x20000000 /* Always has boolean value of FALSE */ -#define EP_FromDDL 0x40000000 /* Originates from sqlite_master */ +#define EP_Indirect 0x40000000 /* Contained within a TRIGGER or a VIEW */ /* ** The EP_Propagate mask is a set of properties that automatically propagate @@ -18017,28 +17635,23 @@ struct Expr { ** also be used as the argument to a function, in which case the a.zName ** field is not used. ** -** In order to try to keep memory usage down, the Expr.a.zEName field -** is used for multiple purposes: -** -** eEName Usage -** ---------- ------------------------- -** ENAME_NAME (1) the AS of result set column -** (2) COLUMN= of an UPDATE -** -** ENAME_TAB DB.TABLE.NAME used to resolve names -** of subqueries -** -** ENAME_SPAN Text of the original result set -** expression. +** By default the Expr.zSpan field holds a human-readable description of +** the expression that is used in the generation of error messages and +** column labels. In this case, Expr.zSpan is typically the text of a +** column expression as it exists in a SELECT statement. However, if +** the bSpanIsTab flag is set, then zSpan is overloaded to mean the name +** of the result column in the form: DATABASE.TABLE.COLUMN. This later +** form is used for name resolution with nested FROM clauses. */ struct ExprList { int nExpr; /* Number of expressions on the list */ struct ExprList_item { /* For each expression in the list */ Expr *pExpr; /* The parse tree for this expression */ - char *zEName; /* Token associated with this expression */ + char *zName; /* Token associated with this expression */ + char *zSpan; /* Original text of the expression */ u8 sortFlags; /* Mask of KEYINFO_ORDER_* flags */ - unsigned eEName :2; /* Meaning of zEName */ unsigned done :1; /* A flag to indicate when processing is finished */ + unsigned bSpanIsTab :1; /* zSpan holds DB.TABLE.COLUMN */ unsigned reusable :1; /* Constant expression is reusable */ unsigned bSorterRef :1; /* Defer evaluation until after sorting */ unsigned bNulls: 1; /* True if explicit "NULLS FIRST/LAST" */ @@ -18052,13 +17665,6 @@ struct ExprList { } a[1]; /* One slot for each expression in the list */ }; -/* -** Allowed values for Expr.a.eEName -*/ -#define ENAME_NAME 0 /* The AS clause of a result set */ -#define ENAME_SPAN 1 /* Complete text of the result set expression */ -#define ENAME_TAB 2 /* "DB.TABLE.NAME" for the result set */ - /* ** An instance of this structure can hold a simple list of identifiers, ** such as the list "a,b,c" in the following statements: @@ -18122,7 +17728,6 @@ struct SrcList { unsigned isCorrelated :1; /* True if sub-query is correlated */ unsigned viaCoroutine :1; /* Implemented as a co-routine */ unsigned isRecursive :1; /* True for recursive reference in WITH */ - unsigned fromDDL :1; /* Comes from sqlite_master */ } fg; int iCursor; /* The VDBE cursor number used to access this table */ Expr *pOn; /* The ON clause of a join */ @@ -18226,24 +17831,21 @@ struct NameContext { ** NC_HasWin == EP_Win ** */ -#define NC_AllowAgg 0x00001 /* Aggregate functions are allowed here */ -#define NC_PartIdx 0x00002 /* True if resolving a partial index WHERE */ -#define NC_IsCheck 0x00004 /* True if resolving a CHECK constraint */ -#define NC_GenCol 0x00008 /* True for a GENERATED ALWAYS AS clause */ -#define NC_HasAgg 0x00010 /* One or more aggregate functions seen */ -#define NC_IdxExpr 0x00020 /* True if resolving columns of CREATE INDEX */ -#define NC_SelfRef 0x0002e /* Combo: PartIdx, isCheck, GenCol, and IdxExpr */ -#define NC_VarSelect 0x00040 /* A correlated subquery has been seen */ -#define NC_UEList 0x00080 /* True if uNC.pEList is used */ -#define NC_UAggInfo 0x00100 /* True if uNC.pAggInfo is used */ -#define NC_UUpsert 0x00200 /* True if uNC.pUpsert is used */ -#define NC_MinMaxAgg 0x01000 /* min/max aggregates seen. See note above */ -#define NC_Complex 0x02000 /* True if a function or subquery seen */ -#define NC_AllowWin 0x04000 /* Window functions are allowed here */ -#define NC_HasWin 0x08000 /* One or more window functions seen */ -#define NC_IsDDL 0x10000 /* Resolving names in a CREATE statement */ -#define NC_InAggFunc 0x20000 /* True if analyzing arguments to an agg func */ -#define NC_FromDDL 0x40000 /* SQL text comes from sqlite_master */ +#define NC_AllowAgg 0x0001 /* Aggregate functions are allowed here */ +#define NC_PartIdx 0x0002 /* True if resolving a partial index WHERE */ +#define NC_IsCheck 0x0004 /* True if resolving names in a CHECK constraint */ +#define NC_InAggFunc 0x0008 /* True if analyzing arguments to an agg func */ +#define NC_HasAgg 0x0010 /* One or more aggregate functions seen */ +#define NC_IdxExpr 0x0020 /* True if resolving columns of CREATE INDEX */ +#define NC_VarSelect 0x0040 /* A correlated subquery has been seen */ +#define NC_UEList 0x0080 /* True if uNC.pEList is used */ +#define NC_UAggInfo 0x0100 /* True if uNC.pAggInfo is used */ +#define NC_UUpsert 0x0200 /* True if uNC.pUpsert is used */ +#define NC_MinMaxAgg 0x1000 /* min/max aggregates seen. See note above */ +#define NC_Complex 0x2000 /* True if a function or subquery seen */ +#define NC_AllowWin 0x4000 /* Window functions are allowed here */ +#define NC_HasWin 0x8000 /* One or more window functions seen */ +#define NC_IsDDL 0x10000 /* Resolving names in a CREATE statement */ /* ** An instance of the following object describes a single ON CONFLICT @@ -18293,13 +17895,13 @@ struct Upsert { ** sequences for the ORDER BY clause. */ struct Select { + ExprList *pEList; /* The fields of the result */ u8 op; /* One of: TK_UNION TK_ALL TK_INTERSECT TK_EXCEPT */ LogEst nSelectRow; /* Estimated number of result rows */ u32 selFlags; /* Various SF_* values */ int iLimit, iOffset; /* Memory registers holding LIMIT & OFFSET counters */ u32 selId; /* Unique identifier number for this SELECT */ int addrOpenEphm[2]; /* OP_OpenEphem opcodes related to this select */ - ExprList *pEList; /* The fields of the result */ SrcList *pSrc; /* The FROM clause */ Expr *pWhere; /* The WHERE clause */ ExprList *pGroupBy; /* The GROUP BY clause */ @@ -18324,28 +17926,26 @@ struct Select { ** SF_MinMaxAgg == NC_MinMaxAgg == SQLITE_FUNC_MINMAX ** SF_FixedLimit == WHERE_USE_LIMIT */ -#define SF_Distinct 0x0000001 /* Output should be DISTINCT */ -#define SF_All 0x0000002 /* Includes the ALL keyword */ -#define SF_Resolved 0x0000004 /* Identifiers have been resolved */ -#define SF_Aggregate 0x0000008 /* Contains agg functions or a GROUP BY */ -#define SF_HasAgg 0x0000010 /* Contains aggregate functions */ -#define SF_UsesEphemeral 0x0000020 /* Uses the OpenEphemeral opcode */ -#define SF_Expanded 0x0000040 /* sqlite3SelectExpand() called on this */ -#define SF_HasTypeInfo 0x0000080 /* FROM subqueries have Table metadata */ -#define SF_Compound 0x0000100 /* Part of a compound query */ -#define SF_Values 0x0000200 /* Synthesized from VALUES clause */ -#define SF_MultiValue 0x0000400 /* Single VALUES term with multiple rows */ -#define SF_NestedFrom 0x0000800 /* Part of a parenthesized FROM clause */ -#define SF_MinMaxAgg 0x0001000 /* Aggregate containing min() or max() */ -#define SF_Recursive 0x0002000 /* The recursive part of a recursive CTE */ -#define SF_FixedLimit 0x0004000 /* nSelectRow set by a constant LIMIT */ -#define SF_MaybeConvert 0x0008000 /* Need convertCompoundSelectToSubquery() */ -#define SF_Converted 0x0010000 /* By convertCompoundSelectToSubquery() */ -#define SF_IncludeHidden 0x0020000 /* Include hidden columns in output */ -#define SF_ComplexResult 0x0040000 /* Result contains subquery or function */ -#define SF_WhereBegin 0x0080000 /* Really a WhereBegin() call. Debug Only */ -#define SF_WinRewrite 0x0100000 /* Window function rewrite accomplished */ -#define SF_View 0x0200000 /* SELECT statement is a view */ +#define SF_Distinct 0x00001 /* Output should be DISTINCT */ +#define SF_All 0x00002 /* Includes the ALL keyword */ +#define SF_Resolved 0x00004 /* Identifiers have been resolved */ +#define SF_Aggregate 0x00008 /* Contains agg functions or a GROUP BY */ +#define SF_HasAgg 0x00010 /* Contains aggregate functions */ +#define SF_UsesEphemeral 0x00020 /* Uses the OpenEphemeral opcode */ +#define SF_Expanded 0x00040 /* sqlite3SelectExpand() called on this */ +#define SF_HasTypeInfo 0x00080 /* FROM subqueries have Table metadata */ +#define SF_Compound 0x00100 /* Part of a compound query */ +#define SF_Values 0x00200 /* Synthesized from VALUES clause */ +#define SF_MultiValue 0x00400 /* Single VALUES term with multiple rows */ +#define SF_NestedFrom 0x00800 /* Part of a parenthesized FROM clause */ +#define SF_MinMaxAgg 0x01000 /* Aggregate containing min() or max() */ +#define SF_Recursive 0x02000 /* The recursive part of a recursive CTE */ +#define SF_FixedLimit 0x04000 /* nSelectRow set by a constant LIMIT */ +#define SF_MaybeConvert 0x08000 /* Need convertCompoundSelectToSubquery() */ +#define SF_Converted 0x10000 /* By convertCompoundSelectToSubquery() */ +#define SF_IncludeHidden 0x20000 /* Include hidden columns in output */ +#define SF_ComplexResult 0x40000 /* Result contains subquery or function */ +#define SF_WhereBegin 0x80000 /* Really a WhereBegin() call. Debug Only */ /* ** The results of a SELECT can be distributed in several ways, as defined @@ -18625,8 +18225,8 @@ struct Parse { #define PARSE_MODE_NORMAL 0 #define PARSE_MODE_DECLARE_VTAB 1 -#define PARSE_MODE_RENAME 2 -#define PARSE_MODE_UNMAP 3 +#define PARSE_MODE_RENAME_COLUMN 2 +#define PARSE_MODE_RENAME_TABLE 3 /* ** Sizes and pointers of various parts of the Parse object. @@ -18648,7 +18248,7 @@ struct Parse { #if defined(SQLITE_OMIT_ALTERTABLE) #define IN_RENAME_OBJECT 0 #else - #define IN_RENAME_OBJECT (pParse->eParseMode>=PARSE_MODE_RENAME) + #define IN_RENAME_OBJECT (pParse->eParseMode>=PARSE_MODE_RENAME_COLUMN) #endif #if defined(SQLITE_OMIT_VIRTUALTABLE) && defined(SQLITE_OMIT_ALTERTABLE) @@ -18799,7 +18399,7 @@ typedef struct DbFixer DbFixer; struct DbFixer { Parse *pParse; /* The parsing context. Error messages written here */ Schema *pSchema; /* Fix items to this schema */ - u8 bTemp; /* True for TEMP schema entries */ + int bVarOnly; /* Check for variable references only */ const char *zDb; /* Make sure all objects are contained in this database */ const char *zType; /* Type of the container - used for error messages */ const Token *pName; /* Name of the container - used for error messages */ @@ -18904,6 +18504,7 @@ struct Sqlite3Config { int (*xTestCallback)(int); /* Invoked by sqlite3FaultSim() */ #endif int bLocaltimeFault; /* True to fail localtime() calls */ + int bInternalFunctions; /* Internal SQL functions are visible */ int iOnceResetThreshold; /* When to reset OP_Once counters */ u32 szSorterRef; /* Min size in bytes to use sorter-refs */ unsigned int iPrngSeed; /* Alternative fixed seed for the PRNG */ @@ -18936,7 +18537,7 @@ struct Walker { int (*xSelectCallback)(Walker*,Select*); /* Callback for SELECTs */ void (*xSelectCallback2)(Walker*,Select*);/* Second callback for SELECTs */ int walkerDepth; /* Number of subqueries */ - u16 eCode; /* A small processing code */ + u8 eCode; /* A small processing code */ union { /* Extra data for callback */ NameContext *pNC; /* Naming context */ int n; /* A counter */ @@ -18952,7 +18553,6 @@ struct Walker { struct WindowRewrite *pRewrite; /* Window rewrite context */ struct WhereConst *pConst; /* WHERE clause constants */ struct RenameCtx *pRename; /* RENAME COLUMN context */ - struct Table *pTab; /* Table of generated column */ } u; }; @@ -19066,7 +18666,7 @@ SQLITE_PRIVATE Window *sqlite3WindowAlloc(Parse*, int, int, Expr*, int , Expr*, SQLITE_PRIVATE void sqlite3WindowAttach(Parse*, Expr*, Window*); SQLITE_PRIVATE void sqlite3WindowLink(Select *pSel, Window *pWin); SQLITE_PRIVATE int sqlite3WindowCompare(Parse*, Window*, Window*, int); -SQLITE_PRIVATE void sqlite3WindowCodeInit(Parse*, Select*); +SQLITE_PRIVATE void sqlite3WindowCodeInit(Parse*, Window*); SQLITE_PRIVATE void sqlite3WindowCodeStep(Parse*, Select*, WhereInfo*, int, int); SQLITE_PRIVATE int sqlite3WindowRewrite(Parse*, Select*); SQLITE_PRIVATE int sqlite3ExpandSubquery(Parse*, struct SrcList_item*); @@ -19332,7 +18932,6 @@ SQLITE_PRIVATE void sqlite3PExprAddSelect(Parse*, Expr*, Select*); SQLITE_PRIVATE Expr *sqlite3ExprAnd(Parse*,Expr*, Expr*); SQLITE_PRIVATE Expr *sqlite3ExprSimplifiedAndOr(Expr*); SQLITE_PRIVATE Expr *sqlite3ExprFunction(Parse*,ExprList*, Token*, int); -SQLITE_PRIVATE void sqlite3ExprFunctionUsable(Parse*,Expr*,FuncDef*); SQLITE_PRIVATE void sqlite3ExprAssignVarNumber(Parse*, Expr*, u32); SQLITE_PRIVATE void sqlite3ExprDelete(sqlite3*, Expr*); SQLITE_PRIVATE void sqlite3ExprUnmapAndDelete(Parse*, Expr*); @@ -19361,14 +18960,7 @@ SQLITE_PRIVATE void sqlite3SelectAddColumnTypeAndCollation(Parse*,Table*,Select* SQLITE_PRIVATE Table *sqlite3ResultSetOfSelect(Parse*,Select*,char); SQLITE_PRIVATE void sqlite3OpenMasterTable(Parse *, int); SQLITE_PRIVATE Index *sqlite3PrimaryKeyIndex(Table*); -SQLITE_PRIVATE i16 sqlite3TableColumnToIndex(Index*, i16); -#ifdef SQLITE_OMIT_GENERATED_COLUMNS -# define sqlite3TableColumnToStorage(T,X) (X) /* No-op pass-through */ -# define sqlite3StorageColumnToTable(T,X) (X) /* No-op pass-through */ -#else -SQLITE_PRIVATE i16 sqlite3TableColumnToStorage(Table*, i16); -SQLITE_PRIVATE i16 sqlite3StorageColumnToTable(Table*, i16); -#endif +SQLITE_PRIVATE i16 sqlite3ColumnOfIndex(Index*, i16); SQLITE_PRIVATE void sqlite3StartTable(Parse*,Token*,Token*,int,int,int,int); #if SQLITE_ENABLE_HIDDEN_COLUMNS SQLITE_PRIVATE void sqlite3ColumnPropertiesFromName(Table*, Column*); @@ -19381,7 +18973,6 @@ SQLITE_PRIVATE void sqlite3AddPrimaryKey(Parse*, ExprList*, int, int, int); SQLITE_PRIVATE void sqlite3AddCheckConstraint(Parse*, Expr*); SQLITE_PRIVATE void sqlite3AddDefaultValue(Parse*,Expr*,const char*,const char*); SQLITE_PRIVATE void sqlite3AddCollateType(Parse*, Token*); -SQLITE_PRIVATE void sqlite3AddGenerated(Parse*,Expr*,Token*); SQLITE_PRIVATE void sqlite3EndTable(Parse*,Token*,Token*,u8,Select*); SQLITE_PRIVATE int sqlite3ParseUri(const char*,const char*,unsigned int*, sqlite3_vfs**,char**,char **); @@ -19439,9 +19030,6 @@ SQLITE_PRIVATE void sqlite3AutoincrementEnd(Parse *pParse); # define sqlite3AutoincrementEnd(X) #endif SQLITE_PRIVATE void sqlite3Insert(Parse*, SrcList*, Select*, IdList*, int, Upsert*); -#ifndef SQLITE_OMIT_GENERATED_COLUMNS -SQLITE_PRIVATE void sqlite3ComputeGeneratedColumns(Parse*, int, Table*); -#endif SQLITE_PRIVATE void *sqlite3ArrayAllocate(sqlite3*,void*,int,int*,int*); SQLITE_PRIVATE IdList *sqlite3IdListAppend(Parse*, IdList*, Token*); SQLITE_PRIVATE int sqlite3IdListIndex(IdList*,const char*); @@ -19464,7 +19052,6 @@ SQLITE_PRIVATE int sqlite3Select(Parse*, Select*, SelectDest*); SQLITE_PRIVATE Select *sqlite3SelectNew(Parse*,ExprList*,SrcList*,Expr*,ExprList*, Expr*,ExprList*,u32,Expr*); SQLITE_PRIVATE void sqlite3SelectDelete(sqlite3*, Select*); -SQLITE_PRIVATE void sqlite3SelectReset(Parse*, Select*); SQLITE_PRIVATE Table *sqlite3SrcListLookup(Parse*, SrcList*); SQLITE_PRIVATE int sqlite3IsReadOnly(Parse*, Table*, int); SQLITE_PRIVATE void sqlite3OpenTable(Parse*, int iCur, int iDb, Table*, int); @@ -19487,20 +19074,17 @@ SQLITE_PRIVATE int sqlite3WhereOkOnePass(WhereInfo*, int*); #define ONEPASS_OFF 0 /* Use of ONEPASS not allowed */ #define ONEPASS_SINGLE 1 /* ONEPASS valid for a single row update */ #define ONEPASS_MULTI 2 /* ONEPASS is valid for multiple rows */ -SQLITE_PRIVATE int sqlite3WhereUsesDeferredSeek(WhereInfo*); SQLITE_PRIVATE void sqlite3ExprCodeLoadIndexColumn(Parse*, Index*, int, int, int); SQLITE_PRIVATE int sqlite3ExprCodeGetColumn(Parse*, Table*, int, int, int, u8); SQLITE_PRIVATE void sqlite3ExprCodeGetColumnOfTable(Vdbe*, Table*, int, int, int); SQLITE_PRIVATE void sqlite3ExprCodeMove(Parse*, int, int, int); SQLITE_PRIVATE void sqlite3ExprCode(Parse*, Expr*, int); -#ifndef SQLITE_OMIT_GENERATED_COLUMNS -SQLITE_PRIVATE void sqlite3ExprCodeGeneratedColumn(Parse*, Column*, int); -#endif SQLITE_PRIVATE void sqlite3ExprCodeCopy(Parse*, Expr*, int); SQLITE_PRIVATE void sqlite3ExprCodeFactorable(Parse*, Expr*, int); SQLITE_PRIVATE int sqlite3ExprCodeAtInit(Parse*, Expr*, int); SQLITE_PRIVATE int sqlite3ExprCodeTemp(Parse*, Expr*, int*); SQLITE_PRIVATE int sqlite3ExprCodeTarget(Parse*, Expr*, int); +SQLITE_PRIVATE void sqlite3ExprCodeAndCache(Parse*, Expr*, int); SQLITE_PRIVATE int sqlite3ExprCodeExprList(Parse*, ExprList*, int, int, u8); #define SQLITE_ECEL_DUP 0x01 /* Deep, not shallow copies */ #define SQLITE_ECEL_FACTOR 0x02 /* Factor out constant terms */ @@ -19542,7 +19126,6 @@ SQLITE_PRIVATE void sqlite3EndTransaction(Parse*,int); SQLITE_PRIVATE void sqlite3Savepoint(Parse*, int, Token*); SQLITE_PRIVATE void sqlite3CloseSavepoints(sqlite3 *); SQLITE_PRIVATE void sqlite3LeaveMutexAndCloseZombie(sqlite3*); -SQLITE_PRIVATE u32 sqlite3IsTrueOrFalse(const char*); SQLITE_PRIVATE int sqlite3ExprIdToTrueFalse(Expr*); SQLITE_PRIVATE int sqlite3ExprTruthValue(const Expr*); SQLITE_PRIVATE int sqlite3ExprIsConstant(Expr*); @@ -19638,7 +19221,6 @@ SQLITE_PRIVATE u32 sqlite3TriggerColmask(Parse*,Trigger*,ExprList*,int,int,Tab #endif SQLITE_PRIVATE int sqlite3JoinType(Parse*, Token*, Token*, Token*); -SQLITE_PRIVATE void sqlite3SetJoinExpr(Expr*,int); SQLITE_PRIVATE void sqlite3CreateForeignKey(Parse*, ExprList*, Token*, ExprList*, int); SQLITE_PRIVATE void sqlite3DeferForeignKey(Parse*, int); #ifndef SQLITE_OMIT_AUTHORIZATION @@ -19799,12 +19381,7 @@ SQLITE_PRIVATE void sqlite3CodeRhsOfIN(Parse*, Expr*, int); SQLITE_PRIVATE int sqlite3CodeSubselect(Parse*, Expr*); SQLITE_PRIVATE void sqlite3SelectPrep(Parse*, Select*, NameContext*); SQLITE_PRIVATE void sqlite3SelectWrongNumTermsError(Parse *pParse, Select *p); -SQLITE_PRIVATE int sqlite3MatchEName( - const struct ExprList_item*, - const char*, - const char*, - const char* -); +SQLITE_PRIVATE int sqlite3MatchSpanName(const char*, const char*, const char*, const char*); SQLITE_PRIVATE int sqlite3ResolveExprNames(NameContext*, Expr*); SQLITE_PRIVATE int sqlite3ResolveExprListNames(NameContext*, ExprList*); SQLITE_PRIVATE void sqlite3ResolveSelectNames(Parse*, Select*, NameContext*); @@ -19942,12 +19519,6 @@ SQLITE_PRIVATE Module *sqlite3VtabCreateModule( ); # define sqlite3VtabInSync(db) ((db)->nVTrans>0 && (db)->aVTrans==0) #endif -SQLITE_PRIVATE int sqlite3ReadOnlyShadowTables(sqlite3 *db); -#ifndef SQLITE_OMIT_VIRTUALTABLE -SQLITE_PRIVATE int sqlite3ShadowTableName(sqlite3 *db, const char *zName); -#else -# define sqlite3ShadowTableName(A,B) 0 -#endif SQLITE_PRIVATE int sqlite3VtabEponymousTableInit(Parse*,Module*); SQLITE_PRIVATE void sqlite3VtabEponymousTableClear(sqlite3*,Module*); SQLITE_PRIVATE void sqlite3VtabMakeWritable(Parse*,Table*); @@ -19969,7 +19540,6 @@ SQLITE_PRIVATE char *sqlite3Normalize(Vdbe*, const char*); #endif SQLITE_PRIVATE int sqlite3Reprepare(Vdbe*); SQLITE_PRIVATE void sqlite3ExprListCheckLength(Parse*, ExprList*, const char*); -SQLITE_PRIVATE CollSeq *sqlite3ExprCompareCollSeq(Parse*,Expr*); SQLITE_PRIVATE CollSeq *sqlite3BinaryCompareCollSeq(Parse *, Expr *, Expr *); SQLITE_PRIVATE int sqlite3TempInMemory(const sqlite3*); SQLITE_PRIVATE const char *sqlite3JournalModename(int); @@ -20276,6 +19846,7 @@ SQLITE_PRIVATE const unsigned char sqlite3UpperToLower[] = { ** non-ASCII UTF character. Hence the test for whether or not a character is ** part of an identifier is 0x46. */ +#ifdef SQLITE_ASCII SQLITE_PRIVATE const unsigned char sqlite3CtypeMap[256] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 00..07 ........ */ 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, /* 08..0f ........ */ @@ -20313,6 +19884,7 @@ SQLITE_PRIVATE const unsigned char sqlite3CtypeMap[256] = { 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, /* f0..f7 ........ */ 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40 /* f8..ff ........ */ }; +#endif /* EVIDENCE-OF: R-02982-34736 In order to maintain full backwards ** compatibility for legacy applications, the URI filename capability is @@ -20377,18 +19949,9 @@ SQLITE_PRIVATE const unsigned char sqlite3CtypeMap[256] = { ** changed as start-time using sqlite3_config(SQLITE_CONFIG_LOOKASIDE) ** or at run-time for an individual database connection using ** sqlite3_db_config(db, SQLITE_DBCONFIG_LOOKASIDE); -** -** With the two-size-lookaside enhancement, less lookaside is required. -** The default configuration of 1200,40 actually provides 30 1200-byte slots -** and 93 128-byte slots, which is more lookaside than is available -** using the older 1200,100 configuration without two-size-lookaside. */ #ifndef SQLITE_DEFAULT_LOOKASIDE -# ifdef SQLITE_OMIT_TWOSIZE_LOOKASIDE -# define SQLITE_DEFAULT_LOOKASIDE 1200,100 /* 120KB of memory */ -# else -# define SQLITE_DEFAULT_LOOKASIDE 1200,40 /* 48KB of memory */ -# endif +# define SQLITE_DEFAULT_LOOKASIDE 1200,100 #endif @@ -20454,6 +20017,7 @@ SQLITE_PRIVATE SQLITE_WSD struct Sqlite3Config sqlite3Config = { 0, /* xTestCallback */ #endif 0, /* bLocaltimeFault */ + 0, /* bInternalFunctions */ 0x7ffffffe, /* iOnceResetThreshold */ SQLITE_DEFAULT_SORTERREF_SIZE, /* szSorterRef */ 0, /* iPrngSeed */ @@ -20818,8 +20382,7 @@ struct sqlite3_value { ** True if Mem X is a NULL-nochng type. */ #define MemNullNochng(X) \ - (((X)->flags&MEM_TypeMask)==(MEM_Null|MEM_Zero) \ - && (X)->n==0 && (X)->u.nZero==0) + ((X)->flags==(MEM_Null|MEM_Zero) && (X)->n==0 && (X)->u.nZero==0) /* ** Return true if a memory cell is not marked as invalid. This macro @@ -21015,7 +20578,6 @@ struct PreUpdate { SQLITE_PRIVATE void sqlite3VdbeError(Vdbe*, const char *, ...); SQLITE_PRIVATE void sqlite3VdbeFreeCursor(Vdbe *, VdbeCursor*); void sqliteVdbePopStack(Vdbe*,int); -SQLITE_PRIVATE int SQLITE_NOINLINE sqlite3VdbeFinishMoveto(VdbeCursor*); SQLITE_PRIVATE int sqlite3VdbeCursorMoveto(VdbeCursor**, int*); SQLITE_PRIVATE int sqlite3VdbeCursorRestore(VdbeCursor*); SQLITE_PRIVATE u32 sqlite3VdbeSerialTypeLen(u32); @@ -21062,7 +20624,7 @@ SQLITE_PRIVATE int sqlite3VdbeBooleanValue(Mem*, int ifNull); SQLITE_PRIVATE void sqlite3VdbeIntegerAffinity(Mem*); SQLITE_PRIVATE int sqlite3VdbeMemRealify(Mem*); SQLITE_PRIVATE int sqlite3VdbeMemNumerify(Mem*); -SQLITE_PRIVATE int sqlite3VdbeMemCast(Mem*,u8,u8); +SQLITE_PRIVATE void sqlite3VdbeMemCast(Mem*,u8,u8); SQLITE_PRIVATE int sqlite3VdbeMemFromBtree(BtCursor*,u32,u32,Mem*); SQLITE_PRIVATE void sqlite3VdbeMemRelease(Mem *p); SQLITE_PRIVATE int sqlite3VdbeMemFinalize(Mem*, FuncDef*); @@ -21128,7 +20690,7 @@ SQLITE_PRIVATE int sqlite3VdbeCheckFk(Vdbe *, int); #ifdef SQLITE_DEBUG SQLITE_PRIVATE void sqlite3VdbePrintSql(Vdbe*); -SQLITE_PRIVATE void sqlite3VdbeMemPrettyPrint(Mem *pMem, StrAccum *pStr); +SQLITE_PRIVATE void sqlite3VdbeMemPrettyPrint(Mem *pMem, char *zBuf); #endif #ifndef SQLITE_OMIT_UTF16 SQLITE_PRIVATE int sqlite3VdbeMemTranslate(Mem*, u8); @@ -21320,10 +20882,6 @@ static u32 countLookasideSlots(LookasideSlot *p){ SQLITE_PRIVATE int sqlite3LookasideUsed(sqlite3 *db, int *pHighwater){ u32 nInit = countLookasideSlots(db->lookaside.pInit); u32 nFree = countLookasideSlots(db->lookaside.pFree); -#ifndef SQLITE_OMIT_TWOSIZE_LOOKASIDE - nInit += countLookasideSlots(db->lookaside.pSmallInit); - nFree += countLookasideSlots(db->lookaside.pSmallFree); -#endif /* SQLITE_OMIT_TWOSIZE_LOOKASIDE */ if( pHighwater ) *pHighwater = db->lookaside.nSlot - nInit; return db->lookaside.nSlot - (nInit+nFree); } @@ -21356,15 +20914,6 @@ SQLITE_API int sqlite3_db_status( db->lookaside.pInit = db->lookaside.pFree; db->lookaside.pFree = 0; } -#ifndef SQLITE_OMIT_TWOSIZE_LOOKASIDE - p = db->lookaside.pSmallFree; - if( p ){ - while( p->pNext ) p = p->pNext; - p->pNext = db->lookaside.pSmallInit; - db->lookaside.pSmallInit = db->lookaside.pSmallFree; - db->lookaside.pSmallFree = 0; - } -#endif } break; } @@ -22216,7 +21765,7 @@ static int parseModifier( r = p->s*1000.0 + 210866760000000.0; if( r>=0.0 && r<464269060800000.0 ){ clearYMD_HMS_TZ(p); - p->iJD = (sqlite3_int64)(r + 0.5); + p->iJD = (sqlite3_int64)r; p->validJD = 1; p->rawS = 0; rc = 0; @@ -22995,7 +22544,7 @@ SQLITE_PRIVATE int sqlite3OsOpen( ** down into the VFS layer. Some SQLITE_OPEN_ flags (for example, ** SQLITE_OPEN_FULLMUTEX or SQLITE_OPEN_SHAREDCACHE) are blocked before ** reaching the VFS. */ - rc = pVfs->xOpen(pVfs, zPath, pFile, flags & 0x1087f7f, pFlagsOut); + rc = pVfs->xOpen(pVfs, zPath, pFile, flags & 0x87f7f, pFlagsOut); assert( rc==SQLITE_OK || pFile->pMethods==0 ); return rc; } @@ -26513,7 +26062,7 @@ SQLITE_PRIVATE sqlite3_mutex_methods const *sqlite3DefaultMutex(void){ ****************************************************************************** ** ** This file contains inline asm code for retrieving "high-performance" -** counters for x86 and x86_64 class CPUs. +** counters for x86 class CPUs. */ #ifndef SQLITE_HWTIME_H #define SQLITE_HWTIME_H @@ -26524,9 +26073,8 @@ SQLITE_PRIVATE sqlite3_mutex_methods const *sqlite3DefaultMutex(void){ ** processor and returns that value. This can be used for high-res ** profiling. */ -#if !defined(__STRICT_ANSI__) && \ - (defined(__GNUC__) || defined(_MSC_VER)) && \ - (defined(i386) || defined(__i386__) || defined(_M_IX86)) +#if (defined(__GNUC__) || defined(_MSC_VER)) && \ + (defined(i386) || defined(__i386__) || defined(_M_IX86)) #if defined(__GNUC__) @@ -26547,7 +26095,7 @@ SQLITE_PRIVATE sqlite3_mutex_methods const *sqlite3DefaultMutex(void){ #endif -#elif !defined(__STRICT_ANSI__) && (defined(__GNUC__) && defined(__x86_64__)) +#elif (defined(__GNUC__) && defined(__x86_64__)) __inline__ sqlite_uint64 sqlite3Hwtime(void){ unsigned long val; @@ -26555,7 +26103,7 @@ SQLITE_PRIVATE sqlite3_mutex_methods const *sqlite3DefaultMutex(void){ return val; } -#elif !defined(__STRICT_ANSI__) && (defined(__GNUC__) && defined(__ppc__)) +#elif (defined(__GNUC__) && defined(__ppc__)) __inline__ sqlite_uint64 sqlite3Hwtime(void){ unsigned long long retval; @@ -26572,13 +26120,14 @@ SQLITE_PRIVATE sqlite3_mutex_methods const *sqlite3DefaultMutex(void){ #else + #error Need implementation of sqlite3Hwtime() for your platform. + /* - ** asm() is needed for hardware timing support. Without asm(), - ** disable the sqlite3Hwtime() routine. - ** - ** sqlite3Hwtime() is only used for some obscure debugging - ** and analysis configurations, not in any deliverable, so this - ** should not be a great loss. + ** To compile without implementing sqlite3Hwtime() for your platform, + ** you can remove the above #error and use the following + ** stub function. You will lose timing support for many + ** of the debugging and testing utilities, but it should at + ** least compile and run. */ SQLITE_PRIVATE sqlite_uint64 sqlite3Hwtime(void){ return ((sqlite_uint64)0); } @@ -27162,27 +26711,19 @@ SQLITE_API int sqlite3_release_memory(int n){ #endif } -/* -** Default value of the hard heap limit. 0 means "no limit". -*/ -#ifndef SQLITE_MAX_MEMORY -# define SQLITE_MAX_MEMORY 0 -#endif - /* ** State information local to the memory allocation subsystem. */ static SQLITE_WSD struct Mem0Global { sqlite3_mutex *mutex; /* Mutex to serialize access */ sqlite3_int64 alarmThreshold; /* The soft heap limit */ - sqlite3_int64 hardLimit; /* The hard upper bound on memory */ /* ** True if heap is nearly "full" where "full" is defined by the ** sqlite3_soft_heap_limit() setting. */ int nearlyFull; -} mem0 = { 0, SQLITE_MAX_MEMORY, SQLITE_MAX_MEMORY, 0 }; +} mem0 = { 0, 0, 0 }; #define mem0 GLOBAL(struct Mem0Global, mem0) @@ -27212,15 +26753,8 @@ SQLITE_API int sqlite3_memory_alarm( #endif /* -** Set the soft heap-size limit for the library. An argument of -** zero disables the limit. A negative argument is a no-op used to -** obtain the return value. -** -** The return value is the value of the heap limit just before this -** interface was called. -** -** If the hard heap limit is enabled, then the soft heap limit cannot -** be disabled nor raised above the hard heap limit. +** Set the soft heap-size limit for the library. Passing a zero or +** negative value indicates no limit. */ SQLITE_API sqlite3_int64 sqlite3_soft_heap_limit64(sqlite3_int64 n){ sqlite3_int64 priorLimit; @@ -27236,9 +26770,6 @@ SQLITE_API sqlite3_int64 sqlite3_soft_heap_limit64(sqlite3_int64 n){ sqlite3_mutex_leave(mem0.mutex); return priorLimit; } - if( mem0.hardLimit>0 && (n>mem0.hardLimit || n==0) ){ - n = mem0.hardLimit; - } mem0.alarmThreshold = n; nUsed = sqlite3StatusValue(SQLITE_STATUS_MEMORY_USED); mem0.nearlyFull = (n>0 && n<=nUsed); @@ -27252,37 +26783,6 @@ SQLITE_API void sqlite3_soft_heap_limit(int n){ sqlite3_soft_heap_limit64(n); } -/* -** Set the hard heap-size limit for the library. An argument of zero -** disables the hard heap limit. A negative argument is a no-op used -** to obtain the return value without affecting the hard heap limit. -** -** The return value is the value of the hard heap limit just prior to -** calling this interface. -** -** Setting the hard heap limit will also activate the soft heap limit -** and constrain the soft heap limit to be no more than the hard heap -** limit. -*/ -SQLITE_API sqlite3_int64 sqlite3_hard_heap_limit64(sqlite3_int64 n){ - sqlite3_int64 priorLimit; -#ifndef SQLITE_OMIT_AUTOINIT - int rc = sqlite3_initialize(); - if( rc ) return -1; -#endif - sqlite3_mutex_enter(mem0.mutex); - priorLimit = mem0.hardLimit; - if( n>=0 ){ - mem0.hardLimit = n; - if( nSQLITE_MAX_MEMORY ){ + *pp = 0; + return; + } +#endif + sqlite3StatusHighwater(SQLITE_STATUS_MALLOC_SIZE, n); if( mem0.alarmThreshold>0 ){ sqlite3_int64 nUsed = sqlite3StatusValue(SQLITE_STATUS_MEMORY_USED); if( nUsed >= mem0.alarmThreshold - nFull ){ mem0.nearlyFull = 1; sqlite3MallocAlarm(nFull); - if( mem0.hardLimit ){ - nUsed = sqlite3StatusValue(SQLITE_STATUS_MEMORY_USED); - if( nUsed >= mem0.hardLimit - nFull ){ - *pp = 0; - return; - } - } }else{ mem0.nearlyFull = 0; } @@ -27462,17 +26962,10 @@ SQLITE_PRIVATE int sqlite3MallocSize(void *p){ assert( sqlite3MemdebugHasType(p, MEMTYPE_HEAP) ); return sqlite3GlobalConfig.m.xSize(p); } -static int lookasideMallocSize(sqlite3 *db, void *p){ -#ifndef SQLITE_OMIT_TWOSIZE_LOOKASIDE - return plookaside.pMiddle ? db->lookaside.szTrue : LOOKASIDE_SMALL; -#else - return db->lookaside.szTrue; -#endif -} SQLITE_PRIVATE int sqlite3DbMallocSize(sqlite3 *db, void *p){ assert( p!=0 ); -#ifdef SQLITE_DEBUG if( db==0 || !isLookaside(db,p) ){ +#ifdef SQLITE_DEBUG if( db==0 ){ assert( sqlite3MemdebugNoType(p, (u8)~MEMTYPE_HEAP) ); assert( sqlite3MemdebugHasType(p, MEMTYPE_HEAP) ); @@ -27480,23 +26973,12 @@ SQLITE_PRIVATE int sqlite3DbMallocSize(sqlite3 *db, void *p){ assert( sqlite3MemdebugHasType(p, (MEMTYPE_LOOKASIDE|MEMTYPE_HEAP)) ); assert( sqlite3MemdebugNoType(p, (u8)~(MEMTYPE_LOOKASIDE|MEMTYPE_HEAP)) ); } - } #endif - if( db ){ - if( ((uptr)p)<(uptr)(db->lookaside.pEnd) ){ -#ifndef SQLITE_OMIT_TWOSIZE_LOOKASIDE - if( ((uptr)p)>=(uptr)(db->lookaside.pMiddle) ){ - assert( sqlite3_mutex_held(db->mutex) ); - return LOOKASIDE_SMALL; - } -#endif - if( ((uptr)p)>=(uptr)(db->lookaside.pStart) ){ - assert( sqlite3_mutex_held(db->mutex) ); - return db->lookaside.szTrue; - } - } + return sqlite3GlobalConfig.m.xSize(p); + }else{ + assert( sqlite3_mutex_held(db->mutex) ); + return db->lookaside.sz; } - return sqlite3GlobalConfig.m.xSize(p); } SQLITE_API sqlite3_uint64 sqlite3_msize(void *p){ assert( sqlite3MemdebugNoType(p, (u8)~MEMTYPE_HEAP) ); @@ -27543,27 +27025,15 @@ SQLITE_PRIVATE void sqlite3DbFreeNN(sqlite3 *db, void *p){ measureAllocationSize(db, p); return; } - if( ((uptr)p)<(uptr)(db->lookaside.pEnd) ){ -#ifndef SQLITE_OMIT_TWOSIZE_LOOKASIDE - if( ((uptr)p)>=(uptr)(db->lookaside.pMiddle) ){ - LookasideSlot *pBuf = (LookasideSlot*)p; + if( isLookaside(db, p) ){ + LookasideSlot *pBuf = (LookasideSlot*)p; #ifdef SQLITE_DEBUG - memset(p, 0xaa, LOOKASIDE_SMALL); /* Trash freed content */ + /* Trash all content in the buffer being freed */ + memset(p, 0xaa, db->lookaside.sz); #endif - pBuf->pNext = db->lookaside.pSmallFree; - db->lookaside.pSmallFree = pBuf; - return; - } -#endif /* SQLITE_OMIT_TWOSIZE_LOOKASIDE */ - if( ((uptr)p)>=(uptr)(db->lookaside.pStart) ){ - LookasideSlot *pBuf = (LookasideSlot*)p; -#ifdef SQLITE_DEBUG - memset(p, 0xaa, db->lookaside.szTrue); /* Trash freed content */ -#endif - pBuf->pNext = db->lookaside.pFree; - db->lookaside.pFree = pBuf; - return; - } + pBuf->pNext = db->lookaside.pFree; + db->lookaside.pFree = pBuf; + return; } } assert( sqlite3MemdebugHasType(p, (MEMTYPE_LOOKASIDE|MEMTYPE_HEAP)) ); @@ -27719,37 +27189,23 @@ SQLITE_PRIVATE void *sqlite3DbMallocRawNN(sqlite3 *db, u64 n){ assert( db!=0 ); assert( sqlite3_mutex_held(db->mutex) ); assert( db->pnBytesFreed==0 ); - if( n>db->lookaside.sz ){ - if( !db->lookaside.bDisable ){ - db->lookaside.anStat[1]++; - }else if( db->mallocFailed ){ - return 0; - } - return dbMallocRawFinish(db, n); - } -#ifndef SQLITE_OMIT_TWOSIZE_LOOKASIDE - if( n<=LOOKASIDE_SMALL ){ - if( (pBuf = db->lookaside.pSmallFree)!=0 ){ - db->lookaside.pSmallFree = pBuf->pNext; + if( db->lookaside.bDisable==0 ){ + assert( db->mallocFailed==0 ); + if( n>db->lookaside.sz ){ + db->lookaside.anStat[1]++; + }else if( (pBuf = db->lookaside.pFree)!=0 ){ + db->lookaside.pFree = pBuf->pNext; db->lookaside.anStat[0]++; return (void*)pBuf; - }else if( (pBuf = db->lookaside.pSmallInit)!=0 ){ - db->lookaside.pSmallInit = pBuf->pNext; + }else if( (pBuf = db->lookaside.pInit)!=0 ){ + db->lookaside.pInit = pBuf->pNext; db->lookaside.anStat[0]++; return (void*)pBuf; + }else{ + db->lookaside.anStat[2]++; } - } -#endif - if( (pBuf = db->lookaside.pFree)!=0 ){ - db->lookaside.pFree = pBuf->pNext; - db->lookaside.anStat[0]++; - return (void*)pBuf; - }else if( (pBuf = db->lookaside.pInit)!=0 ){ - db->lookaside.pInit = pBuf->pNext; - db->lookaside.anStat[0]++; - return (void*)pBuf; - }else{ - db->lookaside.anStat[2]++; + }else if( db->mallocFailed ){ + return 0; } #else assert( db!=0 ); @@ -27773,16 +27229,7 @@ SQLITE_PRIVATE void *sqlite3DbRealloc(sqlite3 *db, void *p, u64 n){ assert( db!=0 ); if( p==0 ) return sqlite3DbMallocRawNN(db, n); assert( sqlite3_mutex_held(db->mutex) ); - if( ((uptr)p)<(uptr)db->lookaside.pEnd ){ -#ifndef SQLITE_OMIT_TWOSIZE_LOOKASIDE - if( ((uptr)p)>=(uptr)db->lookaside.pMiddle ){ - if( n<=LOOKASIDE_SMALL ) return p; - }else -#endif - if( ((uptr)p)>=(uptr)db->lookaside.pStart ){ - if( n<=db->lookaside.szTrue ) return p; - } - } + if( isLookaside(db,p) && n<=db->lookaside.sz ) return p; return dbReallocFinish(db, p, n); } static SQLITE_NOINLINE void *dbReallocFinish(sqlite3 *db, void *p, u64 n){ @@ -27793,7 +27240,7 @@ static SQLITE_NOINLINE void *dbReallocFinish(sqlite3 *db, void *p, u64 n){ if( isLookaside(db, p) ){ pNew = sqlite3DbMallocRawNN(db, n); if( pNew ){ - memcpy(pNew, p, lookasideMallocSize(db, p)); + memcpy(pNew, p, db->lookaside.sz); sqlite3DbFree(db, p); } }else{ @@ -27892,7 +27339,7 @@ SQLITE_PRIVATE void sqlite3OomFault(sqlite3 *db){ if( db->nVdbeExec>0 ){ db->u1.isInterrupted = 1; } - DisableLookaside; + db->lookaside.bDisable++; if( db->pParse ){ db->pParse->rc = SQLITE_NOMEM_BKPT; } @@ -27911,7 +27358,7 @@ SQLITE_PRIVATE void sqlite3OomClear(sqlite3 *db){ db->mallocFailed = 0; db->u1.isInterrupted = 0; assert( db->lookaside.bDisable>0 ); - EnableLookaside; + db->lookaside.bDisable--; } } @@ -29319,7 +28766,7 @@ static void sqlite3TreeViewLine(TreeView *p, const char *zFormat, ...){ va_start(ap, zFormat); sqlite3_str_vappendf(&acc, zFormat, ap); va_end(ap); - assert( acc.nChar>0 || acc.accError ); + assert( acc.nChar>0 ); sqlite3_str_append(&acc, "\n", 1); } sqlite3StrAccumFinish(&acc); @@ -29359,7 +28806,7 @@ SQLITE_PRIVATE void sqlite3TreeViewWith(TreeView *pView, const With *pWith, u8 m char cSep = '('; int j; for(j=0; jpCols->nExpr; j++){ - sqlite3_str_appendf(&x, "%c%s", cSep, pCte->pCols->a[j].zEName); + sqlite3_str_appendf(&x, "%c%s", cSep, pCte->pCols->a[j].zName); cSep = ','; } sqlite3_str_appendf(&x, ")"); @@ -29384,7 +28831,7 @@ SQLITE_PRIVATE void sqlite3TreeViewSrcList(TreeView *pView, const SrcList *pSrc) StrAccum x; char zLine[100]; sqlite3StrAccumInit(&x, 0, zLine, sizeof(zLine), 0); - sqlite3_str_appendf(&x, "{%d:*}", pItem->iCursor); + sqlite3_str_appendf(&x, "{%d,*}", pItem->iCursor); if( pItem->zDatabase ){ sqlite3_str_appendf(&x, " %s.%s", pItem->zDatabase, pItem->zName); }else if( pItem->zName ){ @@ -29400,9 +28847,6 @@ SQLITE_PRIVATE void sqlite3TreeViewSrcList(TreeView *pView, const SrcList *pSrc) if( pItem->fg.jointype & JT_LEFT ){ sqlite3_str_appendf(&x, " LEFT-JOIN"); } - if( pItem->fg.fromDDL ){ - sqlite3_str_appendf(&x, " DDL"); - } sqlite3StrAccumFinish(&x); sqlite3TreeViewItem(pView, zLine, inSrc-1); if( pItem->pSelect ){ @@ -29659,17 +29103,14 @@ SQLITE_PRIVATE void sqlite3TreeViewExpr(TreeView *pView, const Expr *pExpr, u8 m return; } if( pExpr->flags || pExpr->affExpr ){ - StrAccum x; - sqlite3StrAccumInit(&x, 0, zFlgs, sizeof(zFlgs), 0); - sqlite3_str_appendf(&x, " fg.af=%x.%c", - pExpr->flags, pExpr->affExpr ? pExpr->affExpr : 'n'); if( ExprHasProperty(pExpr, EP_FromJoin) ){ - sqlite3_str_appendf(&x, " iRJT=%d", pExpr->iRightJoinTable); + sqlite3_snprintf(sizeof(zFlgs),zFlgs," fg.af=%x.%c iRJT=%d", + pExpr->flags, pExpr->affExpr ? pExpr->affExpr : 'n', + pExpr->iRightJoinTable); + }else{ + sqlite3_snprintf(sizeof(zFlgs),zFlgs," fg.af=%x.%c", + pExpr->flags, pExpr->affExpr ? pExpr->affExpr : 'n'); } - if( ExprHasProperty(pExpr, EP_FromDDL) ){ - sqlite3_str_appendf(&x, " DDL"); - } - sqlite3StrAccumFinish(&x); }else{ zFlgs[0] = 0; } @@ -29682,18 +29123,10 @@ SQLITE_PRIVATE void sqlite3TreeViewExpr(TreeView *pView, const Expr *pExpr, u8 m case TK_COLUMN: { if( pExpr->iTable<0 ){ /* This only happens when coding check constraints */ - char zOp2[16]; - if( pExpr->op2 ){ - sqlite3_snprintf(sizeof(zOp2),zOp2," op2=0x%02x",pExpr->op2); - }else{ - zOp2[0] = 0; - } - sqlite3TreeViewLine(pView, "COLUMN(%d)%s%s", - pExpr->iColumn, zFlgs, zOp2); + sqlite3TreeViewLine(pView, "COLUMN(%d)%s", pExpr->iColumn, zFlgs); }else{ - sqlite3TreeViewLine(pView, "{%d:%d} pTab=%p%s", - pExpr->iTable, pExpr->iColumn, - pExpr->y.pTab, zFlgs); + sqlite3TreeViewLine(pView, "{%d:%d}%s", + pExpr->iTable, pExpr->iColumn, zFlgs); } if( ExprHasProperty(pExpr, EP_FixedCol) ){ sqlite3TreeViewExpr(pView, pExpr->pLeft, 0); @@ -29825,7 +29258,7 @@ SQLITE_PRIVATE void sqlite3TreeViewExpr(TreeView *pView, const Expr *pExpr, u8 m }else{ pFarg = pExpr->x.pList; #ifndef SQLITE_OMIT_WINDOWFUNC - pWin = ExprHasProperty(pExpr, EP_WinFunc) ? pExpr->y.pWin : 0; + pWin = pExpr->y.pWin; #else pWin = 0; #endif @@ -29833,17 +29266,6 @@ SQLITE_PRIVATE void sqlite3TreeViewExpr(TreeView *pView, const Expr *pExpr, u8 m if( pExpr->op==TK_AGG_FUNCTION ){ sqlite3TreeViewLine(pView, "AGG_FUNCTION%d %Q%s", pExpr->op2, pExpr->u.zToken, zFlgs); - }else if( pExpr->op2!=0 ){ - const char *zOp2; - char zBuf[8]; - sqlite3_snprintf(sizeof(zBuf),zBuf,"0x%02x",pExpr->op2); - zOp2 = zBuf; - if( pExpr->op2==NC_IsCheck ) zOp2 = "NC_IsCheck"; - if( pExpr->op2==NC_IdxExpr ) zOp2 = "NC_IdxExpr"; - if( pExpr->op2==NC_PartIdx ) zOp2 = "NC_PartIdx"; - if( pExpr->op2==NC_GenCol ) zOp2 = "NC_GenCol"; - sqlite3TreeViewLine(pView, "FUNCTION %Q%s op2=%s", - pExpr->u.zToken, zFlgs, zOp2); }else{ sqlite3TreeViewLine(pView, "FUNCTION %Q%s", pExpr->u.zToken, zFlgs); } @@ -29939,9 +29361,7 @@ SQLITE_PRIVATE void sqlite3TreeViewExpr(TreeView *pView, const Expr *pExpr, u8 m break; } case TK_VECTOR: { - char *z = sqlite3_mprintf("VECTOR%s",zFlgs); - sqlite3TreeViewBareExprList(pView, pExpr->x.pList, z); - sqlite3_free(z); + sqlite3TreeViewBareExprList(pView, pExpr->x.pList, "VECTOR"); break; } case TK_SELECT_COLUMN: { @@ -29987,9 +29407,8 @@ SQLITE_PRIVATE void sqlite3TreeViewBareExprList( sqlite3TreeViewLine(pView, "%s", zLabel); for(i=0; inExpr; i++){ int j = pList->a[i].u.x.iOrderByCol; - char *zName = pList->a[i].zEName; + char *zName = pList->a[i].zName; int moreToFollow = inExpr - 1; - if( pList->a[i].eEName!=ENAME_NAME ) zName = 0; if( j || zName ){ sqlite3TreeViewPush(pView, moreToFollow); moreToFollow = 0; @@ -30656,11 +30075,9 @@ SQLITE_PRIVATE SQLITE_NOINLINE int sqlite3VdbeMemTranslate(Mem *pMem, u8 desired #if defined(TRANSLATE_TRACE) && defined(SQLITE_DEBUG) { - StrAccum acc; - char zBuf[1000]; - sqlite3StrAccumInit(&acc, 0, zBuf, sizeof(zBuf), 0); - sqlite3VdbeMemPrettyPrint(pMem, &acc); - fprintf(stderr, "INPUT: %s\n", sqlite3StrAccumFinish(&acc)); + char zBuf[100]; + sqlite3VdbeMemPrettyPrint(pMem, zBuf); + fprintf(stderr, "INPUT: %s\n", zBuf); } #endif @@ -30768,11 +30185,9 @@ SQLITE_PRIVATE SQLITE_NOINLINE int sqlite3VdbeMemTranslate(Mem *pMem, u8 desired translate_out: #if defined(TRANSLATE_TRACE) && defined(SQLITE_DEBUG) { - StrAccum acc; - char zBuf[1000]; - sqlite3StrAccumInit(&acc, 0, zBuf, sizeof(zBuf), 0); - sqlite3VdbeMemPrettyPrint(pMem, &acc); - fprintf(stderr, "OUTPUT: %s\n", sqlite3StrAccumFinish(&acc)); + char zBuf[100]; + sqlite3VdbeMemPrettyPrint(pMem, zBuf); + fprintf(stderr, "OUTPUT: %s\n", zBuf); } #endif return SQLITE_OK; @@ -30997,9 +30412,7 @@ SQLITE_PRIVATE void sqlite3UtfSelfTest(void){ */ /* #include "sqliteInt.h" */ /* #include */ -#ifndef SQLITE_OMIT_FLOATING_POINT #include -#endif /* ** Routine needed to support the testcase() macro. @@ -31174,7 +30587,6 @@ SQLITE_PRIVATE void sqlite3ErrorMsg(Parse *pParse, const char *zFormat, ...){ sqlite3DbFree(db, pParse->zErrMsg); pParse->zErrMsg = zMsg; pParse->rc = SQLITE_ERROR; - pParse->pWith = 0; } } @@ -31365,13 +30777,10 @@ static LONGDOUBLE_TYPE sqlite3Pow10(int E){ ** returns FALSE but it still converts the prefix and writes the result ** into *pResult. */ -#if defined(_MSC_VER) -#pragma warning(disable : 4756) -#endif SQLITE_PRIVATE int sqlite3AtoF(const char *z, double *pResult, int length, u8 enc){ #ifndef SQLITE_OMIT_FLOATING_POINT int incr; - const char *zEnd; + const char *zEnd = z + length; /* sign * significand * (10 ^ (esign * exponent)) */ int sign = 1; /* sign of significand */ i64 s = 0; /* significand */ @@ -31385,15 +30794,12 @@ SQLITE_PRIVATE int sqlite3AtoF(const char *z, double *pResult, int length, u8 en assert( enc==SQLITE_UTF8 || enc==SQLITE_UTF16LE || enc==SQLITE_UTF16BE ); *pResult = 0.0; /* Default return value, in case of an error */ - if( length==0 ) return 0; if( enc==SQLITE_UTF8 ){ incr = 1; - zEnd = z + length; }else{ int i; incr = 2; - length &= ~1; assert( SQLITE_UTF16LE==2 && SQLITE_UTF16BE==3 ); testcase( enc==SQLITE_UTF16LE ); testcase( enc==SQLITE_UTF16BE ); @@ -31558,9 +30964,6 @@ SQLITE_PRIVATE int sqlite3AtoF(const char *z, double *pResult, int length, u8 en return !sqlite3Atoi64(z, pResult, length, enc); #endif /* SQLITE_OMIT_FLOATING_POINT */ } -#if defined(_MSC_VER) -#pragma warning(default : 4756) -#endif /* ** Compare the 19-character string zNum against the text representation @@ -32931,30 +32334,30 @@ SQLITE_PRIVATE const char *sqlite3OpcodeName(int i){ /* 23 */ "SeekLE" OpHelp("key=r[P3@P4]"), /* 24 */ "SeekGE" OpHelp("key=r[P3@P4]"), /* 25 */ "SeekGT" OpHelp("key=r[P3@P4]"), - /* 26 */ "IfNotOpen" OpHelp("if( !csr[P1] ) goto P2"), - /* 27 */ "IfNoHope" OpHelp("key=r[P3@P4]"), - /* 28 */ "NoConflict" OpHelp("key=r[P3@P4]"), - /* 29 */ "NotFound" OpHelp("key=r[P3@P4]"), - /* 30 */ "Found" OpHelp("key=r[P3@P4]"), - /* 31 */ "SeekRowid" OpHelp("intkey=r[P3]"), - /* 32 */ "NotExists" OpHelp("intkey=r[P3]"), - /* 33 */ "Last" OpHelp(""), - /* 34 */ "IfSmaller" OpHelp(""), - /* 35 */ "SorterSort" OpHelp(""), - /* 36 */ "Sort" OpHelp(""), - /* 37 */ "Rewind" OpHelp(""), - /* 38 */ "IdxLE" OpHelp("key=r[P3@P4]"), - /* 39 */ "IdxGT" OpHelp("key=r[P3@P4]"), - /* 40 */ "IdxLT" OpHelp("key=r[P3@P4]"), - /* 41 */ "IdxGE" OpHelp("key=r[P3@P4]"), - /* 42 */ "RowSetRead" OpHelp("r[P3]=rowset(P1)"), + /* 26 */ "IfNoHope" OpHelp("key=r[P3@P4]"), + /* 27 */ "NoConflict" OpHelp("key=r[P3@P4]"), + /* 28 */ "NotFound" OpHelp("key=r[P3@P4]"), + /* 29 */ "Found" OpHelp("key=r[P3@P4]"), + /* 30 */ "SeekRowid" OpHelp("intkey=r[P3]"), + /* 31 */ "NotExists" OpHelp("intkey=r[P3]"), + /* 32 */ "Last" OpHelp(""), + /* 33 */ "IfSmaller" OpHelp(""), + /* 34 */ "SorterSort" OpHelp(""), + /* 35 */ "Sort" OpHelp(""), + /* 36 */ "Rewind" OpHelp(""), + /* 37 */ "IdxLE" OpHelp("key=r[P3@P4]"), + /* 38 */ "IdxGT" OpHelp("key=r[P3@P4]"), + /* 39 */ "IdxLT" OpHelp("key=r[P3@P4]"), + /* 40 */ "IdxGE" OpHelp("key=r[P3@P4]"), + /* 41 */ "RowSetRead" OpHelp("r[P3]=rowset(P1)"), + /* 42 */ "RowSetTest" OpHelp("if r[P3] in rowset(P1) goto P2"), /* 43 */ "Or" OpHelp("r[P3]=(r[P1] || r[P2])"), /* 44 */ "And" OpHelp("r[P3]=(r[P1] && r[P2])"), - /* 45 */ "RowSetTest" OpHelp("if r[P3] in rowset(P1) goto P2"), - /* 46 */ "Program" OpHelp(""), - /* 47 */ "FkIfZero" OpHelp("if fkctr[P1]==0 goto P2"), - /* 48 */ "IfPos" OpHelp("if r[P1]>0 then r[P1]-=P3, goto P2"), - /* 49 */ "IfNotZero" OpHelp("if r[P1]!=0 then r[P1]--, goto P2"), + /* 45 */ "Program" OpHelp(""), + /* 46 */ "FkIfZero" OpHelp("if fkctr[P1]==0 goto P2"), + /* 47 */ "IfPos" OpHelp("if r[P1]>0 then r[P1]-=P3, goto P2"), + /* 48 */ "IfNotZero" OpHelp("if r[P1]!=0 then r[P1]--, goto P2"), + /* 49 */ "DecrJumpZero" OpHelp("if (--r[P1])==0 goto P2"), /* 50 */ "IsNull" OpHelp("if r[P1]==NULL goto P2"), /* 51 */ "NotNull" OpHelp("if r[P1]!=NULL goto P2"), /* 52 */ "Ne" OpHelp("IF r[P3]!=r[P1]"), @@ -32964,83 +32367,83 @@ SQLITE_PRIVATE const char *sqlite3OpcodeName(int i){ /* 56 */ "Lt" OpHelp("IF r[P3]=r[P1]"), /* 58 */ "ElseNotEq" OpHelp(""), - /* 59 */ "DecrJumpZero" OpHelp("if (--r[P1])==0 goto P2"), - /* 60 */ "IncrVacuum" OpHelp(""), - /* 61 */ "VNext" OpHelp(""), - /* 62 */ "Init" OpHelp("Start at P2"), - /* 63 */ "PureFunc" OpHelp("r[P3]=func(r[P2@P5])"), - /* 64 */ "Function" OpHelp("r[P3]=func(r[P2@P5])"), - /* 65 */ "Return" OpHelp(""), - /* 66 */ "EndCoroutine" OpHelp(""), - /* 67 */ "HaltIfNull" OpHelp("if r[P3]=null halt"), - /* 68 */ "Halt" OpHelp(""), - /* 69 */ "Integer" OpHelp("r[P2]=P1"), - /* 70 */ "Int64" OpHelp("r[P2]=P4"), - /* 71 */ "String" OpHelp("r[P2]='P4' (len=P1)"), - /* 72 */ "Null" OpHelp("r[P2..P3]=NULL"), - /* 73 */ "SoftNull" OpHelp("r[P1]=NULL"), - /* 74 */ "Blob" OpHelp("r[P2]=P4 (len=P1)"), - /* 75 */ "Variable" OpHelp("r[P2]=parameter(P1,P4)"), - /* 76 */ "Move" OpHelp("r[P2@P3]=r[P1@P3]"), - /* 77 */ "Copy" OpHelp("r[P2@P3+1]=r[P1@P3+1]"), - /* 78 */ "SCopy" OpHelp("r[P2]=r[P1]"), - /* 79 */ "IntCopy" OpHelp("r[P2]=r[P1]"), - /* 80 */ "ResultRow" OpHelp("output=r[P1@P2]"), - /* 81 */ "CollSeq" OpHelp(""), - /* 82 */ "AddImm" OpHelp("r[P1]=r[P1]+P2"), - /* 83 */ "RealAffinity" OpHelp(""), - /* 84 */ "Cast" OpHelp("affinity(r[P1])"), - /* 85 */ "Permutation" OpHelp(""), - /* 86 */ "Compare" OpHelp("r[P1@P3] <-> r[P2@P3]"), - /* 87 */ "IsTrue" OpHelp("r[P2] = coalesce(r[P1]==TRUE,P3) ^ P4"), - /* 88 */ "Offset" OpHelp("r[P3] = sqlite_offset(P1)"), - /* 89 */ "Column" OpHelp("r[P3]=PX"), - /* 90 */ "Affinity" OpHelp("affinity(r[P1@P2])"), - /* 91 */ "MakeRecord" OpHelp("r[P3]=mkrec(r[P1@P2])"), - /* 92 */ "Count" OpHelp("r[P2]=count()"), - /* 93 */ "ReadCookie" OpHelp(""), - /* 94 */ "SetCookie" OpHelp(""), - /* 95 */ "ReopenIdx" OpHelp("root=P2 iDb=P3"), - /* 96 */ "OpenRead" OpHelp("root=P2 iDb=P3"), - /* 97 */ "OpenWrite" OpHelp("root=P2 iDb=P3"), - /* 98 */ "OpenDup" OpHelp(""), - /* 99 */ "OpenAutoindex" OpHelp("nColumn=P2"), - /* 100 */ "OpenEphemeral" OpHelp("nColumn=P2"), - /* 101 */ "BitAnd" OpHelp("r[P3]=r[P1]&r[P2]"), - /* 102 */ "BitOr" OpHelp("r[P3]=r[P1]|r[P2]"), - /* 103 */ "ShiftLeft" OpHelp("r[P3]=r[P2]<>r[P1]"), - /* 105 */ "Add" OpHelp("r[P3]=r[P1]+r[P2]"), - /* 106 */ "Subtract" OpHelp("r[P3]=r[P2]-r[P1]"), - /* 107 */ "Multiply" OpHelp("r[P3]=r[P1]*r[P2]"), - /* 108 */ "Divide" OpHelp("r[P3]=r[P2]/r[P1]"), - /* 109 */ "Remainder" OpHelp("r[P3]=r[P2]%r[P1]"), - /* 110 */ "Concat" OpHelp("r[P3]=r[P2]+r[P1]"), - /* 111 */ "SorterOpen" OpHelp(""), - /* 112 */ "BitNot" OpHelp("r[P2]= ~r[P1]"), - /* 113 */ "SequenceTest" OpHelp("if( cursor[P1].ctr++ ) pc = P2"), - /* 114 */ "OpenPseudo" OpHelp("P3 columns in r[P2]"), - /* 115 */ "String8" OpHelp("r[P2]='P4'"), - /* 116 */ "Close" OpHelp(""), - /* 117 */ "ColumnsUsed" OpHelp(""), - /* 118 */ "SeekHit" OpHelp("seekHit=P2"), - /* 119 */ "Sequence" OpHelp("r[P2]=cursor[P1].ctr++"), - /* 120 */ "NewRowid" OpHelp("r[P2]=rowid"), - /* 121 */ "Insert" OpHelp("intkey=r[P3] data=r[P2]"), - /* 122 */ "Delete" OpHelp(""), - /* 123 */ "ResetCount" OpHelp(""), - /* 124 */ "SorterCompare" OpHelp("if key(P1)!=trim(r[P3],P4) goto P2"), - /* 125 */ "SorterData" OpHelp("r[P2]=data"), - /* 126 */ "RowData" OpHelp("r[P2]=data"), - /* 127 */ "Rowid" OpHelp("r[P2]=rowid"), - /* 128 */ "NullRow" OpHelp(""), - /* 129 */ "SeekEnd" OpHelp(""), - /* 130 */ "SorterInsert" OpHelp("key=r[P2]"), - /* 131 */ "IdxInsert" OpHelp("key=r[P2]"), - /* 132 */ "IdxDelete" OpHelp("key=r[P2@P3]"), - /* 133 */ "DeferredSeek" OpHelp("Move P3 to P1.rowid if needed"), - /* 134 */ "IdxRowid" OpHelp("r[P2]=rowid"), - /* 135 */ "FinishSeek" OpHelp(""), + /* 59 */ "IncrVacuum" OpHelp(""), + /* 60 */ "VNext" OpHelp(""), + /* 61 */ "Init" OpHelp("Start at P2"), + /* 62 */ "PureFunc0" OpHelp(""), + /* 63 */ "Function0" OpHelp("r[P3]=func(r[P2@P5])"), + /* 64 */ "PureFunc" OpHelp(""), + /* 65 */ "Function" OpHelp("r[P3]=func(r[P2@P5])"), + /* 66 */ "Return" OpHelp(""), + /* 67 */ "EndCoroutine" OpHelp(""), + /* 68 */ "HaltIfNull" OpHelp("if r[P3]=null halt"), + /* 69 */ "Halt" OpHelp(""), + /* 70 */ "Integer" OpHelp("r[P2]=P1"), + /* 71 */ "Int64" OpHelp("r[P2]=P4"), + /* 72 */ "String" OpHelp("r[P2]='P4' (len=P1)"), + /* 73 */ "Null" OpHelp("r[P2..P3]=NULL"), + /* 74 */ "SoftNull" OpHelp("r[P1]=NULL"), + /* 75 */ "Blob" OpHelp("r[P2]=P4 (len=P1)"), + /* 76 */ "Variable" OpHelp("r[P2]=parameter(P1,P4)"), + /* 77 */ "Move" OpHelp("r[P2@P3]=r[P1@P3]"), + /* 78 */ "Copy" OpHelp("r[P2@P3+1]=r[P1@P3+1]"), + /* 79 */ "SCopy" OpHelp("r[P2]=r[P1]"), + /* 80 */ "IntCopy" OpHelp("r[P2]=r[P1]"), + /* 81 */ "ResultRow" OpHelp("output=r[P1@P2]"), + /* 82 */ "CollSeq" OpHelp(""), + /* 83 */ "AddImm" OpHelp("r[P1]=r[P1]+P2"), + /* 84 */ "RealAffinity" OpHelp(""), + /* 85 */ "Cast" OpHelp("affinity(r[P1])"), + /* 86 */ "Permutation" OpHelp(""), + /* 87 */ "Compare" OpHelp("r[P1@P3] <-> r[P2@P3]"), + /* 88 */ "IsTrue" OpHelp("r[P2] = coalesce(r[P1]==TRUE,P3) ^ P4"), + /* 89 */ "Offset" OpHelp("r[P3] = sqlite_offset(P1)"), + /* 90 */ "Column" OpHelp("r[P3]=PX"), + /* 91 */ "Affinity" OpHelp("affinity(r[P1@P2])"), + /* 92 */ "MakeRecord" OpHelp("r[P3]=mkrec(r[P1@P2])"), + /* 93 */ "Count" OpHelp("r[P2]=count()"), + /* 94 */ "ReadCookie" OpHelp(""), + /* 95 */ "SetCookie" OpHelp(""), + /* 96 */ "ReopenIdx" OpHelp("root=P2 iDb=P3"), + /* 97 */ "OpenRead" OpHelp("root=P2 iDb=P3"), + /* 98 */ "OpenWrite" OpHelp("root=P2 iDb=P3"), + /* 99 */ "BitAnd" OpHelp("r[P3]=r[P1]&r[P2]"), + /* 100 */ "BitOr" OpHelp("r[P3]=r[P1]|r[P2]"), + /* 101 */ "ShiftLeft" OpHelp("r[P3]=r[P2]<>r[P1]"), + /* 103 */ "Add" OpHelp("r[P3]=r[P1]+r[P2]"), + /* 104 */ "Subtract" OpHelp("r[P3]=r[P2]-r[P1]"), + /* 105 */ "Multiply" OpHelp("r[P3]=r[P1]*r[P2]"), + /* 106 */ "Divide" OpHelp("r[P3]=r[P2]/r[P1]"), + /* 107 */ "Remainder" OpHelp("r[P3]=r[P2]%r[P1]"), + /* 108 */ "Concat" OpHelp("r[P3]=r[P2]+r[P1]"), + /* 109 */ "OpenDup" OpHelp(""), + /* 110 */ "BitNot" OpHelp("r[P2]= ~r[P1]"), + /* 111 */ "OpenAutoindex" OpHelp("nColumn=P2"), + /* 112 */ "OpenEphemeral" OpHelp("nColumn=P2"), + /* 113 */ "String8" OpHelp("r[P2]='P4'"), + /* 114 */ "SorterOpen" OpHelp(""), + /* 115 */ "SequenceTest" OpHelp("if( cursor[P1].ctr++ ) pc = P2"), + /* 116 */ "OpenPseudo" OpHelp("P3 columns in r[P2]"), + /* 117 */ "Close" OpHelp(""), + /* 118 */ "ColumnsUsed" OpHelp(""), + /* 119 */ "SeekHit" OpHelp("seekHit=P2"), + /* 120 */ "Sequence" OpHelp("r[P2]=cursor[P1].ctr++"), + /* 121 */ "NewRowid" OpHelp("r[P2]=rowid"), + /* 122 */ "Insert" OpHelp("intkey=r[P3] data=r[P2]"), + /* 123 */ "Delete" OpHelp(""), + /* 124 */ "ResetCount" OpHelp(""), + /* 125 */ "SorterCompare" OpHelp("if key(P1)!=trim(r[P3],P4) goto P2"), + /* 126 */ "SorterData" OpHelp("r[P2]=data"), + /* 127 */ "RowData" OpHelp("r[P2]=data"), + /* 128 */ "Rowid" OpHelp("r[P2]=rowid"), + /* 129 */ "NullRow" OpHelp(""), + /* 130 */ "SeekEnd" OpHelp(""), + /* 131 */ "SorterInsert" OpHelp("key=r[P2]"), + /* 132 */ "IdxInsert" OpHelp("key=r[P2]"), + /* 133 */ "IdxDelete" OpHelp("key=r[P2@P3]"), + /* 134 */ "DeferredSeek" OpHelp("Move P3 to P1.rowid if needed"), + /* 135 */ "IdxRowid" OpHelp("r[P2]=rowid"), /* 136 */ "Destroy" OpHelp(""), /* 137 */ "Clear" OpHelp(""), /* 138 */ "ResetSorter" OpHelp(""), @@ -33053,9 +32456,9 @@ SQLITE_PRIVATE const char *sqlite3OpcodeName(int i){ /* 145 */ "DropTrigger" OpHelp(""), /* 146 */ "IntegrityCk" OpHelp(""), /* 147 */ "RowSetAdd" OpHelp("rowset(P1)=r[P2]"), - /* 148 */ "Param" OpHelp(""), - /* 149 */ "FkCounter" OpHelp("fkctr[P1]+=P2"), - /* 150 */ "Real" OpHelp("r[P2]=P4"), + /* 148 */ "Real" OpHelp("r[P2]=P4"), + /* 149 */ "Param" OpHelp(""), + /* 150 */ "FkCounter" OpHelp("fkctr[P1]+=P2"), /* 151 */ "MemMax" OpHelp("r[P1]=max(r[P1],r[P2])"), /* 152 */ "OffsetLimit" OpHelp("if r[P1]>0 then r[P2]=r[P1]+max(0,r[P3]) else r[P2]=(-1)"), /* 153 */ "AggInverse" OpHelp("accum=r[P3] inverse(r[P2@P5])"), @@ -33064,23 +32467,20 @@ SQLITE_PRIVATE const char *sqlite3OpcodeName(int i){ /* 156 */ "AggValue" OpHelp("r[P3]=value N=P2"), /* 157 */ "AggFinal" OpHelp("accum=r[P1] N=P2"), /* 158 */ "Expire" OpHelp(""), - /* 159 */ "CursorLock" OpHelp(""), - /* 160 */ "CursorUnlock" OpHelp(""), - /* 161 */ "TableLock" OpHelp("iDb=P1 root=P2 write=P3"), - /* 162 */ "VBegin" OpHelp(""), - /* 163 */ "VCreate" OpHelp(""), - /* 164 */ "VDestroy" OpHelp(""), - /* 165 */ "VOpen" OpHelp(""), - /* 166 */ "VColumn" OpHelp("r[P3]=vcolumn(P2)"), - /* 167 */ "VRename" OpHelp(""), - /* 168 */ "Pagecount" OpHelp(""), - /* 169 */ "MaxPgcnt" OpHelp(""), - /* 170 */ "Trace" OpHelp(""), - /* 171 */ "CursorHint" OpHelp(""), - /* 172 */ "ReleaseReg" OpHelp("release r[P1@P2] mask P3"), - /* 173 */ "Noop" OpHelp(""), - /* 174 */ "Explain" OpHelp(""), - /* 175 */ "Abortable" OpHelp(""), + /* 159 */ "TableLock" OpHelp("iDb=P1 root=P2 write=P3"), + /* 160 */ "VBegin" OpHelp(""), + /* 161 */ "VCreate" OpHelp(""), + /* 162 */ "VDestroy" OpHelp(""), + /* 163 */ "VOpen" OpHelp(""), + /* 164 */ "VColumn" OpHelp("r[P3]=vcolumn(P2)"), + /* 165 */ "VRename" OpHelp(""), + /* 166 */ "Pagecount" OpHelp(""), + /* 167 */ "MaxPgcnt" OpHelp(""), + /* 168 */ "Trace" OpHelp(""), + /* 169 */ "CursorHint" OpHelp(""), + /* 170 */ "Noop" OpHelp(""), + /* 171 */ "Explain" OpHelp(""), + /* 172 */ "Abortable" OpHelp(""), }; return azName[i]; } @@ -33444,7 +32844,7 @@ static pid_t randomnessPid = 0; ****************************************************************************** ** ** This file contains inline asm code for retrieving "high-performance" -** counters for x86 and x86_64 class CPUs. +** counters for x86 class CPUs. */ #ifndef SQLITE_HWTIME_H #define SQLITE_HWTIME_H @@ -33455,9 +32855,8 @@ static pid_t randomnessPid = 0; ** processor and returns that value. This can be used for high-res ** profiling. */ -#if !defined(__STRICT_ANSI__) && \ - (defined(__GNUC__) || defined(_MSC_VER)) && \ - (defined(i386) || defined(__i386__) || defined(_M_IX86)) +#if (defined(__GNUC__) || defined(_MSC_VER)) && \ + (defined(i386) || defined(__i386__) || defined(_M_IX86)) #if defined(__GNUC__) @@ -33478,7 +32877,7 @@ static pid_t randomnessPid = 0; #endif -#elif !defined(__STRICT_ANSI__) && (defined(__GNUC__) && defined(__x86_64__)) +#elif (defined(__GNUC__) && defined(__x86_64__)) __inline__ sqlite_uint64 sqlite3Hwtime(void){ unsigned long val; @@ -33486,7 +32885,7 @@ static pid_t randomnessPid = 0; return val; } -#elif !defined(__STRICT_ANSI__) && (defined(__GNUC__) && defined(__ppc__)) +#elif (defined(__GNUC__) && defined(__ppc__)) __inline__ sqlite_uint64 sqlite3Hwtime(void){ unsigned long long retval; @@ -33503,13 +32902,14 @@ static pid_t randomnessPid = 0; #else + #error Need implementation of sqlite3Hwtime() for your platform. + /* - ** asm() is needed for hardware timing support. Without asm(), - ** disable the sqlite3Hwtime() routine. - ** - ** sqlite3Hwtime() is only used for some obscure debugging - ** and analysis configurations, not in any deliverable, so this - ** should not be a great loss. + ** To compile without implementing sqlite3Hwtime() for your platform, + ** you can remove the above #error and use the following + ** stub function. You will lose timing support for many + ** of the debugging and testing utilities, but it should at + ** least compile and run. */ SQLITE_PRIVATE sqlite_uint64 sqlite3Hwtime(void){ return ((sqlite_uint64)0); } @@ -36973,7 +36373,7 @@ static int openDirectory(const char *zFilename, int *pFd){ if( zDirname[0]!='/' ) zDirname[0] = '.'; zDirname[1] = 0; } - fd = robust_open(zDirname, O_RDONLY|O_BINARY|O_NOFOLLOW, 0); + fd = robust_open(zDirname, O_RDONLY|O_BINARY, 0); if( fd>=0 ){ OSTRACE(("OPENDIR %-3d %s\n", fd, zDirname)); } @@ -37864,12 +37264,10 @@ static int unixOpenSharedMemory(unixFile *pDbFd){ if( pInode->bProcessLock==0 ){ if( 0==sqlite3_uri_boolean(pDbFd->zPath, "readonly_shm", 0) ){ - pShmNode->hShm = robust_open(zShm, O_RDWR|O_CREAT|O_NOFOLLOW, - (sStat.st_mode&0777)); + pShmNode->hShm = robust_open(zShm, O_RDWR|O_CREAT,(sStat.st_mode&0777)); } if( pShmNode->hShm<0 ){ - pShmNode->hShm = robust_open(zShm, O_RDONLY|O_NOFOLLOW, - (sStat.st_mode&0777)); + pShmNode->hShm = robust_open(zShm, O_RDONLY, (sStat.st_mode&0777)); if( pShmNode->hShm<0 ){ rc = unixLogError(SQLITE_CANTOPEN_BKPT, "open", zShm); goto shm_open_err; @@ -39219,7 +38617,7 @@ static int unixOpen( unixFile *p = (unixFile *)pFile; int fd = -1; /* File descriptor returned by open() */ int openFlags = 0; /* Flags to pass to open() */ - int eType = flags&0x0FFF00; /* Type of file to open */ + int eType = flags&0xFFFFFF00; /* Type of file to open */ int noLock; /* True to omit locking primitives */ int rc = SQLITE_OK; /* Function Return Code */ int ctrlFlags = 0; /* UNIXFILE_* flags */ @@ -39329,7 +38727,7 @@ static int unixOpen( if( isReadWrite ) openFlags |= O_RDWR; if( isCreate ) openFlags |= O_CREAT; if( isExclusive ) openFlags |= (O_EXCL|O_NOFOLLOW); - openFlags |= (O_LARGEFILE|O_BINARY|O_NOFOLLOW); + openFlags |= (O_LARGEFILE|O_BINARY); if( fd<0 ){ mode_t openMode; /* Permissions to create file with */ @@ -39547,8 +38945,7 @@ static int unixAccess( if( flags==SQLITE_ACCESS_EXISTS ){ struct stat buf; - *pResOut = 0==osStat(zPath, &buf) && - (!S_ISREG(buf.st_mode) || buf.st_size>0); + *pResOut = (0==osStat(zPath, &buf) && buf.st_size>0); }else{ *pResOut = osAccess(zPath, W_OK|R_OK)==0; } @@ -39602,7 +38999,7 @@ static int unixFullPathname( #else int rc = SQLITE_OK; int nByte; - int nLink = 0; /* Number of symbolic links followed so far */ + int nLink = 1; /* Number of symbolic links followed so far */ const char *zIn = zPath; /* Input path for each iteration of loop */ char *zDel = 0; @@ -39631,11 +39028,10 @@ static int unixFullPathname( } if( bLink ){ - nLink++; if( zDel==0 ){ zDel = sqlite3_malloc(nOut); if( zDel==0 ) rc = SQLITE_NOMEM_BKPT; - }else if( nLink>=SQLITE_MAX_SYMLINKS ){ + }else if( ++nLink>SQLITE_MAX_SYMLINKS ){ rc = SQLITE_CANTOPEN_BKPT; } @@ -39671,7 +39067,6 @@ static int unixFullPathname( }while( rc==SQLITE_OK ); sqlite3_free(zDel); - if( rc==SQLITE_OK && nLink ) rc = SQLITE_OK_SYMLINK; return rc; #endif /* HAVE_READLINK && HAVE_LSTAT */ } @@ -40157,7 +39552,7 @@ static int proxyCreateUnixFile( int fd = -1; unixFile *pNew; int rc = SQLITE_OK; - int openFlags = O_RDWR | O_CREAT | O_NOFOLLOW; + int openFlags = O_RDWR | O_CREAT; sqlite3_vfs dummyVfs; int terrno = 0; UnixUnusedFd *pUnused = NULL; @@ -40187,7 +39582,7 @@ static int proxyCreateUnixFile( } } if( fd<0 ){ - openFlags = O_RDONLY | O_NOFOLLOW; + openFlags = O_RDONLY; fd = robust_open(path, openFlags, 0); terrno = errno; } @@ -40313,7 +39708,7 @@ static int proxyBreakConchLock(unixFile *pFile, uuid_t myHostID){ goto end_breaklock; } /* write it out to the temporary break file */ - fd = robust_open(tPath, (O_RDWR|O_CREAT|O_EXCL|O_NOFOLLOW), 0); + fd = robust_open(tPath, (O_RDWR|O_CREAT|O_EXCL), 0); if( fd<0 ){ sqlite3_snprintf(sizeof(errmsg), errmsg, "create failed (%d)", errno); goto end_breaklock; @@ -41271,7 +40666,7 @@ SQLITE_API int sqlite3_os_end(void){ ****************************************************************************** ** ** This file contains inline asm code for retrieving "high-performance" -** counters for x86 and x86_64 class CPUs. +** counters for x86 class CPUs. */ #ifndef SQLITE_HWTIME_H #define SQLITE_HWTIME_H @@ -41282,9 +40677,8 @@ SQLITE_API int sqlite3_os_end(void){ ** processor and returns that value. This can be used for high-res ** profiling. */ -#if !defined(__STRICT_ANSI__) && \ - (defined(__GNUC__) || defined(_MSC_VER)) && \ - (defined(i386) || defined(__i386__) || defined(_M_IX86)) +#if (defined(__GNUC__) || defined(_MSC_VER)) && \ + (defined(i386) || defined(__i386__) || defined(_M_IX86)) #if defined(__GNUC__) @@ -41305,7 +40699,7 @@ SQLITE_API int sqlite3_os_end(void){ #endif -#elif !defined(__STRICT_ANSI__) && (defined(__GNUC__) && defined(__x86_64__)) +#elif (defined(__GNUC__) && defined(__x86_64__)) __inline__ sqlite_uint64 sqlite3Hwtime(void){ unsigned long val; @@ -41313,7 +40707,7 @@ SQLITE_API int sqlite3_os_end(void){ return val; } -#elif !defined(__STRICT_ANSI__) && (defined(__GNUC__) && defined(__ppc__)) +#elif (defined(__GNUC__) && defined(__ppc__)) __inline__ sqlite_uint64 sqlite3Hwtime(void){ unsigned long long retval; @@ -41330,13 +40724,14 @@ SQLITE_API int sqlite3_os_end(void){ #else + #error Need implementation of sqlite3Hwtime() for your platform. + /* - ** asm() is needed for hardware timing support. Without asm(), - ** disable the sqlite3Hwtime() routine. - ** - ** sqlite3Hwtime() is only used for some obscure debugging - ** and analysis configurations, not in any deliverable, so this - ** should not be a great loss. + ** To compile without implementing sqlite3Hwtime() for your platform, + ** you can remove the above #error and use the following + ** stub function. You will lose timing support for many + ** of the debugging and testing utilities, but it should at + ** least compile and run. */ SQLITE_PRIVATE sqlite_uint64 sqlite3Hwtime(void){ return ((sqlite_uint64)0); } @@ -49904,15 +49299,13 @@ static PgHdr1 *pcache1AllocPage(PCache1 *pCache, int benignMalloc){ } #else pPg = pcache1Alloc(pCache->szAlloc); + p = (PgHdr1 *)&((u8 *)pPg)[pCache->szPage]; #endif if( benignMalloc ){ sqlite3EndBenignMalloc(); } #ifdef SQLITE_ENABLE_MEMORY_MANAGEMENT pcache1EnterMutex(pCache->pGroup); #endif if( pPg==0 ) return 0; -#ifndef SQLITE_PCACHE_SEPARATE_HEADER - p = (PgHdr1 *)&((u8 *)pPg)[pCache->szPage]; -#endif p->page.pBuf = pPg; p->page.pExtra = &p[1]; p->isBulkLocal = 0; @@ -52567,7 +51960,6 @@ static int pagerUnlockDb(Pager *pPager, int eLock){ } IOTRACE(("UNLOCK %p %d\n", pPager, eLock)) } - pPager->changeCountDone = pPager->tempFile; /* ticket fb3b3024ea238d5c */ return rc; } @@ -52755,7 +52147,6 @@ static int readMasterJournal(sqlite3_file *pJrnl, char *zMaster, u32 nMaster){ len = 0; } zMaster[len] = '\0'; - zMaster[len+1] = '\0'; return SQLITE_OK; } @@ -53289,6 +52680,7 @@ static void pager_unlock(Pager *pPager){ ** code is cleared and the cache reset in the block below. */ assert( pPager->errCode || pPager->eState!=PAGER_ERROR ); + pPager->changeCountDone = 0; pPager->eState = PAGER_OPEN; } @@ -53552,6 +52944,7 @@ static int pager_end_transaction(Pager *pPager, int hasMaster, int bCommit){ && (!pagerUseWal(pPager) || sqlite3WalExclusiveMode(pPager->pWal, 0)) ){ rc2 = pagerUnlockDb(pPager, SHARED_LOCK); + pPager->changeCountDone = 0; } pPager->eState = PAGER_READER; pPager->setMaster = 0; @@ -53990,16 +53383,15 @@ static int pager_delmaster(Pager *pPager, const char *zMaster){ rc = sqlite3OsFileSize(pMaster, &nMasterJournal); if( rc!=SQLITE_OK ) goto delmaster_out; nMasterPtr = pVfs->mxPathname+1; - zMasterJournal = sqlite3Malloc(nMasterJournal + nMasterPtr + 2); + zMasterJournal = sqlite3Malloc(nMasterJournal + nMasterPtr + 1); if( !zMasterJournal ){ rc = SQLITE_NOMEM_BKPT; goto delmaster_out; } - zMasterPtr = &zMasterJournal[nMasterJournal+2]; + zMasterPtr = &zMasterJournal[nMasterJournal+1]; rc = sqlite3OsRead(pMaster, zMasterJournal, (int)nMasterJournal, 0); if( rc!=SQLITE_OK ) goto delmaster_out; zMasterJournal[nMasterJournal] = 0; - zMasterJournal[nMasterJournal+1] = 0; zJournal = zMasterJournal; while( (zJournal-zMasterJournal)=1 ); + nUri = (int)(&z[1] - zUri); + assert( nUri>=0 ); if( rc==SQLITE_OK && nPathname+8>pVfs->mxPathname ){ /* This branch is taken when the journal path required by ** the database being opened will be more than pVfs->mxPathname @@ -56233,88 +55614,50 @@ SQLITE_PRIVATE int sqlite3PagerOpen( ** Database file handle (pVfs->szOsFile bytes) ** Sub-journal file handle (journalFileSize bytes) ** Main journal file handle (journalFileSize bytes) - ** \0\1\0 journal prefix (3 bytes) - ** Journal filename (nPathname+8+1 bytes) - ** \2\0 WAL prefix (2 bytes) - ** WAL filename (nPathname+4+1 bytes) - ** \3\0 database prefix (2 bytes) ** Database file name (nPathname+1 bytes) - ** URI query parameters (nUriByte bytes) - ** \0\0 terminator (2 bytes) + ** Journal file name (nPathname+8+1 bytes) */ pPtr = (u8 *)sqlite3MallocZero( - ROUND8(sizeof(*pPager)) + /* Pager structure */ - ROUND8(pcacheSize) + /* PCache object */ - ROUND8(pVfs->szOsFile) + /* The main db file */ - journalFileSize * 2 + /* The two journal files */ - 3 + /* Journal prefix */ - nPathname + 8 + 1 + /* Journal filename */ + ROUND8(sizeof(*pPager)) + /* Pager structure */ + ROUND8(pcacheSize) + /* PCache object */ + ROUND8(pVfs->szOsFile) + /* The main db file */ + journalFileSize * 2 + /* The two journal files */ + nPathname + 1 + nUri + /* zFilename */ + nPathname + 8 + 2 /* zJournal */ #ifndef SQLITE_OMIT_WAL - 2 + /* WAL prefix */ - nPathname + 4 + 1 + /* WAL filename */ + + nPathname + 4 + 2 /* zWal */ #endif - 2 + /* Database prefix */ - nPathname + 1 + /* database filename */ - nUriByte + /* query parameters */ - 2 /* Terminator */ ); assert( EIGHT_BYTE_ALIGNMENT(SQLITE_INT_TO_PTR(journalFileSize)) ); if( !pPtr ){ sqlite3DbFree(0, zPathname); return SQLITE_NOMEM_BKPT; } - pPager = (Pager*)pPtr; pPtr += ROUND8(sizeof(*pPager)); - pPager->pPCache = (PCache*)pPtr; pPtr += ROUND8(pcacheSize); - pPager->fd = (sqlite3_file*)pPtr; pPtr += ROUND8(pVfs->szOsFile); - pPager->sjfd = (sqlite3_file*)pPtr; pPtr += journalFileSize; - pPager->jfd = (sqlite3_file*)pPtr; pPtr += journalFileSize; + pPager = (Pager*)(pPtr); + pPager->pPCache = (PCache*)(pPtr += ROUND8(sizeof(*pPager))); + pPager->fd = (sqlite3_file*)(pPtr += ROUND8(pcacheSize)); + pPager->sjfd = (sqlite3_file*)(pPtr += ROUND8(pVfs->szOsFile)); + pPager->jfd = (sqlite3_file*)(pPtr += journalFileSize); + pPager->zFilename = (char*)(pPtr += journalFileSize); assert( EIGHT_BYTE_ALIGNMENT(pPager->jfd) ); - - /* Fill in Pager.zJournal */ - pPtr[1] = '\001'; pPtr += 3; - if( nPathname>0 ){ - pPager->zJournal = (char*)pPtr; - memcpy(pPtr, zPathname, nPathname); pPtr += nPathname; - memcpy(pPtr, "-journal",8); pPtr += 8 + 1; -#ifdef SQLITE_ENABLE_8_3_NAMES - sqlite3FileSuffix3(zFilename,pPager->zJournal); - pPtr = (u8*)(pPager->zJournal + sqlite3Strlen30(pPager->zJournal)+1); -#endif - }else{ - pPager->zJournal = 0; - pPtr++; - } - + /* Fill in the Pager.zFilename and Pager.zJournal buffers, if required. */ + if( zPathname ){ + assert( nPathname>0 ); + pPager->zJournal = (char*)(pPtr += nPathname + 1 + nUri); + memcpy(pPager->zFilename, zPathname, nPathname); + if( nUri ) memcpy(&pPager->zFilename[nPathname+1], zUri, nUri); + memcpy(pPager->zJournal, zPathname, nPathname); + memcpy(&pPager->zJournal[nPathname], "-journal\000", 8+2); + sqlite3FileSuffix3(pPager->zFilename, pPager->zJournal); #ifndef SQLITE_OMIT_WAL - /* Fill in Pager.zWal */ - pPtr[0] = '\002'; pPtr[1] = 0; pPtr += 2; - if( nPathname>0 ){ - pPager->zWal = (char*)pPtr; - memcpy(pPtr, zPathname, nPathname); pPtr += nPathname; - memcpy(pPtr, "-wal", 4); pPtr += 4 + 1; -#ifdef SQLITE_ENABLE_8_3_NAMES - sqlite3FileSuffix3(zFilename, pPager->zWal); - pPtr = (u8*)(pPager->zWal + sqlite3Strlen30(pPager->zWal)+1); + pPager->zWal = &pPager->zJournal[nPathname+8+1]; + memcpy(pPager->zWal, zPathname, nPathname); + memcpy(&pPager->zWal[nPathname], "-wal\000", 4+1); + sqlite3FileSuffix3(pPager->zFilename, pPager->zWal); #endif - }else{ - pPager->zWal = 0; - pPtr++; + sqlite3DbFree(0, zPathname); } -#endif - - /* Fill in the Pager.zFilename and pPager.zQueryParam fields */ - pPtr[0] = '\003'; pPtr[1] = 0; pPtr += 2; - pPager->zFilename = (char*)pPtr; - if( nPathname>0 ){ - memcpy(pPtr, zPathname, nPathname); pPtr += nPathname + 1; - if( zUri ){ - memcpy(pPtr, zUri, nUriByte); /* pPtr += nUriByte; // not needed */ - } - /* Double-zero terminator implied by the sqlite3MallocZero */ - } - - if( nPathname ) sqlite3DbFree(0, zPathname); pPager->pVfs = pVfs; pPager->vfsFlags = vfsFlags; @@ -56363,9 +55706,9 @@ SQLITE_PRIVATE int sqlite3PagerOpen( } #endif } - pPager->noLock = sqlite3_uri_boolean(pPager->zFilename, "nolock", 0); + pPager->noLock = sqlite3_uri_boolean(zFilename, "nolock", 0); if( (iDc & SQLITE_IOCAP_IMMUTABLE)!=0 - || sqlite3_uri_boolean(pPager->zFilename, "immutable", 0) ){ + || sqlite3_uri_boolean(zFilename, "immutable", 0) ){ vfsFlags |= SQLITE_OPEN_READONLY; goto act_like_temp_file; } @@ -58056,7 +57399,6 @@ SQLITE_PRIVATE int sqlite3PagerCommitPhaseTwo(Pager *pPager){ ** But if (due to a coding error elsewhere in the system) it does get ** called, just return the same error code without doing anything. */ if( NEVER(pPager->errCode) ) return pPager->errCode; - pPager->iDataVersion++; assert( pPager->eState==PAGER_WRITER_LOCKED || pPager->eState==PAGER_WRITER_FINISHED @@ -58085,6 +57427,7 @@ SQLITE_PRIVATE int sqlite3PagerCommitPhaseTwo(Pager *pPager){ } PAGERTRACE(("COMMIT %d\n", PAGERID(pPager))); + pPager->iDataVersion++; rc = pager_end_transaction(pPager, pPager->setMaster, 1); return pager_error(pPager, rc); } @@ -58428,13 +57771,9 @@ SQLITE_PRIVATE int sqlite3PagerSavepoint(Pager *pPager, int op, int iSavepoint){ ** behavior. But when the Btree needs to know the filename for matching to ** shared cache, it uses nullIfMemDb==0 so that in-memory databases can ** participate in shared-cache. -** -** The return value to this routine is always safe to use with -** sqlite3_uri_parameter() and sqlite3_filename_database() and friends. */ -SQLITE_PRIVATE const char *sqlite3PagerFilename(const Pager *pPager, int nullIfMemDb){ - static const char zFake[] = { 0x00, 0x01, 0x00, 0x00, 0x00 }; - return (nullIfMemDb && pPager->memDb) ? &zFake[3] : pPager->zFilename; +SQLITE_PRIVATE const char *sqlite3PagerFilename(Pager *pPager, int nullIfMemDb){ + return (nullIfMemDb && pPager->memDb) ? "" : pPager->zFilename; } /* @@ -59089,8 +58428,6 @@ SQLITE_PRIVATE int sqlite3PagerCloseWal(Pager *pPager, sqlite3 *db){ return rc; } - - #ifdef SQLITE_ENABLE_SNAPSHOT /* ** If this is a WAL database, obtain a snapshot handle for the snapshot @@ -61011,19 +60348,7 @@ static int walCheckpoint( ** not decreasing it. So assuming either that either the "old" or ** "new" version of the value is read, and not some arbitrary value ** that would never be written by a real client, things are still - ** safe. - ** - ** Astute readers have pointed out that the assumption stated in the - ** last sentence of the previous paragraph is not guaranteed to be - ** true for all conforming systems. However, the assumption is true - ** for all compilers and architectures in common use today (circa - ** 2019-11-27) and the alternatives are both slow and complex, and - ** so we will continue to go with the current design for now. If this - ** bothers you, or if you really are running on a system where aligned - ** 32-bit reads and writes are not atomic, then you can simply avoid - ** the use of WAL mode, or only use WAL mode together with - ** PRAGMA locking_mode=EXCLUSIVE and all will be well. - */ + ** safe. */ u32 y = pInfo->aReadMark[i]; if( mxSafeFrame>y ){ assert( y<=pWal->hdr.mxFrame ); @@ -61100,10 +60425,6 @@ static int walCheckpoint( rc = sqlite3OsSync(pWal->pDbFd, CKPT_SYNC_FLAGS(sync_flags)); } } - if( rc==SQLITE_OK ){ - rc = sqlite3OsFileControl(pWal->pDbFd, SQLITE_FCNTL_CKPT_DONE, 0); - if( rc==SQLITE_NOTFOUND ) rc = SQLITE_OK; - } if( rc==SQLITE_OK ){ pInfo->nBackfill = mxSafeFrame; } @@ -63614,7 +62935,6 @@ struct BtCursor { #define BTCF_AtLast 0x08 /* Cursor is pointing ot the last entry */ #define BTCF_Incrblob 0x10 /* True if an incremental I/O handle */ #define BTCF_Multiple 0x20 /* Maybe another cursor on the same btree */ -#define BTCF_Pinned 0x40 /* Cursor is busy and cannot be moved */ /* ** Potential values for BtCursor.eState. @@ -63758,7 +63078,6 @@ struct IntegrityCk { int v1, v2; /* Values for up to two %d fields in zPfx */ StrAccum errMsg; /* Accumulate the error message text here */ u32 *heap; /* Min-heap used for analyzing cell coverage */ - sqlite3 *db; /* Database connection running the check */ }; /* @@ -64780,9 +64099,6 @@ static int saveCursorPosition(BtCursor *pCur){ assert( 0==pCur->pKey ); assert( cursorHoldsMutex(pCur) ); - if( pCur->curFlags & BTCF_Pinned ){ - return SQLITE_CONSTRAINT_PINNED; - } if( pCur->eState==CURSOR_SKIPNEXT ){ pCur->eState = CURSOR_VALID; }else{ @@ -65530,7 +64846,7 @@ static int defragmentPage(MemPage *pPage, int nMaxFrag){ int sz2 = 0; int sz = get2byte(&data[iFree+2]); int top = get2byte(&data[hdr+5]); - if( NEVER(top>=iFree) ){ + if( top>=iFree ){ return SQLITE_CORRUPT_PAGE(pPage); } if( iFree2 ){ @@ -65539,7 +64855,7 @@ static int defragmentPage(MemPage *pPage, int nMaxFrag){ if( iFree2+sz2 > usableSize ) return SQLITE_CORRUPT_PAGE(pPage); memmove(&data[iFree+sz+sz2], &data[iFree+sz], iFree2-(iFree+sz)); sz += sz2; - }else if( NEVER(iFree+sz>usableSize) ){ + }else if( iFree+sz>usableSize ){ return SQLITE_CORRUPT_PAGE(pPage); } @@ -65731,10 +65047,8 @@ static int allocateSpace(MemPage *pPage, int nByte, int *pIdx){ if( (data[hdr+2] || data[hdr+1]) && gap+2<=top ){ u8 *pSpace = pageFindSlot(pPage, nByte, &rc); if( pSpace ){ - int g2; assert( pSpace+nByte<=data+pPage->pBt->usableSize ); - *pIdx = g2 = (int)(pSpace-data); - if( NEVER(g2<=gap) ){ + if( (*pIdx = (int)(pSpace-data))<=gap ){ return SQLITE_CORRUPT_PAGE(pPage); }else{ return SQLITE_OK; @@ -65812,12 +65126,12 @@ static int freeSpace(MemPage *pPage, u16 iStart, u16 iSize){ }else{ while( (iFreeBlk = get2byte(&data[iPtr]))pPage->pBt->usableSize-4 ){ /* TH3: corrupt081.100 */ + if( iFreeBlk>pPage->pBt->usableSize-4 ){ return SQLITE_CORRUPT_PAGE(pPage); } assert( iFreeBlk>iPtr || iFreeBlk==0 ); @@ -65832,7 +65146,7 @@ static int freeSpace(MemPage *pPage, u16 iStart, u16 iSize){ nFrag = iFreeBlk - iEnd; if( iEnd>iFreeBlk ) return SQLITE_CORRUPT_PAGE(pPage); iEnd = iFreeBlk + get2byte(&data[iFreeBlk+2]); - if( NEVER(iEnd > pPage->pBt->usableSize) ){ + if( iEnd > pPage->pBt->usableSize ){ return SQLITE_CORRUPT_PAGE(pPage); } iSize = iEnd - iStart; @@ -65860,8 +65174,7 @@ static int freeSpace(MemPage *pPage, u16 iStart, u16 iSize){ /* The new freeblock is at the beginning of the cell content area, ** so just extend the cell content area rather than create another ** freelist entry */ - if( iStart0 ){ u32 next, size; - if( pcnPage & 0x80000000)==0 || CORRUPT_DB ); return pBt->nPage; } SQLITE_PRIVATE u32 sqlite3BtreeLastPage(Btree *p){ assert( sqlite3BtreeHoldsMutex(p) ); - return btreePagecount(p->pBt) & 0x7fffffff; + assert( ((p->pBt->nPage)&0x80000000)==0 ); + return btreePagecount(p->pBt); } /* @@ -66490,13 +65803,9 @@ SQLITE_PRIVATE int sqlite3BtreeOpen( rc = sqlite3OsFullPathname(pVfs, zFilename, nFullPathname, zFullPathname); if( rc ){ - if( rc==SQLITE_OK_SYMLINK ){ - rc = SQLITE_OK; - }else{ - sqlite3_free(zFullPathname); - sqlite3_free(p); - return rc; - } + sqlite3_free(zFullPathname); + sqlite3_free(p); + return rc; } } #if SQLITE_THREADSAFE @@ -68456,9 +67765,8 @@ static int btreeCursor( /* The following assert statements verify that if this is a sharable ** b-tree database, the connection is holding the required table locks, ** and that no other connection has any open cursor that conflicts with - ** this lock. The iTable<1 term disables the check for corrupt schemas. */ - assert( hasSharedCacheTableLock(p, iTable, pKeyInfo!=0, (wrFlag?2:1)) - || iTable<1 ); + ** this lock. */ + assert( hasSharedCacheTableLock(p, iTable, pKeyInfo!=0, (wrFlag?2:1)) ); assert( wrFlag==0 || !hasReadConflicts(p, iTable) ); /* Assert that the caller has opened the required transaction. */ @@ -68471,13 +67779,9 @@ static int btreeCursor( allocateTempSpace(pBt); if( pBt->pTmpSpace==0 ) return SQLITE_NOMEM_BKPT; } - if( iTable<=1 ){ - if( iTable<1 ){ - return SQLITE_CORRUPT_BKPT; - }else if( btreePagecount(pBt)==0 ){ - assert( wrFlag==0 ); - iTable = 0; - } + if( iTable==1 && btreePagecount(pBt)==0 ){ + assert( wrFlag==0 ); + iTable = 0; } /* Now that no other errors can occur, finish filling in the BtCursor @@ -68502,19 +67806,6 @@ static int btreeCursor( pCur->eState = CURSOR_INVALID; return SQLITE_OK; } -static int btreeCursorWithLock( - Btree *p, /* The btree */ - int iTable, /* Root page of table to open */ - int wrFlag, /* 1 to write. 0 read-only */ - struct KeyInfo *pKeyInfo, /* First arg to comparison function */ - BtCursor *pCur /* Space for new cursor */ -){ - int rc; - sqlite3BtreeEnter(p); - rc = btreeCursor(p, iTable, wrFlag, pKeyInfo, pCur); - sqlite3BtreeLeave(p); - return rc; -} SQLITE_PRIVATE int sqlite3BtreeCursor( Btree *p, /* The btree */ int iTable, /* Root page of table to open */ @@ -68522,11 +67813,15 @@ SQLITE_PRIVATE int sqlite3BtreeCursor( struct KeyInfo *pKeyInfo, /* First arg to xCompare() */ BtCursor *pCur /* Write new cursor here */ ){ - if( p->sharable ){ - return btreeCursorWithLock(p, iTable, wrFlag, pKeyInfo, pCur); + int rc; + if( iTable<1 ){ + rc = SQLITE_CORRUPT_BKPT; }else{ - return btreeCursor(p, iTable, wrFlag, pKeyInfo, pCur); + sqlite3BtreeEnter(p); + rc = btreeCursor(p, iTable, wrFlag, pKeyInfo, pCur); + sqlite3BtreeLeave(p); } + return rc; } /* @@ -68649,18 +67944,6 @@ SQLITE_PRIVATE i64 sqlite3BtreeIntegerKey(BtCursor *pCur){ return pCur->info.nKey; } -/* -** Pin or unpin a cursor. -*/ -SQLITE_PRIVATE void sqlite3BtreeCursorPin(BtCursor *pCur){ - assert( (pCur->curFlags & BTCF_Pinned)==0 ); - pCur->curFlags |= BTCF_Pinned; -} -SQLITE_PRIVATE void sqlite3BtreeCursorUnpin(BtCursor *pCur){ - assert( (pCur->curFlags & BTCF_Pinned)!=0 ); - pCur->curFlags &= ~BTCF_Pinned; -} - #ifdef SQLITE_ENABLE_OFFSET_SQL_FUNC /* ** Return the offset into the database file for the start of the @@ -69817,11 +69100,8 @@ static SQLITE_NOINLINE int btreeNext(BtCursor *pCur){ ** to be invalid here. This can only occur if a second cursor modifies ** the page while cursor pCur is holding a reference to it. Which can ** only happen if the database is corrupt in such a way as to link the - ** page into more than one b-tree structure. - ** - ** Update 2019-12-23: appears to long longer be possible after the - ** addition of anotherValidCursor() condition on balance_deeper(). */ - harmless( idx>pPage->nCell ); + ** page into more than one b-tree structure. */ + testcase( idx>pPage->nCell ); if( idx>=pPage->nCell ){ if( !pPage->leaf ){ @@ -71020,7 +70300,7 @@ static int rebuildPage( assert( i(u32)usableSize) ){ j = 0; } + if( j>(u32)usableSize ){ j = 0; } memcpy(&pTmp[j], &aData[j], usableSize - j); for(k=0; pCArray->ixNx[k]<=i && ALWAYS(kxCellSize(pPg, pCell) || CORRUPT_DB ); - testcase( sz!=pPg->xCellSize(pPg,pCell) ) + testcase( sz!=pPg->xCellSize(pPg,pCell) ); i++; if( i>=iEnd ) break; if( pCArray->ixNx[k]<=i ){ @@ -72410,30 +71690,6 @@ static int balance_deeper(MemPage *pRoot, MemPage **ppChild){ return SQLITE_OK; } -/* -** Return SQLITE_CORRUPT if any cursor other than pCur is currently valid -** on the same B-tree as pCur. -** -** This can if a database is corrupt with two or more SQL tables -** pointing to the same b-tree. If an insert occurs on one SQL table -** and causes a BEFORE TRIGGER to do a secondary insert on the other SQL -** table linked to the same b-tree. If the secondary insert causes a -** rebalance, that can change content out from under the cursor on the -** first SQL table, violating invariants on the first insert. -*/ -static int anotherValidCursor(BtCursor *pCur){ - BtCursor *pOther; - for(pOther=pCur->pBt->pCursor; pOther; pOther=pOther->pNext){ - if( pOther!=pCur - && pOther->eState==CURSOR_VALID - && pOther->pPage==pCur->pPage - ){ - return SQLITE_CORRUPT_BKPT; - } - } - return SQLITE_OK; -} - /* ** The page that pCur currently points to has just been modified in ** some way. This function figures out if this modification means the @@ -72461,7 +71717,7 @@ static int balance(BtCursor *pCur){ if( pPage->nOverflow==0 && pPage->nFree<=nMin ){ break; }else if( (iPage = pCur->iPage)==0 ){ - if( pPage->nOverflow && (rc = anotherValidCursor(pCur))==SQLITE_OK ){ + if( pPage->nOverflow ){ /* The root page of the b-tree is overfull. In this case call the ** balance_deeper() function to create a new child for the root-page ** and copy the current contents of the root-page to it. The @@ -72757,6 +72013,7 @@ SQLITE_PRIVATE int sqlite3BtreeInsert( if( flags & BTREE_SAVEPOSITION ){ assert( pCur->curFlags & BTCF_ValidNKey ); assert( pX->nKey==pCur->info.nKey ); + assert( pCur->info.nSize!=0 ); assert( loc==0 ); } #endif @@ -72831,9 +72088,7 @@ SQLITE_PRIVATE int sqlite3BtreeInsert( } } - assert( pCur->eState==CURSOR_VALID - || (pCur->eState==CURSOR_INVALID && loc) - || CORRUPT_DB ); + assert( pCur->eState==CURSOR_VALID || (pCur->eState==CURSOR_INVALID && loc) ); pPage = pCur->pPage; assert( pPage->intKey || pX->nKey>=0 ); @@ -73604,7 +72859,7 @@ SQLITE_PRIVATE int sqlite3BtreeUpdateMeta(Btree *p, int idx, u32 iMeta){ ** Otherwise, if an error is encountered (i.e. an IO error or database ** corruption) an SQLite error code is returned. */ -SQLITE_PRIVATE int sqlite3BtreeCount(sqlite3 *db, BtCursor *pCur, i64 *pnEntry){ +SQLITE_PRIVATE int sqlite3BtreeCount(BtCursor *pCur, i64 *pnEntry){ i64 nEntry = 0; /* Value to return in *pnEntry */ int rc; /* Return code */ @@ -73617,7 +72872,7 @@ SQLITE_PRIVATE int sqlite3BtreeCount(sqlite3 *db, BtCursor *pCur, i64 *pnEntry){ /* Unless an error occurs, the following loop runs one iteration for each ** page in the B-Tree structure (not including overflow pages). */ - while( rc==SQLITE_OK && !db->u1.isInterrupted ){ + while( rc==SQLITE_OK ){ int iIdx; /* Index of child node in parent */ MemPage *pPage; /* Current page of the b-tree */ @@ -73743,7 +72998,6 @@ static int checkRef(IntegrityCk *pCheck, Pgno iPage){ checkAppendMsg(pCheck, "2nd reference to page %d", iPage); return 1; } - if( pCheck->db->u1.isInterrupted ) return 1; setPageReferenced(pCheck, iPage); return 0; } @@ -74187,7 +73441,6 @@ static int checkTreePage( ** returned. If a memory allocation error occurs, NULL is returned. */ SQLITE_PRIVATE char *sqlite3BtreeIntegrityCheck( - sqlite3 *db, /* Database connection that is running the check */ Btree *p, /* The btree to be checked */ int *aRoot, /* An array of root pages numbers for individual trees */ int nRoot, /* Number of entries in aRoot[] */ @@ -74205,7 +73458,6 @@ SQLITE_PRIVATE char *sqlite3BtreeIntegrityCheck( assert( p->inTrans>TRANS_NONE && pBt->inTransaction>TRANS_NONE ); VVA_ONLY( nRef = sqlite3PagerRefcount(pBt->pPager) ); assert( nRef>=0 ); - sCheck.db = db; sCheck.pBt = pBt; sCheck.pPager = pBt->pPager; sCheck.nPage = btreePagecount(sCheck.pBt); @@ -75872,11 +75124,15 @@ SQLITE_PRIVATE int sqlite3VdbeMemFinalize(Mem *pMem, FuncDef *pFunc){ #ifndef SQLITE_OMIT_WINDOWFUNC SQLITE_PRIVATE int sqlite3VdbeMemAggValue(Mem *pAccum, Mem *pOut, FuncDef *pFunc){ sqlite3_context ctx; + Mem t; assert( pFunc!=0 ); assert( pFunc->xValue!=0 ); assert( (pAccum->flags & MEM_Null)!=0 || pFunc==pAccum->u.pDef ); assert( pAccum->db==0 || sqlite3_mutex_held(pAccum->db->mutex) ); memset(&ctx, 0, sizeof(ctx)); + memset(&t, 0, sizeof(t)); + t.flags = MEM_Null; + t.db = pAccum->db; sqlite3VdbeMemSetNull(pOut); ctx.pOut = pOut; ctx.pMem = pAccum; @@ -76002,7 +75258,8 @@ SQLITE_PRIVATE i64 sqlite3VdbeIntValue(Mem *pMem){ return pMem->u.i; }else if( flags & MEM_Real ){ return doubleToInt64(pMem->u.r); - }else if( (flags & (MEM_Str|MEM_Blob))!=0 && pMem->z!=0 ){ + }else if( flags & (MEM_Str|MEM_Blob) ){ + assert( pMem->z || pMem->n==0 ); return memIntValue(pMem); }else{ return 0; @@ -76159,8 +75416,8 @@ SQLITE_PRIVATE int sqlite3VdbeMemNumerify(Mem *pMem){ ** affinity even if that results in loss of data. This routine is ** used (for example) to implement the SQL "cast()" operator. */ -SQLITE_PRIVATE int sqlite3VdbeMemCast(Mem *pMem, u8 aff, u8 encoding){ - if( pMem->flags & MEM_Null ) return SQLITE_OK; +SQLITE_PRIVATE void sqlite3VdbeMemCast(Mem *pMem, u8 aff, u8 encoding){ + if( pMem->flags & MEM_Null ) return; switch( aff ){ case SQLITE_AFF_BLOB: { /* Really a cast to BLOB */ if( (pMem->flags & MEM_Blob)==0 ){ @@ -76191,10 +75448,9 @@ SQLITE_PRIVATE int sqlite3VdbeMemCast(Mem *pMem, u8 aff, u8 encoding){ sqlite3ValueApplyAffinity(pMem, SQLITE_AFF_TEXT, encoding); assert( pMem->flags & MEM_Str || pMem->db->mallocFailed ); pMem->flags &= ~(MEM_Int|MEM_Real|MEM_IntReal|MEM_Blob|MEM_Zero); - return sqlite3VdbeChangeEncoding(pMem, encoding); + break; } } - return SQLITE_OK; } /* @@ -76360,30 +75616,23 @@ SQLITE_PRIVATE int sqlite3VdbeMemTooBig(Mem *p){ ** its link to a shallow copy and by marking any current shallow ** copies of this cell as invalid. ** -** This is used for testing and debugging only - to help ensure that shallow -** copies (created by OP_SCopy) are not misused. +** This is used for testing and debugging only - to make sure shallow +** copies are not misused. */ SQLITE_PRIVATE void sqlite3VdbeMemAboutToChange(Vdbe *pVdbe, Mem *pMem){ int i; Mem *pX; - for(i=1, pX=pVdbe->aMem+1; inMem; i++, pX++){ + for(i=0, pX=pVdbe->aMem; inMem; i++, pX++){ if( pX->pScopyFrom==pMem ){ - u16 mFlags; - if( pVdbe->db->flags & SQLITE_VdbeTrace ){ - sqlite3DebugPrintf("Invalidate R[%d] due to change in R[%d]\n", - (int)(pX - pVdbe->aMem), (int)(pMem - pVdbe->aMem)); - } /* If pX is marked as a shallow copy of pMem, then verify that ** no significant changes have been made to pX since the OP_SCopy. ** A significant change would indicated a missed call to this ** function for pX. Minor changes, such as adding or removing a ** dual type, are allowed, as long as the underlying value is the ** same. */ - mFlags = pMem->flags & pX->flags & pX->mScopyFlags; + u16 mFlags = pMem->flags & pX->flags & pX->mScopyFlags; assert( (mFlags&(MEM_Int|MEM_IntReal))==0 || pMem->u.i==pX->u.i ); - /* assert( (mFlags&MEM_Real)==0 || pMem->u.r==pX->u.r ); */ - /* ^^ */ - /* Cannot reliably compare doubles for equality */ + assert( (mFlags&MEM_Real)==0 || pMem->u.r==pX->u.r ); assert( (mFlags&MEM_Str)==0 || (pMem->n==pX->n && pMem->z==pX->z) ); assert( (mFlags&MEM_Blob)==0 || sqlite3BlobCompare(pMem,pX)==0 ); @@ -76397,6 +75646,7 @@ SQLITE_PRIVATE void sqlite3VdbeMemAboutToChange(Vdbe *pVdbe, Mem *pMem){ } #endif /* SQLITE_DEBUG */ + /* ** Make an shallow copy of pFrom into pTo. Prior contents of ** pTo are freed. The pFrom->z field is not duplicated. If @@ -76542,19 +75792,10 @@ SQLITE_PRIVATE int sqlite3VdbeMemSetStr( pMem->n = nByte; pMem->flags = flags; - if( enc ){ - pMem->enc = enc; -#ifdef SQLITE_ENABLE_SESSION - }else if( pMem->db==0 ){ - pMem->enc = SQLITE_UTF8; -#endif - }else{ - assert( pMem->db!=0 ); - pMem->enc = ENC(pMem->db); - } + pMem->enc = (enc==0 ? SQLITE_UTF8 : enc); #ifndef SQLITE_OMIT_UTF16 - if( enc>SQLITE_UTF8 && sqlite3VdbeMemHandleBom(pMem) ){ + if( pMem->enc!=SQLITE_UTF8 && sqlite3VdbeMemHandleBom(pMem) ){ return SQLITE_NOMEM_BKPT; } #endif @@ -76971,11 +76212,7 @@ static int valueFromExpr( if( pVal->flags & MEM_Real ){ pVal->u.r = -pVal->u.r; }else if( pVal->u.i==SMALLEST_INT64 ){ -#ifndef SQLITE_OMIT_FLOATING_POINT pVal->u.r = -(double)SMALLEST_INT64; -#else - pVal->u.r = LARGEST_INT64; -#endif MemSetTypeFlag(pVal, MEM_Real); }else{ pVal->u.i = -pVal->u.i; @@ -77334,10 +76571,6 @@ SQLITE_PRIVATE int sqlite3ValueBytes(sqlite3_value *pVal, u8 enc){ /* #include "sqliteInt.h" */ /* #include "vdbeInt.h" */ -/* Forward references */ -static void freeEphemeralFunction(sqlite3 *db, FuncDef *pDef); -static void vdbeFreeOpArray(sqlite3 *, Op *, int); - /* ** Create a new virtual database engine. */ @@ -77365,13 +76598,6 @@ SQLITE_PRIVATE Vdbe *sqlite3VdbeCreate(Parse *pParse){ return p; } -/* -** Return the Parse object that owns a Vdbe object. -*/ -SQLITE_PRIVATE Parse *sqlite3VdbeParser(Vdbe *p){ - return p->pParse; -} - /* ** Change the error string stored in Vdbe.zErrMsg */ @@ -77452,7 +76678,7 @@ SQLITE_PRIVATE void sqlite3VdbeSwap(Vdbe *pA, Vdbe *pB){ zTmp = pA->zSql; pA->zSql = pB->zSql; pB->zSql = zTmp; -#ifdef SQLITE_ENABLE_NORMALIZE +#if 0 zTmp = pA->zNormSql; pA->zNormSql = pB->zNormSql; pB->zNormSql = zTmp; @@ -77513,16 +76739,9 @@ static int growOpArray(Vdbe *v, int nOp){ #ifdef SQLITE_DEBUG /* This routine is just a convenient place to set a breakpoint that will ** fire after each opcode is inserted and displayed using -** "PRAGMA vdbe_addoptrace=on". Parameters "pc" (program counter) and -** pOp are available to make the breakpoint conditional. -** -** Other useful labels for breakpoints include: -** test_trace_breakpoint(pc,pOp) -** sqlite3CorruptError(lineno) -** sqlite3MisuseError(lineno) -** sqlite3CantopenError(lineno) +** "PRAGMA vdbe_addoptrace=on". */ -static void test_addop_breakpoint(int pc, Op *pOp){ +static void test_addop_breakpoint(void){ static int n = 0; n++; } @@ -77575,7 +76794,7 @@ SQLITE_PRIVATE int sqlite3VdbeAddOp3(Vdbe *p, int op, int p1, int p2, int p3){ #ifdef SQLITE_DEBUG if( p->db->flags & SQLITE_VdbeAddopTrace ){ sqlite3VdbePrintOp(0, i, &p->aOp[i]); - test_addop_breakpoint(i, &p->aOp[i]); + test_addop_breakpoint(); } #endif #ifdef VDBE_PROFILE @@ -77658,49 +76877,6 @@ SQLITE_PRIVATE int sqlite3VdbeAddOp4( return addr; } -/* -** Add an OP_Function or OP_PureFunc opcode. -** -** The eCallCtx argument is information (typically taken from Expr.op2) -** that describes the calling context of the function. 0 means a general -** function call. NC_IsCheck means called by a check constraint, -** NC_IdxExpr means called as part of an index expression. NC_PartIdx -** means in the WHERE clause of a partial index. NC_GenCol means called -** while computing a generated column value. 0 is the usual case. -*/ -SQLITE_PRIVATE int sqlite3VdbeAddFunctionCall( - Parse *pParse, /* Parsing context */ - int p1, /* Constant argument mask */ - int p2, /* First argument register */ - int p3, /* Register into which results are written */ - int nArg, /* Number of argument */ - const FuncDef *pFunc, /* The function to be invoked */ - int eCallCtx /* Calling context */ -){ - Vdbe *v = pParse->pVdbe; - int nByte; - int addr; - sqlite3_context *pCtx; - assert( v ); - nByte = sizeof(*pCtx) + (nArg-1)*sizeof(sqlite3_value*); - pCtx = sqlite3DbMallocRawNN(pParse->db, nByte); - if( pCtx==0 ){ - assert( pParse->db->mallocFailed ); - freeEphemeralFunction(pParse->db, (FuncDef*)pFunc); - return 0; - } - pCtx->pOut = 0; - pCtx->pFunc = (FuncDef*)pFunc; - pCtx->pVdbe = 0; - pCtx->isError = 0; - pCtx->argc = nArg; - pCtx->iOp = sqlite3VdbeCurrentAddr(v); - addr = sqlite3VdbeAddOp4(v, eCallCtx ? OP_PureFunc : OP_Function, - p1, p2, p3, (char*)pCtx, P4_FUNCCTX); - sqlite3VdbeChangeP5(v, eCallCtx & NC_SelfRef); - return addr; -} - /* ** Add an opcode that includes the p4 value with a P4_INT64 or ** P4_REAL type. @@ -77993,7 +77169,6 @@ static Op *opIterNext(VdbeOpIter *p){ ** * OP_HaltIfNull with P1=SQLITE_CONSTRAINT and P2=OE_Abort. ** * OP_Destroy ** * OP_VUpdate -** * OP_VCreate ** * OP_VRename ** * OP_FkCounter with P2==0 (immediate foreign key constraint) ** * OP_CreateBtree/BTREE_INTKEY and OP_InitCoroutine @@ -78021,7 +77196,6 @@ SQLITE_PRIVATE int sqlite3VdbeAssertMayAbort(Vdbe *v, int mayAbort){ int opcode = pOp->opcode; if( opcode==OP_Destroy || opcode==OP_VUpdate || opcode==OP_VRename || opcode==OP_VDestroy - || opcode==OP_VCreate || (opcode==OP_ParseSchema && pOp->p4.z==0) || ((opcode==OP_Halt || opcode==OP_HaltIfNull) && ((pOp->p1)!=SQLITE_OK && pOp->p2==OE_Abort)) @@ -78395,6 +77569,8 @@ static void freeEphemeralFunction(sqlite3 *db, FuncDef *pDef){ } } +static void vdbeFreeOpArray(sqlite3 *, Op *, int); + /* ** Delete a P4 value if necessary. */ @@ -78404,7 +77580,7 @@ static SQLITE_NOINLINE void freeP4Mem(sqlite3 *db, Mem *p){ } static SQLITE_NOINLINE void freeP4FuncCtx(sqlite3 *db, sqlite3_context *p){ freeEphemeralFunction(db, p->pFunc); - sqlite3DbFreeNN(db, p); + sqlite3DbFreeNN(db, p); } static void freeP4(sqlite3 *db, int p4type, void *p4){ assert( db ); @@ -78478,13 +77654,6 @@ SQLITE_PRIVATE void sqlite3VdbeLinkSubProgram(Vdbe *pVdbe, SubProgram *p){ pVdbe->pProgram = p; } -/* -** Return true if the given Vdbe has any SubPrograms. -*/ -SQLITE_PRIVATE int sqlite3VdbeHasSubProgram(Vdbe *pVdbe){ - return pVdbe->pProgram!=0; -} - /* ** Change the opcode at addr into OP_Noop */ @@ -78512,41 +77681,6 @@ SQLITE_PRIVATE int sqlite3VdbeDeletePriorOpcode(Vdbe *p, u8 op){ } } -#ifdef SQLITE_DEBUG -/* -** Generate an OP_ReleaseReg opcode to indicate that a range of -** registers, except any identified by mask, are no longer in use. -*/ -SQLITE_PRIVATE void sqlite3VdbeReleaseRegisters( - Parse *pParse, /* Parsing context */ - int iFirst, /* Index of first register to be released */ - int N, /* Number of registers to release */ - u32 mask, /* Mask of registers to NOT release */ - int bUndefine /* If true, mark registers as undefined */ -){ - if( N==0 ) return; - assert( pParse->pVdbe ); - assert( iFirst>=1 ); - assert( iFirst+N-1<=pParse->nMem ); - if( N<=31 && mask!=0 ){ - while( N>0 && (mask&1)!=0 ){ - mask >>= 1; - iFirst++; - N--; - } - while( N>0 && N<=32 && (mask & MASKBIT32(N-1))!=0 ){ - mask &= ~MASKBIT32(N-1); - N--; - } - } - if( N>0 ){ - sqlite3VdbeAddOp3(pParse->pVdbe, OP_ReleaseReg, iFirst, N, *(int*)&mask); - if( bUndefine ) sqlite3VdbeChangeP5(pParse->pVdbe, 1); - } -} -#endif /* SQLITE_DEBUG */ - - /* ** Change the value of the P4 operand for a specific instruction. ** This routine is useful when a large program is loaded from a @@ -78664,8 +77798,7 @@ SQLITE_PRIVATE void sqlite3VdbeSetP4KeyInfo(Parse *pParse, Index *pIdx){ */ static void vdbeVComment(Vdbe *p, const char *zFormat, va_list ap){ assert( p->nOp>0 || p->aOp==0 ); - assert( p->aOp==0 || p->aOp[p->nOp-1].zComment==0 || p->db->mallocFailed - || p->pParse->nErr>0 ); + assert( p->aOp==0 || p->aOp[p->nOp-1].zComment==0 || p->db->mallocFailed ); if( p->nOp ){ assert( p->aOp ); sqlite3DbFree(p->db, p->aOp[p->nOp-1].zComment); @@ -78946,11 +78079,13 @@ static char *displayP4(Op *pOp, char *zTemp, int nTemp){ sqlite3_str_appendf(&x, "%s(%d)", pDef->zName, pDef->nArg); break; } +#if defined(SQLITE_DEBUG) || defined(VDBE_PROFILE) case P4_FUNCCTX: { FuncDef *pDef = pOp->p4.pCtx->pFunc; sqlite3_str_appendf(&x, "%s(%d)", pDef->zName, pDef->nArg); break; } +#endif case P4_INT64: { sqlite3_str_appendf(&x, "%lld", *pOp->p4.pI64); break; @@ -79644,26 +78779,8 @@ SQLITE_PRIVATE void sqlite3VdbeMakeReady( resolveP2Values(p, &nArg); p->usesStmtJournal = (u8)(pParse->isMultiWrite && pParse->mayAbort); - if( pParse->explain ){ - static const char * const azColName[] = { - "addr", "opcode", "p1", "p2", "p3", "p4", "p5", "comment", - "id", "parent", "notused", "detail" - }; - int iFirst, mx, i; - if( nMem<10 ) nMem = 10; - if( pParse->explain==2 ){ - sqlite3VdbeSetNumCols(p, 4); - iFirst = 8; - mx = 12; - }else{ - sqlite3VdbeSetNumCols(p, 8); - iFirst = 0; - mx = 8; - } - for(i=iFirst; iexplain && nMem<10 ){ + nMem = 10; } p->expired = 0; @@ -80013,7 +79130,7 @@ static int vdbeCommit(sqlite3 *db, Vdbe *p){ /* Select a master journal file name */ nMainFile = sqlite3Strlen30(zMainFile); - zMaster = sqlite3MPrintf(db, "%s-mjXXXXXX9XXz%c%c", zMainFile, 0, 0); + zMaster = sqlite3MPrintf(db, "%s-mjXXXXXX9XXz", zMainFile); if( zMaster==0 ) return SQLITE_NOMEM_BKPT; do { u32 iRandom; @@ -80752,7 +79869,7 @@ SQLITE_PRIVATE void sqlite3VdbeDelete(Vdbe *p){ ** carried out. Seek the cursor now. If an error occurs, return ** the appropriate error code. */ -SQLITE_PRIVATE int SQLITE_NOINLINE sqlite3VdbeFinishMoveto(VdbeCursor *p){ +static int SQLITE_NOINLINE handleDeferredMoveto(VdbeCursor *p){ int res, rc; #ifdef SQLITE_TEST extern int sqlite3_search_count; @@ -80824,7 +79941,7 @@ SQLITE_PRIVATE int sqlite3VdbeCursorMoveto(VdbeCursor **pp, int *piCol){ *piCol = iMap - 1; return SQLITE_OK; } - return sqlite3VdbeFinishMoveto(p); + return handleDeferredMoveto(p); } if( sqlite3BtreeCursorHasMoved(p->uc.pCursor) ){ return handleMovedCursor(p); @@ -82364,25 +81481,13 @@ SQLITE_PRIVATE void sqlite3VdbeSetVarmask(Vdbe *v, int iVar){ ** features such as 'now'. */ SQLITE_PRIVATE int sqlite3NotPureFunc(sqlite3_context *pCtx){ - const VdbeOp *pOp; #ifdef SQLITE_ENABLE_STAT4 if( pCtx->pVdbe==0 ) return 1; #endif - pOp = pCtx->pVdbe->aOp + pCtx->iOp; - if( pOp->opcode==OP_PureFunc ){ - const char *zContext; - char *zMsg; - if( pOp->p5 & NC_IsCheck ){ - zContext = "a CHECK constraint"; - }else if( pOp->p5 & NC_GenCol ){ - zContext = "a generated column"; - }else{ - zContext = "an index"; - } - zMsg = sqlite3_mprintf("non-deterministic use of %s() in %s", - pCtx->pFunc->zName, zContext); - sqlite3_result_error(pCtx, zMsg, -1); - sqlite3_free(zMsg); + if( pCtx->pVdbe->aOp[pCtx->iOp].opcode==OP_PureFunc ){ + sqlite3_result_error(pCtx, + "non-deterministic function in index expression or CHECK constraint", + -1); return 0; } return 1; @@ -84329,7 +83434,7 @@ SQLITE_API int sqlite3_preupdate_old(sqlite3 *db, int iIdx, sqlite3_value **ppVa goto preupdate_old_out; } if( p->pPk ){ - iIdx = sqlite3TableColumnToIndex(p->pPk, iIdx); + iIdx = sqlite3ColumnOfIndex(p->pPk, iIdx); } if( iIdx>=p->pCsr->nField || iIdx<0 ){ rc = SQLITE_RANGE; @@ -84419,7 +83524,7 @@ SQLITE_API int sqlite3_preupdate_new(sqlite3 *db, int iIdx, sqlite3_value **ppVa goto preupdate_new_out; } if( p->pPk && p->op!=SQLITE_UPDATE ){ - iIdx = sqlite3TableColumnToIndex(p->pPk, iIdx); + iIdx = sqlite3ColumnOfIndex(p->pPk, iIdx); } if( iIdx>=p->pCsr->nField || iIdx<0 ){ rc = SQLITE_RANGE; @@ -84867,26 +83972,6 @@ SQLITE_API int sqlite3_found_count = 0; # define UPDATE_MAX_BLOBSIZE(P) #endif -#ifdef SQLITE_DEBUG -/* This routine provides a convenient place to set a breakpoint during -** tracing with PRAGMA vdbe_trace=on. The breakpoint fires right after -** each opcode is printed. Variables "pc" (program counter) and pOp are -** available to add conditionals to the breakpoint. GDB example: -** -** break test_trace_breakpoint if pc=22 -** -** Other useful labels for breakpoints include: -** test_addop_breakpoint(pc,pOp) -** sqlite3CorruptError(lineno) -** sqlite3MisuseError(lineno) -** sqlite3CantopenError(lineno) -*/ -static void test_trace_breakpoint(int pc, Op *pOp, Vdbe *v){ - static int n = 0; - n++; -} -#endif - /* ** Invoke the VDBE coverage callback, if that callback is defined. This ** feature is used for test suite validation only and does not appear an @@ -85231,9 +84316,12 @@ static u16 numericType(Mem *pMem){ ** Write a nice string representation of the contents of cell pMem ** into buffer zBuf, length nBuf. */ -SQLITE_PRIVATE void sqlite3VdbeMemPrettyPrint(Mem *pMem, StrAccum *pStr){ +SQLITE_PRIVATE void sqlite3VdbeMemPrettyPrint(Mem *pMem, char *zBuf){ + char *zCsr = zBuf; int f = pMem->flags; + static const char *const encnames[] = {"(X)", "(8)", "(16LE)", "(16BE)"}; + if( f&MEM_Blob ){ int i; char c; @@ -85249,40 +84337,57 @@ SQLITE_PRIVATE void sqlite3VdbeMemPrettyPrint(Mem *pMem, StrAccum *pStr){ }else{ c = 's'; } - sqlite3_str_appendf(pStr, "%cx[", c); + *(zCsr++) = c; + *(zCsr++) = 'x'; + sqlite3_snprintf(100, zCsr, "%d[", pMem->n); + zCsr += sqlite3Strlen30(zCsr); for(i=0; i<25 && in; i++){ - sqlite3_str_appendf(pStr, "%02X", ((int)pMem->z[i] & 0xFF)); + sqlite3_snprintf(100, zCsr, "%02X", ((int)pMem->z[i] & 0xFF)); + zCsr += sqlite3Strlen30(zCsr); } - sqlite3_str_appendf(pStr, "|"); + *zCsr++ = '|'; for(i=0; i<25 && in; i++){ char z = pMem->z[i]; - sqlite3_str_appendchar(pStr, 1, (z<32||z>126)?'.':z); + if( z<32 || z>126 ) *zCsr++ = '.'; + else *zCsr++ = z; } - sqlite3_str_appendf(pStr,"]"); + *(zCsr++) = ']'; if( f & MEM_Zero ){ - sqlite3_str_appendf(pStr, "+%dz",pMem->u.nZero); + sqlite3_snprintf(100, zCsr,"+%dz",pMem->u.nZero); + zCsr += sqlite3Strlen30(zCsr); } + *zCsr = '\0'; }else if( f & MEM_Str ){ - int j; - u8 c; + int j, k; + zBuf[0] = ' '; if( f & MEM_Dyn ){ - c = 'z'; + zBuf[1] = 'z'; assert( (f & (MEM_Static|MEM_Ephem))==0 ); }else if( f & MEM_Static ){ - c = 't'; + zBuf[1] = 't'; assert( (f & (MEM_Dyn|MEM_Ephem))==0 ); }else if( f & MEM_Ephem ){ - c = 'e'; + zBuf[1] = 'e'; assert( (f & (MEM_Static|MEM_Dyn))==0 ); }else{ - c = 's'; + zBuf[1] = 's'; } - sqlite3_str_appendf(pStr, " %c%d[", c, pMem->n); + k = 2; + sqlite3_snprintf(100, &zBuf[k], "%d", pMem->n); + k += sqlite3Strlen30(&zBuf[k]); + zBuf[k++] = '['; for(j=0; j<25 && jn; j++){ - c = pMem->z[j]; - sqlite3_str_appendchar(pStr, 1, (c>=0x20&&c<=0x7f) ? c : '.'); + u8 c = pMem->z[j]; + if( c>=0x20 && c<0x7f ){ + zBuf[k++] = c; + }else{ + zBuf[k++] = '.'; + } } - sqlite3_str_appendf(pStr, "]%s", encnames[pMem->enc]); + zBuf[k++] = ']'; + sqlite3_snprintf(100,&zBuf[k], encnames[pMem->enc]); + k += sqlite3Strlen30(&zBuf[k]); + zBuf[k++] = 0; } } #endif @@ -85309,37 +84414,20 @@ static void memTracePrint(Mem *p){ }else if( sqlite3VdbeMemIsRowSet(p) ){ printf(" (rowset)"); }else{ - StrAccum acc; - char zBuf[1000]; - sqlite3StrAccumInit(&acc, 0, zBuf, sizeof(zBuf), 0); - sqlite3VdbeMemPrettyPrint(p, &acc); - printf(" %s", sqlite3StrAccumFinish(&acc)); + char zBuf[200]; + sqlite3VdbeMemPrettyPrint(p, zBuf); + printf(" %s", zBuf); } if( p->flags & MEM_Subtype ) printf(" subtype=0x%02x", p->eSubtype); } static void registerTrace(int iReg, Mem *p){ - printf("R[%d] = ", iReg); + printf("REG[%d] = ", iReg); memTracePrint(p); - if( p->pScopyFrom ){ - printf(" <== R[%d]", (int)(p->pScopyFrom - &p[-iReg])); - } printf("\n"); sqlite3VdbeCheckMemInvariants(p); } #endif -#ifdef SQLITE_DEBUG -/* -** Show the values of all registers in the virtual machine. Used for -** interactive debugging. -*/ -SQLITE_PRIVATE void sqlite3VdbeRegisterDump(Vdbe *v){ - int i; - for(i=1; inMem; i++) registerTrace(i, v->aMem+i); -} -#endif /* SQLITE_DEBUG */ - - #ifdef SQLITE_DEBUG # define REGISTER_TRACE(R,M) if(db->flags&SQLITE_VdbeTrace)registerTrace(R,M) #else @@ -85368,7 +84456,7 @@ SQLITE_PRIVATE void sqlite3VdbeRegisterDump(Vdbe *v){ ****************************************************************************** ** ** This file contains inline asm code for retrieving "high-performance" -** counters for x86 and x86_64 class CPUs. +** counters for x86 class CPUs. */ #ifndef SQLITE_HWTIME_H #define SQLITE_HWTIME_H @@ -85379,9 +84467,8 @@ SQLITE_PRIVATE void sqlite3VdbeRegisterDump(Vdbe *v){ ** processor and returns that value. This can be used for high-res ** profiling. */ -#if !defined(__STRICT_ANSI__) && \ - (defined(__GNUC__) || defined(_MSC_VER)) && \ - (defined(i386) || defined(__i386__) || defined(_M_IX86)) +#if (defined(__GNUC__) || defined(_MSC_VER)) && \ + (defined(i386) || defined(__i386__) || defined(_M_IX86)) #if defined(__GNUC__) @@ -85402,7 +84489,7 @@ SQLITE_PRIVATE void sqlite3VdbeRegisterDump(Vdbe *v){ #endif -#elif !defined(__STRICT_ANSI__) && (defined(__GNUC__) && defined(__x86_64__)) +#elif (defined(__GNUC__) && defined(__x86_64__)) __inline__ sqlite_uint64 sqlite3Hwtime(void){ unsigned long val; @@ -85410,7 +84497,7 @@ SQLITE_PRIVATE void sqlite3VdbeRegisterDump(Vdbe *v){ return val; } -#elif !defined(__STRICT_ANSI__) && (defined(__GNUC__) && defined(__ppc__)) +#elif (defined(__GNUC__) && defined(__ppc__)) __inline__ sqlite_uint64 sqlite3Hwtime(void){ unsigned long long retval; @@ -85427,13 +84514,14 @@ SQLITE_PRIVATE void sqlite3VdbeRegisterDump(Vdbe *v){ #else + #error Need implementation of sqlite3Hwtime() for your platform. + /* - ** asm() is needed for hardware timing support. Without asm(), - ** disable the sqlite3Hwtime() routine. - ** - ** sqlite3Hwtime() is only used for some obscure debugging - ** and analysis configurations, not in any deliverable, so this - ** should not be a great loss. + ** To compile without implementing sqlite3Hwtime() for your platform, + ** you can remove the above #error and use the following + ** stub function. You will lose timing support for many + ** of the debugging and testing utilities, but it should at + ** least compile and run. */ SQLITE_PRIVATE sqlite_uint64 sqlite3Hwtime(void){ return ((sqlite_uint64)0); } @@ -85594,7 +84682,6 @@ SQLITE_PRIVATE int sqlite3VdbeExec( #ifdef SQLITE_DEBUG if( db->flags & SQLITE_VdbeTrace ){ sqlite3VdbePrintOp(stdout, (int)(pOp - aOp), pOp); - test_trace_breakpoint((int)(pOp - aOp),pOp,p); } #endif @@ -85702,20 +84789,6 @@ SQLITE_PRIVATE int sqlite3VdbeExec( ** to the current line should be indented for EXPLAIN output. */ case OP_Goto: { /* jump */ - -#ifdef SQLITE_DEBUG - /* In debuggging mode, when the p5 flags is set on an OP_Goto, that - ** means we should really jump back to the preceeding OP_ReleaseReg - ** instruction. */ - if( pOp->p5 ){ - assert( pOp->p2 < (int)(pOp - aOp) ); - assert( pOp->p2 > 1 ); - pOp = &aOp[pOp->p2 - 2]; - assert( pOp[1].opcode==OP_ReleaseReg ); - goto check_for_interrupt; - } -#endif - jump_to_p2_and_check_for_interrupt: pOp = &aOp[pOp->p2 - 1]; @@ -86192,13 +85265,8 @@ case OP_Move: { memAboutToChange(p, pOut); sqlite3VdbeMemMove(pOut, pIn1); #ifdef SQLITE_DEBUG - pIn1->pScopyFrom = 0; - { int i; - for(i=1; inMem; i++){ - if( aMem[i].pScopyFrom==pIn1 ){ - aMem[i].pScopyFrom = pOut; - } - } + if( pOut->pScopyFrom>=&aMem[p1] && pOut->pScopyFrompScopyFrom += pOp->p2 - p1; } #endif Deephemeralize(pOut); @@ -86339,14 +85407,6 @@ case OP_ResultRow: { || (pMem[i].flags & (MEM_Str|MEM_Blob))==0 ); sqlite3VdbeMemNulTerminate(&pMem[i]); REGISTER_TRACE(pOp->p1+i, &pMem[i]); -#ifdef SQLITE_DEBUG - /* The registers in the result will not be used again when the - ** prepared statement restarts. This is because sqlite3_column() - ** APIs might have caused type conversions of made other changes to - ** the register values. Therefore, we can go ahead and break any - ** OP_SCopy dependencies. */ - pMem[i].pScopyFrom = 0; -#endif } if( db->mallocFailed ) goto no_mem; @@ -86354,7 +85414,6 @@ case OP_ResultRow: { db->xTrace(SQLITE_TRACE_ROW, db->pTraceArg, p, 0); } - /* Return SQLITE_ROW */ p->pc = (int)(pOp - aOp) + 1; @@ -86751,11 +85810,9 @@ case OP_Cast: { /* in1 */ pIn1 = &aMem[pOp->p1]; memAboutToChange(p, pIn1); rc = ExpandBlob(pIn1); - if( rc ) goto abort_due_to_error; - rc = sqlite3VdbeMemCast(pIn1, pOp->p2, encoding); - if( rc ) goto abort_due_to_error; + sqlite3VdbeMemCast(pIn1, pOp->p2, encoding); UPDATE_MAX_BLOBSIZE(pIn1); - REGISTER_TRACE(pOp->p1, pIn1); + if( rc ) goto abort_due_to_error; break; } #endif /* SQLITE_OMIT_CAST */ @@ -86914,7 +85971,12 @@ case OP_Ge: { /* same as TK_GE, jump, in1, in3 */ if( (flags1 | flags3)&MEM_Str ){ if( (flags1 & (MEM_Int|MEM_IntReal|MEM_Real|MEM_Str))==MEM_Str ){ applyNumericAffinity(pIn1,0); - testcase( flags3!=pIn3->flags ); + assert( flags3==pIn3->flags ); + /* testcase( flags3!=pIn3->flags ); + ** this used to be possible with pIn1==pIn3, but not since + ** the column cache was removed. The following assignment + ** is essentially a no-op. But, it provides defense-in-depth + ** in case our analysis is incorrect, so it is left in. */ flags3 = pIn3->flags; } if( (flags3 & (MEM_Int|MEM_IntReal|MEM_Real|MEM_Str))==MEM_Str ){ @@ -86937,7 +85999,7 @@ case OP_Ge: { /* same as TK_GE, jump, in1, in3 */ sqlite3VdbeMemStringify(pIn1, encoding, 1); testcase( (flags1&MEM_Dyn) != (pIn1->flags&MEM_Dyn) ); flags1 = (pIn1->flags & ~MEM_TypeMask) | (flags1 & MEM_TypeMask); - if( pIn1==pIn3 ) flags3 = flags1 | MEM_Str; + assert( pIn1!=pIn3 ); } if( (flags3 & MEM_Str)==0 && (flags3&(MEM_Int|MEM_Real|MEM_IntReal))!=0 ){ testcase( pIn3->flags & MEM_Int ); @@ -86972,10 +86034,10 @@ case OP_Ge: { /* same as TK_GE, jump, in1, in3 */ } /* Undo any changes made by applyAffinity() to the input registers. */ - assert( (pIn3->flags & MEM_Dyn) == (flags3 & MEM_Dyn) ); - pIn3->flags = flags3; assert( (pIn1->flags & MEM_Dyn) == (flags1 & MEM_Dyn) ); pIn1->flags = flags1; + assert( (pIn3->flags & MEM_Dyn) == (flags3 & MEM_Dyn) ); + pIn3->flags = flags3; if( pOp->p5 & SQLITE_STOREP2 ){ pOut = &aMem[pOp->p2]; @@ -87011,31 +86073,16 @@ case OP_Ge: { /* same as TK_GE, jump, in1, in3 */ /* Opcode: ElseNotEq * P2 * * * ** -** This opcode must follow an OP_Lt or OP_Gt comparison operator. There -** can be zero or more OP_ReleaseReg opcodes intervening, but no other -** opcodes are allowed to occur between this instruction and the previous -** OP_Lt or OP_Gt. Furthermore, the prior OP_Lt or OP_Gt must have the -** SQLITE_STOREP2 bit set in the P5 field. -** -** If result of an OP_Eq comparison on the same two operands as the -** prior OP_Lt or OP_Gt would have been NULL or false (0), then then -** jump to P2. If the result of an OP_Eq comparison on the two previous -** operands would have been true (1), then fall through. +** This opcode must immediately follow an OP_Lt or OP_Gt comparison operator. +** If result of an OP_Eq comparison on the same two operands +** would have be NULL or false (0), then then jump to P2. +** If the result of an OP_Eq comparison on the two previous operands +** would have been true (1), then fall through. */ case OP_ElseNotEq: { /* same as TK_ESCAPE, jump */ - -#ifdef SQLITE_DEBUG - /* Verify the preconditions of this opcode - that it follows an OP_Lt or - ** OP_Gt with the SQLITE_STOREP2 flag set, with zero or more intervening - ** OP_ReleaseReg opcodes */ - int iAddr; - for(iAddr = (int)(pOp - aOp) - 1; ALWAYS(iAddr>=0); iAddr--){ - if( aOp[iAddr].opcode==OP_ReleaseReg ) continue; - assert( aOp[iAddr].opcode==OP_Lt || aOp[iAddr].opcode==OP_Gt ); - assert( aOp[iAddr].p5 & SQLITE_STOREP2 ); - break; - } -#endif /* SQLITE_DEBUG */ + assert( pOp>aOp ); + assert( pOp[-1].opcode==OP_Lt || pOp[-1].opcode==OP_Gt ); + assert( pOp[-1].p5 & SQLITE_STOREP2 ); VdbeBranchTaken(iCompare!=0, 2); if( iCompare!=0 ) goto jump_to_p2; break; @@ -87446,9 +86493,7 @@ case OP_Column: { u32 t; /* A type code from the record header */ Mem *pReg; /* PseudoTable input register */ - assert( pOp->p1>=0 && pOp->p1nCursor ); pC = p->apCsr[pOp->p1]; - assert( pC!=0 ); p2 = pOp->p2; /* If the cursor cache is stale (meaning it is not currently point at @@ -87460,6 +86505,7 @@ case OP_Column: { assert( pOp->p3>0 && pOp->p3<=(p->nMem+1 - p->nCursor) ); pDest = &aMem[pOp->p3]; memAboutToChange(p, pDest); + assert( pOp->p1>=0 && pOp->p1nCursor ); assert( pC!=0 ); assert( p2nField ); aOffset = pC->aOffset; @@ -87670,11 +86716,10 @@ case OP_Column: { ** ** Although sqlite3VdbeSerialGet() may read at most 8 bytes from the ** buffer passed to it, debugging function VdbeMemPrettyPrint() may - ** read more. Use the global constant sqlite3CtypeMap[] as the array, - ** as that array is 256 bytes long (plenty for VdbeMemPrettyPrint()) - ** and it begins with a bunch of zeros. + ** read up to 16. So 16 bytes of bogus content is supplied. */ - sqlite3VdbeSerialGet((u8*)sqlite3CtypeMap, t, pDest); + static u8 aZero[16]; /* This is the bogus content */ + sqlite3VdbeSerialGet(aZero, t, pDest); }else{ rc = sqlite3VdbeMemFromBtree(pC->uc.pCursor, aOffset[p2], len, pDest); if( rc!=SQLITE_OK ) goto abort_due_to_error; @@ -87717,7 +86762,7 @@ case OP_Affinity: { pIn1 = &aMem[pOp->p1]; while( 1 /*exit-by-break*/ ){ assert( pIn1 <= &p->aMem[(p->nMem+1 - p->nCursor)] ); - assert( zAffinity[0]==SQLITE_AFF_NONE || memIsValid(pIn1) ); + assert( memIsValid(pIn1) ); applyAffinity(pIn1, zAffinity[0], encoding); if( zAffinity[0]==SQLITE_AFF_REAL && (pIn1->flags & MEM_Int)!=0 ){ /* When applying REAL affinity, if the result is still an MEM_Int @@ -88042,11 +87087,11 @@ case OP_Count: { /* out2 */ pCrsr = p->apCsr[pOp->p1]->uc.pCursor; assert( pCrsr ); nEntry = 0; /* Not needed. Only used to silence a warning. */ - rc = sqlite3BtreeCount(db, pCrsr, &nEntry); + rc = sqlite3BtreeCount(pCrsr, &nEntry); if( rc ) goto abort_due_to_error; pOut = out2Prerelease(p, pOp); pOut->u.i = nEntry; - goto check_for_interrupt; + break; } #endif @@ -88163,12 +87208,8 @@ case OP_Savepoint: { p->rc = rc = SQLITE_BUSY; goto vdbe_return; } + db->isTransactionSavepoint = 0; rc = p->rc; - if( rc ){ - db->autoCommit = 0; - }else{ - db->isTransactionSavepoint = 0; - } }else{ int isSchemaChange; iSavepoint = db->nSavepoint - iSavepoint - 1; @@ -88196,7 +87237,6 @@ case OP_Savepoint: { db->mDbFlags |= DBFLAG_SchemaChange; } } - if( rc ) goto abort_due_to_error; /* Regardless of whether this is a RELEASE or ROLLBACK, destroy all ** savepoints nested inside of the savepoint being operated on. */ @@ -88279,6 +87319,7 @@ case OP_AutoCommit: { p->rc = rc = SQLITE_BUSY; goto vdbe_return; } + assert( db->nStatement==0 ); sqlite3CloseSavepoints(db); if( p->rc==SQLITE_OK ){ rc = SQLITE_DONE; @@ -88359,8 +87400,7 @@ case OP_Transaction: { goto abort_due_to_error; } - if( p->usesStmtJournal - && pOp->p2 + if( pOp->p2 && p->usesStmtJournal && (db->autoCommit==0 || db->nVdbeRead>1) ){ assert( sqlite3BtreeIsInTrans(pBt) ); @@ -88692,7 +87732,6 @@ case OP_OpenDup: { VdbeCursor *pCx; /* The new cursor */ pOrig = p->apCsr[pOp->p2]; - assert( pOrig ); assert( pOrig->pBtx!=0 ); /* Only ephemeral cursors can be duplicated */ pCx = allocateCursor(p, pOp->p1, pOrig->nField, -1, CURTYPE_BTREE); @@ -88756,13 +87795,15 @@ case OP_OpenEphemeral: { assert( pOp->p1>=0 ); assert( pOp->p2>=0 ); pCx = p->apCsr[pOp->p1]; - if( pCx && pCx->pBtx ){ + if( pCx ){ /* If the ephermeral table is already open, erase all existing content ** so that the table is empty again, rather than creating a new table. */ assert( pCx->isEphemeral ); pCx->seqCount = 0; pCx->cacheStatus = CACHE_STALE; - rc = sqlite3BtreeClearTable(pCx->pBtx, pCx->pgnoRoot, 0); + if( pCx->pBtx ){ + rc = sqlite3BtreeClearTable(pCx->pBtx, pCx->pgnoRoot, 0); + } }else{ pCx = allocateCursor(p, pOp->p1, pOp->p2, -1, CURTYPE_BTREE); if( pCx==0 ) goto no_mem; @@ -89194,7 +88235,7 @@ case OP_SeekGT: { /* jump, in3, group */ ** Synopsis: seekHit=P2 ** ** Set the seekHit flag on cursor P1 to the value in P2. -* The seekHit flag is used by the IfNoHope opcode. +** The seekHit flag is used by the IfNoHope opcode. ** ** P1 must be a valid b-tree cursor. P2 must be a boolean value, ** either 0 or 1. @@ -89209,20 +88250,6 @@ case OP_SeekHit: { break; } -/* Opcode: IfNotOpen P1 P2 * * * -** Synopsis: if( !csr[P1] ) goto P2 -** -** If cursor P1 is not open, jump to instruction P2. Otherwise, fall through. -*/ -case OP_IfNotOpen: { /* jump */ - assert( pOp->p1>=0 && pOp->p1nCursor ); - VdbeBranchTaken(p->apCsr[pOp->p1]==0, 2); - if( !p->apCsr[pOp->p1] ){ - goto jump_to_p2_and_check_for_interrupt; - } - break; -} - /* Opcode: Found P1 P2 P3 P4 * ** Synopsis: key=r[P3@P4] ** @@ -89711,7 +88738,6 @@ case OP_Insert: { pC = p->apCsr[pOp->p1]; assert( pC!=0 ); assert( pC->eCurType==CURTYPE_BTREE ); - assert( pC->deferredMoveto==0 ); assert( pC->uc.pCursor!=0 ); assert( (pOp->p5 & OPFLAG_ISNOOP) || pC->isTable ); assert( pOp->p4type==P4_TABLE || pOp->p4type>=P4_STATIC ); @@ -89829,11 +88855,7 @@ case OP_Delete: { sqlite3VdbeIncrWriteCounter(p, pC); #ifdef SQLITE_DEBUG - if( pOp->p4type==P4_TABLE - && HasRowid(pOp->p4.pTab) - && pOp->p5==0 - && sqlite3BtreeCursorIsValidNN(pC->uc.pCursor) - ){ + if( pOp->p4type==P4_TABLE && HasRowid(pOp->p4.pTab) && pOp->p5==0 ){ /* If p5 is zero, the seek operation that positioned the cursor prior to ** OP_Delete will have also set the pC->movetoTarget field to the rowid of ** the row that is being deleted */ @@ -90589,24 +89611,6 @@ case OP_IdxRowid: { /* out2 */ break; } -/* Opcode: FinishSeek P1 * * * * -** -** If cursor P1 was previously moved via OP_DeferredSeek, complete that -** seek operation now, without further delay. If the cursor seek has -** already occurred, this instruction is a no-op. -*/ -case OP_FinishSeek: { - VdbeCursor *pC; /* The P1 index cursor */ - - assert( pOp->p1>=0 && pOp->p1nCursor ); - pC = p->apCsr[pOp->p1]; - if( pC->deferredMoveto ){ - rc = sqlite3VdbeFinishMoveto(pC); - if( rc ) goto abort_due_to_error; - } - break; -} - /* Opcode: IdxGE P1 P2 P3 P4 P5 ** Synopsis: key=r[P3@P4] ** @@ -91043,7 +90047,7 @@ case OP_IntegrityCk: { pIn1 = &aMem[pOp->p1]; assert( pOp->p5nDb ); assert( DbMaskTest(p->btreeMask, pOp->p5) ); - z = sqlite3BtreeIntegrityCheck(db, db->aDb[pOp->p5].pBt, &aRoot[1], nRoot, + z = sqlite3BtreeIntegrityCheck(db->aDb[pOp->p5].pBt, &aRoot[1], nRoot, (int)pnErr->u.i+1, &nErr); sqlite3VdbeMemSetNull(pIn1); if( nErr==0 ){ @@ -91056,7 +90060,7 @@ case OP_IntegrityCk: { } UPDATE_MAX_BLOBSIZE(pIn1); sqlite3VdbeChangeEncoding(pIn1, encoding); - goto check_for_interrupt; + break; } #endif /* SQLITE_OMIT_INTEGRITY_CHECK */ @@ -91913,36 +90917,6 @@ case OP_Expire: { break; } -/* Opcode: CursorLock P1 * * * * -** -** Lock the btree to which cursor P1 is pointing so that the btree cannot be -** written by an other cursor. -*/ -case OP_CursorLock: { - VdbeCursor *pC; - assert( pOp->p1>=0 && pOp->p1nCursor ); - pC = p->apCsr[pOp->p1]; - assert( pC!=0 ); - assert( pC->eCurType==CURTYPE_BTREE ); - sqlite3BtreeCursorPin(pC->uc.pCursor); - break; -} - -/* Opcode: CursorUnlock P1 * * * * -** -** Unlock the btree to which cursor P1 is pointing so that it can be -** written by other cursors. -*/ -case OP_CursorUnlock: { - VdbeCursor *pC; - assert( pOp->p1>=0 && pOp->p1nCursor ); - pC = p->apCsr[pOp->p1]; - assert( pC!=0 ); - assert( pC->eCurType==CURTYPE_BTREE ); - sqlite3BtreeCursorUnpin(pC->uc.pCursor); - break; -} - #ifndef SQLITE_OMIT_SHARED_CACHE /* Opcode: TableLock P1 P2 P3 P4 * ** Synopsis: iDb=P1 root=P2 write=P3 @@ -92187,7 +91161,7 @@ case OP_VColumn: { assert( pModule->xColumn ); memset(&sContext, 0, sizeof(sContext)); sContext.pOut = pDest; - assert( pOp->p5==OPFLAG_NOCHNG || pOp->p5==0 ); + testcase( (pOp->p5 & OPFLAG_NOCHNG)==0 && pOp->p5!=0 ); if( pOp->p5 & OPFLAG_NOCHNG ){ sqlite3VdbeMemSetNull(pDest); pDest->flags = MEM_Null|MEM_Zero; @@ -92412,14 +91386,29 @@ case OP_MaxPgcnt: { /* out2 */ } #endif -/* Opcode: Function P1 P2 P3 P4 * +/* Opcode: Function0 P1 P2 P3 P4 P5 +** Synopsis: r[P3]=func(r[P2@P5]) +** +** Invoke a user function (P4 is a pointer to a FuncDef object that +** defines the function) with P5 arguments taken from register P2 and +** successors. The result of the function is stored in register P3. +** Register P3 must not be one of the function inputs. +** +** P1 is a 32-bit bitmask indicating whether or not each argument to the +** function was determined to be constant at compile time. If the first +** argument was constant then bit 0 of P1 is set. This is used to determine +** whether meta data associated with a user function argument using the +** sqlite3_set_auxdata() API may be safely retained until the next +** invocation of this opcode. +** +** See also: Function, AggStep, AggFinal +*/ +/* Opcode: Function P1 P2 P3 P4 P5 ** Synopsis: r[P3]=func(r[P2@P5]) ** ** Invoke a user function (P4 is a pointer to an sqlite3_context object that -** contains a pointer to the function to be run) with arguments taken -** from register P2 and successors. The number of arguments is in -** the sqlite3_context object that P4 points to. -** The result of the function is stored +** contains a pointer to the function to be run) with P5 arguments taken +** from register P2 and successors. The result of the function is stored ** in register P3. Register P3 must not be one of the function inputs. ** ** P1 is a 32-bit bitmask indicating whether or not each argument to the @@ -92429,35 +91418,40 @@ case OP_MaxPgcnt: { /* out2 */ ** sqlite3_set_auxdata() API may be safely retained until the next ** invocation of this opcode. ** -** See also: AggStep, AggFinal, PureFunc -*/ -/* Opcode: PureFunc P1 P2 P3 P4 * -** Synopsis: r[P3]=func(r[P2@P5]) -** -** Invoke a user function (P4 is a pointer to an sqlite3_context object that -** contains a pointer to the function to be run) with arguments taken -** from register P2 and successors. The number of arguments is in -** the sqlite3_context object that P4 points to. -** The result of the function is stored -** in register P3. Register P3 must not be one of the function inputs. -** -** P1 is a 32-bit bitmask indicating whether or not each argument to the -** function was determined to be constant at compile time. If the first -** argument was constant then bit 0 of P1 is set. This is used to determine -** whether meta data associated with a user function argument using the -** sqlite3_set_auxdata() API may be safely retained until the next -** invocation of this opcode. -** -** This opcode works exactly like OP_Function. The only difference is in -** its name. This opcode is used in places where the function must be -** purely non-deterministic. Some built-in date/time functions can be -** either determinitic of non-deterministic, depending on their arguments. -** When those function are used in a non-deterministic way, they will check -** to see if they were called using OP_PureFunc instead of OP_Function, and -** if they were, they throw an error. -** -** See also: AggStep, AggFinal, Function +** SQL functions are initially coded as OP_Function0 with P4 pointing +** to a FuncDef object. But on first evaluation, the P4 operand is +** automatically converted into an sqlite3_context object and the operation +** changed to this OP_Function opcode. In this way, the initialization of +** the sqlite3_context object occurs only once, rather than once for each +** evaluation of the function. +** +** See also: Function0, AggStep, AggFinal */ +case OP_PureFunc0: /* group */ +case OP_Function0: { /* group */ + int n; + sqlite3_context *pCtx; + + assert( pOp->p4type==P4_FUNCDEF ); + n = pOp->p5; + assert( pOp->p3>0 && pOp->p3<=(p->nMem+1 - p->nCursor) ); + assert( n==0 || (pOp->p2>0 && pOp->p2+n<=(p->nMem+1 - p->nCursor)+1) ); + assert( pOp->p3p2 || pOp->p3>=pOp->p2+n ); + pCtx = sqlite3DbMallocRawNN(db, sizeof(*pCtx) + (n-1)*sizeof(sqlite3_value*)); + if( pCtx==0 ) goto no_mem; + pCtx->pOut = 0; + pCtx->pFunc = pOp->p4.pFunc; + pCtx->iOp = (int)(pOp - aOp); + pCtx->pVdbe = p; + pCtx->isError = 0; + pCtx->argc = n; + pOp->p4type = P4_FUNCCTX; + pOp->p4.pCtx = pCtx; + assert( OP_PureFunc == OP_PureFunc0+2 ); + assert( OP_Function == OP_Function0+2 ); + pOp->opcode += 2; + /* Fall through into OP_Function */ +} case OP_PureFunc: /* group */ case OP_Function: { /* group */ int i; @@ -92472,11 +91466,9 @@ case OP_Function: { /* group */ ** reinitializes the relavant parts of the sqlite3_context object */ pOut = &aMem[pOp->p3]; if( pCtx->pOut != pOut ){ - pCtx->pVdbe = p; pCtx->pOut = pOut; for(i=pCtx->argc-1; i>=0; i--) pCtx->argv[i] = &aMem[pOp->p2+i]; } - assert( pCtx->pVdbe==p ); memAboutToChange(p, pOut); #ifdef SQLITE_DEBUG @@ -92648,55 +91640,6 @@ case OP_Abortable: { } #endif -#ifdef SQLITE_DEBUG -/* Opcode: ReleaseReg P1 P2 P3 * P5 -** Synopsis: release r[P1@P2] mask P3 -** -** Release registers from service. Any content that was in the -** the registers is unreliable after this opcode completes. -** -** The registers released will be the P2 registers starting at P1, -** except if bit ii of P3 set, then do not release register P1+ii. -** In other words, P3 is a mask of registers to preserve. -** -** Releasing a register clears the Mem.pScopyFrom pointer. That means -** that if the content of the released register was set using OP_SCopy, -** a change to the value of the source register for the OP_SCopy will no longer -** generate an assertion fault in sqlite3VdbeMemAboutToChange(). -** -** If P5 is set, then all released registers have their type set -** to MEM_Undefined so that any subsequent attempt to read the released -** register (before it is reinitialized) will generate an assertion fault. -** -** P5 ought to be set on every call to this opcode. -** However, there are places in the code generator will release registers -** before their are used, under the (valid) assumption that the registers -** will not be reallocated for some other purpose before they are used and -** hence are safe to release. -** -** This opcode is only available in testing and debugging builds. It is -** not generated for release builds. The purpose of this opcode is to help -** validate the generated bytecode. This opcode does not actually contribute -** to computing an answer. -*/ -case OP_ReleaseReg: { - Mem *pMem; - int i; - u32 constMask; - assert( pOp->p1>0 ); - assert( pOp->p1+pOp->p2<=(p->nMem+1 - p->nCursor)+1 ); - pMem = &aMem[pOp->p1]; - constMask = pOp->p3; - for(i=0; ip2; i++, pMem++){ - if( i>=32 || (constMask & MASKBIT32(i))==0 ){ - pMem->pScopyFrom = 0; - if( i<32 && pOp->p5 ) MemSetTypeFlag(pMem, MEM_Undefined); - } - } - break; -} -#endif - /* Opcode: Noop * * * * * ** ** Do nothing. This instruction is often useful as a jump @@ -92748,12 +91691,6 @@ default: { /* This is really OP_Noop, OP_Explain */ if( opProperty & OPFLG_OUT3 ){ registerTrace(pOrigOp->p3, &aMem[pOrigOp->p3]); } - if( opProperty==0xff ){ - /* Never happens. This code exists to avoid a harmless linkage - ** warning aboud sqlite3VdbeRegisterDump() being defined but not - ** used. */ - sqlite3VdbeRegisterDump(p); - } } #endif /* SQLITE_DEBUG */ #endif /* NDEBUG */ @@ -94740,16 +93677,20 @@ static SorterCompare vdbeSorterGetCompare(VdbeSorter *p){ */ static int vdbeSorterSort(SortSubtask *pTask, SorterList *pList){ int i; + SorterRecord **aSlot; SorterRecord *p; int rc; - SorterRecord *aSlot[64]; rc = vdbeSortAllocUnpacked(pTask); if( rc!=SQLITE_OK ) return rc; p = pList->pList; pTask->xCompare = vdbeSorterGetCompare(pTask->pSorter); - memset(aSlot, 0, sizeof(aSlot)); + + aSlot = (SorterRecord **)sqlite3MallocZero(64 * sizeof(SorterRecord *)); + if( !aSlot ){ + return SQLITE_NOMEM_BKPT; + } while( p ){ SorterRecord *pNext; @@ -94774,12 +93715,13 @@ static int vdbeSorterSort(SortSubtask *pTask, SorterList *pList){ } p = 0; - for(i=0; ipList = p; + sqlite3_free(aSlot); assert( pTask->pUnpacked->errCode==SQLITE_OK || pTask->pUnpacked->errCode==SQLITE_NOMEM ); @@ -96612,8 +95554,8 @@ static SQLITE_NOINLINE int walkExpr(Walker *pWalker, Expr *pExpr){ rc = pWalker->xExprCallback(pWalker, pExpr); if( rc ) return rc & WRC_Abort; if( !ExprHasProperty(pExpr,(EP_TokenOnly|EP_Leaf)) ){ - assert( pExpr->x.pList==0 || pExpr->pRight==0 ); if( pExpr->pLeft && walkExpr(pWalker, pExpr->pLeft) ) return WRC_Abort; + assert( pExpr->x.pList==0 || pExpr->pRight==0 ); if( pExpr->pRight ){ assert( !ExprHasProperty(pExpr, EP_WinFunc) ); pExpr = pExpr->pRight; @@ -96882,16 +95824,13 @@ static int nameInUsingClause(IdList *pUsing, const char *zCol){ ** and zCol. If any of zDb, zTab, and zCol are NULL then those fields will ** match anything. */ -SQLITE_PRIVATE int sqlite3MatchEName( - const struct ExprList_item *pItem, +SQLITE_PRIVATE int sqlite3MatchSpanName( + const char *zSpan, const char *zCol, const char *zTab, const char *zDb ){ int n; - const char *zSpan; - if( NEVER(pItem->eEName!=ENAME_TAB) ) return 0; - zSpan = pItem->zEName; for(n=0; ALWAYS(zSpan[n]) && zSpan[n]!='.'; n++){} if( zDb && (sqlite3StrNICmp(zSpan, zDb, n)!=0 || zDb[n]!=0) ){ return 0; @@ -97020,7 +95959,7 @@ static int lookupName( int hit = 0; pEList = pItem->pSelect->pEList; for(j=0; jnExpr; j++){ - if( sqlite3MatchEName(&pEList->a[j], zCol, zTab, zDb) ){ + if( sqlite3MatchSpanName(pEList->a[j].zSpan, zCol, zTab, zDb) ){ cnt++; cntTab = 2; pMatch = pItem; @@ -97167,7 +96106,7 @@ static int lookupName( if( cnt==0 && cntTab==1 && pMatch - && (pNC->ncFlags & (NC_IdxExpr|NC_GenCol))==0 + && (pNC->ncFlags & NC_IdxExpr)==0 && sqlite3IsRowid(zCol) && VisibleRowid(pMatch->pTab) ){ @@ -97201,10 +96140,8 @@ static int lookupName( pEList = pNC->uNC.pEList; assert( pEList!=0 ); for(j=0; jnExpr; j++){ - char *zAs = pEList->a[j].zEName; - if( pEList->a[j].eEName==ENAME_NAME - && sqlite3_stricmp(zAs, zCol)==0 - ){ + char *zAs = pEList->a[j].zName; + if( zAs!=0 && sqlite3StrICmp(zAs, zCol)==0 ){ Expr *pOrig; assert( pExpr->pLeft==0 && pExpr->pRight==0 ); assert( pExpr->x.pList==0 ); @@ -97214,9 +96151,7 @@ static int lookupName( sqlite3ErrorMsg(pParse, "misuse of aliased aggregate %s", zAs); return WRC_Abort; } - if( ExprHasProperty(pOrig, EP_Win) - && ((pNC->ncFlags&NC_AllowWin)==0 || pNC!=pTopNC ) - ){ + if( (pNC->ncFlags&NC_AllowWin)==0 && ExprHasProperty(pOrig, EP_Win) ){ sqlite3ErrorMsg(pParse, "misuse of aliased window function %s",zAs); return WRC_Abort; } @@ -97308,35 +96243,18 @@ static int lookupName( /* If a column from a table in pSrcList is referenced, then record ** this fact in the pSrcList.a[].colUsed bitmask. Column 0 causes - ** bit 0 to be set. Column 1 sets bit 1. And so forth. Bit 63 is - ** set if the 63rd or any subsequent column is used. - ** - ** The colUsed mask is an optimization used to help determine if an - ** index is a covering index. The correct answer is still obtained - ** if the mask contains extra set bits. However, it is important to - ** avoid setting bits beyond the maximum column number of the table. - ** (See ticket [b92e5e8ec2cdbaa1]). - ** - ** If a generated column is referenced, set bits for every column - ** of the table. + ** bit 0 to be set. Column 1 sets bit 1. And so forth. If the + ** column number is greater than the number of bits in the bitmask + ** then set the high-order bit of the bitmask. */ if( pExpr->iColumn>=0 && pMatch!=0 ){ int n = pExpr->iColumn; - Table *pExTab = pExpr->y.pTab; - assert( pExTab!=0 ); - assert( pMatch->iCursor==pExpr->iTable ); - if( (pExTab->tabFlags & TF_HasGenerated)!=0 - && (pExTab->aCol[n].colFlags & COLFLAG_GENERATED)!=0 - ){ - testcase( pExTab->nCol==BMS-1 ); - testcase( pExTab->nCol==BMS ); - pMatch->colUsed = pExTab->nCol>=BMS ? ALLBITS : MASKBIT(pExTab->nCol)-1; - }else{ - testcase( n==BMS-1 ); - testcase( n==BMS ); - if( n>=BMS ) n = BMS-1; - pMatch->colUsed |= ((Bitmask)1)<=BMS ){ + n = BMS-1; } + assert( pMatch->iCursor==pExpr->iTable ); + pMatch->colUsed |= ((Bitmask)1)<a[iSrc]; - Table *pTab = p->y.pTab = pItem->pTab; + p->y.pTab = pItem->pTab; p->iTable = pItem->iCursor; if( p->y.pTab->iPKey==iCol ){ p->iColumn = -1; }else{ p->iColumn = (ynVar)iCol; - if( (pTab->tabFlags & TF_HasGenerated)!=0 - && (pTab->aCol[iCol].colFlags & COLFLAG_GENERATED)!=0 - ){ - testcase( pTab->nCol==63 ); - testcase( pTab->nCol==64 ); - pItem->colUsed = pTab->nCol>=64 ? ALLBITS : MASKBIT(pTab->nCol)-1; - }else{ - testcase( iCol==BMS ); - testcase( iCol==BMS-1 ); - pItem->colUsed |= ((Bitmask)1)<<(iCol>=BMS ? BMS-1 : iCol); - } + testcase( iCol==BMS ); + testcase( iCol==BMS-1 ); + pItem->colUsed |= ((Bitmask)1)<<(iCol>=BMS ? BMS-1 : iCol); } } return p; @@ -97400,39 +96310,23 @@ SQLITE_PRIVATE Expr *sqlite3CreateColumnExpr(sqlite3 *db, SrcList *pSrc, int iSr /* ** Report an error that an expression is not valid for some set of ** pNC->ncFlags values determined by validMask. -** -** static void notValid( -** Parse *pParse, // Leave error message here -** NameContext *pNC, // The name context -** const char *zMsg, // Type of error -** int validMask, // Set of contexts for which prohibited -** Expr *pExpr // Invalidate this expression on error -** ){...} -** -** As an optimization, since the conditional is almost always false -** (because errors are rare), the conditional is moved outside of the -** function call using a macro. */ -static void notValidImpl( - Parse *pParse, /* Leave error message here */ - NameContext *pNC, /* The name context */ - const char *zMsg, /* Type of error */ - Expr *pExpr /* Invalidate this expression on error */ +static void notValid( + Parse *pParse, /* Leave error message here */ + NameContext *pNC, /* The name context */ + const char *zMsg, /* Type of error */ + int validMask /* Set of contexts for which prohibited */ ){ - const char *zIn = "partial index WHERE clauses"; - if( pNC->ncFlags & NC_IdxExpr ) zIn = "index expressions"; + assert( (validMask&~(NC_IsCheck|NC_PartIdx|NC_IdxExpr))==0 ); + if( (pNC->ncFlags & validMask)!=0 ){ + const char *zIn = "partial index WHERE clauses"; + if( pNC->ncFlags & NC_IdxExpr ) zIn = "index expressions"; #ifndef SQLITE_OMIT_CHECK - else if( pNC->ncFlags & NC_IsCheck ) zIn = "CHECK constraints"; + else if( pNC->ncFlags & NC_IsCheck ) zIn = "CHECK constraints"; #endif -#ifndef SQLITE_OMIT_GENERATED_COLUMNS - else if( pNC->ncFlags & NC_GenCol ) zIn = "generated columns"; -#endif - sqlite3ErrorMsg(pParse, "%s prohibited in %s", zMsg, zIn); - if( pExpr ) pExpr->op = TK_NULL; + sqlite3ErrorMsg(pParse, "%s prohibited in %s", zMsg, zIn); + } } -#define sqlite3ResolveNotValid(P,N,M,X,E) \ - assert( ((X)&~(NC_IsCheck|NC_PartIdx|NC_IdxExpr|NC_GenCol))==0 ); \ - if( ((N)->ncFlags & (X))!=0 ) notValidImpl(P,N,M,E); /* ** Expression p should encode a floating point value between 1.0 and 0.0. @@ -97521,10 +96415,7 @@ static int resolveExprStep(Walker *pWalker, Expr *pExpr){ zColumn = pExpr->u.zToken; }else{ Expr *pLeft = pExpr->pLeft; - testcase( pNC->ncFlags & NC_IdxExpr ); - testcase( pNC->ncFlags & NC_GenCol ); - sqlite3ResolveNotValid(pParse, pNC, "the \".\" operator", - NC_IdxExpr|NC_GenCol, 0); + notValid(pParse, pNC, "the \".\" operator", NC_IdxExpr); pRight = pExpr->pRight; if( pRight->op==TK_ID ){ zDb = 0; @@ -97613,39 +96504,33 @@ static int resolveExprStep(Walker *pWalker, Expr *pExpr){ if( pDef->funcFlags & (SQLITE_FUNC_CONSTANT|SQLITE_FUNC_SLOCHNG) ){ /* For the purposes of the EP_ConstFunc flag, date and time ** functions and other functions that change slowly are considered - ** constant because they are constant for the duration of one query. - ** This allows them to be factored out of inner loops. */ + ** constant because they are constant for the duration of one query */ ExprSetProperty(pExpr,EP_ConstFunc); } if( (pDef->funcFlags & SQLITE_FUNC_CONSTANT)==0 ){ - /* Clearly non-deterministic functions like random(), but also - ** date/time functions that use 'now', and other functions like + /* Date/time functions that use 'now', and other functions like ** sqlite_version() that might change over time cannot be used - ** in an index or generated column. Curiously, they can be used - ** in a CHECK constraint. SQLServer, MySQL, and PostgreSQL all - ** all this. */ - sqlite3ResolveNotValid(pParse, pNC, "non-deterministic functions", - NC_IdxExpr|NC_PartIdx|NC_GenCol, 0); - }else{ - assert( (NC_SelfRef & 0xff)==NC_SelfRef ); /* Must fit in 8 bits */ - pExpr->op2 = pNC->ncFlags & NC_SelfRef; - if( pNC->ncFlags & NC_FromDDL ) ExprSetProperty(pExpr, EP_FromDDL); + ** in an index. */ + notValid(pParse, pNC, "non-deterministic functions", + NC_IdxExpr|NC_PartIdx); } if( (pDef->funcFlags & SQLITE_FUNC_INTERNAL)!=0 && pParse->nested==0 - && (pParse->db->mDbFlags & DBFLAG_InternalFunc)==0 + && sqlite3Config.bInternalFunctions==0 ){ /* Internal-use-only functions are disallowed unless the - ** SQL is being compiled using sqlite3NestedParse() or - ** the SQLITE_TESTCTRL_INTERNAL_FUNCTIONS test-control has be - ** used to activate internal functionsn for testing purposes */ + ** SQL is being compiled using sqlite3NestedParse() */ no_such_func = 1; pDef = 0; }else - if( (pDef->funcFlags & (SQLITE_FUNC_DIRECT|SQLITE_FUNC_UNSAFE))!=0 + if( (pDef->funcFlags & SQLITE_FUNC_DIRECT)!=0 + && ExprHasProperty(pExpr, EP_Indirect) && !IN_RENAME_OBJECT ){ - sqlite3ExprFunctionUsable(pParse, pExpr, pDef); + /* Functions tagged with SQLITE_DIRECTONLY may not be used + ** inside of triggers and views */ + sqlite3ErrorMsg(pParse, "%s() prohibited in triggers and views", + pDef->zName); } } @@ -97726,7 +96611,7 @@ static int resolveExprStep(Walker *pWalker, Expr *pExpr){ Select *pSel = pNC->pWinSelect; assert( pWin==pExpr->y.pWin ); if( IN_RENAME_OBJECT==0 ){ - sqlite3WindowUpdate(pParse, pSel ? pSel->pWinDefn : 0, pWin, pDef); + sqlite3WindowUpdate(pParse, pSel->pWinDefn, pWin, pDef); } sqlite3WalkExprList(pWalker, pWin->pPartition); sqlite3WalkExprList(pWalker, pWin->pOrderBy); @@ -97771,12 +96656,7 @@ static int resolveExprStep(Walker *pWalker, Expr *pExpr){ testcase( pExpr->op==TK_IN ); if( ExprHasProperty(pExpr, EP_xIsSelect) ){ int nRef = pNC->nRef; - testcase( pNC->ncFlags & NC_IsCheck ); - testcase( pNC->ncFlags & NC_PartIdx ); - testcase( pNC->ncFlags & NC_IdxExpr ); - testcase( pNC->ncFlags & NC_GenCol ); - sqlite3ResolveNotValid(pParse, pNC, "subqueries", - NC_IsCheck|NC_PartIdx|NC_IdxExpr|NC_GenCol, pExpr); + notValid(pParse, pNC, "subqueries", NC_IsCheck|NC_PartIdx|NC_IdxExpr); sqlite3WalkSelect(pWalker, pExpr->x.pSelect); assert( pNC->nRef>=nRef ); if( nRef!=pNC->nRef ){ @@ -97787,12 +96667,7 @@ static int resolveExprStep(Walker *pWalker, Expr *pExpr){ break; } case TK_VARIABLE: { - testcase( pNC->ncFlags & NC_IsCheck ); - testcase( pNC->ncFlags & NC_PartIdx ); - testcase( pNC->ncFlags & NC_IdxExpr ); - testcase( pNC->ncFlags & NC_GenCol ); - sqlite3ResolveNotValid(pParse, pNC, "parameters", - NC_IsCheck|NC_PartIdx|NC_IdxExpr|NC_GenCol, pExpr); + notValid(pParse, pNC, "parameters", NC_IsCheck|NC_PartIdx|NC_IdxExpr); break; } case TK_IS: @@ -97874,9 +96749,8 @@ static int resolveAsName( if( pE->op==TK_ID ){ char *zCol = pE->u.zToken; for(i=0; inExpr; i++){ - if( pEList->a[i].eEName==ENAME_NAME - && sqlite3_stricmp(pEList->a[i].zEName, zCol)==0 - ){ + char *zAs = pEList->a[i].zName; + if( zAs!=0 && sqlite3StrICmp(zAs, zCol)==0 ){ return i+1; } } @@ -98602,13 +97476,10 @@ SQLITE_PRIVATE void sqlite3ResolveSelectNames( ** Resolve names in expressions that can only reference a single table ** or which cannot reference any tables at all. Examples: ** -** "type" flag -** ------------ -** (1) CHECK constraints NC_IsCheck -** (2) WHERE clauses on partial indices NC_PartIdx -** (3) Expressions in indexes on expressions NC_IdxExpr -** (4) Expression arguments to VACUUM INTO. 0 -** (5) GENERATED ALWAYS as expressions NC_GenCol +** (1) CHECK constraints +** (2) WHERE clauses on partial indices +** (3) Expressions in indexes on expressions +** (4) Expression arguments to VACUUM INTO. ** ** In all cases except (4), the Expr.iTable value for Expr.op==TK_COLUMN ** nodes of the expression is set to -1 and the Expr.iColumn value is @@ -98617,19 +97488,18 @@ SQLITE_PRIVATE void sqlite3ResolveSelectNames( ** Any errors cause an error message to be set in pParse. */ SQLITE_PRIVATE int sqlite3ResolveSelfReference( - Parse *pParse, /* Parsing context */ - Table *pTab, /* The table being referenced, or NULL */ - int type, /* NC_IsCheck, NC_PartIdx, NC_IdxExpr, NC_GenCol, or 0 */ - Expr *pExpr, /* Expression to resolve. May be NULL. */ - ExprList *pList /* Expression list to resolve. May be NULL. */ + Parse *pParse, /* Parsing context */ + Table *pTab, /* The table being referenced, or NULL */ + int type, /* NC_IsCheck or NC_PartIdx or NC_IdxExpr, or 0 */ + Expr *pExpr, /* Expression to resolve. May be NULL. */ + ExprList *pList /* Expression list to resolve. May be NULL. */ ){ SrcList sSrc; /* Fake SrcList for pParse->pNewTable */ NameContext sNC; /* Name context for pParse->pNewTable */ int rc; assert( type==0 || pTab!=0 ); - assert( type==NC_IsCheck || type==NC_PartIdx || type==NC_IdxExpr - || type==NC_GenCol || pTab==0 ); + assert( type==NC_IsCheck || type==NC_PartIdx || type==NC_IdxExpr || pTab==0 ); memset(&sNC, 0, sizeof(sNC)); memset(&sSrc, 0, sizeof(sSrc)); if( pTab ){ @@ -98637,11 +97507,6 @@ SQLITE_PRIVATE int sqlite3ResolveSelfReference( sSrc.a[0].zName = pTab->zName; sSrc.a[0].pTab = pTab; sSrc.a[0].iCursor = -1; - if( pTab->pSchema!=pParse->db->aDb[1].pSchema ){ - /* Cause EP_FromDDL to be set on TK_FUNCTION nodes of non-TEMP - ** schema elements */ - type |= NC_FromDDL; - } } sNC.pParse = pParse; sNC.pSrcList = &sSrc; @@ -98725,9 +97590,6 @@ SQLITE_PRIVATE char sqlite3ExprAffinity(Expr *pExpr){ pExpr->pLeft->x.pSelect->pEList->a[pExpr->iColumn].pExpr ); } - if( op==TK_VECTOR ){ - return sqlite3ExprAffinity(pExpr->x.pList->a[0].pExpr); - } return pExpr->affExpr; } @@ -98830,10 +97692,6 @@ SQLITE_PRIVATE CollSeq *sqlite3ExprCollSeq(Parse *pParse, Expr *pExpr){ p = p->pLeft; continue; } - if( op==TK_VECTOR ){ - p = p->x.pList->a[0].pExpr; - continue; - } if( op==TK_COLLATE ){ pColl = sqlite3GetCollSeq(pParse, ENC(db), 0, p->u.zToken); break; @@ -98845,12 +97703,12 @@ SQLITE_PRIVATE CollSeq *sqlite3ExprCollSeq(Parse *pParse, Expr *pExpr){ Expr *pNext = p->pRight; /* The Expr.x union is never used at the same time as Expr.pRight */ assert( p->x.pList==0 || p->pRight==0 ); - if( p->x.pList!=0 - && !db->mallocFailed - && ALWAYS(!ExprHasProperty(p, EP_xIsSelect)) - ){ + /* p->flags holds EP_Collate and p->pLeft->flags does not. And + ** p->x.pSelect cannot. So if p->x.pLeft exists, it must hold at + ** least one EP_Collate. Thus the following two ALWAYS. */ + if( p->x.pList!=0 && ALWAYS(!ExprHasProperty(p, EP_xIsSelect)) ){ int i; - for(i=0; ix.pList->nExpr; i++){ + for(i=0; ALWAYS(ix.pList->nExpr); i++){ if( ExprHasProperty(p->x.pList->a[i].pExpr, EP_Collate) ){ pNext = p->x.pList->a[i].pExpr; break; @@ -98998,22 +97856,6 @@ SQLITE_PRIVATE CollSeq *sqlite3BinaryCompareCollSeq( return pColl; } -/* Expresssion p is a comparison operator. Return a collation sequence -** appropriate for the comparison operator. -** -** This is normally just a wrapper around sqlite3BinaryCompareCollSeq(). -** However, if the OP_Commuted flag is set, then the order of the operands -** is reversed in the sqlite3BinaryCompareCollSeq() call so that the -** correct collating sequence is found. -*/ -SQLITE_PRIVATE CollSeq *sqlite3ExprCompareCollSeq(Parse *pParse, Expr *p){ - if( ExprHasProperty(p, EP_Commuted) ){ - return sqlite3BinaryCompareCollSeq(pParse, p->pRight, p->pLeft); - }else{ - return sqlite3BinaryCompareCollSeq(pParse, p->pLeft, p->pRight); - } -} - /* ** Generate code for a comparison operator. */ @@ -99024,19 +97866,13 @@ static int codeCompare( int opcode, /* The comparison opcode */ int in1, int in2, /* Register holding operands */ int dest, /* Jump here if true. */ - int jumpIfNull, /* If true, jump if either operand is NULL */ - int isCommuted /* The comparison has been commuted */ + int jumpIfNull /* If true, jump if either operand is NULL */ ){ int p5; int addr; CollSeq *p4; - if( pParse->nErr ) return 0; - if( isCommuted ){ - p4 = sqlite3BinaryCompareCollSeq(pParse, pRight, pLeft); - }else{ - p4 = sqlite3BinaryCompareCollSeq(pParse, pLeft, pRight); - } + p4 = sqlite3BinaryCompareCollSeq(pParse, pLeft, pRight); p5 = binaryCompareP5(pLeft, pRight, jumpIfNull); addr = sqlite3VdbeAddOp4(pParse->pVdbe, opcode, in2, dest, in1, (void*)p4, P4_COLLSEQ); @@ -99247,9 +98083,7 @@ static void codeVectorCompare( int regRight = 0; u8 opx = op; int addrDone = sqlite3VdbeMakeLabel(pParse); - int isCommuted = ExprHasProperty(pExpr,EP_Commuted); - if( pParse->nErr ) return; if( nLeft!=sqlite3ExprVectorSize(pRight) ){ sqlite3ErrorMsg(pParse, "row value misused"); return; @@ -99278,7 +98112,7 @@ static void codeVectorCompare( assert( i>=0 && ifuncFlags & (SQLITE_FUNC_DIRECT|SQLITE_FUNC_UNSAFE))!=0 ); - if( ExprHasProperty(pExpr, EP_FromDDL) ){ - if( (pDef->funcFlags & SQLITE_FUNC_DIRECT)!=0 - || (pParse->db->flags & SQLITE_TrustedSchema)==0 - ){ - /* Functions prohibited in triggers and views if: - ** (1) tagged with SQLITE_DIRECTONLY - ** (2) not tagged with SQLITE_INNOCUOUS (which means it - ** is tagged with SQLITE_FUNC_UNSAFE) and - ** SQLITE_DBCONFIG_TRUSTED_SCHEMA is off (meaning - ** that the schema is possibly tainted). - */ - sqlite3ErrorMsg(pParse, "unsafe use of %s()", pDef->zName); - } - } -} - /* ** Assign a variable number to an expression that encodes a wildcard ** in the original SQL statement. @@ -100129,11 +98927,12 @@ SQLITE_PRIVATE ExprList *sqlite3ExprListDup(sqlite3 *db, ExprList *p, int flags) pNewExpr->pLeft = pPriorSelectCol; } } - pItem->zEName = sqlite3DbStrDup(db, pOldItem->zEName); + pItem->zName = sqlite3DbStrDup(db, pOldItem->zName); + pItem->zSpan = sqlite3DbStrDup(db, pOldItem->zSpan); pItem->sortFlags = pOldItem->sortFlags; - pItem->eEName = pOldItem->eEName; pItem->done = 0; pItem->bNulls = pOldItem->bNulls; + pItem->bSpanIsTab = pOldItem->bSpanIsTab; pItem->bSorterRef = pOldItem->bSorterRef; pItem->u = pOldItem->u; } @@ -100300,9 +99099,9 @@ SQLITE_PRIVATE ExprList *sqlite3ExprListAppend( pList = pNew; } pItem = &pList->a[pList->nExpr++]; - assert( offsetof(struct ExprList_item,zEName)==sizeof(pItem->pExpr) ); + assert( offsetof(struct ExprList_item,zName)==sizeof(pItem->pExpr) ); assert( offsetof(struct ExprList_item,pExpr)==0 ); - memset(&pItem->zEName,0,sizeof(*pItem)-offsetof(struct ExprList_item,zEName)); + memset(&pItem->zName,0,sizeof(*pItem)-offsetof(struct ExprList_item,zName)); pItem->pExpr = pExpr; return pList; @@ -100359,7 +99158,7 @@ SQLITE_PRIVATE ExprList *sqlite3ExprListAppendVector( pList = sqlite3ExprListAppend(pParse, pList, pSubExpr); if( pList ){ assert( pList->nExpr==iFirst+i+1 ); - pList->a[pList->nExpr-1].zEName = pColumns->a[i].zName; + pList->a[pList->nExpr-1].zName = pColumns->a[i].zName; pColumns->a[i].zName = 0; } } @@ -100419,7 +99218,7 @@ SQLITE_PRIVATE void sqlite3ExprListSetSortOrder(ExprList *p, int iSortOrder, int } /* -** Set the ExprList.a[].zEName element of the most recently added item +** Set the ExprList.a[].zName element of the most recently added item ** on the expression list. ** ** pList might be NULL following an OOM error. But pName should never be @@ -100437,12 +99236,11 @@ SQLITE_PRIVATE void sqlite3ExprListSetName( struct ExprList_item *pItem; assert( pList->nExpr>0 ); pItem = &pList->a[pList->nExpr-1]; - assert( pItem->zEName==0 ); - assert( pItem->eEName==ENAME_NAME ); - pItem->zEName = sqlite3DbStrNDup(pParse->db, pName->z, pName->n); - if( dequote ) sqlite3Dequote(pItem->zEName); + assert( pItem->zName==0 ); + pItem->zName = sqlite3DbStrNDup(pParse->db, pName->z, pName->n); + if( dequote ) sqlite3Dequote(pItem->zName); if( IN_RENAME_OBJECT ){ - sqlite3RenameTokenMap(pParse, (void*)pItem->zEName, pName); + sqlite3RenameTokenMap(pParse, (void*)pItem->zName, pName); } } } @@ -100466,10 +99264,8 @@ SQLITE_PRIVATE void sqlite3ExprListSetSpan( if( pList ){ struct ExprList_item *pItem = &pList->a[pList->nExpr-1]; assert( pList->nExpr>0 ); - if( pItem->zEName==0 ){ - pItem->zEName = sqlite3DbSpanDup(db, zStart, zEnd); - pItem->eEName = ENAME_SPAN; - } + sqlite3DbFree(db, pItem->zSpan); + pItem->zSpan = sqlite3DbSpanDup(db, zStart, zEnd); } } @@ -100499,7 +99295,8 @@ static SQLITE_NOINLINE void exprListDeleteNN(sqlite3 *db, ExprList *pList){ assert( pList->nExpr>0 ); do{ sqlite3ExprDelete(db, pItem->pExpr); - sqlite3DbFree(db, pItem->zEName); + sqlite3DbFree(db, pItem->zName); + sqlite3DbFree(db, pItem->zSpan); pItem++; }while( --i>0 ); sqlite3DbFreeNN(db, pList); @@ -100537,34 +99334,19 @@ SQLITE_PRIVATE int sqlite3SelectWalkFail(Walker *pWalker, Select *NotUsed){ return WRC_Abort; } -/* -** Check the input string to see if it is "true" or "false" (in any case). -** -** If the string is.... Return -** "true" EP_IsTrue -** "false" EP_IsFalse -** anything else 0 -*/ -SQLITE_PRIVATE u32 sqlite3IsTrueOrFalse(const char *zIn){ - if( sqlite3StrICmp(zIn, "true")==0 ) return EP_IsTrue; - if( sqlite3StrICmp(zIn, "false")==0 ) return EP_IsFalse; - return 0; -} - - /* ** If the input expression is an ID with the name "true" or "false" ** then convert it into an TK_TRUEFALSE term. Return non-zero if ** the conversion happened, and zero if the expression is unaltered. */ SQLITE_PRIVATE int sqlite3ExprIdToTrueFalse(Expr *pExpr){ - u32 v; assert( pExpr->op==TK_ID || pExpr->op==TK_STRING ); if( !ExprHasProperty(pExpr, EP_Quoted) - && (v = sqlite3IsTrueOrFalse(pExpr->u.zToken))!=0 + && (sqlite3StrICmp(pExpr->u.zToken, "true")==0 + || sqlite3StrICmp(pExpr->u.zToken, "false")==0) ){ pExpr->op = TK_TRUEFALSE; - ExprSetProperty(pExpr, v); + ExprSetProperty(pExpr, pExpr->u.zToken[4]==0 ? EP_IsTrue : EP_IsFalse); return 1; } return 0; @@ -100626,11 +99408,10 @@ SQLITE_PRIVATE Expr *sqlite3ExprSimplifiedAndOr(Expr *pExpr){ ** In all cases, the callbacks set Walker.eCode=0 and abort if the expression ** is found to not be a constant. ** -** The sqlite3ExprIsConstantOrFunction() is used for evaluating DEFAULT -** expressions in a CREATE TABLE statement. The Walker.eCode value is 5 -** when parsing an existing schema out of the sqlite_master table and 4 -** when processing a new CREATE TABLE statement. A bound parameter raises -** an error for new statements, but is silently converted +** The sqlite3ExprIsConstantOrFunction() is used for evaluating expressions +** in a CREATE TABLE statement. The Walker.eCode value is 5 when parsing +** an existing schema and 4 when processing a new statement. A bound +** parameter raises an error for new statements, but is silently converted ** to NULL for existing schemas. This allows sqlite_master tables that ** contain a bound parameter because they were generated by older versions ** of SQLite to be parsed by newer versions of SQLite without raising a @@ -100651,10 +99432,7 @@ static int exprNodeIsConstant(Walker *pWalker, Expr *pExpr){ ** and either pWalker->eCode==4 or 5 or the function has the ** SQLITE_FUNC_CONST flag. */ case TK_FUNCTION: - if( (pWalker->eCode>=4 || ExprHasProperty(pExpr,EP_ConstFunc)) - && !ExprHasProperty(pExpr, EP_WinFunc) - ){ - if( pWalker->eCode==5 ) ExprSetProperty(pExpr, EP_FromDDL); + if( pWalker->eCode>=4 || ExprHasProperty(pExpr,EP_ConstFunc) ){ return WRC_Continue; }else{ pWalker->eCode = 0; @@ -100818,21 +99596,9 @@ SQLITE_PRIVATE int sqlite3ExprIsConstantOrGroupBy(Parse *pParse, Expr *p, ExprLi } /* -** Walk an expression tree for the DEFAULT field of a column definition -** in a CREATE TABLE statement. Return non-zero if the expression is -** acceptable for use as a DEFAULT. That is to say, return non-zero if -** the expression is constant or a function call with constant arguments. -** Return and 0 if there are any variables. -** -** isInit is true when parsing from sqlite_master. isInit is false when -** processing a new CREATE TABLE statement. When isInit is true, parameters -** (such as ? or $abc) in the expression are converted into NULL. When -** isInit is false, parameters raise an error. Parameters should not be -** allowed in a CREATE TABLE statement, but some legacy versions of SQLite -** allowed it, so we need to support it when reading sqlite_master for -** backwards compatibility. -** -** If isInit is true, set EP_FromDDL on every TK_FUNCTION node. +** Walk an expression tree. Return non-zero if the expression is constant +** or a function call with constant arguments. Return and 0 if there +** are any variables. ** ** For the purposes of this function, a double-quoted string (ex: "abc") ** is considered a variable but a single-quoted string (ex: 'abc') is @@ -100929,9 +99695,7 @@ SQLITE_PRIVATE int sqlite3ExprCanBeNull(const Expr *p){ case TK_COLUMN: return ExprHasProperty(p, EP_CanBeNull) || p->y.pTab==0 || /* Reference to column of index on expression */ - (p->iColumn>=0 - && ALWAYS(p->y.pTab->aCol!=0) /* Defense against OOM problems */ - && p->y.pTab->aCol[p->iColumn].notNull==0); + (p->iColumn>=0 && p->y.pTab->aCol[p->iColumn].notNull==0); default: return 1; } @@ -101408,10 +100172,8 @@ static char *exprINAffinity(Parse *pParse, Expr *pExpr){ ** "sub-select returns N columns - expected M" */ SQLITE_PRIVATE void sqlite3SubselectError(Parse *pParse, int nActual, int nExpect){ - if( pParse->nErr==0 ){ - const char *zFmt = "sub-select returns %d columns - expected %d"; - sqlite3ErrorMsg(pParse, zFmt, nActual, nExpect); - } + const char *zFmt = "sub-select returns %d columns - expected %d"; + sqlite3ErrorMsg(pParse, zFmt, nActual, nExpect); } #endif @@ -101912,25 +100674,19 @@ static void sqlite3ExprCodeIN( if( regCkNull && sqlite3ExprCanBeNull(pList->a[ii].pExpr) ){ sqlite3VdbeAddOp3(v, OP_BitAnd, regCkNull, r2, regCkNull); } - sqlite3ReleaseTempReg(pParse, regToFree); if( iinExpr-1 || destIfNull!=destIfFalse ){ - int op = rLhs!=r2 ? OP_Eq : OP_NotNull; - sqlite3VdbeAddOp4(v, op, rLhs, labelOk, r2, + sqlite3VdbeAddOp4(v, OP_Eq, rLhs, labelOk, r2, (void*)pColl, P4_COLLSEQ); - VdbeCoverageIf(v, iinExpr-1 && op==OP_Eq); - VdbeCoverageIf(v, ii==pList->nExpr-1 && op==OP_Eq); - VdbeCoverageIf(v, iinExpr-1 && op==OP_NotNull); - VdbeCoverageIf(v, ii==pList->nExpr-1 && op==OP_NotNull); + VdbeCoverageIf(v, iinExpr-1); + VdbeCoverageIf(v, ii==pList->nExpr-1); sqlite3VdbeChangeP5(v, zAff[0]); }else{ - int op = rLhs!=r2 ? OP_Ne : OP_IsNull; assert( destIfNull==destIfFalse ); - sqlite3VdbeAddOp4(v, op, rLhs, destIfFalse, r2, - (void*)pColl, P4_COLLSEQ); - VdbeCoverageIf(v, op==OP_Ne); - VdbeCoverageIf(v, op==OP_IsNull); + sqlite3VdbeAddOp4(v, OP_Ne, rLhs, destIfFalse, r2, + (void*)pColl, P4_COLLSEQ); VdbeCoverage(v); sqlite3VdbeChangeP5(v, zAff[0] | SQLITE_JUMPIFNULL); } + sqlite3ReleaseTempReg(pParse, regToFree); } if( regCkNull ){ sqlite3VdbeAddOp2(v, OP_IsNull, regCkNull, destIfNull); VdbeCoverage(v); @@ -101950,7 +100706,6 @@ static void sqlite3ExprCodeIN( }else{ destStep2 = destStep6 = sqlite3VdbeMakeLabel(pParse); } - if( pParse->nErr ) goto sqlite3ExprCodeIN_finished; for(i=0; ipLeft, i); if( sqlite3ExprCanBeNull(p) ){ @@ -102132,45 +100887,16 @@ SQLITE_PRIVATE void sqlite3ExprCodeLoadIndexColumn( } } -#ifndef SQLITE_OMIT_GENERATED_COLUMNS -/* -** Generate code that will compute the value of generated column pCol -** and store the result in register regOut -*/ -SQLITE_PRIVATE void sqlite3ExprCodeGeneratedColumn( - Parse *pParse, - Column *pCol, - int regOut -){ - int iAddr; - Vdbe *v = pParse->pVdbe; - assert( v!=0 ); - assert( pParse->iSelfTab!=0 ); - if( pParse->iSelfTab>0 ){ - iAddr = sqlite3VdbeAddOp3(v, OP_IfNullRow, pParse->iSelfTab-1, 0, regOut); - }else{ - iAddr = 0; - } - sqlite3ExprCode(pParse, pCol->pDflt, regOut); - if( pCol->affinity>=SQLITE_AFF_TEXT ){ - sqlite3VdbeAddOp4(v, OP_Affinity, regOut, 1, 0, &pCol->affinity, 1); - } - if( iAddr ) sqlite3VdbeJumpHere(v, iAddr); -} -#endif /* SQLITE_OMIT_GENERATED_COLUMNS */ - /* ** Generate code to extract the value of the iCol-th column of a table. */ SQLITE_PRIVATE void sqlite3ExprCodeGetColumnOfTable( - Vdbe *v, /* Parsing context */ + Vdbe *v, /* The VDBE under construction */ Table *pTab, /* The table containing the value */ int iTabCur, /* The table cursor. Or the PK cursor for WITHOUT ROWID */ int iCol, /* Index of the column to extract */ int regOut /* Extract the value into this register */ ){ - Column *pCol; - assert( v!=0 ); if( pTab==0 ){ sqlite3VdbeAddOp3(v, OP_Column, iTabCur, iCol, regOut); return; @@ -102178,36 +100904,14 @@ SQLITE_PRIVATE void sqlite3ExprCodeGetColumnOfTable( if( iCol<0 || iCol==pTab->iPKey ){ sqlite3VdbeAddOp2(v, OP_Rowid, iTabCur, regOut); }else{ - int op; - int x; - if( IsVirtual(pTab) ){ - op = OP_VColumn; - x = iCol; -#ifndef SQLITE_OMIT_GENERATED_COLUMNS - }else if( (pCol = &pTab->aCol[iCol])->colFlags & COLFLAG_VIRTUAL ){ - Parse *pParse = sqlite3VdbeParser(v); - if( pCol->colFlags & COLFLAG_BUSY ){ - sqlite3ErrorMsg(pParse, "generated column loop on \"%s\"", pCol->zName); - }else{ - int savedSelfTab = pParse->iSelfTab; - pCol->colFlags |= COLFLAG_BUSY; - pParse->iSelfTab = iTabCur+1; - sqlite3ExprCodeGeneratedColumn(pParse, pCol, regOut); - pParse->iSelfTab = savedSelfTab; - pCol->colFlags &= ~COLFLAG_BUSY; - } - return; -#endif - }else if( !HasRowid(pTab) ){ - testcase( iCol!=sqlite3TableColumnToStorage(pTab, iCol) ); - x = sqlite3TableColumnToIndex(sqlite3PrimaryKeyIndex(pTab), iCol); - op = OP_Column; - }else{ - x = sqlite3TableColumnToStorage(pTab,iCol); - testcase( x!=iCol ); - op = OP_Column; + int op = IsVirtual(pTab) ? OP_VColumn : OP_Column; + int x = iCol; + if( !HasRowid(pTab) && !IsVirtual(pTab) ){ + x = sqlite3ColumnOfIndex(sqlite3PrimaryKeyIndex(pTab), iCol); } sqlite3VdbeAddOp3(v, op, iTabCur, x, regOut); + } + if( iCol>=0 ){ sqlite3ColumnDefault(v, pTab, iCol, regOut); } } @@ -102227,11 +100931,11 @@ SQLITE_PRIVATE int sqlite3ExprCodeGetColumn( int iReg, /* Store results here */ u8 p5 /* P5 value for OP_Column + FLAGS */ ){ - assert( pParse->pVdbe!=0 ); - sqlite3ExprCodeGetColumnOfTable(pParse->pVdbe, pTab, iTable, iColumn, iReg); + Vdbe *v = pParse->pVdbe; + assert( v!=0 ); + sqlite3ExprCodeGetColumnOfTable(v, pTab, iTable, iColumn, iReg); if( p5 ){ - VdbeOp *pOp = sqlite3VdbeGetOp(pParse->pVdbe,-1); - if( pOp->opcode==OP_Column ) pOp->p5 = p5; + sqlite3VdbeChangeP5(v, p5); } return iReg; } @@ -102241,6 +100945,7 @@ SQLITE_PRIVATE int sqlite3ExprCodeGetColumn( ** over to iTo..iTo+nReg-1. */ SQLITE_PRIVATE void sqlite3ExprCodeMove(Parse *pParse, int iFrom, int iTo, int nReg){ + assert( iFrom>=iTo+nReg || iFrom+nReg<=iTo ); sqlite3VdbeAddOp3(pParse->pVdbe, OP_Move, iFrom, iTo, nReg); } @@ -102292,109 +100997,6 @@ static int exprCodeVector(Parse *pParse, Expr *p, int *piFreeable){ return iResult; } -/* -** Generate code to implement special SQL functions that are implemented -** in-line rather than by using the usual callbacks. -*/ -static int exprCodeInlineFunction( - Parse *pParse, /* Parsing context */ - ExprList *pFarg, /* List of function arguments */ - int iFuncId, /* Function ID. One of the INTFUNC_... values */ - int target /* Store function result in this register */ -){ - int nFarg; - Vdbe *v = pParse->pVdbe; - assert( v!=0 ); - assert( pFarg!=0 ); - nFarg = pFarg->nExpr; - assert( nFarg>0 ); /* All in-line functions have at least one argument */ - switch( iFuncId ){ - case INLINEFUNC_coalesce: { - /* Attempt a direct implementation of the built-in COALESCE() and - ** IFNULL() functions. This avoids unnecessary evaluation of - ** arguments past the first non-NULL argument. - */ - int endCoalesce = sqlite3VdbeMakeLabel(pParse); - int i; - assert( nFarg>=2 ); - sqlite3ExprCode(pParse, pFarg->a[0].pExpr, target); - for(i=1; ia[i].pExpr, target); - } - if( sqlite3VdbeGetOp(v, -1)->opcode==OP_Copy ){ - sqlite3VdbeChangeP5(v, 1); /* Tag trailing OP_Copy as not mergable */ - } - sqlite3VdbeResolveLabel(v, endCoalesce); - break; - } - - default: { - /* The UNLIKELY() function is a no-op. The result is the value - ** of the first argument. - */ - assert( nFarg==1 || nFarg==2 ); - target = sqlite3ExprCodeTarget(pParse, pFarg->a[0].pExpr, target); - break; - } - - /*********************************************************************** - ** Test-only SQL functions that are only usable if enabled - ** via SQLITE_TESTCTRL_INTERNAL_FUNCTIONS - */ - case INLINEFUNC_expr_compare: { - /* Compare two expressions using sqlite3ExprCompare() */ - assert( nFarg==2 ); - sqlite3VdbeAddOp2(v, OP_Integer, - sqlite3ExprCompare(0,pFarg->a[0].pExpr, pFarg->a[1].pExpr,-1), - target); - break; - } - - case INLINEFUNC_expr_implies_expr: { - /* Compare two expressions using sqlite3ExprImpliesExpr() */ - assert( nFarg==2 ); - sqlite3VdbeAddOp2(v, OP_Integer, - sqlite3ExprImpliesExpr(pParse,pFarg->a[0].pExpr, pFarg->a[1].pExpr,-1), - target); - break; - } - - case INLINEFUNC_implies_nonnull_row: { - /* REsult of sqlite3ExprImpliesNonNullRow() */ - Expr *pA1; - assert( nFarg==2 ); - pA1 = pFarg->a[1].pExpr; - if( pA1->op==TK_COLUMN ){ - sqlite3VdbeAddOp2(v, OP_Integer, - sqlite3ExprImpliesNonNullRow(pFarg->a[0].pExpr,pA1->iTable), - target); - }else{ - sqlite3VdbeAddOp2(v, OP_Null, 0, target); - } - break; - } - -#ifdef SQLITE_DEBUG - case INLINEFUNC_affinity: { - /* The AFFINITY() function evaluates to a string that describes - ** the type affinity of the argument. This is used for testing of - ** the SQLite type logic. - */ - const char *azAff[] = { "blob", "text", "numeric", "integer", "real" }; - char aff; - assert( nFarg==1 ); - aff = sqlite3ExprAffinity(pFarg->a[0].pExpr); - sqlite3VdbeLoadString(v, target, - (aff<=SQLITE_AFF_NONE) ? "none" : azAff[aff-SQLITE_AFF_BLOB]); - break; - } -#endif - } - return target; -} - /* ** Generate code into the current Vdbe to evaluate the given @@ -102445,7 +101047,6 @@ SQLITE_PRIVATE int sqlite3ExprCodeTarget(Parse *pParse, Expr *pExpr, int target) } case TK_COLUMN: { int iTab = pExpr->iTable; - int iReg; if( ExprHasProperty(pExpr, EP_FixedCol) ){ /* This COLUMN expression is really a constant due to WHERE clause ** constraints, and that constant is coded by the pExpr->pLeft @@ -102453,13 +101054,8 @@ SQLITE_PRIVATE int sqlite3ExprCodeTarget(Parse *pParse, Expr *pExpr, int target) ** datatype by applying the Affinity of the table column to the ** constant. */ - int aff; - iReg = sqlite3ExprCodeTarget(pParse, pExpr->pLeft,target); - if( pExpr->y.pTab ){ - aff = sqlite3TableColumnAffinity(pExpr->y.pTab, pExpr->iColumn); - }else{ - aff = pExpr->affExpr; - } + int iReg = sqlite3ExprCodeTarget(pParse, pExpr->pLeft,target); + int aff = sqlite3TableColumnAffinity(pExpr->y.pTab, pExpr->iColumn); if( aff>SQLITE_AFF_BLOB ){ static const char zAff[] = "B\000C\000D\000E"; assert( SQLITE_AFF_BLOB=='A' ); @@ -102475,46 +101071,19 @@ SQLITE_PRIVATE int sqlite3ExprCodeTarget(Parse *pParse, Expr *pExpr, int target) } if( iTab<0 ){ if( pParse->iSelfTab<0 ){ - /* Other columns in the same row for CHECK constraints or - ** generated columns or for inserting into partial index. - ** The row is unpacked into registers beginning at - ** 0-(pParse->iSelfTab). The rowid (if any) is in a register - ** immediately prior to the first column. - */ - Column *pCol; - Table *pTab = pExpr->y.pTab; - int iSrc; - int iCol = pExpr->iColumn; - assert( pTab!=0 ); - assert( iCol>=XN_ROWID ); - assert( iColnCol ); - if( iCol<0 ){ - return -1-pParse->iSelfTab; - } - pCol = pTab->aCol + iCol; - testcase( iCol!=sqlite3TableColumnToStorage(pTab,iCol) ); - iSrc = sqlite3TableColumnToStorage(pTab, iCol) - pParse->iSelfTab; -#ifndef SQLITE_OMIT_GENERATED_COLUMNS - if( pCol->colFlags & COLFLAG_GENERATED ){ - if( pCol->colFlags & COLFLAG_BUSY ){ - sqlite3ErrorMsg(pParse, "generated column loop on \"%s\"", - pCol->zName); - return 0; - } - pCol->colFlags |= COLFLAG_BUSY; - if( pCol->colFlags & COLFLAG_NOTAVAIL ){ - sqlite3ExprCodeGeneratedColumn(pParse, pCol, iSrc); - } - pCol->colFlags &= ~(COLFLAG_BUSY|COLFLAG_NOTAVAIL); - return iSrc; - }else -#endif /* SQLITE_OMIT_GENERATED_COLUMNS */ - if( pCol->affinity==SQLITE_AFF_REAL ){ - sqlite3VdbeAddOp2(v, OP_SCopy, iSrc, target); + /* Generating CHECK constraints or inserting into partial index */ + assert( pExpr->y.pTab!=0 ); + assert( pExpr->iColumn>=XN_ROWID ); + assert( pExpr->iColumny.pTab->nCol ); + if( pExpr->iColumn>=0 + && pExpr->y.pTab->aCol[pExpr->iColumn].affinity==SQLITE_AFF_REAL + ){ + sqlite3VdbeAddOp2(v, OP_SCopy, pExpr->iColumn - pParse->iSelfTab, + target); sqlite3VdbeAddOp1(v, OP_RealAffinity, target); return target; }else{ - return iSrc; + return pExpr->iColumn - pParse->iSelfTab; } }else{ /* Coding an expression that is part of an index where column names @@ -102522,13 +101091,9 @@ SQLITE_PRIVATE int sqlite3ExprCodeTarget(Parse *pParse, Expr *pExpr, int target) iTab = pParse->iSelfTab - 1; } } - iReg = sqlite3ExprCodeGetColumn(pParse, pExpr->y.pTab, + return sqlite3ExprCodeGetColumn(pParse, pExpr->y.pTab, pExpr->iColumn, iTab, target, pExpr->op2); - if( pExpr->y.pTab==0 && pExpr->affExpr==SQLITE_AFF_REAL ){ - sqlite3VdbeAddOp1(v, OP_RealAffinity, iReg); - } - return iReg; } case TK_INTEGER: { codeInteger(pParse, pExpr, 0, target); @@ -102550,12 +101115,7 @@ SQLITE_PRIVATE int sqlite3ExprCodeTarget(Parse *pParse, Expr *pExpr, int target) sqlite3VdbeLoadString(v, target, pExpr->u.zToken); return target; } - default: { - /* Make NULL the default case so that if a bug causes an illegal - ** Expr node to be passed into this function, it will be handled - ** sanely and not crash. But keep the assert() to bring the problem - ** to the attention of the developers. */ - assert( op==TK_NULL ); + case TK_NULL: { sqlite3VdbeAddOp2(v, OP_Null, 0, target); return target; } @@ -102582,7 +101142,7 @@ SQLITE_PRIVATE int sqlite3ExprCodeTarget(Parse *pParse, Expr *pExpr, int target) sqlite3VdbeAddOp2(v, OP_Variable, pExpr->iColumn, target); if( pExpr->u.zToken[1]!=0 ){ const char *z = sqlite3VListNumToName(pParse->pVList, pExpr->iColumn); - assert( pExpr->u.zToken[0]=='?' || (z && !strcmp(pExpr->u.zToken, z)) ); + assert( pExpr->u.zToken[0]=='?' || strcmp(pExpr->u.zToken, z)==0 ); pParse->pVList[0] = 0; /* Indicate VList may no longer be enlarged */ sqlite3VdbeAppendP4(v, (char*)z, P4_STATIC); } @@ -102622,8 +101182,7 @@ SQLITE_PRIVATE int sqlite3ExprCodeTarget(Parse *pParse, Expr *pExpr, int target) r1 = sqlite3ExprCodeTemp(pParse, pLeft, ®Free1); r2 = sqlite3ExprCodeTemp(pParse, pExpr->pRight, ®Free2); codeCompare(pParse, pLeft, pExpr->pRight, op, - r1, r2, inReg, SQLITE_STOREP2 | p5, - ExprHasProperty(pExpr,EP_Commuted)); + r1, r2, inReg, SQLITE_STOREP2 | p5); assert(TK_LT==OP_Lt); testcase(op==OP_Lt); VdbeCoverageIf(v,op==OP_Lt); assert(TK_LE==OP_Le); testcase(op==OP_Le); VdbeCoverageIf(v,op==OP_Le); assert(TK_GT==OP_Gt); testcase(op==OP_Gt); VdbeCoverageIf(v,op==OP_Gt); @@ -102775,15 +101334,48 @@ SQLITE_PRIVATE int sqlite3ExprCodeTarget(Parse *pParse, Expr *pExpr, int target) sqlite3ErrorMsg(pParse, "unknown function: %s()", zId); break; } - if( pDef->funcFlags & SQLITE_FUNC_INLINE ){ - assert( (pDef->funcFlags & SQLITE_FUNC_UNSAFE)==0 ); - assert( (pDef->funcFlags & SQLITE_FUNC_DIRECT)==0 ); - return exprCodeInlineFunction(pParse, pFarg, - SQLITE_PTR_TO_INT(pDef->pUserData), target); - }else if( pDef->funcFlags & (SQLITE_FUNC_DIRECT|SQLITE_FUNC_UNSAFE) ){ - sqlite3ExprFunctionUsable(pParse, pExpr, pDef); + + /* Attempt a direct implementation of the built-in COALESCE() and + ** IFNULL() functions. This avoids unnecessary evaluation of + ** arguments past the first non-NULL argument. + */ + if( pDef->funcFlags & SQLITE_FUNC_COALESCE ){ + int endCoalesce = sqlite3VdbeMakeLabel(pParse); + assert( nFarg>=2 ); + sqlite3ExprCode(pParse, pFarg->a[0].pExpr, target); + for(i=1; ia[i].pExpr, target); + } + sqlite3VdbeResolveLabel(v, endCoalesce); + break; } + /* The UNLIKELY() function is a no-op. The result is the value + ** of the first argument. + */ + if( pDef->funcFlags & SQLITE_FUNC_UNLIKELY ){ + assert( nFarg>=1 ); + return sqlite3ExprCodeTarget(pParse, pFarg->a[0].pExpr, target); + } + +#ifdef SQLITE_DEBUG + /* The AFFINITY() function evaluates to a string that describes + ** the type affinity of the argument. This is used for testing of + ** the SQLite type logic. + */ + if( pDef->funcFlags & SQLITE_FUNC_AFFINITY ){ + const char *azAff[] = { "blob", "text", "numeric", "integer", "real" }; + char aff; + assert( nFarg==1 ); + aff = sqlite3ExprAffinity(pFarg->a[0].pExpr); + sqlite3VdbeLoadString(v, target, + (aff<=SQLITE_AFF_NONE) ? "none" : azAff[aff-SQLITE_AFF_BLOB]); + return target; + } +#endif + for(i=0; ia[i].pExpr) ){ testcase( i==31 ); @@ -102859,15 +101451,12 @@ SQLITE_PRIVATE int sqlite3ExprCodeTarget(Parse *pParse, Expr *pExpr, int target) }else #endif { - sqlite3VdbeAddFunctionCall(pParse, constMask, r1, target, nFarg, - pDef, pExpr->op2); + sqlite3VdbeAddOp4(v, pParse->iSelfTab ? OP_PureFunc0 : OP_Function0, + constMask, r1, target, (char*)pDef, P4_FUNCDEF); + sqlite3VdbeChangeP5(v, (u8)nFarg); } - if( nFarg ){ - if( constMask==0 ){ - sqlite3ReleaseTempRange(pParse, r1, nFarg); - }else{ - sqlite3VdbeReleaseRegisters(pParse, r1, nFarg, constMask, 1); - } + if( nFarg && constMask==0 ){ + sqlite3ReleaseTempRange(pParse, r1, nFarg); } return target; } @@ -102961,19 +101550,17 @@ SQLITE_PRIVATE int sqlite3ExprCodeTarget(Parse *pParse, Expr *pExpr, int target) ** p1==2 -> old.b p1==5 -> new.b */ Table *pTab = pExpr->y.pTab; - int iCol = pExpr->iColumn; - int p1 = pExpr->iTable * (pTab->nCol+1) + 1 - + sqlite3TableColumnToStorage(pTab, iCol); + int p1 = pExpr->iTable * (pTab->nCol+1) + 1 + pExpr->iColumn; assert( pExpr->iTable==0 || pExpr->iTable==1 ); - assert( iCol>=-1 && iColnCol ); - assert( pTab->iPKey<0 || iCol!=pTab->iPKey ); + assert( pExpr->iColumn>=-1 && pExpr->iColumnnCol ); + assert( pTab->iPKey<0 || pExpr->iColumn!=pTab->iPKey ); assert( p1>=0 && p1<(pTab->nCol*2+2) ); sqlite3VdbeAddOp2(v, OP_Param, p1, target); VdbeComment((v, "r[%d]=%s.%s", target, (pExpr->iTable ? "new" : "old"), - (pExpr->iColumn<0 ? "rowid" : pExpr->y.pTab->aCol[iCol].zName) + (pExpr->iColumn<0 ? "rowid" : pExpr->y.pTab->aCol[pExpr->iColumn].zName) )); #ifndef SQLITE_OMIT_FLOATING_POINT @@ -102982,7 +101569,9 @@ SQLITE_PRIVATE int sqlite3ExprCodeTarget(Parse *pParse, Expr *pExpr, int target) ** ** EVIDENCE-OF: R-60985-57662 SQLite will convert the value back to ** floating point when extracting it from the record. */ - if( iCol>=0 && pTab->aCol[iCol].affinity==SQLITE_AFF_REAL ){ + if( pExpr->iColumn>=0 + && pTab->aCol[pExpr->iColumn].affinity==SQLITE_AFF_REAL + ){ sqlite3VdbeAddOp1(v, OP_RealAffinity, target); } #endif @@ -103037,7 +101626,7 @@ SQLITE_PRIVATE int sqlite3ExprCodeTarget(Parse *pParse, Expr *pExpr, int target) ** or if there is no matching Ei, the ELSE term Y, or if there is ** no ELSE term, NULL. */ - case TK_CASE: { + default: assert( op==TK_CASE ); { int endLabel; /* GOTO label for end of CASE stmt */ int nextCase; /* GOTO label for next WHEN clause */ int nExpr; /* 2x number of WHEN terms */ @@ -103215,16 +101804,14 @@ SQLITE_PRIVATE void sqlite3ExprCode(Parse *pParse, Expr *pExpr, int target){ int inReg; assert( target>0 && target<=pParse->nMem ); - inReg = sqlite3ExprCodeTarget(pParse, pExpr, target); - assert( pParse->pVdbe!=0 || pParse->db->mallocFailed ); - if( inReg!=target && pParse->pVdbe ){ - u8 op; - if( ExprHasProperty(pExpr,EP_Subquery) ){ - op = OP_Copy; - }else{ - op = OP_SCopy; + if( pExpr && pExpr->op==TK_REGISTER ){ + sqlite3VdbeAddOp2(pParse->pVdbe, OP_Copy, pExpr->iTable, target); + }else{ + inReg = sqlite3ExprCodeTarget(pParse, pExpr, target); + assert( pParse->pVdbe!=0 || pParse->db->mallocFailed ); + if( inReg!=target && pParse->pVdbe ){ + sqlite3VdbeAddOp2(pParse->pVdbe, OP_SCopy, inReg, target); } - sqlite3VdbeAddOp2(pParse->pVdbe, op, inReg, target); } } @@ -103254,6 +101841,30 @@ SQLITE_PRIVATE void sqlite3ExprCodeFactorable(Parse *pParse, Expr *pExpr, int ta } } +/* +** Generate code that evaluates the given expression and puts the result +** in register target. +** +** Also make a copy of the expression results into another "cache" register +** and modify the expression so that the next time it is evaluated, +** the result is a copy of the cache register. +** +** This routine is used for expressions that are used multiple +** times. They are evaluated once and the results of the expression +** are reused. +*/ +SQLITE_PRIVATE void sqlite3ExprCodeAndCache(Parse *pParse, Expr *pExpr, int target){ + Vdbe *v = pParse->pVdbe; + int iMem; + + assert( target>0 ); + assert( pExpr->op!=TK_REGISTER ); + sqlite3ExprCode(pParse, pExpr, target); + iMem = ++pParse->nMem; + sqlite3VdbeAddOp2(v, OP_Copy, target, iMem); + exprToRegister(pExpr, iMem); +} + /* ** Generate code that pushes the value of every element of the given ** expression list into a sequence of registers beginning at target. @@ -103317,7 +101928,6 @@ SQLITE_PRIVATE int sqlite3ExprCodeExprList( && (pOp=sqlite3VdbeGetOp(v, -1))->opcode==OP_Copy && pOp->p1+pOp->p3+1==inReg && pOp->p2+pOp->p3+1==target+i - && pOp->p5==0 /* The do-not-merge flag must be clear */ ){ pOp->p3++; }else{ @@ -103492,7 +102102,7 @@ SQLITE_PRIVATE void sqlite3ExprIfTrue(Parse *pParse, Expr *pExpr, int dest, int r1 = sqlite3ExprCodeTemp(pParse, pExpr->pLeft, ®Free1); r2 = sqlite3ExprCodeTemp(pParse, pExpr->pRight, ®Free2); codeCompare(pParse, pExpr->pLeft, pExpr->pRight, op, - r1, r2, dest, jumpIfNull, ExprHasProperty(pExpr,EP_Commuted)); + r1, r2, dest, jumpIfNull); assert(TK_LT==OP_Lt); testcase(op==OP_Lt); VdbeCoverageIf(v,op==OP_Lt); assert(TK_LE==OP_Le); testcase(op==OP_Le); VdbeCoverageIf(v,op==OP_Le); assert(TK_GT==OP_Gt); testcase(op==OP_Gt); VdbeCoverageIf(v,op==OP_Gt); @@ -103667,7 +102277,7 @@ SQLITE_PRIVATE void sqlite3ExprIfFalse(Parse *pParse, Expr *pExpr, int dest, int r1 = sqlite3ExprCodeTemp(pParse, pExpr->pLeft, ®Free1); r2 = sqlite3ExprCodeTemp(pParse, pExpr->pRight, ®Free2); codeCompare(pParse, pExpr->pLeft, pExpr->pRight, op, - r1, r2, dest, jumpIfNull,ExprHasProperty(pExpr,EP_Commuted)); + r1, r2, dest, jumpIfNull); assert(TK_LT==OP_Lt); testcase(op==OP_Lt); VdbeCoverageIf(v,op==OP_Lt); assert(TK_LE==OP_Le); testcase(op==OP_Le); VdbeCoverageIf(v,op==OP_Le); assert(TK_GT==OP_Gt); testcase(op==OP_Gt); VdbeCoverageIf(v,op==OP_Gt); @@ -103853,8 +102463,7 @@ SQLITE_PRIVATE int sqlite3ExprCompare(Parse *pParse, Expr *pA, Expr *pB, int iTa return 2; } } - if( (pA->flags & (EP_Distinct|EP_Commuted)) - != (pB->flags & (EP_Distinct|EP_Commuted)) ) return 2; + if( (pA->flags & EP_Distinct)!=(pB->flags & EP_Distinct) ) return 2; if( (combinedFlags & EP_TokenOnly)==0 ){ if( combinedFlags & EP_xIsSelect ) return 2; if( (combinedFlags & EP_FixedCol)==0 @@ -103866,33 +102475,18 @@ SQLITE_PRIVATE int sqlite3ExprCompare(Parse *pParse, Expr *pA, Expr *pB, int iTa && (combinedFlags & EP_Reduced)==0 ){ if( pA->iColumn!=pB->iColumn ) return 2; - if( pA->op2!=pB->op2 ){ - if( pA->op==TK_TRUTH ) return 2; - if( pA->op==TK_FUNCTION && iTab<0 ){ - /* Ex: CREATE TABLE t1(a CHECK( aop!=TK_IN && pA->iTable!=pB->iTable && pA->iTable!=iTab ){ - return 2; - } + if( pA->op2!=pB->op2 ) return 2; + if( pA->op!=TK_IN + && pA->iTable!=pB->iTable + && (pA->iTable!=iTab || NEVER(pB->iTable>=0)) ) return 2; } } return 0; } /* -** Compare two ExprList objects. Return 0 if they are identical, 1 -** if they are certainly different, or 2 if it is not possible to -** determine if they are identical or not. +** Compare two ExprList objects. Return 0 if they are identical and +** non-zero if they differ in any way. ** ** If any subelement of pB has Expr.iTable==(-1) then it is allowed ** to compare equal to an equivalent element in pA with Expr.iTable==iTab. @@ -103911,11 +102505,10 @@ SQLITE_PRIVATE int sqlite3ExprListCompare(ExprList *pA, ExprList *pB, int iTab){ if( pA==0 || pB==0 ) return 1; if( pA->nExpr!=pB->nExpr ) return 1; for(i=0; inExpr; i++){ - int res; Expr *pExprA = pA->a[i].pExpr; Expr *pExprB = pB->a[i].pExpr; if( pA->a[i].sortFlags!=pB->a[i].sortFlags ) return 1; - if( (res = sqlite3ExprCompare(0, pExprA, pExprB, iTab)) ) return res; + if( sqlite3ExprCompare(0, pExprA, pExprB, iTab) ) return 1; } return 0; } @@ -104052,7 +102645,7 @@ SQLITE_PRIVATE int sqlite3ExprImpliesExpr(Parse *pParse, Expr *pE1, Expr *pE2, i } /* -** This is the Expr node callback for sqlite3ExprImpliesNonNullRow(). +** This is the Expr node callback for sqlite3ExprImpliesNotNullRow(). ** If the expression node requires that the table at pWalker->iCur ** have one or more non-NULL column, then set pWalker->eCode to 1 and abort. ** @@ -104070,7 +102663,6 @@ static int impliesNotNullRow(Walker *pWalker, Expr *pExpr){ case TK_NOTNULL: case TK_IS: case TK_OR: - case TK_VECTOR: case TK_CASE: case TK_IN: case TK_FUNCTION: @@ -104080,7 +102672,6 @@ static int impliesNotNullRow(Walker *pWalker, Expr *pExpr){ testcase( pExpr->op==TK_NOTNULL ); testcase( pExpr->op==TK_IS ); testcase( pExpr->op==TK_OR ); - testcase( pExpr->op==TK_VECTOR ); testcase( pExpr->op==TK_CASE ); testcase( pExpr->op==TK_IN ); testcase( pExpr->op==TK_FUNCTION ); @@ -104094,20 +102685,15 @@ static int impliesNotNullRow(Walker *pWalker, Expr *pExpr){ return WRC_Prune; case TK_AND: - if( pWalker->eCode==0 ){ - sqlite3WalkExpr(pWalker, pExpr->pLeft); - if( pWalker->eCode ){ - pWalker->eCode = 0; - sqlite3WalkExpr(pWalker, pExpr->pRight); - } + if( sqlite3ExprImpliesNonNullRow(pExpr->pLeft, pWalker->u.iCur) + && sqlite3ExprImpliesNonNullRow(pExpr->pRight, pWalker->u.iCur) + ){ + pWalker->eCode = 1; } return WRC_Prune; case TK_BETWEEN: - if( sqlite3WalkExpr(pWalker, pExpr->pLeft)==WRC_Abort ){ - assert( pWalker->eCode ); - return WRC_Abort; - } + sqlite3WalkExpr(pWalker, pExpr->pLeft); return WRC_Prune; /* Virtual tables are allowed to use constraints like x=NULL. So @@ -104161,13 +102747,14 @@ static int impliesNotNullRow(Walker *pWalker, Expr *pExpr){ SQLITE_PRIVATE int sqlite3ExprImpliesNonNullRow(Expr *p, int iTab){ Walker w; p = sqlite3ExprSkipCollateAndLikely(p); - if( p==0 ) return 0; - if( p->op==TK_NOTNULL ){ - p = p->pLeft; - }else{ - while( p->op==TK_AND ){ + while( p ){ + if( p->op==TK_NOTNULL ){ + p = p->pLeft; + }else if( p->op==TK_AND ){ if( sqlite3ExprImpliesNonNullRow(p->pLeft, iTab) ) return 1; p = p->pRight; + }else{ + break; } } w.xExprCallback = impliesNotNullRow; @@ -104199,7 +102786,7 @@ struct IdxCover { static int exprIdxCover(Walker *pWalker, Expr *pExpr){ if( pExpr->op==TK_COLUMN && pExpr->iTable==pWalker->u.pIdxCover->iCur - && sqlite3TableColumnToIndex(pWalker->u.pIdxCover->pIdx, pExpr->iColumn)<0 + && sqlite3ColumnOfIndex(pWalker->u.pIdxCover->pIdx, pExpr->iColumn)<0 ){ pWalker->eCode = 1; return WRC_Abort; @@ -104250,13 +102837,12 @@ struct SrcCount { ** Count the number of references to columns. */ static int exprSrcCount(Walker *pWalker, Expr *pExpr){ - /* There was once a NEVER() on the second term on the grounds that - ** sqlite3FunctionUsesThisSrc() was always called before - ** sqlite3ExprAnalyzeAggregates() and so the TK_COLUMNs have not yet - ** been converted into TK_AGG_COLUMN. But this is no longer true due - ** to window functions - sqlite3WindowRewrite() may now indirectly call - ** FunctionUsesThisSrc() when creating a new sub-select. */ - if( pExpr->op==TK_COLUMN || pExpr->op==TK_AGG_COLUMN ){ + /* The NEVER() on the second term is because sqlite3FunctionUsesThisSrc() + ** is always called before sqlite3ExprAnalyzeAggregates() and so the + ** TK_COLUMNs have not yet been converted into TK_AGG_COLUMN. If + ** sqlite3FunctionUsesThisSrc() is used differently in the future, the + ** NEVER() will need to be removed. */ + if( pExpr->op==TK_COLUMN || NEVER(pExpr->op==TK_AGG_COLUMN) ){ int i; struct SrcCount *p = pWalker->u.pSrcCount; SrcList *pSrc = p->pSrc; @@ -104294,11 +102880,6 @@ SQLITE_PRIVATE int sqlite3FunctionUsesThisSrc(Expr *pExpr, SrcList *pSrcList){ cnt.nThis = 0; cnt.nOther = 0; sqlite3WalkExprList(&w, pExpr->x.pList); -#ifndef SQLITE_OMIT_WINDOWFUNC - if( ExprHasProperty(pExpr, EP_WinFunc) ){ - sqlite3WalkExpr(&w, pExpr->y.pWin->pFilter); - } -#endif return cnt.nThis>0 || cnt.nOther==0; } @@ -104527,11 +103108,8 @@ SQLITE_PRIVATE int sqlite3GetTempReg(Parse *pParse){ ** purpose. */ SQLITE_PRIVATE void sqlite3ReleaseTempReg(Parse *pParse, int iReg){ - if( iReg ){ - sqlite3VdbeReleaseRegisters(pParse, iReg, 1, 0, 0); - if( pParse->nTempRegaTempReg) ){ - pParse->aTempReg[pParse->nTempReg++] = iReg; - } + if( iReg && pParse->nTempRegaTempReg) ){ + pParse->aTempReg[pParse->nTempReg++] = iReg; } } @@ -104557,7 +103135,6 @@ SQLITE_PRIVATE void sqlite3ReleaseTempRange(Parse *pParse, int iReg, int nReg){ sqlite3ReleaseTempReg(pParse, iReg); return; } - sqlite3VdbeReleaseRegisters(pParse, iReg, nReg, 0, 0); if( nReg>pParse->nRangeReg ){ pParse->nRangeReg = nReg; pParse->iRangeReg = iReg; @@ -104635,8 +103212,9 @@ SQLITE_PRIVATE int sqlite3NoTempsInRange(Parse *pParse, int iFirst, int iLast){ static int isAlterableTable(Parse *pParse, Table *pTab){ if( 0==sqlite3StrNICmp(pTab->zName, "sqlite_", 7) #ifndef SQLITE_OMIT_VIRTUALTABLE - || ( (pTab->tabFlags & TF_Shadow)!=0 - && sqlite3ReadOnlyShadowTables(pParse->db) + || ( (pTab->tabFlags & TF_Shadow) + && (pParse->db->flags & SQLITE_Defensive) + && pParse->db->nVdbeExec==0 ) #endif ){ @@ -104901,6 +103479,14 @@ SQLITE_PRIVATE void sqlite3AlterFinishAddColumn(Parse *pParse, Token *pColDef){ } #endif + /* If the default value for the new column was specified with a + ** literal NULL, then set pDflt to 0. This simplifies checking + ** for an SQL NULL default below. + */ + assert( pDflt==0 || pDflt->op==TK_SPAN ); + if( pDflt && pDflt->pLeft->op==TK_NULL ){ + pDflt = 0; + } /* Check that the new column is not specified as PRIMARY KEY or UNIQUE. ** If there is a NOT NULL constraint, then the default value for the @@ -104914,49 +103500,35 @@ SQLITE_PRIVATE void sqlite3AlterFinishAddColumn(Parse *pParse, Token *pColDef){ sqlite3ErrorMsg(pParse, "Cannot add a UNIQUE column"); return; } - if( (pCol->colFlags & COLFLAG_GENERATED)==0 ){ - /* If the default value for the new column was specified with a - ** literal NULL, then set pDflt to 0. This simplifies checking - ** for an SQL NULL default below. - */ - assert( pDflt==0 || pDflt->op==TK_SPAN ); - if( pDflt && pDflt->pLeft->op==TK_NULL ){ - pDflt = 0; - } - if( (db->flags&SQLITE_ForeignKeys) && pNew->pFKey && pDflt ){ - sqlite3ErrorMsg(pParse, - "Cannot add a REFERENCES column with non-NULL default value"); - return; - } - if( pCol->notNull && !pDflt ){ - sqlite3ErrorMsg(pParse, - "Cannot add a NOT NULL column with default value NULL"); - return; - } - - /* Ensure the default expression is something that sqlite3ValueFromExpr() - ** can handle (i.e. not CURRENT_TIME etc.) - */ - if( pDflt ){ - sqlite3_value *pVal = 0; - int rc; - rc = sqlite3ValueFromExpr(db, pDflt, SQLITE_UTF8, SQLITE_AFF_BLOB, &pVal); - assert( rc==SQLITE_OK || rc==SQLITE_NOMEM ); - if( rc!=SQLITE_OK ){ - assert( db->mallocFailed == 1 ); - return; - } - if( !pVal ){ - sqlite3ErrorMsg(pParse,"Cannot add a column with non-constant default"); - return; - } - sqlite3ValueFree(pVal); - } - }else if( pCol->colFlags & COLFLAG_STORED ){ - sqlite3ErrorMsg(pParse, "cannot add a STORED column"); + if( (db->flags&SQLITE_ForeignKeys) && pNew->pFKey && pDflt ){ + sqlite3ErrorMsg(pParse, + "Cannot add a REFERENCES column with non-NULL default value"); + return; + } + if( pCol->notNull && !pDflt ){ + sqlite3ErrorMsg(pParse, + "Cannot add a NOT NULL column with default value NULL"); return; } + /* Ensure the default expression is something that sqlite3ValueFromExpr() + ** can handle (i.e. not CURRENT_TIME etc.) + */ + if( pDflt ){ + sqlite3_value *pVal = 0; + int rc; + rc = sqlite3ValueFromExpr(db, pDflt, SQLITE_UTF8, SQLITE_AFF_BLOB, &pVal); + assert( rc==SQLITE_OK || rc==SQLITE_NOMEM ); + if( rc!=SQLITE_OK ){ + assert( db->mallocFailed == 1 ); + return; + } + if( !pVal ){ + sqlite3ErrorMsg(pParse, "Cannot add a column with non-constant default"); + return; + } + sqlite3ValueFree(pVal); + } /* Modify the CREATE TABLE statement. */ zCol = sqlite3DbStrNDup(db, (char*)pColDef->z, pColDef->n); @@ -105301,14 +103873,12 @@ SQLITE_PRIVATE void *sqlite3RenameTokenMap(Parse *pParse, void *pPtr, Token *pTo RenameToken *pNew; assert( pPtr || pParse->db->mallocFailed ); renameTokenCheckAll(pParse, pPtr); - if( pParse->eParseMode!=PARSE_MODE_UNMAP ){ - pNew = sqlite3DbMallocZero(pParse->db, sizeof(RenameToken)); - if( pNew ){ - pNew->p = pPtr; - pNew->t = *pToken; - pNew->pNext = pParse->pRename; - pParse->pRename = pNew; - } + pNew = sqlite3DbMallocZero(pParse->db, sizeof(RenameToken)); + if( pNew ){ + pNew->p = pPtr; + pNew->t = *pToken; + pNew->pNext = pParse->pRename; + pParse->pRename = pNew; } return pPtr; @@ -105339,39 +103909,17 @@ static int renameUnmapExprCb(Walker *pWalker, Expr *pExpr){ return WRC_Continue; } -/* -** Iterate through the Select objects that are part of WITH clauses attached -** to select statement pSelect. -*/ -static void renameWalkWith(Walker *pWalker, Select *pSelect){ - With *pWith = pSelect->pWith; - if( pWith ){ - int i; - for(i=0; inCte; i++){ - Select *p = pWith->a[i].pSelect; - NameContext sNC; - memset(&sNC, 0, sizeof(sNC)); - sNC.pParse = pWalker->pParse; - sqlite3SelectPrep(sNC.pParse, p, &sNC); - sqlite3WalkSelect(pWalker, p); - sqlite3RenameExprlistUnmap(pWalker->pParse, pWith->a[i].pCols); - } - } -} - /* ** Walker callback used by sqlite3RenameExprUnmap(). */ static int renameUnmapSelectCb(Walker *pWalker, Select *p){ Parse *pParse = pWalker->pParse; int i; - if( pParse->nErr ) return WRC_Abort; - if( NEVER(p->selFlags & SF_View) ) return WRC_Prune; if( ALWAYS(p->pEList) ){ ExprList *pList = p->pEList; for(i=0; inExpr; i++){ - if( pList->a[i].zEName && pList->a[i].eEName==ENAME_NAME ){ - sqlite3RenameTokenRemap(pParse, 0, (void*)pList->a[i].zEName); + if( pList->a[i].zName ){ + sqlite3RenameTokenRemap(pParse, 0, (void*)pList->a[i].zName); } } } @@ -105379,11 +103927,8 @@ static int renameUnmapSelectCb(Walker *pWalker, Select *p){ SrcList *pSrc = p->pSrc; for(i=0; inSrc; i++){ sqlite3RenameTokenRemap(pParse, 0, (void*)pSrc->a[i].zName); - if( sqlite3WalkExpr(pWalker, pSrc->a[i].pOn) ) return WRC_Abort; } } - - renameWalkWith(pWalker, p); return WRC_Continue; } @@ -105391,15 +103936,12 @@ static int renameUnmapSelectCb(Walker *pWalker, Select *p){ ** Remove all nodes that are part of expression pExpr from the rename list. */ SQLITE_PRIVATE void sqlite3RenameExprUnmap(Parse *pParse, Expr *pExpr){ - u8 eMode = pParse->eParseMode; Walker sWalker; memset(&sWalker, 0, sizeof(Walker)); sWalker.pParse = pParse; sWalker.xExprCallback = renameUnmapExprCb; sWalker.xSelectCallback = renameUnmapSelectCb; - pParse->eParseMode = PARSE_MODE_UNMAP; sqlite3WalkExpr(&sWalker, pExpr); - pParse->eParseMode = eMode; } /* @@ -105415,9 +103957,7 @@ SQLITE_PRIVATE void sqlite3RenameExprlistUnmap(Parse *pParse, ExprList *pEList){ sWalker.xExprCallback = renameUnmapExprCb; sqlite3WalkExprList(&sWalker, pEList); for(i=0; inExpr; i++){ - if( ALWAYS(pEList->a[i].eEName==ENAME_NAME) ){ - sqlite3RenameTokenRemap(pParse, 0, (void*)pEList->a[i].zEName); - } + sqlite3RenameTokenRemap(pParse, 0, (void*)pEList->a[i].zName); } } } @@ -105455,13 +103995,30 @@ static void renameTokenFind(Parse *pParse, struct RenameCtx *pCtx, void *pPtr){ } } +/* +** Iterate through the Select objects that are part of WITH clauses attached +** to select statement pSelect. +*/ +static void renameWalkWith(Walker *pWalker, Select *pSelect){ + if( pSelect->pWith ){ + int i; + for(i=0; ipWith->nCte; i++){ + Select *p = pSelect->pWith->a[i].pSelect; + NameContext sNC; + memset(&sNC, 0, sizeof(sNC)); + sNC.pParse = pWalker->pParse; + sqlite3SelectPrep(sNC.pParse, p, &sNC); + sqlite3WalkSelect(pWalker, p); + } + } +} + /* ** This is a Walker select callback. It does nothing. It is only required ** because without a dummy callback, sqlite3WalkExpr() and similar do not ** descend into sub-select statements. */ static int renameColumnSelectCb(Walker *pWalker, Select *p){ - if( p->selFlags & SF_View ) return WRC_Prune; renameWalkWith(pWalker, p); return WRC_Continue; } @@ -105555,11 +104112,8 @@ static void renameColumnElistNames( if( pEList ){ int i; for(i=0; inExpr; i++){ - char *zName = pEList->a[i].zEName; - if( ALWAYS(pEList->a[i].eEName==ENAME_NAME) - && ALWAYS(zName!=0) - && 0==sqlite3_stricmp(zName, zOld) - ){ + char *zName = pEList->a[i].zName; + if( 0==sqlite3_stricmp(zName, zOld) ){ renameTokenFind(pParse, pCtx, (void*)zName); } } @@ -105595,6 +104149,7 @@ static void renameColumnIdlistNames( static int renameParseSql( Parse *p, /* Memory to use for Parse object */ const char *zDb, /* Name of schema SQL belongs to */ + int bTable, /* 1 -> RENAME TABLE, 0 -> RENAME COLUMN */ sqlite3 *db, /* Database handle */ const char *zSql, /* SQL to parse */ int bTemp /* True if SQL is from temp schema */ @@ -105608,7 +104163,7 @@ static int renameParseSql( ** occurs and the parse does not result in a new table, index or ** trigger object, the database must be corrupt. */ memset(p, 0, sizeof(Parse)); - p->eParseMode = PARSE_MODE_RENAME; + p->eParseMode = (bTable ? PARSE_MODE_RENAME_TABLE : PARSE_MODE_RENAME_COLUMN); p->db = db; p->nQueryLoop = 1; rc = sqlite3RunParser(p, zSql, &zErr); @@ -105915,7 +104470,7 @@ static void renameColumnFunc( #ifndef SQLITE_OMIT_AUTHORIZATION db->xAuth = 0; #endif - rc = renameParseSql(&sParse, zDb, db, zSql, bTemp); + rc = renameParseSql(&sParse, zDb, 0, db, zSql, bTemp); /* Find tokens that need to be replaced. */ memset(&sWalker, 0, sizeof(Walker)); @@ -105929,9 +104484,8 @@ static void renameColumnFunc( if( sParse.pNewTable ){ Select *pSelect = sParse.pNewTable->pSelect; if( pSelect ){ - pSelect->selFlags &= ~SF_View; sParse.rc = SQLITE_OK; - sqlite3SelectPrep(&sParse, pSelect, 0); + sqlite3SelectPrep(&sParse, sParse.pNewTable->pSelect, 0); rc = (db->mallocFailed ? SQLITE_NOMEM : sParse.rc); if( rc==SQLITE_OK ){ sqlite3WalkSelect(&sWalker, pSelect); @@ -105958,11 +104512,6 @@ static void renameColumnFunc( sqlite3WalkExprList(&sWalker, pIdx->aColExpr); } } -#ifndef SQLITE_OMIT_GENERATED_COLUMNS - for(i=0; inCol; i++){ - sqlite3WalkExpr(&sWalker, sParse.pNewTable->aCol[i].pDflt); - } -#endif for(pFKey=sParse.pNewTable->pFKey; pFKey; pFKey=pFKey->pNextFrom){ for(i=0; inCol; i++){ @@ -106048,7 +104597,6 @@ static int renameTableSelectCb(Walker *pWalker, Select *pSelect){ int i; RenameCtx *p = pWalker->u.pRename; SrcList *pSrc = pSelect->pSrc; - if( pSelect->selFlags & SF_View ) return WRC_Prune; if( pSrc==0 ){ assert( pWalker->pParse->db->mallocFailed ); return WRC_Abort; @@ -106119,7 +104667,7 @@ static void renameTableFunc( sWalker.xSelectCallback = renameTableSelectCb; sWalker.u.pRename = &sCtx; - rc = renameParseSql(&sParse, zDb, db, zInput, bTemp); + rc = renameParseSql(&sParse, zDb, 1, db, zInput, bTemp); if( rc==SQLITE_OK ){ int isLegacy = (db->flags & SQLITE_LegacyAlter); @@ -106128,19 +104676,13 @@ static void renameTableFunc( if( pTab->pSelect ){ if( isLegacy==0 ){ - Select *pSelect = pTab->pSelect; NameContext sNC; memset(&sNC, 0, sizeof(sNC)); sNC.pParse = &sParse; - assert( pSelect->selFlags & SF_View ); - pSelect->selFlags &= ~SF_View; sqlite3SelectPrep(&sParse, pTab->pSelect, &sNC); - if( sParse.nErr ){ - rc = sParse.rc; - }else{ - sqlite3WalkSelect(&sWalker, pTab->pSelect); - } + if( sParse.nErr ) rc = sParse.rc; + sqlite3WalkSelect(&sWalker, pTab->pSelect); } }else{ /* Modify any FK definitions to point to the new table. */ @@ -106261,7 +104803,7 @@ static void renameTableTest( if( zDb && zInput ){ int rc; Parse sParse; - rc = renameParseSql(&sParse, zDb, db, zInput, bTemp); + rc = renameParseSql(&sParse, zDb, 1, db, zInput, bTemp); if( rc==SQLITE_OK ){ if( isLegacy==0 && sParse.pNewTable && sParse.pNewTable->pSelect ){ NameContext sNC; @@ -107227,17 +105769,18 @@ static const FuncDef statGetFuncdef = { {0} }; -static void callStatGet(Parse *pParse, int regStat4, int iParam, int regOut){ +static void callStatGet(Vdbe *v, int regStat4, int iParam, int regOut){ + assert( regOut!=regStat4 && regOut!=regStat4+1 ); #ifdef SQLITE_ENABLE_STAT4 - sqlite3VdbeAddOp2(pParse->pVdbe, OP_Integer, iParam, regStat4+1); + sqlite3VdbeAddOp2(v, OP_Integer, iParam, regStat4+1); #elif SQLITE_DEBUG assert( iParam==STAT_GET_STAT1 ); #else UNUSED_PARAMETER( iParam ); #endif - assert( regOut!=regStat4 && regOut!=regStat4+1 ); - sqlite3VdbeAddFunctionCall(pParse, 0, regStat4, regOut, 1+IsStat4, - &statGetFuncdef, 0); + sqlite3VdbeAddOp4(v, OP_Function0, 0, regStat4, regOut, + (char*)&statGetFuncdef, P4_FUNCDEF); + sqlite3VdbeChangeP5(v, 1 + IsStat4); } /* @@ -107405,8 +105948,9 @@ static void analyzeOneTable( #endif sqlite3VdbeAddOp2(v, OP_Integer, nCol, regStat4+1); sqlite3VdbeAddOp2(v, OP_Integer, pIdx->nKeyCol, regStat4+2); - sqlite3VdbeAddFunctionCall(pParse, 0, regStat4+1, regStat4, 2+IsStat4, - &statInitFuncdef, 0); + sqlite3VdbeAddOp4(v, OP_Function0, 0, regStat4+1, regStat4, + (char*)&statInitFuncdef, P4_FUNCDEF); + sqlite3VdbeChangeP5(v, 2+IsStat4); /* Implementation of the following: ** @@ -107491,7 +106035,7 @@ static void analyzeOneTable( int j, k, regKey; regKey = sqlite3GetTempRange(pParse, pPk->nKeyCol); for(j=0; jnKeyCol; j++){ - k = sqlite3TableColumnToIndex(pIdx, pPk->aiColumn[j]); + k = sqlite3ColumnOfIndex(pIdx, pPk->aiColumn[j]); assert( k>=0 && knColumn ); sqlite3VdbeAddOp3(v, OP_Column, iIdxCur, k, regKey+j); VdbeComment((v, "%s", pTab->aCol[pPk->aiColumn[j]].zName)); @@ -107501,12 +106045,13 @@ static void analyzeOneTable( } #endif assert( regChng==(regStat4+1) ); - sqlite3VdbeAddFunctionCall(pParse, 1, regStat4, regTemp, 2+IsStat4, - &statPushFuncdef, 0); + sqlite3VdbeAddOp4(v, OP_Function0, 1, regStat4, regTemp, + (char*)&statPushFuncdef, P4_FUNCDEF); + sqlite3VdbeChangeP5(v, 2+IsStat4); sqlite3VdbeAddOp2(v, OP_Next, iIdxCur, addrNextRow); VdbeCoverage(v); /* Add the entry to the stat1 table. */ - callStatGet(pParse, regStat4, STAT_GET_STAT1, regStat1); + callStatGet(v, regStat4, STAT_GET_STAT1, regStat1); assert( "BBB"[0]==SQLITE_AFF_TEXT ); sqlite3VdbeAddOp4(v, OP_MakeRecord, regTabname, 3, regTemp, "BBB", 0); sqlite3VdbeAddOp2(v, OP_NewRowid, iStatCur, regNewRowid); @@ -107532,12 +106077,12 @@ static void analyzeOneTable( pParse->nMem = MAX(pParse->nMem, regCol+nCol); addrNext = sqlite3VdbeCurrentAddr(v); - callStatGet(pParse, regStat4, STAT_GET_ROWID, regSampleRowid); + callStatGet(v, regStat4, STAT_GET_ROWID, regSampleRowid); addrIsNull = sqlite3VdbeAddOp1(v, OP_IsNull, regSampleRowid); VdbeCoverage(v); - callStatGet(pParse, regStat4, STAT_GET_NEQ, regEq); - callStatGet(pParse, regStat4, STAT_GET_NLT, regLt); - callStatGet(pParse, regStat4, STAT_GET_NDLT, regDLt); + callStatGet(v, regStat4, STAT_GET_NEQ, regEq); + callStatGet(v, regStat4, STAT_GET_NLT, regLt); + callStatGet(v, regStat4, STAT_GET_NDLT, regDLt); sqlite3VdbeAddOp4Int(v, seekOp, iTabCur, addrNext, regSampleRowid, 0); VdbeCoverage(v); for(i=0; ilookaside.bDisable++; rc = loadStat4(db, sInfo.zDatabase); - EnableLookaside; + db->lookaside.bDisable--; } for(i=sqliteHashFirst(&pSchema->idxHash); i; i=sqliteHashNext(i)){ Index *pIdx = sqliteHashData(i); @@ -108587,8 +107132,11 @@ static void codeAttach( assert( v || db->mallocFailed ); if( v ){ - sqlite3VdbeAddFunctionCall(pParse, 0, regArgs+3-pFunc->nArg, regArgs+3, - pFunc->nArg, pFunc, 0); + sqlite3VdbeAddOp4(v, OP_Function0, 0, regArgs+3-pFunc->nArg, regArgs+3, + (char *)pFunc, P4_FUNCDEF); + assert( pFunc->nArg==-1 || (pFunc->nArg&0xff)==pFunc->nArg ); + sqlite3VdbeChangeP5(v, (u8)(pFunc->nArg)); + /* Code an OP_Expire. For an ATTACH statement, set P1 to true (expire this ** statement only). For DETACH, set it to false (expire all existing ** statements). @@ -108663,7 +107211,7 @@ SQLITE_PRIVATE void sqlite3FixInit( pFix->pSchema = db->aDb[iDb].pSchema; pFix->zType = zType; pFix->pName = pName; - pFix->bTemp = (iDb==1); + pFix->bVarOnly = (iDb==1); } /* @@ -108691,7 +107239,7 @@ SQLITE_PRIVATE int sqlite3FixSrcList( if( NEVER(pList==0) ) return 0; zDb = pFix->zDb; for(i=0, pItem=pList->a; inSrc; i++, pItem++){ - if( pFix->bTemp==0 ){ + if( pFix->bVarOnly==0 ){ if( pItem->zDatabase && sqlite3StrICmp(pItem->zDatabase, zDb) ){ sqlite3ErrorMsg(pFix->pParse, "%s %T cannot reference objects in database %s", @@ -108701,7 +107249,6 @@ SQLITE_PRIVATE int sqlite3FixSrcList( sqlite3DbFree(pFix->pParse->db, pItem->zDatabase); pItem->zDatabase = 0; pItem->pSchema = pFix->pSchema; - pItem->fg.fromDDL = 1; } #if !defined(SQLITE_OMIT_VIEW) || !defined(SQLITE_OMIT_TRIGGER) if( sqlite3FixSelect(pFix, pItem->pSelect) ) return 1; @@ -108757,7 +107304,7 @@ SQLITE_PRIVATE int sqlite3FixExpr( Expr *pExpr /* The expression to be fixed to one database */ ){ while( pExpr ){ - if( !pFix->bTemp ) ExprSetProperty(pExpr, EP_FromDDL); + ExprSetProperty(pExpr, EP_Indirect); if( pExpr->op==TK_VARIABLE ){ if( pFix->pParse->db->init.busy ){ pExpr->op = TK_NULL; @@ -109964,14 +108511,13 @@ SQLITE_PRIVATE int sqlite3CheckObjectName( } } }else{ - if( (pParse->nested==0 && 0==sqlite3StrNICmp(zName, "sqlite_", 7)) - || (sqlite3ReadOnlyShadowTables(db) && sqlite3ShadowTableName(db, zName)) + if( pParse->nested==0 + && 0==sqlite3StrNICmp(zName, "sqlite_", 7) ){ sqlite3ErrorMsg(pParse, "object name reserved for internal use: %s", zName); return SQLITE_ERROR; } - } return SQLITE_OK; } @@ -109986,12 +108532,10 @@ SQLITE_PRIVATE Index *sqlite3PrimaryKeyIndex(Table *pTab){ } /* -** Convert an table column number into a index column number. That is, -** for the column iCol in the table (as defined by the CREATE TABLE statement) -** find the (first) offset of that column in index pIdx. Or return -1 -** if column iCol is not used in index pIdx. +** Return the column of index pIdx that corresponds to table +** column iCol. Return -1 if not found. */ -SQLITE_PRIVATE i16 sqlite3TableColumnToIndex(Index *pIdx, i16 iCol){ +SQLITE_PRIVATE i16 sqlite3ColumnOfIndex(Index *pIdx, i16 iCol){ int i; for(i=0; inColumn; i++){ if( iCol==pIdx->aiColumn[i] ) return i; @@ -109999,84 +108543,6 @@ SQLITE_PRIVATE i16 sqlite3TableColumnToIndex(Index *pIdx, i16 iCol){ return -1; } -#ifndef SQLITE_OMIT_GENERATED_COLUMNS -/* Convert a storage column number into a table column number. -** -** The storage column number (0,1,2,....) is the index of the value -** as it appears in the record on disk. The true column number -** is the index (0,1,2,...) of the column in the CREATE TABLE statement. -** -** The storage column number is less than the table column number if -** and only there are VIRTUAL columns to the left. -** -** If SQLITE_OMIT_GENERATED_COLUMNS, this routine is a no-op macro. -*/ -SQLITE_PRIVATE i16 sqlite3StorageColumnToTable(Table *pTab, i16 iCol){ - if( pTab->tabFlags & TF_HasVirtual ){ - int i; - for(i=0; i<=iCol; i++){ - if( pTab->aCol[i].colFlags & COLFLAG_VIRTUAL ) iCol++; - } - } - return iCol; -} -#endif - -#ifndef SQLITE_OMIT_GENERATED_COLUMNS -/* Convert a table column number into a storage column number. -** -** The storage column number (0,1,2,....) is the index of the value -** as it appears in the record on disk. Or, if the input column is -** the N-th virtual column (zero-based) then the storage number is -** the number of non-virtual columns in the table plus N. -** -** The true column number is the index (0,1,2,...) of the column in -** the CREATE TABLE statement. -** -** If the input column is a VIRTUAL column, then it should not appear -** in storage. But the value sometimes is cached in registers that -** follow the range of registers used to construct storage. This -** avoids computing the same VIRTUAL column multiple times, and provides -** values for use by OP_Param opcodes in triggers. Hence, if the -** input column is a VIRTUAL table, put it after all the other columns. -** -** In the following, N means "normal column", S means STORED, and -** V means VIRTUAL. Suppose the CREATE TABLE has columns like this: -** -** CREATE TABLE ex(N,S,V,N,S,V,N,S,V); -** -- 0 1 2 3 4 5 6 7 8 -** -** Then the mapping from this function is as follows: -** -** INPUTS: 0 1 2 3 4 5 6 7 8 -** OUTPUTS: 0 1 6 2 3 7 4 5 8 -** -** So, in other words, this routine shifts all the virtual columns to -** the end. -** -** If SQLITE_OMIT_GENERATED_COLUMNS then there are no virtual columns and -** this routine is a no-op macro. If the pTab does not have any virtual -** columns, then this routine is no-op that always return iCol. If iCol -** is negative (indicating the ROWID column) then this routine return iCol. -*/ -SQLITE_PRIVATE i16 sqlite3TableColumnToStorage(Table *pTab, i16 iCol){ - int i; - i16 n; - assert( iColnCol ); - if( (pTab->tabFlags & TF_HasVirtual)==0 || iCol<0 ) return iCol; - for(i=0, n=0; iaCol[i].colFlags & COLFLAG_VIRTUAL)==0 ) n++; - } - if( pTab->aCol[i].colFlags & COLFLAG_VIRTUAL ){ - /* iCol is a virtual column itself */ - return pTab->nNVCol + i - n; - }else{ - /* iCol is a normal or stored column */ - return n; - } -} -#endif - /* ** Begin constructing a new table representation in memory. This is ** the first of several action routines that get called in response @@ -110367,7 +108833,6 @@ SQLITE_PRIVATE void sqlite3AddColumn(Parse *pParse, Token *pName, Token *pType){ pCol->colFlags |= COLFLAG_HASTYPE; } p->nCol++; - p->nNVCol++; pParse->constraintName.n = 0; } @@ -110512,17 +108977,10 @@ SQLITE_PRIVATE void sqlite3AddDefaultValue( sqlite3 *db = pParse->db; p = pParse->pNewTable; if( p!=0 ){ - int isInit = db->init.busy && db->init.iDb!=1; pCol = &(p->aCol[p->nCol-1]); - if( !sqlite3ExprIsConstantOrFunction(pExpr, isInit) ){ + if( !sqlite3ExprIsConstantOrFunction(pExpr, db->init.busy) ){ sqlite3ErrorMsg(pParse, "default value of column [%s] is not constant", pCol->zName); -#ifndef SQLITE_OMIT_GENERATED_COLUMNS - }else if( pCol->colFlags & COLFLAG_GENERATED ){ - testcase( pCol->colFlags & COLFLAG_VIRTUAL ); - testcase( pCol->colFlags & COLFLAG_STORED ); - sqlite3ErrorMsg(pParse, "cannot use DEFAULT on a generated column"); -#endif }else{ /* A copy of pExpr is used instead of the original, as pExpr contains ** tokens that point to volatile memory. @@ -110568,21 +109026,6 @@ static void sqlite3StringToId(Expr *p){ } } -/* -** Tag the given column as being part of the PRIMARY KEY -*/ -static void makeColumnPartOfPrimaryKey(Parse *pParse, Column *pCol){ - pCol->colFlags |= COLFLAG_PRIMKEY; -#ifndef SQLITE_OMIT_GENERATED_COLUMNS - if( pCol->colFlags & COLFLAG_GENERATED ){ - testcase( pCol->colFlags & COLFLAG_VIRTUAL ); - testcase( pCol->colFlags & COLFLAG_STORED ); - sqlite3ErrorMsg(pParse, - "generated columns cannot be part of the PRIMARY KEY"); - } -#endif -} - /* ** Designate the PRIMARY KEY for the table. pList is a list of names ** of columns that form the primary key. If pList is NULL, then the @@ -110622,7 +109065,7 @@ SQLITE_PRIVATE void sqlite3AddPrimaryKey( if( pList==0 ){ iCol = pTab->nCol - 1; pCol = &pTab->aCol[iCol]; - makeColumnPartOfPrimaryKey(pParse, pCol); + pCol->colFlags |= COLFLAG_PRIMKEY; nTerm = 1; }else{ nTerm = pList->nExpr; @@ -110635,7 +109078,7 @@ SQLITE_PRIVATE void sqlite3AddPrimaryKey( for(iCol=0; iColnCol; iCol++){ if( sqlite3StrICmp(zCName, pTab->aCol[iCol].zName)==0 ){ pCol = &pTab->aCol[iCol]; - makeColumnPartOfPrimaryKey(pParse, pCol); + pCol->colFlags |= COLFLAG_PRIMKEY; break; } } @@ -110656,7 +109099,6 @@ SQLITE_PRIVATE void sqlite3AddPrimaryKey( assert( autoInc==0 || autoInc==1 ); pTab->tabFlags |= autoInc*TF_Autoincrement; if( pList ) pParse->iPkSortOrder = pList->a[0].sortFlags; - (void)sqlite3HasExplicitNulls(pParse, pList); }else if( autoInc ){ #ifndef SQLITE_OMIT_AUTOINCREMENT sqlite3ErrorMsg(pParse, "AUTOINCREMENT is only allowed on an " @@ -110733,58 +109175,41 @@ SQLITE_PRIVATE void sqlite3AddCollateType(Parse *pParse, Token *pToken){ } } -/* Change the most recently parsed column to be a GENERATED ALWAYS AS -** column. +/* +** This function returns the collation sequence for database native text +** encoding identified by the string zName, length nName. +** +** If the requested collation sequence is not available, or not available +** in the database native encoding, the collation factory is invoked to +** request it. If the collation factory does not supply such a sequence, +** and the sequence is available in another text encoding, then that is +** returned instead. +** +** If no versions of the requested collations sequence are available, or +** another error occurs, NULL is returned and an error message written into +** pParse. +** +** This routine is a wrapper around sqlite3FindCollSeq(). This routine +** invokes the collation factory if the named collation cannot be found +** and generates an error message. +** +** See also: sqlite3FindCollSeq(), sqlite3GetCollSeq() */ -SQLITE_PRIVATE void sqlite3AddGenerated(Parse *pParse, Expr *pExpr, Token *pType){ -#ifndef SQLITE_OMIT_GENERATED_COLUMNS - u8 eType = COLFLAG_VIRTUAL; - Table *pTab = pParse->pNewTable; - Column *pCol; - if( pTab==0 ){ - /* generated column in an CREATE TABLE IF NOT EXISTS that already exists */ - goto generated_done; - } - pCol = &(pTab->aCol[pTab->nCol-1]); - if( IN_DECLARE_VTAB ){ - sqlite3ErrorMsg(pParse, "virtual tables cannot use computed columns"); - goto generated_done; - } - if( pCol->pDflt ) goto generated_error; - if( pType ){ - if( pType->n==7 && sqlite3StrNICmp("virtual",pType->z,7)==0 ){ - /* no-op */ - }else if( pType->n==6 && sqlite3StrNICmp("stored",pType->z,6)==0 ){ - eType = COLFLAG_STORED; - }else{ - goto generated_error; - } - } - if( eType==COLFLAG_VIRTUAL ) pTab->nNVCol--; - pCol->colFlags |= eType; - assert( TF_HasVirtual==COLFLAG_VIRTUAL ); - assert( TF_HasStored==COLFLAG_STORED ); - pTab->tabFlags |= eType; - if( pCol->colFlags & COLFLAG_PRIMKEY ){ - makeColumnPartOfPrimaryKey(pParse, pCol); /* For the error message */ - } - pCol->pDflt = pExpr; - pExpr = 0; - goto generated_done; +SQLITE_PRIVATE CollSeq *sqlite3LocateCollSeq(Parse *pParse, const char *zName){ + sqlite3 *db = pParse->db; + u8 enc = ENC(db); + u8 initbusy = db->init.busy; + CollSeq *pColl; -generated_error: - sqlite3ErrorMsg(pParse, "error in generated column \"%s\"", - pCol->zName); -generated_done: - sqlite3ExprDelete(pParse->db, pExpr); -#else - /* Throw and error for the GENERATED ALWAYS AS clause if the - ** SQLITE_OMIT_GENERATED_COLUMNS compile-time option is used. */ - sqlite3ErrorMsg(pParse, "generated columns not supported"); - sqlite3ExprDelete(pParse->db, pExpr); -#endif + pColl = sqlite3FindCollSeq(db, enc, zName, initbusy); + if( !initbusy && (!pColl || !pColl->xCmp) ){ + pColl = sqlite3GetCollSeq(pParse, enc, pColl, zName); + } + + return pColl; } + /* ** Generate code that will increment the schema cookie. ** @@ -111042,24 +109467,15 @@ static int isDupColumn(Index *pIdx, int nKey, Index *pPk, int iCol){ ** high-order bit of colNotIdxed is always 1. All unindexed columns ** of the table have a 1. ** -** 2019-10-24: For the purpose of this computation, virtual columns are -** not considered to be covered by the index, even if they are in the -** index, because we do not trust the logic in whereIndexExprTrans() to be -** able to find all instances of a reference to the indexed table column -** and convert them into references to the index. Hence we always want -** the actual table at hand in order to recompute the virtual column, if -** necessary. -** ** The colNotIdxed mask is AND-ed with the SrcList.a[].colUsed mask ** to determine if the index is covering index. */ static void recomputeColumnsNotIndexed(Index *pIdx){ Bitmask m = 0; int j; - Table *pTab = pIdx->pTable; for(j=pIdx->nColumn-1; j>=0; j--){ int x = pIdx->aiColumn[j]; - if( x>=0 && (pTab->aCol[x].colFlags & COLFLAG_VIRTUAL)==0 ){ + if( x>=0 ){ testcase( x==BMS-1 ); testcase( x==BMS-2 ); if( xaCol[i].notNull = OE_Abort; } } - pTab->tabFlags |= TF_HasNotNull; } /* Convert the P3 operand of the OP_CreateBtree opcode from BTREE_INTKEY @@ -111218,14 +109633,11 @@ static void convertToWithoutRowidTable(Parse *pParse, Table *pTab){ */ nExtra = 0; for(i=0; inCol; i++){ - if( !hasColumn(pPk->aiColumn, nPk, i) - && (pTab->aCol[i].colFlags & COLFLAG_VIRTUAL)==0 ) nExtra++; + if( !hasColumn(pPk->aiColumn, nPk, i) ) nExtra++; } if( resizeIndexObject(db, pPk, nPk+nExtra) ) return; for(i=0, j=nPk; inCol; i++){ - if( !hasColumn(pPk->aiColumn, j, i) - && (pTab->aCol[i].colFlags & COLFLAG_VIRTUAL)==0 - ){ + if( !hasColumn(pPk->aiColumn, j, i) ){ assert( jnColumn ); pPk->aiColumn[j] = i; pPk->azColl[j] = sqlite3StrBINARY; @@ -111233,7 +109645,7 @@ static void convertToWithoutRowidTable(Parse *pParse, Table *pTab){ } } assert( pPk->nColumn==j ); - assert( pTab->nNVCol<=j ); + assert( pTab->nCol<=j ); recomputeColumnsNotIndexed(pPk); } @@ -111245,7 +109657,7 @@ static void convertToWithoutRowidTable(Parse *pParse, Table *pTab){ ** zName is temporarily modified while this routine is running, but is ** restored to its original value prior to this routine returning. */ -SQLITE_PRIVATE int sqlite3ShadowTableName(sqlite3 *db, const char *zName){ +static int isShadowTableName(sqlite3 *db, char *zName){ char *zTail; /* Pointer to the last "_" in zName */ Table *pTab; /* Table that zName is a shadow of */ Module *pMod; /* Module for the virtual table */ @@ -111263,6 +109675,8 @@ SQLITE_PRIVATE int sqlite3ShadowTableName(sqlite3 *db, const char *zName){ if( pMod->pModule->xShadowName==0 ) return 0; return pMod->pModule->xShadowName(zTail+1); } +#else +# define isShadowTableName(x,y) 0 #endif /* ifndef SQLITE_OMIT_VIRTUALTABLE */ /* @@ -111304,7 +109718,7 @@ SQLITE_PRIVATE void sqlite3EndTable( p = pParse->pNewTable; if( p==0 ) return; - if( pSelect==0 && sqlite3ShadowTableName(db, p->zName) ){ + if( pSelect==0 && isShadowTableName(db, p->zName) ){ p->tabFlags |= TF_Shadow; } @@ -111340,11 +109754,12 @@ SQLITE_PRIVATE void sqlite3EndTable( } if( (p->tabFlags & TF_HasPrimaryKey)==0 ){ sqlite3ErrorMsg(pParse, "PRIMARY KEY missing on table %s", p->zName); - return; + }else{ + p->tabFlags |= TF_WithoutRowid | TF_NoVisibleRowid; + convertToWithoutRowidTable(pParse, p); } - p->tabFlags |= TF_WithoutRowid | TF_NoVisibleRowid; - convertToWithoutRowidTable(pParse, p); } + iDb = sqlite3SchemaToIndex(db, p->pSchema); #ifndef SQLITE_OMIT_CHECK @@ -111352,45 +109767,8 @@ SQLITE_PRIVATE void sqlite3EndTable( */ if( p->pCheck ){ sqlite3ResolveSelfReference(pParse, p, NC_IsCheck, 0, p->pCheck); - if( pParse->nErr ){ - /* If errors are seen, delete the CHECK constraints now, else they might - ** actually be used if PRAGMA writable_schema=ON is set. */ - sqlite3ExprListDelete(db, p->pCheck); - p->pCheck = 0; - } } #endif /* !defined(SQLITE_OMIT_CHECK) */ -#ifndef SQLITE_OMIT_GENERATED_COLUMNS - if( p->tabFlags & TF_HasGenerated ){ - int ii, nNG = 0; - testcase( p->tabFlags & TF_HasVirtual ); - testcase( p->tabFlags & TF_HasStored ); - for(ii=0; iinCol; ii++){ - u32 colFlags = p->aCol[ii].colFlags; - if( (colFlags & COLFLAG_GENERATED)!=0 ){ - Expr *pX = p->aCol[ii].pDflt; - testcase( colFlags & COLFLAG_VIRTUAL ); - testcase( colFlags & COLFLAG_STORED ); - if( sqlite3ResolveSelfReference(pParse, p, NC_GenCol, pX, 0) ){ - /* If there are errors in resolving the expression, change the - ** expression to a NULL. This prevents code generators that operate - ** on the expression from inserting extra parts into the expression - ** tree that have been allocated from lookaside memory, which is - ** illegal in a schema and will lead to errors or heap corruption - ** when the database connection closes. */ - sqlite3ExprDelete(db, pX); - p->aCol[ii].pDflt = sqlite3ExprAlloc(db, TK_NULL, 0, 0); - } - }else{ - nNG++; - } - } - if( nNG==0 ){ - sqlite3ErrorMsg(pParse, "must have at least one non-generated column"); - return; - } - } -#endif /* Estimate the average row size for the table and for all implied indices */ estimateTableWidth(p); @@ -111467,7 +109845,7 @@ SQLITE_PRIVATE void sqlite3EndTable( pSelTab = sqlite3ResultSetOfSelect(pParse, pSelect, SQLITE_AFF_BLOB); if( pSelTab==0 ) return; assert( p->aCol==0 ); - p->nCol = p->nNVCol = pSelTab->nCol; + p->nCol = pSelTab->nCol; p->aCol = pSelTab->aCol; pSelTab->nCol = 0; pSelTab->aCol = 0; @@ -111540,6 +109918,7 @@ SQLITE_PRIVATE void sqlite3EndTable( sqlite3MPrintf(db, "tbl_name='%q' AND type!='trigger'", p->zName)); } + /* Add the table to the in-memory representation of the database. */ if( db->init.busy ){ @@ -111610,7 +109989,6 @@ SQLITE_PRIVATE void sqlite3CreateView( ** allocated rather than point to the input string - which means that ** they will persist after the current sqlite3_exec() call returns. */ - pSelect->selFlags |= SF_View; if( IN_RENAME_OBJECT ){ p->pSelect = pSelect; pSelect = 0; @@ -111724,7 +110102,7 @@ SQLITE_PRIVATE int sqlite3ViewGetColumnNames(Parse *pParse, Table *pTable){ n = pParse->nTab; sqlite3SrcListAssignCursors(pParse, pSel->pSrc); pTable->nCol = -1; - DisableLookaside; + db->lookaside.bDisable++; #ifndef SQLITE_OMIT_AUTHORIZATION xAuth = db->xAuth; db->xAuth = 0; @@ -111734,10 +110112,7 @@ SQLITE_PRIVATE int sqlite3ViewGetColumnNames(Parse *pParse, Table *pTable){ pSelTab = sqlite3ResultSetOfSelect(pParse, pSel, SQLITE_AFF_NONE); #endif pParse->nTab = n; - if( pSelTab==0 ){ - pTable->nCol = 0; - nErr++; - }else if( pTable->pCheck ){ + if( pTable->pCheck ){ /* CREATE VIEW name(arglist) AS ... ** The names of the columns in the table are taken from ** arglist which is stored in pTable->pCheck. The pCheck field @@ -111753,7 +110128,7 @@ SQLITE_PRIVATE int sqlite3ViewGetColumnNames(Parse *pParse, Table *pTable){ sqlite3SelectAddColumnTypeAndCollation(pParse, pTable, pSel, SQLITE_AFF_NONE); } - }else{ + }else if( pSelTab ){ /* CREATE VIEW name AS... without an argument list. Construct ** the column names from the SELECT statement that defines the view. */ @@ -111763,11 +110138,13 @@ SQLITE_PRIVATE int sqlite3ViewGetColumnNames(Parse *pParse, Table *pTable){ pSelTab->nCol = 0; pSelTab->aCol = 0; assert( sqlite3SchemaMutexHeld(db, 0, pTable->pSchema) ); + }else{ + pTable->nCol = 0; + nErr++; } - pTable->nNVCol = pTable->nCol; sqlite3DeleteTable(db, pSelTab); sqlite3SelectDelete(db, pSel); - EnableLookaside; + db->lookaside.bDisable--; #ifndef SQLITE_OMIT_ALTERTABLE pParse->eParseMode = eParseMode; #endif @@ -112024,37 +110401,6 @@ SQLITE_PRIVATE void sqlite3CodeDropTable(Parse *pParse, Table *pTab, int iDb, in sqliteViewResetAll(db, iDb); } -/* -** Return TRUE if shadow tables should be read-only in the current -** context. -*/ -SQLITE_PRIVATE int sqlite3ReadOnlyShadowTables(sqlite3 *db){ -#ifndef SQLITE_OMIT_VIRTUALTABLE - if( (db->flags & SQLITE_Defensive)!=0 - && db->pVtabCtx==0 - && db->nVdbeExec==0 - ){ - return 1; - } -#endif - return 0; -} - -/* -** Return true if it is not allowed to drop the given table -*/ -static int tableMayNotBeDropped(sqlite3 *db, Table *pTab){ - if( sqlite3StrNICmp(pTab->zName, "sqlite_", 7)==0 ){ - if( sqlite3StrNICmp(pTab->zName+7, "stat", 4)==0 ) return 0; - if( sqlite3StrNICmp(pTab->zName+7, "parameters", 10)==0 ) return 0; - return 1; - } - if( (pTab->tabFlags & TF_Shadow)!=0 && sqlite3ReadOnlyShadowTables(db) ){ - return 1; - } - return 0; -} - /* ** This routine is called to do the work of a DROP TABLE statement. ** pName is the name of the table to be dropped. @@ -112124,7 +110470,9 @@ SQLITE_PRIVATE void sqlite3DropTable(Parse *pParse, SrcList *pName, int isView, } } #endif - if( tableMayNotBeDropped(db, pTab) ){ + if( sqlite3StrNICmp(pTab->zName, "sqlite_", 7)==0 + && sqlite3StrNICmp(pTab->zName+7, "stat", 4)!=0 + && sqlite3StrNICmp(pTab->zName+7, "parameters", 10)!=0 ){ sqlite3ErrorMsg(pParse, "table %s may not be dropped", pTab->zName); goto exit_drop_table; } @@ -112216,7 +110564,7 @@ SQLITE_PRIVATE void sqlite3CreateForeignKey( nByte = sizeof(*pFKey) + (nCol-1)*sizeof(pFKey->aCol[0]) + pTo->n + 1; if( pToCol ){ for(i=0; inExpr; i++){ - nByte += sqlite3Strlen30(pToCol->a[i].zEName) + 1; + nByte += sqlite3Strlen30(pToCol->a[i].zName) + 1; } } pFKey = sqlite3DbMallocZero(db, nByte ); @@ -112241,7 +110589,7 @@ SQLITE_PRIVATE void sqlite3CreateForeignKey( for(i=0; inCol; j++){ - if( sqlite3StrICmp(p->aCol[j].zName, pFromCol->a[i].zEName)==0 ){ + if( sqlite3StrICmp(p->aCol[j].zName, pFromCol->a[i].zName)==0 ){ pFKey->aCol[i].iFrom = j; break; } @@ -112249,22 +110597,22 @@ SQLITE_PRIVATE void sqlite3CreateForeignKey( if( j>=p->nCol ){ sqlite3ErrorMsg(pParse, "unknown column \"%s\" in foreign key definition", - pFromCol->a[i].zEName); + pFromCol->a[i].zName); goto fk_end; } if( IN_RENAME_OBJECT ){ - sqlite3RenameTokenRemap(pParse, &pFKey->aCol[i], pFromCol->a[i].zEName); + sqlite3RenameTokenRemap(pParse, &pFKey->aCol[i], pFromCol->a[i].zName); } } } if( pToCol ){ for(i=0; ia[i].zEName); + int n = sqlite3Strlen30(pToCol->a[i].zName); pFKey->aCol[i].zCol = z; if( IN_RENAME_OBJECT ){ - sqlite3RenameTokenRemap(pParse, z, pToCol->a[i].zEName); + sqlite3RenameTokenRemap(pParse, z, pToCol->a[i].zName); } - memcpy(z, pToCol->a[i].zEName, n); + memcpy(z, pToCol->a[i].zName, n); z[n] = 0; z += n+1; } @@ -112795,13 +111143,8 @@ SQLITE_PRIVATE void sqlite3CreateIndex( assert( j<=0x7fff ); if( j<0 ){ j = pTab->iPKey; - }else{ - if( pTab->aCol[j].notNull==0 ){ - pIndex->uniqNotNull = 0; - } - if( pTab->aCol[j].colFlags & COLFLAG_VIRTUAL ){ - pIndex->bHasVCol = 1; - } + }else if( pTab->aCol[j].notNull==0 ){ + pIndex->uniqNotNull = 0; } pIndex->aiColumn[i] = (i16)j; } @@ -112856,13 +111199,13 @@ SQLITE_PRIVATE void sqlite3CreateIndex( /* If this index contains every column of its table, then mark ** it as a covering index */ assert( HasRowid(pTab) - || pTab->iPKey<0 || sqlite3TableColumnToIndex(pIndex, pTab->iPKey)>=0 ); + || pTab->iPKey<0 || sqlite3ColumnOfIndex(pIndex, pTab->iPKey)>=0 ); recomputeColumnsNotIndexed(pIndex); if( pTblName!=0 && pIndex->nColumn>=pTab->nCol ){ pIndex->isCovering = 1; for(j=0; jnCol; j++){ if( j==pTab->iPKey ) continue; - if( sqlite3TableColumnToIndex(pIndex,j)>=0 ) continue; + if( sqlite3ColumnOfIndex(pIndex,j)>=0 ) continue; pIndex->isCovering = 0; break; } @@ -113037,9 +111380,26 @@ SQLITE_PRIVATE void sqlite3CreateIndex( sqlite3VdbeJumpHere(v, pIndex->tnum); } } + + /* When adding an index to the list of indices for a table, make + ** sure all indices labeled OE_Replace come after all those labeled + ** OE_Ignore. This is necessary for the correct constraint check + ** processing (in sqlite3GenerateConstraintChecks()) as part of + ** UPDATE and INSERT statements. + */ if( db->init.busy || pTblName==0 ){ - pIndex->pNext = pTab->pIndex; - pTab->pIndex = pIndex; + if( onError!=OE_Replace || pTab->pIndex==0 + || pTab->pIndex->onError==OE_Replace){ + pIndex->pNext = pTab->pIndex; + pTab->pIndex = pIndex; + }else{ + Index *pOther = pTab->pIndex; + while( pOther->pNext && pOther->pNext->onError!=OE_Replace ){ + pOther = pOther->pNext; + } + pIndex->pNext = pOther->pNext; + pOther->pNext = pIndex; + } pIndex = 0; } else if( IN_RENAME_OBJECT ){ @@ -113051,21 +111411,6 @@ SQLITE_PRIVATE void sqlite3CreateIndex( /* Clean up before exiting */ exit_create_index: if( pIndex ) sqlite3FreeIndex(db, pIndex); - if( pTab ){ /* Ensure all REPLACE indexes are at the end of the list */ - Index **ppFrom = &pTab->pIndex; - Index *pThis; - for(ppFrom=&pTab->pIndex; (pThis = *ppFrom)!=0; ppFrom=&pThis->pNext){ - Index *pNext; - if( pThis->onError!=OE_Replace ) continue; - while( (pNext = pThis->pNext)!=0 && pNext->onError!=OE_Replace ){ - *ppFrom = pNext; - pThis->pNext = pNext->pNext; - pNext->pNext = pThis; - ppFrom = &pNext->pNext; - } - break; - } - } sqlite3ExprDelete(db, pPIWhere); sqlite3ExprListDelete(db, pList); sqlite3SrcListDelete(db, pTblName); @@ -114200,6 +112545,51 @@ static int synthCollSeq(sqlite3 *db, CollSeq *pColl){ return SQLITE_ERROR; } +/* +** This function is responsible for invoking the collation factory callback +** or substituting a collation sequence of a different encoding when the +** requested collation sequence is not available in the desired encoding. +** +** If it is not NULL, then pColl must point to the database native encoding +** collation sequence with name zName, length nName. +** +** The return value is either the collation sequence to be used in database +** db for collation type name zName, length nName, or NULL, if no collation +** sequence can be found. If no collation is found, leave an error message. +** +** See also: sqlite3LocateCollSeq(), sqlite3FindCollSeq() +*/ +SQLITE_PRIVATE CollSeq *sqlite3GetCollSeq( + Parse *pParse, /* Parsing context */ + u8 enc, /* The desired encoding for the collating sequence */ + CollSeq *pColl, /* Collating sequence with native encoding, or NULL */ + const char *zName /* Collating sequence name */ +){ + CollSeq *p; + sqlite3 *db = pParse->db; + + p = pColl; + if( !p ){ + p = sqlite3FindCollSeq(db, enc, zName, 0); + } + if( !p || !p->xCmp ){ + /* No collation sequence of this type for this encoding is registered. + ** Call the collation factory to see if it can supply us with one. + */ + callCollNeeded(db, enc, zName); + p = sqlite3FindCollSeq(db, enc, zName, 0); + } + if( p && !p->xCmp && synthCollSeq(db, p) ){ + p = 0; + } + assert( !p || p->xCmp ); + if( p==0 ){ + sqlite3ErrorMsg(pParse, "no such collation sequence: %s", zName); + pParse->rc = SQLITE_ERROR_MISSING_COLLSEQ; + } + return p; +} + /* ** This routine is called on a collation sequence before it is used to ** check that it is defined. An undefined collation sequence exists when @@ -114292,10 +112682,10 @@ static CollSeq *findCollSeqEntry( ** See also: sqlite3LocateCollSeq(), sqlite3GetCollSeq() */ SQLITE_PRIVATE CollSeq *sqlite3FindCollSeq( - sqlite3 *db, /* Database connection to search */ - u8 enc, /* Desired text encoding */ - const char *zName, /* Name of the collating sequence. Might be NULL */ - int create /* True to create CollSeq if doesn't already exist */ + sqlite3 *db, + u8 enc, + const char *zName, + int create ){ CollSeq *pColl; if( zName ){ @@ -114309,85 +112699,6 @@ SQLITE_PRIVATE CollSeq *sqlite3FindCollSeq( return pColl; } -/* -** This function is responsible for invoking the collation factory callback -** or substituting a collation sequence of a different encoding when the -** requested collation sequence is not available in the desired encoding. -** -** If it is not NULL, then pColl must point to the database native encoding -** collation sequence with name zName, length nName. -** -** The return value is either the collation sequence to be used in database -** db for collation type name zName, length nName, or NULL, if no collation -** sequence can be found. If no collation is found, leave an error message. -** -** See also: sqlite3LocateCollSeq(), sqlite3FindCollSeq() -*/ -SQLITE_PRIVATE CollSeq *sqlite3GetCollSeq( - Parse *pParse, /* Parsing context */ - u8 enc, /* The desired encoding for the collating sequence */ - CollSeq *pColl, /* Collating sequence with native encoding, or NULL */ - const char *zName /* Collating sequence name */ -){ - CollSeq *p; - sqlite3 *db = pParse->db; - - p = pColl; - if( !p ){ - p = sqlite3FindCollSeq(db, enc, zName, 0); - } - if( !p || !p->xCmp ){ - /* No collation sequence of this type for this encoding is registered. - ** Call the collation factory to see if it can supply us with one. - */ - callCollNeeded(db, enc, zName); - p = sqlite3FindCollSeq(db, enc, zName, 0); - } - if( p && !p->xCmp && synthCollSeq(db, p) ){ - p = 0; - } - assert( !p || p->xCmp ); - if( p==0 ){ - sqlite3ErrorMsg(pParse, "no such collation sequence: %s", zName); - pParse->rc = SQLITE_ERROR_MISSING_COLLSEQ; - } - return p; -} - -/* -** This function returns the collation sequence for database native text -** encoding identified by the string zName. -** -** If the requested collation sequence is not available, or not available -** in the database native encoding, the collation factory is invoked to -** request it. If the collation factory does not supply such a sequence, -** and the sequence is available in another text encoding, then that is -** returned instead. -** -** If no versions of the requested collations sequence are available, or -** another error occurs, NULL is returned and an error message written into -** pParse. -** -** This routine is a wrapper around sqlite3FindCollSeq(). This routine -** invokes the collation factory if the named collation cannot be found -** and generates an error message. -** -** See also: sqlite3FindCollSeq(), sqlite3GetCollSeq() -*/ -SQLITE_PRIVATE CollSeq *sqlite3LocateCollSeq(Parse *pParse, const char *zName){ - sqlite3 *db = pParse->db; - u8 enc = ENC(db); - u8 initbusy = db->init.busy; - CollSeq *pColl; - - pColl = sqlite3FindCollSeq(db, enc, zName, initbusy); - if( !initbusy && (!pColl || !pColl->xCmp) ){ - pColl = sqlite3GetCollSeq(pParse, enc, pColl, zName); - } - - return pColl; -} - /* During the search for the best function definition, this procedure ** is called to test how well the function passed as the first argument ** matches the request for a function with nArg arguments in a system @@ -114423,13 +112734,12 @@ static int matchQuality( u8 enc /* Desired text encoding */ ){ int match; - assert( p->nArg>=-1 ); + + /* nArg of -2 is a special case */ + if( nArg==(-2) ) return (p->xSFunc==0) ? 0 : FUNC_PERFECT_MATCH; /* Wrong number of arguments means "no match" */ - if( p->nArg!=nArg ){ - if( nArg==(-2) ) return (p->xSFunc==0) ? 0 : FUNC_PERFECT_MATCH; - if( p->nArg>=0 ) return 0; - } + if( p->nArg!=nArg && p->nArg>=0 ) return 0; /* Give a better score to a function with a specific number of arguments ** than to function that accepts any number of arguments. */ @@ -114731,7 +113041,11 @@ static int tabIsReadOnly(Parse *pParse, Table *pTab){ return sqlite3WritableSchema(db)==0 && pParse->nested==0; } assert( pTab->tabFlags & TF_Shadow ); - return sqlite3ReadOnlyShadowTables(db); + return (db->flags & SQLITE_Defensive)!=0 +#ifndef SQLITE_OMIT_VIRTUALTABLE + && db->pVtabCtx==0 +#endif + && db->nVdbeExec==0; } /* @@ -115394,8 +113708,7 @@ SQLITE_PRIVATE void sqlite3GenerateRowDelete( testcase( mask!=0xffffffff && iCol==31 ); testcase( mask!=0xffffffff && iCol==32 ); if( mask==0xffffffff || (iCol<=31 && (mask & MASKBIT32(iCol))!=0) ){ - int kk = sqlite3TableColumnToStorage(pTab, iCol); - sqlite3ExprCodeGetColumnOfTable(v, pTab, iDataCur, iCol, iOld+kk+1); + sqlite3ExprCodeGetColumnOfTable(v, pTab, iDataCur, iCol, iOld+iCol+1); } } @@ -115575,8 +113888,6 @@ SQLITE_PRIVATE int sqlite3GenerateIndexKey( sqlite3ExprIfFalseDup(pParse, pIdx->pPartIdxWhere, *piPartIdxLabel, SQLITE_JUMPIFNULL); pParse->iSelfTab = 0; - pPrior = 0; /* Ticket a9efb42811fa41ee 2019-11-02; - ** pPartIdxWhere may have corrupted regPrior registers */ }else{ *piPartIdxLabel = 0; } @@ -115643,9 +113954,7 @@ SQLITE_PRIVATE void sqlite3ResolvePartIdxLabel(Parse *pParse, int iLabel){ /* #include "sqliteInt.h" */ /* #include */ /* #include */ -#ifndef SQLITE_OMIT_FLOATING_POINT /* #include */ -#endif /* #include "vdbeInt.h" */ /* @@ -117536,20 +115845,12 @@ SQLITE_PRIVATE void sqlite3RegisterBuiltinFunctions(void){ ** For peak efficiency, put the most frequently used function last. */ static FuncDef aBuiltinFunc[] = { -/***** Functions only available with SQLITE_TESTCTRL_INTERNAL_FUNCTIONS *****/ - TEST_FUNC(implies_nonnull_row, 2, INLINEFUNC_implies_nonnull_row, 0), - TEST_FUNC(expr_compare, 2, INLINEFUNC_expr_compare, 0), - TEST_FUNC(expr_implies_expr, 2, INLINEFUNC_expr_implies_expr, 0), -#ifdef SQLITE_DEBUG - TEST_FUNC(affinity, 1, INLINEFUNC_affinity, 0), -#endif -/***** Regular functions *****/ #ifdef SQLITE_SOUNDEX FUNCTION(soundex, 1, 0, 0, soundexFunc ), #endif #ifndef SQLITE_OMIT_LOAD_EXTENSION - SFUNCTION(load_extension, 1, 0, 0, loadExt ), - SFUNCTION(load_extension, 2, 0, 0, loadExt ), + VFUNCTION(load_extension, 1, 0, 0, loadExt ), + VFUNCTION(load_extension, 2, 0, 0, loadExt ), #endif #if SQLITE_USER_AUTHENTICATION FUNCTION(sqlite_crypt, 2, 0, 0, sqlite3CryptFunc ), @@ -117558,9 +115859,12 @@ SQLITE_PRIVATE void sqlite3RegisterBuiltinFunctions(void){ DFUNCTION(sqlite_compileoption_used,1, 0, 0, compileoptionusedFunc ), DFUNCTION(sqlite_compileoption_get, 1, 0, 0, compileoptiongetFunc ), #endif /* SQLITE_OMIT_COMPILEOPTION_DIAGS */ - INLINE_FUNC(unlikely, 1, INLINEFUNC_unlikely, SQLITE_FUNC_UNLIKELY), - INLINE_FUNC(likelihood, 2, INLINEFUNC_unlikely, SQLITE_FUNC_UNLIKELY), - INLINE_FUNC(likely, 1, INLINEFUNC_unlikely, SQLITE_FUNC_UNLIKELY), + FUNCTION2(unlikely, 1, 0, 0, noopFunc, SQLITE_FUNC_UNLIKELY), + FUNCTION2(likelihood, 2, 0, 0, noopFunc, SQLITE_FUNC_UNLIKELY), + FUNCTION2(likely, 1, 0, 0, noopFunc, SQLITE_FUNC_UNLIKELY), +#ifdef SQLITE_DEBUG + FUNCTION2(affinity, 1, 0, 0, noopFunc, SQLITE_FUNC_AFFINITY), +#endif #ifdef SQLITE_ENABLE_OFFSET_SQL_FUNC FUNCTION2(sqlite_offset, 1, 0, 0, noopFunc, SQLITE_FUNC_OFFSET| SQLITE_FUNC_TYPEOF), @@ -117593,7 +115897,7 @@ SQLITE_PRIVATE void sqlite3RegisterBuiltinFunctions(void){ FUNCTION(upper, 1, 0, 0, upperFunc ), FUNCTION(lower, 1, 0, 0, lowerFunc ), FUNCTION(hex, 1, 0, 0, hexFunc ), - INLINE_FUNC(ifnull, 2, INLINEFUNC_coalesce, SQLITE_FUNC_COALESCE), + FUNCTION2(ifnull, 2, 0, 0, noopFunc, SQLITE_FUNC_COALESCE), VFUNCTION(random, 0, 0, 0, randomFunc ), VFUNCTION(randomblob, 1, 0, 0, randomBlob ), FUNCTION(nullif, 2, 0, 1, nullifFunc ), @@ -117633,7 +115937,7 @@ SQLITE_PRIVATE void sqlite3RegisterBuiltinFunctions(void){ #endif FUNCTION(coalesce, 1, 0, 0, 0 ), FUNCTION(coalesce, 0, 0, 0, 0 ), - INLINE_FUNC(coalesce, -1, INLINEFUNC_coalesce, SQLITE_FUNC_COALESCE), + FUNCTION2(coalesce, -1, 0, 0, noopFunc, SQLITE_FUNC_COALESCE), }; #ifndef SQLITE_OMIT_ALTERTABLE sqlite3AlterFunctions(); @@ -118012,7 +116316,7 @@ static void fkLookupParent( VdbeCoverage(v); } for(i=0; inCol; i++){ - int iReg = sqlite3TableColumnToStorage(pFKey->pFrom,aiCol[i]) + regData + 1; + int iReg = aiCol[i] + regData + 1; sqlite3VdbeAddOp2(v, OP_IsNull, iReg, iOk); VdbeCoverage(v); } @@ -118028,8 +116332,7 @@ static void fkLookupParent( ** is no matching parent key. Before using MustBeInt, make a copy of ** the value. Otherwise, the value inserted into the child key column ** will have INTEGER affinity applied to it, which may not be correct. */ - sqlite3VdbeAddOp2(v, OP_SCopy, - sqlite3TableColumnToStorage(pFKey->pFrom,aiCol[0])+1+regData, regTemp); + sqlite3VdbeAddOp2(v, OP_SCopy, aiCol[0]+1+regData, regTemp); iMustBeInt = sqlite3VdbeAddOp2(v, OP_MustBeInt, regTemp, 0); VdbeCoverage(v); @@ -118056,9 +116359,7 @@ static void fkLookupParent( sqlite3VdbeAddOp3(v, OP_OpenRead, iCur, pIdx->tnum, iDb); sqlite3VdbeSetP4KeyInfo(pParse, pIdx); for(i=0; ipFrom, aiCol[i])+1+regData, - regTemp+i); + sqlite3VdbeAddOp2(v, OP_Copy, aiCol[i]+1+regData, regTemp+i); } /* If the parent table is the same as the child table, and we are about @@ -118074,11 +116375,8 @@ static void fkLookupParent( if( pTab==pFKey->pFrom && nIncr==1 ){ int iJump = sqlite3VdbeCurrentAddr(v) + nCol + 1; for(i=0; ipFrom,aiCol[i]) - +1+regData; - int iParent = 1+regData; - iParent += sqlite3TableColumnToStorage(pIdx->pTable, - pIdx->aiColumn[i]); + int iChild = aiCol[i]+1+regData; + int iParent = pIdx->aiColumn[i]+1+regData; assert( pIdx->aiColumn[i]>=0 ); assert( aiCol[i]!=pTab->iPKey ); if( pIdx->aiColumn[i]==pTab->iPKey ){ @@ -118146,7 +116444,7 @@ static Expr *exprTableRegister( if( pExpr ){ if( iCol>=0 && iCol!=pTab->iPKey ){ pCol = &pTab->aCol[iCol]; - pExpr->iTable = regBase + sqlite3TableColumnToStorage(pTab,iCol) + 1; + pExpr->iTable = regBase + iCol + 1; pExpr->affExpr = pCol->affinity; zColl = pCol->zColl; if( zColl==0 ) zColl = db->pDfltColl->zName; @@ -118595,9 +116893,7 @@ SQLITE_PRIVATE void sqlite3FkCheck( Vdbe *v = sqlite3GetVdbe(pParse); int iJump = sqlite3VdbeCurrentAddr(v) + pFKey->nCol + 1; for(i=0; inCol; i++){ - int iFromCol, iReg; - iFromCol = pFKey->aCol[i].iFrom; - iReg = sqlite3TableColumnToStorage(pFKey->pFrom,iFromCol) + regOld+1; + int iReg = pFKey->aCol[i].iFrom + regOld + 1; sqlite3VdbeAddOp2(v, OP_IsNull, iReg, iJump); VdbeCoverage(v); } sqlite3VdbeAddOp2(v, OP_FkCounter, pFKey->isDeferred, -1); @@ -118932,15 +117228,7 @@ static Trigger *fkActionTrigger( sqlite3ExprAlloc(db, TK_ID, &tNew, 0), sqlite3ExprAlloc(db, TK_ID, &tToCol, 0)); }else if( action==OE_SetDflt ){ - Column *pCol = pFKey->pFrom->aCol + iFromCol; - Expr *pDflt; - if( pCol->colFlags & COLFLAG_GENERATED ){ - testcase( pCol->colFlags & COLFLAG_VIRTUAL ); - testcase( pCol->colFlags & COLFLAG_STORED ); - pDflt = 0; - }else{ - pDflt = pCol->pDflt; - } + Expr *pDflt = pFKey->pFrom->aCol[iFromCol].pDflt; if( pDflt ){ pNew = sqlite3ExprDup(db, pDflt, 0); }else{ @@ -118978,7 +117266,7 @@ static Trigger *fkActionTrigger( } /* Disable lookaside memory allocation */ - DisableLookaside; + db->lookaside.bDisable++; pTrigger = (Trigger *)sqlite3DbMallocZero(db, sizeof(Trigger) + /* struct Trigger */ @@ -119000,7 +117288,7 @@ static Trigger *fkActionTrigger( } /* Re-enable the lookaside buffer, if it was disabled earlier. */ - EnableLookaside; + db->lookaside.bDisable--; sqlite3ExprDelete(db, pWhere); sqlite3ExprDelete(db, pWhen); @@ -119151,7 +117439,7 @@ SQLITE_PRIVATE void sqlite3OpenTable( sqlite3TableLock(pParse, iDb, pTab->tnum, (opcode==OP_OpenWrite)?1:0, pTab->zName); if( HasRowid(pTab) ){ - sqlite3VdbeAddOp4Int(v, opcode, iCur, pTab->tnum, iDb, pTab->nNVCol); + sqlite3VdbeAddOp4Int(v, opcode, iCur, pTab->tnum, iDb, pTab->nCol); VdbeComment((v, "%s", pTab->zName)); }else{ Index *pPk = sqlite3PrimaryKeyIndex(pTab); @@ -119243,7 +117531,7 @@ SQLITE_PRIVATE const char *sqlite3IndexAffinityStr(sqlite3 *db, Index *pIdx){ ** 'E' REAL */ SQLITE_PRIVATE void sqlite3TableAffinity(Vdbe *v, Table *pTab, int iReg){ - int i, j; + int i; char *zColAff = pTab->zColAff; if( zColAff==0 ){ sqlite3 *db = sqlite3VdbeDb(v); @@ -119253,15 +117541,13 @@ SQLITE_PRIVATE void sqlite3TableAffinity(Vdbe *v, Table *pTab, int iReg){ return; } - for(i=j=0; inCol; i++){ + for(i=0; inCol; i++){ assert( pTab->aCol[i].affinity!=0 ); - if( (pTab->aCol[i].colFlags & COLFLAG_VIRTUAL)==0 ){ - zColAff[j++] = pTab->aCol[i].affinity; - } + zColAff[i] = pTab->aCol[i].affinity; } do{ - zColAff[j--] = 0; - }while( j>=0 && zColAff[j]<=SQLITE_AFF_BLOB ); + zColAff[i--] = 0; + }while( i>=0 && zColAff[i]<=SQLITE_AFF_BLOB ); pTab->zColAff = zColAff; } assert( zColAff!=0 ); @@ -119315,119 +117601,6 @@ static int readsTable(Parse *p, int iDb, Table *pTab){ return 0; } -/* This walker callback will compute the union of colFlags flags for all -** referenced columns in a CHECK constraint or generated column expression. -*/ -static int exprColumnFlagUnion(Walker *pWalker, Expr *pExpr){ - if( pExpr->op==TK_COLUMN && pExpr->iColumn>=0 ){ - assert( pExpr->iColumn < pWalker->u.pTab->nCol ); - pWalker->eCode |= pWalker->u.pTab->aCol[pExpr->iColumn].colFlags; - } - return WRC_Continue; -} - -#ifndef SQLITE_OMIT_GENERATED_COLUMNS -/* -** All regular columns for table pTab have been puts into registers -** starting with iRegStore. The registers that correspond to STORED -** or VIRTUAL columns have not yet been initialized. This routine goes -** back and computes the values for those columns based on the previously -** computed normal columns. -*/ -SQLITE_PRIVATE void sqlite3ComputeGeneratedColumns( - Parse *pParse, /* Parsing context */ - int iRegStore, /* Register holding the first column */ - Table *pTab /* The table */ -){ - int i; - Walker w; - Column *pRedo; - int eProgress; - VdbeOp *pOp; - - assert( pTab->tabFlags & TF_HasGenerated ); - testcase( pTab->tabFlags & TF_HasVirtual ); - testcase( pTab->tabFlags & TF_HasStored ); - - /* Before computing generated columns, first go through and make sure - ** that appropriate affinity has been applied to the regular columns - */ - sqlite3TableAffinity(pParse->pVdbe, pTab, iRegStore); - if( (pTab->tabFlags & TF_HasStored)!=0 - && (pOp = sqlite3VdbeGetOp(pParse->pVdbe,-1))->opcode==OP_Affinity - ){ - /* Change the OP_Affinity argument to '@' (NONE) for all stored - ** columns. '@' is the no-op affinity and those columns have not - ** yet been computed. */ - int ii, jj; - char *zP4 = pOp->p4.z; - assert( zP4!=0 ); - assert( pOp->p4type==P4_DYNAMIC ); - for(ii=jj=0; zP4[jj]; ii++){ - if( pTab->aCol[ii].colFlags & COLFLAG_VIRTUAL ){ - continue; - } - if( pTab->aCol[ii].colFlags & COLFLAG_STORED ){ - zP4[jj] = SQLITE_AFF_NONE; - } - jj++; - } - } - - /* Because there can be multiple generated columns that refer to one another, - ** this is a two-pass algorithm. On the first pass, mark all generated - ** columns as "not available". - */ - for(i=0; inCol; i++){ - if( pTab->aCol[i].colFlags & COLFLAG_GENERATED ){ - testcase( pTab->aCol[i].colFlags & COLFLAG_VIRTUAL ); - testcase( pTab->aCol[i].colFlags & COLFLAG_STORED ); - pTab->aCol[i].colFlags |= COLFLAG_NOTAVAIL; - } - } - - w.u.pTab = pTab; - w.xExprCallback = exprColumnFlagUnion; - w.xSelectCallback = 0; - w.xSelectCallback2 = 0; - - /* On the second pass, compute the value of each NOT-AVAILABLE column. - ** Companion code in the TK_COLUMN case of sqlite3ExprCodeTarget() will - ** compute dependencies and mark remove the COLSPAN_NOTAVAIL mark, as - ** they are needed. - */ - pParse->iSelfTab = -iRegStore; - do{ - eProgress = 0; - pRedo = 0; - for(i=0; inCol; i++){ - Column *pCol = pTab->aCol + i; - if( (pCol->colFlags & COLFLAG_NOTAVAIL)!=0 ){ - int x; - pCol->colFlags |= COLFLAG_BUSY; - w.eCode = 0; - sqlite3WalkExpr(&w, pCol->pDflt); - pCol->colFlags &= ~COLFLAG_BUSY; - if( w.eCode & COLFLAG_NOTAVAIL ){ - pRedo = pCol; - continue; - } - eProgress = 1; - assert( pCol->colFlags & COLFLAG_GENERATED ); - x = sqlite3TableColumnToStorage(pTab, i) + iRegStore; - sqlite3ExprCodeGeneratedColumn(pParse, pCol, x); - pCol->colFlags &= ~COLFLAG_NOTAVAIL; - } - } - }while( pRedo && eProgress ); - if( pRedo ){ - sqlite3ErrorMsg(pParse, "generated column loop on \"%s\"", pRedo->zName); - } - pParse->iSelfTab = 0; -} -#endif /* SQLITE_OMIT_GENERATED_COLUMNS */ - - #ifndef SQLITE_OMIT_AUTOINCREMENT /* ** Locate or create an AutoincInfo structure associated with table pTab @@ -119735,7 +117908,7 @@ SQLITE_PRIVATE void sqlite3Insert( Parse *pParse, /* Parser context */ SrcList *pTabList, /* Name of table into which we are inserting */ Select *pSelect, /* A SELECT statement to use as the data source */ - IdList *pColumn, /* Column names corresponding to IDLIST, or NULL. */ + IdList *pColumn, /* Column names corresponding to IDLIST. */ int onError, /* How to handle constraint errors */ Upsert *pUpsert /* ON CONFLICT clauses for upsert, or NULL */ ){ @@ -119760,7 +117933,6 @@ SQLITE_PRIVATE void sqlite3Insert( u8 withoutRowid; /* 0 for normal table. 1 for WITHOUT ROWID table */ u8 bIdListInOrder; /* True if IDLIST is in table order */ ExprList *pList = 0; /* List of VALUES() to be inserted */ - int iRegStore; /* Register in which to store next column */ /* Register allocations */ int regFromSelect = 0;/* Base register for data coming from SELECT */ @@ -119868,8 +118040,8 @@ SQLITE_PRIVATE void sqlite3Insert( */ regAutoinc = autoIncBegin(pParse, iDb, pTab); - /* Allocate a block registers to hold the rowid and the values - ** for all columns of the new row. + /* Allocate registers for holding the rowid of the new row, + ** the content of the new row, and the assembled row record. */ regRowid = regIns = pParse->nMem+1; pParse->nMem += pTab->nCol + 1; @@ -119888,17 +118060,9 @@ SQLITE_PRIVATE void sqlite3Insert( ** the index into IDLIST of the primary key column. ipkColumn is ** the index of the primary key as it appears in IDLIST, not as ** is appears in the original table. (The index of the INTEGER - ** PRIMARY KEY in the original table is pTab->iPKey.) After this - ** loop, if ipkColumn==(-1), that means that integer primary key - ** is unspecified, and hence the table is either WITHOUT ROWID or - ** it will automatically generated an integer primary key. - ** - ** bIdListInOrder is true if the columns in IDLIST are in storage - ** order. This enables an optimization that avoids shuffling the - ** columns into storage order. False negatives are harmless, - ** but false positives will cause database corruption. + ** PRIMARY KEY in the original table is pTab->iPKey.) */ - bIdListInOrder = (pTab->tabFlags & (TF_OOOHidden|TF_HasStored))==0; + bIdListInOrder = (pTab->tabFlags & TF_OOOHidden)==0; if( pColumn ){ for(i=0; inId; i++){ pColumn->a[i].idx = -1; @@ -119911,14 +118075,6 @@ SQLITE_PRIVATE void sqlite3Insert( if( j==pTab->iPKey ){ ipkColumn = i; assert( !withoutRowid ); } -#ifndef SQLITE_OMIT_GENERATED_COLUMNS - if( pTab->aCol[j].colFlags & (COLFLAG_STORED|COLFLAG_VIRTUAL) ){ - sqlite3ErrorMsg(pParse, - "cannot INSERT into generated column \"%s\"", - pTab->aCol[j].zName); - goto insert_cleanup; - } -#endif break; } } @@ -120028,26 +118184,13 @@ SQLITE_PRIVATE void sqlite3Insert( */ if( pColumn==0 && nColumn>0 ){ ipkColumn = pTab->iPKey; -#ifndef SQLITE_OMIT_GENERATED_COLUMNS - if( ipkColumn>=0 && (pTab->tabFlags & TF_HasGenerated)!=0 ){ - testcase( pTab->tabFlags & TF_HasVirtual ); - testcase( pTab->tabFlags & TF_HasStored ); - for(i=ipkColumn-1; i>=0; i--){ - if( pTab->aCol[i].colFlags & COLFLAG_GENERATED ){ - testcase( pTab->aCol[i].colFlags & COLFLAG_VIRTUAL ); - testcase( pTab->aCol[i].colFlags & COLFLAG_STORED ); - ipkColumn--; - } - } - } -#endif } /* Make sure the number of columns in the source data matches the number ** of columns to be inserted into the table. */ for(i=0; inCol; i++){ - if( pTab->aCol[i].colFlags & COLFLAG_NOINSERT ) nHidden++; + nHidden += (IsHiddenColumn(&pTab->aCol[i]) ? 1 : 0); } if( pColumn==0 && nColumn && nColumn!=(pTab->nCol-nHidden) ){ sqlite3ErrorMsg(pParse, @@ -120093,10 +118236,6 @@ SQLITE_PRIVATE void sqlite3Insert( pTab->zName); goto insert_cleanup; } - if( pTab->pSelect ){ - sqlite3ErrorMsg(pParse, "cannot UPSERT a view"); - goto insert_cleanup; - } if( sqlite3HasExplicitNulls(pParse, pUpsert->pUpsertTarget) ){ goto insert_cleanup; } @@ -120134,91 +118273,10 @@ SQLITE_PRIVATE void sqlite3Insert( ** goto C ** D: ... */ - sqlite3VdbeReleaseRegisters(pParse, regData, pTab->nCol, 0, 0); addrInsTop = addrCont = sqlite3VdbeAddOp1(v, OP_Yield, dest.iSDParm); VdbeCoverage(v); - if( ipkColumn>=0 ){ - /* tag-20191021-001: If the INTEGER PRIMARY KEY is being generated by the - ** SELECT, go ahead and copy the value into the rowid slot now, so that - ** the value does not get overwritten by a NULL at tag-20191021-002. */ - sqlite3VdbeAddOp2(v, OP_Copy, regFromSelect+ipkColumn, regRowid); - } } - /* Compute data for ordinary columns of the new entry. Values - ** are written in storage order into registers starting with regData. - ** Only ordinary columns are computed in this loop. The rowid - ** (if there is one) is computed later and generated columns are - ** computed after the rowid since they might depend on the value - ** of the rowid. - */ - nHidden = 0; - iRegStore = regData; assert( regData==regRowid+1 ); - for(i=0; inCol; i++, iRegStore++){ - int k; - u32 colFlags; - assert( i>=nHidden ); - if( i==pTab->iPKey ){ - /* tag-20191021-002: References to the INTEGER PRIMARY KEY are filled - ** using the rowid. So put a NULL in the IPK slot of the record to avoid - ** using excess space. The file format definition requires this extra - ** NULL - we cannot optimize further by skipping the column completely */ - sqlite3VdbeAddOp1(v, OP_SoftNull, iRegStore); - continue; - } - if( ((colFlags = pTab->aCol[i].colFlags) & COLFLAG_NOINSERT)!=0 ){ - nHidden++; - if( (colFlags & COLFLAG_VIRTUAL)!=0 ){ - /* Virtual columns do not participate in OP_MakeRecord. So back up - ** iRegStore by one slot to compensate for the iRegStore++ in the - ** outer for() loop */ - iRegStore--; - continue; - }else if( (colFlags & COLFLAG_STORED)!=0 ){ - /* Stored columns are computed later. But if there are BEFORE - ** triggers, the slots used for stored columns will be OP_Copy-ed - ** to a second block of registers, so the register needs to be - ** initialized to NULL to avoid an uninitialized register read */ - if( tmask & TRIGGER_BEFORE ){ - sqlite3VdbeAddOp1(v, OP_SoftNull, iRegStore); - } - continue; - }else if( pColumn==0 ){ - /* Hidden columns that are not explicitly named in the INSERT - ** get there default value */ - sqlite3ExprCodeFactorable(pParse, pTab->aCol[i].pDflt, iRegStore); - continue; - } - } - if( pColumn ){ - for(j=0; jnId && pColumn->a[j].idx!=i; j++){} - if( j>=pColumn->nId ){ - /* A column not named in the insert column list gets its - ** default value */ - sqlite3ExprCodeFactorable(pParse, pTab->aCol[i].pDflt, iRegStore); - continue; - } - k = j; - }else if( nColumn==0 ){ - /* This is INSERT INTO ... DEFAULT VALUES. Load the default value. */ - sqlite3ExprCodeFactorable(pParse, pTab->aCol[i].pDflt, iRegStore); - continue; - }else{ - k = i - nHidden; - } - - if( useTempTable ){ - sqlite3VdbeAddOp3(v, OP_Column, srcTab, k, iRegStore); - }else if( pSelect ){ - if( regFromSelect!=regData ){ - sqlite3VdbeAddOp2(v, OP_SCopy, regFromSelect+k, iRegStore); - } - }else{ - sqlite3ExprCode(pParse, pList->a[k].pExpr, iRegStore); - } - } - - /* Run the BEFORE and INSTEAD OF triggers, if there are any */ endOfLoop = sqlite3VdbeMakeLabel(pParse); @@ -120253,21 +118311,25 @@ SQLITE_PRIVATE void sqlite3Insert( */ assert( !IsVirtual(pTab) ); - /* Copy the new data already generated. */ - assert( pTab->nNVCol>0 ); - sqlite3VdbeAddOp3(v, OP_Copy, regRowid+1, regCols+1, pTab->nNVCol-1); - -#ifndef SQLITE_OMIT_GENERATED_COLUMNS - /* Compute the new value for generated columns after all other - ** columns have already been computed. This must be done after - ** computing the ROWID in case one of the generated columns - ** refers to the ROWID. */ - if( pTab->tabFlags & TF_HasGenerated ){ - testcase( pTab->tabFlags & TF_HasVirtual ); - testcase( pTab->tabFlags & TF_HasStored ); - sqlite3ComputeGeneratedColumns(pParse, regCols+1, pTab); + /* Create the new column data + */ + for(i=j=0; inCol; i++){ + if( pColumn ){ + for(j=0; jnId; j++){ + if( pColumn->a[j].idx==i ) break; + } + } + if( (!useTempTable && !pList) || (pColumn && j>=pColumn->nId) + || (pColumn==0 && IsOrdinaryHiddenColumn(&pTab->aCol[i])) ){ + sqlite3ExprCode(pParse, pTab->aCol[i].pDflt, regCols+i+1); + }else if( useTempTable ){ + sqlite3VdbeAddOp3(v, OP_Column, srcTab, j, regCols+i+1); + }else{ + assert( pSelect==0 ); /* Otherwise useTempTable is true */ + sqlite3ExprCodeAndCache(pParse, pList->a[j].pExpr, regCols+i+1); + } + if( pColumn==0 && !IsOrdinaryHiddenColumn(&pTab->aCol[i]) ) j++; } -#endif /* If this is an INSERT on a view with an INSTEAD OF INSERT trigger, ** do not attempt any conversions before assembling the record. @@ -120285,17 +118347,19 @@ SQLITE_PRIVATE void sqlite3Insert( sqlite3ReleaseTempRange(pParse, regCols, pTab->nCol+1); } + /* Compute the content of the next row to insert into a range of + ** registers beginning at regIns. + */ if( !isView ){ if( IsVirtual(pTab) ){ /* The row that the VUpdate opcode will delete: none */ sqlite3VdbeAddOp2(v, OP_Null, 0, regIns); } if( ipkColumn>=0 ){ - /* Compute the new rowid */ if( useTempTable ){ sqlite3VdbeAddOp3(v, OP_Column, srcTab, ipkColumn, regRowid); }else if( pSelect ){ - /* Rowid already initialized at tag-20191021-001 */ + sqlite3VdbeAddOp2(v, OP_Copy, regFromSelect+ipkColumn, regRowid); }else{ Expr *pIpk = pList->a[ipkColumn].pExpr; if( pIpk->op==TK_NULL && !IsVirtual(pTab) ){ @@ -120328,15 +118392,45 @@ SQLITE_PRIVATE void sqlite3Insert( } autoIncStep(pParse, regAutoinc, regRowid); -#ifndef SQLITE_OMIT_GENERATED_COLUMNS - /* Compute the new value for generated columns after all other - ** columns have already been computed. This must be done after - ** computing the ROWID in case one of the generated columns - ** is derived from the INTEGER PRIMARY KEY. */ - if( pTab->tabFlags & TF_HasGenerated ){ - sqlite3ComputeGeneratedColumns(pParse, regRowid+1, pTab); + /* Compute data for all columns of the new entry, beginning + ** with the first column. + */ + nHidden = 0; + for(i=0; inCol; i++){ + int iRegStore = regRowid+1+i; + if( i==pTab->iPKey ){ + /* The value of the INTEGER PRIMARY KEY column is always a NULL. + ** Whenever this column is read, the rowid will be substituted + ** in its place. Hence, fill this column with a NULL to avoid + ** taking up data space with information that will never be used. + ** As there may be shallow copies of this value, make it a soft-NULL */ + sqlite3VdbeAddOp1(v, OP_SoftNull, iRegStore); + continue; + } + if( pColumn==0 ){ + if( IsHiddenColumn(&pTab->aCol[i]) ){ + j = -1; + nHidden++; + }else{ + j = i - nHidden; + } + }else{ + for(j=0; jnId; j++){ + if( pColumn->a[j].idx==i ) break; + } + } + if( j<0 || nColumn==0 || (pColumn && j>=pColumn->nId) ){ + sqlite3ExprCodeFactorable(pParse, pTab->aCol[i].pDflt, iRegStore); + }else if( useTempTable ){ + sqlite3VdbeAddOp3(v, OP_Column, srcTab, j, iRegStore); + }else if( pSelect ){ + if( regFromSelect!=regData ){ + sqlite3VdbeAddOp2(v, OP_SCopy, regFromSelect+j, iRegStore); + } + }else{ + sqlite3ExprCode(pParse, pList->a[j].pExpr, iRegStore); + } } -#endif /* Generate code to check constraints and generate index keys and ** do the insertion. @@ -120366,7 +118460,9 @@ SQLITE_PRIVATE void sqlite3Insert( ** cursor that is disturbed. And these instructions both clear the ** VdbeCursor.seekResult variable, disabling the OPFLAG_USESEEKRESULT ** functionality. */ - bUseSeek = (isReplace==0 || !sqlite3VdbeHasSubProgram(v)); + bUseSeek = (isReplace==0 || (pTrigger==0 && + ((db->flags & SQLITE_ForeignKeys)==0 || sqlite3FkReferences(pTab)==0) + )); sqlite3CompleteInsertion(pParse, pTab, iDataCur, iIdxCur, regIns, aRegIdx, 0, appendFlag, bUseSeek ); @@ -120395,15 +118491,6 @@ SQLITE_PRIVATE void sqlite3Insert( sqlite3VdbeAddOp1(v, OP_Close, srcTab); }else if( pSelect ){ sqlite3VdbeGoto(v, addrCont); -#ifdef SQLITE_DEBUG - /* If we are jumping back to an OP_Yield that is preceded by an - ** OP_ReleaseReg, set the p5 flag on the OP_Goto so that the - ** OP_ReleaseReg will be included in the loop. */ - if( sqlite3VdbeGetOp(v, addrCont-1)->opcode==OP_ReleaseReg ){ - assert( sqlite3VdbeGetOp(v, addrCont)->opcode==OP_Yield ); - sqlite3VdbeChangeP5(v, 1); - } -#endif sqlite3VdbeJumpHere(v, addrInsTop); } @@ -120626,6 +118713,7 @@ SQLITE_PRIVATE void sqlite3GenerateConstraintChecks( int ix; /* Index loop counter */ int nCol; /* Number of columns */ int onError; /* Conflict resolution strategy */ + int addr1; /* Address of jump instruction */ int seenReplace = 0; /* True if REPLACE is used to resolve INT PK conflict */ int nPkField; /* Number of fields in PRIMARY KEY. 1 for ROWID tables */ Index *pUpIdx = 0; /* Index to which to apply the upsert */ @@ -120635,13 +118723,6 @@ SQLITE_PRIVATE void sqlite3GenerateConstraintChecks( int upsertJump = 0; /* Address of Goto that jumps into upsert subroutine */ int ipkTop = 0; /* Top of the IPK uniqueness check */ int ipkBottom = 0; /* OP_Goto at the end of the IPK uniqueness check */ - /* Variables associated with retesting uniqueness constraints after - ** replace triggers fire have run */ - int regTrigCnt; /* Register used to count replace trigger invocations */ - int addrRecheck = 0; /* Jump here to recheck all uniqueness constraints */ - int lblRecheckOk = 0; /* Each recheck jumps to this label if it passes */ - Trigger *pTrigger; /* List of DELETE triggers on the table pTab */ - int nReplaceTrig = 0; /* Number of replace triggers coded */ isUpdate = regOldData!=0; db = pParse->db; @@ -120668,103 +118749,63 @@ SQLITE_PRIVATE void sqlite3GenerateConstraintChecks( /* Test all NOT NULL constraints. */ - if( pTab->tabFlags & TF_HasNotNull ){ - int b2ndPass = 0; /* True if currently running 2nd pass */ - int nSeenReplace = 0; /* Number of ON CONFLICT REPLACE operations */ - int nGenerated = 0; /* Number of generated columns with NOT NULL */ - while(1){ /* Make 2 passes over columns. Exit loop via "break" */ - for(i=0; iaCol[i]; /* The column to check for NOT NULL */ - int isGenerated; /* non-zero if column is generated */ - onError = pCol->notNull; - if( onError==OE_None ) continue; /* No NOT NULL on this column */ - if( i==pTab->iPKey ){ - continue; /* ROWID is never NULL */ - } - isGenerated = pCol->colFlags & COLFLAG_GENERATED; - if( isGenerated && !b2ndPass ){ - nGenerated++; - continue; /* Generated columns processed on 2nd pass */ - } - if( aiChng && aiChng[i]<0 && !isGenerated ){ - /* Do not check NOT NULL on columns that do not change */ - continue; - } - if( overrideError!=OE_Default ){ - onError = overrideError; - }else if( onError==OE_Default ){ - onError = OE_Abort; - } - if( onError==OE_Replace ){ - if( b2ndPass /* REPLACE becomes ABORT on the 2nd pass */ - || pCol->pDflt==0 /* REPLACE is ABORT if no DEFAULT value */ - ){ - testcase( pCol->colFlags & COLFLAG_VIRTUAL ); - testcase( pCol->colFlags & COLFLAG_STORED ); - testcase( pCol->colFlags & COLFLAG_GENERATED ); - onError = OE_Abort; - }else{ - assert( !isGenerated ); - } - }else if( b2ndPass && !isGenerated ){ - continue; - } - assert( onError==OE_Rollback || onError==OE_Abort || onError==OE_Fail - || onError==OE_Ignore || onError==OE_Replace ); - testcase( i!=sqlite3TableColumnToStorage(pTab, i) ); - iReg = sqlite3TableColumnToStorage(pTab, i) + regNewData + 1; - switch( onError ){ - case OE_Replace: { - int addr1 = sqlite3VdbeAddOp1(v, OP_NotNull, iReg); - VdbeCoverage(v); - assert( (pCol->colFlags & COLFLAG_GENERATED)==0 ); - nSeenReplace++; - sqlite3ExprCode(pParse, pCol->pDflt, iReg); - sqlite3VdbeJumpHere(v, addr1); - break; - } - case OE_Abort: - sqlite3MayAbort(pParse); - /* Fall through */ - case OE_Rollback: - case OE_Fail: { - char *zMsg = sqlite3MPrintf(db, "%s.%s", pTab->zName, - pCol->zName); - sqlite3VdbeAddOp3(v, OP_HaltIfNull, SQLITE_CONSTRAINT_NOTNULL, - onError, iReg); - sqlite3VdbeAppendP4(v, zMsg, P4_DYNAMIC); - sqlite3VdbeChangeP5(v, P5_ConstraintNotNull); - VdbeCoverage(v); - break; - } - default: { - assert( onError==OE_Ignore ); - sqlite3VdbeAddOp2(v, OP_IsNull, iReg, ignoreDest); - VdbeCoverage(v); - break; - } - } /* end switch(onError) */ - } /* end loop i over columns */ - if( nGenerated==0 && nSeenReplace==0 ){ - /* If there are no generated columns with NOT NULL constraints - ** and no NOT NULL ON CONFLICT REPLACE constraints, then a single - ** pass is sufficient */ + for(i=0; iiPKey ){ + continue; /* ROWID is never NULL */ + } + if( aiChng && aiChng[i]<0 ){ + /* Don't bother checking for NOT NULL on columns that do not change */ + continue; + } + onError = pTab->aCol[i].notNull; + if( onError==OE_None ) continue; /* This column is allowed to be NULL */ + if( overrideError!=OE_Default ){ + onError = overrideError; + }else if( onError==OE_Default ){ + onError = OE_Abort; + } + if( onError==OE_Replace && pTab->aCol[i].pDflt==0 ){ + onError = OE_Abort; + } + assert( onError==OE_Rollback || onError==OE_Abort || onError==OE_Fail + || onError==OE_Ignore || onError==OE_Replace ); + addr1 = 0; + switch( onError ){ + case OE_Replace: { + assert( onError==OE_Replace ); + addr1 = sqlite3VdbeMakeLabel(pParse); + sqlite3VdbeAddOp2(v, OP_NotNull, regNewData+1+i, addr1); + VdbeCoverage(v); + sqlite3ExprCode(pParse, pTab->aCol[i].pDflt, regNewData+1+i); + sqlite3VdbeAddOp2(v, OP_NotNull, regNewData+1+i, addr1); + VdbeCoverage(v); + onError = OE_Abort; + /* Fall through into the OE_Abort case to generate code that runs + ** if both the input and the default value are NULL */ + } + case OE_Abort: + sqlite3MayAbort(pParse); + /* Fall through */ + case OE_Rollback: + case OE_Fail: { + char *zMsg = sqlite3MPrintf(db, "%s.%s", pTab->zName, + pTab->aCol[i].zName); + sqlite3VdbeAddOp3(v, OP_HaltIfNull, SQLITE_CONSTRAINT_NOTNULL, onError, + regNewData+1+i); + sqlite3VdbeAppendP4(v, zMsg, P4_DYNAMIC); + sqlite3VdbeChangeP5(v, P5_ConstraintNotNull); + VdbeCoverage(v); + if( addr1 ) sqlite3VdbeResolveLabel(v, addr1); break; } - if( b2ndPass ) break; /* Never need more than 2 passes */ - b2ndPass = 1; -#ifndef SQLITE_OMIT_GENERATED_COLUMNS - if( nSeenReplace>0 && (pTab->tabFlags & TF_HasGenerated)!=0 ){ - /* If any NOT NULL ON CONFLICT REPLACE constraints fired on the - ** first pass, recomputed values for all generated columns, as - ** those values might depend on columns affected by the REPLACE. - */ - sqlite3ComputeGeneratedColumns(pParse, regNewData+1, pTab); + default: { + assert( onError==OE_Ignore ); + sqlite3VdbeAddOp2(v, OP_IsNull, regNewData+1+i, ignoreDest); + VdbeCoverage(v); + break; } -#endif - } /* end of 2-pass loop */ - } /* end if( has-not-null-constraints ) */ + } + } /* Test all CHECK constraints */ @@ -120789,7 +118830,7 @@ SQLITE_PRIVATE void sqlite3GenerateConstraintChecks( if( onError==OE_Ignore ){ sqlite3VdbeGoto(v, ignoreDest); }else{ - char *zName = pCheck->a[i].zEName; + char *zName = pCheck->a[i].zName; if( zName==0 ) zName = pTab->zName; if( onError==OE_Replace ) onError = OE_Abort; /* IMP: R-26383-51744 */ sqlite3HaltConstraint(pParse, SQLITE_CONSTRAINT_CHECK, @@ -120846,50 +118887,6 @@ SQLITE_PRIVATE void sqlite3GenerateConstraintChecks( } } - /* Determine if it is possible that triggers (either explicitly coded - ** triggers or FK resolution actions) might run as a result of deletes - ** that happen when OE_Replace conflict resolution occurs. (Call these - ** "replace triggers".) If any replace triggers run, we will need to - ** recheck all of the uniqueness constraints after they have all run. - ** But on the recheck, the resolution is OE_Abort instead of OE_Replace. - ** - ** If replace triggers are a possibility, then - ** - ** (1) Allocate register regTrigCnt and initialize it to zero. - ** That register will count the number of replace triggers that - ** fire. Constraint recheck only occurs if the number is positive. - ** (2) Initialize pTrigger to the list of all DELETE triggers on pTab. - ** (3) Initialize addrRecheck and lblRecheckOk - ** - ** The uniqueness rechecking code will create a series of tests to run - ** in a second pass. The addrRecheck and lblRecheckOk variables are - ** used to link together these tests which are separated from each other - ** in the generate bytecode. - */ - if( (db->flags & (SQLITE_RecTriggers|SQLITE_ForeignKeys))==0 ){ - /* There are not DELETE triggers nor FK constraints. No constraint - ** rechecks are needed. */ - pTrigger = 0; - regTrigCnt = 0; - }else{ - if( db->flags&SQLITE_RecTriggers ){ - pTrigger = sqlite3TriggersExist(pParse, pTab, TK_DELETE, 0, 0); - regTrigCnt = pTrigger!=0 || sqlite3FkRequired(pParse, pTab, 0, 0); - }else{ - pTrigger = 0; - regTrigCnt = sqlite3FkRequired(pParse, pTab, 0, 0); - } - if( regTrigCnt ){ - /* Replace triggers might exist. Allocate the counter and - ** initialize it to zero. */ - regTrigCnt = ++pParse->nMem; - sqlite3VdbeAddOp2(v, OP_Integer, 0, regTrigCnt); - VdbeComment((v, "trigger count")); - lblRecheckOk = sqlite3VdbeMakeLabel(pParse); - addrRecheck = lblRecheckOk; - } - } - /* If rowid is changing, make sure the new rowid does not previously ** exist in the table. */ @@ -120979,12 +118976,14 @@ SQLITE_PRIVATE void sqlite3GenerateConstraintChecks( ** to run without a statement journal if there are no indexes on the ** table. */ - if( regTrigCnt ){ + Trigger *pTrigger = 0; + if( db->flags&SQLITE_RecTriggers ){ + pTrigger = sqlite3TriggersExist(pParse, pTab, TK_DELETE, 0, 0); + } + if( pTrigger || sqlite3FkRequired(pParse, pTab, 0, 0) ){ sqlite3MultiWrite(pParse); sqlite3GenerateRowDelete(pParse, pTab, pTrigger, iDataCur, iIdxCur, regNewData, 1, 0, OE_Replace, 1, -1); - sqlite3VdbeAddOp2(v, OP_AddImm, regTrigCnt, 1); /* incr trigger cnt */ - nReplaceTrig++; }else{ #ifdef SQLITE_ENABLE_PREUPDATE_HOOK assert( HasRowid(pTab) ); @@ -121034,7 +119033,6 @@ SQLITE_PRIVATE void sqlite3GenerateConstraintChecks( int regR; /* Range of registers holding conflicting PK */ int iThisCur; /* Cursor for this UNIQUE index */ int addrUniqueOk; /* Jump here if the UNIQUE constraint is satisfied */ - int addrConflictCk; /* First opcode in the conflict check logic */ if( aRegIdx[ix]==0 ) continue; /* Skip indices that do not change */ if( pUpIdx==pIdx ){ @@ -121074,15 +119072,14 @@ SQLITE_PRIVATE void sqlite3GenerateConstraintChecks( sqlite3ExprCodeCopy(pParse, pIdx->aColExpr->a[i].pExpr, regIdx+i); pParse->iSelfTab = 0; VdbeComment((v, "%s column %d", pIdx->zName, i)); - }else if( iField==XN_ROWID || iField==pTab->iPKey ){ - x = regNewData; - sqlite3VdbeAddOp2(v, OP_IntCopy, x, regIdx+i); - VdbeComment((v, "rowid")); }else{ - testcase( sqlite3TableColumnToStorage(pTab, iField)!=iField ); - x = sqlite3TableColumnToStorage(pTab, iField) + regNewData + 1; - sqlite3VdbeAddOp2(v, OP_SCopy, x, regIdx+i); - VdbeComment((v, "%s", pTab->aCol[iField].zName)); + if( iField==XN_ROWID || iField==pTab->iPKey ){ + x = regNewData; + }else{ + x = iField + regNewData + 1; + } + sqlite3VdbeAddOp2(v, iField<0 ? OP_IntCopy : OP_SCopy, x, regIdx+i); + VdbeComment((v, "%s", iField<0 ? "rowid" : pTab->aCol[iField].zName)); } } sqlite3VdbeAddOp3(v, OP_MakeRecord, regIdx, pIdx->nColumn, aRegIdx[ix]); @@ -121092,7 +119089,6 @@ SQLITE_PRIVATE void sqlite3GenerateConstraintChecks( sqlite3SetMakeRecordP5(v, pIdx->pTable); } #endif - sqlite3VdbeReleaseRegisters(pParse, regIdx, pIdx->nColumn, 0, 0); /* In an UPDATE operation, if this index is the PRIMARY KEY index ** of a WITHOUT ROWID table and there has been no change the @@ -121150,9 +119146,8 @@ SQLITE_PRIVATE void sqlite3GenerateConstraintChecks( /* Check to see if the new index entry will be unique */ sqlite3VdbeVerifyAbortable(v, onError); - addrConflictCk = - sqlite3VdbeAddOp4Int(v, OP_NoConflict, iThisCur, addrUniqueOk, - regIdx, pIdx->nKeyCol); VdbeCoverage(v); + sqlite3VdbeAddOp4Int(v, OP_NoConflict, iThisCur, addrUniqueOk, + regIdx, pIdx->nKeyCol); VdbeCoverage(v); /* Generate code to handle collisions */ regR = (pIdx==pPk) ? regIdx : sqlite3GetTempRange(pParse, nPkField); @@ -121173,7 +119168,7 @@ SQLITE_PRIVATE void sqlite3GenerateConstraintChecks( if( pIdx!=pPk ){ for(i=0; inKeyCol; i++){ assert( pPk->aiColumn[i]>=0 ); - x = sqlite3TableColumnToIndex(pIdx, pPk->aiColumn[i]); + x = sqlite3ColumnOfIndex(pIdx, pPk->aiColumn[i]); sqlite3VdbeAddOp3(v, OP_Column, iThisCur, x, regR+i); VdbeComment((v, "%s.%s", pTab->zName, pTab->aCol[pPk->aiColumn[i]].zName)); @@ -121199,7 +119194,6 @@ SQLITE_PRIVATE void sqlite3GenerateConstraintChecks( addrJump = addrUniqueOk; op = OP_Eq; } - x = sqlite3TableColumnToStorage(pTab, x); sqlite3VdbeAddOp4(v, op, regOldData+1+x, addrJump, regCmp+i, p4, P4_COLLSEQ ); @@ -121236,71 +119230,17 @@ SQLITE_PRIVATE void sqlite3GenerateConstraintChecks( break; } default: { - int nConflictCk; /* Number of opcodes in conflict check logic */ - + Trigger *pTrigger = 0; assert( onError==OE_Replace ); - nConflictCk = sqlite3VdbeCurrentAddr(v) - addrConflictCk; - assert( nConflictCk>0 ); - testcase( nConflictCk>1 ); - if( regTrigCnt ){ - sqlite3MultiWrite(pParse); - nReplaceTrig++; + if( db->flags&SQLITE_RecTriggers ){ + pTrigger = sqlite3TriggersExist(pParse, pTab, TK_DELETE, 0, 0); } - if( pTrigger && isUpdate ){ - sqlite3VdbeAddOp1(v, OP_CursorLock, iDataCur); + if( pTrigger || sqlite3FkRequired(pParse, pTab, 0, 0) ){ + sqlite3MultiWrite(pParse); } sqlite3GenerateRowDelete(pParse, pTab, pTrigger, iDataCur, iIdxCur, regR, nPkField, 0, OE_Replace, (pIdx==pPk ? ONEPASS_SINGLE : ONEPASS_OFF), iThisCur); - if( pTrigger && isUpdate ){ - sqlite3VdbeAddOp1(v, OP_CursorUnlock, iDataCur); - } - if( regTrigCnt ){ - int addrBypass; /* Jump destination to bypass recheck logic */ - - sqlite3VdbeAddOp2(v, OP_AddImm, regTrigCnt, 1); /* incr trigger cnt */ - addrBypass = sqlite3VdbeAddOp0(v, OP_Goto); /* Bypass recheck */ - VdbeComment((v, "bypass recheck")); - - /* Here we insert code that will be invoked after all constraint - ** checks have run, if and only if one or more replace triggers - ** fired. */ - sqlite3VdbeResolveLabel(v, lblRecheckOk); - lblRecheckOk = sqlite3VdbeMakeLabel(pParse); - if( pIdx->pPartIdxWhere ){ - /* Bypass the recheck if this partial index is not defined - ** for the current row */ - sqlite3VdbeAddOp2(v, OP_IsNull, regIdx-1, lblRecheckOk); - VdbeCoverage(v); - } - /* Copy the constraint check code from above, except change - ** the constraint-ok jump destination to be the address of - ** the next retest block */ - while( nConflictCk>0 ){ - VdbeOp x; /* Conflict check opcode to copy */ - /* The sqlite3VdbeAddOp4() call might reallocate the opcode array. - ** Hence, make a complete copy of the opcode, rather than using - ** a pointer to the opcode. */ - x = *sqlite3VdbeGetOp(v, addrConflictCk); - if( x.opcode!=OP_IdxRowid ){ - int p2; /* New P2 value for copied conflict check opcode */ - if( sqlite3OpcodeProperty[x.opcode]&OPFLG_JUMP ){ - p2 = lblRecheckOk; - }else{ - p2 = x.p2; - } - sqlite3VdbeAddOp4(v, x.opcode, x.p1, p2, x.p3, x.p4.z, x.p4type); - sqlite3VdbeChangeP5(v, x.p5); - VdbeCoverageIf(v, p2!=x.p2); - } - nConflictCk--; - addrConflictCk++; - } - /* If the retest fails, issue an abort */ - sqlite3UniqueConstraint(pParse, OE_Abort, pIdx); - - sqlite3VdbeJumpHere(v, addrBypass); /* Terminate the recheck bypass */ - } seenReplace = 1; break; } @@ -121321,30 +119261,10 @@ SQLITE_PRIVATE void sqlite3GenerateConstraintChecks( sqlite3VdbeJumpHere(v, ipkBottom); } - /* Recheck all uniqueness constraints after replace triggers have run */ - testcase( regTrigCnt!=0 && nReplaceTrig==0 ); - assert( regTrigCnt!=0 || nReplaceTrig==0 ); - if( nReplaceTrig ){ - sqlite3VdbeAddOp2(v, OP_IfNot, regTrigCnt, lblRecheckOk);VdbeCoverage(v); - if( !pPk ){ - if( isUpdate ){ - sqlite3VdbeAddOp3(v, OP_Eq, regNewData, addrRecheck, regOldData); - sqlite3VdbeChangeP5(v, SQLITE_NOTNULL); - VdbeCoverage(v); - } - sqlite3VdbeAddOp3(v, OP_NotExists, iDataCur, addrRecheck, regNewData); - VdbeCoverage(v); - sqlite3RowidConstraint(pParse, OE_Abort, pTab); - }else{ - sqlite3VdbeGoto(v, addrRecheck); - } - sqlite3VdbeResolveLabel(v, lblRecheckOk); - } - /* Generate the table record */ if( HasRowid(pTab) ){ int regRec = aRegIdx[ix]; - sqlite3VdbeAddOp3(v, OP_MakeRecord, regNewData+1, pTab->nNVCol, regRec); + sqlite3VdbeAddOp3(v, OP_MakeRecord, regNewData+1, pTab->nCol, regRec); sqlite3SetMakeRecordP5(v, pTab); if( !bAffinityDone ){ sqlite3TableAffinity(v, pTab, 0); @@ -121411,10 +119331,6 @@ SQLITE_PRIVATE void sqlite3CompleteInsertion( assert( v!=0 ); assert( pTab->pSelect==0 ); /* This table is not a VIEW */ for(i=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, i++){ - /* All REPLACE indexes are at the end of the list */ - assert( pIdx->onError!=OE_Replace - || pIdx->pNext==0 - || pIdx->pNext->onError==OE_Replace ); if( aRegIdx[i]==0 ) continue; if( pIdx->pPartIdxWhere ){ sqlite3VdbeAddOp2(v, OP_IsNull, aRegIdx[i], sqlite3VdbeCurrentAddr(v)+2); @@ -121565,7 +119481,7 @@ static int xferCompatibleIndex(Index *pDest, Index *pSrc){ int i; assert( pDest && pSrc ); assert( pDest->pTable!=pSrc->pTable ); - if( pDest->nKeyCol!=pSrc->nKeyCol || pDest->nColumn!=pSrc->nColumn ){ + if( pDest->nKeyCol!=pSrc->nKeyCol ){ return 0; /* Different number of columns */ } if( pDest->onError!=pSrc->onError ){ @@ -121742,39 +119658,6 @@ static int xferOptimization( ){ return 0; /* Neither table may have __hidden__ columns */ } -#endif -#ifndef SQLITE_OMIT_GENERATED_COLUMNS - /* Even if tables t1 and t2 have identical schemas, if they contain - ** generated columns, then this statement is semantically incorrect: - ** - ** INSERT INTO t2 SELECT * FROM t1; - ** - ** The reason is that generated column values are returned by the - ** the SELECT statement on the right but the INSERT statement on the - ** left wants them to be omitted. - ** - ** Nevertheless, this is a useful notational shorthand to tell SQLite - ** to do a bulk transfer all of the content from t1 over to t2. - ** - ** We could, in theory, disable this (except for internal use by the - ** VACUUM command where it is actually needed). But why do that? It - ** seems harmless enough, and provides a useful service. - */ - if( (pDestCol->colFlags & COLFLAG_GENERATED) != - (pSrcCol->colFlags & COLFLAG_GENERATED) ){ - return 0; /* Both columns have the same generated-column type */ - } - /* But the transfer is only allowed if both the source and destination - ** tables have the exact same expressions for generated columns. - ** This requirement could be relaxed for VIRTUAL columns, I suppose. - */ - if( (pDestCol->colFlags & COLFLAG_GENERATED)!=0 ){ - if( sqlite3ExprCompare(0, pSrcCol->pDflt, pDestCol->pDflt, -1)!=0 ){ - testcase( pDestCol->colFlags & COLFLAG_VIRTUAL ); - testcase( pDestCol->colFlags & COLFLAG_STORED ); - return 0; /* Different generator expressions */ - } - } #endif if( pDestCol->affinity!=pSrcCol->affinity ){ return 0; /* Affinity must be the same on all columns */ @@ -121786,7 +119669,7 @@ static int xferOptimization( return 0; /* tab2 must be NOT NULL if tab1 is */ } /* Default values for second and subsequent columns need to match. */ - if( (pDestCol->colFlags & COLFLAG_GENERATED)==0 && i>0 ){ + if( i>0 ){ assert( pDestCol->pDflt==0 || pDestCol->pDflt->op==TK_SPAN ); assert( pSrcCol->pDflt==0 || pSrcCol->pDflt->op==TK_SPAN ); if( (pDestCol->pDflt==0)!=(pSrcCol->pDflt==0) @@ -122471,12 +120354,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*); }; /* @@ -122771,12 +120648,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) @@ -123249,12 +121120,6 @@ static const sqlite3_api_routines sqlite3Apis = { #else 0, #endif - /* Version 3.31.0 and later */ - sqlite3_hard_heap_limit64, - sqlite3_uri_key, - sqlite3_filename_database, - sqlite3_filename_journal, - sqlite3_filename_wal, }; /* @@ -123677,35 +121542,34 @@ SQLITE_PRIVATE void sqlite3AutoLoadExtensions(sqlite3 *db){ #define PragTyp_FOREIGN_KEY_CHECK 13 #define PragTyp_FOREIGN_KEY_LIST 14 #define PragTyp_FUNCTION_LIST 15 -#define PragTyp_HARD_HEAP_LIMIT 16 -#define PragTyp_INCREMENTAL_VACUUM 17 -#define PragTyp_INDEX_INFO 18 -#define PragTyp_INDEX_LIST 19 -#define PragTyp_INTEGRITY_CHECK 20 -#define PragTyp_JOURNAL_MODE 21 -#define PragTyp_JOURNAL_SIZE_LIMIT 22 -#define PragTyp_LOCK_PROXY_FILE 23 -#define PragTyp_LOCKING_MODE 24 -#define PragTyp_PAGE_COUNT 25 -#define PragTyp_MMAP_SIZE 26 -#define PragTyp_MODULE_LIST 27 -#define PragTyp_OPTIMIZE 28 -#define PragTyp_PAGE_SIZE 29 -#define PragTyp_PRAGMA_LIST 30 -#define PragTyp_SECURE_DELETE 31 -#define PragTyp_SHRINK_MEMORY 32 -#define PragTyp_SOFT_HEAP_LIMIT 33 -#define PragTyp_SYNCHRONOUS 34 -#define PragTyp_TABLE_INFO 35 -#define PragTyp_TEMP_STORE 36 -#define PragTyp_TEMP_STORE_DIRECTORY 37 -#define PragTyp_THREADS 38 -#define PragTyp_WAL_AUTOCHECKPOINT 39 -#define PragTyp_WAL_CHECKPOINT 40 -#define PragTyp_ACTIVATE_EXTENSIONS 41 -#define PragTyp_KEY 42 -#define PragTyp_LOCK_STATUS 43 -#define PragTyp_STATS 44 +#define PragTyp_INCREMENTAL_VACUUM 16 +#define PragTyp_INDEX_INFO 17 +#define PragTyp_INDEX_LIST 18 +#define PragTyp_INTEGRITY_CHECK 19 +#define PragTyp_JOURNAL_MODE 20 +#define PragTyp_JOURNAL_SIZE_LIMIT 21 +#define PragTyp_LOCK_PROXY_FILE 22 +#define PragTyp_LOCKING_MODE 23 +#define PragTyp_PAGE_COUNT 24 +#define PragTyp_MMAP_SIZE 25 +#define PragTyp_MODULE_LIST 26 +#define PragTyp_OPTIMIZE 27 +#define PragTyp_PAGE_SIZE 28 +#define PragTyp_PRAGMA_LIST 29 +#define PragTyp_SECURE_DELETE 30 +#define PragTyp_SHRINK_MEMORY 31 +#define PragTyp_SOFT_HEAP_LIMIT 32 +#define PragTyp_SYNCHRONOUS 33 +#define PragTyp_TABLE_INFO 34 +#define PragTyp_TEMP_STORE 35 +#define PragTyp_TEMP_STORE_DIRECTORY 36 +#define PragTyp_THREADS 37 +#define PragTyp_WAL_AUTOCHECKPOINT 38 +#define PragTyp_WAL_CHECKPOINT 39 +#define PragTyp_ACTIVATE_EXTENSIONS 40 +#define PragTyp_KEY 41 +#define PragTyp_LOCK_STATUS 42 +#define PragTyp_STATS 43 /* Property flags associated with various pragma. */ #define PragFlg_NeedSchema 0x01 /* Force schema load before running */ @@ -123744,39 +121608,35 @@ static const char *const pragCName[] = { /* 18 */ "desc", /* 19 */ "coll", /* 20 */ "key", - /* 21 */ "name", /* Used by: function_list */ - /* 22 */ "builtin", - /* 23 */ "type", - /* 24 */ "enc", - /* 25 */ "narg", - /* 26 */ "flags", - /* 27 */ "tbl", /* Used by: stats */ - /* 28 */ "idx", - /* 29 */ "wdth", - /* 30 */ "hght", - /* 31 */ "flgs", - /* 32 */ "seq", /* Used by: index_list */ - /* 33 */ "name", - /* 34 */ "unique", - /* 35 */ "origin", - /* 36 */ "partial", - /* 37 */ "table", /* Used by: foreign_key_check */ - /* 38 */ "rowid", - /* 39 */ "parent", - /* 40 */ "fkid", + /* 21 */ "tbl", /* Used by: stats */ + /* 22 */ "idx", + /* 23 */ "wdth", + /* 24 */ "hght", + /* 25 */ "flgs", + /* 26 */ "seq", /* Used by: index_list */ + /* 27 */ "name", + /* 28 */ "unique", + /* 29 */ "origin", + /* 30 */ "partial", + /* 31 */ "table", /* Used by: foreign_key_check */ + /* 32 */ "rowid", + /* 33 */ "parent", + /* 34 */ "fkid", /* index_info reuses 15 */ - /* 41 */ "seq", /* Used by: database_list */ - /* 42 */ "name", - /* 43 */ "file", - /* 44 */ "busy", /* Used by: wal_checkpoint */ - /* 45 */ "log", - /* 46 */ "checkpointed", - /* collation_list reuses 32 */ - /* 47 */ "database", /* Used by: lock_status */ - /* 48 */ "status", - /* 49 */ "cache_size", /* Used by: default_cache_size */ + /* 35 */ "seq", /* Used by: database_list */ + /* 36 */ "name", + /* 37 */ "file", + /* 38 */ "busy", /* Used by: wal_checkpoint */ + /* 39 */ "log", + /* 40 */ "checkpointed", + /* 41 */ "name", /* Used by: function_list */ + /* 42 */ "builtin", + /* collation_list reuses 26 */ + /* 43 */ "database", /* Used by: lock_status */ + /* 44 */ "status", + /* 45 */ "cache_size", /* Used by: default_cache_size */ /* module_list pragma_list reuses 9 */ - /* 50 */ "timeout", /* Used by: busy_timeout */ + /* 46 */ "timeout", /* Used by: busy_timeout */ }; /* Definitions of all built-in pragmas */ @@ -123822,7 +121682,7 @@ static const PragmaName aPragmaName[] = { {/* zName: */ "busy_timeout", /* ePragTyp: */ PragTyp_BUSY_TIMEOUT, /* ePragFlg: */ PragFlg_Result0, - /* ColNames: */ 50, 1, + /* ColNames: */ 46, 1, /* iArg: */ 0 }, #if !defined(SQLITE_OMIT_PAGER_PRAGMAS) {/* zName: */ "cache_size", @@ -123861,7 +121721,7 @@ static const PragmaName aPragmaName[] = { {/* zName: */ "collation_list", /* ePragTyp: */ PragTyp_COLLATION_LIST, /* ePragFlg: */ PragFlg_Result0, - /* ColNames: */ 32, 2, + /* ColNames: */ 26, 2, /* iArg: */ 0 }, #endif #if !defined(SQLITE_OMIT_COMPILEOPTION_DIAGS) @@ -123896,14 +121756,14 @@ static const PragmaName aPragmaName[] = { {/* zName: */ "database_list", /* ePragTyp: */ PragTyp_DATABASE_LIST, /* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result0, - /* ColNames: */ 41, 3, + /* ColNames: */ 35, 3, /* iArg: */ 0 }, #endif #if !defined(SQLITE_OMIT_PAGER_PRAGMAS) && !defined(SQLITE_OMIT_DEPRECATED) {/* zName: */ "default_cache_size", /* ePragTyp: */ PragTyp_DEFAULT_CACHE_SIZE, /* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result0|PragFlg_SchemaReq|PragFlg_NoColumns1, - /* ColNames: */ 49, 1, + /* ColNames: */ 45, 1, /* iArg: */ 0 }, #endif #if !defined(SQLITE_OMIT_FLAG_PRAGMAS) @@ -123933,7 +121793,7 @@ static const PragmaName aPragmaName[] = { {/* zName: */ "foreign_key_check", /* ePragTyp: */ PragTyp_FOREIGN_KEY_CHECK, /* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result0, - /* ColNames: */ 37, 4, + /* ColNames: */ 31, 4, /* iArg: */ 0 }, #endif #if !defined(SQLITE_OMIT_FOREIGN_KEY) @@ -123976,15 +121836,10 @@ static const PragmaName aPragmaName[] = { {/* zName: */ "function_list", /* ePragTyp: */ PragTyp_FUNCTION_LIST, /* ePragFlg: */ PragFlg_Result0, - /* ColNames: */ 21, 6, + /* ColNames: */ 41, 2, /* iArg: */ 0 }, #endif #endif - {/* zName: */ "hard_heap_limit", - /* ePragTyp: */ PragTyp_HARD_HEAP_LIMIT, - /* ePragFlg: */ PragFlg_Result0, - /* ColNames: */ 0, 0, - /* iArg: */ 0 }, #if defined(SQLITE_HAS_CODEC) {/* zName: */ "hexkey", /* ePragTyp: */ PragTyp_KEY, @@ -124022,7 +121877,7 @@ static const PragmaName aPragmaName[] = { {/* zName: */ "index_list", /* ePragTyp: */ PragTyp_INDEX_LIST, /* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result1|PragFlg_SchemaOpt, - /* ColNames: */ 32, 5, + /* ColNames: */ 26, 5, /* iArg: */ 0 }, {/* zName: */ "index_xinfo", /* ePragTyp: */ PragTyp_INDEX_INFO, @@ -124062,6 +121917,11 @@ static const PragmaName aPragmaName[] = { /* ePragFlg: */ PragFlg_Result0|PragFlg_NoColumns1, /* ColNames: */ 0, 0, /* iArg: */ SQLITE_LegacyAlter }, + {/* zName: */ "legacy_file_format", + /* ePragTyp: */ PragTyp_FLAG, + /* ePragFlg: */ PragFlg_Result0|PragFlg_NoColumns1, + /* ColNames: */ 0, 0, + /* iArg: */ SQLITE_LegacyFileFmt }, #endif #if !defined(SQLITE_OMIT_PAGER_PRAGMAS) && SQLITE_ENABLE_LOCKING_STYLE {/* zName: */ "lock_proxy_file", @@ -124074,7 +121934,7 @@ static const PragmaName aPragmaName[] = { {/* zName: */ "lock_status", /* ePragTyp: */ PragTyp_LOCK_STATUS, /* ePragFlg: */ PragFlg_Result0, - /* ColNames: */ 47, 2, + /* ColNames: */ 43, 2, /* iArg: */ 0 }, #endif #if !defined(SQLITE_OMIT_PAGER_PRAGMAS) @@ -124222,7 +122082,7 @@ static const PragmaName aPragmaName[] = { {/* zName: */ "stats", /* ePragTyp: */ PragTyp_STATS, /* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result0|PragFlg_SchemaReq, - /* ColNames: */ 27, 5, + /* ColNames: */ 21, 5, /* iArg: */ 0 }, #endif #if !defined(SQLITE_OMIT_PAGER_PRAGMAS) @@ -124273,13 +122133,6 @@ static const PragmaName aPragmaName[] = { /* ePragFlg: */ PragFlg_Result0, /* ColNames: */ 0, 0, /* iArg: */ 0 }, -#if !defined(SQLITE_OMIT_FLAG_PRAGMAS) - {/* zName: */ "trusted_schema", - /* ePragTyp: */ PragTyp_FLAG, - /* ePragFlg: */ PragFlg_Result0|PragFlg_NoColumns1, - /* ColNames: */ 0, 0, - /* iArg: */ SQLITE_TrustedSchema }, -#endif #if !defined(SQLITE_OMIT_SCHEMA_VERSION_PRAGMAS) {/* zName: */ "user_version", /* ePragTyp: */ PragTyp_HEADER_VALUE, @@ -124325,7 +122178,7 @@ static const PragmaName aPragmaName[] = { {/* zName: */ "wal_checkpoint", /* ePragTyp: */ PragTyp_WAL_CHECKPOINT, /* ePragFlg: */ PragFlg_NeedSchema, - /* ColNames: */ 44, 3, + /* ColNames: */ 38, 3, /* iArg: */ 0 }, #endif #if !defined(SQLITE_OMIT_FLAG_PRAGMAS) @@ -124336,7 +122189,7 @@ static const PragmaName aPragmaName[] = { /* iArg: */ SQLITE_WriteSchema|SQLITE_NoSchemaError }, #endif }; -/* Number of pragmas: 66 on by default, 82 total. */ +/* Number of pragmas: 65 on by default, 81 total. */ /************** End of pragma.h **********************************************/ /************** Continuing where we left off in pragma.c *********************/ @@ -124606,55 +122459,6 @@ static const PragmaName *pragmaLocate(const char *zName){ return lwr>upr ? 0 : &aPragmaName[mid]; } -/* -** Create zero or more entries in the output for the SQL functions -** defined by FuncDef p. -*/ -static void pragmaFunclistLine( - Vdbe *v, /* The prepared statement being created */ - FuncDef *p, /* A particular function definition */ - int isBuiltin, /* True if this is a built-in function */ - int showInternFuncs /* True if showing internal functions */ -){ - for(; p; p=p->pNext){ - const char *zType; - static const u32 mask = - SQLITE_DETERMINISTIC | - SQLITE_DIRECTONLY | - SQLITE_SUBTYPE | - SQLITE_INNOCUOUS | - SQLITE_FUNC_INTERNAL - ; - static const char *azEnc[] = { 0, "utf8", "utf16le", "utf16be" }; - - assert( SQLITE_FUNC_ENCMASK==0x3 ); - assert( strcmp(azEnc[SQLITE_UTF8],"utf8")==0 ); - assert( strcmp(azEnc[SQLITE_UTF16LE],"utf16le")==0 ); - assert( strcmp(azEnc[SQLITE_UTF16BE],"utf16be")==0 ); - - if( p->xSFunc==0 ) continue; - if( (p->funcFlags & SQLITE_FUNC_INTERNAL)!=0 - && showInternFuncs==0 - ){ - continue; - } - if( p->xValue!=0 ){ - zType = "w"; - }else if( p->xFinalize!=0 ){ - zType = "a"; - }else{ - zType = "s"; - } - sqlite3VdbeMultiLoad(v, 1, "sissii", - p->zName, isBuiltin, - zType, azEnc[p->funcFlags&SQLITE_FUNC_ENCMASK], - p->nArg, - (p->funcFlags & mask) ^ SQLITE_INNOCUOUS - ); - } -} - - /* ** Helper subroutine for PRAGMA integrity_check: ** @@ -125460,19 +123264,10 @@ SQLITE_PRIVATE void sqlite3Pragma( sqlite3CodeVerifySchema(pParse, iTabDb); sqlite3ViewGetColumnNames(pParse, pTab); for(i=0, pCol=pTab->aCol; inCol; i++, pCol++){ - int isHidden = 0; - if( pCol->colFlags & COLFLAG_NOINSERT ){ - if( pPragma->iArg==0 ){ - nHidden++; - continue; - } - if( pCol->colFlags & COLFLAG_VIRTUAL ){ - isHidden = 2; /* GENERATED ALWAYS AS ... VIRTUAL */ - }else if( pCol->colFlags & COLFLAG_STORED ){ - isHidden = 3; /* GENERATED ALWAYS AS ... STORED */ - }else{ assert( pCol->colFlags & COLFLAG_HIDDEN ); - isHidden = 1; /* HIDDEN */ - } + int isHidden = IsHiddenColumn(pCol); + if( isHidden && pPragma->iArg==0 ){ + nHidden++; + continue; } if( (pCol->colFlags & COLFLAG_PRIMKEY)==0 ){ k = 0; @@ -125481,13 +123276,13 @@ SQLITE_PRIVATE void sqlite3Pragma( }else{ for(k=1; k<=pTab->nCol && pPk->aiColumn[k-1]!=i; k++){} } - assert( pCol->pDflt==0 || pCol->pDflt->op==TK_SPAN || isHidden>=2 ); + assert( pCol->pDflt==0 || pCol->pDflt->op==TK_SPAN ); sqlite3VdbeMultiLoad(v, 1, pPragma->iArg ? "issisii" : "issisi", i-nHidden, pCol->zName, sqlite3ColumnType(pCol,""), pCol->notNull ? 1 : 0, - pCol->pDflt && isHidden<2 ? pCol->pDflt->u.zToken : 0, + pCol->pDflt ? pCol->pDflt->u.zToken : 0, k, isHidden); } @@ -125619,16 +123414,16 @@ SQLITE_PRIVATE void sqlite3Pragma( int i; HashElem *j; FuncDef *p; - int showInternFunc = (db->mDbFlags & DBFLAG_InternalFunc)!=0; - pParse->nMem = 6; + pParse->nMem = 2; for(i=0; iu.pHash ){ - pragmaFunclistLine(v, p, 1, showInternFunc); + if( p->funcFlags & SQLITE_FUNC_INTERNAL ) continue; + sqlite3VdbeMultiLoad(v, 1, "si", p->zName, 1); } } for(j=sqliteHashFirst(&db->aFunc); j; j=sqliteHashNext(j)){ p = (FuncDef*)sqliteHashData(j); - pragmaFunclistLine(v, p, 0, showInternFunc); + sqlite3VdbeMultiLoad(v, 1, "si", p->zName, 0); } } break; @@ -125946,7 +123741,7 @@ SQLITE_PRIVATE void sqlite3Pragma( loopTop = sqlite3VdbeAddOp2(v, OP_AddImm, 7, 1); if( !isQuick ){ /* Sanity check on record header decoding */ - sqlite3VdbeAddOp3(v, OP_Column, iDataCur, pTab->nNVCol-1,3); + sqlite3VdbeAddOp3(v, OP_Column, iDataCur, pTab->nCol-1, 3); sqlite3VdbeChangeP5(v, OPFLAG_TYPEOFARG); } /* Verify that all NOT NULL columns really are NOT NULL */ @@ -125956,9 +123751,7 @@ SQLITE_PRIVATE void sqlite3Pragma( if( j==pTab->iPKey ) continue; if( pTab->aCol[j].notNull==0 ) continue; sqlite3ExprCodeGetColumnOfTable(v, pTab, iDataCur, j, 3); - if( sqlite3VdbeGetOp(v,-1)->opcode==OP_Column ){ - sqlite3VdbeChangeP5(v, OPFLAG_TYPEOFARG); - } + sqlite3VdbeChangeP5(v, OPFLAG_TYPEOFARG); jmp2 = sqlite3VdbeAddOp1(v, OP_NotNull, 3); VdbeCoverage(v); zErr = sqlite3MPrintf(db, "NULL value in %s.%s", pTab->zName, pTab->aCol[j].zName); @@ -126135,17 +123928,10 @@ SQLITE_PRIVATE void sqlite3Pragma( ** will be overwritten when the schema is next loaded. If it does not ** already exists, it will be created to use the new encoding value. */ - int canChangeEnc = 1; /* True if allowed to change the encoding */ - int i; /* For looping over all attached databases */ - for(i=0; inDb; i++){ - if( db->aDb[i].pBt!=0 - && DbHasProperty(db,i,DB_SchemaLoaded) - && !DbHasProperty(db,i,DB_Empty) - ){ - canChangeEnc = 0; - } - } - if( canChangeEnc ){ + if( + !(DbHasProperty(db, 0, DB_SchemaLoaded)) || + DbHasProperty(db, 0, DB_Empty) + ){ for(pEnc=&encnames[0]; pEnc->zName; pEnc++){ if( 0==sqlite3StrICmp(zRight, pEnc->zName) ){ SCHEMA_ENC(db) = ENC(db) = @@ -126458,27 +124244,6 @@ SQLITE_PRIVATE void sqlite3Pragma( break; } - /* - ** PRAGMA hard_heap_limit - ** PRAGMA hard_heap_limit = N - ** - ** Invoke sqlite3_hard_heap_limit64() to query or set the hard heap - ** limit. The hard heap limit can be activated or lowered by this - ** pragma, but not raised or deactivated. Only the - ** sqlite3_hard_heap_limit64() C-language API can raise or deactivate - ** the hard heap limit. This allows an application to set a heap limit - ** constraint that cannot be relaxed by an untrusted SQL script. - */ - case PragTyp_HARD_HEAP_LIMIT: { - sqlite3_int64 N; - if( zRight && sqlite3DecOrHexToI64(zRight, &N)==SQLITE_OK ){ - sqlite3_int64 iPrior = sqlite3_hard_heap_limit64(-1); - if( N>0 && (iPrior==0 || iPrior>N) ) sqlite3_hard_heap_limit64(N); - } - returnSingleInt(v, sqlite3_hard_heap_limit64(-1)); - break; - } - /* ** PRAGMA threads ** PRAGMA threads = N @@ -126972,18 +124737,6 @@ SQLITE_PRIVATE int sqlite3IndexHasDuplicateRootPage(Index *pIndex){ return 0; } -/* forward declaration */ -static int sqlite3Prepare( - sqlite3 *db, /* Database handle. */ - const char *zSql, /* UTF-8 encoded SQL statement. */ - int nBytes, /* Length of zSql in bytes. */ - u32 prepFlags, /* Zero or more SQLITE_PREPARE_* flags */ - Vdbe *pReprepare, /* VM being reprepared */ - sqlite3_stmt **ppStmt, /* OUT: A pointer to the prepared statement */ - const char **pzTail /* OUT: End of parsed string */ -); - - /* ** This is the callback routine for the code that initializes the ** database. See sqlite3Init() below for additional information. @@ -127033,8 +124786,7 @@ SQLITE_PRIVATE int sqlite3InitCallback(void *pInit, int argc, char **argv, char db->init.newTnum = sqlite3Atoi(argv[3]); db->init.orphanTrigger = 0; db->init.azInit = argv; - pStmt = 0; - TESTONLY(rcp = ) sqlite3Prepare(db, argv[4], -1, 0, 0, &pStmt, 0); + TESTONLY(rcp = ) sqlite3_prepare(db, argv[4], -1, &pStmt, 0); rc = db->errCode; assert( (rc&0xFF)==(rcp&0xFF) ); db->init.iDb = saved_iDb; @@ -127455,7 +125207,6 @@ SQLITE_PRIVATE void sqlite3ParserReset(Parse *pParse){ if( db ){ assert( db->lookaside.bDisable >= pParse->disableLookaside ); db->lookaside.bDisable -= pParse->disableLookaside; - db->lookaside.sz = db->lookaside.bDisable ? 0 : db->lookaside.szTrue; } pParse->disableLookaside = 0; } @@ -127489,7 +125240,7 @@ static int sqlite3Prepare( */ if( prepFlags & SQLITE_PREPARE_PERSISTENT ){ sParse.disableLookaside++; - DisableLookaside; + db->lookaside.bDisable++; } sParse.disableVtab = (prepFlags & SQLITE_PREPARE_NO_VTAB)!=0; @@ -127516,18 +125267,16 @@ static int sqlite3Prepare( ** but it does *not* override schema lock detection, so this all still ** works even if READ_UNCOMMITTED is set. */ - if( !db->noSharedCache ){ - for(i=0; inDb; i++) { - Btree *pBt = db->aDb[i].pBt; - if( pBt ){ - assert( sqlite3BtreeHoldsMutex(pBt) ); - rc = sqlite3BtreeSchemaLocked(pBt); - if( rc ){ - const char *zDb = db->aDb[i].zDbSName; - sqlite3ErrorWithMsg(db, rc, "database schema is locked: %s", zDb); - testcase( db->flags & SQLITE_ReadUncommit ); - goto end_prepare; - } + for(i=0; inDb; i++) { + Btree *pBt = db->aDb[i].pBt; + if( pBt ){ + assert( sqlite3BtreeHoldsMutex(pBt) ); + rc = sqlite3BtreeSchemaLocked(pBt); + if( rc ){ + const char *zDb = db->aDb[i].zDbSName; + sqlite3ErrorWithMsg(db, rc, "database schema is locked: %s", zDb); + testcase( db->flags & SQLITE_ReadUncommit ); + goto end_prepare; } } } @@ -127558,24 +125307,48 @@ static int sqlite3Prepare( } assert( 0==sParse.nQueryLoop ); - if( sParse.rc==SQLITE_DONE ){ - sParse.rc = SQLITE_OK; - } + if( sParse.rc==SQLITE_DONE ) sParse.rc = SQLITE_OK; if( sParse.checkSchema ){ schemaIsValid(&sParse); } - if( pzTail ){ - *pzTail = sParse.zTail; - } - - if( db->init.busy==0 ){ - sqlite3VdbeSetSql(sParse.pVdbe, zSql, (int)(sParse.zTail-zSql), prepFlags); - } if( db->mallocFailed ){ sParse.rc = SQLITE_NOMEM_BKPT; } + if( pzTail ){ + *pzTail = sParse.zTail; + } rc = sParse.rc; - if( rc!=SQLITE_OK ){ + +#ifndef SQLITE_OMIT_EXPLAIN + /* Justification for the ALWAYS(): The only way for rc to be SQLITE_OK and + ** sParse.pVdbe to be NULL is if the input SQL is an empty string, but in + ** that case, sParse.explain will be false. */ + if( sParse.explain && rc==SQLITE_OK && ALWAYS(sParse.pVdbe) ){ + static const char * const azColName[] = { + "addr", "opcode", "p1", "p2", "p3", "p4", "p5", "comment", + "id", "parent", "notused", "detail" + }; + int iFirst, mx; + if( sParse.explain==2 ){ + sqlite3VdbeSetNumCols(sParse.pVdbe, 4); + iFirst = 8; + mx = 12; + }else{ + sqlite3VdbeSetNumCols(sParse.pVdbe, 8); + iFirst = 0; + mx = 8; + } + for(i=iFirst; iinit.busy==0 ){ + sqlite3VdbeSetSql(sParse.pVdbe, zSql, (int)(sParse.zTail-zSql), prepFlags); + } + if( rc!=SQLITE_OK || db->mallocFailed ){ if( sParse.pVdbe ) sqlite3VdbeFinalize(sParse.pVdbe); assert(!(*ppStmt)); }else{ @@ -127931,10 +125704,7 @@ struct SortCtx { /* ** Delete all the content of a Select structure. Deallocate the structure -** itself depending on the value of bFree -** -** If bFree==1, call sqlite3DbFree() on the p object. -** If bFree==0, Leave the first Select object unfreed +** itself only if bFree is true. */ static void clearSelect(sqlite3 *db, Select *p, int bFree){ while( p ){ @@ -128038,21 +125808,6 @@ SQLITE_PRIVATE void sqlite3SelectDelete(sqlite3 *db, Select *p){ if( OK_IF_ALWAYS_TRUE(p) ) clearSelect(db, p, 1); } -/* -** Delete all the substructure for p, but keep p allocated. Redefine -** p to be a single SELECT where every column of the result set has a -** value of NULL. -*/ -SQLITE_PRIVATE void sqlite3SelectReset(Parse *pParse, Select *p){ - if( ALWAYS(p) ){ - clearSelect(pParse->db, p, 0); - memset(&p->iLimit, 0, sizeof(Select) - offsetof(Select,iLimit)); - p->pEList = sqlite3ExprListAppend(pParse, 0, - sqlite3ExprAlloc(pParse->db,TK_NULL,0,0)); - p->pSrc = sqlite3DbMallocZero(pParse->db, sizeof(SrcList)); - } -} - /* ** Return a pointer to the right-most SELECT statement in a compound. */ @@ -128161,8 +125916,7 @@ static int tableAndColumnIndex( int N, /* Number of tables in pSrc->a[] to search */ const char *zCol, /* Name of the column we are looking for */ int *piTab, /* Write index of pSrc->a[] here */ - int *piCol, /* Write index of pSrc->a[*piTab].pTab->aCol[] here */ - int bIgnoreHidden /* True to ignore hidden columns */ + int *piCol /* Write index of pSrc->a[*piTab].pTab->aCol[] here */ ){ int i; /* For looping over tables in pSrc */ int iCol; /* Index of column matching zCol */ @@ -128170,9 +125924,7 @@ static int tableAndColumnIndex( assert( (piTab==0)==(piCol==0) ); /* Both or neither are NULL */ for(i=0; ia[i].pTab, zCol); - if( iCol>=0 - && (bIgnoreHidden==0 || IsHiddenColumn(&pSrc->a[i].pTab->aCol[iCol])==0) - ){ + if( iCol>=0 ){ if( piTab ){ *piTab = i; *piCol = iCol; @@ -128253,7 +126005,7 @@ static void addWhereTerm( ** after the t1 loop and rows with t1.x!=5 will never appear in ** the output, which is incorrect. */ -SQLITE_PRIVATE void sqlite3SetJoinExpr(Expr *p, int iTable){ +static void setJoinExpr(Expr *p, int iTable){ while( p ){ ExprSetProperty(p, EP_FromJoin); assert( !ExprHasProperty(p, EP_TokenOnly|EP_Reduced) ); @@ -128262,15 +126014,15 @@ SQLITE_PRIVATE void sqlite3SetJoinExpr(Expr *p, int iTable){ if( p->op==TK_FUNCTION && p->x.pList ){ int i; for(i=0; ix.pList->nExpr; i++){ - sqlite3SetJoinExpr(p->x.pList->a[i].pExpr, iTable); + setJoinExpr(p->x.pList->a[i].pExpr, iTable); } } - sqlite3SetJoinExpr(p->pLeft, iTable); + setJoinExpr(p->pLeft, iTable); p = p->pRight; } } -/* Undo the work of sqlite3SetJoinExpr(). In the expression p, convert every +/* Undo the work of setJoinExpr(). In the expression tree p, convert every ** term that is marked with EP_FromJoin and iRightJoinTable==iTable into ** an ordinary term that omits the EP_FromJoin mark. ** @@ -128337,11 +126089,10 @@ static int sqliteProcessJoin(Parse *pParse, Select *p){ int iLeft; /* Matching left table */ int iLeftCol; /* Matching column in the left table */ - if( IsHiddenColumn(&pRightTab->aCol[j]) ) continue; zName = pRightTab->aCol[j].zName; - if( tableAndColumnIndex(pSrc, i+1, zName, &iLeft, &iLeftCol, 1) ){ + if( tableAndColumnIndex(pSrc, i+1, zName, &iLeft, &iLeftCol) ){ addWhereTerm(pParse, pSrc, iLeft, iLeftCol, i+1, j, - isOuter, &p->pWhere); + isOuter, &p->pWhere); } } } @@ -128358,7 +126109,7 @@ static int sqliteProcessJoin(Parse *pParse, Select *p){ ** an AND operator. */ if( pRight->pOn ){ - if( isOuter ) sqlite3SetJoinExpr(pRight->pOn, pRight->iCursor); + if( isOuter ) setJoinExpr(pRight->pOn, pRight->iCursor); p->pWhere = sqlite3ExprAnd(pParse, p->pWhere, pRight->pOn); pRight->pOn = 0; } @@ -128381,7 +126132,7 @@ static int sqliteProcessJoin(Parse *pParse, Select *p){ zName = pList->a[j].zName; iRightCol = columnIndex(pRightTab, zName); if( iRightCol<0 - || !tableAndColumnIndex(pSrc, i+1, zName, &iLeft, &iLeftCol, 0) + || !tableAndColumnIndex(pSrc, i+1, zName, &iLeft, &iLeftCol) ){ sqlite3ErrorMsg(pParse, "cannot join using column %s - column " "not present in both tables", zName); @@ -128538,7 +126289,6 @@ static void pushOntoSorter( testcase( pKI->nAllField > pKI->nKeyField+2 ); pOp->p4.pKeyInfo = sqlite3KeyInfoFromExprList(pParse,pSort->pOrderBy,nOBSat, pKI->nAllField-pKI->nKeyField-1); - pOp = 0; /* Ensure pOp not used after sqltie3VdbeAddOp3() */ addrJmp = sqlite3VdbeCurrentAddr(v); sqlite3VdbeAddOp3(v, OP_Jump, addrJmp+1, 0, addrJmp+1); VdbeCoverage(v); pSort->labelBkOut = sqlite3VdbeMakeLabel(pParse); @@ -128787,7 +126537,7 @@ static void selectInnerLoop( if( srcTab>=0 ){ for(i=0; ipEList->a[i].zEName)); + VdbeComment((v, "%s", p->pEList->a[i].zName)); } }else if( eDest!=SRT_Exists ){ #ifdef SQLITE_ENABLE_SORTER_REFERENCES @@ -128901,7 +126651,6 @@ static void selectInnerLoop( pOp->opcode = OP_Null; pOp->p1 = 1; pOp->p2 = regPrev; - pOp = 0; /* Ensure pOp is not used after sqlite3VdbeAddOp() */ iJump = sqlite3VdbeCurrentAddr(v) + nResultCol; for(i=0; iop!=TK_AGG_COLUMN ); /* Agg processing has not run yet */ assert( p->op!=TK_COLUMN || p->y.pTab!=0 ); /* Covering idx not yet coded */ - if( pEList->a[i].zEName && pEList->a[i].eEName==ENAME_NAME ){ + if( pEList->a[i].zName ){ /* An AS clause always takes first priority */ - char *zName = pEList->a[i].zEName; + char *zName = pEList->a[i].zName; sqlite3VdbeSetColName(v, i, COLNAME_NAME, zName, SQLITE_TRANSIENT); }else if( srcName && p->op==TK_COLUMN ){ char *zCol; @@ -129766,7 +127515,7 @@ static void generateColumnNames( sqlite3VdbeSetColName(v, i, COLNAME_NAME, zCol, SQLITE_TRANSIENT); } }else{ - const char *z = pEList->a[i].zEName; + const char *z = pEList->a[i].zSpan; z = z==0 ? sqlite3MPrintf(db, "column%d", i+1) : sqlite3DbStrDup(db, z); sqlite3VdbeSetColName(v, i, COLNAME_NAME, z, SQLITE_DYNAMIC); } @@ -129828,7 +127577,7 @@ SQLITE_PRIVATE int sqlite3ColumnsFromExprList( for(i=0, pCol=aCol; imallocFailed; i++, pCol++){ /* Get an appropriate name for the column */ - if( (zName = pEList->a[i].zEName)!=0 && pEList->a[i].eEName==ENAME_NAME ){ + if( (zName = pEList->a[i].zName)!=0 ){ /* If the column contains an "AS " phrase, use as the name */ }else{ Expr *pColExpr = sqlite3ExprSkipCollateAndLikely(pEList->a[i].pExpr); @@ -129848,10 +127597,10 @@ SQLITE_PRIVATE int sqlite3ColumnsFromExprList( zName = pColExpr->u.zToken; }else{ /* Use the original text of the column expression as its name */ - zName = pEList->a[i].zEName; + zName = pEList->a[i].zSpan; } } - if( zName && !sqlite3IsTrueOrFalse(zName) ){ + if( zName ){ zName = sqlite3DbStrDup(db, zName); }else{ zName = sqlite3MPrintf(db,"column%d",i+1); @@ -130343,9 +128092,6 @@ static int multiSelectValues( assert( p->selFlags & SF_Values ); assert( p->op==TK_ALL || (p->op==TK_SELECT && p->pPrior==0) ); assert( p->pNext==0 || p->pEList->nExpr==p->pNext->pEList->nExpr ); -#ifndef SQLITE_OMIT_WINDOWFUNC - if( p->pWin ) return -1; -#endif if( p->pPrior==0 ) break; assert( p->pPrior->pNext==p ); p = p->pPrior; @@ -130436,8 +128182,7 @@ static int multiSelect( */ if( p->selFlags & SF_MultiValue ){ rc = multiSelectValues(pParse, p, &dest); - if( rc>=0 ) goto multi_select_end; - rc = SQLITE_OK; + goto multi_select_end; } /* Make sure all SELECTs in the statement have the same number of elements @@ -130582,9 +128327,9 @@ static int multiSelect( ** it is that we currently need. */ assert( unionTab==dest.iSDParm || dest.eDest!=priorOp ); - assert( p->pEList || db->mallocFailed ); - if( dest.eDest!=priorOp && db->mallocFailed==0 ){ + if( dest.eDest!=priorOp ){ int iCont, iBreak, iStart; + assert( p->pEList ); iBreak = sqlite3VdbeMakeLabel(pParse); iCont = sqlite3VdbeMakeLabel(pParse); computeLimitRegisters(pParse, p, iBreak); @@ -130680,7 +128425,6 @@ static int multiSelect( } #endif } - if( pParse->nErr ) goto multi_select_end; /* Compute collating sequences used by ** temporary tables needed to implement the compound select. @@ -131472,7 +129216,6 @@ static void substSelect( ** (3b) the FROM clause of the subquery may not contain a virtual ** table and ** (3c) the outer query may not be an aggregate. -** (3d) the outer query may not be DISTINCT. ** ** (4) The subquery can not be DISTINCT. ** @@ -131523,7 +129266,6 @@ static void substSelect( ** (17d1) aggregate, or ** (17d2) DISTINCT, or ** (17d3) a join. -** (17e) the subquery may not contain window functions ** ** The parent and sub-query may contain WHERE clauses. Subject to ** rules (11), (13) and (14), they may also contain ORDER BY, @@ -131670,11 +129412,8 @@ static int flattenSubquery( */ if( (pSubitem->fg.jointype & JT_OUTER)!=0 ){ isLeftJoin = 1; - if( pSubSrc->nSrc>1 /* (3a) */ - || isAgg /* (3b) */ - || IsVirtual(pSubSrc->a[0].pTab) /* (3c) */ - || (p->selFlags & SF_Distinct)!=0 /* (3d) */ - ){ + if( pSubSrc->nSrc>1 || isAgg || IsVirtual(pSubSrc->a[0].pTab) ){ + /* (3a) (3c) (3b) */ return 0; } } @@ -131708,9 +129447,6 @@ static int flattenSubquery( if( (pSub1->selFlags & (SF_Distinct|SF_Aggregate))!=0 /* (17b) */ || (pSub1->pPrior && pSub1->op!=TK_ALL) /* (17a) */ || pSub1->pSrc->nSrc<1 /* (17c) */ -#ifndef SQLITE_OMIT_WINDOWFUNC - || pSub1->pWin /* (17e) */ -#endif ){ return 0; } @@ -131937,7 +129673,7 @@ static int flattenSubquery( pWhere = pSub->pWhere; pSub->pWhere = 0; if( isLeftJoin>0 ){ - sqlite3SetJoinExpr(pWhere, iNewParent); + setJoinExpr(pWhere, iNewParent); } pParent->pWhere = sqlite3ExprAnd(pParse, pWhere, pParent->pWhere); if( db->mallocFailed==0 ){ @@ -131997,36 +129733,23 @@ struct WhereConst { /* ** Add a new entry to the pConst object. Except, do not add duplicate -** pColumn entires. Also, do not add if doing so would not be appropriate. -** -** The caller guarantees the pColumn is a column and pValue is a constant. -** This routine has to do some additional checks before completing the -** insert. +** pColumn entires. */ static void constInsert( - WhereConst *pConst, /* The WhereConst into which we are inserting */ - Expr *pColumn, /* The COLUMN part of the constraint */ - Expr *pValue, /* The VALUE part of the constraint */ - Expr *pExpr /* Overall expression: COLUMN=VALUE or VALUE=COLUMN */ + WhereConst *pConst, /* The WhereConst into which we are inserting */ + Expr *pColumn, /* The COLUMN part of the constraint */ + Expr *pValue /* The VALUE part of the constraint */ ){ int i; assert( pColumn->op==TK_COLUMN ); - assert( sqlite3ExprIsConstant(pValue) ); - - if( !ExprHasProperty(pValue, EP_FixedCol) && sqlite3ExprAffinity(pValue)!=0 ){ - return; - } - if( !sqlite3IsBinary(sqlite3ExprCompareCollSeq(pConst->pParse,pExpr)) ){ - return; - } /* 2018-10-25 ticket [cf5ed20f] ** Make sure the same pColumn is not inserted more than once */ for(i=0; inConst; i++){ - const Expr *pE2 = pConst->apExpr[i*2]; - assert( pE2->op==TK_COLUMN ); - if( pE2->iTable==pColumn->iTable - && pE2->iColumn==pColumn->iColumn + const Expr *pExpr = pConst->apExpr[i*2]; + assert( pExpr->op==TK_COLUMN ); + if( pExpr->iTable==pColumn->iTable + && pExpr->iColumn==pColumn->iColumn ){ return; /* Already present. Return without doing anything. */ } @@ -132038,9 +129761,7 @@ static void constInsert( if( pConst->apExpr==0 ){ pConst->nConst = 0; }else{ - if( ExprHasProperty(pValue, EP_FixedCol) ){ - pValue = pValue->pLeft; - } + if( ExprHasProperty(pValue, EP_FixedCol) ) pValue = pValue->pLeft; pConst->apExpr[pConst->nConst*2-2] = pColumn; pConst->apExpr[pConst->nConst*2-1] = pValue; } @@ -132066,11 +129787,19 @@ static void findConstInWhere(WhereConst *pConst, Expr *pExpr){ pLeft = pExpr->pLeft; assert( pRight!=0 ); assert( pLeft!=0 ); - if( pRight->op==TK_COLUMN && sqlite3ExprIsConstant(pLeft) ){ - constInsert(pConst,pRight,pLeft,pExpr); - } - if( pLeft->op==TK_COLUMN && sqlite3ExprIsConstant(pRight) ){ - constInsert(pConst,pLeft,pRight,pExpr); + if( pRight->op==TK_COLUMN + && !ExprHasProperty(pRight, EP_FixedCol) + && sqlite3ExprIsConstant(pLeft) + && sqlite3IsBinary(sqlite3BinaryCompareCollSeq(pConst->pParse,pLeft,pRight)) + ){ + constInsert(pConst, pRight, pLeft); + }else + if( pLeft->op==TK_COLUMN + && !ExprHasProperty(pLeft, EP_FixedCol) + && sqlite3ExprIsConstant(pRight) + && sqlite3IsBinary(sqlite3BinaryCompareCollSeq(pConst->pParse,pLeft,pRight)) + ){ + constInsert(pConst, pLeft, pRight); } } @@ -132084,11 +129813,7 @@ static int propagateConstantExprRewrite(Walker *pWalker, Expr *pExpr){ int i; WhereConst *pConst; if( pExpr->op!=TK_COLUMN ) return WRC_Continue; - if( ExprHasProperty(pExpr, EP_FixedCol|EP_FromJoin) ){ - testcase( ExprHasProperty(pExpr, EP_FixedCol) ); - testcase( ExprHasProperty(pExpr, EP_FromJoin) ); - return WRC_Continue; - } + if( ExprHasProperty(pExpr, EP_FixedCol) ) return WRC_Continue; pConst = pWalker->u.pConst; for(i=0; inConst; i++){ Expr *pColumn = pConst->apExpr[i*2]; @@ -132110,9 +129835,10 @@ static int propagateConstantExprRewrite(Walker *pWalker, Expr *pExpr){ ** The WHERE-clause constant propagation optimization. ** ** If the WHERE clause contains terms of the form COLUMN=CONSTANT or -** CONSTANT=COLUMN that are top-level AND-connected terms that are not -** part of a ON clause from a LEFT JOIN, then throughout the query -** replace all other occurrences of COLUMN with CONSTANT. +** CONSTANT=COLUMN that must be tree (in other words, if the terms top-level +** AND-connected terms that are not part of a ON clause from a LEFT JOIN) +** then throughout the query replace all other occurrences of COLUMN +** with CONSTANT within the WHERE clause. ** ** For example, the query: ** @@ -132461,9 +130187,6 @@ static int convertCompoundSelectToSubquery(Walker *pWalker, Select *p){ p->pPrior = 0; p->pNext = 0; p->pWith = 0; -#ifndef SQLITE_OMIT_WINDOWFUNC - p->pWinDefn = 0; -#endif p->selFlags &= ~SF_Compound; assert( (p->selFlags & SF_Converted)==0 ); p->selFlags |= SF_Converted; @@ -132563,9 +130286,6 @@ static int withExpand( With *pWith; /* WITH clause that pCte belongs to */ assert( pFrom->pTab==0 ); - if( pParse->nErr ){ - return SQLITE_ERROR; - } pCte = searchWith(pParse->pWith, pFrom, &pWith); if( pCte ){ @@ -132686,7 +130406,7 @@ static void selectPopWith(Walker *pWalker, Select *p){ if( OK_IF_ALWAYS_TRUE(pParse->pWith) && p->pPrior==0 ){ With *pWith = findRightmost(p)->pWith; if( pWith!=0 ){ - assert( pParse->pWith==pWith || pParse->nErr ); + assert( pParse->pWith==pWith ); pParse->pWith = pWith->pOuter; } } @@ -132817,7 +130537,7 @@ static int selectExpander(Walker *pWalker, Select *p){ if( !IsVirtual(pTab) && cannotBeFunction(pParse, pFrom) ){ return WRC_Abort; } -#if !defined(SQLITE_OMIT_VIEW) || !defined(SQLITE_OMIT_VIRTUALTABLE) +#if !defined(SQLITE_OMIT_VIEW) || !defined (SQLITE_OMIT_VIRTUALTABLE) if( IsVirtual(pTab) || pTab->pSelect ){ i16 nCol; u8 eCodeOrig = pWalker->eCode; @@ -132825,18 +130545,8 @@ static int selectExpander(Walker *pWalker, Select *p){ assert( pFrom->pSelect==0 ); if( pTab->pSelect && (db->flags & SQLITE_EnableView)==0 ){ sqlite3ErrorMsg(pParse, "access to view \"%s\" prohibited", - pTab->zName); + pTab->zName); } -#ifndef SQLITE_OMIT_VIRTUALTABLE - if( IsVirtual(pTab) - && pFrom->fg.fromDDL - && ALWAYS(pTab->pVTable!=0) - && pTab->pVTable->eVtabRisk > ((db->flags & SQLITE_TrustedSchema)!=0) - ){ - sqlite3ErrorMsg(pParse, "unsafe use of virtual table \"%s\"", - pTab->zName); - } -#endif pFrom->pSelect = sqlite3SelectDup(db, pTab->pSelect, 0); nCol = pTab->nCol; pTab->nCol = -1; @@ -132856,7 +130566,7 @@ static int selectExpander(Walker *pWalker, Select *p){ /* Process NATURAL keywords, and ON and USING clauses of joins. */ - if( pParse->nErr || db->mallocFailed || sqliteProcessJoin(pParse, p) ){ + if( db->mallocFailed || sqliteProcessJoin(pParse, p) ){ return WRC_Abort; } @@ -132903,9 +130613,10 @@ static int selectExpander(Walker *pWalker, Select *p){ */ pNew = sqlite3ExprListAppend(pParse, pNew, a[k].pExpr); if( pNew ){ - pNew->a[pNew->nExpr-1].zEName = a[k].zEName; - pNew->a[pNew->nExpr-1].eEName = a[k].eEName; - a[k].zEName = 0; + pNew->a[pNew->nExpr-1].zName = a[k].zName; + pNew->a[pNew->nExpr-1].zSpan = a[k].zSpan; + a[k].zName = 0; + a[k].zSpan = 0; } a[k].pExpr = 0; }else{ @@ -132944,7 +130655,7 @@ static int selectExpander(Walker *pWalker, Select *p){ assert( zName ); if( zTName && pSub - && sqlite3MatchEName(&pSub->pEList->a[j], 0, zTName, 0)==0 + && sqlite3MatchSpanName(pSub->pEList->a[j].zSpan, 0, zTName, 0)==0 ){ continue; } @@ -132962,7 +130673,7 @@ static int selectExpander(Walker *pWalker, Select *p){ if( i>0 && zTName==0 ){ if( (pFrom->fg.jointype & JT_NATURAL)!=0 - && tableAndColumnIndex(pTabList, i, zName, 0, 0, 1) + && tableAndColumnIndex(pTabList, i, zName, 0, 0) ){ /* In a NATURAL join, omit the join columns from the ** table to the right of the join */ @@ -132997,16 +130708,15 @@ static int selectExpander(Walker *pWalker, Select *p){ sqlite3ExprListSetName(pParse, pNew, &sColname, 0); if( pNew && (p->selFlags & SF_NestedFrom)!=0 ){ struct ExprList_item *pX = &pNew->a[pNew->nExpr-1]; - sqlite3DbFree(db, pX->zEName); if( pSub ){ - pX->zEName = sqlite3DbStrDup(db, pSub->pEList->a[j].zEName); - testcase( pX->zEName==0 ); + pX->zSpan = sqlite3DbStrDup(db, pSub->pEList->a[j].zSpan); + testcase( pX->zSpan==0 ); }else{ - pX->zEName = sqlite3MPrintf(db, "%s.%s.%s", + pX->zSpan = sqlite3MPrintf(db, "%s.%s.%s", zSchemaName, zTabName, zColname); - testcase( pX->zEName==0 ); + testcase( pX->zSpan==0 ); } - pX->eEName = ENAME_TAB; + pX->bSpanIsTab = 1; } sqlite3DbFree(db, zToFree); } @@ -133633,13 +131343,11 @@ SQLITE_PRIVATE int sqlite3Select( } #ifndef SQLITE_OMIT_WINDOWFUNC - rc = sqlite3WindowRewrite(pParse, p); - if( rc ){ - assert( db->mallocFailed || pParse->nErr>0 ); + if( sqlite3WindowRewrite(pParse, p) ){ goto select_end; } #if SELECTTRACE_ENABLED - if( p->pWin && (sqlite3SelectTrace & 0x108)!=0 ){ + if( sqlite3SelectTrace & 0x108 ){ SELECTTRACE(0x104,pParse,p, ("after window rewrite:\n")); sqlite3TreeViewSelect(0, p, 0); } @@ -133971,13 +131679,9 @@ SQLITE_PRIVATE int sqlite3Select( */ if( (p->selFlags & (SF_Distinct|SF_Aggregate))==SF_Distinct && sqlite3ExprListCompare(sSort.pOrderBy, pEList, -1)==0 -#ifndef SQLITE_OMIT_WINDOWFUNC - && p->pWin==0 -#endif ){ p->selFlags &= ~SF_Distinct; pGroupBy = p->pGroupBy = sqlite3ExprListDup(db, pEList, 0); - p->selFlags |= SF_Aggregate; /* Notice that even thought SF_Distinct has been cleared from p->selFlags, ** the sDistinct.isTnct is still set. Hence, isTnct represents the ** original setting of the SF_Distinct flag, not the current setting */ @@ -134052,7 +131756,7 @@ SQLITE_PRIVATE int sqlite3Select( #ifndef SQLITE_OMIT_WINDOWFUNC Window *pWin = p->pWin; /* Master window object (or NULL) */ if( pWin ){ - sqlite3WindowCodeInit(pParse, p); + sqlite3WindowCodeInit(pParse, pWin); } #endif assert( WHERE_USE_LIMIT==SF_FixedLimit ); @@ -135498,12 +133202,8 @@ SQLITE_PRIVATE void sqlite3UnlinkAndDeleteTrigger(sqlite3 *db, int iDb, const ch Table *pTab = tableOfTrigger(pTrigger); if( pTab ){ Trigger **pp; - for(pp=&pTab->pTrigger; *pp; pp=&((*pp)->pNext)){ - if( *pp==pTrigger ){ - *pp = (*pp)->pNext; - break; - } - } + for(pp=&pTab->pTrigger; *pp!=pTrigger; pp=&((*pp)->pNext)); + *pp = (*pp)->pNext; } } sqlite3DeleteTrigger(db, pTrigger); @@ -135524,7 +133224,7 @@ static int checkColumnOverlap(IdList *pIdList, ExprList *pEList){ int e; if( pIdList==0 || NEVER(pEList==0) ) return 1; for(e=0; enExpr; e++){ - if( sqlite3IdListIndex(pIdList, pEList->a[e].zEName)>=0 ) return 1; + if( sqlite3IdListIndex(pIdList, pEList->a[e].zName)>=0 ) return 1; } return 0; } @@ -136184,7 +133884,7 @@ SQLITE_PRIVATE void sqlite3Update( Expr *pLimit, /* LIMIT clause. May be null */ Upsert *pUpsert /* ON CONFLICT clause, or null */ ){ - int i, j, k; /* Loop counters */ + int i, j; /* Loop counters */ Table *pTab; /* The table to be updated */ int addrTop = 0; /* VDBE instruction address of the start of the loop */ WhereInfo *pWInfo; /* Information about the WHERE clause */ @@ -136228,7 +133928,6 @@ SQLITE_PRIVATE void sqlite3Update( int iPk = 0; /* First of nPk cells holding PRIMARY KEY value */ i16 nPk = 0; /* Number of components of the PRIMARY KEY */ int bReplace = 0; /* True if REPLACE conflict resolution might happen */ - int bFinishSeek = 1; /* The OP_FinishSeek opcode is needed */ /* Register Allocations */ int regRowCount = 0; /* A count of rows changed */ @@ -136327,10 +134026,6 @@ SQLITE_PRIVATE void sqlite3Update( sNC.uNC.pUpsert = pUpsert; sNC.ncFlags = NC_UUpsert; - /* Begin generating code. */ - v = sqlite3GetVdbe(pParse); - if( v==0 ) goto update_cleanup; - /* Resolve the column names in all the expressions of the ** of the UPDATE statement. Also find the column index ** for each column to be updated in the pChanges array. For each @@ -136343,34 +134038,24 @@ SQLITE_PRIVATE void sqlite3Update( goto update_cleanup; } for(j=0; jnCol; j++){ - if( sqlite3StrICmp(pTab->aCol[j].zName, pChanges->a[i].zEName)==0 ){ + if( sqlite3StrICmp(pTab->aCol[j].zName, pChanges->a[i].zName)==0 ){ if( j==pTab->iPKey ){ chngRowid = 1; pRowidExpr = pChanges->a[i].pExpr; }else if( pPk && (pTab->aCol[j].colFlags & COLFLAG_PRIMKEY)!=0 ){ chngPk = 1; } -#ifndef SQLITE_OMIT_GENERATED_COLUMNS - else if( pTab->aCol[j].colFlags & COLFLAG_GENERATED ){ - testcase( pTab->aCol[j].colFlags & COLFLAG_VIRTUAL ); - testcase( pTab->aCol[j].colFlags & COLFLAG_STORED ); - sqlite3ErrorMsg(pParse, - "cannot UPDATE generated column \"%s\"", - pTab->aCol[j].zName); - goto update_cleanup; - } -#endif aXRef[j] = i; break; } } if( j>=pTab->nCol ){ - if( pPk==0 && sqlite3IsRowid(pChanges->a[i].zEName) ){ + if( pPk==0 && sqlite3IsRowid(pChanges->a[i].zName) ){ j = -1; chngRowid = 1; pRowidExpr = pChanges->a[i].pExpr; }else{ - sqlite3ErrorMsg(pParse, "no such column: %s", pChanges->a[i].zEName); + sqlite3ErrorMsg(pParse, "no such column: %s", pChanges->a[i].zName); pParse->checkSchema = 1; goto update_cleanup; } @@ -136394,33 +134079,6 @@ SQLITE_PRIVATE void sqlite3Update( assert( chngPk==0 || chngPk==1 ); chngKey = chngRowid + chngPk; -#ifndef SQLITE_OMIT_GENERATED_COLUMNS - /* Mark generated columns as changing if their generator expressions - ** reference any changing column. The actual aXRef[] value for - ** generated expressions is not used, other than to check to see that it - ** is non-negative, so the value of aXRef[] for generated columns can be - ** set to any non-negative number. We use 99999 so that the value is - ** obvious when looking at aXRef[] in a symbolic debugger. - */ - if( pTab->tabFlags & TF_HasGenerated ){ - int bProgress; - testcase( pTab->tabFlags & TF_HasVirtual ); - testcase( pTab->tabFlags & TF_HasStored ); - do{ - bProgress = 0; - for(i=0; inCol; i++){ - if( aXRef[i]>=0 ) continue; - if( (pTab->aCol[i].colFlags & COLFLAG_GENERATED)==0 ) continue; - if( sqlite3ExprReferencesUpdatedColumn(pTab->aCol[i].pDflt, - aXRef, chngRowid) ){ - aXRef[i] = 99999; - bProgress = 1; - } - } - }while( bProgress ); - } -#endif - /* The SET expressions are not actually used inside the WHERE loop. ** So reset the colUsed mask. Unless this is a virtual table. In that ** case, set all bits of the colUsed mask (to ensure that the virtual @@ -136465,6 +134123,9 @@ SQLITE_PRIVATE void sqlite3Update( memset(aToOpen, 1, nIdx+1); } + /* Begin generating code. */ + v = sqlite3GetVdbe(pParse); + if( v==0 ) goto update_cleanup; if( pParse->nested==0 ) sqlite3VdbeCountChanges(v); sqlite3BeginWriteOperation(pParse, pTrigger || hasFK, iDb); @@ -136562,7 +134223,6 @@ SQLITE_PRIVATE void sqlite3Update( pWInfo = 0; eOnePass = ONEPASS_SINGLE; sqlite3ExprIfFalse(pParse, pWhere, labelBreak, SQLITE_JUMPIFNULL); - bFinishSeek = 0; }else{ /* Begin the database scan. ** @@ -136589,7 +134249,6 @@ SQLITE_PRIVATE void sqlite3Update( ** strategy that uses an index for which one or more columns are being ** updated. */ eOnePass = sqlite3WhereOkOnePass(pWInfo, aiCurOnePass); - bFinishSeek = sqlite3WhereUsesDeferredSeek(pWInfo); if( eOnePass!=ONEPASS_SINGLE ){ sqlite3MultiWrite(pParse); if( eOnePass==ONEPASS_MULTI ){ @@ -136620,8 +134279,7 @@ SQLITE_PRIVATE void sqlite3Update( ** is not required) and leave the PK fields in the array of registers. */ for(i=0; iaiColumn[i]>=0 ); - sqlite3ExprCodeGetColumnOfTable(v, pTab, iDataCur, - pPk->aiColumn[i], iPk+i); + sqlite3ExprCodeGetColumnOfTable(v, pTab, iDataCur,pPk->aiColumn[i],iPk+i); } if( eOnePass ){ if( addrOpen ) sqlite3VdbeChangeToNoop(v, addrOpen); @@ -136702,16 +134360,14 @@ SQLITE_PRIVATE void sqlite3Update( pTrigger, pChanges, 0, TRIGGER_BEFORE|TRIGGER_AFTER, pTab, onError ); for(i=0; inCol; i++){ - u32 colFlags = pTab->aCol[i].colFlags; - k = sqlite3TableColumnToStorage(pTab, i) + regOld; if( oldmask==0xffffffff || (i<32 && (oldmask & MASKBIT32(i))!=0) - || (colFlags & COLFLAG_PRIMKEY)!=0 + || (pTab->aCol[i].colFlags & COLFLAG_PRIMKEY)!=0 ){ testcase( oldmask!=0xffffffff && i==31 ); - sqlite3ExprCodeGetColumnOfTable(v, pTab, iDataCur, i, k); + sqlite3ExprCodeGetColumnOfTable(v, pTab, iDataCur, i, regOld+i); }else{ - sqlite3VdbeAddOp2(v, OP_Null, 0, k); + sqlite3VdbeAddOp2(v, OP_Null, 0, regOld+i); } } if( chngRowid==0 && pPk==0 ){ @@ -136735,15 +134391,13 @@ SQLITE_PRIVATE void sqlite3Update( newmask = sqlite3TriggerColmask( pParse, pTrigger, pChanges, 1, TRIGGER_BEFORE, pTab, onError ); - for(i=0, k=regNew; inCol; i++, k++){ + for(i=0; inCol; i++){ if( i==pTab->iPKey ){ - sqlite3VdbeAddOp2(v, OP_Null, 0, k); - }else if( (pTab->aCol[i].colFlags & COLFLAG_GENERATED)!=0 ){ - if( pTab->aCol[i].colFlags & COLFLAG_VIRTUAL ) k--; + sqlite3VdbeAddOp2(v, OP_Null, 0, regNew+i); }else{ j = aXRef[i]; if( j>=0 ){ - sqlite3ExprCode(pParse, pChanges->a[j].pExpr, k); + sqlite3ExprCode(pParse, pChanges->a[j].pExpr, regNew+i); }else if( 0==(tmask&TRIGGER_BEFORE) || i>31 || (newmask & MASKBIT32(i)) ){ /* This branch loads the value of a column that will not be changed ** into a register. This is done if there are no BEFORE triggers, or @@ -136752,20 +134406,12 @@ SQLITE_PRIVATE void sqlite3Update( */ testcase( i==31 ); testcase( i==32 ); - sqlite3ExprCodeGetColumnOfTable(v, pTab, iDataCur, i, k); - bFinishSeek = 0; + sqlite3ExprCodeGetColumnOfTable(v, pTab, iDataCur, i, regNew+i); }else{ - sqlite3VdbeAddOp2(v, OP_Null, 0, k); + sqlite3VdbeAddOp2(v, OP_Null, 0, regNew+i); } } } -#ifndef SQLITE_OMIT_GENERATED_COLUMNS - if( pTab->tabFlags & TF_HasGenerated ){ - testcase( pTab->tabFlags & TF_HasVirtual ); - testcase( pTab->tabFlags & TF_HasStored ); - sqlite3ComputeGeneratedColumns(pParse, regNew, pTab); - } -#endif /* Fire any BEFORE UPDATE triggers. This happens before constraints are ** verified. One could argue that this is wrong. @@ -136798,20 +134444,11 @@ SQLITE_PRIVATE void sqlite3Update( ** BEFORE trigger runs. See test case trigger1-18.0 (added 2018-04-26) ** for an example. */ - for(i=0, k=regNew; inCol; i++, k++){ - if( pTab->aCol[i].colFlags & COLFLAG_GENERATED ){ - if( pTab->aCol[i].colFlags & COLFLAG_VIRTUAL ) k--; - }else if( aXRef[i]<0 && i!=pTab->iPKey ){ - sqlite3ExprCodeGetColumnOfTable(v, pTab, iDataCur, i, k); + for(i=0; inCol; i++){ + if( aXRef[i]<0 && i!=pTab->iPKey ){ + sqlite3ExprCodeGetColumnOfTable(v, pTab, iDataCur, i, regNew+i); } } -#ifndef SQLITE_OMIT_GENERATED_COLUMNS - if( pTab->tabFlags & TF_HasGenerated ){ - testcase( pTab->tabFlags & TF_HasVirtual ); - testcase( pTab->tabFlags & TF_HasStored ); - sqlite3ComputeGeneratedColumns(pParse, regNew, pTab); - } -#endif } if( !isView ){ @@ -136841,15 +134478,6 @@ SQLITE_PRIVATE void sqlite3Update( /* Delete the index entries associated with the current record. */ sqlite3GenerateRowIndexDelete(pParse, pTab, iDataCur, iIdxCur, aRegIdx, -1); - /* We must run the OP_FinishSeek opcode to resolve a prior - ** OP_DeferredSeek if there is any possibility that there have been - ** no OP_Column opcodes since the OP_DeferredSeek was issued. But - ** we want to avoid the OP_FinishSeek if possible, as running it - ** costs CPU cycles. */ - if( bFinishSeek ){ - sqlite3VdbeAddOp1(v, OP_FinishSeek, iDataCur); - } - /* If changing the rowid value, or if there are foreign key constraints ** to process, delete the old record. Otherwise, add a noop OP_Delete ** to invoke the pre-update hook. @@ -137026,7 +134654,6 @@ static void updateVirtualTable( /* Populate the argument registers. */ for(i=0; inCol; i++){ - assert( (pTab->aCol[i].colFlags & COLFLAG_GENERATED)==0 ); if( aXRef[i]>=0 ){ sqlite3ExprCode(pParse, pChanges->a[aXRef[i]].pExpr, regArg+2+i); }else{ @@ -137337,7 +134964,7 @@ SQLITE_PRIVATE void sqlite3UpsertDoUpdate( for(i=0; iaiColumn[i]>=0 ); - k = sqlite3TableColumnToIndex(pIdx, pPk->aiColumn[i]); + k = sqlite3ColumnOfIndex(pIdx, pPk->aiColumn[i]); sqlite3VdbeAddOp3(v, OP_Column, iCur, k, iPk+i); VdbeComment((v, "%s.%s", pIdx->zName, pTab->aCol[pPk->aiColumn[i]].zName)); @@ -137347,7 +134974,6 @@ SQLITE_PRIVATE void sqlite3UpsertDoUpdate( VdbeCoverage(v); sqlite3VdbeAddOp4(v, OP_Halt, SQLITE_CORRUPT, OE_Abort, 0, "corrupt database", P4_STATIC); - sqlite3MayAbort(pParse); sqlite3VdbeJumpHere(v, i); } } @@ -138096,12 +135722,12 @@ SQLITE_PRIVATE void sqlite3VtabDisconnect(sqlite3 *db, Table *p){ */ SQLITE_PRIVATE void sqlite3VtabUnlockList(sqlite3 *db){ VTable *p = db->pDisconnect; + db->pDisconnect = 0; assert( sqlite3BtreeHoldsAllMutexes(db) ); assert( sqlite3_mutex_held(db->mutex) ); if( p ){ - db->pDisconnect = 0; sqlite3ExpirePreparedStatements(db, 0); do { VTable *pNext = p->pNext; @@ -138248,8 +135874,6 @@ SQLITE_PRIVATE void sqlite3VtabFinishParse(Parse *pParse, Token *pEnd){ int iReg; Vdbe *v; - sqlite3MayAbort(pParse); - /* Compute the complete text of the CREATE VIRTUAL TABLE statement */ if( pEnd ){ pParse->sNameToken.n = (int)(pEnd->z - pParse->sNameToken.z) + pEnd->n; @@ -138275,13 +135899,13 @@ SQLITE_PRIVATE void sqlite3VtabFinishParse(Parse *pParse, Token *pEnd){ zStmt, pParse->regRowid ); + sqlite3DbFree(db, zStmt); v = sqlite3GetVdbe(pParse); sqlite3ChangeCookie(pParse, iDb); sqlite3VdbeAddOp0(v, OP_Expire); - zWhere = sqlite3MPrintf(db, "name=%Q AND sql=%Q", pTab->zName, zStmt); + zWhere = sqlite3MPrintf(db, "name='%q' AND type='table'", pTab->zName); sqlite3VdbeAddParseSchemaOp(v, iDb, zWhere); - sqlite3DbFree(db, zStmt); iReg = ++pParse->nMem; sqlite3VdbeLoadString(v, iReg, pTab->zName); @@ -138378,7 +136002,6 @@ static int vtabCallConstructor( } pVTable->db = db; pVTable->pMod = pMod; - pVTable->eVtabRisk = SQLITE_VTABRISK_Normal; iDb = sqlite3SchemaToIndex(db, pTab->pSchema); pTab->azModuleArg[1] = db->aDb[iDb].zDbSName; @@ -138418,7 +136041,7 @@ static int vtabCallConstructor( rc = SQLITE_ERROR; }else{ int iCol; - u16 oooHidden = 0; + u8 oooHidden = 0; /* If everything went according to plan, link the new VTable structure ** into the linked list headed by pTab->pVTable. Then loop through the ** columns of the table to see if any of them contain the token "hidden". @@ -138684,8 +136307,7 @@ SQLITE_PRIVATE int sqlite3VtabCallDestroy(sqlite3 *db, int iDb, const char *zTab } p = vtabDisconnectAll(db, pTab); xDestroy = p->pMod->pModule->xDestroy; - if( xDestroy==0 ) xDestroy = p->pMod->pModule->xDisconnect; - assert( xDestroy!=0 ); + assert( xDestroy!=0 ); /* Checked before the virtual table is created */ pTab->nTabRef++; rc = xDestroy(p->pVtab); /* Remove the sqlite3_vtab* from the aVTrans[] array, if applicable */ @@ -139068,38 +136690,28 @@ SQLITE_API int sqlite3_vtab_on_conflict(sqlite3 *db){ SQLITE_API int sqlite3_vtab_config(sqlite3 *db, int op, ...){ va_list ap; int rc = SQLITE_OK; - VtabCtx *p; #ifdef SQLITE_ENABLE_API_ARMOR if( !sqlite3SafetyCheckOk(db) ) return SQLITE_MISUSE_BKPT; #endif sqlite3_mutex_enter(db->mutex); - p = db->pVtabCtx; - if( !p ){ - rc = SQLITE_MISUSE_BKPT; - }else{ - assert( p->pTab==0 || IsVirtual(p->pTab) ); - va_start(ap, op); - switch( op ){ - case SQLITE_VTAB_CONSTRAINT_SUPPORT: { - p->pVTable->bConstraint = (u8)va_arg(ap, int); - break; - } - case SQLITE_VTAB_INNOCUOUS: { - p->pVTable->eVtabRisk = SQLITE_VTABRISK_Low; - break; - } - case SQLITE_VTAB_DIRECTONLY: { - p->pVTable->eVtabRisk = SQLITE_VTABRISK_High; - break; - } - default: { + va_start(ap, op); + switch( op ){ + case SQLITE_VTAB_CONSTRAINT_SUPPORT: { + VtabCtx *p = db->pVtabCtx; + if( !p ){ rc = SQLITE_MISUSE_BKPT; - break; + }else{ + assert( p->pTab==0 || IsVirtual(p->pTab) ); + p->pVTable->bConstraint = (u8)va_arg(ap, int); } + break; } - va_end(ap); + default: + rc = SQLITE_MISUSE_BKPT; + break; } + va_end(ap); if( rc!=SQLITE_OK ) sqlite3Error(db, rc); sqlite3_mutex_leave(db->mutex); @@ -139408,23 +137020,24 @@ struct WhereTerm { /* ** Allowed values of WhereTerm.wtFlags */ -#define TERM_DYNAMIC 0x0001 /* Need to call sqlite3ExprDelete(db, pExpr) */ -#define TERM_VIRTUAL 0x0002 /* Added by the optimizer. Do not code */ -#define TERM_CODED 0x0004 /* This term is already coded */ -#define TERM_COPIED 0x0008 /* Has a child */ -#define TERM_ORINFO 0x0010 /* Need to free the WhereTerm.u.pOrInfo object */ -#define TERM_ANDINFO 0x0020 /* Need to free the WhereTerm.u.pAndInfo obj */ -#define TERM_OR_OK 0x0040 /* Used during OR-clause processing */ +#define TERM_DYNAMIC 0x01 /* Need to call sqlite3ExprDelete(db, pExpr) */ +#define TERM_VIRTUAL 0x02 /* Added by the optimizer. Do not code */ +#define TERM_CODED 0x04 /* This term is already coded */ +#define TERM_COPIED 0x08 /* Has a child */ +#define TERM_ORINFO 0x10 /* Need to free the WhereTerm.u.pOrInfo object */ +#define TERM_ANDINFO 0x20 /* Need to free the WhereTerm.u.pAndInfo obj */ +#define TERM_OR_OK 0x40 /* Used during OR-clause processing */ #ifdef SQLITE_ENABLE_STAT4 -# define TERM_VNULL 0x0080 /* Manufactured x>NULL or x<=NULL term */ +# define TERM_VNULL 0x80 /* Manufactured x>NULL or x<=NULL term */ #else -# define TERM_VNULL 0x0000 /* Disabled if not using stat4 */ +# define TERM_VNULL 0x00 /* Disabled if not using stat4 */ #endif -#define TERM_LIKEOPT 0x0100 /* Virtual terms from the LIKE optimization */ -#define TERM_LIKECOND 0x0200 /* Conditionally this LIKE operator term */ -#define TERM_LIKE 0x0400 /* The original LIKE operator */ -#define TERM_IS 0x0800 /* Term.pExpr is an IS operator */ +#define TERM_LIKEOPT 0x100 /* Virtual terms from the LIKE optimization */ +#define TERM_LIKECOND 0x200 /* Conditionally this LIKE operator term */ +#define TERM_LIKE 0x400 /* The original LIKE operator */ +#define TERM_IS 0x800 /* Term.pExpr is an IS operator */ #define TERM_VARSELECT 0x1000 /* Term.pExpr contains a correlated sub-query */ +#define TERM_NOPARTIDX 0x2000 /* Not for use to enable a partial index */ /* ** An instance of the WhereScan object is used as an iterator for locating @@ -139567,20 +137180,6 @@ struct WhereLoopBuilder { # define SQLITE_QUERY_PLANNER_LIMIT_INCR 1000 #endif -/* -** Each instance of this object records a change to a single node -** in an expression tree to cause that node to point to a column -** of an index rather than an expression or a virtual column. All -** such transformations need to be undone at the end of WHERE clause -** processing. -*/ -typedef struct WhereExprMod WhereExprMod; -struct WhereExprMod { - WhereExprMod *pNext; /* Next translation on a list of them all */ - Expr *pExpr; /* The Expr node that was transformed */ - Expr orig; /* Original value of the Expr node */ -}; - /* ** The WHERE clause processing routine has two halves. The ** first part does the start of the WHERE loop and the second @@ -139597,25 +137196,23 @@ struct WhereInfo { ExprList *pOrderBy; /* The ORDER BY clause or NULL */ ExprList *pResultSet; /* Result set of the query */ Expr *pWhere; /* The complete WHERE clause */ + LogEst iLimit; /* LIMIT if wctrlFlags has WHERE_USE_LIMIT */ int aiCurOnePass[2]; /* OP_OpenWrite cursors for the ONEPASS opt */ int iContinue; /* Jump here to continue with next record */ int iBreak; /* Jump here to break out of the loop */ int savedNQueryLoop; /* pParse->nQueryLoop outside the WHERE loop */ u16 wctrlFlags; /* Flags originally passed to sqlite3WhereBegin() */ - LogEst iLimit; /* LIMIT if wctrlFlags has WHERE_USE_LIMIT */ u8 nLevel; /* Number of nested loop */ i8 nOBSat; /* Number of ORDER BY terms satisfied by indices */ + u8 sorted; /* True if really sorted (not just grouped) */ u8 eOnePass; /* ONEPASS_OFF, or _SINGLE, or _MULTI */ + u8 untestedTerms; /* Not all WHERE terms resolved by outer loop */ u8 eDistinct; /* One of the WHERE_DISTINCT_* values */ - unsigned bDeferredSeek :1; /* Uses OP_DeferredSeek */ - unsigned untestedTerms :1; /* Not all WHERE terms resolved by outer loop */ - unsigned bOrderedInnerLoop:1;/* True if only the inner-most loop is ordered */ - unsigned sorted :1; /* True if really sorted (not just grouped) */ - LogEst nRowOut; /* Estimated number of output rows */ + u8 bOrderedInnerLoop; /* True if only the inner-most loop is ordered */ int iTop; /* The very beginning of the WHERE loop */ WhereLoop *pLoops; /* List of all WhereLoop objects */ - WhereExprMod *pExprMods; /* Expression modifications */ Bitmask revMask; /* Mask of ORDER BY terms that need reversing */ + LogEst nRowOut; /* Estimated number of output rows */ WhereClause sWC; /* Decomposition of the WHERE clause */ WhereMaskSet sMaskSet; /* Map cursor numbers to bitmasks */ WhereLevel a[1]; /* Information about each nest loop in WHERE */ @@ -139629,8 +137226,6 @@ struct WhereInfo { SQLITE_PRIVATE Bitmask sqlite3WhereGetMask(WhereMaskSet*,int); #ifdef WHERETRACE_ENABLED SQLITE_PRIVATE void sqlite3WhereClausePrint(WhereClause *pWC); -SQLITE_PRIVATE void sqlite3WhereTermPrint(WhereTerm *pTerm, int iTerm); -SQLITE_PRIVATE void sqlite3WhereLoopPrint(WhereLoop *p, WhereClause *pWC); #endif SQLITE_PRIVATE WhereTerm *sqlite3WhereFindTerm( WhereClause *pWC, /* The WHERE clause to be searched */ @@ -140142,8 +137737,7 @@ static Expr *removeUnindexableInClauseTerms( Expr *pX /* The IN expression to be reduced */ ){ sqlite3 *db = pParse->db; - Expr *pNew; - pNew = sqlite3ExprDup(db, pX, 0); + Expr *pNew = sqlite3ExprDup(db, pX, 0); if( db->mallocFailed==0 ){ ExprList *pOrigRhs = pNew->x.pSelect->pEList; /* Original unmodified RHS */ ExprList *pOrigLhs = pNew->pLeft->x.pList; /* Original unmodified LHS */ @@ -140320,7 +137914,7 @@ static int codeEqualityTerm( if( i==iEq ){ pIn->iCur = iTab; pIn->eEndLoopOp = bRev ? OP_Prev : OP_Next; - if( iEq>0 ){ + if( iEq>0 && (pLoop->wsFlags & WHERE_VIRTUALTABLE)==0 ){ pIn->iBase = iReg - i; pIn->nPrefix = i; pLoop->wsFlags |= WHERE_IN_EARLYOUT; @@ -140551,7 +138145,7 @@ static int codeCursorHintCheckExpr(Walker *pWalker, Expr *pExpr){ assert( pHint->pIdx!=0 ); if( pExpr->op==TK_COLUMN && pExpr->iTable==pHint->iTabCur - && sqlite3TableColumnToIndex(pHint->pIdx, pExpr->iColumn)<0 + && sqlite3ColumnOfIndex(pHint->pIdx, pExpr->iColumn)<0 ){ pWalker->eCode = 1; } @@ -140619,7 +138213,7 @@ static int codeCursorHintFixExpr(Walker *pWalker, Expr *pExpr){ pExpr->iTable = reg; }else if( pHint->pIdx!=0 ){ pExpr->iTable = pHint->iIdxCur; - pExpr->iColumn = sqlite3TableColumnToIndex(pHint->pIdx, pExpr->iColumn); + pExpr->iColumn = sqlite3ColumnOfIndex(pHint->pIdx, pExpr->iColumn); assert( pExpr->iColumn>=0 ); } }else if( pExpr->op==TK_AGG_FUNCTION ){ @@ -140772,7 +138366,6 @@ static void codeDeferredSeek( assert( iIdxCur>0 ); assert( pIdx->aiColumn[pIdx->nColumn-1]==-1 ); - pWInfo->bDeferredSeek = 1; sqlite3VdbeAddOp3(v, OP_DeferredSeek, iIdxCur, 0, iCur); if( (pWInfo->wctrlFlags & WHERE_OR_SUBCLAUSE) && DbMaskAllZero(sqlite3ParseToplevel(pParse)->writeMask) @@ -140783,12 +138376,8 @@ static void codeDeferredSeek( if( ai ){ ai[0] = pTab->nCol; for(i=0; inColumn-1; i++){ - int x1, x2; assert( pIdx->aiColumn[i]nCol ); - x1 = pIdx->aiColumn[i]; - x2 = sqlite3TableColumnToStorage(pTab, x1); - testcase( x1!=x2 ); - if( x1>=0 ) ai[x2+1] = i+1; + if( pIdx->aiColumn[i]>=0 ) ai[pIdx->aiColumn[i]+1] = i+1; } sqlite3VdbeChangeP4(v, -1, (char*)ai, P4_INTARRAY); } @@ -140839,24 +138428,8 @@ typedef struct IdxExprTrans { int iTabCur; /* The cursor of the corresponding table */ int iIdxCur; /* The cursor for the index */ int iIdxCol; /* The column for the index */ - int iTabCol; /* The column for the table */ - WhereInfo *pWInfo; /* Complete WHERE clause information */ - sqlite3 *db; /* Database connection (for malloc()) */ } IdxExprTrans; -/* -** Preserve pExpr on the WhereETrans list of the WhereInfo. -*/ -static void preserveExpr(IdxExprTrans *pTrans, Expr *pExpr){ - WhereExprMod *pNew; - pNew = sqlite3DbMallocRaw(pTrans->db, sizeof(*pNew)); - if( pNew==0 ) return; - pNew->pNext = pTrans->pWInfo->pExprMods; - pTrans->pWInfo->pExprMods = pNew; - pNew->pExpr = pExpr; - memcpy(&pNew->orig, pExpr, sizeof(*pExpr)); -} - /* The walker node callback used to transform matching expressions into ** a reference to an index column for an index on an expression. ** @@ -140866,49 +138439,21 @@ static void preserveExpr(IdxExprTrans *pTrans, Expr *pExpr){ static int whereIndexExprTransNode(Walker *p, Expr *pExpr){ IdxExprTrans *pX = p->u.pIdxTrans; if( sqlite3ExprCompare(0, pExpr, pX->pIdxExpr, pX->iTabCur)==0 ){ - preserveExpr(pX, pExpr); pExpr->affExpr = sqlite3ExprAffinity(pExpr); pExpr->op = TK_COLUMN; pExpr->iTable = pX->iIdxCur; pExpr->iColumn = pX->iIdxCol; pExpr->y.pTab = 0; - testcase( ExprHasProperty(pExpr, EP_Skip) ); - testcase( ExprHasProperty(pExpr, EP_Unlikely) ); - ExprClearProperty(pExpr, EP_Skip|EP_Unlikely); return WRC_Prune; }else{ return WRC_Continue; } } -#ifndef SQLITE_OMIT_GENERATED_COLUMNS -/* A walker node callback that translates a column reference to a table -** into a corresponding column reference of an index. -*/ -static int whereIndexExprTransColumn(Walker *p, Expr *pExpr){ - if( pExpr->op==TK_COLUMN ){ - IdxExprTrans *pX = p->u.pIdxTrans; - if( pExpr->iTable==pX->iTabCur && pExpr->iColumn==pX->iTabCol ){ - assert( pExpr->y.pTab!=0 ); - preserveExpr(pX, pExpr); - pExpr->affExpr = sqlite3TableColumnAffinity(pExpr->y.pTab,pExpr->iColumn); - pExpr->iTable = pX->iIdxCur; - pExpr->iColumn = pX->iIdxCol; - pExpr->y.pTab = 0; - } - } - return WRC_Continue; -} -#endif /* SQLITE_OMIT_GENERATED_COLUMNS */ - /* ** For an indexes on expression X, locate every instance of expression X ** in pExpr and change that subexpression into a reference to the appropriate ** column of the index. -** -** 2019-10-24: Updated to also translate references to a VIRTUAL column in -** the table into references to the corresponding (stored) column of the -** index. */ static void whereIndexExprTrans( Index *pIdx, /* The Index */ @@ -140918,48 +138463,20 @@ static void whereIndexExprTrans( ){ int iIdxCol; /* Column number of the index */ ExprList *aColExpr; /* Expressions that are indexed */ - Table *pTab; Walker w; IdxExprTrans x; aColExpr = pIdx->aColExpr; - if( aColExpr==0 && !pIdx->bHasVCol ){ - /* The index does not reference any expressions or virtual columns - ** so no translations are needed. */ - return; - } - pTab = pIdx->pTable; + if( aColExpr==0 ) return; /* Not an index on expressions */ memset(&w, 0, sizeof(w)); + w.xExprCallback = whereIndexExprTransNode; w.u.pIdxTrans = &x; x.iTabCur = iTabCur; x.iIdxCur = iIdxCur; - x.pWInfo = pWInfo; - x.db = pWInfo->pParse->db; - for(iIdxCol=0; iIdxColnColumn; iIdxCol++){ - i16 iRef = pIdx->aiColumn[iIdxCol]; - if( iRef==XN_EXPR ){ - assert( aColExpr->a[iIdxCol].pExpr!=0 ); - x.pIdxExpr = aColExpr->a[iIdxCol].pExpr; - if( sqlite3ExprIsConstant(x.pIdxExpr) ) continue; - w.xExprCallback = whereIndexExprTransNode; -#ifndef SQLITE_OMIT_GENERATED_COLUMNS - }else if( iRef>=0 - && (pTab->aCol[iRef].colFlags & COLFLAG_VIRTUAL)!=0 - && (pTab->aCol[iRef].zColl==0 - || sqlite3StrICmp(pTab->aCol[iRef].zColl, sqlite3StrBINARY)==0) - ){ - /* Check to see if there are direct references to generated columns - ** that are contained in the index. Pulling the generated column - ** out of the index is an optimization only - the main table is always - ** available if the index cannot be used. To avoid unnecessary - ** complication, omit this optimization if the collating sequence for - ** the column is non-standard */ - x.iTabCol = iRef; - w.xExprCallback = whereIndexExprTransColumn; -#endif /* SQLITE_OMIT_GENERATED_COLUMNS */ - }else{ - continue; - } + for(iIdxCol=0; iIdxColnExpr; iIdxCol++){ + if( pIdx->aiColumn[iIdxCol]!=XN_EXPR ) continue; + assert( aColExpr->a[iIdxCol].pExpr!=0 ); x.iIdxCol = iIdxCol; + x.pIdxExpr = aColExpr->a[iIdxCol].pExpr; sqlite3WalkExpr(&w, pWInfo->pWhere); sqlite3WalkExprList(&w, pWInfo->pOrderBy); sqlite3WalkExprList(&w, pWInfo->pResultSet); @@ -141031,21 +138548,6 @@ SQLITE_PRIVATE Bitmask sqlite3WhereCodeOneLoopStart( pLevel->notReady = notReady & ~sqlite3WhereGetMask(&pWInfo->sMaskSet, iCur); bRev = (pWInfo->revMask>>iLevel)&1; VdbeModuleComment((v, "Begin WHERE-loop%d: %s",iLevel,pTabItem->pTab->zName)); -#if WHERETRACE_ENABLED /* 0x20800 */ - if( sqlite3WhereTrace & 0x800 ){ - sqlite3DebugPrintf("Coding level %d of %d: notReady=%llx iFrom=%d\n", - iLevel, pWInfo->nLevel, (u64)notReady, pLevel->iFrom); - sqlite3WhereLoopPrint(pLoop, pWC); - } - if( sqlite3WhereTrace & 0x20000 ){ - if( iLevel==0 ){ - sqlite3DebugPrintf("WHERE clause being coded:\n"); - sqlite3TreeViewExpr(0, pWInfo->pWhere, 0); - } - sqlite3DebugPrintf("All WHERE-clause terms before coding:\n"); - sqlite3WhereClausePrint(pWC); - } -#endif /* Create labels for the "break" and "continue" instructions ** for the current loop. Jump to addrBrk to break out of a loop. @@ -141125,12 +138627,9 @@ SQLITE_PRIVATE Bitmask sqlite3WhereCodeOneLoopStart( iIn = pLevel->u.in.nIn; for(j=nConstraint-1; j>=0; j--){ pTerm = pLoop->aLTerm[j]; - if( (pTerm->eOperator & WO_IN)!=0 ) iIn--; if( j<16 && (pLoop->u.vtab.omitMask>>j)&1 ){ disableTerm(pLevel, pTerm); - }else if( (pTerm->eOperator & WO_IN)!=0 - && sqlite3ExprVectorSize(pTerm->pExpr->pLeft)==1 - ){ + }else if( (pTerm->eOperator & WO_IN)!=0 ){ Expr *pCompare; /* The comparison operator */ Expr *pRight; /* RHS of the comparison */ VdbeOp *pOp; /* Opcode to access the value of the IN constraint */ @@ -141141,8 +138640,8 @@ SQLITE_PRIVATE Bitmask sqlite3WhereCodeOneLoopStart( ** encoding of the value in the register, so it *must* be reloaded. */ assert( pLevel->u.in.aInLoop!=0 || db->mallocFailed ); if( !db->mallocFailed ){ - assert( iIn>=0 && iInu.in.nIn ); - pOp = sqlite3VdbeGetOp(v, pLevel->u.in.aInLoop[iIn].addrInTop); + assert( iIn>0 ); + pOp = sqlite3VdbeGetOp(v, pLevel->u.in.aInLoop[--iIn].addrInTop); assert( pOp->opcode==OP_Column || pOp->opcode==OP_Rowid ); assert( pOp->opcode!=OP_Column || pOp->p3==iReg+j+2 ); assert( pOp->opcode!=OP_Rowid || pOp->p2==iReg+j+2 ); @@ -141166,7 +138665,6 @@ SQLITE_PRIVATE Bitmask sqlite3WhereCodeOneLoopStart( } } } - assert( iIn==0 || db->mallocFailed ); /* These registers need to be preserved in case there is an IN operator ** loop. So we could deallocate the registers here (and potentially ** reuse them later) if (pLoop->wsFlags & WHERE_IN_ABLE)==0. But it seems @@ -141432,7 +138930,7 @@ SQLITE_PRIVATE Bitmask sqlite3WhereCodeOneLoopStart( ){ assert( bSeekPastNull==0 && nExtraReg==0 && nBtm==0 && nTop==0 ); assert( pRangeEnd==0 && pRangeStart==0 ); - testcase( pLoop->nSkip>0 ); + assert( pLoop->nSkip==0 ); nExtraReg = 1; bSeekPastNull = 1; pLevel->regBignull = regBignull = ++pParse->nMem; @@ -141631,10 +139129,10 @@ SQLITE_PRIVATE Bitmask sqlite3WhereCodeOneLoopStart( if( omitTable ){ /* pIdx is a covering index. No need to access the main table. */ }else if( HasRowid(pIdx->pTable) ){ - if( (pWInfo->wctrlFlags & WHERE_SEEK_TABLE) - || ( (pWInfo->wctrlFlags & WHERE_SEEK_UNIQ_TABLE)!=0 - && (pWInfo->eOnePass==ONEPASS_SINGLE || pLoop->nLTerm==0) ) - ){ + if( (pWInfo->wctrlFlags & WHERE_SEEK_TABLE) || ( + (pWInfo->wctrlFlags & WHERE_SEEK_UNIQ_TABLE) + && (pWInfo->eOnePass==ONEPASS_SINGLE) + )){ iRowidReg = ++pParse->nMem; sqlite3VdbeAddOp2(v, OP_IdxRowid, iIdxCur, iRowidReg); sqlite3VdbeAddOp3(v, OP_NotExists, iCur, 0, iRowidReg); @@ -141646,53 +139144,40 @@ SQLITE_PRIVATE Bitmask sqlite3WhereCodeOneLoopStart( Index *pPk = sqlite3PrimaryKeyIndex(pIdx->pTable); iRowidReg = sqlite3GetTempRange(pParse, pPk->nKeyCol); for(j=0; jnKeyCol; j++){ - k = sqlite3TableColumnToIndex(pIdx, pPk->aiColumn[j]); + k = sqlite3ColumnOfIndex(pIdx, pPk->aiColumn[j]); sqlite3VdbeAddOp3(v, OP_Column, iIdxCur, k, iRowidReg+j); } sqlite3VdbeAddOp4Int(v, OP_NotFound, iCur, addrCont, iRowidReg, pPk->nKeyCol); VdbeCoverage(v); } - if( pLevel->iLeftJoin==0 ){ - /* If pIdx is an index on one or more expressions, then look through - ** all the expressions in pWInfo and try to transform matching expressions - ** into reference to index columns. Also attempt to translate references - ** to virtual columns in the table into references to (stored) columns - ** of the index. - ** - ** Do not do this for the RHS of a LEFT JOIN. This is because the - ** expression may be evaluated after OP_NullRow has been executed on - ** the cursor. In this case it is important to do the full evaluation, - ** as the result of the expression may not be NULL, even if all table - ** column values are. https://www.sqlite.org/src/info/7fa8049685b50b5a - ** - ** Also, do not do this when processing one index an a multi-index - ** OR clause, since the transformation will become invalid once we - ** move forward to the next index. - ** https://sqlite.org/src/info/4e8e4857d32d401f - */ - if( (pWInfo->wctrlFlags & WHERE_OR_SUBCLAUSE)==0 ){ - whereIndexExprTrans(pIdx, iCur, iIdxCur, pWInfo); - } - - /* If a partial index is driving the loop, try to eliminate WHERE clause - ** terms from the query that must be true due to the WHERE clause of - ** the partial index. - ** - ** 2019-11-02 ticket 623eff57e76d45f6: This optimization does not work - ** for a LEFT JOIN. - */ - if( pIdx->pPartIdxWhere ){ - whereApplyPartialIndexConstraints(pIdx->pPartIdxWhere, iCur, pWC); - } - }else{ - testcase( pIdx->pPartIdxWhere ); - /* The following assert() is not a requirement, merely an observation: - ** The OR-optimization doesn't work for the right hand table of - ** a LEFT JOIN: */ - assert( (pWInfo->wctrlFlags & WHERE_OR_SUBCLAUSE)==0 ); + /* If pIdx is an index on one or more expressions, then look through + ** all the expressions in pWInfo and try to transform matching expressions + ** into reference to index columns. + ** + ** Do not do this for the RHS of a LEFT JOIN. This is because the + ** expression may be evaluated after OP_NullRow has been executed on + ** the cursor. In this case it is important to do the full evaluation, + ** as the result of the expression may not be NULL, even if all table + ** column values are. https://www.sqlite.org/src/info/7fa8049685b50b5a + ** + ** Also, do not do this when processing one index an a multi-index + ** OR clause, since the transformation will become invalid once we + ** move forward to the next index. + ** https://sqlite.org/src/info/4e8e4857d32d401f + */ + if( pLevel->iLeftJoin==0 && (pWInfo->wctrlFlags & WHERE_OR_SUBCLAUSE)==0 ){ + whereIndexExprTrans(pIdx, iCur, iIdxCur, pWInfo); } - + + /* If a partial index is driving the loop, try to eliminate WHERE clause + ** terms from the query that must be true due to the WHERE clause of + ** the partial index + */ + if( pIdx->pPartIdxWhere ){ + whereApplyPartialIndexConstraints(pIdx->pPartIdxWhere, iCur, pWC); + } + /* Record the instruction used to terminate the loop. */ if( pLoop->wsFlags & WHERE_ONEROW ){ pLevel->op = OP_Noop; @@ -141877,9 +139362,9 @@ SQLITE_PRIVATE Bitmask sqlite3WhereCodeOneLoopStart( WhereInfo *pSubWInfo; /* Info for single OR-term scan */ Expr *pOrExpr = pOrTerm->pExpr; /* Current OR clause term */ int jmp1 = 0; /* Address of jump operation */ - testcase( (pTabItem[0].fg.jointype & JT_LEFT)!=0 - && !ExprHasProperty(pOrExpr, EP_FromJoin) - ); /* See TH3 vtab25.400 and ticket 614b25314c766238 */ + assert( (pTabItem[0].fg.jointype & JT_LEFT)==0 + || ExprHasProperty(pOrExpr, EP_FromJoin) + ); if( pAndExpr ){ pAndExpr->pLeft = pOrExpr; pOrExpr = pAndExpr; @@ -141919,7 +139404,7 @@ SQLITE_PRIVATE Bitmask sqlite3WhereCodeOneLoopStart( r = sqlite3GetTempRange(pParse, nPk); for(iPk=0; iPkaiColumn[iPk]; - sqlite3ExprCodeGetColumnOfTable(v, pTab, iCur, iCol,r+iPk); + sqlite3ExprCodeGetColumnOfTable(v, pTab, iCur, iCol, r+iPk); } /* Check if the temp table already contains this key. If so, @@ -142101,10 +139586,6 @@ SQLITE_PRIVATE Bitmask sqlite3WhereCodeOneLoopStart( VdbeNoopComment((v, "WhereTerm[%d] (%p) priority=%d", pWC->nTerm-j, pTerm, iLoop)); } - if( sqlite3WhereTrace & 0x800 ){ - sqlite3DebugPrintf("Coding auxiliary constraint:\n"); - sqlite3WhereTermPrint(pTerm, pWC->nTerm-j); - } #endif sqlite3ExprIfFalse(pParse, pE, addrCont, SQLITE_JUMPIFNULL); if( skipLikeAddr ) sqlite3VdbeJumpHere(v, skipLikeAddr); @@ -142128,14 +139609,8 @@ SQLITE_PRIVATE Bitmask sqlite3WhereCodeOneLoopStart( if( (pTerm->eOperator & (WO_EQ|WO_IS))==0 ) continue; if( (pTerm->eOperator & WO_EQUIV)==0 ) continue; if( pTerm->leftCursor!=iCur ) continue; - if( pTabItem->fg.jointype & JT_LEFT ) continue; + if( pLevel->iLeftJoin ) continue; pE = pTerm->pExpr; -#ifdef WHERETRACE_ENABLED /* 0x800 */ - if( sqlite3WhereTrace & 0x800 ){ - sqlite3DebugPrintf("Coding transitive constraint:\n"); - sqlite3WhereTermPrint(pTerm, pWC->nTerm-j); - } -#endif assert( !ExprHasProperty(pE, EP_FromJoin) ); assert( (pTerm->prereqRight & pLevel->notReady)!=0 ); pAlt = sqlite3WhereFindTerm(pWC, iCur, pTerm->u.leftColumn, notReady, @@ -142178,17 +139653,6 @@ SQLITE_PRIVATE Bitmask sqlite3WhereCodeOneLoopStart( } } -#if WHERETRACE_ENABLED /* 0x20800 */ - if( sqlite3WhereTrace & 0x20000 ){ - sqlite3DebugPrintf("All WHERE-clause terms after coding level %d:\n", - iLevel); - sqlite3WhereClausePrint(pWC); - } - if( sqlite3WhereTrace & 0x800 ){ - sqlite3DebugPrintf("End Coding level %d: notReady=%llx\n", - iLevel, (u64)pLevel->notReady); - } -#endif return pLevel->notReady; } @@ -142305,14 +139769,39 @@ static int allowedOp(int op){ /* ** Commute a comparison operator. Expressions of the form "X op Y" ** are converted into "Y op X". +** +** If left/right precedence rules come into play when determining the +** collating sequence, then COLLATE operators are adjusted to ensure +** that the collating sequence does not change. For example: +** "Y collate NOCASE op X" becomes "X op Y" because any collation sequence on +** the left hand side of a comparison overrides any collation sequence +** attached to the right. For the same reason the EP_Collate flag +** is not commuted. +** +** The return value is extra flags that are added to the WhereTerm object +** after it is commuted. The only extra flag ever added is TERM_NOPARTIDX +** which prevents the term from being used to enable a partial index if +** COLLATE changes have been made. */ static u16 exprCommute(Parse *pParse, Expr *pExpr){ - if( pExpr->pLeft->op==TK_VECTOR - || pExpr->pRight->op==TK_VECTOR - || sqlite3BinaryCompareCollSeq(pParse, pExpr->pLeft, pExpr->pRight) != - sqlite3BinaryCompareCollSeq(pParse, pExpr->pRight, pExpr->pLeft) - ){ - pExpr->flags ^= EP_Commuted; + u16 expRight = (pExpr->pRight->flags & EP_Collate); + u16 expLeft = (pExpr->pLeft->flags & EP_Collate); + u16 wtFlags = 0; + assert( allowedOp(pExpr->op) && pExpr->op!=TK_IN ); + if( expRight==expLeft ){ + /* Either X and Y both have COLLATE operator or neither do */ + if( expRight ){ + /* Both X and Y have COLLATE operators. Make sure X is always + ** used by clearing the EP_Collate flag from Y. */ + pExpr->pRight->flags &= ~EP_Collate; + wtFlags |= TERM_NOPARTIDX; + }else if( sqlite3ExprCollSeq(pParse, pExpr->pLeft)!=0 ){ + /* Neither X nor Y have COLLATE operators, but X has a non-default + ** collating sequence. So add the EP_Collate marker on X to cause + ** it to be searched first. */ + pExpr->pLeft->flags |= EP_Collate; + wtFlags |= TERM_NOPARTIDX; + } } SWAP(Expr*,pExpr->pRight,pExpr->pLeft); if( pExpr->op>=TK_GT ){ @@ -142323,7 +139812,7 @@ static u16 exprCommute(Parse *pParse, Expr *pExpr){ assert( pExpr->op>=TK_GT && pExpr->op<=TK_GE ); pExpr->op = ((pExpr->op-TK_GT)^2)+TK_GT; } - return 0; + return wtFlags; } /* @@ -143101,7 +140590,7 @@ static int termIsEquivalence(Parse *pParse, Expr *pExpr){ ){ return 0; } - pColl = sqlite3ExprCompareCollSeq(pParse, pExpr); + pColl = sqlite3BinaryCompareCollSeq(pParse, pExpr->pLeft, pExpr->pRight); if( sqlite3IsBinary(pColl) ) return 1; return sqlite3ExprCollSeqMatch(pParse, pExpr->pLeft, pExpr->pRight); } @@ -143494,7 +140983,6 @@ static void exprAnalyze( 0, sqlite3ExprDup(db, pRight, 0)); if( ExprHasProperty(pExpr, EP_FromJoin) && pNewExpr ){ ExprSetProperty(pNewExpr, EP_FromJoin); - pNewExpr->iRightJoinTable = pExpr->iRightJoinTable; } idxNew = whereClauseInsert(pWC, pNewExpr, TERM_VIRTUAL|TERM_DYNAMIC); testcase( idxNew==0 ); @@ -143551,15 +141039,11 @@ static void exprAnalyze( ** expression). The WhereTerm.iField variable identifies the index within ** the vector on the LHS that the virtual term represents. ** - ** This only works if the RHS is a simple SELECT (not a compound) that does - ** not use window functions. + ** This only works if the RHS is a simple SELECT, not a compound */ if( pWC->op==TK_AND && pExpr->op==TK_IN && pTerm->iField==0 && pExpr->pLeft->op==TK_VECTOR && pExpr->x.pSelect->pPrior==0 -#ifndef SQLITE_OMIT_WINDOWFUNC - && pExpr->x.pSelect->pWin==0 -#endif ){ int i; for(i=0; ipLeft); i++){ @@ -143717,10 +141201,9 @@ SQLITE_PRIVATE Bitmask sqlite3WhereExprUsageNN(WhereMaskSet *pMaskSet, Expr *p){ mask |= sqlite3WhereExprListUsage(pMaskSet, p->x.pList); } #ifndef SQLITE_OMIT_WINDOWFUNC - if( (p->op==TK_FUNCTION || p->op==TK_AGG_FUNCTION) && p->y.pWin ){ + if( p->op==TK_FUNCTION && p->y.pWin ){ mask |= sqlite3WhereExprListUsage(pMaskSet, p->y.pWin->pPartition); mask |= sqlite3WhereExprListUsage(pMaskSet, p->y.pWin->pOrderBy); - mask |= sqlite3WhereExprUsage(pMaskSet, p->y.pWin->pFilter); } #endif return mask; @@ -143796,9 +141279,6 @@ SQLITE_PRIVATE void sqlite3WhereTabFuncArgs( pRhs = sqlite3PExpr(pParse, TK_UPLUS, sqlite3ExprDup(pParse->db, pArgs->a[j].pExpr, 0), 0); pTerm = sqlite3PExpr(pParse, TK_EQ, pColRef, pRhs); - if( pItem->fg.jointype & JT_LEFT ){ - sqlite3SetJoinExpr(pTerm, pItem->iCursor); - } whereClauseInsert(pWC, pTerm, TERM_DYNAMIC); } } @@ -143927,7 +141407,7 @@ SQLITE_PRIVATE int sqlite3WhereBreakLabel(WhereInfo *pWInfo){ /* ** Return ONEPASS_OFF (0) if an UPDATE or DELETE statement is unable to -** operate directly on the rowids returned by a WHERE clause. Return +** operate directly on the rowis returned by a WHERE clause. Return ** ONEPASS_SINGLE (1) if the statement can operation directly because only ** a single row is to be changed. Return ONEPASS_MULTI (2) if the one-pass ** optimization can be used on multiple @@ -143954,14 +141434,6 @@ SQLITE_PRIVATE int sqlite3WhereOkOnePass(WhereInfo *pWInfo, int *aiCur){ return pWInfo->eOnePass; } -/* -** Return TRUE if the WHERE loop uses the OP_DeferredSeek opcode to move -** the data cursor to the row selected by the index cursor. -*/ -SQLITE_PRIVATE int sqlite3WhereUsesDeferredSeek(WhereInfo *pWInfo){ - return pWInfo->bDeferredSeek; -} - /* ** Move the content of pSrc into pDest */ @@ -144094,7 +141566,8 @@ static WhereTerm *whereScanNext(WhereScan *pScan){ continue; } assert(pX->pLeft); - pColl = sqlite3ExprCompareCollSeq(pParse, pX); + pColl = sqlite3BinaryCompareCollSeq(pParse, + pX->pLeft, pX->pRight); if( pColl==0 ) pColl = pParse->db->pDfltColl; if( sqlite3StrICmp(pColl->zName, pScan->zCollName) ){ continue; @@ -144420,7 +141893,7 @@ static void translateColumnToCopy( ** are no-ops. */ #if !defined(SQLITE_OMIT_VIRTUALTABLE) && defined(WHERETRACE_ENABLED) -static void whereTraceIndexInfoInputs(sqlite3_index_info *p){ +static void TRACE_IDX_INPUTS(sqlite3_index_info *p){ int i; if( !sqlite3WhereTrace ) return; for(i=0; inConstraint; i++){ @@ -144438,7 +141911,7 @@ static void whereTraceIndexInfoInputs(sqlite3_index_info *p){ p->aOrderBy[i].desc); } } -static void whereTraceIndexInfoOutputs(sqlite3_index_info *p){ +static void TRACE_IDX_OUTPUTS(sqlite3_index_info *p){ int i; if( !sqlite3WhereTrace ) return; for(i=0; inConstraint; i++){ @@ -144454,8 +141927,8 @@ static void whereTraceIndexInfoOutputs(sqlite3_index_info *p){ sqlite3DebugPrintf(" estimatedRows=%lld\n", p->estimatedRows); } #else -#define whereTraceIndexInfoInputs(A) -#define whereTraceIndexInfoOutputs(A) +#define TRACE_IDX_INPUTS(A) +#define TRACE_IDX_OUTPUTS(A) #endif #ifndef SQLITE_OMIT_AUTOMATIC_INDEX @@ -144615,8 +142088,7 @@ static void constructAutomaticIndex( Expr *pX = pTerm->pExpr; idxCols |= cMask; pIdx->aiColumn[n] = pTerm->u.leftColumn; - pColl = sqlite3ExprCompareCollSeq(pParse, pX); - assert( pColl!=0 || pParse->nErr>0 ); /* TH3 collate01.800 */ + pColl = sqlite3BinaryCompareCollSeq(pParse, pX->pLeft, pX->pRight); pIdx->azColl[n] = pColl ? pColl->zName : sqlite3StrBINARY; n++; } @@ -144685,8 +142157,8 @@ static void constructAutomaticIndex( pTabItem->fg.viaCoroutine = 0; }else{ sqlite3VdbeAddOp2(v, OP_Next, pLevel->iTabCur, addrTop+1); VdbeCoverage(v); - sqlite3VdbeChangeP5(v, SQLITE_STMTSTATUS_AUTOINDEX); } + sqlite3VdbeChangeP5(v, SQLITE_STMTSTATUS_AUTOINDEX); sqlite3VdbeJumpHere(v, addrTop); sqlite3ReleaseTempReg(pParse, regRecord); @@ -144765,14 +142237,23 @@ static sqlite3_index_info *allocateIndexInfo( sqlite3ErrorMsg(pParse, "out of memory"); return 0; } + + /* Initialize the structure. The sqlite3_index_info structure contains + ** many fields that are declared "const" to prevent xBestIndex from + ** changing them. We have to do some funky casting in order to + ** initialize those fields. + */ pHidden = (struct HiddenIndexInfo*)&pIdxInfo[1]; pIdxCons = (struct sqlite3_index_constraint*)&pHidden[1]; pIdxOrderBy = (struct sqlite3_index_orderby*)&pIdxCons[nTerm]; pUsage = (struct sqlite3_index_constraint_usage*)&pIdxOrderBy[nOrderBy]; - pIdxInfo->nOrderBy = nOrderBy; - pIdxInfo->aConstraint = pIdxCons; - pIdxInfo->aOrderBy = pIdxOrderBy; - pIdxInfo->aConstraintUsage = pUsage; + *(int*)&pIdxInfo->nConstraint = nTerm; + *(int*)&pIdxInfo->nOrderBy = nOrderBy; + *(struct sqlite3_index_constraint**)&pIdxInfo->aConstraint = pIdxCons; + *(struct sqlite3_index_orderby**)&pIdxInfo->aOrderBy = pIdxOrderBy; + *(struct sqlite3_index_constraint_usage**)&pIdxInfo->aConstraintUsage = + pUsage; + pHidden->pWC = pWC; pHidden->pParse = pParse; for(i=j=0, pTerm=pWC->a; inTerm; i++, pTerm++){ @@ -144786,13 +142267,18 @@ static sqlite3_index_info *allocateIndexInfo( testcase( pTerm->eOperator & WO_ALL ); if( (pTerm->eOperator & ~(WO_EQUIV))==0 ) continue; if( pTerm->wtFlags & TERM_VNULL ) continue; - - /* tag-20191211-002: WHERE-clause constraints are not useful to the - ** right-hand table of a LEFT JOIN. See tag-20191211-001 for the - ** equivalent restriction for ordinary tables. */ if( (pSrc->fg.jointype & JT_LEFT)!=0 && !ExprHasProperty(pTerm->pExpr, EP_FromJoin) + && (pTerm->eOperator & (WO_IS|WO_ISNULL)) ){ + /* An "IS" term in the WHERE clause where the virtual table is the rhs + ** of a LEFT JOIN. Do not pass this term to the virtual table + ** implementation, as this can lead to incorrect results from SQL such + ** as: + ** + ** "LEFT JOIN vtab WHERE vtab.col IS NULL" */ + testcase( pTerm->eOperator & WO_ISNULL ); + testcase( pTerm->eOperator & WO_IS ); continue; } assert( pTerm->u.leftColumn>=(-1) ); @@ -144823,8 +142309,7 @@ static sqlite3_index_info *allocateIndexInfo( if( op & (WO_LT|WO_LE|WO_GT|WO_GE) && sqlite3ExprIsVector(pTerm->pExpr->pRight) ){ - testcase( j!=i ); - if( j<16 ) mNoOmit |= (1 << j); + if( i<16 ) mNoOmit |= (1 << i); if( op==WO_LT ) pIdxCons[j].op = WO_LE; if( op==WO_GT ) pIdxCons[j].op = WO_GE; } @@ -144832,7 +142317,6 @@ static sqlite3_index_info *allocateIndexInfo( j++; } - pIdxInfo->nConstraint = j; for(i=0; ia[i].pExpr; pIdxOrderBy[i].iColumn = pExpr->iColumn; @@ -144863,9 +142347,9 @@ static int vtabBestIndex(Parse *pParse, Table *pTab, sqlite3_index_info *p){ sqlite3_vtab *pVtab = sqlite3GetVTable(pParse->db, pTab)->pVtab; int rc; - whereTraceIndexInfoInputs(p); + TRACE_IDX_INPUTS(p); rc = pVtab->pModule->xBestIndex(pVtab, p); - whereTraceIndexInfoOutputs(p); + TRACE_IDX_OUTPUTS(p); if( rc!=SQLITE_OK && rc!=SQLITE_CONSTRAINT ){ if( rc==SQLITE_NOMEM ){ @@ -145546,17 +143030,16 @@ static int whereInScanEst( /* ** Print the content of a WhereTerm object */ -SQLITE_PRIVATE void sqlite3WhereTermPrint(WhereTerm *pTerm, int iTerm){ +static void whereTermPrint(WhereTerm *pTerm, int iTerm){ if( pTerm==0 ){ sqlite3DebugPrintf("TERM-%-3d NULL\n", iTerm); }else{ - char zType[8]; + char zType[4]; char zLeft[50]; - memcpy(zType, "....", 5); + memcpy(zType, "...", 4); if( pTerm->wtFlags & TERM_VIRTUAL ) zType[0] = 'V'; if( pTerm->eOperator & WO_EQUIV ) zType[1] = 'E'; if( ExprHasProperty(pTerm->pExpr, EP_FromJoin) ) zType[2] = 'L'; - if( pTerm->wtFlags & TERM_CODED ) zType[3] = 'C'; if( pTerm->eOperator & WO_SINGLE ){ sqlite3_snprintf(sizeof(zLeft),zLeft,"left={%d:%d}", pTerm->leftCursor, pTerm->u.leftColumn); @@ -145567,21 +143050,14 @@ SQLITE_PRIVATE void sqlite3WhereTermPrint(WhereTerm *pTerm, int iTerm){ sqlite3_snprintf(sizeof(zLeft),zLeft,"left=%d", pTerm->leftCursor); } sqlite3DebugPrintf( - "TERM-%-3d %p %s %-12s op=%03x wtFlags=%04x", - iTerm, pTerm, zType, zLeft, pTerm->eOperator, pTerm->wtFlags); - /* The 0x10000 .wheretrace flag causes extra information to be - ** shown about each Term */ - if( sqlite3WhereTrace & 0x10000 ){ - sqlite3DebugPrintf(" prob=%-3d prereq=%llx,%llx", - pTerm->truthProb, (u64)pTerm->prereqAll, (u64)pTerm->prereqRight); - } + "TERM-%-3d %p %s %-12s prob=%-3d op=0x%03x wtFlags=0x%04x", + iTerm, pTerm, zType, zLeft, pTerm->truthProb, + pTerm->eOperator, pTerm->wtFlags); if( pTerm->iField ){ - sqlite3DebugPrintf(" iField=%d", pTerm->iField); + sqlite3DebugPrintf(" iField=%d\n", pTerm->iField); + }else{ + sqlite3DebugPrintf("\n"); } - if( pTerm->iParent>=0 ){ - sqlite3DebugPrintf(" iParent=%d", pTerm->iParent); - } - sqlite3DebugPrintf("\n"); sqlite3TreeViewExpr(0, pTerm->pExpr, 0); } } @@ -145594,7 +143070,7 @@ SQLITE_PRIVATE void sqlite3WhereTermPrint(WhereTerm *pTerm, int iTerm){ SQLITE_PRIVATE void sqlite3WhereClausePrint(WhereClause *pWC){ int i; for(i=0; inTerm; i++){ - sqlite3WhereTermPrint(&pWC->a[i], i); + whereTermPrint(&pWC->a[i], i); } } #endif @@ -145603,7 +143079,7 @@ SQLITE_PRIVATE void sqlite3WhereClausePrint(WhereClause *pWC){ /* ** Print a WhereLoop object for debugging purposes */ -SQLITE_PRIVATE void sqlite3WhereLoopPrint(WhereLoop *p, WhereClause *pWC){ +static void whereLoopPrint(WhereLoop *p, WhereClause *pWC){ WhereInfo *pWInfo = pWC->pWInfo; int nb = 1+(pWInfo->pTabList->nSrc+3)/4; struct SrcList_item *pItem = pWInfo->pTabList->a + p->iTab; @@ -145628,7 +143104,7 @@ SQLITE_PRIVATE void sqlite3WhereLoopPrint(WhereLoop *p, WhereClause *pWC){ }else{ char *z; if( p->u.vtab.idxStr ){ - z = sqlite3_mprintf("(%d,\"%s\",%#x)", + z = sqlite3_mprintf("(%d,\"%s\",%x)", p->u.vtab.idxNum, p->u.vtab.idxStr, p->u.vtab.omitMask); }else{ z = sqlite3_mprintf("(%d,%x)", p->u.vtab.idxNum, p->u.vtab.omitMask); @@ -145645,7 +143121,7 @@ SQLITE_PRIVATE void sqlite3WhereLoopPrint(WhereLoop *p, WhereClause *pWC){ if( p->nLTerm && (sqlite3WhereTrace & 0x100)!=0 ){ int i; for(i=0; inLTerm; i++){ - sqlite3WhereTermPrint(p->aLTerm[i], i); + whereTermPrint(p->aLTerm[i], i); } } } @@ -145749,7 +143225,6 @@ static void whereInfoFree(sqlite3 *db, WhereInfo *pWInfo){ pWInfo->pLoops = p->pNextLoop; whereLoopDelete(db, p); } - assert( pWInfo->pExprMods==0 ); sqlite3DbFreeNN(db, pWInfo); } @@ -145951,8 +143426,6 @@ static int whereLoopInsert(WhereLoopBuilder *pBuilder, WhereLoop *pTemplate){ } pBuilder->iPlanLimit--; - whereLoopAdjustCost(pWInfo->pLoops, pTemplate); - /* If pBuilder->pOrSet is defined, then only keep track of the costs ** and prereqs. */ @@ -145967,7 +143440,7 @@ static int whereLoopInsert(WhereLoopBuilder *pBuilder, WhereLoop *pTemplate){ #if WHERETRACE_ENABLED /* 0x8 */ if( sqlite3WhereTrace & 0x8 ){ sqlite3DebugPrintf(x?" or-%d: ":" or-X: ", n); - sqlite3WhereLoopPrint(pTemplate, pBuilder->pWC); + whereLoopPrint(pTemplate, pBuilder->pWC); } #endif } @@ -145976,6 +143449,7 @@ static int whereLoopInsert(WhereLoopBuilder *pBuilder, WhereLoop *pTemplate){ /* Look for an existing WhereLoop to replace with pTemplate */ + whereLoopAdjustCost(pWInfo->pLoops, pTemplate); ppPrev = whereLoopFindLesser(&pWInfo->pLoops, pTemplate); if( ppPrev==0 ){ @@ -145984,7 +143458,7 @@ static int whereLoopInsert(WhereLoopBuilder *pBuilder, WhereLoop *pTemplate){ #if WHERETRACE_ENABLED /* 0x8 */ if( sqlite3WhereTrace & 0x8 ){ sqlite3DebugPrintf(" skip: "); - sqlite3WhereLoopPrint(pTemplate, pBuilder->pWC); + whereLoopPrint(pTemplate, pBuilder->pWC); } #endif return SQLITE_OK; @@ -146000,12 +143474,12 @@ static int whereLoopInsert(WhereLoopBuilder *pBuilder, WhereLoop *pTemplate){ if( sqlite3WhereTrace & 0x8 ){ if( p!=0 ){ sqlite3DebugPrintf("replace: "); - sqlite3WhereLoopPrint(p, pBuilder->pWC); + whereLoopPrint(p, pBuilder->pWC); sqlite3DebugPrintf(" with: "); }else{ sqlite3DebugPrintf(" add: "); } - sqlite3WhereLoopPrint(pTemplate, pBuilder->pWC); + whereLoopPrint(pTemplate, pBuilder->pWC); } #endif if( p==0 ){ @@ -146029,7 +143503,7 @@ static int whereLoopInsert(WhereLoopBuilder *pBuilder, WhereLoop *pTemplate){ #if WHERETRACE_ENABLED /* 0x8 */ if( sqlite3WhereTrace & 0x8 ){ sqlite3DebugPrintf(" delete: "); - sqlite3WhereLoopPrint(pToDel, pBuilder->pWC); + whereLoopPrint(pToDel, pBuilder->pWC); } #endif whereLoopDelete(db, pToDel); @@ -146238,9 +143712,8 @@ static int whereLoopAddBtreeIndex( pNew = pBuilder->pNew; if( db->mallocFailed ) return SQLITE_NOMEM_BKPT; - WHERETRACE(0x800, ("BEGIN %s.addBtreeIdx(%s), nEq=%d, nSkip=%d\n", - pProbe->pTable->zName,pProbe->zName, - pNew->u.btree.nEq, pNew->nSkip)); + WHERETRACE(0x800, ("BEGIN %s.addBtreeIdx(%s), nEq=%d\n", + pProbe->pTable->zName,pProbe->zName, pNew->u.btree.nEq)); assert( (pNew->wsFlags & WHERE_VIRTUALTABLE)==0 ); assert( (pNew->wsFlags & WHERE_TOP_LIMIT)==0 ); @@ -146286,9 +143759,9 @@ static int whereLoopAddBtreeIndex( ** to mix with a lower range bound from some other source */ if( pTerm->wtFlags & TERM_LIKEOPT && pTerm->eOperator==WO_LT ) continue; - /* tag-20191211-001: Do not allow constraints from the WHERE clause to - ** be used by the right table of a LEFT JOIN. Only constraints in the - ** ON clause are allowed. See tag-20191211-002 for the vtab equivalent. */ + /* Do not allow constraints from the WHERE clause to be used by the + ** right table of a LEFT JOIN. Only constraints in the ON clause are + ** allowed */ if( (pSrc->fg.jointype & JT_LEFT)!=0 && !ExprHasProperty(pTerm->pExpr, EP_FromJoin) ){ @@ -146537,7 +144010,6 @@ static int whereLoopAddBtreeIndex( assert( 42==sqlite3LogEst(18) ); if( saved_nEq==saved_nSkip && saved_nEq+1nKeyCol - && saved_nEq==pNew->nLTerm && pProbe->noSkipScan==0 && OptimizationEnabled(db, SQLITE_SkipScan) && pProbe->aiRowLogEst[saved_nEq+1]>=42 /* TUNING: Minimum for skip-scan */ @@ -146606,25 +144078,20 @@ static int indexMightHelpWithOrderBy( /* Check to see if a partial index with pPartIndexWhere can be used ** in the current query. Return true if it can be and false if not. */ -static int whereUsablePartialIndex( - int iTab, /* The table for which we want an index */ - int isLeft, /* True if iTab is the right table of a LEFT JOIN */ - WhereClause *pWC, /* The WHERE clause of the query */ - Expr *pWhere /* The WHERE clause from the partial index */ -){ +static int whereUsablePartialIndex(int iTab, WhereClause *pWC, Expr *pWhere){ int i; WhereTerm *pTerm; Parse *pParse = pWC->pWInfo->pParse; while( pWhere->op==TK_AND ){ - if( !whereUsablePartialIndex(iTab,isLeft,pWC,pWhere->pLeft) ) return 0; + if( !whereUsablePartialIndex(iTab,pWC,pWhere->pLeft) ) return 0; pWhere = pWhere->pRight; } if( pParse->db->flags & SQLITE_EnableQPSG ) pParse = 0; for(i=0, pTerm=pWC->a; inTerm; i++, pTerm++){ Expr *pExpr; + if( pTerm->wtFlags & TERM_NOPARTIDX ) continue; pExpr = pTerm->pExpr; if( (!ExprHasProperty(pExpr, EP_FromJoin) || pExpr->iRightJoinTable==iTab) - && (isLeft==0 || ExprHasProperty(pExpr, EP_FromJoin)) && sqlite3ExprImpliesExpr(pParse, pExpr, pWhere, iTab) ){ return 1; @@ -146787,11 +144254,8 @@ static int whereLoopAddBtree( for(; rc==SQLITE_OK && pProbe; pProbe=(pSrc->pIBIndex ? 0 : pProbe->pNext), iSortIdx++ ){ - int isLeft = (pSrc->fg.jointype & JT_OUTER)!=0; if( pProbe->pPartIdxWhere!=0 - && !whereUsablePartialIndex(pSrc->iCursor, isLeft, pWC, - pProbe->pPartIdxWhere) - ){ + && !whereUsablePartialIndex(pSrc->iCursor, pWC, pProbe->pPartIdxWhere) ){ testcase( pNew->iTab!=pSrc->iCursor ); /* See ticket [98d973b8f5] */ continue; /* Partial index inappropriate for this query */ } @@ -147018,14 +144482,7 @@ static int whereLoopAddVirtualOne( if( iTerm>mxTerm ) mxTerm = iTerm; testcase( iTerm==15 ); testcase( iTerm==16 ); - if( pUsage[i].omit ){ - if( i<16 && ((1<u.vtab.omitMask |= 1<u.vtab.omitMask |= 1<eOperator & WO_IN)!=0 ){ /* A virtual table that is constrained by an IN clause may not ** consume the ORDER BY clause because (1) the order of IN terms @@ -147038,6 +144495,7 @@ static int whereLoopAddVirtualOne( } } } + pNew->u.vtab.omitMask &= ~mNoOmit; pNew->nLTerm = mxTerm+1; for(i=0; i<=mxTerm; i++){ @@ -147094,7 +144552,7 @@ SQLITE_API const char *sqlite3_vtab_collation(sqlite3_index_info *pIdxInfo, int int iTerm = pIdxInfo->aConstraint[iCons].iTermOffset; Expr *pX = pHidden->pWC->a[iTerm].pExpr; if( pX->pLeft ){ - pC = sqlite3ExprCompareCollSeq(pHidden->pParse, pX); + pC = sqlite3BinaryCompareCollSeq(pHidden->pParse, pX->pLeft, pX->pRight); } zRet = (pC ? pC->zName : sqlite3StrBINARY); } @@ -147319,8 +144777,7 @@ static int whereLoopAddOr( if( rc==SQLITE_OK ){ rc = whereLoopAddOr(&sSubBuild, mPrereq, mUnusable); } - assert( rc==SQLITE_OK || rc==SQLITE_DONE || sCur.n==0 ); - testcase( rc==SQLITE_DONE ); + assert( rc==SQLITE_OK || sCur.n==0 ); if( sCur.n==0 ){ sSum.n = 0; break; @@ -147528,9 +144985,7 @@ static i8 wherePathSatisfiesOrderBy( pLoop = pLast; } if( pLoop->wsFlags & WHERE_VIRTUALTABLE ){ - if( pLoop->u.vtab.isOrdered && (wctrlFlags & WHERE_DISTINCTBY)==0 ){ - obSat = obDone; - } + if( pLoop->u.vtab.isOrdered ) obSat = obDone; break; }else if( wctrlFlags & WHERE_DISTINCTBY ){ pLoop->u.btree.nDistinctCol = 0; @@ -148633,7 +146088,6 @@ SQLITE_PRIVATE WhereInfo *sqlite3WhereBegin( } } if( sqlite3WhereTrace & 0x100 ){ /* Display all terms of the WHERE clause */ - sqlite3DebugPrintf("---- WHERE clause at start of analysis:\n"); sqlite3WhereClausePrint(sWLB.pWC); } #endif @@ -148650,7 +146104,7 @@ SQLITE_PRIVATE WhereInfo *sqlite3WhereBegin( "ABCDEFGHIJKLMNOPQRSTUVWYXZ"; for(p=pWInfo->pLoops, i=0; p; p=p->pNextLoop, i++){ p->cId = zLabel[i%(sizeof(zLabel)-1)]; - sqlite3WhereLoopPrint(p, sWLB.pWC); + whereLoopPrint(p, sWLB.pWC); } } #endif @@ -148690,7 +146144,7 @@ SQLITE_PRIVATE WhereInfo *sqlite3WhereBegin( } sqlite3DebugPrintf("\n"); for(ii=0; iinLevel; ii++){ - sqlite3WhereLoopPrint(pWInfo->a[ii].pWLoop, sWLB.pWC); + whereLoopPrint(pWInfo->a[ii].pWLoop, sWLB.pWC); } } #endif @@ -148715,14 +146169,14 @@ SQLITE_PRIVATE WhereInfo *sqlite3WhereBegin( ** then table t2 can be omitted from the following: ** ** SELECT v1, v3 FROM t1 - ** LEFT JOIN t2 ON (t1.ipk=t2.ipk) - ** LEFT JOIN t3 ON (t1.ipk=t3.ipk) + ** LEFT JOIN t2 USING (t1.ipk=t2.ipk) + ** LEFT JOIN t3 USING (t1.ipk=t3.ipk) ** ** or from: ** ** SELECT DISTINCT v1, v3 FROM t1 ** LEFT JOIN t2 - ** LEFT JOIN t3 ON (t1.ipk=t3.ipk) + ** LEFT JOIN t3 USING (t1.ipk=t3.ipk) */ notReady = ~(Bitmask)0; if( pWInfo->nLevel>=2 @@ -148772,13 +146226,7 @@ SQLITE_PRIVATE WhereInfo *sqlite3WhereBegin( nTabList--; } } -#if defined(WHERETRACE_ENABLED) - if( sqlite3WhereTrace & 0x100 ){ /* Display all terms of the WHERE clause */ - sqlite3DebugPrintf("---- WHERE clause at end of analysis:\n"); - sqlite3WhereClausePrint(sWLB.pWC); - } WHERETRACE(0xffff,("*** Optimizer Finished ***\n")); -#endif pWInfo->pParse->nQueryLoop += pWInfo->nRowOut; /* If the caller is an UPDATE or DELETE statement that is requesting @@ -148855,13 +146303,7 @@ SQLITE_PRIVATE WhereInfo *sqlite3WhereBegin( assert( pTabItem->iCursor==pLevel->iTabCur ); testcase( pWInfo->eOnePass==ONEPASS_OFF && pTab->nCol==BMS-1 ); testcase( pWInfo->eOnePass==ONEPASS_OFF && pTab->nCol==BMS ); - if( pWInfo->eOnePass==ONEPASS_OFF - && pTab->nColtabFlags & (TF_HasGenerated|TF_WithoutRowid))==0 - ){ - /* If we know that only a prefix of the record will be used, - ** it is advantageous to reduce the "column count" field in - ** the P4 operand of the OP_OpenRead/Write opcode. */ + if( pWInfo->eOnePass==ONEPASS_OFF && pTab->nColcolUsed; int n = 0; for(; b; b=b>>1, n++){} @@ -149082,26 +146524,10 @@ SQLITE_PRIVATE void sqlite3WhereEnd(WhereInfo *pWInfo){ if( pIn->eEndLoopOp!=OP_Noop ){ if( pIn->nPrefix ){ assert( pLoop->wsFlags & WHERE_IN_EARLYOUT ); - if( (pLoop->wsFlags & WHERE_VIRTUALTABLE)==0 ){ - sqlite3VdbeAddOp4Int(v, OP_IfNoHope, pLevel->iIdxCur, - sqlite3VdbeCurrentAddr(v)+2+(pLevel->iLeftJoin!=0), - pIn->iBase, pIn->nPrefix); - VdbeCoverage(v); - } - if( pLevel->iLeftJoin ){ - /* For LEFT JOIN queries, cursor pIn->iCur may not have been - ** opened yet. This occurs for WHERE clauses such as - ** "a = ? AND b IN (...)", where the index is on (a, b). If - ** the RHS of the (a=?) is NULL, then the "b IN (...)" may - ** never have been coded, but the body of the loop run to - ** return the null-row. So, if the cursor is not open yet, - ** jump over the OP_Next or OP_Prev instruction about to - ** be coded. */ - sqlite3VdbeAddOp2(v, OP_IfNotOpen, pIn->iCur, - sqlite3VdbeCurrentAddr(v) + 2 - ); - VdbeCoverage(v); - } + sqlite3VdbeAddOp4Int(v, OP_IfNoHope, pLevel->iIdxCur, + sqlite3VdbeCurrentAddr(v)+2, + pIn->iBase, pIn->nPrefix); + VdbeCoverage(v); } sqlite3VdbeAddOp2(v, pIn->eEndLoopOp, pIn->iCur, pIn->addrInTop); VdbeCoverage(v); @@ -149239,11 +146665,8 @@ SQLITE_PRIVATE void sqlite3WhereEnd(WhereInfo *pWInfo){ Index *pPk = sqlite3PrimaryKeyIndex(pTab); x = pPk->aiColumn[x]; assert( x>=0 ); - }else{ - testcase( x!=sqlite3StorageColumnToTable(pTab,x) ); - x = sqlite3StorageColumnToTable(pTab,x); } - x = sqlite3TableColumnToIndex(pIdx, x); + x = sqlite3ColumnOfIndex(pIdx, x); if( x>=0 ){ pOp->p2 = x; pOp->p1 = pLevel->iIdxCur; @@ -149266,14 +146689,6 @@ SQLITE_PRIVATE void sqlite3WhereEnd(WhereInfo *pWInfo){ } } - /* Undo all Expr node modifications */ - while( pWInfo->pExprMods ){ - WhereExprMod *p = pWInfo->pExprMods; - pWInfo->pExprMods = p->pNext; - memcpy(p->pExpr, &p->orig, sizeof(p->orig)); - sqlite3DbFree(db, p); - } - /* Final cleanup */ pParse->nQueryLoop = pWInfo->savedNQueryLoop; @@ -150072,21 +147487,8 @@ static int selectWindowRewriteExprCb(Walker *pWalker, Expr *pExpr){ case TK_AGG_FUNCTION: case TK_COLUMN: { - int iCol = -1; - if( p->pSub ){ - int i; - for(i=0; ipSub->nExpr; i++){ - if( 0==sqlite3ExprCompare(0, p->pSub->a[i].pExpr, pExpr, -1) ){ - iCol = i; - break; - } - } - } - if( iCol<0 ){ - Expr *pDup = sqlite3ExprDup(pParse->db, pExpr, 0); - if( pDup && pDup->op==TK_AGG_FUNCTION ) pDup->op = TK_FUNCTION; - p->pSub = sqlite3ExprListAppend(pParse, p->pSub, pDup); - } + Expr *pDup = sqlite3ExprDup(pParse->db, pExpr, 0); + p->pSub = sqlite3ExprListAppend(pParse, p->pSub, pDup); if( p->pSub ){ assert( ExprHasProperty(pExpr, EP_Static)==0 ); ExprSetProperty(pExpr, EP_Static); @@ -150095,11 +147497,11 @@ static int selectWindowRewriteExprCb(Walker *pWalker, Expr *pExpr){ memset(pExpr, 0, sizeof(Expr)); pExpr->op = TK_COLUMN; - pExpr->iColumn = (iCol<0 ? p->pSub->nExpr-1: iCol); + pExpr->iColumn = p->pSub->nExpr-1; pExpr->iTable = p->pWin->iEphCsr; pExpr->y.pTab = p->pTab; } - if( pParse->db->mallocFailed ) return WRC_Abort; + break; } @@ -150180,13 +147582,10 @@ static ExprList *exprListAppendList( int i; int nInit = pList ? pList->nExpr : 0; for(i=0; inExpr; i++){ - int iDummy; Expr *pDup = sqlite3ExprDup(pParse->db, pAppend->a[i].pExpr, 0); - assert( pDup==0 || !ExprHasProperty(pDup, EP_MemToken) ); - if( bIntToNull && pDup && sqlite3ExprIsInteger(pDup, &iDummy) ){ + if( bIntToNull && pDup && pDup->op==TK_INTEGER ){ pDup->op = TK_NULL; pDup->flags &= ~(EP_IntValue|EP_IsTrue|EP_IsFalse); - pDup->u.zToken = 0; } pList = sqlite3ExprListAppend(pParse, pList, pDup); if( pList ) pList->a[nInit+i].sortFlags = pAppend->a[i].sortFlags; @@ -150204,7 +147603,7 @@ static ExprList *exprListAppendList( */ SQLITE_PRIVATE int sqlite3WindowRewrite(Parse *pParse, Select *p){ int rc = SQLITE_OK; - if( p->pWin && p->pPrior==0 && (p->selFlags & SF_WinRewrite)==0 ){ + if( p->pWin && p->pPrior==0 ){ Vdbe *v = sqlite3GetVdbe(pParse); sqlite3 *db = pParse->db; Select *pSub = 0; /* The subquery */ @@ -150221,7 +147620,7 @@ SQLITE_PRIVATE int sqlite3WindowRewrite(Parse *pParse, Select *p){ pTab = sqlite3DbMallocZero(db, sizeof(Table)); if( pTab==0 ){ - return sqlite3ErrorToParser(db, SQLITE_NOMEM); + return SQLITE_NOMEM; } p->pSrc = 0; @@ -150229,12 +147628,11 @@ SQLITE_PRIVATE int sqlite3WindowRewrite(Parse *pParse, Select *p){ p->pGroupBy = 0; p->pHaving = 0; p->selFlags &= ~SF_Aggregate; - p->selFlags |= SF_WinRewrite; /* Create the ORDER BY clause for the sub-select. This is the concatenation ** of the window PARTITION and ORDER BY clauses. Then, if this makes it ** redundant, remove the ORDER BY from the parent SELECT. */ - pSort = exprListAppendList(pParse, 0, pMWin->pPartition, 1); + pSort = sqlite3ExprListDup(db, pMWin->pPartition, 0); pSort = exprListAppendList(pParse, pSort, pMWin->pOrderBy, 1); if( pSort && p->pOrderBy && p->pOrderBy->nExpr<=pSort->nExpr ){ int nSave = pSort->nExpr; @@ -150308,9 +147706,6 @@ SQLITE_PRIVATE int sqlite3WindowRewrite(Parse *pParse, Select *p){ pSub->selFlags |= SF_Expanded; pTab2 = sqlite3ResultSetOfSelect(pParse, pSub, SQLITE_AFF_NONE); if( pTab2==0 ){ - /* Might actually be some other kind of error, but in that case - ** pParse->nErr will be set, so if SQLITE_NOMEM is set, we will get - ** the correct error message regardless. */ rc = SQLITE_NOMEM; }else{ memcpy(pTab, pTab2, sizeof(Table)); @@ -150318,6 +147713,10 @@ SQLITE_PRIVATE int sqlite3WindowRewrite(Parse *pParse, Select *p){ p->pSrc->a[0].pTab = pTab; pTab = pTab2; } + sqlite3VdbeAddOp2(v, OP_OpenEphemeral, pMWin->iEphCsr, pSublist->nExpr); + sqlite3VdbeAddOp2(v, OP_OpenDup, pMWin->iEphCsr+1, pMWin->iEphCsr); + sqlite3VdbeAddOp2(v, OP_OpenDup, pMWin->iEphCsr+2, pMWin->iEphCsr); + sqlite3VdbeAddOp2(v, OP_OpenDup, pMWin->iEphCsr+3, pMWin->iEphCsr); }else{ sqlite3SelectDelete(db, pSub); } @@ -150325,13 +147724,6 @@ SQLITE_PRIVATE int sqlite3WindowRewrite(Parse *pParse, Select *p){ sqlite3DbFree(db, pTab); } - if( rc ){ - if( pParse->nErr==0 ){ - assert( pParse->db->mallocFailed ); - sqlite3ErrorToParser(pParse->db, SQLITE_NOMEM); - } - sqlite3SelectReset(pParse, p); - } return rc; } @@ -150551,8 +147943,8 @@ SQLITE_PRIVATE void sqlite3WindowAttach(Parse *pParse, Expr *p, Window *pWin){ ** SELECT, or (b) the windows already linked use a compatible window frame. */ SQLITE_PRIVATE void sqlite3WindowLink(Select *pSel, Window *pWin){ - if( pSel!=0 - && (0==pSel->pWin || 0==sqlite3WindowCompare(0, pSel->pWin, pWin, 0)) + if( 0==pSel->pWin + || 0==sqlite3WindowCompare(0, pSel->pWin, pWin, 0) ){ pWin->pNextWin = pSel->pWin; if( pSel->pWin ){ @@ -150564,29 +147956,20 @@ SQLITE_PRIVATE void sqlite3WindowLink(Select *pSel, Window *pWin){ } /* -** Return 0 if the two window objects are identical, 1 if they are -** different, or 2 if it cannot be determined if the objects are identical -** or not. Identical window objects can be processed in a single scan. +** Return 0 if the two window objects are identical, or non-zero otherwise. +** Identical window objects can be processed in a single scan. */ SQLITE_PRIVATE int sqlite3WindowCompare(Parse *pParse, Window *p1, Window *p2, int bFilter){ - int res; - if( NEVER(p1==0) || NEVER(p2==0) ) return 1; if( p1->eFrmType!=p2->eFrmType ) return 1; if( p1->eStart!=p2->eStart ) return 1; if( p1->eEnd!=p2->eEnd ) return 1; if( p1->eExclude!=p2->eExclude ) return 1; if( sqlite3ExprCompare(pParse, p1->pStart, p2->pStart, -1) ) return 1; if( sqlite3ExprCompare(pParse, p1->pEnd, p2->pEnd, -1) ) return 1; - if( (res = sqlite3ExprListCompare(p1->pPartition, p2->pPartition, -1)) ){ - return res; - } - if( (res = sqlite3ExprListCompare(p1->pOrderBy, p2->pOrderBy, -1)) ){ - return res; - } + if( sqlite3ExprListCompare(p1->pPartition, p2->pPartition, -1) ) return 1; + if( sqlite3ExprListCompare(p1->pOrderBy, p2->pOrderBy, -1) ) return 1; if( bFilter ){ - if( (res = sqlite3ExprCompare(pParse, p1->pFilter, p2->pFilter, -1)) ){ - return res; - } + if( sqlite3ExprCompare(pParse, p1->pFilter, p2->pFilter, -1) ) return 1; } return 0; } @@ -150597,17 +147980,10 @@ SQLITE_PRIVATE int sqlite3WindowCompare(Parse *pParse, Window *p1, Window *p2, i ** to begin iterating through the sub-query results. It is used to allocate ** and initialize registers and cursors used by sqlite3WindowCodeStep(). */ -SQLITE_PRIVATE void sqlite3WindowCodeInit(Parse *pParse, Select *pSelect){ - int nEphExpr = pSelect->pSrc->a[0].pSelect->pEList->nExpr; - Window *pMWin = pSelect->pWin; +SQLITE_PRIVATE void sqlite3WindowCodeInit(Parse *pParse, Window *pMWin){ Window *pWin; Vdbe *v = sqlite3GetVdbe(pParse); - sqlite3VdbeAddOp2(v, OP_OpenEphemeral, pMWin->iEphCsr, nEphExpr); - sqlite3VdbeAddOp2(v, OP_OpenDup, pMWin->iEphCsr+1, pMWin->iEphCsr); - sqlite3VdbeAddOp2(v, OP_OpenDup, pMWin->iEphCsr+2, pMWin->iEphCsr); - sqlite3VdbeAddOp2(v, OP_OpenDup, pMWin->iEphCsr+3, pMWin->iEphCsr); - /* Allocate registers to use for PARTITION BY values, if any. Initialize ** said registers to NULL. */ if( pMWin->pPartition ){ @@ -150873,7 +148249,7 @@ static void windowAggStep( /* All OVER clauses in the same window function aggregate step must ** be the same. */ - assert( pWin==pMWin || sqlite3WindowCompare(pParse,pWin,pMWin,0)!=1 ); + assert( pWin==pMWin || sqlite3WindowCompare(pParse,pWin,pMWin,0)==0 ); for(i=0; izName!=nth_valueName ){ @@ -152369,9 +149745,8 @@ struct FrameBound { int eType; Expr *pExpr; }; ** shared across database connections. */ static void disableLookaside(Parse *pParse){ - sqlite3 *db = pParse->db; pParse->disableLookaside++; - DisableLookaside; + pParse->db->lookaside.bDisable++; } @@ -152535,28 +149910,28 @@ static void disableLookaside(Parse *pParse){ #endif /************* Begin control #defines *****************************************/ #define YYCODETYPE unsigned short int -#define YYNOCODE 310 +#define YYNOCODE 307 #define YYACTIONTYPE unsigned short int -#define YYWILDCARD 100 +#define YYWILDCARD 98 #define sqlite3ParserTOKENTYPE Token typedef union { int yyinit; sqlite3ParserTOKENTYPE yy0; - SrcList* yy47; - u8 yy58; - struct FrameBound yy77; - With* yy131; - int yy192; - Expr* yy202; - struct {int value; int mask;} yy207; - struct TrigEvent yy230; - ExprList* yy242; - Window* yy303; - Upsert* yy318; - const char* yy436; - TriggerStep* yy447; - Select* yy539; - IdList* yy600; + const char* yy8; + Select* yy25; + int yy32; + Expr* yy46; + struct FrameBound yy57; + u8 yy118; + ExprList* yy138; + Upsert* yy288; + With* yy297; + IdList* yy406; + Window* yy455; + struct {int value; int mask;} yy495; + TriggerStep* yy527; + struct TrigEvent yy572; + SrcList* yy609; } YYMINORTYPE; #ifndef YYSTACKDEPTH #define YYSTACKDEPTH 100 @@ -152572,18 +149947,17 @@ typedef union { #define sqlite3ParserCTX_FETCH Parse *pParse=yypParser->pParse; #define sqlite3ParserCTX_STORE yypParser->pParse=pParse; #define YYFALLBACK 1 -#define YYNSTATE 551 -#define YYNRULE 385 -#define YYNRULE_WITH_ACTION 325 -#define YYNTOKEN 181 -#define YY_MAX_SHIFT 550 -#define YY_MIN_SHIFTREDUCE 801 -#define YY_MAX_SHIFTREDUCE 1185 -#define YY_ERROR_ACTION 1186 -#define YY_ACCEPT_ACTION 1187 -#define YY_NO_ACTION 1188 -#define YY_MIN_REDUCE 1189 -#define YY_MAX_REDUCE 1573 +#define YYNSTATE 543 +#define YYNRULE 381 +#define YYNTOKEN 179 +#define YY_MAX_SHIFT 542 +#define YY_MIN_SHIFTREDUCE 790 +#define YY_MAX_SHIFTREDUCE 1170 +#define YY_ERROR_ACTION 1171 +#define YY_ACCEPT_ACTION 1172 +#define YY_NO_ACTION 1173 +#define YY_MIN_REDUCE 1174 +#define YY_MAX_REDUCE 1554 /************* End control #defines *******************************************/ #define YY_NLOOKAHEAD ((int)(sizeof(yy_lookahead)/sizeof(yy_lookahead[0]))) @@ -152650,583 +150024,573 @@ typedef union { ** yy_default[] Default action for each state. ** *********** Begin parsing tables **********************************************/ -#define YY_ACTTAB_COUNT (1958) +#define YY_ACTTAB_COUNT (1913) static const YYACTIONTYPE yy_action[] = { - /* 0 */ 544, 1220, 544, 449, 1258, 544, 1237, 544, 114, 111, - /* 10 */ 211, 544, 1535, 544, 1258, 521, 114, 111, 211, 390, - /* 20 */ 1230, 342, 42, 42, 42, 42, 1223, 42, 42, 71, - /* 30 */ 71, 935, 1222, 71, 71, 71, 71, 1460, 1491, 936, - /* 40 */ 818, 451, 6, 121, 122, 112, 1163, 1163, 1004, 1007, - /* 50 */ 997, 997, 119, 119, 120, 120, 120, 120, 1541, 390, - /* 60 */ 1356, 1515, 550, 2, 1191, 194, 526, 434, 143, 291, - /* 70 */ 526, 136, 526, 369, 261, 502, 272, 383, 1271, 525, - /* 80 */ 501, 491, 164, 121, 122, 112, 1163, 1163, 1004, 1007, - /* 90 */ 997, 997, 119, 119, 120, 120, 120, 120, 1356, 440, - /* 100 */ 1512, 118, 118, 118, 118, 117, 117, 116, 116, 116, - /* 110 */ 115, 422, 266, 266, 266, 266, 1496, 356, 1498, 433, - /* 120 */ 355, 1496, 515, 522, 1483, 541, 1112, 541, 1112, 390, - /* 130 */ 403, 241, 208, 114, 111, 211, 98, 290, 535, 221, - /* 140 */ 1027, 118, 118, 118, 118, 117, 117, 116, 116, 116, - /* 150 */ 115, 422, 1140, 121, 122, 112, 1163, 1163, 1004, 1007, - /* 160 */ 997, 997, 119, 119, 120, 120, 120, 120, 404, 426, - /* 170 */ 117, 117, 116, 116, 116, 115, 422, 1416, 466, 123, - /* 180 */ 118, 118, 118, 118, 117, 117, 116, 116, 116, 115, - /* 190 */ 422, 116, 116, 116, 115, 422, 538, 538, 538, 390, - /* 200 */ 503, 120, 120, 120, 120, 113, 1049, 1140, 1141, 1142, - /* 210 */ 1049, 118, 118, 118, 118, 117, 117, 116, 116, 116, - /* 220 */ 115, 422, 1459, 121, 122, 112, 1163, 1163, 1004, 1007, - /* 230 */ 997, 997, 119, 119, 120, 120, 120, 120, 390, 442, - /* 240 */ 314, 83, 461, 81, 357, 380, 1140, 80, 118, 118, - /* 250 */ 118, 118, 117, 117, 116, 116, 116, 115, 422, 179, - /* 260 */ 432, 422, 121, 122, 112, 1163, 1163, 1004, 1007, 997, - /* 270 */ 997, 119, 119, 120, 120, 120, 120, 432, 431, 266, - /* 280 */ 266, 118, 118, 118, 118, 117, 117, 116, 116, 116, - /* 290 */ 115, 422, 541, 1107, 901, 504, 1140, 114, 111, 211, - /* 300 */ 1429, 1140, 1141, 1142, 206, 489, 1107, 390, 447, 1107, - /* 310 */ 543, 328, 120, 120, 120, 120, 298, 1429, 1431, 17, - /* 320 */ 118, 118, 118, 118, 117, 117, 116, 116, 116, 115, - /* 330 */ 422, 121, 122, 112, 1163, 1163, 1004, 1007, 997, 997, - /* 340 */ 119, 119, 120, 120, 120, 120, 390, 1356, 432, 1140, - /* 350 */ 480, 1140, 1141, 1142, 994, 994, 1005, 1008, 443, 118, - /* 360 */ 118, 118, 118, 117, 117, 116, 116, 116, 115, 422, - /* 370 */ 121, 122, 112, 1163, 1163, 1004, 1007, 997, 997, 119, - /* 380 */ 119, 120, 120, 120, 120, 1052, 1052, 463, 1429, 118, - /* 390 */ 118, 118, 118, 117, 117, 116, 116, 116, 115, 422, - /* 400 */ 1140, 449, 544, 1424, 1140, 1141, 1142, 233, 964, 1140, - /* 410 */ 479, 476, 475, 171, 358, 390, 164, 405, 412, 840, - /* 420 */ 474, 164, 185, 332, 71, 71, 1241, 998, 118, 118, - /* 430 */ 118, 118, 117, 117, 116, 116, 116, 115, 422, 121, - /* 440 */ 122, 112, 1163, 1163, 1004, 1007, 997, 997, 119, 119, - /* 450 */ 120, 120, 120, 120, 390, 1140, 1141, 1142, 833, 12, - /* 460 */ 313, 507, 163, 354, 1140, 1141, 1142, 114, 111, 211, - /* 470 */ 506, 290, 535, 544, 276, 180, 290, 535, 121, 122, - /* 480 */ 112, 1163, 1163, 1004, 1007, 997, 997, 119, 119, 120, - /* 490 */ 120, 120, 120, 343, 482, 71, 71, 118, 118, 118, - /* 500 */ 118, 117, 117, 116, 116, 116, 115, 422, 1140, 209, - /* 510 */ 409, 521, 1140, 1107, 1569, 376, 252, 269, 340, 485, - /* 520 */ 335, 484, 238, 390, 511, 362, 1107, 1125, 331, 1107, - /* 530 */ 191, 407, 286, 32, 455, 441, 118, 118, 118, 118, - /* 540 */ 117, 117, 116, 116, 116, 115, 422, 121, 122, 112, - /* 550 */ 1163, 1163, 1004, 1007, 997, 997, 119, 119, 120, 120, - /* 560 */ 120, 120, 390, 1140, 1141, 1142, 985, 1140, 1141, 1142, - /* 570 */ 1140, 233, 490, 1490, 479, 476, 475, 6, 163, 544, - /* 580 */ 510, 544, 115, 422, 474, 5, 121, 122, 112, 1163, - /* 590 */ 1163, 1004, 1007, 997, 997, 119, 119, 120, 120, 120, - /* 600 */ 120, 13, 13, 13, 13, 118, 118, 118, 118, 117, - /* 610 */ 117, 116, 116, 116, 115, 422, 401, 500, 406, 544, - /* 620 */ 1484, 542, 1140, 890, 890, 1140, 1141, 1142, 1471, 1140, - /* 630 */ 275, 390, 806, 807, 808, 969, 420, 420, 420, 16, - /* 640 */ 16, 55, 55, 1240, 118, 118, 118, 118, 117, 117, - /* 650 */ 116, 116, 116, 115, 422, 121, 122, 112, 1163, 1163, - /* 660 */ 1004, 1007, 997, 997, 119, 119, 120, 120, 120, 120, - /* 670 */ 390, 1187, 1, 1, 550, 2, 1191, 1140, 1141, 1142, - /* 680 */ 194, 291, 896, 136, 1140, 1141, 1142, 895, 519, 1490, - /* 690 */ 1271, 3, 378, 6, 121, 122, 112, 1163, 1163, 1004, - /* 700 */ 1007, 997, 997, 119, 119, 120, 120, 120, 120, 856, - /* 710 */ 544, 922, 544, 118, 118, 118, 118, 117, 117, 116, - /* 720 */ 116, 116, 115, 422, 266, 266, 1090, 1567, 1140, 549, - /* 730 */ 1567, 1191, 13, 13, 13, 13, 291, 541, 136, 390, - /* 740 */ 483, 419, 418, 964, 342, 1271, 466, 408, 857, 279, - /* 750 */ 140, 221, 118, 118, 118, 118, 117, 117, 116, 116, - /* 760 */ 116, 115, 422, 121, 122, 112, 1163, 1163, 1004, 1007, - /* 770 */ 997, 997, 119, 119, 120, 120, 120, 120, 544, 266, - /* 780 */ 266, 426, 390, 1140, 1141, 1142, 1170, 828, 1170, 466, - /* 790 */ 429, 145, 541, 1144, 399, 313, 437, 301, 836, 1488, - /* 800 */ 71, 71, 410, 6, 1088, 471, 221, 100, 112, 1163, - /* 810 */ 1163, 1004, 1007, 997, 997, 119, 119, 120, 120, 120, - /* 820 */ 120, 118, 118, 118, 118, 117, 117, 116, 116, 116, - /* 830 */ 115, 422, 237, 1423, 544, 449, 426, 287, 984, 544, - /* 840 */ 236, 235, 234, 828, 97, 527, 427, 1263, 1263, 1144, - /* 850 */ 492, 306, 428, 836, 975, 544, 71, 71, 974, 1239, - /* 860 */ 544, 51, 51, 300, 118, 118, 118, 118, 117, 117, - /* 870 */ 116, 116, 116, 115, 422, 194, 103, 70, 70, 266, - /* 880 */ 266, 544, 71, 71, 266, 266, 30, 389, 342, 974, - /* 890 */ 974, 976, 541, 526, 1107, 326, 390, 541, 493, 395, - /* 900 */ 1468, 195, 528, 13, 13, 1356, 240, 1107, 277, 280, - /* 910 */ 1107, 280, 303, 455, 305, 331, 390, 31, 188, 417, - /* 920 */ 121, 122, 112, 1163, 1163, 1004, 1007, 997, 997, 119, - /* 930 */ 119, 120, 120, 120, 120, 142, 390, 363, 455, 984, - /* 940 */ 121, 122, 112, 1163, 1163, 1004, 1007, 997, 997, 119, - /* 950 */ 119, 120, 120, 120, 120, 975, 321, 1140, 324, 974, - /* 960 */ 121, 110, 112, 1163, 1163, 1004, 1007, 997, 997, 119, - /* 970 */ 119, 120, 120, 120, 120, 462, 375, 1183, 118, 118, - /* 980 */ 118, 118, 117, 117, 116, 116, 116, 115, 422, 1140, - /* 990 */ 974, 974, 976, 304, 9, 364, 244, 360, 118, 118, - /* 1000 */ 118, 118, 117, 117, 116, 116, 116, 115, 422, 312, - /* 1010 */ 544, 342, 1140, 1141, 1142, 299, 290, 535, 118, 118, - /* 1020 */ 118, 118, 117, 117, 116, 116, 116, 115, 422, 1261, - /* 1030 */ 1261, 1161, 13, 13, 278, 419, 418, 466, 390, 921, - /* 1040 */ 260, 260, 289, 1167, 1140, 1141, 1142, 189, 1169, 266, - /* 1050 */ 266, 466, 388, 541, 1184, 544, 1168, 263, 144, 487, - /* 1060 */ 920, 544, 541, 122, 112, 1163, 1163, 1004, 1007, 997, - /* 1070 */ 997, 119, 119, 120, 120, 120, 120, 71, 71, 1140, - /* 1080 */ 1170, 1270, 1170, 13, 13, 896, 1068, 1161, 544, 466, - /* 1090 */ 895, 107, 536, 1489, 4, 1266, 1107, 6, 523, 1047, - /* 1100 */ 12, 1069, 1090, 1568, 311, 453, 1568, 518, 539, 1107, - /* 1110 */ 56, 56, 1107, 1487, 421, 1356, 1070, 6, 343, 285, - /* 1120 */ 118, 118, 118, 118, 117, 117, 116, 116, 116, 115, - /* 1130 */ 422, 423, 1269, 319, 1140, 1141, 1142, 876, 266, 266, - /* 1140 */ 1275, 107, 536, 533, 4, 1486, 293, 877, 1209, 6, - /* 1150 */ 210, 541, 541, 164, 1540, 494, 414, 865, 539, 267, - /* 1160 */ 267, 1212, 396, 509, 497, 204, 266, 266, 394, 529, - /* 1170 */ 8, 984, 541, 517, 544, 920, 456, 105, 105, 541, - /* 1180 */ 1088, 423, 266, 266, 106, 415, 423, 546, 545, 266, - /* 1190 */ 266, 974, 516, 533, 1371, 541, 15, 15, 266, 266, - /* 1200 */ 454, 1118, 541, 266, 266, 1068, 1370, 513, 290, 535, - /* 1210 */ 544, 541, 512, 97, 442, 314, 541, 544, 920, 125, - /* 1220 */ 1069, 984, 974, 974, 976, 977, 27, 105, 105, 399, - /* 1230 */ 341, 1509, 44, 44, 106, 1070, 423, 546, 545, 57, - /* 1240 */ 57, 974, 341, 1509, 107, 536, 544, 4, 460, 399, - /* 1250 */ 214, 1118, 457, 294, 375, 1089, 532, 297, 544, 537, - /* 1260 */ 396, 539, 290, 535, 104, 244, 102, 524, 58, 58, - /* 1270 */ 544, 109, 974, 974, 976, 977, 27, 1514, 1129, 425, - /* 1280 */ 59, 59, 270, 237, 423, 138, 95, 373, 373, 372, - /* 1290 */ 255, 370, 60, 60, 815, 1178, 533, 544, 273, 544, - /* 1300 */ 1161, 843, 387, 386, 544, 1307, 544, 215, 210, 296, - /* 1310 */ 513, 847, 544, 265, 208, 514, 1306, 295, 274, 61, - /* 1320 */ 61, 62, 62, 436, 984, 1160, 45, 45, 46, 46, - /* 1330 */ 105, 105, 1184, 920, 47, 47, 1474, 106, 544, 423, - /* 1340 */ 546, 545, 218, 544, 974, 935, 1085, 217, 544, 377, - /* 1350 */ 395, 107, 536, 936, 4, 156, 1161, 843, 158, 544, - /* 1360 */ 49, 49, 141, 544, 38, 50, 50, 544, 539, 307, - /* 1370 */ 63, 63, 544, 1448, 216, 974, 974, 976, 977, 27, - /* 1380 */ 444, 64, 64, 544, 1447, 65, 65, 544, 524, 14, - /* 1390 */ 14, 423, 458, 544, 66, 66, 310, 544, 316, 97, - /* 1400 */ 1034, 544, 961, 533, 268, 127, 127, 544, 391, 67, - /* 1410 */ 67, 544, 978, 290, 535, 52, 52, 513, 544, 68, - /* 1420 */ 68, 1294, 512, 69, 69, 397, 165, 855, 854, 53, - /* 1430 */ 53, 984, 966, 151, 151, 243, 430, 105, 105, 199, - /* 1440 */ 152, 152, 448, 1303, 106, 243, 423, 546, 545, 1129, - /* 1450 */ 425, 974, 320, 270, 862, 863, 1034, 220, 373, 373, - /* 1460 */ 372, 255, 370, 450, 323, 815, 243, 544, 978, 544, - /* 1470 */ 107, 536, 544, 4, 544, 938, 939, 325, 215, 1046, - /* 1480 */ 296, 1046, 974, 974, 976, 977, 27, 539, 295, 76, - /* 1490 */ 76, 54, 54, 327, 72, 72, 128, 128, 1503, 1254, - /* 1500 */ 107, 536, 544, 4, 1045, 544, 1045, 531, 1238, 544, - /* 1510 */ 423, 544, 315, 334, 544, 97, 544, 539, 217, 544, - /* 1520 */ 472, 1528, 533, 239, 73, 73, 156, 129, 129, 158, - /* 1530 */ 467, 130, 130, 126, 126, 344, 150, 150, 149, 149, - /* 1540 */ 423, 134, 134, 329, 1030, 216, 97, 239, 929, 345, - /* 1550 */ 984, 243, 533, 1315, 339, 544, 105, 105, 900, 1355, - /* 1560 */ 544, 1290, 258, 106, 338, 423, 546, 545, 544, 1301, - /* 1570 */ 974, 893, 99, 536, 109, 4, 544, 133, 133, 391, - /* 1580 */ 984, 197, 131, 131, 290, 535, 105, 105, 530, 539, - /* 1590 */ 132, 132, 1361, 106, 1219, 423, 546, 545, 75, 75, - /* 1600 */ 974, 974, 974, 976, 977, 27, 544, 430, 826, 1211, - /* 1610 */ 894, 139, 423, 109, 544, 1200, 1199, 1201, 1522, 544, - /* 1620 */ 201, 544, 11, 374, 533, 1287, 347, 349, 77, 77, - /* 1630 */ 1340, 974, 974, 976, 977, 27, 74, 74, 351, 213, - /* 1640 */ 435, 43, 43, 48, 48, 302, 477, 309, 1348, 382, - /* 1650 */ 353, 452, 984, 337, 1237, 1420, 1419, 205, 105, 105, - /* 1660 */ 192, 367, 193, 534, 1525, 106, 1178, 423, 546, 545, - /* 1670 */ 247, 167, 974, 270, 1467, 200, 1465, 1175, 373, 373, - /* 1680 */ 372, 255, 370, 398, 79, 815, 83, 82, 1425, 446, - /* 1690 */ 161, 177, 169, 95, 1337, 438, 172, 173, 215, 174, - /* 1700 */ 296, 175, 35, 974, 974, 976, 977, 27, 295, 1345, - /* 1710 */ 439, 470, 223, 36, 379, 445, 1414, 381, 459, 1351, - /* 1720 */ 181, 227, 88, 465, 259, 229, 1436, 318, 186, 468, - /* 1730 */ 322, 230, 384, 1202, 231, 486, 1257, 1256, 217, 411, - /* 1740 */ 1255, 1248, 90, 847, 206, 413, 156, 505, 1539, 158, - /* 1750 */ 1226, 1538, 283, 1508, 1227, 336, 385, 284, 1225, 496, - /* 1760 */ 1537, 1298, 94, 346, 348, 216, 1247, 499, 1299, 245, - /* 1770 */ 246, 1297, 416, 350, 1494, 124, 1493, 10, 524, 361, - /* 1780 */ 1400, 101, 96, 288, 508, 253, 1135, 1208, 34, 1296, - /* 1790 */ 547, 254, 256, 257, 392, 548, 1197, 1192, 359, 391, - /* 1800 */ 1280, 1279, 196, 365, 290, 535, 366, 352, 1452, 1322, - /* 1810 */ 1321, 1453, 153, 137, 281, 154, 802, 424, 155, 1451, - /* 1820 */ 1450, 198, 292, 202, 203, 78, 212, 430, 271, 135, - /* 1830 */ 1044, 1042, 958, 168, 219, 157, 170, 879, 308, 222, - /* 1840 */ 1058, 176, 159, 962, 400, 84, 402, 178, 85, 86, - /* 1850 */ 87, 166, 160, 393, 1061, 224, 225, 1057, 146, 18, - /* 1860 */ 226, 317, 1050, 1172, 243, 464, 182, 228, 37, 183, - /* 1870 */ 817, 469, 338, 232, 330, 481, 184, 89, 845, 19, - /* 1880 */ 20, 92, 473, 478, 333, 91, 162, 858, 147, 488, - /* 1890 */ 282, 1123, 148, 1010, 928, 1093, 39, 93, 40, 495, - /* 1900 */ 1094, 187, 498, 207, 262, 264, 923, 242, 1109, 109, - /* 1910 */ 1113, 1111, 1097, 33, 21, 1117, 520, 1025, 22, 23, - /* 1920 */ 24, 1116, 25, 190, 97, 1011, 1009, 26, 1013, 1067, - /* 1930 */ 248, 7, 1066, 249, 1014, 28, 41, 889, 979, 827, - /* 1940 */ 108, 29, 250, 540, 251, 1530, 371, 368, 1131, 1130, - /* 1950 */ 1188, 1188, 1188, 1188, 1188, 1188, 1188, 1529, + /* 0 */ 537, 339, 537, 1241, 1220, 537, 12, 537, 112, 109, + /* 10 */ 209, 537, 1241, 537, 1205, 462, 112, 109, 209, 386, + /* 20 */ 338, 462, 42, 42, 42, 42, 445, 42, 42, 70, + /* 30 */ 70, 922, 1208, 70, 70, 70, 70, 1443, 403, 923, + /* 40 */ 531, 531, 531, 119, 120, 110, 1148, 1148, 991, 994, + /* 50 */ 984, 984, 117, 117, 118, 118, 118, 118, 425, 386, + /* 60 */ 1498, 542, 2, 1176, 1442, 519, 141, 1518, 289, 519, + /* 70 */ 134, 519, 95, 259, 495, 1215, 189, 1254, 518, 494, + /* 80 */ 484, 437, 296, 119, 120, 110, 1148, 1148, 991, 994, + /* 90 */ 984, 984, 117, 117, 118, 118, 118, 118, 270, 116, + /* 100 */ 116, 116, 116, 115, 115, 114, 114, 114, 113, 418, + /* 110 */ 264, 264, 264, 264, 423, 1479, 352, 1481, 123, 351, + /* 120 */ 1479, 508, 1094, 534, 1034, 534, 1099, 386, 1099, 239, + /* 130 */ 206, 112, 109, 209, 96, 1094, 376, 219, 1094, 116, + /* 140 */ 116, 116, 116, 115, 115, 114, 114, 114, 113, 418, + /* 150 */ 480, 119, 120, 110, 1148, 1148, 991, 994, 984, 984, + /* 160 */ 117, 117, 118, 118, 118, 118, 353, 422, 1407, 264, + /* 170 */ 264, 114, 114, 114, 113, 418, 883, 121, 416, 416, + /* 180 */ 416, 882, 534, 116, 116, 116, 116, 115, 115, 114, + /* 190 */ 114, 114, 113, 418, 212, 415, 414, 386, 443, 383, + /* 200 */ 382, 118, 118, 118, 118, 111, 177, 116, 116, 116, + /* 210 */ 116, 115, 115, 114, 114, 114, 113, 418, 112, 109, + /* 220 */ 209, 119, 120, 110, 1148, 1148, 991, 994, 984, 984, + /* 230 */ 117, 117, 118, 118, 118, 118, 386, 438, 312, 1163, + /* 240 */ 1155, 80, 1155, 1127, 514, 79, 116, 116, 116, 116, + /* 250 */ 115, 115, 114, 114, 114, 113, 418, 514, 428, 418, + /* 260 */ 119, 120, 110, 1148, 1148, 991, 994, 984, 984, 117, + /* 270 */ 117, 118, 118, 118, 118, 428, 427, 116, 116, 116, + /* 280 */ 116, 115, 115, 114, 114, 114, 113, 418, 115, 115, + /* 290 */ 114, 114, 114, 113, 418, 1127, 1127, 1128, 1129, 1094, + /* 300 */ 258, 258, 192, 386, 408, 371, 1168, 326, 118, 118, + /* 310 */ 118, 118, 1094, 534, 374, 1094, 116, 116, 116, 116, + /* 320 */ 115, 115, 114, 114, 114, 113, 418, 119, 120, 110, + /* 330 */ 1148, 1148, 991, 994, 984, 984, 117, 117, 118, 118, + /* 340 */ 118, 118, 386, 354, 445, 428, 829, 238, 1127, 1128, + /* 350 */ 1129, 515, 1466, 116, 116, 116, 116, 115, 115, 114, + /* 360 */ 114, 114, 113, 418, 1127, 1467, 119, 120, 110, 1148, + /* 370 */ 1148, 991, 994, 984, 984, 117, 117, 118, 118, 118, + /* 380 */ 118, 1169, 82, 116, 116, 116, 116, 115, 115, 114, + /* 390 */ 114, 114, 113, 418, 405, 112, 109, 209, 161, 445, + /* 400 */ 250, 267, 336, 478, 331, 477, 236, 951, 1127, 386, + /* 410 */ 888, 1521, 329, 822, 852, 162, 274, 1127, 1128, 1129, + /* 420 */ 338, 169, 116, 116, 116, 116, 115, 115, 114, 114, + /* 430 */ 114, 113, 418, 119, 120, 110, 1148, 1148, 991, 994, + /* 440 */ 984, 984, 117, 117, 118, 118, 118, 118, 386, 438, + /* 450 */ 312, 1502, 1112, 1176, 161, 288, 528, 311, 289, 883, + /* 460 */ 134, 1127, 1128, 1129, 882, 537, 143, 1254, 288, 528, + /* 470 */ 297, 275, 119, 120, 110, 1148, 1148, 991, 994, 984, + /* 480 */ 984, 117, 117, 118, 118, 118, 118, 70, 70, 116, + /* 490 */ 116, 116, 116, 115, 115, 114, 114, 114, 113, 418, + /* 500 */ 264, 264, 12, 264, 264, 395, 1127, 483, 1473, 1094, + /* 510 */ 204, 482, 6, 534, 1258, 386, 534, 1474, 825, 972, + /* 520 */ 504, 6, 1094, 500, 95, 1094, 534, 219, 116, 116, + /* 530 */ 116, 116, 115, 115, 114, 114, 114, 113, 418, 119, + /* 540 */ 120, 110, 1148, 1148, 991, 994, 984, 984, 117, 117, + /* 550 */ 118, 118, 118, 118, 386, 1339, 971, 422, 956, 1127, + /* 560 */ 1128, 1129, 231, 512, 1473, 475, 472, 471, 6, 113, + /* 570 */ 418, 825, 962, 298, 503, 470, 961, 452, 119, 120, + /* 580 */ 110, 1148, 1148, 991, 994, 984, 984, 117, 117, 118, + /* 590 */ 118, 118, 118, 395, 537, 116, 116, 116, 116, 115, + /* 600 */ 115, 114, 114, 114, 113, 418, 202, 961, 961, 963, + /* 610 */ 231, 971, 1127, 475, 472, 471, 13, 13, 951, 1127, + /* 620 */ 834, 386, 1207, 470, 399, 183, 447, 962, 462, 162, + /* 630 */ 397, 961, 1246, 1246, 116, 116, 116, 116, 115, 115, + /* 640 */ 114, 114, 114, 113, 418, 119, 120, 110, 1148, 1148, + /* 650 */ 991, 994, 984, 984, 117, 117, 118, 118, 118, 118, + /* 660 */ 386, 271, 961, 961, 963, 1127, 1128, 1129, 311, 433, + /* 670 */ 299, 1406, 1127, 1128, 1129, 178, 1471, 138, 162, 32, + /* 680 */ 6, 1127, 288, 528, 119, 120, 110, 1148, 1148, 991, + /* 690 */ 994, 984, 984, 117, 117, 118, 118, 118, 118, 909, + /* 700 */ 390, 116, 116, 116, 116, 115, 115, 114, 114, 114, + /* 710 */ 113, 418, 1127, 429, 817, 537, 1127, 265, 265, 981, + /* 720 */ 981, 992, 995, 324, 1055, 93, 520, 5, 338, 537, + /* 730 */ 534, 288, 528, 1522, 1127, 1128, 1129, 70, 70, 1056, + /* 740 */ 116, 116, 116, 116, 115, 115, 114, 114, 114, 113, + /* 750 */ 418, 70, 70, 1495, 1057, 537, 98, 1244, 1244, 264, + /* 760 */ 264, 908, 371, 1076, 1127, 1127, 1128, 1129, 817, 1127, + /* 770 */ 1128, 1129, 534, 519, 140, 863, 386, 13, 13, 456, + /* 780 */ 192, 193, 521, 453, 319, 864, 322, 284, 365, 430, + /* 790 */ 985, 402, 379, 1077, 1548, 101, 386, 1548, 3, 395, + /* 800 */ 119, 120, 110, 1148, 1148, 991, 994, 984, 984, 117, + /* 810 */ 117, 118, 118, 118, 118, 386, 451, 1127, 1128, 1129, + /* 820 */ 119, 120, 110, 1148, 1148, 991, 994, 984, 984, 117, + /* 830 */ 117, 118, 118, 118, 118, 1127, 1354, 1412, 1169, 119, + /* 840 */ 108, 110, 1148, 1148, 991, 994, 984, 984, 117, 117, + /* 850 */ 118, 118, 118, 118, 1412, 1414, 116, 116, 116, 116, + /* 860 */ 115, 115, 114, 114, 114, 113, 418, 272, 535, 1075, + /* 870 */ 877, 877, 337, 1492, 309, 462, 116, 116, 116, 116, + /* 880 */ 115, 115, 114, 114, 114, 113, 418, 537, 1127, 1128, + /* 890 */ 1129, 537, 360, 537, 356, 116, 116, 116, 116, 115, + /* 900 */ 115, 114, 114, 114, 113, 418, 386, 264, 264, 13, + /* 910 */ 13, 273, 1127, 13, 13, 13, 13, 304, 1253, 386, + /* 920 */ 534, 1077, 1549, 404, 1412, 1549, 496, 277, 451, 186, + /* 930 */ 1252, 120, 110, 1148, 1148, 991, 994, 984, 984, 117, + /* 940 */ 117, 118, 118, 118, 118, 110, 1148, 1148, 991, 994, + /* 950 */ 984, 984, 117, 117, 118, 118, 118, 118, 105, 529, + /* 960 */ 537, 4, 1339, 264, 264, 1127, 1128, 1129, 1039, 1039, + /* 970 */ 459, 795, 796, 797, 536, 532, 534, 242, 301, 807, + /* 980 */ 303, 462, 69, 69, 451, 1353, 116, 116, 116, 116, + /* 990 */ 115, 115, 114, 114, 114, 113, 418, 1075, 419, 116, + /* 1000 */ 116, 116, 116, 115, 115, 114, 114, 114, 113, 418, + /* 1010 */ 526, 537, 1146, 192, 350, 105, 529, 537, 4, 497, + /* 1020 */ 162, 337, 1492, 310, 1249, 385, 1550, 372, 9, 462, + /* 1030 */ 242, 400, 532, 13, 13, 499, 971, 843, 436, 70, + /* 1040 */ 70, 359, 103, 103, 8, 339, 278, 187, 278, 104, + /* 1050 */ 1127, 419, 539, 538, 1339, 419, 961, 302, 1339, 1172, + /* 1060 */ 1, 1, 542, 2, 1176, 1146, 1146, 526, 476, 289, + /* 1070 */ 30, 134, 317, 288, 528, 285, 844, 1014, 1254, 276, + /* 1080 */ 1472, 506, 410, 1194, 6, 207, 505, 961, 961, 963, + /* 1090 */ 964, 27, 449, 971, 415, 414, 234, 233, 232, 103, + /* 1100 */ 103, 31, 1152, 1127, 1128, 1129, 104, 1154, 419, 539, + /* 1110 */ 538, 264, 264, 961, 1399, 1153, 264, 264, 1470, 1146, + /* 1120 */ 537, 216, 6, 401, 534, 1197, 392, 458, 406, 534, + /* 1130 */ 537, 485, 358, 537, 261, 537, 1339, 907, 219, 1155, + /* 1140 */ 467, 1155, 50, 50, 961, 961, 963, 964, 27, 1497, + /* 1150 */ 1116, 421, 70, 70, 268, 70, 70, 13, 13, 369, + /* 1160 */ 369, 368, 253, 366, 264, 264, 804, 235, 422, 105, + /* 1170 */ 529, 516, 4, 287, 487, 510, 493, 534, 486, 213, + /* 1180 */ 1055, 294, 490, 384, 1127, 450, 532, 338, 413, 293, + /* 1190 */ 522, 417, 335, 1036, 509, 1056, 107, 1036, 16, 16, + /* 1200 */ 1469, 1094, 334, 1105, 6, 411, 1145, 264, 264, 419, + /* 1210 */ 1057, 102, 511, 100, 1094, 264, 264, 1094, 922, 215, + /* 1220 */ 534, 526, 907, 264, 264, 208, 923, 154, 534, 457, + /* 1230 */ 156, 525, 391, 142, 218, 506, 534, 1127, 1128, 1129, + /* 1240 */ 507, 139, 1131, 38, 214, 530, 392, 971, 329, 1454, + /* 1250 */ 907, 1105, 537, 103, 103, 105, 529, 537, 4, 537, + /* 1260 */ 104, 424, 419, 539, 538, 537, 502, 961, 517, 537, + /* 1270 */ 1072, 537, 532, 373, 54, 54, 288, 528, 387, 55, + /* 1280 */ 55, 15, 15, 288, 528, 17, 136, 44, 44, 1451, + /* 1290 */ 537, 56, 56, 57, 57, 419, 1131, 291, 961, 961, + /* 1300 */ 963, 964, 27, 393, 163, 537, 426, 526, 263, 206, + /* 1310 */ 208, 517, 58, 58, 235, 440, 842, 841, 197, 105, + /* 1320 */ 529, 506, 4, 1033, 439, 1033, 505, 59, 59, 308, + /* 1330 */ 849, 850, 95, 971, 537, 907, 532, 948, 832, 103, + /* 1340 */ 103, 105, 529, 537, 4, 1021, 104, 537, 419, 539, + /* 1350 */ 538, 1116, 421, 961, 537, 268, 60, 60, 532, 419, + /* 1360 */ 369, 369, 368, 253, 366, 61, 61, 804, 965, 45, + /* 1370 */ 45, 526, 537, 1032, 1277, 1032, 46, 46, 537, 391, + /* 1380 */ 213, 419, 294, 266, 961, 961, 963, 964, 27, 292, + /* 1390 */ 293, 295, 832, 526, 48, 48, 1290, 971, 1289, 1021, + /* 1400 */ 49, 49, 432, 103, 103, 887, 953, 537, 1457, 241, + /* 1410 */ 104, 305, 419, 539, 538, 925, 926, 961, 444, 971, + /* 1420 */ 215, 241, 965, 1224, 537, 103, 103, 1431, 154, 62, + /* 1430 */ 62, 156, 104, 1430, 419, 539, 538, 97, 529, 961, + /* 1440 */ 4, 537, 454, 537, 314, 214, 63, 63, 961, 961, + /* 1450 */ 963, 964, 27, 537, 532, 446, 1286, 318, 241, 537, + /* 1460 */ 321, 323, 325, 64, 64, 14, 14, 1237, 537, 1223, + /* 1470 */ 961, 961, 963, 964, 27, 65, 65, 419, 537, 387, + /* 1480 */ 537, 125, 125, 537, 288, 528, 537, 1486, 537, 526, + /* 1490 */ 66, 66, 313, 524, 537, 95, 468, 1221, 1511, 237, + /* 1500 */ 51, 51, 67, 67, 330, 68, 68, 426, 52, 52, + /* 1510 */ 149, 149, 1222, 340, 341, 971, 150, 150, 1298, 463, + /* 1520 */ 327, 103, 103, 95, 537, 1338, 1273, 537, 104, 537, + /* 1530 */ 419, 539, 538, 1284, 537, 961, 268, 283, 523, 1344, + /* 1540 */ 1204, 369, 369, 368, 253, 366, 75, 75, 804, 53, + /* 1550 */ 53, 71, 71, 537, 1196, 537, 126, 126, 537, 1017, + /* 1560 */ 537, 213, 237, 294, 537, 1185, 961, 961, 963, 964, + /* 1570 */ 27, 293, 537, 1184, 537, 72, 72, 127, 127, 1186, + /* 1580 */ 128, 128, 124, 124, 1505, 537, 148, 148, 537, 256, + /* 1590 */ 195, 537, 1270, 537, 147, 147, 132, 132, 537, 11, + /* 1600 */ 537, 215, 537, 199, 343, 345, 347, 131, 131, 154, + /* 1610 */ 129, 129, 156, 130, 130, 74, 74, 537, 370, 1323, + /* 1620 */ 76, 76, 73, 73, 43, 43, 214, 431, 211, 1331, + /* 1630 */ 300, 916, 880, 815, 241, 107, 137, 307, 881, 47, + /* 1640 */ 47, 107, 473, 378, 203, 448, 333, 1403, 1220, 1402, + /* 1650 */ 349, 190, 527, 191, 363, 198, 1508, 1163, 245, 165, + /* 1660 */ 387, 1450, 1448, 1160, 78, 288, 528, 1408, 81, 394, + /* 1670 */ 82, 442, 175, 159, 167, 93, 1328, 35, 1320, 434, + /* 1680 */ 170, 171, 172, 173, 435, 466, 221, 375, 426, 377, + /* 1690 */ 1334, 179, 455, 441, 1397, 225, 87, 36, 461, 1419, + /* 1700 */ 316, 257, 227, 184, 320, 464, 228, 479, 1187, 229, + /* 1710 */ 380, 1240, 1239, 407, 1238, 1212, 834, 332, 1231, 381, + /* 1720 */ 409, 1211, 204, 1210, 1491, 498, 1520, 1281, 92, 281, + /* 1730 */ 1230, 489, 282, 492, 342, 243, 1282, 344, 244, 1280, + /* 1740 */ 346, 412, 1279, 1477, 348, 122, 1476, 517, 10, 357, + /* 1750 */ 286, 1305, 1304, 99, 1383, 94, 501, 251, 1193, 34, + /* 1760 */ 1263, 355, 540, 194, 1262, 361, 362, 1122, 252, 254, + /* 1770 */ 255, 388, 541, 1182, 1177, 151, 1435, 389, 1436, 1434, + /* 1780 */ 1433, 791, 152, 135, 279, 200, 201, 420, 196, 77, + /* 1790 */ 153, 290, 269, 210, 1031, 133, 1029, 945, 166, 155, + /* 1800 */ 217, 168, 866, 306, 220, 1045, 174, 949, 157, 396, + /* 1810 */ 83, 398, 176, 84, 85, 164, 86, 158, 1048, 222, + /* 1820 */ 223, 1044, 144, 18, 224, 315, 1037, 180, 241, 460, + /* 1830 */ 1157, 226, 181, 37, 806, 465, 334, 230, 328, 469, + /* 1840 */ 182, 88, 474, 19, 20, 160, 89, 280, 145, 90, + /* 1850 */ 481, 845, 1110, 146, 997, 205, 1080, 39, 91, 40, + /* 1860 */ 488, 1081, 915, 491, 260, 262, 185, 910, 240, 107, + /* 1870 */ 1100, 1096, 1098, 1104, 21, 1084, 33, 513, 247, 22, + /* 1880 */ 23, 24, 1103, 25, 188, 95, 1012, 998, 996, 26, + /* 1890 */ 1000, 1054, 7, 1053, 1001, 246, 28, 41, 533, 966, + /* 1900 */ 816, 106, 29, 367, 248, 249, 1513, 1512, 364, 1117, + /* 1910 */ 1173, 1173, 876, }; static const YYCODETYPE yy_lookahead[] = { - /* 0 */ 189, 211, 189, 189, 218, 189, 220, 189, 267, 268, - /* 10 */ 269, 189, 210, 189, 228, 189, 267, 268, 269, 19, - /* 20 */ 218, 189, 211, 212, 211, 212, 211, 211, 212, 211, - /* 30 */ 212, 31, 211, 211, 212, 211, 212, 288, 300, 39, - /* 40 */ 21, 189, 304, 43, 44, 45, 46, 47, 48, 49, - /* 50 */ 50, 51, 52, 53, 54, 55, 56, 57, 225, 19, - /* 60 */ 189, 183, 184, 185, 186, 189, 248, 263, 236, 191, - /* 70 */ 248, 193, 248, 197, 208, 257, 262, 201, 200, 257, - /* 80 */ 200, 257, 81, 43, 44, 45, 46, 47, 48, 49, - /* 90 */ 50, 51, 52, 53, 54, 55, 56, 57, 189, 80, - /* 100 */ 189, 101, 102, 103, 104, 105, 106, 107, 108, 109, - /* 110 */ 110, 111, 234, 235, 234, 235, 305, 306, 305, 118, - /* 120 */ 307, 305, 306, 297, 298, 247, 86, 247, 88, 19, - /* 130 */ 259, 251, 252, 267, 268, 269, 26, 136, 137, 261, - /* 140 */ 121, 101, 102, 103, 104, 105, 106, 107, 108, 109, - /* 150 */ 110, 111, 59, 43, 44, 45, 46, 47, 48, 49, - /* 160 */ 50, 51, 52, 53, 54, 55, 56, 57, 259, 291, - /* 170 */ 105, 106, 107, 108, 109, 110, 111, 158, 189, 69, - /* 180 */ 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, - /* 190 */ 111, 107, 108, 109, 110, 111, 205, 206, 207, 19, - /* 200 */ 19, 54, 55, 56, 57, 58, 29, 114, 115, 116, - /* 210 */ 33, 101, 102, 103, 104, 105, 106, 107, 108, 109, - /* 220 */ 110, 111, 233, 43, 44, 45, 46, 47, 48, 49, - /* 230 */ 50, 51, 52, 53, 54, 55, 56, 57, 19, 126, - /* 240 */ 127, 148, 65, 24, 214, 200, 59, 67, 101, 102, - /* 250 */ 103, 104, 105, 106, 107, 108, 109, 110, 111, 22, - /* 260 */ 189, 111, 43, 44, 45, 46, 47, 48, 49, 50, - /* 270 */ 51, 52, 53, 54, 55, 56, 57, 206, 207, 234, - /* 280 */ 235, 101, 102, 103, 104, 105, 106, 107, 108, 109, - /* 290 */ 110, 111, 247, 76, 107, 114, 59, 267, 268, 269, - /* 300 */ 189, 114, 115, 116, 162, 163, 89, 19, 263, 92, - /* 310 */ 189, 23, 54, 55, 56, 57, 189, 206, 207, 22, - /* 320 */ 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, - /* 330 */ 111, 43, 44, 45, 46, 47, 48, 49, 50, 51, - /* 340 */ 52, 53, 54, 55, 56, 57, 19, 189, 277, 59, - /* 350 */ 23, 114, 115, 116, 46, 47, 48, 49, 61, 101, - /* 360 */ 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, - /* 370 */ 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, - /* 380 */ 53, 54, 55, 56, 57, 125, 126, 127, 277, 101, - /* 390 */ 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, - /* 400 */ 59, 189, 189, 276, 114, 115, 116, 117, 73, 59, - /* 410 */ 120, 121, 122, 72, 214, 19, 81, 259, 19, 23, - /* 420 */ 130, 81, 72, 24, 211, 212, 221, 119, 101, 102, - /* 430 */ 103, 104, 105, 106, 107, 108, 109, 110, 111, 43, - /* 440 */ 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, - /* 450 */ 54, 55, 56, 57, 19, 114, 115, 116, 23, 208, - /* 460 */ 125, 248, 189, 189, 114, 115, 116, 267, 268, 269, - /* 470 */ 189, 136, 137, 189, 262, 22, 136, 137, 43, 44, - /* 480 */ 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, - /* 490 */ 55, 56, 57, 189, 95, 211, 212, 101, 102, 103, - /* 500 */ 104, 105, 106, 107, 108, 109, 110, 111, 59, 189, - /* 510 */ 111, 189, 59, 76, 294, 295, 117, 118, 119, 120, - /* 520 */ 121, 122, 123, 19, 87, 189, 89, 23, 129, 92, - /* 530 */ 279, 227, 248, 22, 189, 284, 101, 102, 103, 104, - /* 540 */ 105, 106, 107, 108, 109, 110, 111, 43, 44, 45, - /* 550 */ 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, - /* 560 */ 56, 57, 19, 114, 115, 116, 23, 114, 115, 116, - /* 570 */ 59, 117, 299, 300, 120, 121, 122, 304, 189, 189, - /* 580 */ 143, 189, 110, 111, 130, 22, 43, 44, 45, 46, - /* 590 */ 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, - /* 600 */ 57, 211, 212, 211, 212, 101, 102, 103, 104, 105, - /* 610 */ 106, 107, 108, 109, 110, 111, 226, 189, 226, 189, - /* 620 */ 298, 132, 59, 134, 135, 114, 115, 116, 189, 59, - /* 630 */ 285, 19, 7, 8, 9, 23, 205, 206, 207, 211, - /* 640 */ 212, 211, 212, 221, 101, 102, 103, 104, 105, 106, - /* 650 */ 107, 108, 109, 110, 111, 43, 44, 45, 46, 47, - /* 660 */ 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, - /* 670 */ 19, 181, 182, 183, 184, 185, 186, 114, 115, 116, - /* 680 */ 189, 191, 133, 193, 114, 115, 116, 138, 299, 300, - /* 690 */ 200, 22, 201, 304, 43, 44, 45, 46, 47, 48, - /* 700 */ 49, 50, 51, 52, 53, 54, 55, 56, 57, 35, - /* 710 */ 189, 141, 189, 101, 102, 103, 104, 105, 106, 107, - /* 720 */ 108, 109, 110, 111, 234, 235, 22, 23, 59, 184, - /* 730 */ 26, 186, 211, 212, 211, 212, 191, 247, 193, 19, - /* 740 */ 66, 105, 106, 73, 189, 200, 189, 226, 74, 226, - /* 750 */ 22, 261, 101, 102, 103, 104, 105, 106, 107, 108, - /* 760 */ 109, 110, 111, 43, 44, 45, 46, 47, 48, 49, - /* 770 */ 50, 51, 52, 53, 54, 55, 56, 57, 189, 234, - /* 780 */ 235, 291, 19, 114, 115, 116, 150, 59, 152, 189, - /* 790 */ 233, 236, 247, 59, 189, 125, 126, 127, 59, 300, - /* 800 */ 211, 212, 128, 304, 100, 19, 261, 156, 45, 46, - /* 810 */ 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, - /* 820 */ 57, 101, 102, 103, 104, 105, 106, 107, 108, 109, - /* 830 */ 110, 111, 46, 233, 189, 189, 291, 248, 99, 189, - /* 840 */ 125, 126, 127, 115, 26, 200, 289, 230, 231, 115, - /* 850 */ 200, 16, 189, 114, 115, 189, 211, 212, 119, 221, - /* 860 */ 189, 211, 212, 258, 101, 102, 103, 104, 105, 106, - /* 870 */ 107, 108, 109, 110, 111, 189, 156, 211, 212, 234, - /* 880 */ 235, 189, 211, 212, 234, 235, 22, 201, 189, 150, - /* 890 */ 151, 152, 247, 248, 76, 16, 19, 247, 248, 113, - /* 900 */ 189, 24, 257, 211, 212, 189, 26, 89, 262, 223, - /* 910 */ 92, 225, 77, 189, 79, 129, 19, 53, 226, 248, - /* 920 */ 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, - /* 930 */ 53, 54, 55, 56, 57, 236, 19, 271, 189, 99, - /* 940 */ 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, - /* 950 */ 53, 54, 55, 56, 57, 115, 77, 59, 79, 119, - /* 960 */ 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, - /* 970 */ 53, 54, 55, 56, 57, 259, 22, 23, 101, 102, - /* 980 */ 103, 104, 105, 106, 107, 108, 109, 110, 111, 59, - /* 990 */ 150, 151, 152, 158, 22, 244, 24, 246, 101, 102, - /* 1000 */ 103, 104, 105, 106, 107, 108, 109, 110, 111, 285, - /* 1010 */ 189, 189, 114, 115, 116, 200, 136, 137, 101, 102, - /* 1020 */ 103, 104, 105, 106, 107, 108, 109, 110, 111, 230, - /* 1030 */ 231, 59, 211, 212, 285, 105, 106, 189, 19, 141, - /* 1040 */ 234, 235, 239, 113, 114, 115, 116, 226, 118, 234, - /* 1050 */ 235, 189, 249, 247, 100, 189, 126, 23, 236, 107, - /* 1060 */ 26, 189, 247, 44, 45, 46, 47, 48, 49, 50, - /* 1070 */ 51, 52, 53, 54, 55, 56, 57, 211, 212, 59, - /* 1080 */ 150, 233, 152, 211, 212, 133, 12, 115, 189, 189, - /* 1090 */ 138, 19, 20, 300, 22, 233, 76, 304, 226, 11, - /* 1100 */ 208, 27, 22, 23, 200, 19, 26, 87, 36, 89, - /* 1110 */ 211, 212, 92, 300, 248, 189, 42, 304, 189, 250, - /* 1120 */ 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, - /* 1130 */ 111, 59, 200, 233, 114, 115, 116, 63, 234, 235, - /* 1140 */ 235, 19, 20, 71, 22, 300, 189, 73, 200, 304, - /* 1150 */ 116, 247, 247, 81, 23, 200, 227, 26, 36, 234, - /* 1160 */ 235, 203, 204, 143, 200, 26, 234, 235, 194, 200, - /* 1170 */ 48, 99, 247, 66, 189, 141, 284, 105, 106, 247, - /* 1180 */ 100, 59, 234, 235, 112, 259, 114, 115, 116, 234, - /* 1190 */ 235, 119, 85, 71, 266, 247, 211, 212, 234, 235, - /* 1200 */ 114, 94, 247, 234, 235, 12, 266, 85, 136, 137, - /* 1210 */ 189, 247, 90, 26, 126, 127, 247, 189, 26, 22, - /* 1220 */ 27, 99, 150, 151, 152, 153, 154, 105, 106, 189, - /* 1230 */ 302, 303, 211, 212, 112, 42, 114, 115, 116, 211, - /* 1240 */ 212, 119, 302, 303, 19, 20, 189, 22, 274, 189, - /* 1250 */ 15, 144, 278, 189, 22, 23, 63, 189, 189, 203, - /* 1260 */ 204, 36, 136, 137, 155, 24, 157, 143, 211, 212, - /* 1270 */ 189, 26, 150, 151, 152, 153, 154, 0, 1, 2, - /* 1280 */ 211, 212, 5, 46, 59, 161, 147, 10, 11, 12, - /* 1290 */ 13, 14, 211, 212, 17, 60, 71, 189, 258, 189, - /* 1300 */ 59, 59, 105, 106, 189, 189, 189, 30, 116, 32, - /* 1310 */ 85, 124, 189, 251, 252, 90, 189, 40, 258, 211, - /* 1320 */ 212, 211, 212, 189, 99, 26, 211, 212, 211, 212, - /* 1330 */ 105, 106, 100, 141, 211, 212, 189, 112, 189, 114, - /* 1340 */ 115, 116, 24, 189, 119, 31, 23, 70, 189, 26, - /* 1350 */ 113, 19, 20, 39, 22, 78, 115, 115, 81, 189, - /* 1360 */ 211, 212, 22, 189, 24, 211, 212, 189, 36, 189, - /* 1370 */ 211, 212, 189, 189, 97, 150, 151, 152, 153, 154, - /* 1380 */ 127, 211, 212, 189, 189, 211, 212, 189, 143, 211, - /* 1390 */ 212, 59, 189, 189, 211, 212, 23, 189, 189, 26, - /* 1400 */ 59, 189, 149, 71, 22, 211, 212, 189, 131, 211, - /* 1410 */ 212, 189, 59, 136, 137, 211, 212, 85, 189, 211, - /* 1420 */ 212, 253, 90, 211, 212, 292, 293, 118, 119, 211, - /* 1430 */ 212, 99, 23, 211, 212, 26, 159, 105, 106, 140, - /* 1440 */ 211, 212, 23, 189, 112, 26, 114, 115, 116, 1, - /* 1450 */ 2, 119, 189, 5, 7, 8, 115, 139, 10, 11, - /* 1460 */ 12, 13, 14, 23, 189, 17, 26, 189, 115, 189, - /* 1470 */ 19, 20, 189, 22, 189, 83, 84, 189, 30, 150, - /* 1480 */ 32, 152, 150, 151, 152, 153, 154, 36, 40, 211, - /* 1490 */ 212, 211, 212, 189, 211, 212, 211, 212, 309, 189, - /* 1500 */ 19, 20, 189, 22, 150, 189, 152, 231, 189, 189, - /* 1510 */ 59, 189, 23, 189, 189, 26, 189, 36, 70, 189, - /* 1520 */ 23, 139, 71, 26, 211, 212, 78, 211, 212, 81, - /* 1530 */ 281, 211, 212, 211, 212, 189, 211, 212, 211, 212, - /* 1540 */ 59, 211, 212, 23, 23, 97, 26, 26, 23, 189, - /* 1550 */ 99, 26, 71, 189, 119, 189, 105, 106, 107, 189, - /* 1560 */ 189, 189, 280, 112, 129, 114, 115, 116, 189, 189, - /* 1570 */ 119, 23, 19, 20, 26, 22, 189, 211, 212, 131, - /* 1580 */ 99, 237, 211, 212, 136, 137, 105, 106, 189, 36, - /* 1590 */ 211, 212, 189, 112, 189, 114, 115, 116, 211, 212, - /* 1600 */ 119, 150, 151, 152, 153, 154, 189, 159, 23, 189, - /* 1610 */ 23, 26, 59, 26, 189, 189, 189, 189, 189, 189, - /* 1620 */ 209, 189, 238, 187, 71, 250, 250, 250, 211, 212, - /* 1630 */ 241, 150, 151, 152, 153, 154, 211, 212, 250, 290, - /* 1640 */ 254, 211, 212, 211, 212, 254, 215, 286, 241, 241, - /* 1650 */ 254, 286, 99, 214, 220, 214, 214, 224, 105, 106, - /* 1660 */ 244, 240, 244, 273, 192, 112, 60, 114, 115, 116, - /* 1670 */ 139, 290, 119, 5, 196, 238, 196, 38, 10, 11, - /* 1680 */ 12, 13, 14, 196, 287, 17, 148, 287, 276, 113, - /* 1690 */ 43, 22, 229, 147, 241, 18, 232, 232, 30, 232, - /* 1700 */ 32, 232, 264, 150, 151, 152, 153, 154, 40, 265, - /* 1710 */ 196, 18, 195, 264, 241, 241, 241, 265, 196, 229, - /* 1720 */ 229, 195, 155, 62, 196, 195, 283, 282, 22, 216, - /* 1730 */ 196, 195, 216, 196, 195, 113, 213, 213, 70, 64, - /* 1740 */ 213, 222, 22, 124, 162, 111, 78, 142, 219, 81, - /* 1750 */ 215, 219, 275, 303, 213, 213, 216, 275, 213, 216, - /* 1760 */ 213, 256, 113, 255, 255, 97, 222, 216, 256, 196, - /* 1770 */ 91, 256, 82, 255, 308, 146, 308, 22, 143, 196, - /* 1780 */ 270, 155, 145, 272, 144, 25, 13, 199, 26, 256, - /* 1790 */ 198, 190, 190, 6, 296, 188, 188, 188, 244, 131, - /* 1800 */ 245, 245, 243, 242, 136, 137, 241, 255, 208, 260, - /* 1810 */ 260, 208, 202, 217, 217, 202, 4, 3, 202, 208, - /* 1820 */ 208, 22, 160, 209, 209, 208, 15, 159, 98, 16, - /* 1830 */ 23, 23, 137, 148, 24, 128, 140, 20, 16, 142, - /* 1840 */ 1, 140, 128, 149, 61, 53, 37, 148, 53, 53, - /* 1850 */ 53, 293, 128, 296, 114, 34, 139, 1, 5, 22, - /* 1860 */ 113, 158, 68, 75, 26, 41, 68, 139, 24, 113, - /* 1870 */ 20, 19, 129, 123, 23, 96, 22, 22, 59, 22, - /* 1880 */ 22, 147, 67, 67, 24, 22, 37, 28, 23, 22, - /* 1890 */ 67, 23, 23, 23, 114, 23, 22, 26, 22, 24, - /* 1900 */ 23, 22, 24, 139, 23, 23, 141, 34, 88, 26, - /* 1910 */ 75, 86, 23, 22, 34, 75, 24, 23, 34, 34, - /* 1920 */ 34, 93, 34, 26, 26, 23, 23, 34, 23, 23, - /* 1930 */ 26, 44, 23, 22, 11, 22, 22, 133, 23, 23, - /* 1940 */ 22, 22, 139, 26, 139, 139, 15, 23, 1, 1, - /* 1950 */ 310, 310, 310, 310, 310, 310, 310, 139, 310, 310, - /* 1960 */ 310, 310, 310, 310, 310, 310, 310, 310, 310, 310, - /* 1970 */ 310, 310, 310, 310, 310, 310, 310, 310, 310, 310, - /* 1980 */ 310, 310, 310, 310, 310, 310, 310, 310, 310, 310, - /* 1990 */ 310, 310, 310, 310, 310, 310, 310, 310, 310, 310, - /* 2000 */ 310, 310, 310, 310, 310, 310, 310, 310, 310, 310, - /* 2010 */ 310, 310, 310, 310, 310, 310, 310, 310, 310, 310, - /* 2020 */ 310, 310, 310, 310, 310, 310, 310, 310, 310, 310, - /* 2030 */ 310, 310, 310, 310, 310, 310, 310, 310, 310, 310, - /* 2040 */ 310, 310, 310, 310, 310, 310, 310, 310, 310, 310, - /* 2050 */ 310, 310, 310, 310, 310, 310, 310, 310, 310, 310, - /* 2060 */ 310, 310, 310, 310, 310, 310, 310, 310, 310, 310, - /* 2070 */ 310, 310, 310, 310, 310, 310, 310, 310, 310, 310, - /* 2080 */ 310, 310, 310, 310, 310, 310, 310, 310, 310, 310, - /* 2090 */ 310, 310, 310, 310, 310, 310, 310, 310, 310, 310, - /* 2100 */ 310, 310, 310, 310, 310, 310, 310, 310, 310, 310, - /* 2110 */ 310, 310, 310, 310, 310, 310, 310, 310, 310, 310, - /* 2120 */ 310, 310, 310, 310, 310, 310, 310, 310, 310, 310, - /* 2130 */ 310, 310, 310, 310, 310, 310, 310, 310, 310, + /* 0 */ 187, 187, 187, 216, 217, 187, 206, 187, 264, 265, + /* 10 */ 266, 187, 225, 187, 209, 187, 264, 265, 266, 19, + /* 20 */ 187, 187, 209, 210, 209, 210, 187, 209, 210, 209, + /* 30 */ 210, 31, 209, 209, 210, 209, 210, 285, 224, 39, + /* 40 */ 203, 204, 205, 43, 44, 45, 46, 47, 48, 49, + /* 50 */ 50, 51, 52, 53, 54, 55, 56, 57, 230, 19, + /* 60 */ 181, 182, 183, 184, 230, 245, 233, 208, 189, 245, + /* 70 */ 191, 245, 26, 206, 254, 216, 276, 198, 254, 198, + /* 80 */ 254, 281, 187, 43, 44, 45, 46, 47, 48, 49, + /* 90 */ 50, 51, 52, 53, 54, 55, 56, 57, 259, 99, + /* 100 */ 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, + /* 110 */ 231, 232, 231, 232, 286, 302, 303, 302, 22, 304, + /* 120 */ 302, 303, 76, 244, 11, 244, 86, 19, 88, 248, + /* 130 */ 249, 264, 265, 266, 26, 89, 198, 258, 92, 99, + /* 140 */ 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, + /* 150 */ 105, 43, 44, 45, 46, 47, 48, 49, 50, 51, + /* 160 */ 52, 53, 54, 55, 56, 57, 212, 288, 273, 231, + /* 170 */ 232, 105, 106, 107, 108, 109, 131, 69, 203, 204, + /* 180 */ 205, 136, 244, 99, 100, 101, 102, 103, 104, 105, + /* 190 */ 106, 107, 108, 109, 15, 103, 104, 19, 260, 103, + /* 200 */ 104, 54, 55, 56, 57, 58, 22, 99, 100, 101, + /* 210 */ 102, 103, 104, 105, 106, 107, 108, 109, 264, 265, + /* 220 */ 266, 43, 44, 45, 46, 47, 48, 49, 50, 51, + /* 230 */ 52, 53, 54, 55, 56, 57, 19, 124, 125, 60, + /* 240 */ 148, 24, 150, 59, 187, 67, 99, 100, 101, 102, + /* 250 */ 103, 104, 105, 106, 107, 108, 109, 187, 187, 109, + /* 260 */ 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, + /* 270 */ 53, 54, 55, 56, 57, 204, 205, 99, 100, 101, + /* 280 */ 102, 103, 104, 105, 106, 107, 108, 109, 103, 104, + /* 290 */ 105, 106, 107, 108, 109, 59, 112, 113, 114, 76, + /* 300 */ 231, 232, 187, 19, 19, 22, 23, 23, 54, 55, + /* 310 */ 56, 57, 89, 244, 199, 92, 99, 100, 101, 102, + /* 320 */ 103, 104, 105, 106, 107, 108, 109, 43, 44, 45, + /* 330 */ 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, + /* 340 */ 56, 57, 19, 212, 187, 274, 23, 26, 112, 113, + /* 350 */ 114, 294, 295, 99, 100, 101, 102, 103, 104, 105, + /* 360 */ 106, 107, 108, 109, 59, 295, 43, 44, 45, 46, + /* 370 */ 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, + /* 380 */ 57, 98, 146, 99, 100, 101, 102, 103, 104, 105, + /* 390 */ 106, 107, 108, 109, 109, 264, 265, 266, 187, 187, + /* 400 */ 115, 116, 117, 118, 119, 120, 121, 73, 59, 19, + /* 410 */ 105, 23, 127, 23, 26, 81, 259, 112, 113, 114, + /* 420 */ 187, 72, 99, 100, 101, 102, 103, 104, 105, 106, + /* 430 */ 107, 108, 109, 43, 44, 45, 46, 47, 48, 49, + /* 440 */ 50, 51, 52, 53, 54, 55, 56, 57, 19, 124, + /* 450 */ 125, 182, 23, 184, 187, 134, 135, 123, 189, 131, + /* 460 */ 191, 112, 113, 114, 136, 187, 233, 198, 134, 135, + /* 470 */ 198, 259, 43, 44, 45, 46, 47, 48, 49, 50, + /* 480 */ 51, 52, 53, 54, 55, 56, 57, 209, 210, 99, + /* 490 */ 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, + /* 500 */ 231, 232, 206, 231, 232, 187, 59, 296, 297, 76, + /* 510 */ 160, 161, 301, 244, 232, 19, 244, 297, 59, 23, + /* 520 */ 87, 301, 89, 245, 26, 92, 244, 258, 99, 100, + /* 530 */ 101, 102, 103, 104, 105, 106, 107, 108, 109, 43, + /* 540 */ 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, + /* 550 */ 54, 55, 56, 57, 19, 187, 97, 288, 23, 112, + /* 560 */ 113, 114, 115, 296, 297, 118, 119, 120, 301, 108, + /* 570 */ 109, 112, 113, 255, 141, 128, 117, 281, 43, 44, + /* 580 */ 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, + /* 590 */ 55, 56, 57, 187, 187, 99, 100, 101, 102, 103, + /* 600 */ 104, 105, 106, 107, 108, 109, 26, 148, 149, 150, + /* 610 */ 115, 97, 59, 118, 119, 120, 209, 210, 73, 59, + /* 620 */ 122, 19, 209, 128, 256, 72, 187, 113, 187, 81, + /* 630 */ 223, 117, 227, 228, 99, 100, 101, 102, 103, 104, + /* 640 */ 105, 106, 107, 108, 109, 43, 44, 45, 46, 47, + /* 650 */ 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, + /* 660 */ 19, 255, 148, 149, 150, 112, 113, 114, 123, 124, + /* 670 */ 125, 230, 112, 113, 114, 22, 297, 22, 81, 22, + /* 680 */ 301, 59, 134, 135, 43, 44, 45, 46, 47, 48, + /* 690 */ 49, 50, 51, 52, 53, 54, 55, 56, 57, 139, + /* 700 */ 192, 99, 100, 101, 102, 103, 104, 105, 106, 107, + /* 710 */ 108, 109, 59, 116, 59, 187, 59, 231, 232, 46, + /* 720 */ 47, 48, 49, 16, 12, 145, 198, 22, 187, 187, + /* 730 */ 244, 134, 135, 222, 112, 113, 114, 209, 210, 27, + /* 740 */ 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, + /* 750 */ 109, 209, 210, 187, 42, 187, 154, 227, 228, 231, + /* 760 */ 232, 139, 22, 23, 59, 112, 113, 114, 113, 112, + /* 770 */ 113, 114, 244, 245, 233, 63, 19, 209, 210, 271, + /* 780 */ 187, 24, 254, 275, 77, 73, 79, 245, 195, 260, + /* 790 */ 117, 223, 199, 22, 23, 154, 19, 26, 22, 187, + /* 800 */ 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, + /* 810 */ 53, 54, 55, 56, 57, 19, 187, 112, 113, 114, + /* 820 */ 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, + /* 830 */ 53, 54, 55, 56, 57, 59, 263, 187, 98, 43, + /* 840 */ 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, + /* 850 */ 54, 55, 56, 57, 204, 205, 99, 100, 101, 102, + /* 860 */ 103, 104, 105, 106, 107, 108, 109, 255, 130, 98, + /* 870 */ 132, 133, 299, 300, 198, 187, 99, 100, 101, 102, + /* 880 */ 103, 104, 105, 106, 107, 108, 109, 187, 112, 113, + /* 890 */ 114, 187, 241, 187, 243, 99, 100, 101, 102, 103, + /* 900 */ 104, 105, 106, 107, 108, 109, 19, 231, 232, 209, + /* 910 */ 210, 282, 59, 209, 210, 209, 210, 16, 230, 19, + /* 920 */ 244, 22, 23, 223, 274, 26, 19, 223, 187, 223, + /* 930 */ 198, 44, 45, 46, 47, 48, 49, 50, 51, 52, + /* 940 */ 53, 54, 55, 56, 57, 45, 46, 47, 48, 49, + /* 950 */ 50, 51, 52, 53, 54, 55, 56, 57, 19, 20, + /* 960 */ 187, 22, 187, 231, 232, 112, 113, 114, 123, 124, + /* 970 */ 125, 7, 8, 9, 187, 36, 244, 24, 77, 21, + /* 980 */ 79, 187, 209, 210, 187, 263, 99, 100, 101, 102, + /* 990 */ 103, 104, 105, 106, 107, 108, 109, 98, 59, 99, + /* 1000 */ 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, + /* 1010 */ 71, 187, 59, 187, 187, 19, 20, 187, 22, 112, + /* 1020 */ 81, 299, 300, 282, 230, 199, 291, 292, 22, 187, + /* 1030 */ 24, 256, 36, 209, 210, 187, 97, 35, 80, 209, + /* 1040 */ 210, 268, 103, 104, 48, 187, 220, 223, 222, 110, + /* 1050 */ 59, 112, 113, 114, 187, 59, 117, 156, 187, 179, + /* 1060 */ 180, 181, 182, 183, 184, 59, 113, 71, 66, 189, + /* 1070 */ 22, 191, 230, 134, 135, 245, 74, 119, 198, 282, + /* 1080 */ 297, 85, 224, 198, 301, 187, 90, 148, 149, 150, + /* 1090 */ 151, 152, 19, 97, 103, 104, 123, 124, 125, 103, + /* 1100 */ 104, 53, 111, 112, 113, 114, 110, 116, 112, 113, + /* 1110 */ 114, 231, 232, 117, 156, 124, 231, 232, 297, 113, + /* 1120 */ 187, 24, 301, 256, 244, 201, 202, 256, 126, 244, + /* 1130 */ 187, 198, 187, 187, 23, 187, 187, 26, 258, 148, + /* 1140 */ 19, 150, 209, 210, 148, 149, 150, 151, 152, 0, + /* 1150 */ 1, 2, 209, 210, 5, 209, 210, 209, 210, 10, + /* 1160 */ 11, 12, 13, 14, 231, 232, 17, 46, 288, 19, + /* 1170 */ 20, 223, 22, 236, 198, 66, 187, 244, 245, 30, + /* 1180 */ 12, 32, 198, 246, 59, 112, 36, 187, 245, 40, + /* 1190 */ 198, 245, 117, 29, 85, 27, 26, 33, 209, 210, + /* 1200 */ 297, 76, 127, 94, 301, 256, 26, 231, 232, 59, + /* 1210 */ 42, 153, 87, 155, 89, 231, 232, 92, 31, 70, + /* 1220 */ 244, 71, 26, 231, 232, 114, 39, 78, 244, 65, + /* 1230 */ 81, 63, 111, 233, 137, 85, 244, 112, 113, 114, + /* 1240 */ 90, 22, 59, 24, 95, 201, 202, 97, 127, 187, + /* 1250 */ 139, 142, 187, 103, 104, 19, 20, 187, 22, 187, + /* 1260 */ 110, 187, 112, 113, 114, 187, 141, 117, 141, 187, + /* 1270 */ 23, 187, 36, 26, 209, 210, 134, 135, 129, 209, + /* 1280 */ 210, 209, 210, 134, 135, 22, 159, 209, 210, 187, + /* 1290 */ 187, 209, 210, 209, 210, 59, 113, 187, 148, 149, + /* 1300 */ 150, 151, 152, 289, 290, 187, 157, 71, 248, 249, + /* 1310 */ 114, 141, 209, 210, 46, 125, 116, 117, 138, 19, + /* 1320 */ 20, 85, 22, 148, 61, 150, 90, 209, 210, 23, + /* 1330 */ 7, 8, 26, 97, 187, 139, 36, 147, 59, 103, + /* 1340 */ 104, 19, 20, 187, 22, 59, 110, 187, 112, 113, + /* 1350 */ 114, 1, 2, 117, 187, 5, 209, 210, 36, 59, + /* 1360 */ 10, 11, 12, 13, 14, 209, 210, 17, 59, 209, + /* 1370 */ 210, 71, 187, 148, 250, 150, 209, 210, 187, 111, + /* 1380 */ 30, 59, 32, 22, 148, 149, 150, 151, 152, 187, + /* 1390 */ 40, 187, 113, 71, 209, 210, 187, 97, 187, 113, + /* 1400 */ 209, 210, 187, 103, 104, 105, 23, 187, 187, 26, + /* 1410 */ 110, 187, 112, 113, 114, 83, 84, 117, 23, 97, + /* 1420 */ 70, 26, 113, 218, 187, 103, 104, 187, 78, 209, + /* 1430 */ 210, 81, 110, 187, 112, 113, 114, 19, 20, 117, + /* 1440 */ 22, 187, 187, 187, 187, 95, 209, 210, 148, 149, + /* 1450 */ 150, 151, 152, 187, 36, 23, 187, 187, 26, 187, + /* 1460 */ 187, 187, 187, 209, 210, 209, 210, 187, 187, 218, + /* 1470 */ 148, 149, 150, 151, 152, 209, 210, 59, 187, 129, + /* 1480 */ 187, 209, 210, 187, 134, 135, 187, 306, 187, 71, + /* 1490 */ 209, 210, 23, 228, 187, 26, 23, 187, 137, 26, + /* 1500 */ 209, 210, 209, 210, 187, 209, 210, 157, 209, 210, + /* 1510 */ 209, 210, 218, 187, 187, 97, 209, 210, 187, 278, + /* 1520 */ 23, 103, 104, 26, 187, 187, 187, 187, 110, 187, + /* 1530 */ 112, 113, 114, 187, 187, 117, 5, 247, 187, 187, + /* 1540 */ 187, 10, 11, 12, 13, 14, 209, 210, 17, 209, + /* 1550 */ 210, 209, 210, 187, 187, 187, 209, 210, 187, 23, + /* 1560 */ 187, 30, 26, 32, 187, 187, 148, 149, 150, 151, + /* 1570 */ 152, 40, 187, 187, 187, 209, 210, 209, 210, 187, + /* 1580 */ 209, 210, 209, 210, 187, 187, 209, 210, 187, 277, + /* 1590 */ 234, 187, 247, 187, 209, 210, 209, 210, 187, 235, + /* 1600 */ 187, 70, 187, 207, 247, 247, 247, 209, 210, 78, + /* 1610 */ 209, 210, 81, 209, 210, 209, 210, 187, 185, 238, + /* 1620 */ 209, 210, 209, 210, 209, 210, 95, 251, 287, 238, + /* 1630 */ 251, 23, 23, 23, 26, 26, 26, 283, 23, 209, + /* 1640 */ 210, 26, 213, 238, 221, 283, 212, 212, 217, 212, + /* 1650 */ 251, 241, 270, 241, 237, 235, 190, 60, 137, 287, + /* 1660 */ 129, 194, 194, 38, 284, 134, 135, 273, 284, 194, + /* 1670 */ 146, 111, 22, 43, 226, 145, 262, 261, 238, 18, + /* 1680 */ 229, 229, 229, 229, 194, 18, 193, 238, 157, 262, + /* 1690 */ 226, 226, 194, 238, 238, 193, 153, 261, 62, 280, + /* 1700 */ 279, 194, 193, 22, 194, 214, 193, 111, 194, 193, + /* 1710 */ 214, 211, 211, 64, 211, 211, 122, 211, 219, 214, + /* 1720 */ 109, 213, 160, 211, 300, 140, 211, 253, 111, 272, + /* 1730 */ 219, 214, 272, 214, 252, 194, 253, 252, 91, 253, + /* 1740 */ 252, 82, 253, 305, 252, 144, 305, 141, 22, 194, + /* 1750 */ 269, 257, 257, 153, 267, 143, 142, 25, 197, 26, + /* 1760 */ 242, 241, 196, 240, 242, 239, 238, 13, 188, 188, + /* 1770 */ 6, 293, 186, 186, 186, 200, 206, 293, 206, 206, + /* 1780 */ 206, 4, 200, 215, 215, 207, 207, 3, 22, 206, + /* 1790 */ 200, 158, 96, 15, 23, 16, 23, 135, 146, 126, + /* 1800 */ 24, 138, 20, 16, 140, 1, 138, 147, 126, 61, + /* 1810 */ 53, 37, 146, 53, 53, 290, 53, 126, 112, 34, + /* 1820 */ 137, 1, 5, 22, 111, 156, 68, 68, 26, 41, + /* 1830 */ 75, 137, 111, 24, 20, 19, 127, 121, 23, 67, + /* 1840 */ 22, 22, 67, 22, 22, 37, 22, 67, 23, 145, + /* 1850 */ 22, 28, 23, 23, 23, 137, 23, 22, 26, 22, + /* 1860 */ 24, 23, 112, 24, 23, 23, 22, 139, 34, 26, + /* 1870 */ 75, 88, 86, 75, 34, 23, 22, 24, 22, 34, + /* 1880 */ 34, 34, 93, 34, 26, 26, 23, 23, 23, 34, + /* 1890 */ 23, 23, 44, 23, 11, 26, 22, 22, 26, 23, + /* 1900 */ 23, 22, 22, 15, 137, 137, 137, 137, 23, 1, + /* 1910 */ 307, 307, 131, 307, 307, 307, 307, 307, 307, 307, + /* 1920 */ 307, 307, 307, 307, 307, 307, 307, 307, 307, 307, + /* 1930 */ 307, 307, 307, 307, 307, 307, 307, 307, 307, 307, + /* 1940 */ 307, 307, 307, 307, 307, 307, 307, 307, 307, 307, + /* 1950 */ 307, 307, 307, 307, 307, 307, 307, 307, 307, 307, + /* 1960 */ 307, 307, 307, 307, 307, 307, 307, 307, 307, 307, + /* 1970 */ 307, 307, 307, 307, 307, 307, 307, 307, 307, 307, + /* 1980 */ 307, 307, 307, 307, 307, 307, 307, 307, 307, 307, + /* 1990 */ 307, 307, 307, 307, 307, 307, 307, 307, 307, 307, + /* 2000 */ 307, 307, 307, 307, 307, 307, 307, 307, 307, 307, + /* 2010 */ 307, 307, 307, 307, 307, 307, 307, 307, 307, 307, + /* 2020 */ 307, 307, 307, 307, 307, 307, 307, 307, 307, 307, + /* 2030 */ 307, 307, 307, 307, 307, 307, 307, 307, 307, 307, + /* 2040 */ 307, 307, 307, 307, 307, 307, 307, 307, 307, 307, + /* 2050 */ 307, 307, 307, 307, 307, 307, 307, 307, 307, 307, + /* 2060 */ 307, 307, 307, 307, 307, 307, 307, 307, 307, 307, + /* 2070 */ 307, 307, 307, 307, 307, 307, 307, 307, 307, 307, + /* 2080 */ 307, 307, 307, 307, 307, 307, 307, 307, 307, 307, + /* 2090 */ 307, 307, }; -#define YY_SHIFT_COUNT (550) +#define YY_SHIFT_COUNT (542) #define YY_SHIFT_MIN (0) -#define YY_SHIFT_MAX (1948) +#define YY_SHIFT_MAX (1908) static const unsigned short int yy_shift_ofst[] = { - /* 0 */ 1448, 1277, 1668, 1072, 1072, 340, 1122, 1225, 1332, 1481, - /* 10 */ 1481, 1481, 335, 0, 0, 180, 897, 1481, 1481, 1481, - /* 20 */ 1481, 1481, 1481, 1481, 1481, 1481, 1481, 1481, 1481, 1481, - /* 30 */ 930, 930, 1020, 1020, 290, 1, 340, 340, 340, 340, - /* 40 */ 340, 340, 40, 110, 219, 288, 327, 396, 435, 504, - /* 50 */ 543, 612, 651, 720, 877, 897, 897, 897, 897, 897, - /* 60 */ 897, 897, 897, 897, 897, 897, 897, 897, 897, 897, - /* 70 */ 897, 897, 897, 917, 897, 1019, 763, 763, 1451, 1481, - /* 80 */ 1481, 1481, 1481, 1481, 1481, 1481, 1481, 1481, 1481, 1481, - /* 90 */ 1481, 1481, 1481, 1481, 1481, 1481, 1481, 1481, 1481, 1481, - /* 100 */ 1481, 1481, 1481, 1481, 1481, 1481, 1481, 1481, 1481, 1481, - /* 110 */ 1481, 1481, 1553, 1481, 1481, 1481, 1481, 1481, 1481, 1481, - /* 120 */ 1481, 1481, 1481, 1481, 1481, 1481, 147, 258, 258, 258, - /* 130 */ 258, 258, 79, 65, 84, 449, 19, 786, 449, 636, - /* 140 */ 636, 449, 880, 880, 880, 880, 113, 142, 142, 472, - /* 150 */ 150, 1958, 1958, 399, 399, 399, 93, 237, 341, 237, - /* 160 */ 237, 1074, 1074, 437, 350, 704, 1080, 449, 449, 449, - /* 170 */ 449, 449, 449, 449, 449, 449, 449, 449, 449, 449, - /* 180 */ 449, 449, 449, 449, 449, 449, 449, 449, 818, 818, - /* 190 */ 449, 1088, 217, 217, 734, 734, 1124, 1126, 1958, 1958, - /* 200 */ 1958, 739, 840, 840, 453, 454, 511, 187, 563, 570, - /* 210 */ 898, 669, 449, 449, 449, 449, 449, 449, 449, 449, - /* 220 */ 449, 670, 449, 449, 449, 449, 449, 449, 449, 449, - /* 230 */ 449, 449, 449, 449, 674, 674, 674, 449, 449, 449, - /* 240 */ 449, 1034, 449, 449, 449, 972, 1107, 449, 449, 1193, - /* 250 */ 449, 449, 449, 449, 449, 449, 449, 449, 260, 177, - /* 260 */ 489, 1241, 1241, 1241, 1241, 1192, 489, 489, 952, 1197, - /* 270 */ 625, 1235, 1139, 181, 181, 1086, 1139, 1139, 1086, 1187, - /* 280 */ 1131, 1237, 1314, 1314, 1314, 181, 1245, 1245, 1109, 1299, - /* 290 */ 549, 1340, 1606, 1531, 1531, 1639, 1639, 1531, 1538, 1576, - /* 300 */ 1669, 1647, 1546, 1677, 1677, 1677, 1677, 1531, 1693, 1546, - /* 310 */ 1546, 1576, 1669, 1647, 1647, 1546, 1531, 1693, 1567, 1661, - /* 320 */ 1531, 1693, 1706, 1531, 1693, 1531, 1693, 1706, 1622, 1622, - /* 330 */ 1622, 1675, 1720, 1720, 1706, 1622, 1619, 1622, 1675, 1622, - /* 340 */ 1622, 1582, 1706, 1634, 1634, 1706, 1605, 1649, 1605, 1649, - /* 350 */ 1605, 1649, 1605, 1649, 1531, 1679, 1679, 1690, 1690, 1629, - /* 360 */ 1635, 1755, 1531, 1626, 1629, 1637, 1640, 1546, 1760, 1762, - /* 370 */ 1773, 1773, 1787, 1787, 1787, 1958, 1958, 1958, 1958, 1958, - /* 380 */ 1958, 1958, 1958, 1958, 1958, 1958, 1958, 1958, 1958, 1958, - /* 390 */ 308, 835, 954, 1232, 879, 715, 728, 1323, 864, 1318, - /* 400 */ 1253, 1373, 297, 1409, 1419, 1440, 1489, 1497, 1520, 1242, - /* 410 */ 1309, 1447, 1435, 1341, 1521, 1525, 1392, 1548, 1329, 1354, - /* 420 */ 1585, 1587, 1353, 1382, 1812, 1814, 1799, 1662, 1811, 1730, - /* 430 */ 1813, 1807, 1808, 1695, 1685, 1707, 1810, 1696, 1817, 1697, - /* 440 */ 1822, 1839, 1701, 1694, 1714, 1783, 1809, 1699, 1792, 1795, - /* 450 */ 1796, 1797, 1724, 1740, 1821, 1717, 1856, 1853, 1837, 1747, - /* 460 */ 1703, 1794, 1838, 1798, 1788, 1824, 1728, 1756, 1844, 1850, - /* 470 */ 1852, 1743, 1750, 1854, 1815, 1855, 1857, 1851, 1858, 1816, - /* 480 */ 1819, 1860, 1779, 1859, 1863, 1823, 1849, 1865, 1734, 1867, - /* 490 */ 1868, 1869, 1870, 1871, 1872, 1874, 1875, 1877, 1876, 1878, - /* 500 */ 1764, 1881, 1882, 1780, 1873, 1879, 1765, 1883, 1880, 1884, - /* 510 */ 1885, 1886, 1820, 1835, 1825, 1887, 1840, 1828, 1888, 1889, - /* 520 */ 1891, 1892, 1897, 1898, 1893, 1894, 1883, 1902, 1903, 1905, - /* 530 */ 1906, 1904, 1909, 1911, 1923, 1913, 1914, 1915, 1916, 1918, - /* 540 */ 1919, 1917, 1804, 1803, 1805, 1806, 1818, 1924, 1931, 1947, - /* 550 */ 1948, + /* 0 */ 1350, 1149, 1531, 939, 939, 548, 996, 1150, 1236, 1322, + /* 10 */ 1322, 1322, 334, 0, 0, 178, 777, 1322, 1322, 1322, + /* 20 */ 1322, 1322, 1322, 1322, 1322, 1322, 1322, 1322, 1322, 1322, + /* 30 */ 991, 991, 1125, 1125, 447, 597, 548, 548, 548, 548, + /* 40 */ 548, 548, 40, 108, 217, 284, 323, 390, 429, 496, + /* 50 */ 535, 602, 641, 757, 777, 777, 777, 777, 777, 777, + /* 60 */ 777, 777, 777, 777, 777, 777, 777, 777, 777, 777, + /* 70 */ 777, 777, 796, 777, 887, 900, 900, 1300, 1322, 1322, + /* 80 */ 1322, 1322, 1322, 1322, 1322, 1322, 1322, 1322, 1322, 1322, + /* 90 */ 1322, 1322, 1322, 1322, 1322, 1322, 1322, 1322, 1322, 1322, + /* 100 */ 1322, 1322, 1322, 1322, 1322, 1322, 1322, 1322, 1322, 1322, + /* 110 */ 1418, 1322, 1322, 1322, 1322, 1322, 1322, 1322, 1322, 1322, + /* 120 */ 1322, 1322, 1322, 1322, 147, 254, 254, 254, 254, 254, + /* 130 */ 84, 185, 66, 853, 958, 1121, 853, 92, 92, 853, + /* 140 */ 321, 321, 321, 321, 325, 350, 350, 461, 150, 1913, + /* 150 */ 1913, 285, 285, 285, 236, 184, 349, 184, 184, 712, + /* 160 */ 712, 433, 553, 771, 899, 853, 853, 853, 853, 853, + /* 170 */ 853, 853, 853, 853, 853, 853, 853, 853, 853, 853, + /* 180 */ 853, 853, 853, 853, 853, 853, 46, 46, 853, 113, + /* 190 */ 223, 223, 1183, 1183, 1127, 1142, 1913, 1913, 1913, 459, + /* 200 */ 514, 514, 653, 495, 657, 305, 705, 560, 622, 776, + /* 210 */ 853, 853, 853, 853, 853, 853, 853, 853, 853, 545, + /* 220 */ 853, 853, 853, 853, 853, 853, 853, 853, 853, 853, + /* 230 */ 853, 853, 1002, 1002, 1002, 853, 853, 853, 853, 1111, + /* 240 */ 853, 853, 853, 1006, 1109, 853, 853, 1168, 853, 853, + /* 250 */ 853, 853, 853, 853, 853, 853, 845, 1164, 738, 953, + /* 260 */ 953, 953, 953, 1196, 738, 738, 45, 96, 964, 179, + /* 270 */ 580, 907, 907, 1073, 580, 580, 1073, 498, 388, 1268, + /* 280 */ 1187, 1187, 1187, 907, 1170, 1170, 1058, 1180, 328, 1219, + /* 290 */ 1597, 1521, 1521, 1625, 1625, 1521, 1524, 1560, 1650, 1630, + /* 300 */ 1530, 1661, 1661, 1661, 1661, 1521, 1667, 1530, 1530, 1560, + /* 310 */ 1650, 1630, 1630, 1530, 1521, 1667, 1543, 1636, 1521, 1667, + /* 320 */ 1681, 1521, 1667, 1521, 1667, 1681, 1596, 1596, 1596, 1649, + /* 330 */ 1681, 1596, 1594, 1596, 1649, 1596, 1596, 1562, 1681, 1611, + /* 340 */ 1611, 1681, 1585, 1617, 1585, 1617, 1585, 1617, 1585, 1617, + /* 350 */ 1521, 1647, 1647, 1659, 1659, 1601, 1606, 1726, 1521, 1600, + /* 360 */ 1601, 1612, 1614, 1530, 1732, 1733, 1754, 1754, 1764, 1764, + /* 370 */ 1764, 1913, 1913, 1913, 1913, 1913, 1913, 1913, 1913, 1913, + /* 380 */ 1913, 1913, 1913, 1913, 1913, 1913, 673, 901, 283, 740, + /* 390 */ 707, 973, 655, 1247, 1048, 1097, 1190, 1306, 1263, 1383, + /* 400 */ 1395, 1432, 1469, 1473, 1497, 1279, 1200, 1323, 1075, 1286, + /* 410 */ 1536, 1608, 1332, 1609, 1175, 1225, 1610, 1615, 1309, 1361, + /* 420 */ 1777, 1784, 1766, 1633, 1778, 1696, 1779, 1771, 1773, 1662, + /* 430 */ 1652, 1673, 1776, 1663, 1782, 1664, 1787, 1804, 1668, 1660, + /* 440 */ 1682, 1748, 1774, 1666, 1757, 1760, 1761, 1763, 1691, 1706, + /* 450 */ 1785, 1683, 1820, 1817, 1801, 1713, 1669, 1758, 1802, 1759, + /* 460 */ 1755, 1788, 1694, 1721, 1809, 1814, 1816, 1709, 1716, 1818, + /* 470 */ 1772, 1819, 1821, 1815, 1822, 1775, 1823, 1824, 1780, 1808, + /* 480 */ 1825, 1704, 1828, 1829, 1830, 1831, 1832, 1833, 1835, 1836, + /* 490 */ 1838, 1837, 1839, 1718, 1841, 1842, 1750, 1834, 1844, 1728, + /* 500 */ 1843, 1840, 1845, 1846, 1847, 1783, 1795, 1786, 1848, 1798, + /* 510 */ 1789, 1849, 1852, 1854, 1853, 1858, 1859, 1855, 1863, 1843, + /* 520 */ 1864, 1865, 1867, 1868, 1869, 1870, 1856, 1883, 1874, 1875, + /* 530 */ 1876, 1877, 1879, 1880, 1872, 1781, 1767, 1768, 1769, 1770, + /* 540 */ 1885, 1888, 1908, }; -#define YY_REDUCE_COUNT (389) -#define YY_REDUCE_MIN (-262) -#define YY_REDUCE_MAX (1617) +#define YY_REDUCE_COUNT (385) +#define YY_REDUCE_MIN (-256) +#define YY_REDUCE_MAX (1590) static const short yy_reduce_ofst[] = { - /* 0 */ 490, -122, 545, 645, 650, -120, -189, -187, -184, -182, - /* 10 */ -178, -176, 45, 30, 200, -251, -134, 390, 392, 521, - /* 20 */ 523, 213, 692, 821, 284, 589, 872, 666, 671, 866, - /* 30 */ 71, 111, 273, 389, 686, 815, 904, 932, 948, 955, - /* 40 */ 964, 969, -259, -259, -259, -259, -259, -259, -259, -259, - /* 50 */ -259, -259, -259, -259, -259, -259, -259, -259, -259, -259, - /* 60 */ -259, -259, -259, -259, -259, -259, -259, -259, -259, -259, - /* 70 */ -259, -259, -259, -259, -259, -259, -259, -259, 428, 430, - /* 80 */ 899, 985, 1021, 1028, 1057, 1069, 1081, 1108, 1110, 1115, - /* 90 */ 1117, 1123, 1149, 1154, 1159, 1170, 1174, 1178, 1183, 1194, - /* 100 */ 1198, 1204, 1208, 1212, 1218, 1222, 1229, 1278, 1280, 1283, - /* 110 */ 1285, 1313, 1316, 1320, 1322, 1325, 1327, 1330, 1366, 1371, - /* 120 */ 1379, 1387, 1417, 1425, 1430, 1432, -259, -259, -259, -259, - /* 130 */ -259, -259, -259, -259, -259, 557, 974, -214, -174, -9, - /* 140 */ 431, -124, 806, 925, 806, 925, 251, 928, 940, -259, - /* 150 */ -259, -259, -259, -198, -198, -198, 127, -186, -168, 212, - /* 160 */ 646, 617, 799, -262, 555, 220, 220, 491, 605, 1040, - /* 170 */ 1060, 699, -11, 600, 848, 862, 345, -129, 724, -91, - /* 180 */ 158, 749, 716, 900, 304, 822, 929, 926, 499, 793, - /* 190 */ 322, 892, 813, 845, 958, 1056, 751, 905, 1133, 1062, - /* 200 */ 803, -210, -185, -179, -148, -167, -89, 121, 274, 281, - /* 210 */ 320, 336, 439, 663, 711, 957, 1064, 1068, 1116, 1127, - /* 220 */ 1134, -196, 1147, 1180, 1184, 1195, 1203, 1209, 1254, 1263, - /* 230 */ 1275, 1288, 1304, 1310, 205, 422, 638, 1319, 1324, 1346, - /* 240 */ 1360, 1168, 1364, 1370, 1372, 869, 1189, 1380, 1399, 1276, - /* 250 */ 1403, 121, 1405, 1420, 1426, 1427, 1428, 1429, 1249, 1282, - /* 260 */ 1344, 1375, 1376, 1377, 1388, 1168, 1344, 1344, 1384, 1411, - /* 270 */ 1436, 1349, 1389, 1386, 1391, 1361, 1407, 1408, 1365, 1431, - /* 280 */ 1433, 1434, 1439, 1441, 1442, 1396, 1416, 1418, 1390, 1421, - /* 290 */ 1437, 1472, 1381, 1478, 1480, 1397, 1400, 1487, 1412, 1444, - /* 300 */ 1438, 1463, 1453, 1464, 1465, 1467, 1469, 1514, 1517, 1473, - /* 310 */ 1474, 1452, 1449, 1490, 1491, 1475, 1522, 1526, 1443, 1445, - /* 320 */ 1528, 1530, 1513, 1534, 1536, 1537, 1539, 1516, 1523, 1524, - /* 330 */ 1527, 1519, 1529, 1532, 1540, 1541, 1535, 1542, 1544, 1545, - /* 340 */ 1547, 1450, 1543, 1477, 1482, 1551, 1505, 1508, 1512, 1509, - /* 350 */ 1515, 1518, 1533, 1552, 1573, 1466, 1468, 1549, 1550, 1555, - /* 360 */ 1554, 1510, 1583, 1511, 1556, 1559, 1561, 1565, 1588, 1592, - /* 370 */ 1601, 1602, 1607, 1608, 1609, 1498, 1557, 1558, 1610, 1600, - /* 380 */ 1603, 1611, 1612, 1613, 1596, 1597, 1614, 1615, 1617, 1616, + /* 0 */ 880, -121, 269, 528, 933, -119, -187, -185, -182, -180, + /* 10 */ -176, -174, -62, -46, 131, -248, -133, 407, 568, 700, + /* 20 */ 704, 278, 706, 824, 542, 830, 948, 773, 943, 946, + /* 30 */ 71, 650, 211, 267, 826, 272, 676, 732, 885, 976, + /* 40 */ 984, 992, -256, -256, -256, -256, -256, -256, -256, -256, + /* 50 */ -256, -256, -256, -256, -256, -256, -256, -256, -256, -256, + /* 60 */ -256, -256, -256, -256, -256, -256, -256, -256, -256, -256, + /* 70 */ -256, -256, -256, -256, -256, -256, -256, 989, 1065, 1070, + /* 80 */ 1072, 1078, 1082, 1084, 1103, 1118, 1147, 1156, 1160, 1167, + /* 90 */ 1185, 1191, 1220, 1237, 1254, 1256, 1266, 1272, 1281, 1291, + /* 100 */ 1293, 1296, 1299, 1301, 1307, 1337, 1340, 1342, 1347, 1366, + /* 110 */ 1368, 1371, 1373, 1377, 1385, 1387, 1398, 1401, 1404, 1406, + /* 120 */ 1411, 1413, 1415, 1430, -256, -256, -256, -256, -256, -256, + /* 130 */ -256, -256, -256, -172, 508, -213, 57, -163, -25, 593, + /* 140 */ 69, 486, 69, 486, -200, 573, 722, -256, -256, -256, + /* 150 */ -256, -141, -141, -141, -105, -161, -167, 157, 212, 405, + /* 160 */ 530, 220, 233, 735, 735, 115, 318, 406, 612, 541, + /* 170 */ -166, 441, 688, 794, 629, 368, 741, 775, 867, 797, + /* 180 */ 871, 842, -186, 1000, 858, 949, 379, 783, 70, 296, + /* 190 */ 821, 903, 924, 1044, 651, 282, 1014, 1060, 937, -195, + /* 200 */ -177, 413, 439, 511, 566, 787, 827, 848, 898, 945, + /* 210 */ 1062, 1074, 1102, 1110, 1202, 1204, 1209, 1211, 1215, 529, + /* 220 */ 1221, 1224, 1240, 1246, 1255, 1257, 1269, 1270, 1273, 1274, + /* 230 */ 1275, 1280, 1205, 1251, 1294, 1310, 1317, 1326, 1327, 1124, + /* 240 */ 1331, 1338, 1339, 1290, 1181, 1346, 1351, 1265, 1352, 787, + /* 250 */ 1353, 1367, 1378, 1386, 1392, 1397, 1241, 1312, 1356, 1345, + /* 260 */ 1357, 1358, 1359, 1124, 1356, 1356, 1364, 1396, 1433, 1341, + /* 270 */ 1381, 1376, 1379, 1354, 1391, 1405, 1362, 1429, 1423, 1431, + /* 280 */ 1434, 1435, 1437, 1399, 1410, 1412, 1382, 1417, 1420, 1466, + /* 290 */ 1372, 1467, 1468, 1380, 1384, 1475, 1394, 1414, 1416, 1448, + /* 300 */ 1440, 1451, 1452, 1453, 1454, 1490, 1493, 1449, 1455, 1427, + /* 310 */ 1436, 1464, 1465, 1456, 1498, 1502, 1419, 1421, 1507, 1509, + /* 320 */ 1491, 1510, 1513, 1514, 1516, 1496, 1500, 1501, 1503, 1499, + /* 330 */ 1505, 1504, 1508, 1506, 1511, 1512, 1515, 1424, 1517, 1457, + /* 340 */ 1460, 1519, 1474, 1482, 1483, 1485, 1486, 1488, 1489, 1492, + /* 350 */ 1541, 1438, 1441, 1494, 1495, 1518, 1520, 1487, 1555, 1481, + /* 360 */ 1522, 1523, 1526, 1528, 1561, 1566, 1580, 1581, 1586, 1587, + /* 370 */ 1588, 1478, 1484, 1525, 1575, 1570, 1572, 1573, 1574, 1582, + /* 380 */ 1568, 1569, 1578, 1579, 1583, 1590, }; static const YYACTIONTYPE yy_default[] = { - /* 0 */ 1573, 1573, 1573, 1409, 1186, 1295, 1186, 1186, 1186, 1409, - /* 10 */ 1409, 1409, 1186, 1325, 1325, 1462, 1217, 1186, 1186, 1186, - /* 20 */ 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1408, 1186, 1186, - /* 30 */ 1186, 1186, 1492, 1492, 1186, 1186, 1186, 1186, 1186, 1186, - /* 40 */ 1186, 1186, 1186, 1334, 1186, 1186, 1186, 1186, 1186, 1186, - /* 50 */ 1410, 1411, 1186, 1186, 1186, 1461, 1463, 1426, 1344, 1343, - /* 60 */ 1342, 1341, 1444, 1312, 1339, 1332, 1336, 1404, 1405, 1403, - /* 70 */ 1407, 1411, 1410, 1186, 1335, 1375, 1389, 1374, 1186, 1186, - /* 80 */ 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186, - /* 90 */ 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186, - /* 100 */ 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186, - /* 110 */ 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186, - /* 120 */ 1186, 1186, 1186, 1186, 1186, 1186, 1383, 1388, 1394, 1387, - /* 130 */ 1384, 1377, 1376, 1378, 1379, 1186, 1207, 1259, 1186, 1186, - /* 140 */ 1186, 1186, 1480, 1479, 1186, 1186, 1217, 1369, 1368, 1380, - /* 150 */ 1381, 1391, 1390, 1469, 1527, 1526, 1427, 1186, 1186, 1186, - /* 160 */ 1186, 1186, 1186, 1492, 1186, 1186, 1186, 1186, 1186, 1186, - /* 170 */ 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186, - /* 180 */ 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1492, 1492, - /* 190 */ 1186, 1217, 1492, 1492, 1213, 1213, 1319, 1186, 1475, 1295, - /* 200 */ 1286, 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186, - /* 210 */ 1186, 1186, 1186, 1186, 1186, 1466, 1464, 1186, 1186, 1186, - /* 220 */ 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186, - /* 230 */ 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186, - /* 240 */ 1186, 1186, 1186, 1186, 1186, 1291, 1186, 1186, 1186, 1186, - /* 250 */ 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1521, 1186, 1439, - /* 260 */ 1273, 1291, 1291, 1291, 1291, 1293, 1274, 1272, 1285, 1218, - /* 270 */ 1193, 1565, 1338, 1314, 1314, 1562, 1338, 1338, 1562, 1234, - /* 280 */ 1543, 1229, 1325, 1325, 1325, 1314, 1319, 1319, 1406, 1292, - /* 290 */ 1285, 1186, 1565, 1300, 1300, 1564, 1564, 1300, 1427, 1347, - /* 300 */ 1353, 1262, 1338, 1268, 1268, 1268, 1268, 1300, 1204, 1338, - /* 310 */ 1338, 1347, 1353, 1262, 1262, 1338, 1300, 1204, 1443, 1559, - /* 320 */ 1300, 1204, 1417, 1300, 1204, 1300, 1204, 1417, 1260, 1260, - /* 330 */ 1260, 1249, 1186, 1186, 1417, 1260, 1234, 1260, 1249, 1260, - /* 340 */ 1260, 1510, 1417, 1421, 1421, 1417, 1318, 1313, 1318, 1313, - /* 350 */ 1318, 1313, 1318, 1313, 1300, 1502, 1502, 1328, 1328, 1333, - /* 360 */ 1319, 1412, 1300, 1186, 1333, 1331, 1329, 1338, 1210, 1252, - /* 370 */ 1524, 1524, 1520, 1520, 1520, 1570, 1570, 1475, 1536, 1217, - /* 380 */ 1217, 1217, 1217, 1536, 1236, 1236, 1218, 1218, 1217, 1536, - /* 390 */ 1186, 1186, 1186, 1186, 1186, 1186, 1531, 1186, 1428, 1304, - /* 400 */ 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186, - /* 410 */ 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186, - /* 420 */ 1186, 1186, 1186, 1358, 1186, 1189, 1472, 1186, 1186, 1470, - /* 430 */ 1186, 1186, 1186, 1186, 1186, 1186, 1305, 1186, 1186, 1186, - /* 440 */ 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186, - /* 450 */ 1186, 1186, 1186, 1186, 1186, 1561, 1186, 1186, 1186, 1186, - /* 460 */ 1186, 1186, 1442, 1441, 1186, 1186, 1302, 1186, 1186, 1186, - /* 470 */ 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186, - /* 480 */ 1232, 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186, - /* 490 */ 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186, - /* 500 */ 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1330, 1186, 1186, - /* 510 */ 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186, - /* 520 */ 1186, 1186, 1507, 1320, 1186, 1186, 1552, 1186, 1186, 1186, - /* 530 */ 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186, 1186, - /* 540 */ 1186, 1547, 1276, 1360, 1186, 1359, 1363, 1186, 1198, 1186, - /* 550 */ 1186, + /* 0 */ 1554, 1554, 1554, 1392, 1171, 1278, 1171, 1171, 1171, 1392, + /* 10 */ 1392, 1392, 1171, 1308, 1308, 1445, 1202, 1171, 1171, 1171, + /* 20 */ 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1391, 1171, 1171, + /* 30 */ 1171, 1171, 1475, 1475, 1171, 1171, 1171, 1171, 1171, 1171, + /* 40 */ 1171, 1171, 1171, 1317, 1171, 1171, 1171, 1171, 1171, 1393, + /* 50 */ 1394, 1171, 1171, 1171, 1444, 1446, 1409, 1327, 1326, 1325, + /* 60 */ 1324, 1427, 1295, 1322, 1315, 1319, 1387, 1388, 1386, 1390, + /* 70 */ 1394, 1393, 1171, 1318, 1358, 1372, 1357, 1171, 1171, 1171, + /* 80 */ 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171, + /* 90 */ 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171, + /* 100 */ 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171, + /* 110 */ 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171, + /* 120 */ 1171, 1171, 1171, 1171, 1366, 1371, 1377, 1370, 1367, 1360, + /* 130 */ 1359, 1361, 1362, 1171, 1192, 1242, 1171, 1171, 1171, 1171, + /* 140 */ 1463, 1462, 1171, 1171, 1202, 1352, 1351, 1363, 1364, 1374, + /* 150 */ 1373, 1452, 1510, 1509, 1410, 1171, 1171, 1171, 1171, 1171, + /* 160 */ 1171, 1475, 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171, + /* 170 */ 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171, + /* 180 */ 1171, 1171, 1171, 1171, 1171, 1171, 1475, 1475, 1171, 1202, + /* 190 */ 1475, 1475, 1198, 1198, 1302, 1171, 1458, 1278, 1269, 1171, + /* 200 */ 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171, + /* 210 */ 1171, 1171, 1171, 1449, 1447, 1171, 1171, 1171, 1171, 1171, + /* 220 */ 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171, + /* 230 */ 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171, + /* 240 */ 1171, 1171, 1171, 1274, 1171, 1171, 1171, 1171, 1171, 1171, + /* 250 */ 1171, 1171, 1171, 1171, 1171, 1504, 1171, 1422, 1256, 1274, + /* 260 */ 1274, 1274, 1274, 1276, 1257, 1255, 1268, 1203, 1178, 1546, + /* 270 */ 1321, 1297, 1297, 1543, 1321, 1321, 1543, 1217, 1524, 1214, + /* 280 */ 1308, 1308, 1308, 1297, 1302, 1302, 1389, 1275, 1268, 1171, + /* 290 */ 1546, 1283, 1283, 1545, 1545, 1283, 1410, 1330, 1336, 1245, + /* 300 */ 1321, 1251, 1251, 1251, 1251, 1283, 1189, 1321, 1321, 1330, + /* 310 */ 1336, 1245, 1245, 1321, 1283, 1189, 1426, 1540, 1283, 1189, + /* 320 */ 1400, 1283, 1189, 1283, 1189, 1400, 1243, 1243, 1243, 1232, + /* 330 */ 1400, 1243, 1217, 1243, 1232, 1243, 1243, 1493, 1400, 1404, + /* 340 */ 1404, 1400, 1301, 1296, 1301, 1296, 1301, 1296, 1301, 1296, + /* 350 */ 1283, 1485, 1485, 1311, 1311, 1316, 1302, 1395, 1283, 1171, + /* 360 */ 1316, 1314, 1312, 1321, 1195, 1235, 1507, 1507, 1503, 1503, + /* 370 */ 1503, 1551, 1551, 1458, 1519, 1202, 1202, 1202, 1202, 1519, + /* 380 */ 1219, 1219, 1203, 1203, 1202, 1519, 1171, 1171, 1171, 1171, + /* 390 */ 1171, 1171, 1514, 1171, 1411, 1287, 1171, 1171, 1171, 1171, + /* 400 */ 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171, + /* 410 */ 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1341, + /* 420 */ 1171, 1174, 1455, 1171, 1171, 1453, 1171, 1171, 1171, 1171, + /* 430 */ 1171, 1171, 1288, 1171, 1171, 1171, 1171, 1171, 1171, 1171, + /* 440 */ 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171, + /* 450 */ 1171, 1542, 1171, 1171, 1171, 1171, 1171, 1171, 1425, 1424, + /* 460 */ 1171, 1171, 1285, 1171, 1171, 1171, 1171, 1171, 1171, 1171, + /* 470 */ 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171, + /* 480 */ 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171, + /* 490 */ 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171, + /* 500 */ 1313, 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171, + /* 510 */ 1171, 1171, 1171, 1171, 1171, 1490, 1303, 1171, 1171, 1533, + /* 520 */ 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171, 1171, + /* 530 */ 1171, 1171, 1171, 1171, 1528, 1259, 1343, 1171, 1342, 1346, + /* 540 */ 1171, 1183, 1171, }; /********** End of lemon-generated parsing tables *****************************/ @@ -153341,8 +150705,6 @@ static const YYCODETYPE yyFallback[] = { 59, /* GROUPS => ID */ 59, /* OTHERS => ID */ 59, /* TIES => ID */ - 59, /* GENERATED => ID */ - 59, /* ALWAYS => ID */ 59, /* REINDEX => ID */ 59, /* RENAME => ID */ 59, /* CTIME_KW => ID */ @@ -153609,221 +150971,218 @@ static const char *const yyTokenName[] = { /* 92 */ "GROUPS", /* 93 */ "OTHERS", /* 94 */ "TIES", - /* 95 */ "GENERATED", - /* 96 */ "ALWAYS", - /* 97 */ "REINDEX", - /* 98 */ "RENAME", - /* 99 */ "CTIME_KW", - /* 100 */ "ANY", - /* 101 */ "BITAND", - /* 102 */ "BITOR", - /* 103 */ "LSHIFT", - /* 104 */ "RSHIFT", - /* 105 */ "PLUS", - /* 106 */ "MINUS", - /* 107 */ "STAR", - /* 108 */ "SLASH", - /* 109 */ "REM", - /* 110 */ "CONCAT", - /* 111 */ "COLLATE", - /* 112 */ "BITNOT", - /* 113 */ "ON", - /* 114 */ "INDEXED", - /* 115 */ "STRING", - /* 116 */ "JOIN_KW", - /* 117 */ "CONSTRAINT", - /* 118 */ "DEFAULT", - /* 119 */ "NULL", - /* 120 */ "PRIMARY", - /* 121 */ "UNIQUE", - /* 122 */ "CHECK", - /* 123 */ "REFERENCES", - /* 124 */ "AUTOINCR", - /* 125 */ "INSERT", - /* 126 */ "DELETE", - /* 127 */ "UPDATE", - /* 128 */ "SET", - /* 129 */ "DEFERRABLE", - /* 130 */ "FOREIGN", - /* 131 */ "DROP", - /* 132 */ "UNION", - /* 133 */ "ALL", - /* 134 */ "EXCEPT", - /* 135 */ "INTERSECT", - /* 136 */ "SELECT", - /* 137 */ "VALUES", - /* 138 */ "DISTINCT", - /* 139 */ "DOT", - /* 140 */ "FROM", - /* 141 */ "JOIN", - /* 142 */ "USING", - /* 143 */ "ORDER", - /* 144 */ "GROUP", - /* 145 */ "HAVING", - /* 146 */ "LIMIT", - /* 147 */ "WHERE", - /* 148 */ "INTO", - /* 149 */ "NOTHING", - /* 150 */ "FLOAT", - /* 151 */ "BLOB", - /* 152 */ "INTEGER", - /* 153 */ "VARIABLE", - /* 154 */ "CASE", - /* 155 */ "WHEN", - /* 156 */ "THEN", - /* 157 */ "ELSE", - /* 158 */ "INDEX", - /* 159 */ "ALTER", - /* 160 */ "ADD", - /* 161 */ "WINDOW", - /* 162 */ "OVER", - /* 163 */ "FILTER", - /* 164 */ "COLUMN", - /* 165 */ "AGG_FUNCTION", - /* 166 */ "AGG_COLUMN", - /* 167 */ "TRUEFALSE", - /* 168 */ "ISNOT", - /* 169 */ "FUNCTION", - /* 170 */ "UMINUS", - /* 171 */ "UPLUS", - /* 172 */ "TRUTH", - /* 173 */ "REGISTER", - /* 174 */ "VECTOR", - /* 175 */ "SELECT_COLUMN", - /* 176 */ "IF_NULL_ROW", - /* 177 */ "ASTERISK", - /* 178 */ "SPAN", - /* 179 */ "SPACE", - /* 180 */ "ILLEGAL", - /* 181 */ "input", - /* 182 */ "cmdlist", - /* 183 */ "ecmd", - /* 184 */ "cmdx", - /* 185 */ "explain", - /* 186 */ "cmd", - /* 187 */ "transtype", - /* 188 */ "trans_opt", - /* 189 */ "nm", - /* 190 */ "savepoint_opt", - /* 191 */ "create_table", - /* 192 */ "create_table_args", - /* 193 */ "createkw", - /* 194 */ "temp", - /* 195 */ "ifnotexists", - /* 196 */ "dbnm", - /* 197 */ "columnlist", - /* 198 */ "conslist_opt", - /* 199 */ "table_options", - /* 200 */ "select", - /* 201 */ "columnname", - /* 202 */ "carglist", - /* 203 */ "typetoken", - /* 204 */ "typename", - /* 205 */ "signed", - /* 206 */ "plus_num", - /* 207 */ "minus_num", - /* 208 */ "scanpt", - /* 209 */ "scantok", - /* 210 */ "ccons", - /* 211 */ "term", - /* 212 */ "expr", - /* 213 */ "onconf", - /* 214 */ "sortorder", - /* 215 */ "autoinc", - /* 216 */ "eidlist_opt", - /* 217 */ "refargs", - /* 218 */ "defer_subclause", - /* 219 */ "generated", - /* 220 */ "refarg", - /* 221 */ "refact", - /* 222 */ "init_deferred_pred_opt", - /* 223 */ "conslist", - /* 224 */ "tconscomma", - /* 225 */ "tcons", - /* 226 */ "sortlist", - /* 227 */ "eidlist", - /* 228 */ "defer_subclause_opt", - /* 229 */ "orconf", - /* 230 */ "resolvetype", - /* 231 */ "raisetype", - /* 232 */ "ifexists", - /* 233 */ "fullname", - /* 234 */ "selectnowith", - /* 235 */ "oneselect", - /* 236 */ "wqlist", - /* 237 */ "multiselect_op", - /* 238 */ "distinct", - /* 239 */ "selcollist", - /* 240 */ "from", - /* 241 */ "where_opt", - /* 242 */ "groupby_opt", - /* 243 */ "having_opt", - /* 244 */ "orderby_opt", - /* 245 */ "limit_opt", - /* 246 */ "window_clause", - /* 247 */ "values", - /* 248 */ "nexprlist", - /* 249 */ "sclp", - /* 250 */ "as", - /* 251 */ "seltablist", - /* 252 */ "stl_prefix", - /* 253 */ "joinop", - /* 254 */ "indexed_opt", - /* 255 */ "on_opt", - /* 256 */ "using_opt", - /* 257 */ "exprlist", - /* 258 */ "xfullname", - /* 259 */ "idlist", - /* 260 */ "nulls", - /* 261 */ "with", - /* 262 */ "setlist", - /* 263 */ "insert_cmd", - /* 264 */ "idlist_opt", - /* 265 */ "upsert", - /* 266 */ "filter_over", - /* 267 */ "likeop", - /* 268 */ "between_op", - /* 269 */ "in_op", - /* 270 */ "paren_exprlist", - /* 271 */ "case_operand", - /* 272 */ "case_exprlist", - /* 273 */ "case_else", - /* 274 */ "uniqueflag", - /* 275 */ "collate", - /* 276 */ "vinto", - /* 277 */ "nmnum", - /* 278 */ "trigger_decl", - /* 279 */ "trigger_cmd_list", - /* 280 */ "trigger_time", - /* 281 */ "trigger_event", - /* 282 */ "foreach_clause", - /* 283 */ "when_clause", - /* 284 */ "trigger_cmd", - /* 285 */ "trnm", - /* 286 */ "tridxby", - /* 287 */ "database_kw_opt", - /* 288 */ "key_opt", - /* 289 */ "add_column_fullname", - /* 290 */ "kwcolumn_opt", - /* 291 */ "create_vtab", - /* 292 */ "vtabarglist", - /* 293 */ "vtabarg", - /* 294 */ "vtabargtoken", - /* 295 */ "lp", - /* 296 */ "anylist", - /* 297 */ "windowdefn_list", - /* 298 */ "windowdefn", - /* 299 */ "window", - /* 300 */ "frame_opt", - /* 301 */ "part_opt", - /* 302 */ "filter_clause", - /* 303 */ "over_clause", - /* 304 */ "range_or_rows", - /* 305 */ "frame_bound", - /* 306 */ "frame_bound_s", - /* 307 */ "frame_bound_e", - /* 308 */ "frame_exclude_opt", - /* 309 */ "frame_exclude", + /* 95 */ "REINDEX", + /* 96 */ "RENAME", + /* 97 */ "CTIME_KW", + /* 98 */ "ANY", + /* 99 */ "BITAND", + /* 100 */ "BITOR", + /* 101 */ "LSHIFT", + /* 102 */ "RSHIFT", + /* 103 */ "PLUS", + /* 104 */ "MINUS", + /* 105 */ "STAR", + /* 106 */ "SLASH", + /* 107 */ "REM", + /* 108 */ "CONCAT", + /* 109 */ "COLLATE", + /* 110 */ "BITNOT", + /* 111 */ "ON", + /* 112 */ "INDEXED", + /* 113 */ "STRING", + /* 114 */ "JOIN_KW", + /* 115 */ "CONSTRAINT", + /* 116 */ "DEFAULT", + /* 117 */ "NULL", + /* 118 */ "PRIMARY", + /* 119 */ "UNIQUE", + /* 120 */ "CHECK", + /* 121 */ "REFERENCES", + /* 122 */ "AUTOINCR", + /* 123 */ "INSERT", + /* 124 */ "DELETE", + /* 125 */ "UPDATE", + /* 126 */ "SET", + /* 127 */ "DEFERRABLE", + /* 128 */ "FOREIGN", + /* 129 */ "DROP", + /* 130 */ "UNION", + /* 131 */ "ALL", + /* 132 */ "EXCEPT", + /* 133 */ "INTERSECT", + /* 134 */ "SELECT", + /* 135 */ "VALUES", + /* 136 */ "DISTINCT", + /* 137 */ "DOT", + /* 138 */ "FROM", + /* 139 */ "JOIN", + /* 140 */ "USING", + /* 141 */ "ORDER", + /* 142 */ "GROUP", + /* 143 */ "HAVING", + /* 144 */ "LIMIT", + /* 145 */ "WHERE", + /* 146 */ "INTO", + /* 147 */ "NOTHING", + /* 148 */ "FLOAT", + /* 149 */ "BLOB", + /* 150 */ "INTEGER", + /* 151 */ "VARIABLE", + /* 152 */ "CASE", + /* 153 */ "WHEN", + /* 154 */ "THEN", + /* 155 */ "ELSE", + /* 156 */ "INDEX", + /* 157 */ "ALTER", + /* 158 */ "ADD", + /* 159 */ "WINDOW", + /* 160 */ "OVER", + /* 161 */ "FILTER", + /* 162 */ "COLUMN", + /* 163 */ "AGG_FUNCTION", + /* 164 */ "AGG_COLUMN", + /* 165 */ "TRUEFALSE", + /* 166 */ "ISNOT", + /* 167 */ "FUNCTION", + /* 168 */ "UMINUS", + /* 169 */ "UPLUS", + /* 170 */ "TRUTH", + /* 171 */ "REGISTER", + /* 172 */ "VECTOR", + /* 173 */ "SELECT_COLUMN", + /* 174 */ "IF_NULL_ROW", + /* 175 */ "ASTERISK", + /* 176 */ "SPAN", + /* 177 */ "SPACE", + /* 178 */ "ILLEGAL", + /* 179 */ "input", + /* 180 */ "cmdlist", + /* 181 */ "ecmd", + /* 182 */ "cmdx", + /* 183 */ "explain", + /* 184 */ "cmd", + /* 185 */ "transtype", + /* 186 */ "trans_opt", + /* 187 */ "nm", + /* 188 */ "savepoint_opt", + /* 189 */ "create_table", + /* 190 */ "create_table_args", + /* 191 */ "createkw", + /* 192 */ "temp", + /* 193 */ "ifnotexists", + /* 194 */ "dbnm", + /* 195 */ "columnlist", + /* 196 */ "conslist_opt", + /* 197 */ "table_options", + /* 198 */ "select", + /* 199 */ "columnname", + /* 200 */ "carglist", + /* 201 */ "typetoken", + /* 202 */ "typename", + /* 203 */ "signed", + /* 204 */ "plus_num", + /* 205 */ "minus_num", + /* 206 */ "scanpt", + /* 207 */ "scantok", + /* 208 */ "ccons", + /* 209 */ "term", + /* 210 */ "expr", + /* 211 */ "onconf", + /* 212 */ "sortorder", + /* 213 */ "autoinc", + /* 214 */ "eidlist_opt", + /* 215 */ "refargs", + /* 216 */ "defer_subclause", + /* 217 */ "refarg", + /* 218 */ "refact", + /* 219 */ "init_deferred_pred_opt", + /* 220 */ "conslist", + /* 221 */ "tconscomma", + /* 222 */ "tcons", + /* 223 */ "sortlist", + /* 224 */ "eidlist", + /* 225 */ "defer_subclause_opt", + /* 226 */ "orconf", + /* 227 */ "resolvetype", + /* 228 */ "raisetype", + /* 229 */ "ifexists", + /* 230 */ "fullname", + /* 231 */ "selectnowith", + /* 232 */ "oneselect", + /* 233 */ "wqlist", + /* 234 */ "multiselect_op", + /* 235 */ "distinct", + /* 236 */ "selcollist", + /* 237 */ "from", + /* 238 */ "where_opt", + /* 239 */ "groupby_opt", + /* 240 */ "having_opt", + /* 241 */ "orderby_opt", + /* 242 */ "limit_opt", + /* 243 */ "window_clause", + /* 244 */ "values", + /* 245 */ "nexprlist", + /* 246 */ "sclp", + /* 247 */ "as", + /* 248 */ "seltablist", + /* 249 */ "stl_prefix", + /* 250 */ "joinop", + /* 251 */ "indexed_opt", + /* 252 */ "on_opt", + /* 253 */ "using_opt", + /* 254 */ "exprlist", + /* 255 */ "xfullname", + /* 256 */ "idlist", + /* 257 */ "nulls", + /* 258 */ "with", + /* 259 */ "setlist", + /* 260 */ "insert_cmd", + /* 261 */ "idlist_opt", + /* 262 */ "upsert", + /* 263 */ "filter_over", + /* 264 */ "likeop", + /* 265 */ "between_op", + /* 266 */ "in_op", + /* 267 */ "paren_exprlist", + /* 268 */ "case_operand", + /* 269 */ "case_exprlist", + /* 270 */ "case_else", + /* 271 */ "uniqueflag", + /* 272 */ "collate", + /* 273 */ "vinto", + /* 274 */ "nmnum", + /* 275 */ "trigger_decl", + /* 276 */ "trigger_cmd_list", + /* 277 */ "trigger_time", + /* 278 */ "trigger_event", + /* 279 */ "foreach_clause", + /* 280 */ "when_clause", + /* 281 */ "trigger_cmd", + /* 282 */ "trnm", + /* 283 */ "tridxby", + /* 284 */ "database_kw_opt", + /* 285 */ "key_opt", + /* 286 */ "add_column_fullname", + /* 287 */ "kwcolumn_opt", + /* 288 */ "create_vtab", + /* 289 */ "vtabarglist", + /* 290 */ "vtabarg", + /* 291 */ "vtabargtoken", + /* 292 */ "lp", + /* 293 */ "anylist", + /* 294 */ "windowdefn_list", + /* 295 */ "windowdefn", + /* 296 */ "window", + /* 297 */ "frame_opt", + /* 298 */ "part_opt", + /* 299 */ "filter_clause", + /* 300 */ "over_clause", + /* 301 */ "range_or_rows", + /* 302 */ "frame_bound", + /* 303 */ "frame_bound_s", + /* 304 */ "frame_bound_e", + /* 305 */ "frame_exclude_opt", + /* 306 */ "frame_exclude", }; #endif /* defined(YYCOVERAGE) || !defined(NDEBUG) */ @@ -153874,348 +151233,344 @@ static const char *const yyRuleName[] = { /* 40 */ "ccons ::= REFERENCES nm eidlist_opt refargs", /* 41 */ "ccons ::= defer_subclause", /* 42 */ "ccons ::= COLLATE ID|STRING", - /* 43 */ "generated ::= LP expr RP", - /* 44 */ "generated ::= LP expr RP ID", - /* 45 */ "autoinc ::=", - /* 46 */ "autoinc ::= AUTOINCR", - /* 47 */ "refargs ::=", - /* 48 */ "refargs ::= refargs refarg", - /* 49 */ "refarg ::= MATCH nm", - /* 50 */ "refarg ::= ON INSERT refact", - /* 51 */ "refarg ::= ON DELETE refact", - /* 52 */ "refarg ::= ON UPDATE refact", - /* 53 */ "refact ::= SET NULL", - /* 54 */ "refact ::= SET DEFAULT", - /* 55 */ "refact ::= CASCADE", - /* 56 */ "refact ::= RESTRICT", - /* 57 */ "refact ::= NO ACTION", - /* 58 */ "defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt", - /* 59 */ "defer_subclause ::= DEFERRABLE init_deferred_pred_opt", - /* 60 */ "init_deferred_pred_opt ::=", - /* 61 */ "init_deferred_pred_opt ::= INITIALLY DEFERRED", - /* 62 */ "init_deferred_pred_opt ::= INITIALLY IMMEDIATE", - /* 63 */ "conslist_opt ::=", - /* 64 */ "tconscomma ::= COMMA", - /* 65 */ "tcons ::= CONSTRAINT nm", - /* 66 */ "tcons ::= PRIMARY KEY LP sortlist autoinc RP onconf", - /* 67 */ "tcons ::= UNIQUE LP sortlist RP onconf", - /* 68 */ "tcons ::= CHECK LP expr RP onconf", - /* 69 */ "tcons ::= FOREIGN KEY LP eidlist RP REFERENCES nm eidlist_opt refargs defer_subclause_opt", - /* 70 */ "defer_subclause_opt ::=", - /* 71 */ "onconf ::=", - /* 72 */ "onconf ::= ON CONFLICT resolvetype", - /* 73 */ "orconf ::=", - /* 74 */ "orconf ::= OR resolvetype", - /* 75 */ "resolvetype ::= IGNORE", - /* 76 */ "resolvetype ::= REPLACE", - /* 77 */ "cmd ::= DROP TABLE ifexists fullname", - /* 78 */ "ifexists ::= IF EXISTS", - /* 79 */ "ifexists ::=", - /* 80 */ "cmd ::= createkw temp VIEW ifnotexists nm dbnm eidlist_opt AS select", - /* 81 */ "cmd ::= DROP VIEW ifexists fullname", - /* 82 */ "cmd ::= select", - /* 83 */ "select ::= WITH wqlist selectnowith", - /* 84 */ "select ::= WITH RECURSIVE wqlist selectnowith", - /* 85 */ "select ::= selectnowith", - /* 86 */ "selectnowith ::= selectnowith multiselect_op oneselect", - /* 87 */ "multiselect_op ::= UNION", - /* 88 */ "multiselect_op ::= UNION ALL", - /* 89 */ "multiselect_op ::= EXCEPT|INTERSECT", - /* 90 */ "oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt", - /* 91 */ "oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt window_clause orderby_opt limit_opt", - /* 92 */ "values ::= VALUES LP nexprlist RP", - /* 93 */ "values ::= values COMMA LP nexprlist RP", - /* 94 */ "distinct ::= DISTINCT", - /* 95 */ "distinct ::= ALL", - /* 96 */ "distinct ::=", - /* 97 */ "sclp ::=", - /* 98 */ "selcollist ::= sclp scanpt expr scanpt as", - /* 99 */ "selcollist ::= sclp scanpt STAR", - /* 100 */ "selcollist ::= sclp scanpt nm DOT STAR", - /* 101 */ "as ::= AS nm", - /* 102 */ "as ::=", - /* 103 */ "from ::=", - /* 104 */ "from ::= FROM seltablist", - /* 105 */ "stl_prefix ::= seltablist joinop", - /* 106 */ "stl_prefix ::=", - /* 107 */ "seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt", - /* 108 */ "seltablist ::= stl_prefix nm dbnm LP exprlist RP as on_opt using_opt", - /* 109 */ "seltablist ::= stl_prefix LP select RP as on_opt using_opt", - /* 110 */ "seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt", - /* 111 */ "dbnm ::=", - /* 112 */ "dbnm ::= DOT nm", - /* 113 */ "fullname ::= nm", - /* 114 */ "fullname ::= nm DOT nm", - /* 115 */ "xfullname ::= nm", - /* 116 */ "xfullname ::= nm DOT nm", - /* 117 */ "xfullname ::= nm DOT nm AS nm", - /* 118 */ "xfullname ::= nm AS nm", - /* 119 */ "joinop ::= COMMA|JOIN", - /* 120 */ "joinop ::= JOIN_KW JOIN", - /* 121 */ "joinop ::= JOIN_KW nm JOIN", - /* 122 */ "joinop ::= JOIN_KW nm nm JOIN", - /* 123 */ "on_opt ::= ON expr", - /* 124 */ "on_opt ::=", - /* 125 */ "indexed_opt ::=", - /* 126 */ "indexed_opt ::= INDEXED BY nm", - /* 127 */ "indexed_opt ::= NOT INDEXED", - /* 128 */ "using_opt ::= USING LP idlist RP", - /* 129 */ "using_opt ::=", - /* 130 */ "orderby_opt ::=", - /* 131 */ "orderby_opt ::= ORDER BY sortlist", - /* 132 */ "sortlist ::= sortlist COMMA expr sortorder nulls", - /* 133 */ "sortlist ::= expr sortorder nulls", - /* 134 */ "sortorder ::= ASC", - /* 135 */ "sortorder ::= DESC", - /* 136 */ "sortorder ::=", - /* 137 */ "nulls ::= NULLS FIRST", - /* 138 */ "nulls ::= NULLS LAST", - /* 139 */ "nulls ::=", - /* 140 */ "groupby_opt ::=", - /* 141 */ "groupby_opt ::= GROUP BY nexprlist", - /* 142 */ "having_opt ::=", - /* 143 */ "having_opt ::= HAVING expr", - /* 144 */ "limit_opt ::=", - /* 145 */ "limit_opt ::= LIMIT expr", - /* 146 */ "limit_opt ::= LIMIT expr OFFSET expr", - /* 147 */ "limit_opt ::= LIMIT expr COMMA expr", - /* 148 */ "cmd ::= with DELETE FROM xfullname indexed_opt where_opt", - /* 149 */ "where_opt ::=", - /* 150 */ "where_opt ::= WHERE expr", - /* 151 */ "cmd ::= with UPDATE orconf xfullname indexed_opt SET setlist where_opt", - /* 152 */ "setlist ::= setlist COMMA nm EQ expr", - /* 153 */ "setlist ::= setlist COMMA LP idlist RP EQ expr", - /* 154 */ "setlist ::= nm EQ expr", - /* 155 */ "setlist ::= LP idlist RP EQ expr", - /* 156 */ "cmd ::= with insert_cmd INTO xfullname idlist_opt select upsert", - /* 157 */ "cmd ::= with insert_cmd INTO xfullname idlist_opt DEFAULT VALUES", - /* 158 */ "upsert ::=", - /* 159 */ "upsert ::= ON CONFLICT LP sortlist RP where_opt DO UPDATE SET setlist where_opt", - /* 160 */ "upsert ::= ON CONFLICT LP sortlist RP where_opt DO NOTHING", - /* 161 */ "upsert ::= ON CONFLICT DO NOTHING", - /* 162 */ "insert_cmd ::= INSERT orconf", - /* 163 */ "insert_cmd ::= REPLACE", - /* 164 */ "idlist_opt ::=", - /* 165 */ "idlist_opt ::= LP idlist RP", - /* 166 */ "idlist ::= idlist COMMA nm", - /* 167 */ "idlist ::= nm", - /* 168 */ "expr ::= LP expr RP", - /* 169 */ "expr ::= ID|INDEXED", - /* 170 */ "expr ::= JOIN_KW", - /* 171 */ "expr ::= nm DOT nm", - /* 172 */ "expr ::= nm DOT nm DOT nm", - /* 173 */ "term ::= NULL|FLOAT|BLOB", - /* 174 */ "term ::= STRING", - /* 175 */ "term ::= INTEGER", - /* 176 */ "expr ::= VARIABLE", - /* 177 */ "expr ::= expr COLLATE ID|STRING", - /* 178 */ "expr ::= CAST LP expr AS typetoken RP", - /* 179 */ "expr ::= ID|INDEXED LP distinct exprlist RP", - /* 180 */ "expr ::= ID|INDEXED LP STAR RP", - /* 181 */ "expr ::= ID|INDEXED LP distinct exprlist RP filter_over", - /* 182 */ "expr ::= ID|INDEXED LP STAR RP filter_over", - /* 183 */ "term ::= CTIME_KW", - /* 184 */ "expr ::= LP nexprlist COMMA expr RP", - /* 185 */ "expr ::= expr AND expr", - /* 186 */ "expr ::= expr OR expr", - /* 187 */ "expr ::= expr LT|GT|GE|LE expr", - /* 188 */ "expr ::= expr EQ|NE expr", - /* 189 */ "expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr", - /* 190 */ "expr ::= expr PLUS|MINUS expr", - /* 191 */ "expr ::= expr STAR|SLASH|REM expr", - /* 192 */ "expr ::= expr CONCAT expr", - /* 193 */ "likeop ::= NOT LIKE_KW|MATCH", - /* 194 */ "expr ::= expr likeop expr", - /* 195 */ "expr ::= expr likeop expr ESCAPE expr", - /* 196 */ "expr ::= expr ISNULL|NOTNULL", - /* 197 */ "expr ::= expr NOT NULL", - /* 198 */ "expr ::= expr IS expr", - /* 199 */ "expr ::= expr IS NOT expr", - /* 200 */ "expr ::= NOT expr", - /* 201 */ "expr ::= BITNOT expr", - /* 202 */ "expr ::= PLUS|MINUS expr", - /* 203 */ "between_op ::= BETWEEN", - /* 204 */ "between_op ::= NOT BETWEEN", - /* 205 */ "expr ::= expr between_op expr AND expr", - /* 206 */ "in_op ::= IN", - /* 207 */ "in_op ::= NOT IN", - /* 208 */ "expr ::= expr in_op LP exprlist RP", - /* 209 */ "expr ::= LP select RP", - /* 210 */ "expr ::= expr in_op LP select RP", - /* 211 */ "expr ::= expr in_op nm dbnm paren_exprlist", - /* 212 */ "expr ::= EXISTS LP select RP", - /* 213 */ "expr ::= CASE case_operand case_exprlist case_else END", - /* 214 */ "case_exprlist ::= case_exprlist WHEN expr THEN expr", - /* 215 */ "case_exprlist ::= WHEN expr THEN expr", - /* 216 */ "case_else ::= ELSE expr", - /* 217 */ "case_else ::=", - /* 218 */ "case_operand ::= expr", - /* 219 */ "case_operand ::=", - /* 220 */ "exprlist ::=", - /* 221 */ "nexprlist ::= nexprlist COMMA expr", - /* 222 */ "nexprlist ::= expr", - /* 223 */ "paren_exprlist ::=", - /* 224 */ "paren_exprlist ::= LP exprlist RP", - /* 225 */ "cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt", - /* 226 */ "uniqueflag ::= UNIQUE", - /* 227 */ "uniqueflag ::=", - /* 228 */ "eidlist_opt ::=", - /* 229 */ "eidlist_opt ::= LP eidlist RP", - /* 230 */ "eidlist ::= eidlist COMMA nm collate sortorder", - /* 231 */ "eidlist ::= nm collate sortorder", - /* 232 */ "collate ::=", - /* 233 */ "collate ::= COLLATE ID|STRING", - /* 234 */ "cmd ::= DROP INDEX ifexists fullname", - /* 235 */ "cmd ::= VACUUM vinto", - /* 236 */ "cmd ::= VACUUM nm vinto", - /* 237 */ "vinto ::= INTO expr", - /* 238 */ "vinto ::=", - /* 239 */ "cmd ::= PRAGMA nm dbnm", - /* 240 */ "cmd ::= PRAGMA nm dbnm EQ nmnum", - /* 241 */ "cmd ::= PRAGMA nm dbnm LP nmnum RP", - /* 242 */ "cmd ::= PRAGMA nm dbnm EQ minus_num", - /* 243 */ "cmd ::= PRAGMA nm dbnm LP minus_num RP", - /* 244 */ "plus_num ::= PLUS INTEGER|FLOAT", - /* 245 */ "minus_num ::= MINUS INTEGER|FLOAT", - /* 246 */ "cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END", - /* 247 */ "trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause", - /* 248 */ "trigger_time ::= BEFORE|AFTER", - /* 249 */ "trigger_time ::= INSTEAD OF", - /* 250 */ "trigger_time ::=", - /* 251 */ "trigger_event ::= DELETE|INSERT", - /* 252 */ "trigger_event ::= UPDATE", - /* 253 */ "trigger_event ::= UPDATE OF idlist", - /* 254 */ "when_clause ::=", - /* 255 */ "when_clause ::= WHEN expr", - /* 256 */ "trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI", - /* 257 */ "trigger_cmd_list ::= trigger_cmd SEMI", - /* 258 */ "trnm ::= nm DOT nm", - /* 259 */ "tridxby ::= INDEXED BY nm", - /* 260 */ "tridxby ::= NOT INDEXED", - /* 261 */ "trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt scanpt", - /* 262 */ "trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt", - /* 263 */ "trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt", - /* 264 */ "trigger_cmd ::= scanpt select scanpt", - /* 265 */ "expr ::= RAISE LP IGNORE RP", - /* 266 */ "expr ::= RAISE LP raisetype COMMA nm RP", - /* 267 */ "raisetype ::= ROLLBACK", - /* 268 */ "raisetype ::= ABORT", - /* 269 */ "raisetype ::= FAIL", - /* 270 */ "cmd ::= DROP TRIGGER ifexists fullname", - /* 271 */ "cmd ::= ATTACH database_kw_opt expr AS expr key_opt", - /* 272 */ "cmd ::= DETACH database_kw_opt expr", - /* 273 */ "key_opt ::=", - /* 274 */ "key_opt ::= KEY expr", - /* 275 */ "cmd ::= REINDEX", - /* 276 */ "cmd ::= REINDEX nm dbnm", - /* 277 */ "cmd ::= ANALYZE", - /* 278 */ "cmd ::= ANALYZE nm dbnm", - /* 279 */ "cmd ::= ALTER TABLE fullname RENAME TO nm", - /* 280 */ "cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist", - /* 281 */ "add_column_fullname ::= fullname", - /* 282 */ "cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm", - /* 283 */ "cmd ::= create_vtab", - /* 284 */ "cmd ::= create_vtab LP vtabarglist RP", - /* 285 */ "create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm", - /* 286 */ "vtabarg ::=", - /* 287 */ "vtabargtoken ::= ANY", - /* 288 */ "vtabargtoken ::= lp anylist RP", - /* 289 */ "lp ::= LP", - /* 290 */ "with ::= WITH wqlist", - /* 291 */ "with ::= WITH RECURSIVE wqlist", - /* 292 */ "wqlist ::= nm eidlist_opt AS LP select RP", - /* 293 */ "wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP", - /* 294 */ "windowdefn_list ::= windowdefn", - /* 295 */ "windowdefn_list ::= windowdefn_list COMMA windowdefn", - /* 296 */ "windowdefn ::= nm AS LP window RP", - /* 297 */ "window ::= PARTITION BY nexprlist orderby_opt frame_opt", - /* 298 */ "window ::= nm PARTITION BY nexprlist orderby_opt frame_opt", - /* 299 */ "window ::= ORDER BY sortlist frame_opt", - /* 300 */ "window ::= nm ORDER BY sortlist frame_opt", - /* 301 */ "window ::= frame_opt", - /* 302 */ "window ::= nm frame_opt", - /* 303 */ "frame_opt ::=", - /* 304 */ "frame_opt ::= range_or_rows frame_bound_s frame_exclude_opt", - /* 305 */ "frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e frame_exclude_opt", - /* 306 */ "range_or_rows ::= RANGE|ROWS|GROUPS", - /* 307 */ "frame_bound_s ::= frame_bound", - /* 308 */ "frame_bound_s ::= UNBOUNDED PRECEDING", - /* 309 */ "frame_bound_e ::= frame_bound", - /* 310 */ "frame_bound_e ::= UNBOUNDED FOLLOWING", - /* 311 */ "frame_bound ::= expr PRECEDING|FOLLOWING", - /* 312 */ "frame_bound ::= CURRENT ROW", - /* 313 */ "frame_exclude_opt ::=", - /* 314 */ "frame_exclude_opt ::= EXCLUDE frame_exclude", - /* 315 */ "frame_exclude ::= NO OTHERS", - /* 316 */ "frame_exclude ::= CURRENT ROW", - /* 317 */ "frame_exclude ::= GROUP|TIES", - /* 318 */ "window_clause ::= WINDOW windowdefn_list", - /* 319 */ "filter_over ::= filter_clause over_clause", - /* 320 */ "filter_over ::= over_clause", - /* 321 */ "filter_over ::= filter_clause", - /* 322 */ "over_clause ::= OVER LP window RP", - /* 323 */ "over_clause ::= OVER nm", - /* 324 */ "filter_clause ::= FILTER LP WHERE expr RP", - /* 325 */ "input ::= cmdlist", - /* 326 */ "cmdlist ::= cmdlist ecmd", - /* 327 */ "cmdlist ::= ecmd", - /* 328 */ "ecmd ::= SEMI", - /* 329 */ "ecmd ::= cmdx SEMI", - /* 330 */ "ecmd ::= explain cmdx SEMI", - /* 331 */ "trans_opt ::=", - /* 332 */ "trans_opt ::= TRANSACTION", - /* 333 */ "trans_opt ::= TRANSACTION nm", - /* 334 */ "savepoint_opt ::= SAVEPOINT", - /* 335 */ "savepoint_opt ::=", - /* 336 */ "cmd ::= create_table create_table_args", - /* 337 */ "columnlist ::= columnlist COMMA columnname carglist", - /* 338 */ "columnlist ::= columnname carglist", - /* 339 */ "nm ::= ID|INDEXED", - /* 340 */ "nm ::= STRING", - /* 341 */ "nm ::= JOIN_KW", - /* 342 */ "typetoken ::= typename", - /* 343 */ "typename ::= ID|STRING", - /* 344 */ "signed ::= plus_num", - /* 345 */ "signed ::= minus_num", - /* 346 */ "carglist ::= carglist ccons", - /* 347 */ "carglist ::=", - /* 348 */ "ccons ::= NULL onconf", - /* 349 */ "ccons ::= GENERATED ALWAYS AS generated", - /* 350 */ "ccons ::= AS generated", - /* 351 */ "conslist_opt ::= COMMA conslist", - /* 352 */ "conslist ::= conslist tconscomma tcons", - /* 353 */ "conslist ::= tcons", - /* 354 */ "tconscomma ::=", - /* 355 */ "defer_subclause_opt ::= defer_subclause", - /* 356 */ "resolvetype ::= raisetype", - /* 357 */ "selectnowith ::= oneselect", - /* 358 */ "oneselect ::= values", - /* 359 */ "sclp ::= selcollist COMMA", - /* 360 */ "as ::= ID|STRING", - /* 361 */ "expr ::= term", - /* 362 */ "likeop ::= LIKE_KW|MATCH", - /* 363 */ "exprlist ::= nexprlist", - /* 364 */ "nmnum ::= plus_num", - /* 365 */ "nmnum ::= nm", - /* 366 */ "nmnum ::= ON", - /* 367 */ "nmnum ::= DELETE", - /* 368 */ "nmnum ::= DEFAULT", - /* 369 */ "plus_num ::= INTEGER|FLOAT", - /* 370 */ "foreach_clause ::=", - /* 371 */ "foreach_clause ::= FOR EACH ROW", - /* 372 */ "trnm ::= nm", - /* 373 */ "tridxby ::=", - /* 374 */ "database_kw_opt ::= DATABASE", - /* 375 */ "database_kw_opt ::=", - /* 376 */ "kwcolumn_opt ::=", - /* 377 */ "kwcolumn_opt ::= COLUMNKW", - /* 378 */ "vtabarglist ::= vtabarg", - /* 379 */ "vtabarglist ::= vtabarglist COMMA vtabarg", - /* 380 */ "vtabarg ::= vtabarg vtabargtoken", - /* 381 */ "anylist ::=", - /* 382 */ "anylist ::= anylist LP anylist RP", - /* 383 */ "anylist ::= anylist ANY", - /* 384 */ "with ::=", + /* 43 */ "autoinc ::=", + /* 44 */ "autoinc ::= AUTOINCR", + /* 45 */ "refargs ::=", + /* 46 */ "refargs ::= refargs refarg", + /* 47 */ "refarg ::= MATCH nm", + /* 48 */ "refarg ::= ON INSERT refact", + /* 49 */ "refarg ::= ON DELETE refact", + /* 50 */ "refarg ::= ON UPDATE refact", + /* 51 */ "refact ::= SET NULL", + /* 52 */ "refact ::= SET DEFAULT", + /* 53 */ "refact ::= CASCADE", + /* 54 */ "refact ::= RESTRICT", + /* 55 */ "refact ::= NO ACTION", + /* 56 */ "defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt", + /* 57 */ "defer_subclause ::= DEFERRABLE init_deferred_pred_opt", + /* 58 */ "init_deferred_pred_opt ::=", + /* 59 */ "init_deferred_pred_opt ::= INITIALLY DEFERRED", + /* 60 */ "init_deferred_pred_opt ::= INITIALLY IMMEDIATE", + /* 61 */ "conslist_opt ::=", + /* 62 */ "tconscomma ::= COMMA", + /* 63 */ "tcons ::= CONSTRAINT nm", + /* 64 */ "tcons ::= PRIMARY KEY LP sortlist autoinc RP onconf", + /* 65 */ "tcons ::= UNIQUE LP sortlist RP onconf", + /* 66 */ "tcons ::= CHECK LP expr RP onconf", + /* 67 */ "tcons ::= FOREIGN KEY LP eidlist RP REFERENCES nm eidlist_opt refargs defer_subclause_opt", + /* 68 */ "defer_subclause_opt ::=", + /* 69 */ "onconf ::=", + /* 70 */ "onconf ::= ON CONFLICT resolvetype", + /* 71 */ "orconf ::=", + /* 72 */ "orconf ::= OR resolvetype", + /* 73 */ "resolvetype ::= IGNORE", + /* 74 */ "resolvetype ::= REPLACE", + /* 75 */ "cmd ::= DROP TABLE ifexists fullname", + /* 76 */ "ifexists ::= IF EXISTS", + /* 77 */ "ifexists ::=", + /* 78 */ "cmd ::= createkw temp VIEW ifnotexists nm dbnm eidlist_opt AS select", + /* 79 */ "cmd ::= DROP VIEW ifexists fullname", + /* 80 */ "cmd ::= select", + /* 81 */ "select ::= WITH wqlist selectnowith", + /* 82 */ "select ::= WITH RECURSIVE wqlist selectnowith", + /* 83 */ "select ::= selectnowith", + /* 84 */ "selectnowith ::= selectnowith multiselect_op oneselect", + /* 85 */ "multiselect_op ::= UNION", + /* 86 */ "multiselect_op ::= UNION ALL", + /* 87 */ "multiselect_op ::= EXCEPT|INTERSECT", + /* 88 */ "oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt", + /* 89 */ "oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt window_clause orderby_opt limit_opt", + /* 90 */ "values ::= VALUES LP nexprlist RP", + /* 91 */ "values ::= values COMMA LP nexprlist RP", + /* 92 */ "distinct ::= DISTINCT", + /* 93 */ "distinct ::= ALL", + /* 94 */ "distinct ::=", + /* 95 */ "sclp ::=", + /* 96 */ "selcollist ::= sclp scanpt expr scanpt as", + /* 97 */ "selcollist ::= sclp scanpt STAR", + /* 98 */ "selcollist ::= sclp scanpt nm DOT STAR", + /* 99 */ "as ::= AS nm", + /* 100 */ "as ::=", + /* 101 */ "from ::=", + /* 102 */ "from ::= FROM seltablist", + /* 103 */ "stl_prefix ::= seltablist joinop", + /* 104 */ "stl_prefix ::=", + /* 105 */ "seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt", + /* 106 */ "seltablist ::= stl_prefix nm dbnm LP exprlist RP as on_opt using_opt", + /* 107 */ "seltablist ::= stl_prefix LP select RP as on_opt using_opt", + /* 108 */ "seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt", + /* 109 */ "dbnm ::=", + /* 110 */ "dbnm ::= DOT nm", + /* 111 */ "fullname ::= nm", + /* 112 */ "fullname ::= nm DOT nm", + /* 113 */ "xfullname ::= nm", + /* 114 */ "xfullname ::= nm DOT nm", + /* 115 */ "xfullname ::= nm DOT nm AS nm", + /* 116 */ "xfullname ::= nm AS nm", + /* 117 */ "joinop ::= COMMA|JOIN", + /* 118 */ "joinop ::= JOIN_KW JOIN", + /* 119 */ "joinop ::= JOIN_KW nm JOIN", + /* 120 */ "joinop ::= JOIN_KW nm nm JOIN", + /* 121 */ "on_opt ::= ON expr", + /* 122 */ "on_opt ::=", + /* 123 */ "indexed_opt ::=", + /* 124 */ "indexed_opt ::= INDEXED BY nm", + /* 125 */ "indexed_opt ::= NOT INDEXED", + /* 126 */ "using_opt ::= USING LP idlist RP", + /* 127 */ "using_opt ::=", + /* 128 */ "orderby_opt ::=", + /* 129 */ "orderby_opt ::= ORDER BY sortlist", + /* 130 */ "sortlist ::= sortlist COMMA expr sortorder nulls", + /* 131 */ "sortlist ::= expr sortorder nulls", + /* 132 */ "sortorder ::= ASC", + /* 133 */ "sortorder ::= DESC", + /* 134 */ "sortorder ::=", + /* 135 */ "nulls ::= NULLS FIRST", + /* 136 */ "nulls ::= NULLS LAST", + /* 137 */ "nulls ::=", + /* 138 */ "groupby_opt ::=", + /* 139 */ "groupby_opt ::= GROUP BY nexprlist", + /* 140 */ "having_opt ::=", + /* 141 */ "having_opt ::= HAVING expr", + /* 142 */ "limit_opt ::=", + /* 143 */ "limit_opt ::= LIMIT expr", + /* 144 */ "limit_opt ::= LIMIT expr OFFSET expr", + /* 145 */ "limit_opt ::= LIMIT expr COMMA expr", + /* 146 */ "cmd ::= with DELETE FROM xfullname indexed_opt where_opt", + /* 147 */ "where_opt ::=", + /* 148 */ "where_opt ::= WHERE expr", + /* 149 */ "cmd ::= with UPDATE orconf xfullname indexed_opt SET setlist where_opt", + /* 150 */ "setlist ::= setlist COMMA nm EQ expr", + /* 151 */ "setlist ::= setlist COMMA LP idlist RP EQ expr", + /* 152 */ "setlist ::= nm EQ expr", + /* 153 */ "setlist ::= LP idlist RP EQ expr", + /* 154 */ "cmd ::= with insert_cmd INTO xfullname idlist_opt select upsert", + /* 155 */ "cmd ::= with insert_cmd INTO xfullname idlist_opt DEFAULT VALUES", + /* 156 */ "upsert ::=", + /* 157 */ "upsert ::= ON CONFLICT LP sortlist RP where_opt DO UPDATE SET setlist where_opt", + /* 158 */ "upsert ::= ON CONFLICT LP sortlist RP where_opt DO NOTHING", + /* 159 */ "upsert ::= ON CONFLICT DO NOTHING", + /* 160 */ "insert_cmd ::= INSERT orconf", + /* 161 */ "insert_cmd ::= REPLACE", + /* 162 */ "idlist_opt ::=", + /* 163 */ "idlist_opt ::= LP idlist RP", + /* 164 */ "idlist ::= idlist COMMA nm", + /* 165 */ "idlist ::= nm", + /* 166 */ "expr ::= LP expr RP", + /* 167 */ "expr ::= ID|INDEXED", + /* 168 */ "expr ::= JOIN_KW", + /* 169 */ "expr ::= nm DOT nm", + /* 170 */ "expr ::= nm DOT nm DOT nm", + /* 171 */ "term ::= NULL|FLOAT|BLOB", + /* 172 */ "term ::= STRING", + /* 173 */ "term ::= INTEGER", + /* 174 */ "expr ::= VARIABLE", + /* 175 */ "expr ::= expr COLLATE ID|STRING", + /* 176 */ "expr ::= CAST LP expr AS typetoken RP", + /* 177 */ "expr ::= ID|INDEXED LP distinct exprlist RP", + /* 178 */ "expr ::= ID|INDEXED LP STAR RP", + /* 179 */ "expr ::= ID|INDEXED LP distinct exprlist RP filter_over", + /* 180 */ "expr ::= ID|INDEXED LP STAR RP filter_over", + /* 181 */ "term ::= CTIME_KW", + /* 182 */ "expr ::= LP nexprlist COMMA expr RP", + /* 183 */ "expr ::= expr AND expr", + /* 184 */ "expr ::= expr OR expr", + /* 185 */ "expr ::= expr LT|GT|GE|LE expr", + /* 186 */ "expr ::= expr EQ|NE expr", + /* 187 */ "expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr", + /* 188 */ "expr ::= expr PLUS|MINUS expr", + /* 189 */ "expr ::= expr STAR|SLASH|REM expr", + /* 190 */ "expr ::= expr CONCAT expr", + /* 191 */ "likeop ::= NOT LIKE_KW|MATCH", + /* 192 */ "expr ::= expr likeop expr", + /* 193 */ "expr ::= expr likeop expr ESCAPE expr", + /* 194 */ "expr ::= expr ISNULL|NOTNULL", + /* 195 */ "expr ::= expr NOT NULL", + /* 196 */ "expr ::= expr IS expr", + /* 197 */ "expr ::= expr IS NOT expr", + /* 198 */ "expr ::= NOT expr", + /* 199 */ "expr ::= BITNOT expr", + /* 200 */ "expr ::= PLUS|MINUS expr", + /* 201 */ "between_op ::= BETWEEN", + /* 202 */ "between_op ::= NOT BETWEEN", + /* 203 */ "expr ::= expr between_op expr AND expr", + /* 204 */ "in_op ::= IN", + /* 205 */ "in_op ::= NOT IN", + /* 206 */ "expr ::= expr in_op LP exprlist RP", + /* 207 */ "expr ::= LP select RP", + /* 208 */ "expr ::= expr in_op LP select RP", + /* 209 */ "expr ::= expr in_op nm dbnm paren_exprlist", + /* 210 */ "expr ::= EXISTS LP select RP", + /* 211 */ "expr ::= CASE case_operand case_exprlist case_else END", + /* 212 */ "case_exprlist ::= case_exprlist WHEN expr THEN expr", + /* 213 */ "case_exprlist ::= WHEN expr THEN expr", + /* 214 */ "case_else ::= ELSE expr", + /* 215 */ "case_else ::=", + /* 216 */ "case_operand ::= expr", + /* 217 */ "case_operand ::=", + /* 218 */ "exprlist ::=", + /* 219 */ "nexprlist ::= nexprlist COMMA expr", + /* 220 */ "nexprlist ::= expr", + /* 221 */ "paren_exprlist ::=", + /* 222 */ "paren_exprlist ::= LP exprlist RP", + /* 223 */ "cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt", + /* 224 */ "uniqueflag ::= UNIQUE", + /* 225 */ "uniqueflag ::=", + /* 226 */ "eidlist_opt ::=", + /* 227 */ "eidlist_opt ::= LP eidlist RP", + /* 228 */ "eidlist ::= eidlist COMMA nm collate sortorder", + /* 229 */ "eidlist ::= nm collate sortorder", + /* 230 */ "collate ::=", + /* 231 */ "collate ::= COLLATE ID|STRING", + /* 232 */ "cmd ::= DROP INDEX ifexists fullname", + /* 233 */ "cmd ::= VACUUM vinto", + /* 234 */ "cmd ::= VACUUM nm vinto", + /* 235 */ "vinto ::= INTO expr", + /* 236 */ "vinto ::=", + /* 237 */ "cmd ::= PRAGMA nm dbnm", + /* 238 */ "cmd ::= PRAGMA nm dbnm EQ nmnum", + /* 239 */ "cmd ::= PRAGMA nm dbnm LP nmnum RP", + /* 240 */ "cmd ::= PRAGMA nm dbnm EQ minus_num", + /* 241 */ "cmd ::= PRAGMA nm dbnm LP minus_num RP", + /* 242 */ "plus_num ::= PLUS INTEGER|FLOAT", + /* 243 */ "minus_num ::= MINUS INTEGER|FLOAT", + /* 244 */ "cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END", + /* 245 */ "trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause", + /* 246 */ "trigger_time ::= BEFORE|AFTER", + /* 247 */ "trigger_time ::= INSTEAD OF", + /* 248 */ "trigger_time ::=", + /* 249 */ "trigger_event ::= DELETE|INSERT", + /* 250 */ "trigger_event ::= UPDATE", + /* 251 */ "trigger_event ::= UPDATE OF idlist", + /* 252 */ "when_clause ::=", + /* 253 */ "when_clause ::= WHEN expr", + /* 254 */ "trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI", + /* 255 */ "trigger_cmd_list ::= trigger_cmd SEMI", + /* 256 */ "trnm ::= nm DOT nm", + /* 257 */ "tridxby ::= INDEXED BY nm", + /* 258 */ "tridxby ::= NOT INDEXED", + /* 259 */ "trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt scanpt", + /* 260 */ "trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt", + /* 261 */ "trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt", + /* 262 */ "trigger_cmd ::= scanpt select scanpt", + /* 263 */ "expr ::= RAISE LP IGNORE RP", + /* 264 */ "expr ::= RAISE LP raisetype COMMA nm RP", + /* 265 */ "raisetype ::= ROLLBACK", + /* 266 */ "raisetype ::= ABORT", + /* 267 */ "raisetype ::= FAIL", + /* 268 */ "cmd ::= DROP TRIGGER ifexists fullname", + /* 269 */ "cmd ::= ATTACH database_kw_opt expr AS expr key_opt", + /* 270 */ "cmd ::= DETACH database_kw_opt expr", + /* 271 */ "key_opt ::=", + /* 272 */ "key_opt ::= KEY expr", + /* 273 */ "cmd ::= REINDEX", + /* 274 */ "cmd ::= REINDEX nm dbnm", + /* 275 */ "cmd ::= ANALYZE", + /* 276 */ "cmd ::= ANALYZE nm dbnm", + /* 277 */ "cmd ::= ALTER TABLE fullname RENAME TO nm", + /* 278 */ "cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist", + /* 279 */ "add_column_fullname ::= fullname", + /* 280 */ "cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm", + /* 281 */ "cmd ::= create_vtab", + /* 282 */ "cmd ::= create_vtab LP vtabarglist RP", + /* 283 */ "create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm", + /* 284 */ "vtabarg ::=", + /* 285 */ "vtabargtoken ::= ANY", + /* 286 */ "vtabargtoken ::= lp anylist RP", + /* 287 */ "lp ::= LP", + /* 288 */ "with ::= WITH wqlist", + /* 289 */ "with ::= WITH RECURSIVE wqlist", + /* 290 */ "wqlist ::= nm eidlist_opt AS LP select RP", + /* 291 */ "wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP", + /* 292 */ "windowdefn_list ::= windowdefn", + /* 293 */ "windowdefn_list ::= windowdefn_list COMMA windowdefn", + /* 294 */ "windowdefn ::= nm AS LP window RP", + /* 295 */ "window ::= PARTITION BY nexprlist orderby_opt frame_opt", + /* 296 */ "window ::= nm PARTITION BY nexprlist orderby_opt frame_opt", + /* 297 */ "window ::= ORDER BY sortlist frame_opt", + /* 298 */ "window ::= nm ORDER BY sortlist frame_opt", + /* 299 */ "window ::= frame_opt", + /* 300 */ "window ::= nm frame_opt", + /* 301 */ "frame_opt ::=", + /* 302 */ "frame_opt ::= range_or_rows frame_bound_s frame_exclude_opt", + /* 303 */ "frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e frame_exclude_opt", + /* 304 */ "range_or_rows ::= RANGE|ROWS|GROUPS", + /* 305 */ "frame_bound_s ::= frame_bound", + /* 306 */ "frame_bound_s ::= UNBOUNDED PRECEDING", + /* 307 */ "frame_bound_e ::= frame_bound", + /* 308 */ "frame_bound_e ::= UNBOUNDED FOLLOWING", + /* 309 */ "frame_bound ::= expr PRECEDING|FOLLOWING", + /* 310 */ "frame_bound ::= CURRENT ROW", + /* 311 */ "frame_exclude_opt ::=", + /* 312 */ "frame_exclude_opt ::= EXCLUDE frame_exclude", + /* 313 */ "frame_exclude ::= NO OTHERS", + /* 314 */ "frame_exclude ::= CURRENT ROW", + /* 315 */ "frame_exclude ::= GROUP|TIES", + /* 316 */ "window_clause ::= WINDOW windowdefn_list", + /* 317 */ "filter_over ::= filter_clause over_clause", + /* 318 */ "filter_over ::= over_clause", + /* 319 */ "filter_over ::= filter_clause", + /* 320 */ "over_clause ::= OVER LP window RP", + /* 321 */ "over_clause ::= OVER nm", + /* 322 */ "filter_clause ::= FILTER LP WHERE expr RP", + /* 323 */ "input ::= cmdlist", + /* 324 */ "cmdlist ::= cmdlist ecmd", + /* 325 */ "cmdlist ::= ecmd", + /* 326 */ "ecmd ::= SEMI", + /* 327 */ "ecmd ::= cmdx SEMI", + /* 328 */ "ecmd ::= explain cmdx", + /* 329 */ "trans_opt ::=", + /* 330 */ "trans_opt ::= TRANSACTION", + /* 331 */ "trans_opt ::= TRANSACTION nm", + /* 332 */ "savepoint_opt ::= SAVEPOINT", + /* 333 */ "savepoint_opt ::=", + /* 334 */ "cmd ::= create_table create_table_args", + /* 335 */ "columnlist ::= columnlist COMMA columnname carglist", + /* 336 */ "columnlist ::= columnname carglist", + /* 337 */ "nm ::= ID|INDEXED", + /* 338 */ "nm ::= STRING", + /* 339 */ "nm ::= JOIN_KW", + /* 340 */ "typetoken ::= typename", + /* 341 */ "typename ::= ID|STRING", + /* 342 */ "signed ::= plus_num", + /* 343 */ "signed ::= minus_num", + /* 344 */ "carglist ::= carglist ccons", + /* 345 */ "carglist ::=", + /* 346 */ "ccons ::= NULL onconf", + /* 347 */ "conslist_opt ::= COMMA conslist", + /* 348 */ "conslist ::= conslist tconscomma tcons", + /* 349 */ "conslist ::= tcons", + /* 350 */ "tconscomma ::=", + /* 351 */ "defer_subclause_opt ::= defer_subclause", + /* 352 */ "resolvetype ::= raisetype", + /* 353 */ "selectnowith ::= oneselect", + /* 354 */ "oneselect ::= values", + /* 355 */ "sclp ::= selcollist COMMA", + /* 356 */ "as ::= ID|STRING", + /* 357 */ "expr ::= term", + /* 358 */ "likeop ::= LIKE_KW|MATCH", + /* 359 */ "exprlist ::= nexprlist", + /* 360 */ "nmnum ::= plus_num", + /* 361 */ "nmnum ::= nm", + /* 362 */ "nmnum ::= ON", + /* 363 */ "nmnum ::= DELETE", + /* 364 */ "nmnum ::= DEFAULT", + /* 365 */ "plus_num ::= INTEGER|FLOAT", + /* 366 */ "foreach_clause ::=", + /* 367 */ "foreach_clause ::= FOR EACH ROW", + /* 368 */ "trnm ::= nm", + /* 369 */ "tridxby ::=", + /* 370 */ "database_kw_opt ::= DATABASE", + /* 371 */ "database_kw_opt ::=", + /* 372 */ "kwcolumn_opt ::=", + /* 373 */ "kwcolumn_opt ::= COLUMNKW", + /* 374 */ "vtabarglist ::= vtabarg", + /* 375 */ "vtabarglist ::= vtabarglist COMMA vtabarg", + /* 376 */ "vtabarg ::= vtabarg vtabargtoken", + /* 377 */ "anylist ::=", + /* 378 */ "anylist ::= anylist LP anylist RP", + /* 379 */ "anylist ::= anylist ANY", + /* 380 */ "with ::=", }; #endif /* NDEBUG */ @@ -154341,98 +151696,98 @@ static void yy_destructor( ** inside the C code. */ /********* Begin destructor definitions ***************************************/ - case 200: /* select */ - case 234: /* selectnowith */ - case 235: /* oneselect */ - case 247: /* values */ + case 198: /* select */ + case 231: /* selectnowith */ + case 232: /* oneselect */ + case 244: /* values */ { -sqlite3SelectDelete(pParse->db, (yypminor->yy539)); +sqlite3SelectDelete(pParse->db, (yypminor->yy25)); } break; - case 211: /* term */ - case 212: /* expr */ - case 241: /* where_opt */ - case 243: /* having_opt */ - case 255: /* on_opt */ - case 271: /* case_operand */ - case 273: /* case_else */ - case 276: /* vinto */ - case 283: /* when_clause */ - case 288: /* key_opt */ - case 302: /* filter_clause */ + case 209: /* term */ + case 210: /* expr */ + case 238: /* where_opt */ + case 240: /* having_opt */ + case 252: /* on_opt */ + case 268: /* case_operand */ + case 270: /* case_else */ + case 273: /* vinto */ + case 280: /* when_clause */ + case 285: /* key_opt */ + case 299: /* filter_clause */ { -sqlite3ExprDelete(pParse->db, (yypminor->yy202)); +sqlite3ExprDelete(pParse->db, (yypminor->yy46)); } break; - case 216: /* eidlist_opt */ - case 226: /* sortlist */ - case 227: /* eidlist */ - case 239: /* selcollist */ - case 242: /* groupby_opt */ - case 244: /* orderby_opt */ - case 248: /* nexprlist */ - case 249: /* sclp */ - case 257: /* exprlist */ - case 262: /* setlist */ - case 270: /* paren_exprlist */ - case 272: /* case_exprlist */ - case 301: /* part_opt */ + case 214: /* eidlist_opt */ + case 223: /* sortlist */ + case 224: /* eidlist */ + case 236: /* selcollist */ + case 239: /* groupby_opt */ + case 241: /* orderby_opt */ + case 245: /* nexprlist */ + case 246: /* sclp */ + case 254: /* exprlist */ + case 259: /* setlist */ + case 267: /* paren_exprlist */ + case 269: /* case_exprlist */ + case 298: /* part_opt */ { -sqlite3ExprListDelete(pParse->db, (yypminor->yy242)); +sqlite3ExprListDelete(pParse->db, (yypminor->yy138)); } break; - case 233: /* fullname */ - case 240: /* from */ - case 251: /* seltablist */ - case 252: /* stl_prefix */ - case 258: /* xfullname */ + case 230: /* fullname */ + case 237: /* from */ + case 248: /* seltablist */ + case 249: /* stl_prefix */ + case 255: /* xfullname */ { -sqlite3SrcListDelete(pParse->db, (yypminor->yy47)); +sqlite3SrcListDelete(pParse->db, (yypminor->yy609)); } break; - case 236: /* wqlist */ + case 233: /* wqlist */ { -sqlite3WithDelete(pParse->db, (yypminor->yy131)); +sqlite3WithDelete(pParse->db, (yypminor->yy297)); } break; - case 246: /* window_clause */ - case 297: /* windowdefn_list */ + case 243: /* window_clause */ + case 294: /* windowdefn_list */ { -sqlite3WindowListDelete(pParse->db, (yypminor->yy303)); +sqlite3WindowListDelete(pParse->db, (yypminor->yy455)); } break; - case 256: /* using_opt */ - case 259: /* idlist */ - case 264: /* idlist_opt */ + case 253: /* using_opt */ + case 256: /* idlist */ + case 261: /* idlist_opt */ { -sqlite3IdListDelete(pParse->db, (yypminor->yy600)); +sqlite3IdListDelete(pParse->db, (yypminor->yy406)); } break; - case 266: /* filter_over */ - case 298: /* windowdefn */ - case 299: /* window */ - case 300: /* frame_opt */ - case 303: /* over_clause */ + case 263: /* filter_over */ + case 295: /* windowdefn */ + case 296: /* window */ + case 297: /* frame_opt */ + case 300: /* over_clause */ { -sqlite3WindowDelete(pParse->db, (yypminor->yy303)); +sqlite3WindowDelete(pParse->db, (yypminor->yy455)); } break; - case 279: /* trigger_cmd_list */ - case 284: /* trigger_cmd */ + case 276: /* trigger_cmd_list */ + case 281: /* trigger_cmd */ { -sqlite3DeleteTriggerStep(pParse->db, (yypminor->yy447)); +sqlite3DeleteTriggerStep(pParse->db, (yypminor->yy527)); } break; - case 281: /* trigger_event */ + case 278: /* trigger_event */ { -sqlite3IdListDelete(pParse->db, (yypminor->yy230).b); +sqlite3IdListDelete(pParse->db, (yypminor->yy572).b); } break; - case 305: /* frame_bound */ - case 306: /* frame_bound_s */ - case 307: /* frame_bound_e */ + case 302: /* frame_bound */ + case 303: /* frame_bound_s */ + case 304: /* frame_bound_e */ { -sqlite3ExprDelete(pParse->db, (yypminor->yy77).pExpr); +sqlite3ExprDelete(pParse->db, (yypminor->yy57).pExpr); } break; /********* End destructor definitions *****************************************/ @@ -154723,391 +152078,387 @@ static void yy_shift( /* For rule J, yyRuleInfoLhs[J] contains the symbol on the left-hand side ** of that rule */ static const YYCODETYPE yyRuleInfoLhs[] = { - 185, /* (0) explain ::= EXPLAIN */ - 185, /* (1) explain ::= EXPLAIN QUERY PLAN */ - 184, /* (2) cmdx ::= cmd */ - 186, /* (3) cmd ::= BEGIN transtype trans_opt */ - 187, /* (4) transtype ::= */ - 187, /* (5) transtype ::= DEFERRED */ - 187, /* (6) transtype ::= IMMEDIATE */ - 187, /* (7) transtype ::= EXCLUSIVE */ - 186, /* (8) cmd ::= COMMIT|END trans_opt */ - 186, /* (9) cmd ::= ROLLBACK trans_opt */ - 186, /* (10) cmd ::= SAVEPOINT nm */ - 186, /* (11) cmd ::= RELEASE savepoint_opt nm */ - 186, /* (12) cmd ::= ROLLBACK trans_opt TO savepoint_opt nm */ - 191, /* (13) create_table ::= createkw temp TABLE ifnotexists nm dbnm */ - 193, /* (14) createkw ::= CREATE */ - 195, /* (15) ifnotexists ::= */ - 195, /* (16) ifnotexists ::= IF NOT EXISTS */ - 194, /* (17) temp ::= TEMP */ - 194, /* (18) temp ::= */ - 192, /* (19) create_table_args ::= LP columnlist conslist_opt RP table_options */ - 192, /* (20) create_table_args ::= AS select */ - 199, /* (21) table_options ::= */ - 199, /* (22) table_options ::= WITHOUT nm */ - 201, /* (23) columnname ::= nm typetoken */ - 203, /* (24) typetoken ::= */ - 203, /* (25) typetoken ::= typename LP signed RP */ - 203, /* (26) typetoken ::= typename LP signed COMMA signed RP */ - 204, /* (27) typename ::= typename ID|STRING */ - 208, /* (28) scanpt ::= */ - 209, /* (29) scantok ::= */ - 210, /* (30) ccons ::= CONSTRAINT nm */ - 210, /* (31) ccons ::= DEFAULT scantok term */ - 210, /* (32) ccons ::= DEFAULT LP expr RP */ - 210, /* (33) ccons ::= DEFAULT PLUS scantok term */ - 210, /* (34) ccons ::= DEFAULT MINUS scantok term */ - 210, /* (35) ccons ::= DEFAULT scantok ID|INDEXED */ - 210, /* (36) ccons ::= NOT NULL onconf */ - 210, /* (37) ccons ::= PRIMARY KEY sortorder onconf autoinc */ - 210, /* (38) ccons ::= UNIQUE onconf */ - 210, /* (39) ccons ::= CHECK LP expr RP */ - 210, /* (40) ccons ::= REFERENCES nm eidlist_opt refargs */ - 210, /* (41) ccons ::= defer_subclause */ - 210, /* (42) ccons ::= COLLATE ID|STRING */ - 219, /* (43) generated ::= LP expr RP */ - 219, /* (44) generated ::= LP expr RP ID */ - 215, /* (45) autoinc ::= */ - 215, /* (46) autoinc ::= AUTOINCR */ - 217, /* (47) refargs ::= */ - 217, /* (48) refargs ::= refargs refarg */ - 220, /* (49) refarg ::= MATCH nm */ - 220, /* (50) refarg ::= ON INSERT refact */ - 220, /* (51) refarg ::= ON DELETE refact */ - 220, /* (52) refarg ::= ON UPDATE refact */ - 221, /* (53) refact ::= SET NULL */ - 221, /* (54) refact ::= SET DEFAULT */ - 221, /* (55) refact ::= CASCADE */ - 221, /* (56) refact ::= RESTRICT */ - 221, /* (57) refact ::= NO ACTION */ - 218, /* (58) defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt */ - 218, /* (59) defer_subclause ::= DEFERRABLE init_deferred_pred_opt */ - 222, /* (60) init_deferred_pred_opt ::= */ - 222, /* (61) init_deferred_pred_opt ::= INITIALLY DEFERRED */ - 222, /* (62) init_deferred_pred_opt ::= INITIALLY IMMEDIATE */ - 198, /* (63) conslist_opt ::= */ - 224, /* (64) tconscomma ::= COMMA */ - 225, /* (65) tcons ::= CONSTRAINT nm */ - 225, /* (66) tcons ::= PRIMARY KEY LP sortlist autoinc RP onconf */ - 225, /* (67) tcons ::= UNIQUE LP sortlist RP onconf */ - 225, /* (68) tcons ::= CHECK LP expr RP onconf */ - 225, /* (69) tcons ::= FOREIGN KEY LP eidlist RP REFERENCES nm eidlist_opt refargs defer_subclause_opt */ - 228, /* (70) defer_subclause_opt ::= */ - 213, /* (71) onconf ::= */ - 213, /* (72) onconf ::= ON CONFLICT resolvetype */ - 229, /* (73) orconf ::= */ - 229, /* (74) orconf ::= OR resolvetype */ - 230, /* (75) resolvetype ::= IGNORE */ - 230, /* (76) resolvetype ::= REPLACE */ - 186, /* (77) cmd ::= DROP TABLE ifexists fullname */ - 232, /* (78) ifexists ::= IF EXISTS */ - 232, /* (79) ifexists ::= */ - 186, /* (80) cmd ::= createkw temp VIEW ifnotexists nm dbnm eidlist_opt AS select */ - 186, /* (81) cmd ::= DROP VIEW ifexists fullname */ - 186, /* (82) cmd ::= select */ - 200, /* (83) select ::= WITH wqlist selectnowith */ - 200, /* (84) select ::= WITH RECURSIVE wqlist selectnowith */ - 200, /* (85) select ::= selectnowith */ - 234, /* (86) selectnowith ::= selectnowith multiselect_op oneselect */ - 237, /* (87) multiselect_op ::= UNION */ - 237, /* (88) multiselect_op ::= UNION ALL */ - 237, /* (89) multiselect_op ::= EXCEPT|INTERSECT */ - 235, /* (90) oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt */ - 235, /* (91) oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt window_clause orderby_opt limit_opt */ - 247, /* (92) values ::= VALUES LP nexprlist RP */ - 247, /* (93) values ::= values COMMA LP nexprlist RP */ - 238, /* (94) distinct ::= DISTINCT */ - 238, /* (95) distinct ::= ALL */ - 238, /* (96) distinct ::= */ - 249, /* (97) sclp ::= */ - 239, /* (98) selcollist ::= sclp scanpt expr scanpt as */ - 239, /* (99) selcollist ::= sclp scanpt STAR */ - 239, /* (100) selcollist ::= sclp scanpt nm DOT STAR */ - 250, /* (101) as ::= AS nm */ - 250, /* (102) as ::= */ - 240, /* (103) from ::= */ - 240, /* (104) from ::= FROM seltablist */ - 252, /* (105) stl_prefix ::= seltablist joinop */ - 252, /* (106) stl_prefix ::= */ - 251, /* (107) seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt */ - 251, /* (108) seltablist ::= stl_prefix nm dbnm LP exprlist RP as on_opt using_opt */ - 251, /* (109) seltablist ::= stl_prefix LP select RP as on_opt using_opt */ - 251, /* (110) seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt */ - 196, /* (111) dbnm ::= */ - 196, /* (112) dbnm ::= DOT nm */ - 233, /* (113) fullname ::= nm */ - 233, /* (114) fullname ::= nm DOT nm */ - 258, /* (115) xfullname ::= nm */ - 258, /* (116) xfullname ::= nm DOT nm */ - 258, /* (117) xfullname ::= nm DOT nm AS nm */ - 258, /* (118) xfullname ::= nm AS nm */ - 253, /* (119) joinop ::= COMMA|JOIN */ - 253, /* (120) joinop ::= JOIN_KW JOIN */ - 253, /* (121) joinop ::= JOIN_KW nm JOIN */ - 253, /* (122) joinop ::= JOIN_KW nm nm JOIN */ - 255, /* (123) on_opt ::= ON expr */ - 255, /* (124) on_opt ::= */ - 254, /* (125) indexed_opt ::= */ - 254, /* (126) indexed_opt ::= INDEXED BY nm */ - 254, /* (127) indexed_opt ::= NOT INDEXED */ - 256, /* (128) using_opt ::= USING LP idlist RP */ - 256, /* (129) using_opt ::= */ - 244, /* (130) orderby_opt ::= */ - 244, /* (131) orderby_opt ::= ORDER BY sortlist */ - 226, /* (132) sortlist ::= sortlist COMMA expr sortorder nulls */ - 226, /* (133) sortlist ::= expr sortorder nulls */ - 214, /* (134) sortorder ::= ASC */ - 214, /* (135) sortorder ::= DESC */ - 214, /* (136) sortorder ::= */ - 260, /* (137) nulls ::= NULLS FIRST */ - 260, /* (138) nulls ::= NULLS LAST */ - 260, /* (139) nulls ::= */ - 242, /* (140) groupby_opt ::= */ - 242, /* (141) groupby_opt ::= GROUP BY nexprlist */ - 243, /* (142) having_opt ::= */ - 243, /* (143) having_opt ::= HAVING expr */ - 245, /* (144) limit_opt ::= */ - 245, /* (145) limit_opt ::= LIMIT expr */ - 245, /* (146) limit_opt ::= LIMIT expr OFFSET expr */ - 245, /* (147) limit_opt ::= LIMIT expr COMMA expr */ - 186, /* (148) cmd ::= with DELETE FROM xfullname indexed_opt where_opt */ - 241, /* (149) where_opt ::= */ - 241, /* (150) where_opt ::= WHERE expr */ - 186, /* (151) cmd ::= with UPDATE orconf xfullname indexed_opt SET setlist where_opt */ - 262, /* (152) setlist ::= setlist COMMA nm EQ expr */ - 262, /* (153) setlist ::= setlist COMMA LP idlist RP EQ expr */ - 262, /* (154) setlist ::= nm EQ expr */ - 262, /* (155) setlist ::= LP idlist RP EQ expr */ - 186, /* (156) cmd ::= with insert_cmd INTO xfullname idlist_opt select upsert */ - 186, /* (157) cmd ::= with insert_cmd INTO xfullname idlist_opt DEFAULT VALUES */ - 265, /* (158) upsert ::= */ - 265, /* (159) upsert ::= ON CONFLICT LP sortlist RP where_opt DO UPDATE SET setlist where_opt */ - 265, /* (160) upsert ::= ON CONFLICT LP sortlist RP where_opt DO NOTHING */ - 265, /* (161) upsert ::= ON CONFLICT DO NOTHING */ - 263, /* (162) insert_cmd ::= INSERT orconf */ - 263, /* (163) insert_cmd ::= REPLACE */ - 264, /* (164) idlist_opt ::= */ - 264, /* (165) idlist_opt ::= LP idlist RP */ - 259, /* (166) idlist ::= idlist COMMA nm */ - 259, /* (167) idlist ::= nm */ - 212, /* (168) expr ::= LP expr RP */ - 212, /* (169) expr ::= ID|INDEXED */ - 212, /* (170) expr ::= JOIN_KW */ - 212, /* (171) expr ::= nm DOT nm */ - 212, /* (172) expr ::= nm DOT nm DOT nm */ - 211, /* (173) term ::= NULL|FLOAT|BLOB */ - 211, /* (174) term ::= STRING */ - 211, /* (175) term ::= INTEGER */ - 212, /* (176) expr ::= VARIABLE */ - 212, /* (177) expr ::= expr COLLATE ID|STRING */ - 212, /* (178) expr ::= CAST LP expr AS typetoken RP */ - 212, /* (179) expr ::= ID|INDEXED LP distinct exprlist RP */ - 212, /* (180) expr ::= ID|INDEXED LP STAR RP */ - 212, /* (181) expr ::= ID|INDEXED LP distinct exprlist RP filter_over */ - 212, /* (182) expr ::= ID|INDEXED LP STAR RP filter_over */ - 211, /* (183) term ::= CTIME_KW */ - 212, /* (184) expr ::= LP nexprlist COMMA expr RP */ - 212, /* (185) expr ::= expr AND expr */ - 212, /* (186) expr ::= expr OR expr */ - 212, /* (187) expr ::= expr LT|GT|GE|LE expr */ - 212, /* (188) expr ::= expr EQ|NE expr */ - 212, /* (189) expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */ - 212, /* (190) expr ::= expr PLUS|MINUS expr */ - 212, /* (191) expr ::= expr STAR|SLASH|REM expr */ - 212, /* (192) expr ::= expr CONCAT expr */ - 267, /* (193) likeop ::= NOT LIKE_KW|MATCH */ - 212, /* (194) expr ::= expr likeop expr */ - 212, /* (195) expr ::= expr likeop expr ESCAPE expr */ - 212, /* (196) expr ::= expr ISNULL|NOTNULL */ - 212, /* (197) expr ::= expr NOT NULL */ - 212, /* (198) expr ::= expr IS expr */ - 212, /* (199) expr ::= expr IS NOT expr */ - 212, /* (200) expr ::= NOT expr */ - 212, /* (201) expr ::= BITNOT expr */ - 212, /* (202) expr ::= PLUS|MINUS expr */ - 268, /* (203) between_op ::= BETWEEN */ - 268, /* (204) between_op ::= NOT BETWEEN */ - 212, /* (205) expr ::= expr between_op expr AND expr */ - 269, /* (206) in_op ::= IN */ - 269, /* (207) in_op ::= NOT IN */ - 212, /* (208) expr ::= expr in_op LP exprlist RP */ - 212, /* (209) expr ::= LP select RP */ - 212, /* (210) expr ::= expr in_op LP select RP */ - 212, /* (211) expr ::= expr in_op nm dbnm paren_exprlist */ - 212, /* (212) expr ::= EXISTS LP select RP */ - 212, /* (213) expr ::= CASE case_operand case_exprlist case_else END */ - 272, /* (214) case_exprlist ::= case_exprlist WHEN expr THEN expr */ - 272, /* (215) case_exprlist ::= WHEN expr THEN expr */ - 273, /* (216) case_else ::= ELSE expr */ - 273, /* (217) case_else ::= */ - 271, /* (218) case_operand ::= expr */ - 271, /* (219) case_operand ::= */ - 257, /* (220) exprlist ::= */ - 248, /* (221) nexprlist ::= nexprlist COMMA expr */ - 248, /* (222) nexprlist ::= expr */ - 270, /* (223) paren_exprlist ::= */ - 270, /* (224) paren_exprlist ::= LP exprlist RP */ - 186, /* (225) cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */ - 274, /* (226) uniqueflag ::= UNIQUE */ - 274, /* (227) uniqueflag ::= */ - 216, /* (228) eidlist_opt ::= */ - 216, /* (229) eidlist_opt ::= LP eidlist RP */ - 227, /* (230) eidlist ::= eidlist COMMA nm collate sortorder */ - 227, /* (231) eidlist ::= nm collate sortorder */ - 275, /* (232) collate ::= */ - 275, /* (233) collate ::= COLLATE ID|STRING */ - 186, /* (234) cmd ::= DROP INDEX ifexists fullname */ - 186, /* (235) cmd ::= VACUUM vinto */ - 186, /* (236) cmd ::= VACUUM nm vinto */ - 276, /* (237) vinto ::= INTO expr */ - 276, /* (238) vinto ::= */ - 186, /* (239) cmd ::= PRAGMA nm dbnm */ - 186, /* (240) cmd ::= PRAGMA nm dbnm EQ nmnum */ - 186, /* (241) cmd ::= PRAGMA nm dbnm LP nmnum RP */ - 186, /* (242) cmd ::= PRAGMA nm dbnm EQ minus_num */ - 186, /* (243) cmd ::= PRAGMA nm dbnm LP minus_num RP */ - 206, /* (244) plus_num ::= PLUS INTEGER|FLOAT */ - 207, /* (245) minus_num ::= MINUS INTEGER|FLOAT */ - 186, /* (246) cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */ - 278, /* (247) trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */ - 280, /* (248) trigger_time ::= BEFORE|AFTER */ - 280, /* (249) trigger_time ::= INSTEAD OF */ - 280, /* (250) trigger_time ::= */ - 281, /* (251) trigger_event ::= DELETE|INSERT */ - 281, /* (252) trigger_event ::= UPDATE */ - 281, /* (253) trigger_event ::= UPDATE OF idlist */ - 283, /* (254) when_clause ::= */ - 283, /* (255) when_clause ::= WHEN expr */ - 279, /* (256) trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */ - 279, /* (257) trigger_cmd_list ::= trigger_cmd SEMI */ - 285, /* (258) trnm ::= nm DOT nm */ - 286, /* (259) tridxby ::= INDEXED BY nm */ - 286, /* (260) tridxby ::= NOT INDEXED */ - 284, /* (261) trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt scanpt */ - 284, /* (262) trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt */ - 284, /* (263) trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt */ - 284, /* (264) trigger_cmd ::= scanpt select scanpt */ - 212, /* (265) expr ::= RAISE LP IGNORE RP */ - 212, /* (266) expr ::= RAISE LP raisetype COMMA nm RP */ - 231, /* (267) raisetype ::= ROLLBACK */ - 231, /* (268) raisetype ::= ABORT */ - 231, /* (269) raisetype ::= FAIL */ - 186, /* (270) cmd ::= DROP TRIGGER ifexists fullname */ - 186, /* (271) cmd ::= ATTACH database_kw_opt expr AS expr key_opt */ - 186, /* (272) cmd ::= DETACH database_kw_opt expr */ - 288, /* (273) key_opt ::= */ - 288, /* (274) key_opt ::= KEY expr */ - 186, /* (275) cmd ::= REINDEX */ - 186, /* (276) cmd ::= REINDEX nm dbnm */ - 186, /* (277) cmd ::= ANALYZE */ - 186, /* (278) cmd ::= ANALYZE nm dbnm */ - 186, /* (279) cmd ::= ALTER TABLE fullname RENAME TO nm */ - 186, /* (280) cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */ - 289, /* (281) add_column_fullname ::= fullname */ - 186, /* (282) cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm */ - 186, /* (283) cmd ::= create_vtab */ - 186, /* (284) cmd ::= create_vtab LP vtabarglist RP */ - 291, /* (285) create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */ - 293, /* (286) vtabarg ::= */ - 294, /* (287) vtabargtoken ::= ANY */ - 294, /* (288) vtabargtoken ::= lp anylist RP */ - 295, /* (289) lp ::= LP */ - 261, /* (290) with ::= WITH wqlist */ - 261, /* (291) with ::= WITH RECURSIVE wqlist */ - 236, /* (292) wqlist ::= nm eidlist_opt AS LP select RP */ - 236, /* (293) wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP */ - 297, /* (294) windowdefn_list ::= windowdefn */ - 297, /* (295) windowdefn_list ::= windowdefn_list COMMA windowdefn */ - 298, /* (296) windowdefn ::= nm AS LP window RP */ - 299, /* (297) window ::= PARTITION BY nexprlist orderby_opt frame_opt */ - 299, /* (298) window ::= nm PARTITION BY nexprlist orderby_opt frame_opt */ - 299, /* (299) window ::= ORDER BY sortlist frame_opt */ - 299, /* (300) window ::= nm ORDER BY sortlist frame_opt */ - 299, /* (301) window ::= frame_opt */ - 299, /* (302) window ::= nm frame_opt */ - 300, /* (303) frame_opt ::= */ - 300, /* (304) frame_opt ::= range_or_rows frame_bound_s frame_exclude_opt */ - 300, /* (305) frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e frame_exclude_opt */ - 304, /* (306) range_or_rows ::= RANGE|ROWS|GROUPS */ - 306, /* (307) frame_bound_s ::= frame_bound */ - 306, /* (308) frame_bound_s ::= UNBOUNDED PRECEDING */ - 307, /* (309) frame_bound_e ::= frame_bound */ - 307, /* (310) frame_bound_e ::= UNBOUNDED FOLLOWING */ - 305, /* (311) frame_bound ::= expr PRECEDING|FOLLOWING */ - 305, /* (312) frame_bound ::= CURRENT ROW */ - 308, /* (313) frame_exclude_opt ::= */ - 308, /* (314) frame_exclude_opt ::= EXCLUDE frame_exclude */ - 309, /* (315) frame_exclude ::= NO OTHERS */ - 309, /* (316) frame_exclude ::= CURRENT ROW */ - 309, /* (317) frame_exclude ::= GROUP|TIES */ - 246, /* (318) window_clause ::= WINDOW windowdefn_list */ - 266, /* (319) filter_over ::= filter_clause over_clause */ - 266, /* (320) filter_over ::= over_clause */ - 266, /* (321) filter_over ::= filter_clause */ - 303, /* (322) over_clause ::= OVER LP window RP */ - 303, /* (323) over_clause ::= OVER nm */ - 302, /* (324) filter_clause ::= FILTER LP WHERE expr RP */ - 181, /* (325) input ::= cmdlist */ - 182, /* (326) cmdlist ::= cmdlist ecmd */ - 182, /* (327) cmdlist ::= ecmd */ - 183, /* (328) ecmd ::= SEMI */ - 183, /* (329) ecmd ::= cmdx SEMI */ - 183, /* (330) ecmd ::= explain cmdx SEMI */ - 188, /* (331) trans_opt ::= */ - 188, /* (332) trans_opt ::= TRANSACTION */ - 188, /* (333) trans_opt ::= TRANSACTION nm */ - 190, /* (334) savepoint_opt ::= SAVEPOINT */ - 190, /* (335) savepoint_opt ::= */ - 186, /* (336) cmd ::= create_table create_table_args */ - 197, /* (337) columnlist ::= columnlist COMMA columnname carglist */ - 197, /* (338) columnlist ::= columnname carglist */ - 189, /* (339) nm ::= ID|INDEXED */ - 189, /* (340) nm ::= STRING */ - 189, /* (341) nm ::= JOIN_KW */ - 203, /* (342) typetoken ::= typename */ - 204, /* (343) typename ::= ID|STRING */ - 205, /* (344) signed ::= plus_num */ - 205, /* (345) signed ::= minus_num */ - 202, /* (346) carglist ::= carglist ccons */ - 202, /* (347) carglist ::= */ - 210, /* (348) ccons ::= NULL onconf */ - 210, /* (349) ccons ::= GENERATED ALWAYS AS generated */ - 210, /* (350) ccons ::= AS generated */ - 198, /* (351) conslist_opt ::= COMMA conslist */ - 223, /* (352) conslist ::= conslist tconscomma tcons */ - 223, /* (353) conslist ::= tcons */ - 224, /* (354) tconscomma ::= */ - 228, /* (355) defer_subclause_opt ::= defer_subclause */ - 230, /* (356) resolvetype ::= raisetype */ - 234, /* (357) selectnowith ::= oneselect */ - 235, /* (358) oneselect ::= values */ - 249, /* (359) sclp ::= selcollist COMMA */ - 250, /* (360) as ::= ID|STRING */ - 212, /* (361) expr ::= term */ - 267, /* (362) likeop ::= LIKE_KW|MATCH */ - 257, /* (363) exprlist ::= nexprlist */ - 277, /* (364) nmnum ::= plus_num */ - 277, /* (365) nmnum ::= nm */ - 277, /* (366) nmnum ::= ON */ - 277, /* (367) nmnum ::= DELETE */ - 277, /* (368) nmnum ::= DEFAULT */ - 206, /* (369) plus_num ::= INTEGER|FLOAT */ - 282, /* (370) foreach_clause ::= */ - 282, /* (371) foreach_clause ::= FOR EACH ROW */ - 285, /* (372) trnm ::= nm */ - 286, /* (373) tridxby ::= */ - 287, /* (374) database_kw_opt ::= DATABASE */ - 287, /* (375) database_kw_opt ::= */ - 290, /* (376) kwcolumn_opt ::= */ - 290, /* (377) kwcolumn_opt ::= COLUMNKW */ - 292, /* (378) vtabarglist ::= vtabarg */ - 292, /* (379) vtabarglist ::= vtabarglist COMMA vtabarg */ - 293, /* (380) vtabarg ::= vtabarg vtabargtoken */ - 296, /* (381) anylist ::= */ - 296, /* (382) anylist ::= anylist LP anylist RP */ - 296, /* (383) anylist ::= anylist ANY */ - 261, /* (384) with ::= */ + 183, /* (0) explain ::= EXPLAIN */ + 183, /* (1) explain ::= EXPLAIN QUERY PLAN */ + 182, /* (2) cmdx ::= cmd */ + 184, /* (3) cmd ::= BEGIN transtype trans_opt */ + 185, /* (4) transtype ::= */ + 185, /* (5) transtype ::= DEFERRED */ + 185, /* (6) transtype ::= IMMEDIATE */ + 185, /* (7) transtype ::= EXCLUSIVE */ + 184, /* (8) cmd ::= COMMIT|END trans_opt */ + 184, /* (9) cmd ::= ROLLBACK trans_opt */ + 184, /* (10) cmd ::= SAVEPOINT nm */ + 184, /* (11) cmd ::= RELEASE savepoint_opt nm */ + 184, /* (12) cmd ::= ROLLBACK trans_opt TO savepoint_opt nm */ + 189, /* (13) create_table ::= createkw temp TABLE ifnotexists nm dbnm */ + 191, /* (14) createkw ::= CREATE */ + 193, /* (15) ifnotexists ::= */ + 193, /* (16) ifnotexists ::= IF NOT EXISTS */ + 192, /* (17) temp ::= TEMP */ + 192, /* (18) temp ::= */ + 190, /* (19) create_table_args ::= LP columnlist conslist_opt RP table_options */ + 190, /* (20) create_table_args ::= AS select */ + 197, /* (21) table_options ::= */ + 197, /* (22) table_options ::= WITHOUT nm */ + 199, /* (23) columnname ::= nm typetoken */ + 201, /* (24) typetoken ::= */ + 201, /* (25) typetoken ::= typename LP signed RP */ + 201, /* (26) typetoken ::= typename LP signed COMMA signed RP */ + 202, /* (27) typename ::= typename ID|STRING */ + 206, /* (28) scanpt ::= */ + 207, /* (29) scantok ::= */ + 208, /* (30) ccons ::= CONSTRAINT nm */ + 208, /* (31) ccons ::= DEFAULT scantok term */ + 208, /* (32) ccons ::= DEFAULT LP expr RP */ + 208, /* (33) ccons ::= DEFAULT PLUS scantok term */ + 208, /* (34) ccons ::= DEFAULT MINUS scantok term */ + 208, /* (35) ccons ::= DEFAULT scantok ID|INDEXED */ + 208, /* (36) ccons ::= NOT NULL onconf */ + 208, /* (37) ccons ::= PRIMARY KEY sortorder onconf autoinc */ + 208, /* (38) ccons ::= UNIQUE onconf */ + 208, /* (39) ccons ::= CHECK LP expr RP */ + 208, /* (40) ccons ::= REFERENCES nm eidlist_opt refargs */ + 208, /* (41) ccons ::= defer_subclause */ + 208, /* (42) ccons ::= COLLATE ID|STRING */ + 213, /* (43) autoinc ::= */ + 213, /* (44) autoinc ::= AUTOINCR */ + 215, /* (45) refargs ::= */ + 215, /* (46) refargs ::= refargs refarg */ + 217, /* (47) refarg ::= MATCH nm */ + 217, /* (48) refarg ::= ON INSERT refact */ + 217, /* (49) refarg ::= ON DELETE refact */ + 217, /* (50) refarg ::= ON UPDATE refact */ + 218, /* (51) refact ::= SET NULL */ + 218, /* (52) refact ::= SET DEFAULT */ + 218, /* (53) refact ::= CASCADE */ + 218, /* (54) refact ::= RESTRICT */ + 218, /* (55) refact ::= NO ACTION */ + 216, /* (56) defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt */ + 216, /* (57) defer_subclause ::= DEFERRABLE init_deferred_pred_opt */ + 219, /* (58) init_deferred_pred_opt ::= */ + 219, /* (59) init_deferred_pred_opt ::= INITIALLY DEFERRED */ + 219, /* (60) init_deferred_pred_opt ::= INITIALLY IMMEDIATE */ + 196, /* (61) conslist_opt ::= */ + 221, /* (62) tconscomma ::= COMMA */ + 222, /* (63) tcons ::= CONSTRAINT nm */ + 222, /* (64) tcons ::= PRIMARY KEY LP sortlist autoinc RP onconf */ + 222, /* (65) tcons ::= UNIQUE LP sortlist RP onconf */ + 222, /* (66) tcons ::= CHECK LP expr RP onconf */ + 222, /* (67) tcons ::= FOREIGN KEY LP eidlist RP REFERENCES nm eidlist_opt refargs defer_subclause_opt */ + 225, /* (68) defer_subclause_opt ::= */ + 211, /* (69) onconf ::= */ + 211, /* (70) onconf ::= ON CONFLICT resolvetype */ + 226, /* (71) orconf ::= */ + 226, /* (72) orconf ::= OR resolvetype */ + 227, /* (73) resolvetype ::= IGNORE */ + 227, /* (74) resolvetype ::= REPLACE */ + 184, /* (75) cmd ::= DROP TABLE ifexists fullname */ + 229, /* (76) ifexists ::= IF EXISTS */ + 229, /* (77) ifexists ::= */ + 184, /* (78) cmd ::= createkw temp VIEW ifnotexists nm dbnm eidlist_opt AS select */ + 184, /* (79) cmd ::= DROP VIEW ifexists fullname */ + 184, /* (80) cmd ::= select */ + 198, /* (81) select ::= WITH wqlist selectnowith */ + 198, /* (82) select ::= WITH RECURSIVE wqlist selectnowith */ + 198, /* (83) select ::= selectnowith */ + 231, /* (84) selectnowith ::= selectnowith multiselect_op oneselect */ + 234, /* (85) multiselect_op ::= UNION */ + 234, /* (86) multiselect_op ::= UNION ALL */ + 234, /* (87) multiselect_op ::= EXCEPT|INTERSECT */ + 232, /* (88) oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt */ + 232, /* (89) oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt window_clause orderby_opt limit_opt */ + 244, /* (90) values ::= VALUES LP nexprlist RP */ + 244, /* (91) values ::= values COMMA LP nexprlist RP */ + 235, /* (92) distinct ::= DISTINCT */ + 235, /* (93) distinct ::= ALL */ + 235, /* (94) distinct ::= */ + 246, /* (95) sclp ::= */ + 236, /* (96) selcollist ::= sclp scanpt expr scanpt as */ + 236, /* (97) selcollist ::= sclp scanpt STAR */ + 236, /* (98) selcollist ::= sclp scanpt nm DOT STAR */ + 247, /* (99) as ::= AS nm */ + 247, /* (100) as ::= */ + 237, /* (101) from ::= */ + 237, /* (102) from ::= FROM seltablist */ + 249, /* (103) stl_prefix ::= seltablist joinop */ + 249, /* (104) stl_prefix ::= */ + 248, /* (105) seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt */ + 248, /* (106) seltablist ::= stl_prefix nm dbnm LP exprlist RP as on_opt using_opt */ + 248, /* (107) seltablist ::= stl_prefix LP select RP as on_opt using_opt */ + 248, /* (108) seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt */ + 194, /* (109) dbnm ::= */ + 194, /* (110) dbnm ::= DOT nm */ + 230, /* (111) fullname ::= nm */ + 230, /* (112) fullname ::= nm DOT nm */ + 255, /* (113) xfullname ::= nm */ + 255, /* (114) xfullname ::= nm DOT nm */ + 255, /* (115) xfullname ::= nm DOT nm AS nm */ + 255, /* (116) xfullname ::= nm AS nm */ + 250, /* (117) joinop ::= COMMA|JOIN */ + 250, /* (118) joinop ::= JOIN_KW JOIN */ + 250, /* (119) joinop ::= JOIN_KW nm JOIN */ + 250, /* (120) joinop ::= JOIN_KW nm nm JOIN */ + 252, /* (121) on_opt ::= ON expr */ + 252, /* (122) on_opt ::= */ + 251, /* (123) indexed_opt ::= */ + 251, /* (124) indexed_opt ::= INDEXED BY nm */ + 251, /* (125) indexed_opt ::= NOT INDEXED */ + 253, /* (126) using_opt ::= USING LP idlist RP */ + 253, /* (127) using_opt ::= */ + 241, /* (128) orderby_opt ::= */ + 241, /* (129) orderby_opt ::= ORDER BY sortlist */ + 223, /* (130) sortlist ::= sortlist COMMA expr sortorder nulls */ + 223, /* (131) sortlist ::= expr sortorder nulls */ + 212, /* (132) sortorder ::= ASC */ + 212, /* (133) sortorder ::= DESC */ + 212, /* (134) sortorder ::= */ + 257, /* (135) nulls ::= NULLS FIRST */ + 257, /* (136) nulls ::= NULLS LAST */ + 257, /* (137) nulls ::= */ + 239, /* (138) groupby_opt ::= */ + 239, /* (139) groupby_opt ::= GROUP BY nexprlist */ + 240, /* (140) having_opt ::= */ + 240, /* (141) having_opt ::= HAVING expr */ + 242, /* (142) limit_opt ::= */ + 242, /* (143) limit_opt ::= LIMIT expr */ + 242, /* (144) limit_opt ::= LIMIT expr OFFSET expr */ + 242, /* (145) limit_opt ::= LIMIT expr COMMA expr */ + 184, /* (146) cmd ::= with DELETE FROM xfullname indexed_opt where_opt */ + 238, /* (147) where_opt ::= */ + 238, /* (148) where_opt ::= WHERE expr */ + 184, /* (149) cmd ::= with UPDATE orconf xfullname indexed_opt SET setlist where_opt */ + 259, /* (150) setlist ::= setlist COMMA nm EQ expr */ + 259, /* (151) setlist ::= setlist COMMA LP idlist RP EQ expr */ + 259, /* (152) setlist ::= nm EQ expr */ + 259, /* (153) setlist ::= LP idlist RP EQ expr */ + 184, /* (154) cmd ::= with insert_cmd INTO xfullname idlist_opt select upsert */ + 184, /* (155) cmd ::= with insert_cmd INTO xfullname idlist_opt DEFAULT VALUES */ + 262, /* (156) upsert ::= */ + 262, /* (157) upsert ::= ON CONFLICT LP sortlist RP where_opt DO UPDATE SET setlist where_opt */ + 262, /* (158) upsert ::= ON CONFLICT LP sortlist RP where_opt DO NOTHING */ + 262, /* (159) upsert ::= ON CONFLICT DO NOTHING */ + 260, /* (160) insert_cmd ::= INSERT orconf */ + 260, /* (161) insert_cmd ::= REPLACE */ + 261, /* (162) idlist_opt ::= */ + 261, /* (163) idlist_opt ::= LP idlist RP */ + 256, /* (164) idlist ::= idlist COMMA nm */ + 256, /* (165) idlist ::= nm */ + 210, /* (166) expr ::= LP expr RP */ + 210, /* (167) expr ::= ID|INDEXED */ + 210, /* (168) expr ::= JOIN_KW */ + 210, /* (169) expr ::= nm DOT nm */ + 210, /* (170) expr ::= nm DOT nm DOT nm */ + 209, /* (171) term ::= NULL|FLOAT|BLOB */ + 209, /* (172) term ::= STRING */ + 209, /* (173) term ::= INTEGER */ + 210, /* (174) expr ::= VARIABLE */ + 210, /* (175) expr ::= expr COLLATE ID|STRING */ + 210, /* (176) expr ::= CAST LP expr AS typetoken RP */ + 210, /* (177) expr ::= ID|INDEXED LP distinct exprlist RP */ + 210, /* (178) expr ::= ID|INDEXED LP STAR RP */ + 210, /* (179) expr ::= ID|INDEXED LP distinct exprlist RP filter_over */ + 210, /* (180) expr ::= ID|INDEXED LP STAR RP filter_over */ + 209, /* (181) term ::= CTIME_KW */ + 210, /* (182) expr ::= LP nexprlist COMMA expr RP */ + 210, /* (183) expr ::= expr AND expr */ + 210, /* (184) expr ::= expr OR expr */ + 210, /* (185) expr ::= expr LT|GT|GE|LE expr */ + 210, /* (186) expr ::= expr EQ|NE expr */ + 210, /* (187) expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */ + 210, /* (188) expr ::= expr PLUS|MINUS expr */ + 210, /* (189) expr ::= expr STAR|SLASH|REM expr */ + 210, /* (190) expr ::= expr CONCAT expr */ + 264, /* (191) likeop ::= NOT LIKE_KW|MATCH */ + 210, /* (192) expr ::= expr likeop expr */ + 210, /* (193) expr ::= expr likeop expr ESCAPE expr */ + 210, /* (194) expr ::= expr ISNULL|NOTNULL */ + 210, /* (195) expr ::= expr NOT NULL */ + 210, /* (196) expr ::= expr IS expr */ + 210, /* (197) expr ::= expr IS NOT expr */ + 210, /* (198) expr ::= NOT expr */ + 210, /* (199) expr ::= BITNOT expr */ + 210, /* (200) expr ::= PLUS|MINUS expr */ + 265, /* (201) between_op ::= BETWEEN */ + 265, /* (202) between_op ::= NOT BETWEEN */ + 210, /* (203) expr ::= expr between_op expr AND expr */ + 266, /* (204) in_op ::= IN */ + 266, /* (205) in_op ::= NOT IN */ + 210, /* (206) expr ::= expr in_op LP exprlist RP */ + 210, /* (207) expr ::= LP select RP */ + 210, /* (208) expr ::= expr in_op LP select RP */ + 210, /* (209) expr ::= expr in_op nm dbnm paren_exprlist */ + 210, /* (210) expr ::= EXISTS LP select RP */ + 210, /* (211) expr ::= CASE case_operand case_exprlist case_else END */ + 269, /* (212) case_exprlist ::= case_exprlist WHEN expr THEN expr */ + 269, /* (213) case_exprlist ::= WHEN expr THEN expr */ + 270, /* (214) case_else ::= ELSE expr */ + 270, /* (215) case_else ::= */ + 268, /* (216) case_operand ::= expr */ + 268, /* (217) case_operand ::= */ + 254, /* (218) exprlist ::= */ + 245, /* (219) nexprlist ::= nexprlist COMMA expr */ + 245, /* (220) nexprlist ::= expr */ + 267, /* (221) paren_exprlist ::= */ + 267, /* (222) paren_exprlist ::= LP exprlist RP */ + 184, /* (223) cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */ + 271, /* (224) uniqueflag ::= UNIQUE */ + 271, /* (225) uniqueflag ::= */ + 214, /* (226) eidlist_opt ::= */ + 214, /* (227) eidlist_opt ::= LP eidlist RP */ + 224, /* (228) eidlist ::= eidlist COMMA nm collate sortorder */ + 224, /* (229) eidlist ::= nm collate sortorder */ + 272, /* (230) collate ::= */ + 272, /* (231) collate ::= COLLATE ID|STRING */ + 184, /* (232) cmd ::= DROP INDEX ifexists fullname */ + 184, /* (233) cmd ::= VACUUM vinto */ + 184, /* (234) cmd ::= VACUUM nm vinto */ + 273, /* (235) vinto ::= INTO expr */ + 273, /* (236) vinto ::= */ + 184, /* (237) cmd ::= PRAGMA nm dbnm */ + 184, /* (238) cmd ::= PRAGMA nm dbnm EQ nmnum */ + 184, /* (239) cmd ::= PRAGMA nm dbnm LP nmnum RP */ + 184, /* (240) cmd ::= PRAGMA nm dbnm EQ minus_num */ + 184, /* (241) cmd ::= PRAGMA nm dbnm LP minus_num RP */ + 204, /* (242) plus_num ::= PLUS INTEGER|FLOAT */ + 205, /* (243) minus_num ::= MINUS INTEGER|FLOAT */ + 184, /* (244) cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */ + 275, /* (245) trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */ + 277, /* (246) trigger_time ::= BEFORE|AFTER */ + 277, /* (247) trigger_time ::= INSTEAD OF */ + 277, /* (248) trigger_time ::= */ + 278, /* (249) trigger_event ::= DELETE|INSERT */ + 278, /* (250) trigger_event ::= UPDATE */ + 278, /* (251) trigger_event ::= UPDATE OF idlist */ + 280, /* (252) when_clause ::= */ + 280, /* (253) when_clause ::= WHEN expr */ + 276, /* (254) trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */ + 276, /* (255) trigger_cmd_list ::= trigger_cmd SEMI */ + 282, /* (256) trnm ::= nm DOT nm */ + 283, /* (257) tridxby ::= INDEXED BY nm */ + 283, /* (258) tridxby ::= NOT INDEXED */ + 281, /* (259) trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt scanpt */ + 281, /* (260) trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt */ + 281, /* (261) trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt */ + 281, /* (262) trigger_cmd ::= scanpt select scanpt */ + 210, /* (263) expr ::= RAISE LP IGNORE RP */ + 210, /* (264) expr ::= RAISE LP raisetype COMMA nm RP */ + 228, /* (265) raisetype ::= ROLLBACK */ + 228, /* (266) raisetype ::= ABORT */ + 228, /* (267) raisetype ::= FAIL */ + 184, /* (268) cmd ::= DROP TRIGGER ifexists fullname */ + 184, /* (269) cmd ::= ATTACH database_kw_opt expr AS expr key_opt */ + 184, /* (270) cmd ::= DETACH database_kw_opt expr */ + 285, /* (271) key_opt ::= */ + 285, /* (272) key_opt ::= KEY expr */ + 184, /* (273) cmd ::= REINDEX */ + 184, /* (274) cmd ::= REINDEX nm dbnm */ + 184, /* (275) cmd ::= ANALYZE */ + 184, /* (276) cmd ::= ANALYZE nm dbnm */ + 184, /* (277) cmd ::= ALTER TABLE fullname RENAME TO nm */ + 184, /* (278) cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */ + 286, /* (279) add_column_fullname ::= fullname */ + 184, /* (280) cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm */ + 184, /* (281) cmd ::= create_vtab */ + 184, /* (282) cmd ::= create_vtab LP vtabarglist RP */ + 288, /* (283) create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */ + 290, /* (284) vtabarg ::= */ + 291, /* (285) vtabargtoken ::= ANY */ + 291, /* (286) vtabargtoken ::= lp anylist RP */ + 292, /* (287) lp ::= LP */ + 258, /* (288) with ::= WITH wqlist */ + 258, /* (289) with ::= WITH RECURSIVE wqlist */ + 233, /* (290) wqlist ::= nm eidlist_opt AS LP select RP */ + 233, /* (291) wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP */ + 294, /* (292) windowdefn_list ::= windowdefn */ + 294, /* (293) windowdefn_list ::= windowdefn_list COMMA windowdefn */ + 295, /* (294) windowdefn ::= nm AS LP window RP */ + 296, /* (295) window ::= PARTITION BY nexprlist orderby_opt frame_opt */ + 296, /* (296) window ::= nm PARTITION BY nexprlist orderby_opt frame_opt */ + 296, /* (297) window ::= ORDER BY sortlist frame_opt */ + 296, /* (298) window ::= nm ORDER BY sortlist frame_opt */ + 296, /* (299) window ::= frame_opt */ + 296, /* (300) window ::= nm frame_opt */ + 297, /* (301) frame_opt ::= */ + 297, /* (302) frame_opt ::= range_or_rows frame_bound_s frame_exclude_opt */ + 297, /* (303) frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e frame_exclude_opt */ + 301, /* (304) range_or_rows ::= RANGE|ROWS|GROUPS */ + 303, /* (305) frame_bound_s ::= frame_bound */ + 303, /* (306) frame_bound_s ::= UNBOUNDED PRECEDING */ + 304, /* (307) frame_bound_e ::= frame_bound */ + 304, /* (308) frame_bound_e ::= UNBOUNDED FOLLOWING */ + 302, /* (309) frame_bound ::= expr PRECEDING|FOLLOWING */ + 302, /* (310) frame_bound ::= CURRENT ROW */ + 305, /* (311) frame_exclude_opt ::= */ + 305, /* (312) frame_exclude_opt ::= EXCLUDE frame_exclude */ + 306, /* (313) frame_exclude ::= NO OTHERS */ + 306, /* (314) frame_exclude ::= CURRENT ROW */ + 306, /* (315) frame_exclude ::= GROUP|TIES */ + 243, /* (316) window_clause ::= WINDOW windowdefn_list */ + 263, /* (317) filter_over ::= filter_clause over_clause */ + 263, /* (318) filter_over ::= over_clause */ + 263, /* (319) filter_over ::= filter_clause */ + 300, /* (320) over_clause ::= OVER LP window RP */ + 300, /* (321) over_clause ::= OVER nm */ + 299, /* (322) filter_clause ::= FILTER LP WHERE expr RP */ + 179, /* (323) input ::= cmdlist */ + 180, /* (324) cmdlist ::= cmdlist ecmd */ + 180, /* (325) cmdlist ::= ecmd */ + 181, /* (326) ecmd ::= SEMI */ + 181, /* (327) ecmd ::= cmdx SEMI */ + 181, /* (328) ecmd ::= explain cmdx */ + 186, /* (329) trans_opt ::= */ + 186, /* (330) trans_opt ::= TRANSACTION */ + 186, /* (331) trans_opt ::= TRANSACTION nm */ + 188, /* (332) savepoint_opt ::= SAVEPOINT */ + 188, /* (333) savepoint_opt ::= */ + 184, /* (334) cmd ::= create_table create_table_args */ + 195, /* (335) columnlist ::= columnlist COMMA columnname carglist */ + 195, /* (336) columnlist ::= columnname carglist */ + 187, /* (337) nm ::= ID|INDEXED */ + 187, /* (338) nm ::= STRING */ + 187, /* (339) nm ::= JOIN_KW */ + 201, /* (340) typetoken ::= typename */ + 202, /* (341) typename ::= ID|STRING */ + 203, /* (342) signed ::= plus_num */ + 203, /* (343) signed ::= minus_num */ + 200, /* (344) carglist ::= carglist ccons */ + 200, /* (345) carglist ::= */ + 208, /* (346) ccons ::= NULL onconf */ + 196, /* (347) conslist_opt ::= COMMA conslist */ + 220, /* (348) conslist ::= conslist tconscomma tcons */ + 220, /* (349) conslist ::= tcons */ + 221, /* (350) tconscomma ::= */ + 225, /* (351) defer_subclause_opt ::= defer_subclause */ + 227, /* (352) resolvetype ::= raisetype */ + 231, /* (353) selectnowith ::= oneselect */ + 232, /* (354) oneselect ::= values */ + 246, /* (355) sclp ::= selcollist COMMA */ + 247, /* (356) as ::= ID|STRING */ + 210, /* (357) expr ::= term */ + 264, /* (358) likeop ::= LIKE_KW|MATCH */ + 254, /* (359) exprlist ::= nexprlist */ + 274, /* (360) nmnum ::= plus_num */ + 274, /* (361) nmnum ::= nm */ + 274, /* (362) nmnum ::= ON */ + 274, /* (363) nmnum ::= DELETE */ + 274, /* (364) nmnum ::= DEFAULT */ + 204, /* (365) plus_num ::= INTEGER|FLOAT */ + 279, /* (366) foreach_clause ::= */ + 279, /* (367) foreach_clause ::= FOR EACH ROW */ + 282, /* (368) trnm ::= nm */ + 283, /* (369) tridxby ::= */ + 284, /* (370) database_kw_opt ::= DATABASE */ + 284, /* (371) database_kw_opt ::= */ + 287, /* (372) kwcolumn_opt ::= */ + 287, /* (373) kwcolumn_opt ::= COLUMNKW */ + 289, /* (374) vtabarglist ::= vtabarg */ + 289, /* (375) vtabarglist ::= vtabarglist COMMA vtabarg */ + 290, /* (376) vtabarg ::= vtabarg vtabargtoken */ + 293, /* (377) anylist ::= */ + 293, /* (378) anylist ::= anylist LP anylist RP */ + 293, /* (379) anylist ::= anylist ANY */ + 258, /* (380) with ::= */ }; /* For rule J, yyRuleInfoNRhs[J] contains the negative of the number @@ -155156,348 +152507,344 @@ static const signed char yyRuleInfoNRhs[] = { -4, /* (40) ccons ::= REFERENCES nm eidlist_opt refargs */ -1, /* (41) ccons ::= defer_subclause */ -2, /* (42) ccons ::= COLLATE ID|STRING */ - -3, /* (43) generated ::= LP expr RP */ - -4, /* (44) generated ::= LP expr RP ID */ - 0, /* (45) autoinc ::= */ - -1, /* (46) autoinc ::= AUTOINCR */ - 0, /* (47) refargs ::= */ - -2, /* (48) refargs ::= refargs refarg */ - -2, /* (49) refarg ::= MATCH nm */ - -3, /* (50) refarg ::= ON INSERT refact */ - -3, /* (51) refarg ::= ON DELETE refact */ - -3, /* (52) refarg ::= ON UPDATE refact */ - -2, /* (53) refact ::= SET NULL */ - -2, /* (54) refact ::= SET DEFAULT */ - -1, /* (55) refact ::= CASCADE */ - -1, /* (56) refact ::= RESTRICT */ - -2, /* (57) refact ::= NO ACTION */ - -3, /* (58) defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt */ - -2, /* (59) defer_subclause ::= DEFERRABLE init_deferred_pred_opt */ - 0, /* (60) init_deferred_pred_opt ::= */ - -2, /* (61) init_deferred_pred_opt ::= INITIALLY DEFERRED */ - -2, /* (62) init_deferred_pred_opt ::= INITIALLY IMMEDIATE */ - 0, /* (63) conslist_opt ::= */ - -1, /* (64) tconscomma ::= COMMA */ - -2, /* (65) tcons ::= CONSTRAINT nm */ - -7, /* (66) tcons ::= PRIMARY KEY LP sortlist autoinc RP onconf */ - -5, /* (67) tcons ::= UNIQUE LP sortlist RP onconf */ - -5, /* (68) tcons ::= CHECK LP expr RP onconf */ - -10, /* (69) tcons ::= FOREIGN KEY LP eidlist RP REFERENCES nm eidlist_opt refargs defer_subclause_opt */ - 0, /* (70) defer_subclause_opt ::= */ - 0, /* (71) onconf ::= */ - -3, /* (72) onconf ::= ON CONFLICT resolvetype */ - 0, /* (73) orconf ::= */ - -2, /* (74) orconf ::= OR resolvetype */ - -1, /* (75) resolvetype ::= IGNORE */ - -1, /* (76) resolvetype ::= REPLACE */ - -4, /* (77) cmd ::= DROP TABLE ifexists fullname */ - -2, /* (78) ifexists ::= IF EXISTS */ - 0, /* (79) ifexists ::= */ - -9, /* (80) cmd ::= createkw temp VIEW ifnotexists nm dbnm eidlist_opt AS select */ - -4, /* (81) cmd ::= DROP VIEW ifexists fullname */ - -1, /* (82) cmd ::= select */ - -3, /* (83) select ::= WITH wqlist selectnowith */ - -4, /* (84) select ::= WITH RECURSIVE wqlist selectnowith */ - -1, /* (85) select ::= selectnowith */ - -3, /* (86) selectnowith ::= selectnowith multiselect_op oneselect */ - -1, /* (87) multiselect_op ::= UNION */ - -2, /* (88) multiselect_op ::= UNION ALL */ - -1, /* (89) multiselect_op ::= EXCEPT|INTERSECT */ - -9, /* (90) oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt */ - -10, /* (91) oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt window_clause orderby_opt limit_opt */ - -4, /* (92) values ::= VALUES LP nexprlist RP */ - -5, /* (93) values ::= values COMMA LP nexprlist RP */ - -1, /* (94) distinct ::= DISTINCT */ - -1, /* (95) distinct ::= ALL */ - 0, /* (96) distinct ::= */ - 0, /* (97) sclp ::= */ - -5, /* (98) selcollist ::= sclp scanpt expr scanpt as */ - -3, /* (99) selcollist ::= sclp scanpt STAR */ - -5, /* (100) selcollist ::= sclp scanpt nm DOT STAR */ - -2, /* (101) as ::= AS nm */ - 0, /* (102) as ::= */ - 0, /* (103) from ::= */ - -2, /* (104) from ::= FROM seltablist */ - -2, /* (105) stl_prefix ::= seltablist joinop */ - 0, /* (106) stl_prefix ::= */ - -7, /* (107) seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt */ - -9, /* (108) seltablist ::= stl_prefix nm dbnm LP exprlist RP as on_opt using_opt */ - -7, /* (109) seltablist ::= stl_prefix LP select RP as on_opt using_opt */ - -7, /* (110) seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt */ - 0, /* (111) dbnm ::= */ - -2, /* (112) dbnm ::= DOT nm */ - -1, /* (113) fullname ::= nm */ - -3, /* (114) fullname ::= nm DOT nm */ - -1, /* (115) xfullname ::= nm */ - -3, /* (116) xfullname ::= nm DOT nm */ - -5, /* (117) xfullname ::= nm DOT nm AS nm */ - -3, /* (118) xfullname ::= nm AS nm */ - -1, /* (119) joinop ::= COMMA|JOIN */ - -2, /* (120) joinop ::= JOIN_KW JOIN */ - -3, /* (121) joinop ::= JOIN_KW nm JOIN */ - -4, /* (122) joinop ::= JOIN_KW nm nm JOIN */ - -2, /* (123) on_opt ::= ON expr */ - 0, /* (124) on_opt ::= */ - 0, /* (125) indexed_opt ::= */ - -3, /* (126) indexed_opt ::= INDEXED BY nm */ - -2, /* (127) indexed_opt ::= NOT INDEXED */ - -4, /* (128) using_opt ::= USING LP idlist RP */ - 0, /* (129) using_opt ::= */ - 0, /* (130) orderby_opt ::= */ - -3, /* (131) orderby_opt ::= ORDER BY sortlist */ - -5, /* (132) sortlist ::= sortlist COMMA expr sortorder nulls */ - -3, /* (133) sortlist ::= expr sortorder nulls */ - -1, /* (134) sortorder ::= ASC */ - -1, /* (135) sortorder ::= DESC */ - 0, /* (136) sortorder ::= */ - -2, /* (137) nulls ::= NULLS FIRST */ - -2, /* (138) nulls ::= NULLS LAST */ - 0, /* (139) nulls ::= */ - 0, /* (140) groupby_opt ::= */ - -3, /* (141) groupby_opt ::= GROUP BY nexprlist */ - 0, /* (142) having_opt ::= */ - -2, /* (143) having_opt ::= HAVING expr */ - 0, /* (144) limit_opt ::= */ - -2, /* (145) limit_opt ::= LIMIT expr */ - -4, /* (146) limit_opt ::= LIMIT expr OFFSET expr */ - -4, /* (147) limit_opt ::= LIMIT expr COMMA expr */ - -6, /* (148) cmd ::= with DELETE FROM xfullname indexed_opt where_opt */ - 0, /* (149) where_opt ::= */ - -2, /* (150) where_opt ::= WHERE expr */ - -8, /* (151) cmd ::= with UPDATE orconf xfullname indexed_opt SET setlist where_opt */ - -5, /* (152) setlist ::= setlist COMMA nm EQ expr */ - -7, /* (153) setlist ::= setlist COMMA LP idlist RP EQ expr */ - -3, /* (154) setlist ::= nm EQ expr */ - -5, /* (155) setlist ::= LP idlist RP EQ expr */ - -7, /* (156) cmd ::= with insert_cmd INTO xfullname idlist_opt select upsert */ - -7, /* (157) cmd ::= with insert_cmd INTO xfullname idlist_opt DEFAULT VALUES */ - 0, /* (158) upsert ::= */ - -11, /* (159) upsert ::= ON CONFLICT LP sortlist RP where_opt DO UPDATE SET setlist where_opt */ - -8, /* (160) upsert ::= ON CONFLICT LP sortlist RP where_opt DO NOTHING */ - -4, /* (161) upsert ::= ON CONFLICT DO NOTHING */ - -2, /* (162) insert_cmd ::= INSERT orconf */ - -1, /* (163) insert_cmd ::= REPLACE */ - 0, /* (164) idlist_opt ::= */ - -3, /* (165) idlist_opt ::= LP idlist RP */ - -3, /* (166) idlist ::= idlist COMMA nm */ - -1, /* (167) idlist ::= nm */ - -3, /* (168) expr ::= LP expr RP */ - -1, /* (169) expr ::= ID|INDEXED */ - -1, /* (170) expr ::= JOIN_KW */ - -3, /* (171) expr ::= nm DOT nm */ - -5, /* (172) expr ::= nm DOT nm DOT nm */ - -1, /* (173) term ::= NULL|FLOAT|BLOB */ - -1, /* (174) term ::= STRING */ - -1, /* (175) term ::= INTEGER */ - -1, /* (176) expr ::= VARIABLE */ - -3, /* (177) expr ::= expr COLLATE ID|STRING */ - -6, /* (178) expr ::= CAST LP expr AS typetoken RP */ - -5, /* (179) expr ::= ID|INDEXED LP distinct exprlist RP */ - -4, /* (180) expr ::= ID|INDEXED LP STAR RP */ - -6, /* (181) expr ::= ID|INDEXED LP distinct exprlist RP filter_over */ - -5, /* (182) expr ::= ID|INDEXED LP STAR RP filter_over */ - -1, /* (183) term ::= CTIME_KW */ - -5, /* (184) expr ::= LP nexprlist COMMA expr RP */ - -3, /* (185) expr ::= expr AND expr */ - -3, /* (186) expr ::= expr OR expr */ - -3, /* (187) expr ::= expr LT|GT|GE|LE expr */ - -3, /* (188) expr ::= expr EQ|NE expr */ - -3, /* (189) expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */ - -3, /* (190) expr ::= expr PLUS|MINUS expr */ - -3, /* (191) expr ::= expr STAR|SLASH|REM expr */ - -3, /* (192) expr ::= expr CONCAT expr */ - -2, /* (193) likeop ::= NOT LIKE_KW|MATCH */ - -3, /* (194) expr ::= expr likeop expr */ - -5, /* (195) expr ::= expr likeop expr ESCAPE expr */ - -2, /* (196) expr ::= expr ISNULL|NOTNULL */ - -3, /* (197) expr ::= expr NOT NULL */ - -3, /* (198) expr ::= expr IS expr */ - -4, /* (199) expr ::= expr IS NOT expr */ - -2, /* (200) expr ::= NOT expr */ - -2, /* (201) expr ::= BITNOT expr */ - -2, /* (202) expr ::= PLUS|MINUS expr */ - -1, /* (203) between_op ::= BETWEEN */ - -2, /* (204) between_op ::= NOT BETWEEN */ - -5, /* (205) expr ::= expr between_op expr AND expr */ - -1, /* (206) in_op ::= IN */ - -2, /* (207) in_op ::= NOT IN */ - -5, /* (208) expr ::= expr in_op LP exprlist RP */ - -3, /* (209) expr ::= LP select RP */ - -5, /* (210) expr ::= expr in_op LP select RP */ - -5, /* (211) expr ::= expr in_op nm dbnm paren_exprlist */ - -4, /* (212) expr ::= EXISTS LP select RP */ - -5, /* (213) expr ::= CASE case_operand case_exprlist case_else END */ - -5, /* (214) case_exprlist ::= case_exprlist WHEN expr THEN expr */ - -4, /* (215) case_exprlist ::= WHEN expr THEN expr */ - -2, /* (216) case_else ::= ELSE expr */ - 0, /* (217) case_else ::= */ - -1, /* (218) case_operand ::= expr */ - 0, /* (219) case_operand ::= */ - 0, /* (220) exprlist ::= */ - -3, /* (221) nexprlist ::= nexprlist COMMA expr */ - -1, /* (222) nexprlist ::= expr */ - 0, /* (223) paren_exprlist ::= */ - -3, /* (224) paren_exprlist ::= LP exprlist RP */ - -12, /* (225) cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */ - -1, /* (226) uniqueflag ::= UNIQUE */ - 0, /* (227) uniqueflag ::= */ - 0, /* (228) eidlist_opt ::= */ - -3, /* (229) eidlist_opt ::= LP eidlist RP */ - -5, /* (230) eidlist ::= eidlist COMMA nm collate sortorder */ - -3, /* (231) eidlist ::= nm collate sortorder */ - 0, /* (232) collate ::= */ - -2, /* (233) collate ::= COLLATE ID|STRING */ - -4, /* (234) cmd ::= DROP INDEX ifexists fullname */ - -2, /* (235) cmd ::= VACUUM vinto */ - -3, /* (236) cmd ::= VACUUM nm vinto */ - -2, /* (237) vinto ::= INTO expr */ - 0, /* (238) vinto ::= */ - -3, /* (239) cmd ::= PRAGMA nm dbnm */ - -5, /* (240) cmd ::= PRAGMA nm dbnm EQ nmnum */ - -6, /* (241) cmd ::= PRAGMA nm dbnm LP nmnum RP */ - -5, /* (242) cmd ::= PRAGMA nm dbnm EQ minus_num */ - -6, /* (243) cmd ::= PRAGMA nm dbnm LP minus_num RP */ - -2, /* (244) plus_num ::= PLUS INTEGER|FLOAT */ - -2, /* (245) minus_num ::= MINUS INTEGER|FLOAT */ - -5, /* (246) cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */ - -11, /* (247) trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */ - -1, /* (248) trigger_time ::= BEFORE|AFTER */ - -2, /* (249) trigger_time ::= INSTEAD OF */ - 0, /* (250) trigger_time ::= */ - -1, /* (251) trigger_event ::= DELETE|INSERT */ - -1, /* (252) trigger_event ::= UPDATE */ - -3, /* (253) trigger_event ::= UPDATE OF idlist */ - 0, /* (254) when_clause ::= */ - -2, /* (255) when_clause ::= WHEN expr */ - -3, /* (256) trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */ - -2, /* (257) trigger_cmd_list ::= trigger_cmd SEMI */ - -3, /* (258) trnm ::= nm DOT nm */ - -3, /* (259) tridxby ::= INDEXED BY nm */ - -2, /* (260) tridxby ::= NOT INDEXED */ - -8, /* (261) trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt scanpt */ - -8, /* (262) trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt */ - -6, /* (263) trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt */ - -3, /* (264) trigger_cmd ::= scanpt select scanpt */ - -4, /* (265) expr ::= RAISE LP IGNORE RP */ - -6, /* (266) expr ::= RAISE LP raisetype COMMA nm RP */ - -1, /* (267) raisetype ::= ROLLBACK */ - -1, /* (268) raisetype ::= ABORT */ - -1, /* (269) raisetype ::= FAIL */ - -4, /* (270) cmd ::= DROP TRIGGER ifexists fullname */ - -6, /* (271) cmd ::= ATTACH database_kw_opt expr AS expr key_opt */ - -3, /* (272) cmd ::= DETACH database_kw_opt expr */ - 0, /* (273) key_opt ::= */ - -2, /* (274) key_opt ::= KEY expr */ - -1, /* (275) cmd ::= REINDEX */ - -3, /* (276) cmd ::= REINDEX nm dbnm */ - -1, /* (277) cmd ::= ANALYZE */ - -3, /* (278) cmd ::= ANALYZE nm dbnm */ - -6, /* (279) cmd ::= ALTER TABLE fullname RENAME TO nm */ - -7, /* (280) cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */ - -1, /* (281) add_column_fullname ::= fullname */ - -8, /* (282) cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm */ - -1, /* (283) cmd ::= create_vtab */ - -4, /* (284) cmd ::= create_vtab LP vtabarglist RP */ - -8, /* (285) create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */ - 0, /* (286) vtabarg ::= */ - -1, /* (287) vtabargtoken ::= ANY */ - -3, /* (288) vtabargtoken ::= lp anylist RP */ - -1, /* (289) lp ::= LP */ - -2, /* (290) with ::= WITH wqlist */ - -3, /* (291) with ::= WITH RECURSIVE wqlist */ - -6, /* (292) wqlist ::= nm eidlist_opt AS LP select RP */ - -8, /* (293) wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP */ - -1, /* (294) windowdefn_list ::= windowdefn */ - -3, /* (295) windowdefn_list ::= windowdefn_list COMMA windowdefn */ - -5, /* (296) windowdefn ::= nm AS LP window RP */ - -5, /* (297) window ::= PARTITION BY nexprlist orderby_opt frame_opt */ - -6, /* (298) window ::= nm PARTITION BY nexprlist orderby_opt frame_opt */ - -4, /* (299) window ::= ORDER BY sortlist frame_opt */ - -5, /* (300) window ::= nm ORDER BY sortlist frame_opt */ - -1, /* (301) window ::= frame_opt */ - -2, /* (302) window ::= nm frame_opt */ - 0, /* (303) frame_opt ::= */ - -3, /* (304) frame_opt ::= range_or_rows frame_bound_s frame_exclude_opt */ - -6, /* (305) frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e frame_exclude_opt */ - -1, /* (306) range_or_rows ::= RANGE|ROWS|GROUPS */ - -1, /* (307) frame_bound_s ::= frame_bound */ - -2, /* (308) frame_bound_s ::= UNBOUNDED PRECEDING */ - -1, /* (309) frame_bound_e ::= frame_bound */ - -2, /* (310) frame_bound_e ::= UNBOUNDED FOLLOWING */ - -2, /* (311) frame_bound ::= expr PRECEDING|FOLLOWING */ - -2, /* (312) frame_bound ::= CURRENT ROW */ - 0, /* (313) frame_exclude_opt ::= */ - -2, /* (314) frame_exclude_opt ::= EXCLUDE frame_exclude */ - -2, /* (315) frame_exclude ::= NO OTHERS */ - -2, /* (316) frame_exclude ::= CURRENT ROW */ - -1, /* (317) frame_exclude ::= GROUP|TIES */ - -2, /* (318) window_clause ::= WINDOW windowdefn_list */ - -2, /* (319) filter_over ::= filter_clause over_clause */ - -1, /* (320) filter_over ::= over_clause */ - -1, /* (321) filter_over ::= filter_clause */ - -4, /* (322) over_clause ::= OVER LP window RP */ - -2, /* (323) over_clause ::= OVER nm */ - -5, /* (324) filter_clause ::= FILTER LP WHERE expr RP */ - -1, /* (325) input ::= cmdlist */ - -2, /* (326) cmdlist ::= cmdlist ecmd */ - -1, /* (327) cmdlist ::= ecmd */ - -1, /* (328) ecmd ::= SEMI */ - -2, /* (329) ecmd ::= cmdx SEMI */ - -3, /* (330) ecmd ::= explain cmdx SEMI */ - 0, /* (331) trans_opt ::= */ - -1, /* (332) trans_opt ::= TRANSACTION */ - -2, /* (333) trans_opt ::= TRANSACTION nm */ - -1, /* (334) savepoint_opt ::= SAVEPOINT */ - 0, /* (335) savepoint_opt ::= */ - -2, /* (336) cmd ::= create_table create_table_args */ - -4, /* (337) columnlist ::= columnlist COMMA columnname carglist */ - -2, /* (338) columnlist ::= columnname carglist */ - -1, /* (339) nm ::= ID|INDEXED */ - -1, /* (340) nm ::= STRING */ - -1, /* (341) nm ::= JOIN_KW */ - -1, /* (342) typetoken ::= typename */ - -1, /* (343) typename ::= ID|STRING */ - -1, /* (344) signed ::= plus_num */ - -1, /* (345) signed ::= minus_num */ - -2, /* (346) carglist ::= carglist ccons */ - 0, /* (347) carglist ::= */ - -2, /* (348) ccons ::= NULL onconf */ - -4, /* (349) ccons ::= GENERATED ALWAYS AS generated */ - -2, /* (350) ccons ::= AS generated */ - -2, /* (351) conslist_opt ::= COMMA conslist */ - -3, /* (352) conslist ::= conslist tconscomma tcons */ - -1, /* (353) conslist ::= tcons */ - 0, /* (354) tconscomma ::= */ - -1, /* (355) defer_subclause_opt ::= defer_subclause */ - -1, /* (356) resolvetype ::= raisetype */ - -1, /* (357) selectnowith ::= oneselect */ - -1, /* (358) oneselect ::= values */ - -2, /* (359) sclp ::= selcollist COMMA */ - -1, /* (360) as ::= ID|STRING */ - -1, /* (361) expr ::= term */ - -1, /* (362) likeop ::= LIKE_KW|MATCH */ - -1, /* (363) exprlist ::= nexprlist */ - -1, /* (364) nmnum ::= plus_num */ - -1, /* (365) nmnum ::= nm */ - -1, /* (366) nmnum ::= ON */ - -1, /* (367) nmnum ::= DELETE */ - -1, /* (368) nmnum ::= DEFAULT */ - -1, /* (369) plus_num ::= INTEGER|FLOAT */ - 0, /* (370) foreach_clause ::= */ - -3, /* (371) foreach_clause ::= FOR EACH ROW */ - -1, /* (372) trnm ::= nm */ - 0, /* (373) tridxby ::= */ - -1, /* (374) database_kw_opt ::= DATABASE */ - 0, /* (375) database_kw_opt ::= */ - 0, /* (376) kwcolumn_opt ::= */ - -1, /* (377) kwcolumn_opt ::= COLUMNKW */ - -1, /* (378) vtabarglist ::= vtabarg */ - -3, /* (379) vtabarglist ::= vtabarglist COMMA vtabarg */ - -2, /* (380) vtabarg ::= vtabarg vtabargtoken */ - 0, /* (381) anylist ::= */ - -4, /* (382) anylist ::= anylist LP anylist RP */ - -2, /* (383) anylist ::= anylist ANY */ - 0, /* (384) with ::= */ + 0, /* (43) autoinc ::= */ + -1, /* (44) autoinc ::= AUTOINCR */ + 0, /* (45) refargs ::= */ + -2, /* (46) refargs ::= refargs refarg */ + -2, /* (47) refarg ::= MATCH nm */ + -3, /* (48) refarg ::= ON INSERT refact */ + -3, /* (49) refarg ::= ON DELETE refact */ + -3, /* (50) refarg ::= ON UPDATE refact */ + -2, /* (51) refact ::= SET NULL */ + -2, /* (52) refact ::= SET DEFAULT */ + -1, /* (53) refact ::= CASCADE */ + -1, /* (54) refact ::= RESTRICT */ + -2, /* (55) refact ::= NO ACTION */ + -3, /* (56) defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt */ + -2, /* (57) defer_subclause ::= DEFERRABLE init_deferred_pred_opt */ + 0, /* (58) init_deferred_pred_opt ::= */ + -2, /* (59) init_deferred_pred_opt ::= INITIALLY DEFERRED */ + -2, /* (60) init_deferred_pred_opt ::= INITIALLY IMMEDIATE */ + 0, /* (61) conslist_opt ::= */ + -1, /* (62) tconscomma ::= COMMA */ + -2, /* (63) tcons ::= CONSTRAINT nm */ + -7, /* (64) tcons ::= PRIMARY KEY LP sortlist autoinc RP onconf */ + -5, /* (65) tcons ::= UNIQUE LP sortlist RP onconf */ + -5, /* (66) tcons ::= CHECK LP expr RP onconf */ + -10, /* (67) tcons ::= FOREIGN KEY LP eidlist RP REFERENCES nm eidlist_opt refargs defer_subclause_opt */ + 0, /* (68) defer_subclause_opt ::= */ + 0, /* (69) onconf ::= */ + -3, /* (70) onconf ::= ON CONFLICT resolvetype */ + 0, /* (71) orconf ::= */ + -2, /* (72) orconf ::= OR resolvetype */ + -1, /* (73) resolvetype ::= IGNORE */ + -1, /* (74) resolvetype ::= REPLACE */ + -4, /* (75) cmd ::= DROP TABLE ifexists fullname */ + -2, /* (76) ifexists ::= IF EXISTS */ + 0, /* (77) ifexists ::= */ + -9, /* (78) cmd ::= createkw temp VIEW ifnotexists nm dbnm eidlist_opt AS select */ + -4, /* (79) cmd ::= DROP VIEW ifexists fullname */ + -1, /* (80) cmd ::= select */ + -3, /* (81) select ::= WITH wqlist selectnowith */ + -4, /* (82) select ::= WITH RECURSIVE wqlist selectnowith */ + -1, /* (83) select ::= selectnowith */ + -3, /* (84) selectnowith ::= selectnowith multiselect_op oneselect */ + -1, /* (85) multiselect_op ::= UNION */ + -2, /* (86) multiselect_op ::= UNION ALL */ + -1, /* (87) multiselect_op ::= EXCEPT|INTERSECT */ + -9, /* (88) oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt */ + -10, /* (89) oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt window_clause orderby_opt limit_opt */ + -4, /* (90) values ::= VALUES LP nexprlist RP */ + -5, /* (91) values ::= values COMMA LP nexprlist RP */ + -1, /* (92) distinct ::= DISTINCT */ + -1, /* (93) distinct ::= ALL */ + 0, /* (94) distinct ::= */ + 0, /* (95) sclp ::= */ + -5, /* (96) selcollist ::= sclp scanpt expr scanpt as */ + -3, /* (97) selcollist ::= sclp scanpt STAR */ + -5, /* (98) selcollist ::= sclp scanpt nm DOT STAR */ + -2, /* (99) as ::= AS nm */ + 0, /* (100) as ::= */ + 0, /* (101) from ::= */ + -2, /* (102) from ::= FROM seltablist */ + -2, /* (103) stl_prefix ::= seltablist joinop */ + 0, /* (104) stl_prefix ::= */ + -7, /* (105) seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt */ + -9, /* (106) seltablist ::= stl_prefix nm dbnm LP exprlist RP as on_opt using_opt */ + -7, /* (107) seltablist ::= stl_prefix LP select RP as on_opt using_opt */ + -7, /* (108) seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt */ + 0, /* (109) dbnm ::= */ + -2, /* (110) dbnm ::= DOT nm */ + -1, /* (111) fullname ::= nm */ + -3, /* (112) fullname ::= nm DOT nm */ + -1, /* (113) xfullname ::= nm */ + -3, /* (114) xfullname ::= nm DOT nm */ + -5, /* (115) xfullname ::= nm DOT nm AS nm */ + -3, /* (116) xfullname ::= nm AS nm */ + -1, /* (117) joinop ::= COMMA|JOIN */ + -2, /* (118) joinop ::= JOIN_KW JOIN */ + -3, /* (119) joinop ::= JOIN_KW nm JOIN */ + -4, /* (120) joinop ::= JOIN_KW nm nm JOIN */ + -2, /* (121) on_opt ::= ON expr */ + 0, /* (122) on_opt ::= */ + 0, /* (123) indexed_opt ::= */ + -3, /* (124) indexed_opt ::= INDEXED BY nm */ + -2, /* (125) indexed_opt ::= NOT INDEXED */ + -4, /* (126) using_opt ::= USING LP idlist RP */ + 0, /* (127) using_opt ::= */ + 0, /* (128) orderby_opt ::= */ + -3, /* (129) orderby_opt ::= ORDER BY sortlist */ + -5, /* (130) sortlist ::= sortlist COMMA expr sortorder nulls */ + -3, /* (131) sortlist ::= expr sortorder nulls */ + -1, /* (132) sortorder ::= ASC */ + -1, /* (133) sortorder ::= DESC */ + 0, /* (134) sortorder ::= */ + -2, /* (135) nulls ::= NULLS FIRST */ + -2, /* (136) nulls ::= NULLS LAST */ + 0, /* (137) nulls ::= */ + 0, /* (138) groupby_opt ::= */ + -3, /* (139) groupby_opt ::= GROUP BY nexprlist */ + 0, /* (140) having_opt ::= */ + -2, /* (141) having_opt ::= HAVING expr */ + 0, /* (142) limit_opt ::= */ + -2, /* (143) limit_opt ::= LIMIT expr */ + -4, /* (144) limit_opt ::= LIMIT expr OFFSET expr */ + -4, /* (145) limit_opt ::= LIMIT expr COMMA expr */ + -6, /* (146) cmd ::= with DELETE FROM xfullname indexed_opt where_opt */ + 0, /* (147) where_opt ::= */ + -2, /* (148) where_opt ::= WHERE expr */ + -8, /* (149) cmd ::= with UPDATE orconf xfullname indexed_opt SET setlist where_opt */ + -5, /* (150) setlist ::= setlist COMMA nm EQ expr */ + -7, /* (151) setlist ::= setlist COMMA LP idlist RP EQ expr */ + -3, /* (152) setlist ::= nm EQ expr */ + -5, /* (153) setlist ::= LP idlist RP EQ expr */ + -7, /* (154) cmd ::= with insert_cmd INTO xfullname idlist_opt select upsert */ + -7, /* (155) cmd ::= with insert_cmd INTO xfullname idlist_opt DEFAULT VALUES */ + 0, /* (156) upsert ::= */ + -11, /* (157) upsert ::= ON CONFLICT LP sortlist RP where_opt DO UPDATE SET setlist where_opt */ + -8, /* (158) upsert ::= ON CONFLICT LP sortlist RP where_opt DO NOTHING */ + -4, /* (159) upsert ::= ON CONFLICT DO NOTHING */ + -2, /* (160) insert_cmd ::= INSERT orconf */ + -1, /* (161) insert_cmd ::= REPLACE */ + 0, /* (162) idlist_opt ::= */ + -3, /* (163) idlist_opt ::= LP idlist RP */ + -3, /* (164) idlist ::= idlist COMMA nm */ + -1, /* (165) idlist ::= nm */ + -3, /* (166) expr ::= LP expr RP */ + -1, /* (167) expr ::= ID|INDEXED */ + -1, /* (168) expr ::= JOIN_KW */ + -3, /* (169) expr ::= nm DOT nm */ + -5, /* (170) expr ::= nm DOT nm DOT nm */ + -1, /* (171) term ::= NULL|FLOAT|BLOB */ + -1, /* (172) term ::= STRING */ + -1, /* (173) term ::= INTEGER */ + -1, /* (174) expr ::= VARIABLE */ + -3, /* (175) expr ::= expr COLLATE ID|STRING */ + -6, /* (176) expr ::= CAST LP expr AS typetoken RP */ + -5, /* (177) expr ::= ID|INDEXED LP distinct exprlist RP */ + -4, /* (178) expr ::= ID|INDEXED LP STAR RP */ + -6, /* (179) expr ::= ID|INDEXED LP distinct exprlist RP filter_over */ + -5, /* (180) expr ::= ID|INDEXED LP STAR RP filter_over */ + -1, /* (181) term ::= CTIME_KW */ + -5, /* (182) expr ::= LP nexprlist COMMA expr RP */ + -3, /* (183) expr ::= expr AND expr */ + -3, /* (184) expr ::= expr OR expr */ + -3, /* (185) expr ::= expr LT|GT|GE|LE expr */ + -3, /* (186) expr ::= expr EQ|NE expr */ + -3, /* (187) expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */ + -3, /* (188) expr ::= expr PLUS|MINUS expr */ + -3, /* (189) expr ::= expr STAR|SLASH|REM expr */ + -3, /* (190) expr ::= expr CONCAT expr */ + -2, /* (191) likeop ::= NOT LIKE_KW|MATCH */ + -3, /* (192) expr ::= expr likeop expr */ + -5, /* (193) expr ::= expr likeop expr ESCAPE expr */ + -2, /* (194) expr ::= expr ISNULL|NOTNULL */ + -3, /* (195) expr ::= expr NOT NULL */ + -3, /* (196) expr ::= expr IS expr */ + -4, /* (197) expr ::= expr IS NOT expr */ + -2, /* (198) expr ::= NOT expr */ + -2, /* (199) expr ::= BITNOT expr */ + -2, /* (200) expr ::= PLUS|MINUS expr */ + -1, /* (201) between_op ::= BETWEEN */ + -2, /* (202) between_op ::= NOT BETWEEN */ + -5, /* (203) expr ::= expr between_op expr AND expr */ + -1, /* (204) in_op ::= IN */ + -2, /* (205) in_op ::= NOT IN */ + -5, /* (206) expr ::= expr in_op LP exprlist RP */ + -3, /* (207) expr ::= LP select RP */ + -5, /* (208) expr ::= expr in_op LP select RP */ + -5, /* (209) expr ::= expr in_op nm dbnm paren_exprlist */ + -4, /* (210) expr ::= EXISTS LP select RP */ + -5, /* (211) expr ::= CASE case_operand case_exprlist case_else END */ + -5, /* (212) case_exprlist ::= case_exprlist WHEN expr THEN expr */ + -4, /* (213) case_exprlist ::= WHEN expr THEN expr */ + -2, /* (214) case_else ::= ELSE expr */ + 0, /* (215) case_else ::= */ + -1, /* (216) case_operand ::= expr */ + 0, /* (217) case_operand ::= */ + 0, /* (218) exprlist ::= */ + -3, /* (219) nexprlist ::= nexprlist COMMA expr */ + -1, /* (220) nexprlist ::= expr */ + 0, /* (221) paren_exprlist ::= */ + -3, /* (222) paren_exprlist ::= LP exprlist RP */ + -12, /* (223) cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */ + -1, /* (224) uniqueflag ::= UNIQUE */ + 0, /* (225) uniqueflag ::= */ + 0, /* (226) eidlist_opt ::= */ + -3, /* (227) eidlist_opt ::= LP eidlist RP */ + -5, /* (228) eidlist ::= eidlist COMMA nm collate sortorder */ + -3, /* (229) eidlist ::= nm collate sortorder */ + 0, /* (230) collate ::= */ + -2, /* (231) collate ::= COLLATE ID|STRING */ + -4, /* (232) cmd ::= DROP INDEX ifexists fullname */ + -2, /* (233) cmd ::= VACUUM vinto */ + -3, /* (234) cmd ::= VACUUM nm vinto */ + -2, /* (235) vinto ::= INTO expr */ + 0, /* (236) vinto ::= */ + -3, /* (237) cmd ::= PRAGMA nm dbnm */ + -5, /* (238) cmd ::= PRAGMA nm dbnm EQ nmnum */ + -6, /* (239) cmd ::= PRAGMA nm dbnm LP nmnum RP */ + -5, /* (240) cmd ::= PRAGMA nm dbnm EQ minus_num */ + -6, /* (241) cmd ::= PRAGMA nm dbnm LP minus_num RP */ + -2, /* (242) plus_num ::= PLUS INTEGER|FLOAT */ + -2, /* (243) minus_num ::= MINUS INTEGER|FLOAT */ + -5, /* (244) cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */ + -11, /* (245) trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */ + -1, /* (246) trigger_time ::= BEFORE|AFTER */ + -2, /* (247) trigger_time ::= INSTEAD OF */ + 0, /* (248) trigger_time ::= */ + -1, /* (249) trigger_event ::= DELETE|INSERT */ + -1, /* (250) trigger_event ::= UPDATE */ + -3, /* (251) trigger_event ::= UPDATE OF idlist */ + 0, /* (252) when_clause ::= */ + -2, /* (253) when_clause ::= WHEN expr */ + -3, /* (254) trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */ + -2, /* (255) trigger_cmd_list ::= trigger_cmd SEMI */ + -3, /* (256) trnm ::= nm DOT nm */ + -3, /* (257) tridxby ::= INDEXED BY nm */ + -2, /* (258) tridxby ::= NOT INDEXED */ + -8, /* (259) trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt scanpt */ + -8, /* (260) trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt */ + -6, /* (261) trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt */ + -3, /* (262) trigger_cmd ::= scanpt select scanpt */ + -4, /* (263) expr ::= RAISE LP IGNORE RP */ + -6, /* (264) expr ::= RAISE LP raisetype COMMA nm RP */ + -1, /* (265) raisetype ::= ROLLBACK */ + -1, /* (266) raisetype ::= ABORT */ + -1, /* (267) raisetype ::= FAIL */ + -4, /* (268) cmd ::= DROP TRIGGER ifexists fullname */ + -6, /* (269) cmd ::= ATTACH database_kw_opt expr AS expr key_opt */ + -3, /* (270) cmd ::= DETACH database_kw_opt expr */ + 0, /* (271) key_opt ::= */ + -2, /* (272) key_opt ::= KEY expr */ + -1, /* (273) cmd ::= REINDEX */ + -3, /* (274) cmd ::= REINDEX nm dbnm */ + -1, /* (275) cmd ::= ANALYZE */ + -3, /* (276) cmd ::= ANALYZE nm dbnm */ + -6, /* (277) cmd ::= ALTER TABLE fullname RENAME TO nm */ + -7, /* (278) cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */ + -1, /* (279) add_column_fullname ::= fullname */ + -8, /* (280) cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm */ + -1, /* (281) cmd ::= create_vtab */ + -4, /* (282) cmd ::= create_vtab LP vtabarglist RP */ + -8, /* (283) create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */ + 0, /* (284) vtabarg ::= */ + -1, /* (285) vtabargtoken ::= ANY */ + -3, /* (286) vtabargtoken ::= lp anylist RP */ + -1, /* (287) lp ::= LP */ + -2, /* (288) with ::= WITH wqlist */ + -3, /* (289) with ::= WITH RECURSIVE wqlist */ + -6, /* (290) wqlist ::= nm eidlist_opt AS LP select RP */ + -8, /* (291) wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP */ + -1, /* (292) windowdefn_list ::= windowdefn */ + -3, /* (293) windowdefn_list ::= windowdefn_list COMMA windowdefn */ + -5, /* (294) windowdefn ::= nm AS LP window RP */ + -5, /* (295) window ::= PARTITION BY nexprlist orderby_opt frame_opt */ + -6, /* (296) window ::= nm PARTITION BY nexprlist orderby_opt frame_opt */ + -4, /* (297) window ::= ORDER BY sortlist frame_opt */ + -5, /* (298) window ::= nm ORDER BY sortlist frame_opt */ + -1, /* (299) window ::= frame_opt */ + -2, /* (300) window ::= nm frame_opt */ + 0, /* (301) frame_opt ::= */ + -3, /* (302) frame_opt ::= range_or_rows frame_bound_s frame_exclude_opt */ + -6, /* (303) frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e frame_exclude_opt */ + -1, /* (304) range_or_rows ::= RANGE|ROWS|GROUPS */ + -1, /* (305) frame_bound_s ::= frame_bound */ + -2, /* (306) frame_bound_s ::= UNBOUNDED PRECEDING */ + -1, /* (307) frame_bound_e ::= frame_bound */ + -2, /* (308) frame_bound_e ::= UNBOUNDED FOLLOWING */ + -2, /* (309) frame_bound ::= expr PRECEDING|FOLLOWING */ + -2, /* (310) frame_bound ::= CURRENT ROW */ + 0, /* (311) frame_exclude_opt ::= */ + -2, /* (312) frame_exclude_opt ::= EXCLUDE frame_exclude */ + -2, /* (313) frame_exclude ::= NO OTHERS */ + -2, /* (314) frame_exclude ::= CURRENT ROW */ + -1, /* (315) frame_exclude ::= GROUP|TIES */ + -2, /* (316) window_clause ::= WINDOW windowdefn_list */ + -2, /* (317) filter_over ::= filter_clause over_clause */ + -1, /* (318) filter_over ::= over_clause */ + -1, /* (319) filter_over ::= filter_clause */ + -4, /* (320) over_clause ::= OVER LP window RP */ + -2, /* (321) over_clause ::= OVER nm */ + -5, /* (322) filter_clause ::= FILTER LP WHERE expr RP */ + -1, /* (323) input ::= cmdlist */ + -2, /* (324) cmdlist ::= cmdlist ecmd */ + -1, /* (325) cmdlist ::= ecmd */ + -1, /* (326) ecmd ::= SEMI */ + -2, /* (327) ecmd ::= cmdx SEMI */ + -2, /* (328) ecmd ::= explain cmdx */ + 0, /* (329) trans_opt ::= */ + -1, /* (330) trans_opt ::= TRANSACTION */ + -2, /* (331) trans_opt ::= TRANSACTION nm */ + -1, /* (332) savepoint_opt ::= SAVEPOINT */ + 0, /* (333) savepoint_opt ::= */ + -2, /* (334) cmd ::= create_table create_table_args */ + -4, /* (335) columnlist ::= columnlist COMMA columnname carglist */ + -2, /* (336) columnlist ::= columnname carglist */ + -1, /* (337) nm ::= ID|INDEXED */ + -1, /* (338) nm ::= STRING */ + -1, /* (339) nm ::= JOIN_KW */ + -1, /* (340) typetoken ::= typename */ + -1, /* (341) typename ::= ID|STRING */ + -1, /* (342) signed ::= plus_num */ + -1, /* (343) signed ::= minus_num */ + -2, /* (344) carglist ::= carglist ccons */ + 0, /* (345) carglist ::= */ + -2, /* (346) ccons ::= NULL onconf */ + -2, /* (347) conslist_opt ::= COMMA conslist */ + -3, /* (348) conslist ::= conslist tconscomma tcons */ + -1, /* (349) conslist ::= tcons */ + 0, /* (350) tconscomma ::= */ + -1, /* (351) defer_subclause_opt ::= defer_subclause */ + -1, /* (352) resolvetype ::= raisetype */ + -1, /* (353) selectnowith ::= oneselect */ + -1, /* (354) oneselect ::= values */ + -2, /* (355) sclp ::= selcollist COMMA */ + -1, /* (356) as ::= ID|STRING */ + -1, /* (357) expr ::= term */ + -1, /* (358) likeop ::= LIKE_KW|MATCH */ + -1, /* (359) exprlist ::= nexprlist */ + -1, /* (360) nmnum ::= plus_num */ + -1, /* (361) nmnum ::= nm */ + -1, /* (362) nmnum ::= ON */ + -1, /* (363) nmnum ::= DELETE */ + -1, /* (364) nmnum ::= DEFAULT */ + -1, /* (365) plus_num ::= INTEGER|FLOAT */ + 0, /* (366) foreach_clause ::= */ + -3, /* (367) foreach_clause ::= FOR EACH ROW */ + -1, /* (368) trnm ::= nm */ + 0, /* (369) tridxby ::= */ + -1, /* (370) database_kw_opt ::= DATABASE */ + 0, /* (371) database_kw_opt ::= */ + 0, /* (372) kwcolumn_opt ::= */ + -1, /* (373) kwcolumn_opt ::= COLUMNKW */ + -1, /* (374) vtabarglist ::= vtabarg */ + -3, /* (375) vtabarglist ::= vtabarglist COMMA vtabarg */ + -2, /* (376) vtabarg ::= vtabarg vtabargtoken */ + 0, /* (377) anylist ::= */ + -4, /* (378) anylist ::= anylist LP anylist RP */ + -2, /* (379) anylist ::= anylist ANY */ + 0, /* (380) with ::= */ }; static void yy_accept(yyParser*); /* Forward Declaration */ @@ -155531,15 +152878,12 @@ static YYACTIONTYPE yy_reduce( if( yyTraceFILE && yyruleno<(int)(sizeof(yyRuleName)/sizeof(yyRuleName[0])) ){ yysize = yyRuleInfoNRhs[yyruleno]; if( yysize ){ - fprintf(yyTraceFILE, "%sReduce %d [%s]%s, pop back to state %d.\n", + fprintf(yyTraceFILE, "%sReduce %d [%s], go to state %d.\n", yyTracePrompt, - yyruleno, yyRuleName[yyruleno], - yyrulenodb, yymsp[0].minor.yy539); + sqlite3EndTable(pParse,0,0,0,yymsp[0].minor.yy25); + sqlite3SelectDelete(pParse->db, yymsp[0].minor.yy25); } break; case 22: /* table_options ::= WITHOUT nm */ { if( yymsp[0].minor.yy0.n==5 && sqlite3_strnicmp(yymsp[0].minor.yy0.z,"rowid",5)==0 ){ - yymsp[-1].minor.yy192 = TF_WithoutRowid | TF_NoVisibleRowid; + yymsp[-1].minor.yy32 = TF_WithoutRowid | TF_NoVisibleRowid; }else{ - yymsp[-1].minor.yy192 = 0; + yymsp[-1].minor.yy32 = 0; sqlite3ErrorMsg(pParse, "unknown table option: %.*s", yymsp[0].minor.yy0.n, yymsp[0].minor.yy0.z); } } @@ -155678,8 +153022,8 @@ static YYACTIONTYPE yy_reduce( {sqlite3AddColumn(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0);} break; case 24: /* typetoken ::= */ - case 63: /* conslist_opt ::= */ yytestcase(yyruleno==63); - case 102: /* as ::= */ yytestcase(yyruleno==102); + case 61: /* conslist_opt ::= */ yytestcase(yyruleno==61); + case 100: /* as ::= */ yytestcase(yyruleno==100); {yymsp[1].minor.yy0.n = 0; yymsp[1].minor.yy0.z = 0;} break; case 25: /* typetoken ::= typename LP signed RP */ @@ -155698,7 +153042,7 @@ static YYACTIONTYPE yy_reduce( case 28: /* scanpt ::= */ { assert( yyLookahead!=YYNOCODE ); - yymsp[1].minor.yy436 = yyLookaheadToken.z; + yymsp[1].minor.yy8 = yyLookaheadToken.z; } break; case 29: /* scantok ::= */ @@ -155708,21 +153052,21 @@ static YYACTIONTYPE yy_reduce( } break; case 30: /* ccons ::= CONSTRAINT nm */ - case 65: /* tcons ::= CONSTRAINT nm */ yytestcase(yyruleno==65); + case 63: /* tcons ::= CONSTRAINT nm */ yytestcase(yyruleno==63); {pParse->constraintName = yymsp[0].minor.yy0;} break; case 31: /* ccons ::= DEFAULT scantok term */ -{sqlite3AddDefaultValue(pParse,yymsp[0].minor.yy202,yymsp[-1].minor.yy0.z,&yymsp[-1].minor.yy0.z[yymsp[-1].minor.yy0.n]);} +{sqlite3AddDefaultValue(pParse,yymsp[0].minor.yy46,yymsp[-1].minor.yy0.z,&yymsp[-1].minor.yy0.z[yymsp[-1].minor.yy0.n]);} break; case 32: /* ccons ::= DEFAULT LP expr RP */ -{sqlite3AddDefaultValue(pParse,yymsp[-1].minor.yy202,yymsp[-2].minor.yy0.z+1,yymsp[0].minor.yy0.z);} +{sqlite3AddDefaultValue(pParse,yymsp[-1].minor.yy46,yymsp[-2].minor.yy0.z+1,yymsp[0].minor.yy0.z);} break; case 33: /* ccons ::= DEFAULT PLUS scantok term */ -{sqlite3AddDefaultValue(pParse,yymsp[0].minor.yy202,yymsp[-2].minor.yy0.z,&yymsp[-1].minor.yy0.z[yymsp[-1].minor.yy0.n]);} +{sqlite3AddDefaultValue(pParse,yymsp[0].minor.yy46,yymsp[-2].minor.yy0.z,&yymsp[-1].minor.yy0.z[yymsp[-1].minor.yy0.n]);} break; case 34: /* ccons ::= DEFAULT MINUS scantok term */ { - Expr *p = sqlite3PExpr(pParse, TK_UMINUS, yymsp[0].minor.yy202, 0); + Expr *p = sqlite3PExpr(pParse, TK_UMINUS, yymsp[0].minor.yy46, 0); sqlite3AddDefaultValue(pParse,p,yymsp[-2].minor.yy0.z,&yymsp[-1].minor.yy0.z[yymsp[-1].minor.yy0.n]); } break; @@ -155737,176 +153081,170 @@ static YYACTIONTYPE yy_reduce( } break; case 36: /* ccons ::= NOT NULL onconf */ -{sqlite3AddNotNull(pParse, yymsp[0].minor.yy192);} +{sqlite3AddNotNull(pParse, yymsp[0].minor.yy32);} break; case 37: /* ccons ::= PRIMARY KEY sortorder onconf autoinc */ -{sqlite3AddPrimaryKey(pParse,0,yymsp[-1].minor.yy192,yymsp[0].minor.yy192,yymsp[-2].minor.yy192);} +{sqlite3AddPrimaryKey(pParse,0,yymsp[-1].minor.yy32,yymsp[0].minor.yy32,yymsp[-2].minor.yy32);} break; case 38: /* ccons ::= UNIQUE onconf */ -{sqlite3CreateIndex(pParse,0,0,0,0,yymsp[0].minor.yy192,0,0,0,0, +{sqlite3CreateIndex(pParse,0,0,0,0,yymsp[0].minor.yy32,0,0,0,0, SQLITE_IDXTYPE_UNIQUE);} break; case 39: /* ccons ::= CHECK LP expr RP */ -{sqlite3AddCheckConstraint(pParse,yymsp[-1].minor.yy202);} +{sqlite3AddCheckConstraint(pParse,yymsp[-1].minor.yy46);} break; case 40: /* ccons ::= REFERENCES nm eidlist_opt refargs */ -{sqlite3CreateForeignKey(pParse,0,&yymsp[-2].minor.yy0,yymsp[-1].minor.yy242,yymsp[0].minor.yy192);} +{sqlite3CreateForeignKey(pParse,0,&yymsp[-2].minor.yy0,yymsp[-1].minor.yy138,yymsp[0].minor.yy32);} break; case 41: /* ccons ::= defer_subclause */ -{sqlite3DeferForeignKey(pParse,yymsp[0].minor.yy192);} +{sqlite3DeferForeignKey(pParse,yymsp[0].minor.yy32);} break; case 42: /* ccons ::= COLLATE ID|STRING */ {sqlite3AddCollateType(pParse, &yymsp[0].minor.yy0);} break; - case 43: /* generated ::= LP expr RP */ -{sqlite3AddGenerated(pParse,yymsp[-1].minor.yy202,0);} + case 45: /* refargs ::= */ +{ yymsp[1].minor.yy32 = OE_None*0x0101; /* EV: R-19803-45884 */} break; - case 44: /* generated ::= LP expr RP ID */ -{sqlite3AddGenerated(pParse,yymsp[-2].minor.yy202,&yymsp[0].minor.yy0);} + case 46: /* refargs ::= refargs refarg */ +{ yymsp[-1].minor.yy32 = (yymsp[-1].minor.yy32 & ~yymsp[0].minor.yy495.mask) | yymsp[0].minor.yy495.value; } break; - case 47: /* refargs ::= */ -{ yymsp[1].minor.yy192 = OE_None*0x0101; /* EV: R-19803-45884 */} + case 47: /* refarg ::= MATCH nm */ +{ yymsp[-1].minor.yy495.value = 0; yymsp[-1].minor.yy495.mask = 0x000000; } break; - case 48: /* refargs ::= refargs refarg */ -{ yymsp[-1].minor.yy192 = (yymsp[-1].minor.yy192 & ~yymsp[0].minor.yy207.mask) | yymsp[0].minor.yy207.value; } + case 48: /* refarg ::= ON INSERT refact */ +{ yymsp[-2].minor.yy495.value = 0; yymsp[-2].minor.yy495.mask = 0x000000; } break; - case 49: /* refarg ::= MATCH nm */ -{ yymsp[-1].minor.yy207.value = 0; yymsp[-1].minor.yy207.mask = 0x000000; } + case 49: /* refarg ::= ON DELETE refact */ +{ yymsp[-2].minor.yy495.value = yymsp[0].minor.yy32; yymsp[-2].minor.yy495.mask = 0x0000ff; } break; - case 50: /* refarg ::= ON INSERT refact */ -{ yymsp[-2].minor.yy207.value = 0; yymsp[-2].minor.yy207.mask = 0x000000; } + case 50: /* refarg ::= ON UPDATE refact */ +{ yymsp[-2].minor.yy495.value = yymsp[0].minor.yy32<<8; yymsp[-2].minor.yy495.mask = 0x00ff00; } break; - case 51: /* refarg ::= ON DELETE refact */ -{ yymsp[-2].minor.yy207.value = yymsp[0].minor.yy192; yymsp[-2].minor.yy207.mask = 0x0000ff; } + case 51: /* refact ::= SET NULL */ +{ yymsp[-1].minor.yy32 = OE_SetNull; /* EV: R-33326-45252 */} break; - case 52: /* refarg ::= ON UPDATE refact */ -{ yymsp[-2].minor.yy207.value = yymsp[0].minor.yy192<<8; yymsp[-2].minor.yy207.mask = 0x00ff00; } + case 52: /* refact ::= SET DEFAULT */ +{ yymsp[-1].minor.yy32 = OE_SetDflt; /* EV: R-33326-45252 */} break; - case 53: /* refact ::= SET NULL */ -{ yymsp[-1].minor.yy192 = OE_SetNull; /* EV: R-33326-45252 */} + case 53: /* refact ::= CASCADE */ +{ yymsp[0].minor.yy32 = OE_Cascade; /* EV: R-33326-45252 */} break; - case 54: /* refact ::= SET DEFAULT */ -{ yymsp[-1].minor.yy192 = OE_SetDflt; /* EV: R-33326-45252 */} + case 54: /* refact ::= RESTRICT */ +{ yymsp[0].minor.yy32 = OE_Restrict; /* EV: R-33326-45252 */} break; - case 55: /* refact ::= CASCADE */ -{ yymsp[0].minor.yy192 = OE_Cascade; /* EV: R-33326-45252 */} + case 55: /* refact ::= NO ACTION */ +{ yymsp[-1].minor.yy32 = OE_None; /* EV: R-33326-45252 */} break; - case 56: /* refact ::= RESTRICT */ -{ yymsp[0].minor.yy192 = OE_Restrict; /* EV: R-33326-45252 */} + case 56: /* defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt */ +{yymsp[-2].minor.yy32 = 0;} break; - case 57: /* refact ::= NO ACTION */ -{ yymsp[-1].minor.yy192 = OE_None; /* EV: R-33326-45252 */} + case 57: /* defer_subclause ::= DEFERRABLE init_deferred_pred_opt */ + case 72: /* orconf ::= OR resolvetype */ yytestcase(yyruleno==72); + case 160: /* insert_cmd ::= INSERT orconf */ yytestcase(yyruleno==160); +{yymsp[-1].minor.yy32 = yymsp[0].minor.yy32;} break; - case 58: /* defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt */ -{yymsp[-2].minor.yy192 = 0;} + case 59: /* init_deferred_pred_opt ::= INITIALLY DEFERRED */ + case 76: /* ifexists ::= IF EXISTS */ yytestcase(yyruleno==76); + case 202: /* between_op ::= NOT BETWEEN */ yytestcase(yyruleno==202); + case 205: /* in_op ::= NOT IN */ yytestcase(yyruleno==205); + case 231: /* collate ::= COLLATE ID|STRING */ yytestcase(yyruleno==231); +{yymsp[-1].minor.yy32 = 1;} break; - case 59: /* defer_subclause ::= DEFERRABLE init_deferred_pred_opt */ - case 74: /* orconf ::= OR resolvetype */ yytestcase(yyruleno==74); - case 162: /* insert_cmd ::= INSERT orconf */ yytestcase(yyruleno==162); -{yymsp[-1].minor.yy192 = yymsp[0].minor.yy192;} + case 60: /* init_deferred_pred_opt ::= INITIALLY IMMEDIATE */ +{yymsp[-1].minor.yy32 = 0;} break; - case 61: /* init_deferred_pred_opt ::= INITIALLY DEFERRED */ - case 78: /* ifexists ::= IF EXISTS */ yytestcase(yyruleno==78); - case 204: /* between_op ::= NOT BETWEEN */ yytestcase(yyruleno==204); - case 207: /* in_op ::= NOT IN */ yytestcase(yyruleno==207); - case 233: /* collate ::= COLLATE ID|STRING */ yytestcase(yyruleno==233); -{yymsp[-1].minor.yy192 = 1;} - break; - case 62: /* init_deferred_pred_opt ::= INITIALLY IMMEDIATE */ -{yymsp[-1].minor.yy192 = 0;} - break; - case 64: /* tconscomma ::= COMMA */ + case 62: /* tconscomma ::= COMMA */ {pParse->constraintName.n = 0;} break; - case 66: /* tcons ::= PRIMARY KEY LP sortlist autoinc RP onconf */ -{sqlite3AddPrimaryKey(pParse,yymsp[-3].minor.yy242,yymsp[0].minor.yy192,yymsp[-2].minor.yy192,0);} + case 64: /* tcons ::= PRIMARY KEY LP sortlist autoinc RP onconf */ +{sqlite3AddPrimaryKey(pParse,yymsp[-3].minor.yy138,yymsp[0].minor.yy32,yymsp[-2].minor.yy32,0);} break; - case 67: /* tcons ::= UNIQUE LP sortlist RP onconf */ -{sqlite3CreateIndex(pParse,0,0,0,yymsp[-2].minor.yy242,yymsp[0].minor.yy192,0,0,0,0, + case 65: /* tcons ::= UNIQUE LP sortlist RP onconf */ +{sqlite3CreateIndex(pParse,0,0,0,yymsp[-2].minor.yy138,yymsp[0].minor.yy32,0,0,0,0, SQLITE_IDXTYPE_UNIQUE);} break; - case 68: /* tcons ::= CHECK LP expr RP onconf */ -{sqlite3AddCheckConstraint(pParse,yymsp[-2].minor.yy202);} + case 66: /* tcons ::= CHECK LP expr RP onconf */ +{sqlite3AddCheckConstraint(pParse,yymsp[-2].minor.yy46);} break; - case 69: /* tcons ::= FOREIGN KEY LP eidlist RP REFERENCES nm eidlist_opt refargs defer_subclause_opt */ + case 67: /* tcons ::= FOREIGN KEY LP eidlist RP REFERENCES nm eidlist_opt refargs defer_subclause_opt */ { - sqlite3CreateForeignKey(pParse, yymsp[-6].minor.yy242, &yymsp[-3].minor.yy0, yymsp[-2].minor.yy242, yymsp[-1].minor.yy192); - sqlite3DeferForeignKey(pParse, yymsp[0].minor.yy192); + sqlite3CreateForeignKey(pParse, yymsp[-6].minor.yy138, &yymsp[-3].minor.yy0, yymsp[-2].minor.yy138, yymsp[-1].minor.yy32); + sqlite3DeferForeignKey(pParse, yymsp[0].minor.yy32); } break; - case 71: /* onconf ::= */ - case 73: /* orconf ::= */ yytestcase(yyruleno==73); -{yymsp[1].minor.yy192 = OE_Default;} + case 69: /* onconf ::= */ + case 71: /* orconf ::= */ yytestcase(yyruleno==71); +{yymsp[1].minor.yy32 = OE_Default;} break; - case 72: /* onconf ::= ON CONFLICT resolvetype */ -{yymsp[-2].minor.yy192 = yymsp[0].minor.yy192;} + case 70: /* onconf ::= ON CONFLICT resolvetype */ +{yymsp[-2].minor.yy32 = yymsp[0].minor.yy32;} break; - case 75: /* resolvetype ::= IGNORE */ -{yymsp[0].minor.yy192 = OE_Ignore;} + case 73: /* resolvetype ::= IGNORE */ +{yymsp[0].minor.yy32 = OE_Ignore;} break; - case 76: /* resolvetype ::= REPLACE */ - case 163: /* insert_cmd ::= REPLACE */ yytestcase(yyruleno==163); -{yymsp[0].minor.yy192 = OE_Replace;} + case 74: /* resolvetype ::= REPLACE */ + case 161: /* insert_cmd ::= REPLACE */ yytestcase(yyruleno==161); +{yymsp[0].minor.yy32 = OE_Replace;} break; - case 77: /* cmd ::= DROP TABLE ifexists fullname */ + case 75: /* cmd ::= DROP TABLE ifexists fullname */ { - sqlite3DropTable(pParse, yymsp[0].minor.yy47, 0, yymsp[-1].minor.yy192); + sqlite3DropTable(pParse, yymsp[0].minor.yy609, 0, yymsp[-1].minor.yy32); } break; - case 80: /* cmd ::= createkw temp VIEW ifnotexists nm dbnm eidlist_opt AS select */ + case 78: /* cmd ::= createkw temp VIEW ifnotexists nm dbnm eidlist_opt AS select */ { - sqlite3CreateView(pParse, &yymsp[-8].minor.yy0, &yymsp[-4].minor.yy0, &yymsp[-3].minor.yy0, yymsp[-2].minor.yy242, yymsp[0].minor.yy539, yymsp[-7].minor.yy192, yymsp[-5].minor.yy192); + sqlite3CreateView(pParse, &yymsp[-8].minor.yy0, &yymsp[-4].minor.yy0, &yymsp[-3].minor.yy0, yymsp[-2].minor.yy138, yymsp[0].minor.yy25, yymsp[-7].minor.yy32, yymsp[-5].minor.yy32); } break; - case 81: /* cmd ::= DROP VIEW ifexists fullname */ + case 79: /* cmd ::= DROP VIEW ifexists fullname */ { - sqlite3DropTable(pParse, yymsp[0].minor.yy47, 1, yymsp[-1].minor.yy192); + sqlite3DropTable(pParse, yymsp[0].minor.yy609, 1, yymsp[-1].minor.yy32); } break; - case 82: /* cmd ::= select */ + case 80: /* cmd ::= select */ { SelectDest dest = {SRT_Output, 0, 0, 0, 0, 0}; - sqlite3Select(pParse, yymsp[0].minor.yy539, &dest); - sqlite3SelectDelete(pParse->db, yymsp[0].minor.yy539); + sqlite3Select(pParse, yymsp[0].minor.yy25, &dest); + sqlite3SelectDelete(pParse->db, yymsp[0].minor.yy25); } break; - case 83: /* select ::= WITH wqlist selectnowith */ + case 81: /* select ::= WITH wqlist selectnowith */ { - Select *p = yymsp[0].minor.yy539; + Select *p = yymsp[0].minor.yy25; if( p ){ - p->pWith = yymsp[-1].minor.yy131; + p->pWith = yymsp[-1].minor.yy297; parserDoubleLinkSelect(pParse, p); }else{ - sqlite3WithDelete(pParse->db, yymsp[-1].minor.yy131); + sqlite3WithDelete(pParse->db, yymsp[-1].minor.yy297); } - yymsp[-2].minor.yy539 = p; + yymsp[-2].minor.yy25 = p; } break; - case 84: /* select ::= WITH RECURSIVE wqlist selectnowith */ + case 82: /* select ::= WITH RECURSIVE wqlist selectnowith */ { - Select *p = yymsp[0].minor.yy539; + Select *p = yymsp[0].minor.yy25; if( p ){ - p->pWith = yymsp[-1].minor.yy131; + p->pWith = yymsp[-1].minor.yy297; parserDoubleLinkSelect(pParse, p); }else{ - sqlite3WithDelete(pParse->db, yymsp[-1].minor.yy131); + sqlite3WithDelete(pParse->db, yymsp[-1].minor.yy297); } - yymsp[-3].minor.yy539 = p; + yymsp[-3].minor.yy25 = p; } break; - case 85: /* select ::= selectnowith */ + case 83: /* select ::= selectnowith */ { - Select *p = yymsp[0].minor.yy539; + Select *p = yymsp[0].minor.yy25; if( p ){ parserDoubleLinkSelect(pParse, p); } - yymsp[0].minor.yy539 = p; /*A-overwrites-X*/ + yymsp[0].minor.yy25 = p; /*A-overwrites-X*/ } break; - case 86: /* selectnowith ::= selectnowith multiselect_op oneselect */ + case 84: /* selectnowith ::= selectnowith multiselect_op oneselect */ { - Select *pRhs = yymsp[0].minor.yy539; - Select *pLhs = yymsp[-2].minor.yy539; + Select *pRhs = yymsp[0].minor.yy25; + Select *pLhs = yymsp[-2].minor.yy25; if( pRhs && pRhs->pPrior ){ SrcList *pFrom; Token x; @@ -155916,142 +153254,142 @@ static YYACTIONTYPE yy_reduce( pRhs = sqlite3SelectNew(pParse,0,pFrom,0,0,0,0,0,0); } if( pRhs ){ - pRhs->op = (u8)yymsp[-1].minor.yy192; + pRhs->op = (u8)yymsp[-1].minor.yy32; pRhs->pPrior = pLhs; if( ALWAYS(pLhs) ) pLhs->selFlags &= ~SF_MultiValue; pRhs->selFlags &= ~SF_MultiValue; - if( yymsp[-1].minor.yy192!=TK_ALL ) pParse->hasCompound = 1; + if( yymsp[-1].minor.yy32!=TK_ALL ) pParse->hasCompound = 1; }else{ sqlite3SelectDelete(pParse->db, pLhs); } - yymsp[-2].minor.yy539 = pRhs; + yymsp[-2].minor.yy25 = pRhs; } break; - case 87: /* multiselect_op ::= UNION */ - case 89: /* multiselect_op ::= EXCEPT|INTERSECT */ yytestcase(yyruleno==89); -{yymsp[0].minor.yy192 = yymsp[0].major; /*A-overwrites-OP*/} + case 85: /* multiselect_op ::= UNION */ + case 87: /* multiselect_op ::= EXCEPT|INTERSECT */ yytestcase(yyruleno==87); +{yymsp[0].minor.yy32 = yymsp[0].major; /*A-overwrites-OP*/} break; - case 88: /* multiselect_op ::= UNION ALL */ -{yymsp[-1].minor.yy192 = TK_ALL;} + case 86: /* multiselect_op ::= UNION ALL */ +{yymsp[-1].minor.yy32 = TK_ALL;} break; - case 90: /* oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt */ + case 88: /* oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt */ { - yymsp[-8].minor.yy539 = sqlite3SelectNew(pParse,yymsp[-6].minor.yy242,yymsp[-5].minor.yy47,yymsp[-4].minor.yy202,yymsp[-3].minor.yy242,yymsp[-2].minor.yy202,yymsp[-1].minor.yy242,yymsp[-7].minor.yy192,yymsp[0].minor.yy202); + yymsp[-8].minor.yy25 = sqlite3SelectNew(pParse,yymsp[-6].minor.yy138,yymsp[-5].minor.yy609,yymsp[-4].minor.yy46,yymsp[-3].minor.yy138,yymsp[-2].minor.yy46,yymsp[-1].minor.yy138,yymsp[-7].minor.yy32,yymsp[0].minor.yy46); } break; - case 91: /* oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt window_clause orderby_opt limit_opt */ + case 89: /* oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt window_clause orderby_opt limit_opt */ { - yymsp[-9].minor.yy539 = sqlite3SelectNew(pParse,yymsp[-7].minor.yy242,yymsp[-6].minor.yy47,yymsp[-5].minor.yy202,yymsp[-4].minor.yy242,yymsp[-3].minor.yy202,yymsp[-1].minor.yy242,yymsp[-8].minor.yy192,yymsp[0].minor.yy202); - if( yymsp[-9].minor.yy539 ){ - yymsp[-9].minor.yy539->pWinDefn = yymsp[-2].minor.yy303; + yymsp[-9].minor.yy25 = sqlite3SelectNew(pParse,yymsp[-7].minor.yy138,yymsp[-6].minor.yy609,yymsp[-5].minor.yy46,yymsp[-4].minor.yy138,yymsp[-3].minor.yy46,yymsp[-1].minor.yy138,yymsp[-8].minor.yy32,yymsp[0].minor.yy46); + if( yymsp[-9].minor.yy25 ){ + yymsp[-9].minor.yy25->pWinDefn = yymsp[-2].minor.yy455; }else{ - sqlite3WindowListDelete(pParse->db, yymsp[-2].minor.yy303); + sqlite3WindowListDelete(pParse->db, yymsp[-2].minor.yy455); } } break; - case 92: /* values ::= VALUES LP nexprlist RP */ + case 90: /* values ::= VALUES LP nexprlist RP */ { - yymsp[-3].minor.yy539 = sqlite3SelectNew(pParse,yymsp[-1].minor.yy242,0,0,0,0,0,SF_Values,0); + yymsp[-3].minor.yy25 = sqlite3SelectNew(pParse,yymsp[-1].minor.yy138,0,0,0,0,0,SF_Values,0); } break; - case 93: /* values ::= values COMMA LP nexprlist RP */ + case 91: /* values ::= values COMMA LP nexprlist RP */ { - Select *pRight, *pLeft = yymsp[-4].minor.yy539; - pRight = sqlite3SelectNew(pParse,yymsp[-1].minor.yy242,0,0,0,0,0,SF_Values|SF_MultiValue,0); + Select *pRight, *pLeft = yymsp[-4].minor.yy25; + pRight = sqlite3SelectNew(pParse,yymsp[-1].minor.yy138,0,0,0,0,0,SF_Values|SF_MultiValue,0); if( ALWAYS(pLeft) ) pLeft->selFlags &= ~SF_MultiValue; if( pRight ){ pRight->op = TK_ALL; pRight->pPrior = pLeft; - yymsp[-4].minor.yy539 = pRight; + yymsp[-4].minor.yy25 = pRight; }else{ - yymsp[-4].minor.yy539 = pLeft; + yymsp[-4].minor.yy25 = pLeft; } } break; - case 94: /* distinct ::= DISTINCT */ -{yymsp[0].minor.yy192 = SF_Distinct;} + case 92: /* distinct ::= DISTINCT */ +{yymsp[0].minor.yy32 = SF_Distinct;} break; - case 95: /* distinct ::= ALL */ -{yymsp[0].minor.yy192 = SF_All;} + case 93: /* distinct ::= ALL */ +{yymsp[0].minor.yy32 = SF_All;} break; - case 97: /* sclp ::= */ - case 130: /* orderby_opt ::= */ yytestcase(yyruleno==130); - case 140: /* groupby_opt ::= */ yytestcase(yyruleno==140); - case 220: /* exprlist ::= */ yytestcase(yyruleno==220); - case 223: /* paren_exprlist ::= */ yytestcase(yyruleno==223); - case 228: /* eidlist_opt ::= */ yytestcase(yyruleno==228); -{yymsp[1].minor.yy242 = 0;} + case 95: /* sclp ::= */ + case 128: /* orderby_opt ::= */ yytestcase(yyruleno==128); + case 138: /* groupby_opt ::= */ yytestcase(yyruleno==138); + case 218: /* exprlist ::= */ yytestcase(yyruleno==218); + case 221: /* paren_exprlist ::= */ yytestcase(yyruleno==221); + case 226: /* eidlist_opt ::= */ yytestcase(yyruleno==226); +{yymsp[1].minor.yy138 = 0;} break; - case 98: /* selcollist ::= sclp scanpt expr scanpt as */ + case 96: /* selcollist ::= sclp scanpt expr scanpt as */ { - yymsp[-4].minor.yy242 = sqlite3ExprListAppend(pParse, yymsp[-4].minor.yy242, yymsp[-2].minor.yy202); - if( yymsp[0].minor.yy0.n>0 ) sqlite3ExprListSetName(pParse, yymsp[-4].minor.yy242, &yymsp[0].minor.yy0, 1); - sqlite3ExprListSetSpan(pParse,yymsp[-4].minor.yy242,yymsp[-3].minor.yy436,yymsp[-1].minor.yy436); + yymsp[-4].minor.yy138 = sqlite3ExprListAppend(pParse, yymsp[-4].minor.yy138, yymsp[-2].minor.yy46); + if( yymsp[0].minor.yy0.n>0 ) sqlite3ExprListSetName(pParse, yymsp[-4].minor.yy138, &yymsp[0].minor.yy0, 1); + sqlite3ExprListSetSpan(pParse,yymsp[-4].minor.yy138,yymsp[-3].minor.yy8,yymsp[-1].minor.yy8); } break; - case 99: /* selcollist ::= sclp scanpt STAR */ + case 97: /* selcollist ::= sclp scanpt STAR */ { Expr *p = sqlite3Expr(pParse->db, TK_ASTERISK, 0); - yymsp[-2].minor.yy242 = sqlite3ExprListAppend(pParse, yymsp[-2].minor.yy242, p); + yymsp[-2].minor.yy138 = sqlite3ExprListAppend(pParse, yymsp[-2].minor.yy138, p); } break; - case 100: /* selcollist ::= sclp scanpt nm DOT STAR */ + case 98: /* selcollist ::= sclp scanpt nm DOT STAR */ { Expr *pRight = sqlite3PExpr(pParse, TK_ASTERISK, 0, 0); Expr *pLeft = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[-2].minor.yy0, 1); Expr *pDot = sqlite3PExpr(pParse, TK_DOT, pLeft, pRight); - yymsp[-4].minor.yy242 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy242, pDot); + yymsp[-4].minor.yy138 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy138, pDot); } break; - case 101: /* as ::= AS nm */ - case 112: /* dbnm ::= DOT nm */ yytestcase(yyruleno==112); - case 244: /* plus_num ::= PLUS INTEGER|FLOAT */ yytestcase(yyruleno==244); - case 245: /* minus_num ::= MINUS INTEGER|FLOAT */ yytestcase(yyruleno==245); + case 99: /* as ::= AS nm */ + case 110: /* dbnm ::= DOT nm */ yytestcase(yyruleno==110); + case 242: /* plus_num ::= PLUS INTEGER|FLOAT */ yytestcase(yyruleno==242); + case 243: /* minus_num ::= MINUS INTEGER|FLOAT */ yytestcase(yyruleno==243); {yymsp[-1].minor.yy0 = yymsp[0].minor.yy0;} break; - case 103: /* from ::= */ -{yymsp[1].minor.yy47 = sqlite3DbMallocZero(pParse->db, sizeof(*yymsp[1].minor.yy47));} + case 101: /* from ::= */ +{yymsp[1].minor.yy609 = sqlite3DbMallocZero(pParse->db, sizeof(*yymsp[1].minor.yy609));} break; - case 104: /* from ::= FROM seltablist */ + case 102: /* from ::= FROM seltablist */ { - yymsp[-1].minor.yy47 = yymsp[0].minor.yy47; - sqlite3SrcListShiftJoinType(yymsp[-1].minor.yy47); + yymsp[-1].minor.yy609 = yymsp[0].minor.yy609; + sqlite3SrcListShiftJoinType(yymsp[-1].minor.yy609); } break; - case 105: /* stl_prefix ::= seltablist joinop */ + case 103: /* stl_prefix ::= seltablist joinop */ { - if( ALWAYS(yymsp[-1].minor.yy47 && yymsp[-1].minor.yy47->nSrc>0) ) yymsp[-1].minor.yy47->a[yymsp[-1].minor.yy47->nSrc-1].fg.jointype = (u8)yymsp[0].minor.yy192; + if( ALWAYS(yymsp[-1].minor.yy609 && yymsp[-1].minor.yy609->nSrc>0) ) yymsp[-1].minor.yy609->a[yymsp[-1].minor.yy609->nSrc-1].fg.jointype = (u8)yymsp[0].minor.yy32; } break; - case 106: /* stl_prefix ::= */ -{yymsp[1].minor.yy47 = 0;} + case 104: /* stl_prefix ::= */ +{yymsp[1].minor.yy609 = 0;} break; - case 107: /* seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt */ + case 105: /* seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt */ { - yymsp[-6].minor.yy47 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy47,&yymsp[-5].minor.yy0,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,0,yymsp[-1].minor.yy202,yymsp[0].minor.yy600); - sqlite3SrcListIndexedBy(pParse, yymsp[-6].minor.yy47, &yymsp[-2].minor.yy0); + yymsp[-6].minor.yy609 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy609,&yymsp[-5].minor.yy0,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,0,yymsp[-1].minor.yy46,yymsp[0].minor.yy406); + sqlite3SrcListIndexedBy(pParse, yymsp[-6].minor.yy609, &yymsp[-2].minor.yy0); } break; - case 108: /* seltablist ::= stl_prefix nm dbnm LP exprlist RP as on_opt using_opt */ + case 106: /* seltablist ::= stl_prefix nm dbnm LP exprlist RP as on_opt using_opt */ { - yymsp[-8].minor.yy47 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-8].minor.yy47,&yymsp[-7].minor.yy0,&yymsp[-6].minor.yy0,&yymsp[-2].minor.yy0,0,yymsp[-1].minor.yy202,yymsp[0].minor.yy600); - sqlite3SrcListFuncArgs(pParse, yymsp[-8].minor.yy47, yymsp[-4].minor.yy242); + yymsp[-8].minor.yy609 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-8].minor.yy609,&yymsp[-7].minor.yy0,&yymsp[-6].minor.yy0,&yymsp[-2].minor.yy0,0,yymsp[-1].minor.yy46,yymsp[0].minor.yy406); + sqlite3SrcListFuncArgs(pParse, yymsp[-8].minor.yy609, yymsp[-4].minor.yy138); } break; - case 109: /* seltablist ::= stl_prefix LP select RP as on_opt using_opt */ + case 107: /* seltablist ::= stl_prefix LP select RP as on_opt using_opt */ { - yymsp[-6].minor.yy47 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy47,0,0,&yymsp[-2].minor.yy0,yymsp[-4].minor.yy539,yymsp[-1].minor.yy202,yymsp[0].minor.yy600); + yymsp[-6].minor.yy609 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy609,0,0,&yymsp[-2].minor.yy0,yymsp[-4].minor.yy25,yymsp[-1].minor.yy46,yymsp[0].minor.yy406); } break; - case 110: /* seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt */ + case 108: /* seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt */ { - if( yymsp[-6].minor.yy47==0 && yymsp[-2].minor.yy0.n==0 && yymsp[-1].minor.yy202==0 && yymsp[0].minor.yy600==0 ){ - yymsp[-6].minor.yy47 = yymsp[-4].minor.yy47; - }else if( yymsp[-4].minor.yy47->nSrc==1 ){ - yymsp[-6].minor.yy47 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy47,0,0,&yymsp[-2].minor.yy0,0,yymsp[-1].minor.yy202,yymsp[0].minor.yy600); - if( yymsp[-6].minor.yy47 ){ - struct SrcList_item *pNew = &yymsp[-6].minor.yy47->a[yymsp[-6].minor.yy47->nSrc-1]; - struct SrcList_item *pOld = yymsp[-4].minor.yy47->a; + if( yymsp[-6].minor.yy609==0 && yymsp[-2].minor.yy0.n==0 && yymsp[-1].minor.yy46==0 && yymsp[0].minor.yy406==0 ){ + yymsp[-6].minor.yy609 = yymsp[-4].minor.yy609; + }else if( yymsp[-4].minor.yy609->nSrc==1 ){ + yymsp[-6].minor.yy609 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy609,0,0,&yymsp[-2].minor.yy0,0,yymsp[-1].minor.yy46,yymsp[0].minor.yy406); + if( yymsp[-6].minor.yy609 ){ + struct SrcList_item *pNew = &yymsp[-6].minor.yy609->a[yymsp[-6].minor.yy609->nSrc-1]; + struct SrcList_item *pOld = yymsp[-4].minor.yy609->a; pNew->zName = pOld->zName; pNew->zDatabase = pOld->zDatabase; pNew->pSelect = pOld->pSelect; @@ -156064,208 +153402,208 @@ static YYACTIONTYPE yy_reduce( pOld->zName = pOld->zDatabase = 0; pOld->pSelect = 0; } - sqlite3SrcListDelete(pParse->db, yymsp[-4].minor.yy47); + sqlite3SrcListDelete(pParse->db, yymsp[-4].minor.yy609); }else{ Select *pSubquery; - sqlite3SrcListShiftJoinType(yymsp[-4].minor.yy47); - pSubquery = sqlite3SelectNew(pParse,0,yymsp[-4].minor.yy47,0,0,0,0,SF_NestedFrom,0); - yymsp[-6].minor.yy47 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy47,0,0,&yymsp[-2].minor.yy0,pSubquery,yymsp[-1].minor.yy202,yymsp[0].minor.yy600); + sqlite3SrcListShiftJoinType(yymsp[-4].minor.yy609); + pSubquery = sqlite3SelectNew(pParse,0,yymsp[-4].minor.yy609,0,0,0,0,SF_NestedFrom,0); + yymsp[-6].minor.yy609 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy609,0,0,&yymsp[-2].minor.yy0,pSubquery,yymsp[-1].minor.yy46,yymsp[0].minor.yy406); } } break; - case 111: /* dbnm ::= */ - case 125: /* indexed_opt ::= */ yytestcase(yyruleno==125); + case 109: /* dbnm ::= */ + case 123: /* indexed_opt ::= */ yytestcase(yyruleno==123); {yymsp[1].minor.yy0.z=0; yymsp[1].minor.yy0.n=0;} break; - case 113: /* fullname ::= nm */ + case 111: /* fullname ::= nm */ { - yylhsminor.yy47 = sqlite3SrcListAppend(pParse,0,&yymsp[0].minor.yy0,0); - if( IN_RENAME_OBJECT && yylhsminor.yy47 ) sqlite3RenameTokenMap(pParse, yylhsminor.yy47->a[0].zName, &yymsp[0].minor.yy0); + yylhsminor.yy609 = sqlite3SrcListAppend(pParse,0,&yymsp[0].minor.yy0,0); + if( IN_RENAME_OBJECT && yylhsminor.yy609 ) sqlite3RenameTokenMap(pParse, yylhsminor.yy609->a[0].zName, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy47 = yylhsminor.yy47; + yymsp[0].minor.yy609 = yylhsminor.yy609; break; - case 114: /* fullname ::= nm DOT nm */ + case 112: /* fullname ::= nm DOT nm */ { - yylhsminor.yy47 = sqlite3SrcListAppend(pParse,0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0); - if( IN_RENAME_OBJECT && yylhsminor.yy47 ) sqlite3RenameTokenMap(pParse, yylhsminor.yy47->a[0].zName, &yymsp[0].minor.yy0); + yylhsminor.yy609 = sqlite3SrcListAppend(pParse,0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0); + if( IN_RENAME_OBJECT && yylhsminor.yy609 ) sqlite3RenameTokenMap(pParse, yylhsminor.yy609->a[0].zName, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy47 = yylhsminor.yy47; + yymsp[-2].minor.yy609 = yylhsminor.yy609; break; - case 115: /* xfullname ::= nm */ -{yymsp[0].minor.yy47 = sqlite3SrcListAppend(pParse,0,&yymsp[0].minor.yy0,0); /*A-overwrites-X*/} + case 113: /* xfullname ::= nm */ +{yymsp[0].minor.yy609 = sqlite3SrcListAppend(pParse,0,&yymsp[0].minor.yy0,0); /*A-overwrites-X*/} break; - case 116: /* xfullname ::= nm DOT nm */ -{yymsp[-2].minor.yy47 = sqlite3SrcListAppend(pParse,0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-X*/} + case 114: /* xfullname ::= nm DOT nm */ +{yymsp[-2].minor.yy609 = sqlite3SrcListAppend(pParse,0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-X*/} break; - case 117: /* xfullname ::= nm DOT nm AS nm */ + case 115: /* xfullname ::= nm DOT nm AS nm */ { - yymsp[-4].minor.yy47 = sqlite3SrcListAppend(pParse,0,&yymsp[-4].minor.yy0,&yymsp[-2].minor.yy0); /*A-overwrites-X*/ - if( yymsp[-4].minor.yy47 ) yymsp[-4].minor.yy47->a[0].zAlias = sqlite3NameFromToken(pParse->db, &yymsp[0].minor.yy0); + yymsp[-4].minor.yy609 = sqlite3SrcListAppend(pParse,0,&yymsp[-4].minor.yy0,&yymsp[-2].minor.yy0); /*A-overwrites-X*/ + if( yymsp[-4].minor.yy609 ) yymsp[-4].minor.yy609->a[0].zAlias = sqlite3NameFromToken(pParse->db, &yymsp[0].minor.yy0); } break; - case 118: /* xfullname ::= nm AS nm */ + case 116: /* xfullname ::= nm AS nm */ { - yymsp[-2].minor.yy47 = sqlite3SrcListAppend(pParse,0,&yymsp[-2].minor.yy0,0); /*A-overwrites-X*/ - if( yymsp[-2].minor.yy47 ) yymsp[-2].minor.yy47->a[0].zAlias = sqlite3NameFromToken(pParse->db, &yymsp[0].minor.yy0); + yymsp[-2].minor.yy609 = sqlite3SrcListAppend(pParse,0,&yymsp[-2].minor.yy0,0); /*A-overwrites-X*/ + if( yymsp[-2].minor.yy609 ) yymsp[-2].minor.yy609->a[0].zAlias = sqlite3NameFromToken(pParse->db, &yymsp[0].minor.yy0); } break; - case 119: /* joinop ::= COMMA|JOIN */ -{ yymsp[0].minor.yy192 = JT_INNER; } + case 117: /* joinop ::= COMMA|JOIN */ +{ yymsp[0].minor.yy32 = JT_INNER; } break; - case 120: /* joinop ::= JOIN_KW JOIN */ -{yymsp[-1].minor.yy192 = sqlite3JoinType(pParse,&yymsp[-1].minor.yy0,0,0); /*X-overwrites-A*/} + case 118: /* joinop ::= JOIN_KW JOIN */ +{yymsp[-1].minor.yy32 = sqlite3JoinType(pParse,&yymsp[-1].minor.yy0,0,0); /*X-overwrites-A*/} break; - case 121: /* joinop ::= JOIN_KW nm JOIN */ -{yymsp[-2].minor.yy192 = sqlite3JoinType(pParse,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0,0); /*X-overwrites-A*/} + case 119: /* joinop ::= JOIN_KW nm JOIN */ +{yymsp[-2].minor.yy32 = sqlite3JoinType(pParse,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0,0); /*X-overwrites-A*/} break; - case 122: /* joinop ::= JOIN_KW nm nm JOIN */ -{yymsp[-3].minor.yy192 = sqlite3JoinType(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0);/*X-overwrites-A*/} + case 120: /* joinop ::= JOIN_KW nm nm JOIN */ +{yymsp[-3].minor.yy32 = sqlite3JoinType(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0);/*X-overwrites-A*/} break; - case 123: /* on_opt ::= ON expr */ - case 143: /* having_opt ::= HAVING expr */ yytestcase(yyruleno==143); - case 150: /* where_opt ::= WHERE expr */ yytestcase(yyruleno==150); - case 216: /* case_else ::= ELSE expr */ yytestcase(yyruleno==216); - case 237: /* vinto ::= INTO expr */ yytestcase(yyruleno==237); -{yymsp[-1].minor.yy202 = yymsp[0].minor.yy202;} + case 121: /* on_opt ::= ON expr */ + case 141: /* having_opt ::= HAVING expr */ yytestcase(yyruleno==141); + case 148: /* where_opt ::= WHERE expr */ yytestcase(yyruleno==148); + case 214: /* case_else ::= ELSE expr */ yytestcase(yyruleno==214); + case 235: /* vinto ::= INTO expr */ yytestcase(yyruleno==235); +{yymsp[-1].minor.yy46 = yymsp[0].minor.yy46;} break; - case 124: /* on_opt ::= */ - case 142: /* having_opt ::= */ yytestcase(yyruleno==142); - case 144: /* limit_opt ::= */ yytestcase(yyruleno==144); - case 149: /* where_opt ::= */ yytestcase(yyruleno==149); - case 217: /* case_else ::= */ yytestcase(yyruleno==217); - case 219: /* case_operand ::= */ yytestcase(yyruleno==219); - case 238: /* vinto ::= */ yytestcase(yyruleno==238); -{yymsp[1].minor.yy202 = 0;} + case 122: /* on_opt ::= */ + case 140: /* having_opt ::= */ yytestcase(yyruleno==140); + case 142: /* limit_opt ::= */ yytestcase(yyruleno==142); + case 147: /* where_opt ::= */ yytestcase(yyruleno==147); + case 215: /* case_else ::= */ yytestcase(yyruleno==215); + case 217: /* case_operand ::= */ yytestcase(yyruleno==217); + case 236: /* vinto ::= */ yytestcase(yyruleno==236); +{yymsp[1].minor.yy46 = 0;} break; - case 126: /* indexed_opt ::= INDEXED BY nm */ + case 124: /* indexed_opt ::= INDEXED BY nm */ {yymsp[-2].minor.yy0 = yymsp[0].minor.yy0;} break; - case 127: /* indexed_opt ::= NOT INDEXED */ + case 125: /* indexed_opt ::= NOT INDEXED */ {yymsp[-1].minor.yy0.z=0; yymsp[-1].minor.yy0.n=1;} break; - case 128: /* using_opt ::= USING LP idlist RP */ -{yymsp[-3].minor.yy600 = yymsp[-1].minor.yy600;} + case 126: /* using_opt ::= USING LP idlist RP */ +{yymsp[-3].minor.yy406 = yymsp[-1].minor.yy406;} break; - case 129: /* using_opt ::= */ - case 164: /* idlist_opt ::= */ yytestcase(yyruleno==164); -{yymsp[1].minor.yy600 = 0;} + case 127: /* using_opt ::= */ + case 162: /* idlist_opt ::= */ yytestcase(yyruleno==162); +{yymsp[1].minor.yy406 = 0;} break; - case 131: /* orderby_opt ::= ORDER BY sortlist */ - case 141: /* groupby_opt ::= GROUP BY nexprlist */ yytestcase(yyruleno==141); -{yymsp[-2].minor.yy242 = yymsp[0].minor.yy242;} + case 129: /* orderby_opt ::= ORDER BY sortlist */ + case 139: /* groupby_opt ::= GROUP BY nexprlist */ yytestcase(yyruleno==139); +{yymsp[-2].minor.yy138 = yymsp[0].minor.yy138;} break; - case 132: /* sortlist ::= sortlist COMMA expr sortorder nulls */ + case 130: /* sortlist ::= sortlist COMMA expr sortorder nulls */ { - yymsp[-4].minor.yy242 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy242,yymsp[-2].minor.yy202); - sqlite3ExprListSetSortOrder(yymsp[-4].minor.yy242,yymsp[-1].minor.yy192,yymsp[0].minor.yy192); + yymsp[-4].minor.yy138 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy138,yymsp[-2].minor.yy46); + sqlite3ExprListSetSortOrder(yymsp[-4].minor.yy138,yymsp[-1].minor.yy32,yymsp[0].minor.yy32); } break; - case 133: /* sortlist ::= expr sortorder nulls */ + case 131: /* sortlist ::= expr sortorder nulls */ { - yymsp[-2].minor.yy242 = sqlite3ExprListAppend(pParse,0,yymsp[-2].minor.yy202); /*A-overwrites-Y*/ - sqlite3ExprListSetSortOrder(yymsp[-2].minor.yy242,yymsp[-1].minor.yy192,yymsp[0].minor.yy192); + yymsp[-2].minor.yy138 = sqlite3ExprListAppend(pParse,0,yymsp[-2].minor.yy46); /*A-overwrites-Y*/ + sqlite3ExprListSetSortOrder(yymsp[-2].minor.yy138,yymsp[-1].minor.yy32,yymsp[0].minor.yy32); } break; - case 134: /* sortorder ::= ASC */ -{yymsp[0].minor.yy192 = SQLITE_SO_ASC;} + case 132: /* sortorder ::= ASC */ +{yymsp[0].minor.yy32 = SQLITE_SO_ASC;} break; - case 135: /* sortorder ::= DESC */ -{yymsp[0].minor.yy192 = SQLITE_SO_DESC;} + case 133: /* sortorder ::= DESC */ +{yymsp[0].minor.yy32 = SQLITE_SO_DESC;} break; - case 136: /* sortorder ::= */ - case 139: /* nulls ::= */ yytestcase(yyruleno==139); -{yymsp[1].minor.yy192 = SQLITE_SO_UNDEFINED;} + case 134: /* sortorder ::= */ + case 137: /* nulls ::= */ yytestcase(yyruleno==137); +{yymsp[1].minor.yy32 = SQLITE_SO_UNDEFINED;} break; - case 137: /* nulls ::= NULLS FIRST */ -{yymsp[-1].minor.yy192 = SQLITE_SO_ASC;} + case 135: /* nulls ::= NULLS FIRST */ +{yymsp[-1].minor.yy32 = SQLITE_SO_ASC;} break; - case 138: /* nulls ::= NULLS LAST */ -{yymsp[-1].minor.yy192 = SQLITE_SO_DESC;} + case 136: /* nulls ::= NULLS LAST */ +{yymsp[-1].minor.yy32 = SQLITE_SO_DESC;} break; - case 145: /* limit_opt ::= LIMIT expr */ -{yymsp[-1].minor.yy202 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[0].minor.yy202,0);} + case 143: /* limit_opt ::= LIMIT expr */ +{yymsp[-1].minor.yy46 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[0].minor.yy46,0);} break; - case 146: /* limit_opt ::= LIMIT expr OFFSET expr */ -{yymsp[-3].minor.yy202 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[-2].minor.yy202,yymsp[0].minor.yy202);} + case 144: /* limit_opt ::= LIMIT expr OFFSET expr */ +{yymsp[-3].minor.yy46 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[-2].minor.yy46,yymsp[0].minor.yy46);} break; - case 147: /* limit_opt ::= LIMIT expr COMMA expr */ -{yymsp[-3].minor.yy202 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[0].minor.yy202,yymsp[-2].minor.yy202);} + case 145: /* limit_opt ::= LIMIT expr COMMA expr */ +{yymsp[-3].minor.yy46 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[0].minor.yy46,yymsp[-2].minor.yy46);} break; - case 148: /* cmd ::= with DELETE FROM xfullname indexed_opt where_opt */ + case 146: /* cmd ::= with DELETE FROM xfullname indexed_opt where_opt */ { - sqlite3SrcListIndexedBy(pParse, yymsp[-2].minor.yy47, &yymsp[-1].minor.yy0); - sqlite3DeleteFrom(pParse,yymsp[-2].minor.yy47,yymsp[0].minor.yy202,0,0); + sqlite3SrcListIndexedBy(pParse, yymsp[-2].minor.yy609, &yymsp[-1].minor.yy0); + sqlite3DeleteFrom(pParse,yymsp[-2].minor.yy609,yymsp[0].minor.yy46,0,0); } break; - case 151: /* cmd ::= with UPDATE orconf xfullname indexed_opt SET setlist where_opt */ + case 149: /* cmd ::= with UPDATE orconf xfullname indexed_opt SET setlist where_opt */ { - sqlite3SrcListIndexedBy(pParse, yymsp[-4].minor.yy47, &yymsp[-3].minor.yy0); - sqlite3ExprListCheckLength(pParse,yymsp[-1].minor.yy242,"set list"); - sqlite3Update(pParse,yymsp[-4].minor.yy47,yymsp[-1].minor.yy242,yymsp[0].minor.yy202,yymsp[-5].minor.yy192,0,0,0); + sqlite3SrcListIndexedBy(pParse, yymsp[-4].minor.yy609, &yymsp[-3].minor.yy0); + sqlite3ExprListCheckLength(pParse,yymsp[-1].minor.yy138,"set list"); + sqlite3Update(pParse,yymsp[-4].minor.yy609,yymsp[-1].minor.yy138,yymsp[0].minor.yy46,yymsp[-5].minor.yy32,0,0,0); } break; - case 152: /* setlist ::= setlist COMMA nm EQ expr */ + case 150: /* setlist ::= setlist COMMA nm EQ expr */ { - yymsp[-4].minor.yy242 = sqlite3ExprListAppend(pParse, yymsp[-4].minor.yy242, yymsp[0].minor.yy202); - sqlite3ExprListSetName(pParse, yymsp[-4].minor.yy242, &yymsp[-2].minor.yy0, 1); + yymsp[-4].minor.yy138 = sqlite3ExprListAppend(pParse, yymsp[-4].minor.yy138, yymsp[0].minor.yy46); + sqlite3ExprListSetName(pParse, yymsp[-4].minor.yy138, &yymsp[-2].minor.yy0, 1); } break; - case 153: /* setlist ::= setlist COMMA LP idlist RP EQ expr */ + case 151: /* setlist ::= setlist COMMA LP idlist RP EQ expr */ { - yymsp[-6].minor.yy242 = sqlite3ExprListAppendVector(pParse, yymsp[-6].minor.yy242, yymsp[-3].minor.yy600, yymsp[0].minor.yy202); + yymsp[-6].minor.yy138 = sqlite3ExprListAppendVector(pParse, yymsp[-6].minor.yy138, yymsp[-3].minor.yy406, yymsp[0].minor.yy46); } break; - case 154: /* setlist ::= nm EQ expr */ + case 152: /* setlist ::= nm EQ expr */ { - yylhsminor.yy242 = sqlite3ExprListAppend(pParse, 0, yymsp[0].minor.yy202); - sqlite3ExprListSetName(pParse, yylhsminor.yy242, &yymsp[-2].minor.yy0, 1); + yylhsminor.yy138 = sqlite3ExprListAppend(pParse, 0, yymsp[0].minor.yy46); + sqlite3ExprListSetName(pParse, yylhsminor.yy138, &yymsp[-2].minor.yy0, 1); } - yymsp[-2].minor.yy242 = yylhsminor.yy242; + yymsp[-2].minor.yy138 = yylhsminor.yy138; break; - case 155: /* setlist ::= LP idlist RP EQ expr */ + case 153: /* setlist ::= LP idlist RP EQ expr */ { - yymsp[-4].minor.yy242 = sqlite3ExprListAppendVector(pParse, 0, yymsp[-3].minor.yy600, yymsp[0].minor.yy202); + yymsp[-4].minor.yy138 = sqlite3ExprListAppendVector(pParse, 0, yymsp[-3].minor.yy406, yymsp[0].minor.yy46); } break; - case 156: /* cmd ::= with insert_cmd INTO xfullname idlist_opt select upsert */ + case 154: /* cmd ::= with insert_cmd INTO xfullname idlist_opt select upsert */ { - sqlite3Insert(pParse, yymsp[-3].minor.yy47, yymsp[-1].minor.yy539, yymsp[-2].minor.yy600, yymsp[-5].minor.yy192, yymsp[0].minor.yy318); + sqlite3Insert(pParse, yymsp[-3].minor.yy609, yymsp[-1].minor.yy25, yymsp[-2].minor.yy406, yymsp[-5].minor.yy32, yymsp[0].minor.yy288); } break; - case 157: /* cmd ::= with insert_cmd INTO xfullname idlist_opt DEFAULT VALUES */ + case 155: /* cmd ::= with insert_cmd INTO xfullname idlist_opt DEFAULT VALUES */ { - sqlite3Insert(pParse, yymsp[-3].minor.yy47, 0, yymsp[-2].minor.yy600, yymsp[-5].minor.yy192, 0); + sqlite3Insert(pParse, yymsp[-3].minor.yy609, 0, yymsp[-2].minor.yy406, yymsp[-5].minor.yy32, 0); } break; - case 158: /* upsert ::= */ -{ yymsp[1].minor.yy318 = 0; } + case 156: /* upsert ::= */ +{ yymsp[1].minor.yy288 = 0; } break; - case 159: /* upsert ::= ON CONFLICT LP sortlist RP where_opt DO UPDATE SET setlist where_opt */ -{ yymsp[-10].minor.yy318 = sqlite3UpsertNew(pParse->db,yymsp[-7].minor.yy242,yymsp[-5].minor.yy202,yymsp[-1].minor.yy242,yymsp[0].minor.yy202);} + case 157: /* upsert ::= ON CONFLICT LP sortlist RP where_opt DO UPDATE SET setlist where_opt */ +{ yymsp[-10].minor.yy288 = sqlite3UpsertNew(pParse->db,yymsp[-7].minor.yy138,yymsp[-5].minor.yy46,yymsp[-1].minor.yy138,yymsp[0].minor.yy46);} break; - case 160: /* upsert ::= ON CONFLICT LP sortlist RP where_opt DO NOTHING */ -{ yymsp[-7].minor.yy318 = sqlite3UpsertNew(pParse->db,yymsp[-4].minor.yy242,yymsp[-2].minor.yy202,0,0); } + case 158: /* upsert ::= ON CONFLICT LP sortlist RP where_opt DO NOTHING */ +{ yymsp[-7].minor.yy288 = sqlite3UpsertNew(pParse->db,yymsp[-4].minor.yy138,yymsp[-2].minor.yy46,0,0); } break; - case 161: /* upsert ::= ON CONFLICT DO NOTHING */ -{ yymsp[-3].minor.yy318 = sqlite3UpsertNew(pParse->db,0,0,0,0); } + case 159: /* upsert ::= ON CONFLICT DO NOTHING */ +{ yymsp[-3].minor.yy288 = sqlite3UpsertNew(pParse->db,0,0,0,0); } break; - case 165: /* idlist_opt ::= LP idlist RP */ -{yymsp[-2].minor.yy600 = yymsp[-1].minor.yy600;} + case 163: /* idlist_opt ::= LP idlist RP */ +{yymsp[-2].minor.yy406 = yymsp[-1].minor.yy406;} break; - case 166: /* idlist ::= idlist COMMA nm */ -{yymsp[-2].minor.yy600 = sqlite3IdListAppend(pParse,yymsp[-2].minor.yy600,&yymsp[0].minor.yy0);} + case 164: /* idlist ::= idlist COMMA nm */ +{yymsp[-2].minor.yy406 = sqlite3IdListAppend(pParse,yymsp[-2].minor.yy406,&yymsp[0].minor.yy0);} break; - case 167: /* idlist ::= nm */ -{yymsp[0].minor.yy600 = sqlite3IdListAppend(pParse,0,&yymsp[0].minor.yy0); /*A-overwrites-Y*/} + case 165: /* idlist ::= nm */ +{yymsp[0].minor.yy406 = sqlite3IdListAppend(pParse,0,&yymsp[0].minor.yy0); /*A-overwrites-Y*/} break; - case 168: /* expr ::= LP expr RP */ -{yymsp[-2].minor.yy202 = yymsp[-1].minor.yy202;} + case 166: /* expr ::= LP expr RP */ +{yymsp[-2].minor.yy46 = yymsp[-1].minor.yy46;} break; - case 169: /* expr ::= ID|INDEXED */ - case 170: /* expr ::= JOIN_KW */ yytestcase(yyruleno==170); -{yymsp[0].minor.yy202=tokenExpr(pParse,TK_ID,yymsp[0].minor.yy0); /*A-overwrites-X*/} + case 167: /* expr ::= ID|INDEXED */ + case 168: /* expr ::= JOIN_KW */ yytestcase(yyruleno==168); +{yymsp[0].minor.yy46=tokenExpr(pParse,TK_ID,yymsp[0].minor.yy0); /*A-overwrites-X*/} break; - case 171: /* expr ::= nm DOT nm */ + case 169: /* expr ::= nm DOT nm */ { Expr *temp1 = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[-2].minor.yy0, 1); Expr *temp2 = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[0].minor.yy0, 1); @@ -156273,11 +153611,11 @@ static YYACTIONTYPE yy_reduce( sqlite3RenameTokenMap(pParse, (void*)temp2, &yymsp[0].minor.yy0); sqlite3RenameTokenMap(pParse, (void*)temp1, &yymsp[-2].minor.yy0); } - yylhsminor.yy202 = sqlite3PExpr(pParse, TK_DOT, temp1, temp2); + yylhsminor.yy46 = sqlite3PExpr(pParse, TK_DOT, temp1, temp2); } - yymsp[-2].minor.yy202 = yylhsminor.yy202; + yymsp[-2].minor.yy46 = yylhsminor.yy46; break; - case 172: /* expr ::= nm DOT nm DOT nm */ + case 170: /* expr ::= nm DOT nm DOT nm */ { Expr *temp1 = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[-4].minor.yy0, 1); Expr *temp2 = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[-2].minor.yy0, 1); @@ -156287,26 +153625,26 @@ static YYACTIONTYPE yy_reduce( sqlite3RenameTokenMap(pParse, (void*)temp3, &yymsp[0].minor.yy0); sqlite3RenameTokenMap(pParse, (void*)temp2, &yymsp[-2].minor.yy0); } - yylhsminor.yy202 = sqlite3PExpr(pParse, TK_DOT, temp1, temp4); + yylhsminor.yy46 = sqlite3PExpr(pParse, TK_DOT, temp1, temp4); } - yymsp[-4].minor.yy202 = yylhsminor.yy202; + yymsp[-4].minor.yy46 = yylhsminor.yy46; break; - case 173: /* term ::= NULL|FLOAT|BLOB */ - case 174: /* term ::= STRING */ yytestcase(yyruleno==174); -{yymsp[0].minor.yy202=tokenExpr(pParse,yymsp[0].major,yymsp[0].minor.yy0); /*A-overwrites-X*/} + case 171: /* term ::= NULL|FLOAT|BLOB */ + case 172: /* term ::= STRING */ yytestcase(yyruleno==172); +{yymsp[0].minor.yy46=tokenExpr(pParse,yymsp[0].major,yymsp[0].minor.yy0); /*A-overwrites-X*/} break; - case 175: /* term ::= INTEGER */ + case 173: /* term ::= INTEGER */ { - yylhsminor.yy202 = sqlite3ExprAlloc(pParse->db, TK_INTEGER, &yymsp[0].minor.yy0, 1); + yylhsminor.yy46 = sqlite3ExprAlloc(pParse->db, TK_INTEGER, &yymsp[0].minor.yy0, 1); } - yymsp[0].minor.yy202 = yylhsminor.yy202; + yymsp[0].minor.yy46 = yylhsminor.yy46; break; - case 176: /* expr ::= VARIABLE */ + case 174: /* expr ::= VARIABLE */ { if( !(yymsp[0].minor.yy0.z[0]=='#' && sqlite3Isdigit(yymsp[0].minor.yy0.z[1])) ){ u32 n = yymsp[0].minor.yy0.n; - yymsp[0].minor.yy202 = tokenExpr(pParse, TK_VARIABLE, yymsp[0].minor.yy0); - sqlite3ExprAssignVarNumber(pParse, yymsp[0].minor.yy202, n); + yymsp[0].minor.yy46 = tokenExpr(pParse, TK_VARIABLE, yymsp[0].minor.yy0); + sqlite3ExprAssignVarNumber(pParse, yymsp[0].minor.yy46, n); }else{ /* When doing a nested parse, one can include terms in an expression ** that look like this: #1 #2 ... These terms refer to registers @@ -156315,159 +153653,156 @@ static YYACTIONTYPE yy_reduce( assert( t.n>=2 ); if( pParse->nested==0 ){ sqlite3ErrorMsg(pParse, "near \"%T\": syntax error", &t); - yymsp[0].minor.yy202 = 0; + yymsp[0].minor.yy46 = 0; }else{ - yymsp[0].minor.yy202 = sqlite3PExpr(pParse, TK_REGISTER, 0, 0); - if( yymsp[0].minor.yy202 ) sqlite3GetInt32(&t.z[1], &yymsp[0].minor.yy202->iTable); + yymsp[0].minor.yy46 = sqlite3PExpr(pParse, TK_REGISTER, 0, 0); + if( yymsp[0].minor.yy46 ) sqlite3GetInt32(&t.z[1], &yymsp[0].minor.yy46->iTable); } } } break; - case 177: /* expr ::= expr COLLATE ID|STRING */ + case 175: /* expr ::= expr COLLATE ID|STRING */ { - yymsp[-2].minor.yy202 = sqlite3ExprAddCollateToken(pParse, yymsp[-2].minor.yy202, &yymsp[0].minor.yy0, 1); + yymsp[-2].minor.yy46 = sqlite3ExprAddCollateToken(pParse, yymsp[-2].minor.yy46, &yymsp[0].minor.yy0, 1); } break; - case 178: /* expr ::= CAST LP expr AS typetoken RP */ + case 176: /* expr ::= CAST LP expr AS typetoken RP */ { - yymsp[-5].minor.yy202 = sqlite3ExprAlloc(pParse->db, TK_CAST, &yymsp[-1].minor.yy0, 1); - sqlite3ExprAttachSubtrees(pParse->db, yymsp[-5].minor.yy202, yymsp[-3].minor.yy202, 0); + yymsp[-5].minor.yy46 = sqlite3ExprAlloc(pParse->db, TK_CAST, &yymsp[-1].minor.yy0, 1); + sqlite3ExprAttachSubtrees(pParse->db, yymsp[-5].minor.yy46, yymsp[-3].minor.yy46, 0); } break; - case 179: /* expr ::= ID|INDEXED LP distinct exprlist RP */ + case 177: /* expr ::= ID|INDEXED LP distinct exprlist RP */ { - yylhsminor.yy202 = sqlite3ExprFunction(pParse, yymsp[-1].minor.yy242, &yymsp[-4].minor.yy0, yymsp[-2].minor.yy192); + yylhsminor.yy46 = sqlite3ExprFunction(pParse, yymsp[-1].minor.yy138, &yymsp[-4].minor.yy0, yymsp[-2].minor.yy32); } - yymsp[-4].minor.yy202 = yylhsminor.yy202; + yymsp[-4].minor.yy46 = yylhsminor.yy46; break; - case 180: /* expr ::= ID|INDEXED LP STAR RP */ + case 178: /* expr ::= ID|INDEXED LP STAR RP */ { - yylhsminor.yy202 = sqlite3ExprFunction(pParse, 0, &yymsp[-3].minor.yy0, 0); + yylhsminor.yy46 = sqlite3ExprFunction(pParse, 0, &yymsp[-3].minor.yy0, 0); } - yymsp[-3].minor.yy202 = yylhsminor.yy202; + yymsp[-3].minor.yy46 = yylhsminor.yy46; break; - case 181: /* expr ::= ID|INDEXED LP distinct exprlist RP filter_over */ + case 179: /* expr ::= ID|INDEXED LP distinct exprlist RP filter_over */ { - yylhsminor.yy202 = sqlite3ExprFunction(pParse, yymsp[-2].minor.yy242, &yymsp[-5].minor.yy0, yymsp[-3].minor.yy192); - sqlite3WindowAttach(pParse, yylhsminor.yy202, yymsp[0].minor.yy303); + yylhsminor.yy46 = sqlite3ExprFunction(pParse, yymsp[-2].minor.yy138, &yymsp[-5].minor.yy0, yymsp[-3].minor.yy32); + sqlite3WindowAttach(pParse, yylhsminor.yy46, yymsp[0].minor.yy455); } - yymsp[-5].minor.yy202 = yylhsminor.yy202; + yymsp[-5].minor.yy46 = yylhsminor.yy46; break; - case 182: /* expr ::= ID|INDEXED LP STAR RP filter_over */ + case 180: /* expr ::= ID|INDEXED LP STAR RP filter_over */ { - yylhsminor.yy202 = sqlite3ExprFunction(pParse, 0, &yymsp[-4].minor.yy0, 0); - sqlite3WindowAttach(pParse, yylhsminor.yy202, yymsp[0].minor.yy303); + yylhsminor.yy46 = sqlite3ExprFunction(pParse, 0, &yymsp[-4].minor.yy0, 0); + sqlite3WindowAttach(pParse, yylhsminor.yy46, yymsp[0].minor.yy455); } - yymsp[-4].minor.yy202 = yylhsminor.yy202; + yymsp[-4].minor.yy46 = yylhsminor.yy46; break; - case 183: /* term ::= CTIME_KW */ + case 181: /* term ::= CTIME_KW */ { - yylhsminor.yy202 = sqlite3ExprFunction(pParse, 0, &yymsp[0].minor.yy0, 0); + yylhsminor.yy46 = sqlite3ExprFunction(pParse, 0, &yymsp[0].minor.yy0, 0); } - yymsp[0].minor.yy202 = yylhsminor.yy202; + yymsp[0].minor.yy46 = yylhsminor.yy46; break; - case 184: /* expr ::= LP nexprlist COMMA expr RP */ + case 182: /* expr ::= LP nexprlist COMMA expr RP */ { - ExprList *pList = sqlite3ExprListAppend(pParse, yymsp[-3].minor.yy242, yymsp[-1].minor.yy202); - yymsp[-4].minor.yy202 = sqlite3PExpr(pParse, TK_VECTOR, 0, 0); - if( yymsp[-4].minor.yy202 ){ - yymsp[-4].minor.yy202->x.pList = pList; - if( ALWAYS(pList->nExpr) ){ - yymsp[-4].minor.yy202->flags |= pList->a[0].pExpr->flags & EP_Propagate; - } + ExprList *pList = sqlite3ExprListAppend(pParse, yymsp[-3].minor.yy138, yymsp[-1].minor.yy46); + yymsp[-4].minor.yy46 = sqlite3PExpr(pParse, TK_VECTOR, 0, 0); + if( yymsp[-4].minor.yy46 ){ + yymsp[-4].minor.yy46->x.pList = pList; }else{ sqlite3ExprListDelete(pParse->db, pList); } } break; - case 185: /* expr ::= expr AND expr */ -{yymsp[-2].minor.yy202=sqlite3ExprAnd(pParse,yymsp[-2].minor.yy202,yymsp[0].minor.yy202);} + case 183: /* expr ::= expr AND expr */ +{yymsp[-2].minor.yy46=sqlite3ExprAnd(pParse,yymsp[-2].minor.yy46,yymsp[0].minor.yy46);} break; - case 186: /* expr ::= expr OR expr */ - case 187: /* expr ::= expr LT|GT|GE|LE expr */ yytestcase(yyruleno==187); - case 188: /* expr ::= expr EQ|NE expr */ yytestcase(yyruleno==188); - case 189: /* expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */ yytestcase(yyruleno==189); - case 190: /* expr ::= expr PLUS|MINUS expr */ yytestcase(yyruleno==190); - case 191: /* expr ::= expr STAR|SLASH|REM expr */ yytestcase(yyruleno==191); - case 192: /* expr ::= expr CONCAT expr */ yytestcase(yyruleno==192); -{yymsp[-2].minor.yy202=sqlite3PExpr(pParse,yymsp[-1].major,yymsp[-2].minor.yy202,yymsp[0].minor.yy202);} + case 184: /* expr ::= expr OR expr */ + case 185: /* expr ::= expr LT|GT|GE|LE expr */ yytestcase(yyruleno==185); + case 186: /* expr ::= expr EQ|NE expr */ yytestcase(yyruleno==186); + case 187: /* expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */ yytestcase(yyruleno==187); + case 188: /* expr ::= expr PLUS|MINUS expr */ yytestcase(yyruleno==188); + case 189: /* expr ::= expr STAR|SLASH|REM expr */ yytestcase(yyruleno==189); + case 190: /* expr ::= expr CONCAT expr */ yytestcase(yyruleno==190); +{yymsp[-2].minor.yy46=sqlite3PExpr(pParse,yymsp[-1].major,yymsp[-2].minor.yy46,yymsp[0].minor.yy46);} break; - case 193: /* likeop ::= NOT LIKE_KW|MATCH */ + case 191: /* likeop ::= NOT LIKE_KW|MATCH */ {yymsp[-1].minor.yy0=yymsp[0].minor.yy0; yymsp[-1].minor.yy0.n|=0x80000000; /*yymsp[-1].minor.yy0-overwrite-yymsp[0].minor.yy0*/} break; - case 194: /* expr ::= expr likeop expr */ + case 192: /* expr ::= expr likeop expr */ { ExprList *pList; int bNot = yymsp[-1].minor.yy0.n & 0x80000000; yymsp[-1].minor.yy0.n &= 0x7fffffff; - pList = sqlite3ExprListAppend(pParse,0, yymsp[0].minor.yy202); - pList = sqlite3ExprListAppend(pParse,pList, yymsp[-2].minor.yy202); - yymsp[-2].minor.yy202 = sqlite3ExprFunction(pParse, pList, &yymsp[-1].minor.yy0, 0); - if( bNot ) yymsp[-2].minor.yy202 = sqlite3PExpr(pParse, TK_NOT, yymsp[-2].minor.yy202, 0); - if( yymsp[-2].minor.yy202 ) yymsp[-2].minor.yy202->flags |= EP_InfixFunc; + pList = sqlite3ExprListAppend(pParse,0, yymsp[0].minor.yy46); + pList = sqlite3ExprListAppend(pParse,pList, yymsp[-2].minor.yy46); + yymsp[-2].minor.yy46 = sqlite3ExprFunction(pParse, pList, &yymsp[-1].minor.yy0, 0); + if( bNot ) yymsp[-2].minor.yy46 = sqlite3PExpr(pParse, TK_NOT, yymsp[-2].minor.yy46, 0); + if( yymsp[-2].minor.yy46 ) yymsp[-2].minor.yy46->flags |= EP_InfixFunc; } break; - case 195: /* expr ::= expr likeop expr ESCAPE expr */ + case 193: /* expr ::= expr likeop expr ESCAPE expr */ { ExprList *pList; int bNot = yymsp[-3].minor.yy0.n & 0x80000000; yymsp[-3].minor.yy0.n &= 0x7fffffff; - pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy202); - pList = sqlite3ExprListAppend(pParse,pList, yymsp[-4].minor.yy202); - pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy202); - yymsp[-4].minor.yy202 = sqlite3ExprFunction(pParse, pList, &yymsp[-3].minor.yy0, 0); - if( bNot ) yymsp[-4].minor.yy202 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy202, 0); - if( yymsp[-4].minor.yy202 ) yymsp[-4].minor.yy202->flags |= EP_InfixFunc; + pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy46); + pList = sqlite3ExprListAppend(pParse,pList, yymsp[-4].minor.yy46); + pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy46); + yymsp[-4].minor.yy46 = sqlite3ExprFunction(pParse, pList, &yymsp[-3].minor.yy0, 0); + if( bNot ) yymsp[-4].minor.yy46 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy46, 0); + if( yymsp[-4].minor.yy46 ) yymsp[-4].minor.yy46->flags |= EP_InfixFunc; } break; - case 196: /* expr ::= expr ISNULL|NOTNULL */ -{yymsp[-1].minor.yy202 = sqlite3PExpr(pParse,yymsp[0].major,yymsp[-1].minor.yy202,0);} + case 194: /* expr ::= expr ISNULL|NOTNULL */ +{yymsp[-1].minor.yy46 = sqlite3PExpr(pParse,yymsp[0].major,yymsp[-1].minor.yy46,0);} break; - case 197: /* expr ::= expr NOT NULL */ -{yymsp[-2].minor.yy202 = sqlite3PExpr(pParse,TK_NOTNULL,yymsp[-2].minor.yy202,0);} + case 195: /* expr ::= expr NOT NULL */ +{yymsp[-2].minor.yy46 = sqlite3PExpr(pParse,TK_NOTNULL,yymsp[-2].minor.yy46,0);} break; - case 198: /* expr ::= expr IS expr */ + case 196: /* expr ::= expr IS expr */ { - yymsp[-2].minor.yy202 = sqlite3PExpr(pParse,TK_IS,yymsp[-2].minor.yy202,yymsp[0].minor.yy202); - binaryToUnaryIfNull(pParse, yymsp[0].minor.yy202, yymsp[-2].minor.yy202, TK_ISNULL); + yymsp[-2].minor.yy46 = sqlite3PExpr(pParse,TK_IS,yymsp[-2].minor.yy46,yymsp[0].minor.yy46); + binaryToUnaryIfNull(pParse, yymsp[0].minor.yy46, yymsp[-2].minor.yy46, TK_ISNULL); } break; - case 199: /* expr ::= expr IS NOT expr */ + case 197: /* expr ::= expr IS NOT expr */ { - yymsp[-3].minor.yy202 = sqlite3PExpr(pParse,TK_ISNOT,yymsp[-3].minor.yy202,yymsp[0].minor.yy202); - binaryToUnaryIfNull(pParse, yymsp[0].minor.yy202, yymsp[-3].minor.yy202, TK_NOTNULL); + yymsp[-3].minor.yy46 = sqlite3PExpr(pParse,TK_ISNOT,yymsp[-3].minor.yy46,yymsp[0].minor.yy46); + binaryToUnaryIfNull(pParse, yymsp[0].minor.yy46, yymsp[-3].minor.yy46, TK_NOTNULL); } break; - case 200: /* expr ::= NOT expr */ - case 201: /* expr ::= BITNOT expr */ yytestcase(yyruleno==201); -{yymsp[-1].minor.yy202 = sqlite3PExpr(pParse, yymsp[-1].major, yymsp[0].minor.yy202, 0);/*A-overwrites-B*/} + case 198: /* expr ::= NOT expr */ + case 199: /* expr ::= BITNOT expr */ yytestcase(yyruleno==199); +{yymsp[-1].minor.yy46 = sqlite3PExpr(pParse, yymsp[-1].major, yymsp[0].minor.yy46, 0);/*A-overwrites-B*/} break; - case 202: /* expr ::= PLUS|MINUS expr */ + case 200: /* expr ::= PLUS|MINUS expr */ { - yymsp[-1].minor.yy202 = sqlite3PExpr(pParse, yymsp[-1].major==TK_PLUS ? TK_UPLUS : TK_UMINUS, yymsp[0].minor.yy202, 0); + yymsp[-1].minor.yy46 = sqlite3PExpr(pParse, yymsp[-1].major==TK_PLUS ? TK_UPLUS : TK_UMINUS, yymsp[0].minor.yy46, 0); /*A-overwrites-B*/ } break; - case 203: /* between_op ::= BETWEEN */ - case 206: /* in_op ::= IN */ yytestcase(yyruleno==206); -{yymsp[0].minor.yy192 = 0;} + case 201: /* between_op ::= BETWEEN */ + case 204: /* in_op ::= IN */ yytestcase(yyruleno==204); +{yymsp[0].minor.yy32 = 0;} break; - case 205: /* expr ::= expr between_op expr AND expr */ + case 203: /* expr ::= expr between_op expr AND expr */ { - ExprList *pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy202); - pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy202); - yymsp[-4].minor.yy202 = sqlite3PExpr(pParse, TK_BETWEEN, yymsp[-4].minor.yy202, 0); - if( yymsp[-4].minor.yy202 ){ - yymsp[-4].minor.yy202->x.pList = pList; + ExprList *pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy46); + pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy46); + yymsp[-4].minor.yy46 = sqlite3PExpr(pParse, TK_BETWEEN, yymsp[-4].minor.yy46, 0); + if( yymsp[-4].minor.yy46 ){ + yymsp[-4].minor.yy46->x.pList = pList; }else{ sqlite3ExprListDelete(pParse->db, pList); } - if( yymsp[-3].minor.yy192 ) yymsp[-4].minor.yy202 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy202, 0); + if( yymsp[-3].minor.yy32 ) yymsp[-4].minor.yy46 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy46, 0); } break; - case 208: /* expr ::= expr in_op LP exprlist RP */ + case 206: /* expr ::= expr in_op LP exprlist RP */ { - if( yymsp[-1].minor.yy242==0 ){ + if( yymsp[-1].minor.yy138==0 ){ /* Expressions of the form ** ** expr1 IN () @@ -156476,190 +153811,190 @@ static YYACTIONTYPE yy_reduce( ** simplify to constants 0 (false) and 1 (true), respectively, ** regardless of the value of expr1. */ - sqlite3ExprUnmapAndDelete(pParse, yymsp[-4].minor.yy202); - yymsp[-4].minor.yy202 = sqlite3Expr(pParse->db, TK_INTEGER, yymsp[-3].minor.yy192 ? "1" : "0"); + sqlite3ExprUnmapAndDelete(pParse, yymsp[-4].minor.yy46); + yymsp[-4].minor.yy46 = sqlite3Expr(pParse->db, TK_INTEGER, yymsp[-3].minor.yy32 ? "1" : "0"); }else{ - yymsp[-4].minor.yy202 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy202, 0); - if( yymsp[-4].minor.yy202 ){ - yymsp[-4].minor.yy202->x.pList = yymsp[-1].minor.yy242; - sqlite3ExprSetHeightAndFlags(pParse, yymsp[-4].minor.yy202); + yymsp[-4].minor.yy46 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy46, 0); + if( yymsp[-4].minor.yy46 ){ + yymsp[-4].minor.yy46->x.pList = yymsp[-1].minor.yy138; + sqlite3ExprSetHeightAndFlags(pParse, yymsp[-4].minor.yy46); }else{ - sqlite3ExprListDelete(pParse->db, yymsp[-1].minor.yy242); + sqlite3ExprListDelete(pParse->db, yymsp[-1].minor.yy138); } - if( yymsp[-3].minor.yy192 ) yymsp[-4].minor.yy202 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy202, 0); + if( yymsp[-3].minor.yy32 ) yymsp[-4].minor.yy46 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy46, 0); } } break; - case 209: /* expr ::= LP select RP */ + case 207: /* expr ::= LP select RP */ { - yymsp[-2].minor.yy202 = sqlite3PExpr(pParse, TK_SELECT, 0, 0); - sqlite3PExprAddSelect(pParse, yymsp[-2].minor.yy202, yymsp[-1].minor.yy539); + yymsp[-2].minor.yy46 = sqlite3PExpr(pParse, TK_SELECT, 0, 0); + sqlite3PExprAddSelect(pParse, yymsp[-2].minor.yy46, yymsp[-1].minor.yy25); } break; - case 210: /* expr ::= expr in_op LP select RP */ + case 208: /* expr ::= expr in_op LP select RP */ { - yymsp[-4].minor.yy202 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy202, 0); - sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy202, yymsp[-1].minor.yy539); - if( yymsp[-3].minor.yy192 ) yymsp[-4].minor.yy202 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy202, 0); + yymsp[-4].minor.yy46 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy46, 0); + sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy46, yymsp[-1].minor.yy25); + if( yymsp[-3].minor.yy32 ) yymsp[-4].minor.yy46 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy46, 0); } break; - case 211: /* expr ::= expr in_op nm dbnm paren_exprlist */ + case 209: /* expr ::= expr in_op nm dbnm paren_exprlist */ { SrcList *pSrc = sqlite3SrcListAppend(pParse, 0,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0); Select *pSelect = sqlite3SelectNew(pParse, 0,pSrc,0,0,0,0,0,0); - if( yymsp[0].minor.yy242 ) sqlite3SrcListFuncArgs(pParse, pSelect ? pSrc : 0, yymsp[0].minor.yy242); - yymsp[-4].minor.yy202 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy202, 0); - sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy202, pSelect); - if( yymsp[-3].minor.yy192 ) yymsp[-4].minor.yy202 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy202, 0); + if( yymsp[0].minor.yy138 ) sqlite3SrcListFuncArgs(pParse, pSelect ? pSrc : 0, yymsp[0].minor.yy138); + yymsp[-4].minor.yy46 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy46, 0); + sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy46, pSelect); + if( yymsp[-3].minor.yy32 ) yymsp[-4].minor.yy46 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy46, 0); } break; - case 212: /* expr ::= EXISTS LP select RP */ + case 210: /* expr ::= EXISTS LP select RP */ { Expr *p; - p = yymsp[-3].minor.yy202 = sqlite3PExpr(pParse, TK_EXISTS, 0, 0); - sqlite3PExprAddSelect(pParse, p, yymsp[-1].minor.yy539); + p = yymsp[-3].minor.yy46 = sqlite3PExpr(pParse, TK_EXISTS, 0, 0); + sqlite3PExprAddSelect(pParse, p, yymsp[-1].minor.yy25); } break; - case 213: /* expr ::= CASE case_operand case_exprlist case_else END */ + case 211: /* expr ::= CASE case_operand case_exprlist case_else END */ { - yymsp[-4].minor.yy202 = sqlite3PExpr(pParse, TK_CASE, yymsp[-3].minor.yy202, 0); - if( yymsp[-4].minor.yy202 ){ - yymsp[-4].minor.yy202->x.pList = yymsp[-1].minor.yy202 ? sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy242,yymsp[-1].minor.yy202) : yymsp[-2].minor.yy242; - sqlite3ExprSetHeightAndFlags(pParse, yymsp[-4].minor.yy202); + yymsp[-4].minor.yy46 = sqlite3PExpr(pParse, TK_CASE, yymsp[-3].minor.yy46, 0); + if( yymsp[-4].minor.yy46 ){ + yymsp[-4].minor.yy46->x.pList = yymsp[-1].minor.yy46 ? sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy138,yymsp[-1].minor.yy46) : yymsp[-2].minor.yy138; + sqlite3ExprSetHeightAndFlags(pParse, yymsp[-4].minor.yy46); }else{ - sqlite3ExprListDelete(pParse->db, yymsp[-2].minor.yy242); - sqlite3ExprDelete(pParse->db, yymsp[-1].minor.yy202); + sqlite3ExprListDelete(pParse->db, yymsp[-2].minor.yy138); + sqlite3ExprDelete(pParse->db, yymsp[-1].minor.yy46); } } break; - case 214: /* case_exprlist ::= case_exprlist WHEN expr THEN expr */ + case 212: /* case_exprlist ::= case_exprlist WHEN expr THEN expr */ { - yymsp[-4].minor.yy242 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy242, yymsp[-2].minor.yy202); - yymsp[-4].minor.yy242 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy242, yymsp[0].minor.yy202); + yymsp[-4].minor.yy138 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy138, yymsp[-2].minor.yy46); + yymsp[-4].minor.yy138 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy138, yymsp[0].minor.yy46); } break; - case 215: /* case_exprlist ::= WHEN expr THEN expr */ + case 213: /* case_exprlist ::= WHEN expr THEN expr */ { - yymsp[-3].minor.yy242 = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy202); - yymsp[-3].minor.yy242 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy242, yymsp[0].minor.yy202); + yymsp[-3].minor.yy138 = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy46); + yymsp[-3].minor.yy138 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy138, yymsp[0].minor.yy46); } break; - case 218: /* case_operand ::= expr */ -{yymsp[0].minor.yy202 = yymsp[0].minor.yy202; /*A-overwrites-X*/} + case 216: /* case_operand ::= expr */ +{yymsp[0].minor.yy46 = yymsp[0].minor.yy46; /*A-overwrites-X*/} break; - case 221: /* nexprlist ::= nexprlist COMMA expr */ -{yymsp[-2].minor.yy242 = sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy242,yymsp[0].minor.yy202);} + case 219: /* nexprlist ::= nexprlist COMMA expr */ +{yymsp[-2].minor.yy138 = sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy138,yymsp[0].minor.yy46);} break; - case 222: /* nexprlist ::= expr */ -{yymsp[0].minor.yy242 = sqlite3ExprListAppend(pParse,0,yymsp[0].minor.yy202); /*A-overwrites-Y*/} + case 220: /* nexprlist ::= expr */ +{yymsp[0].minor.yy138 = sqlite3ExprListAppend(pParse,0,yymsp[0].minor.yy46); /*A-overwrites-Y*/} break; - case 224: /* paren_exprlist ::= LP exprlist RP */ - case 229: /* eidlist_opt ::= LP eidlist RP */ yytestcase(yyruleno==229); -{yymsp[-2].minor.yy242 = yymsp[-1].minor.yy242;} + case 222: /* paren_exprlist ::= LP exprlist RP */ + case 227: /* eidlist_opt ::= LP eidlist RP */ yytestcase(yyruleno==227); +{yymsp[-2].minor.yy138 = yymsp[-1].minor.yy138;} break; - case 225: /* cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */ + case 223: /* cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */ { sqlite3CreateIndex(pParse, &yymsp[-7].minor.yy0, &yymsp[-6].minor.yy0, - sqlite3SrcListAppend(pParse,0,&yymsp[-4].minor.yy0,0), yymsp[-2].minor.yy242, yymsp[-10].minor.yy192, - &yymsp[-11].minor.yy0, yymsp[0].minor.yy202, SQLITE_SO_ASC, yymsp[-8].minor.yy192, SQLITE_IDXTYPE_APPDEF); + sqlite3SrcListAppend(pParse,0,&yymsp[-4].minor.yy0,0), yymsp[-2].minor.yy138, yymsp[-10].minor.yy32, + &yymsp[-11].minor.yy0, yymsp[0].minor.yy46, SQLITE_SO_ASC, yymsp[-8].minor.yy32, SQLITE_IDXTYPE_APPDEF); if( IN_RENAME_OBJECT && pParse->pNewIndex ){ sqlite3RenameTokenMap(pParse, pParse->pNewIndex->zName, &yymsp[-4].minor.yy0); } } break; - case 226: /* uniqueflag ::= UNIQUE */ - case 268: /* raisetype ::= ABORT */ yytestcase(yyruleno==268); -{yymsp[0].minor.yy192 = OE_Abort;} + case 224: /* uniqueflag ::= UNIQUE */ + case 266: /* raisetype ::= ABORT */ yytestcase(yyruleno==266); +{yymsp[0].minor.yy32 = OE_Abort;} break; - case 227: /* uniqueflag ::= */ -{yymsp[1].minor.yy192 = OE_None;} + case 225: /* uniqueflag ::= */ +{yymsp[1].minor.yy32 = OE_None;} break; - case 230: /* eidlist ::= eidlist COMMA nm collate sortorder */ + case 228: /* eidlist ::= eidlist COMMA nm collate sortorder */ { - yymsp[-4].minor.yy242 = parserAddExprIdListTerm(pParse, yymsp[-4].minor.yy242, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy192, yymsp[0].minor.yy192); + yymsp[-4].minor.yy138 = parserAddExprIdListTerm(pParse, yymsp[-4].minor.yy138, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy32, yymsp[0].minor.yy32); } break; - case 231: /* eidlist ::= nm collate sortorder */ + case 229: /* eidlist ::= nm collate sortorder */ { - yymsp[-2].minor.yy242 = parserAddExprIdListTerm(pParse, 0, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy192, yymsp[0].minor.yy192); /*A-overwrites-Y*/ + yymsp[-2].minor.yy138 = parserAddExprIdListTerm(pParse, 0, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy32, yymsp[0].minor.yy32); /*A-overwrites-Y*/ } break; - case 234: /* cmd ::= DROP INDEX ifexists fullname */ -{sqlite3DropIndex(pParse, yymsp[0].minor.yy47, yymsp[-1].minor.yy192);} + case 232: /* cmd ::= DROP INDEX ifexists fullname */ +{sqlite3DropIndex(pParse, yymsp[0].minor.yy609, yymsp[-1].minor.yy32);} break; - case 235: /* cmd ::= VACUUM vinto */ -{sqlite3Vacuum(pParse,0,yymsp[0].minor.yy202);} + case 233: /* cmd ::= VACUUM vinto */ +{sqlite3Vacuum(pParse,0,yymsp[0].minor.yy46);} break; - case 236: /* cmd ::= VACUUM nm vinto */ -{sqlite3Vacuum(pParse,&yymsp[-1].minor.yy0,yymsp[0].minor.yy202);} + case 234: /* cmd ::= VACUUM nm vinto */ +{sqlite3Vacuum(pParse,&yymsp[-1].minor.yy0,yymsp[0].minor.yy46);} break; - case 239: /* cmd ::= PRAGMA nm dbnm */ + case 237: /* cmd ::= PRAGMA nm dbnm */ {sqlite3Pragma(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,0,0);} break; - case 240: /* cmd ::= PRAGMA nm dbnm EQ nmnum */ + case 238: /* cmd ::= PRAGMA nm dbnm EQ nmnum */ {sqlite3Pragma(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0,0);} break; - case 241: /* cmd ::= PRAGMA nm dbnm LP nmnum RP */ + case 239: /* cmd ::= PRAGMA nm dbnm LP nmnum RP */ {sqlite3Pragma(pParse,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,&yymsp[-1].minor.yy0,0);} break; - case 242: /* cmd ::= PRAGMA nm dbnm EQ minus_num */ + case 240: /* cmd ::= PRAGMA nm dbnm EQ minus_num */ {sqlite3Pragma(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0,1);} break; - case 243: /* cmd ::= PRAGMA nm dbnm LP minus_num RP */ + case 241: /* cmd ::= PRAGMA nm dbnm LP minus_num RP */ {sqlite3Pragma(pParse,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,&yymsp[-1].minor.yy0,1);} break; - case 246: /* cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */ + case 244: /* cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */ { Token all; all.z = yymsp[-3].minor.yy0.z; all.n = (int)(yymsp[0].minor.yy0.z - yymsp[-3].minor.yy0.z) + yymsp[0].minor.yy0.n; - sqlite3FinishTrigger(pParse, yymsp[-1].minor.yy447, &all); + sqlite3FinishTrigger(pParse, yymsp[-1].minor.yy527, &all); } break; - case 247: /* trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */ + case 245: /* trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */ { - sqlite3BeginTrigger(pParse, &yymsp[-7].minor.yy0, &yymsp[-6].minor.yy0, yymsp[-5].minor.yy192, yymsp[-4].minor.yy230.a, yymsp[-4].minor.yy230.b, yymsp[-2].minor.yy47, yymsp[0].minor.yy202, yymsp[-10].minor.yy192, yymsp[-8].minor.yy192); + sqlite3BeginTrigger(pParse, &yymsp[-7].minor.yy0, &yymsp[-6].minor.yy0, yymsp[-5].minor.yy32, yymsp[-4].minor.yy572.a, yymsp[-4].minor.yy572.b, yymsp[-2].minor.yy609, yymsp[0].minor.yy46, yymsp[-10].minor.yy32, yymsp[-8].minor.yy32); yymsp[-10].minor.yy0 = (yymsp[-6].minor.yy0.n==0?yymsp[-7].minor.yy0:yymsp[-6].minor.yy0); /*A-overwrites-T*/ } break; - case 248: /* trigger_time ::= BEFORE|AFTER */ -{ yymsp[0].minor.yy192 = yymsp[0].major; /*A-overwrites-X*/ } + case 246: /* trigger_time ::= BEFORE|AFTER */ +{ yymsp[0].minor.yy32 = yymsp[0].major; /*A-overwrites-X*/ } break; - case 249: /* trigger_time ::= INSTEAD OF */ -{ yymsp[-1].minor.yy192 = TK_INSTEAD;} + case 247: /* trigger_time ::= INSTEAD OF */ +{ yymsp[-1].minor.yy32 = TK_INSTEAD;} break; - case 250: /* trigger_time ::= */ -{ yymsp[1].minor.yy192 = TK_BEFORE; } + case 248: /* trigger_time ::= */ +{ yymsp[1].minor.yy32 = TK_BEFORE; } break; - case 251: /* trigger_event ::= DELETE|INSERT */ - case 252: /* trigger_event ::= UPDATE */ yytestcase(yyruleno==252); -{yymsp[0].minor.yy230.a = yymsp[0].major; /*A-overwrites-X*/ yymsp[0].minor.yy230.b = 0;} + case 249: /* trigger_event ::= DELETE|INSERT */ + case 250: /* trigger_event ::= UPDATE */ yytestcase(yyruleno==250); +{yymsp[0].minor.yy572.a = yymsp[0].major; /*A-overwrites-X*/ yymsp[0].minor.yy572.b = 0;} break; - case 253: /* trigger_event ::= UPDATE OF idlist */ -{yymsp[-2].minor.yy230.a = TK_UPDATE; yymsp[-2].minor.yy230.b = yymsp[0].minor.yy600;} + case 251: /* trigger_event ::= UPDATE OF idlist */ +{yymsp[-2].minor.yy572.a = TK_UPDATE; yymsp[-2].minor.yy572.b = yymsp[0].minor.yy406;} break; - case 254: /* when_clause ::= */ - case 273: /* key_opt ::= */ yytestcase(yyruleno==273); -{ yymsp[1].minor.yy202 = 0; } + case 252: /* when_clause ::= */ + case 271: /* key_opt ::= */ yytestcase(yyruleno==271); +{ yymsp[1].minor.yy46 = 0; } break; - case 255: /* when_clause ::= WHEN expr */ - case 274: /* key_opt ::= KEY expr */ yytestcase(yyruleno==274); -{ yymsp[-1].minor.yy202 = yymsp[0].minor.yy202; } + case 253: /* when_clause ::= WHEN expr */ + case 272: /* key_opt ::= KEY expr */ yytestcase(yyruleno==272); +{ yymsp[-1].minor.yy46 = yymsp[0].minor.yy46; } break; - case 256: /* trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */ + case 254: /* trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */ { - assert( yymsp[-2].minor.yy447!=0 ); - yymsp[-2].minor.yy447->pLast->pNext = yymsp[-1].minor.yy447; - yymsp[-2].minor.yy447->pLast = yymsp[-1].minor.yy447; + assert( yymsp[-2].minor.yy527!=0 ); + yymsp[-2].minor.yy527->pLast->pNext = yymsp[-1].minor.yy527; + yymsp[-2].minor.yy527->pLast = yymsp[-1].minor.yy527; } break; - case 257: /* trigger_cmd_list ::= trigger_cmd SEMI */ + case 255: /* trigger_cmd_list ::= trigger_cmd SEMI */ { - assert( yymsp[-1].minor.yy447!=0 ); - yymsp[-1].minor.yy447->pLast = yymsp[-1].minor.yy447; + assert( yymsp[-1].minor.yy527!=0 ); + yymsp[-1].minor.yy527->pLast = yymsp[-1].minor.yy527; } break; - case 258: /* trnm ::= nm DOT nm */ + case 256: /* trnm ::= nm DOT nm */ { yymsp[-2].minor.yy0 = yymsp[0].minor.yy0; sqlite3ErrorMsg(pParse, @@ -156667,344 +154002,342 @@ static YYACTIONTYPE yy_reduce( "statements within triggers"); } break; - case 259: /* tridxby ::= INDEXED BY nm */ + case 257: /* tridxby ::= INDEXED BY nm */ { sqlite3ErrorMsg(pParse, "the INDEXED BY clause is not allowed on UPDATE or DELETE statements " "within triggers"); } break; - case 260: /* tridxby ::= NOT INDEXED */ + case 258: /* tridxby ::= NOT INDEXED */ { sqlite3ErrorMsg(pParse, "the NOT INDEXED clause is not allowed on UPDATE or DELETE statements " "within triggers"); } break; - case 261: /* trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt scanpt */ -{yylhsminor.yy447 = sqlite3TriggerUpdateStep(pParse, &yymsp[-5].minor.yy0, yymsp[-2].minor.yy242, yymsp[-1].minor.yy202, yymsp[-6].minor.yy192, yymsp[-7].minor.yy0.z, yymsp[0].minor.yy436);} - yymsp[-7].minor.yy447 = yylhsminor.yy447; + case 259: /* trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt scanpt */ +{yylhsminor.yy527 = sqlite3TriggerUpdateStep(pParse, &yymsp[-5].minor.yy0, yymsp[-2].minor.yy138, yymsp[-1].minor.yy46, yymsp[-6].minor.yy32, yymsp[-7].minor.yy0.z, yymsp[0].minor.yy8);} + yymsp[-7].minor.yy527 = yylhsminor.yy527; break; - case 262: /* trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt */ + case 260: /* trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt */ { - yylhsminor.yy447 = sqlite3TriggerInsertStep(pParse,&yymsp[-4].minor.yy0,yymsp[-3].minor.yy600,yymsp[-2].minor.yy539,yymsp[-6].minor.yy192,yymsp[-1].minor.yy318,yymsp[-7].minor.yy436,yymsp[0].minor.yy436);/*yylhsminor.yy447-overwrites-yymsp[-6].minor.yy192*/ + yylhsminor.yy527 = sqlite3TriggerInsertStep(pParse,&yymsp[-4].minor.yy0,yymsp[-3].minor.yy406,yymsp[-2].minor.yy25,yymsp[-6].minor.yy32,yymsp[-1].minor.yy288,yymsp[-7].minor.yy8,yymsp[0].minor.yy8);/*yylhsminor.yy527-overwrites-yymsp[-6].minor.yy32*/ } - yymsp[-7].minor.yy447 = yylhsminor.yy447; + yymsp[-7].minor.yy527 = yylhsminor.yy527; break; - case 263: /* trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt */ -{yylhsminor.yy447 = sqlite3TriggerDeleteStep(pParse, &yymsp[-3].minor.yy0, yymsp[-1].minor.yy202, yymsp[-5].minor.yy0.z, yymsp[0].minor.yy436);} - yymsp[-5].minor.yy447 = yylhsminor.yy447; + case 261: /* trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt */ +{yylhsminor.yy527 = sqlite3TriggerDeleteStep(pParse, &yymsp[-3].minor.yy0, yymsp[-1].minor.yy46, yymsp[-5].minor.yy0.z, yymsp[0].minor.yy8);} + yymsp[-5].minor.yy527 = yylhsminor.yy527; break; - case 264: /* trigger_cmd ::= scanpt select scanpt */ -{yylhsminor.yy447 = sqlite3TriggerSelectStep(pParse->db, yymsp[-1].minor.yy539, yymsp[-2].minor.yy436, yymsp[0].minor.yy436); /*yylhsminor.yy447-overwrites-yymsp[-1].minor.yy539*/} - yymsp[-2].minor.yy447 = yylhsminor.yy447; + case 262: /* trigger_cmd ::= scanpt select scanpt */ +{yylhsminor.yy527 = sqlite3TriggerSelectStep(pParse->db, yymsp[-1].minor.yy25, yymsp[-2].minor.yy8, yymsp[0].minor.yy8); /*yylhsminor.yy527-overwrites-yymsp[-1].minor.yy25*/} + yymsp[-2].minor.yy527 = yylhsminor.yy527; break; - case 265: /* expr ::= RAISE LP IGNORE RP */ + case 263: /* expr ::= RAISE LP IGNORE RP */ { - yymsp[-3].minor.yy202 = sqlite3PExpr(pParse, TK_RAISE, 0, 0); - if( yymsp[-3].minor.yy202 ){ - yymsp[-3].minor.yy202->affExpr = OE_Ignore; + yymsp[-3].minor.yy46 = sqlite3PExpr(pParse, TK_RAISE, 0, 0); + if( yymsp[-3].minor.yy46 ){ + yymsp[-3].minor.yy46->affExpr = OE_Ignore; } } break; - case 266: /* expr ::= RAISE LP raisetype COMMA nm RP */ + case 264: /* expr ::= RAISE LP raisetype COMMA nm RP */ { - yymsp[-5].minor.yy202 = sqlite3ExprAlloc(pParse->db, TK_RAISE, &yymsp[-1].minor.yy0, 1); - if( yymsp[-5].minor.yy202 ) { - yymsp[-5].minor.yy202->affExpr = (char)yymsp[-3].minor.yy192; + yymsp[-5].minor.yy46 = sqlite3ExprAlloc(pParse->db, TK_RAISE, &yymsp[-1].minor.yy0, 1); + if( yymsp[-5].minor.yy46 ) { + yymsp[-5].minor.yy46->affExpr = (char)yymsp[-3].minor.yy32; } } break; - case 267: /* raisetype ::= ROLLBACK */ -{yymsp[0].minor.yy192 = OE_Rollback;} + case 265: /* raisetype ::= ROLLBACK */ +{yymsp[0].minor.yy32 = OE_Rollback;} break; - case 269: /* raisetype ::= FAIL */ -{yymsp[0].minor.yy192 = OE_Fail;} + case 267: /* raisetype ::= FAIL */ +{yymsp[0].minor.yy32 = OE_Fail;} break; - case 270: /* cmd ::= DROP TRIGGER ifexists fullname */ + case 268: /* cmd ::= DROP TRIGGER ifexists fullname */ { - sqlite3DropTrigger(pParse,yymsp[0].minor.yy47,yymsp[-1].minor.yy192); + sqlite3DropTrigger(pParse,yymsp[0].minor.yy609,yymsp[-1].minor.yy32); } break; - case 271: /* cmd ::= ATTACH database_kw_opt expr AS expr key_opt */ + case 269: /* cmd ::= ATTACH database_kw_opt expr AS expr key_opt */ { - sqlite3Attach(pParse, yymsp[-3].minor.yy202, yymsp[-1].minor.yy202, yymsp[0].minor.yy202); + sqlite3Attach(pParse, yymsp[-3].minor.yy46, yymsp[-1].minor.yy46, yymsp[0].minor.yy46); } break; - case 272: /* cmd ::= DETACH database_kw_opt expr */ + case 270: /* cmd ::= DETACH database_kw_opt expr */ { - sqlite3Detach(pParse, yymsp[0].minor.yy202); + sqlite3Detach(pParse, yymsp[0].minor.yy46); } break; - case 275: /* cmd ::= REINDEX */ + case 273: /* cmd ::= REINDEX */ {sqlite3Reindex(pParse, 0, 0);} break; - case 276: /* cmd ::= REINDEX nm dbnm */ + case 274: /* cmd ::= REINDEX nm dbnm */ {sqlite3Reindex(pParse, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0);} break; - case 277: /* cmd ::= ANALYZE */ + case 275: /* cmd ::= ANALYZE */ {sqlite3Analyze(pParse, 0, 0);} break; - case 278: /* cmd ::= ANALYZE nm dbnm */ + case 276: /* cmd ::= ANALYZE nm dbnm */ {sqlite3Analyze(pParse, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0);} break; - case 279: /* cmd ::= ALTER TABLE fullname RENAME TO nm */ + case 277: /* cmd ::= ALTER TABLE fullname RENAME TO nm */ { - sqlite3AlterRenameTable(pParse,yymsp[-3].minor.yy47,&yymsp[0].minor.yy0); + sqlite3AlterRenameTable(pParse,yymsp[-3].minor.yy609,&yymsp[0].minor.yy0); } break; - case 280: /* cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */ + case 278: /* cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */ { yymsp[-1].minor.yy0.n = (int)(pParse->sLastToken.z-yymsp[-1].minor.yy0.z) + pParse->sLastToken.n; sqlite3AlterFinishAddColumn(pParse, &yymsp[-1].minor.yy0); } break; - case 281: /* add_column_fullname ::= fullname */ + case 279: /* add_column_fullname ::= fullname */ { disableLookaside(pParse); - sqlite3AlterBeginAddColumn(pParse, yymsp[0].minor.yy47); + sqlite3AlterBeginAddColumn(pParse, yymsp[0].minor.yy609); } break; - case 282: /* cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm */ + case 280: /* cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm */ { - sqlite3AlterRenameColumn(pParse, yymsp[-5].minor.yy47, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); + sqlite3AlterRenameColumn(pParse, yymsp[-5].minor.yy609, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); } break; - case 283: /* cmd ::= create_vtab */ + case 281: /* cmd ::= create_vtab */ {sqlite3VtabFinishParse(pParse,0);} break; - case 284: /* cmd ::= create_vtab LP vtabarglist RP */ + case 282: /* cmd ::= create_vtab LP vtabarglist RP */ {sqlite3VtabFinishParse(pParse,&yymsp[0].minor.yy0);} break; - case 285: /* create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */ + case 283: /* create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */ { - sqlite3VtabBeginParse(pParse, &yymsp[-3].minor.yy0, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-4].minor.yy192); + sqlite3VtabBeginParse(pParse, &yymsp[-3].minor.yy0, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-4].minor.yy32); } break; - case 286: /* vtabarg ::= */ + case 284: /* vtabarg ::= */ {sqlite3VtabArgInit(pParse);} break; - case 287: /* vtabargtoken ::= ANY */ - case 288: /* vtabargtoken ::= lp anylist RP */ yytestcase(yyruleno==288); - case 289: /* lp ::= LP */ yytestcase(yyruleno==289); + case 285: /* vtabargtoken ::= ANY */ + case 286: /* vtabargtoken ::= lp anylist RP */ yytestcase(yyruleno==286); + case 287: /* lp ::= LP */ yytestcase(yyruleno==287); {sqlite3VtabArgExtend(pParse,&yymsp[0].minor.yy0);} break; - case 290: /* with ::= WITH wqlist */ - case 291: /* with ::= WITH RECURSIVE wqlist */ yytestcase(yyruleno==291); -{ sqlite3WithPush(pParse, yymsp[0].minor.yy131, 1); } + case 288: /* with ::= WITH wqlist */ + case 289: /* with ::= WITH RECURSIVE wqlist */ yytestcase(yyruleno==289); +{ sqlite3WithPush(pParse, yymsp[0].minor.yy297, 1); } break; - case 292: /* wqlist ::= nm eidlist_opt AS LP select RP */ + case 290: /* wqlist ::= nm eidlist_opt AS LP select RP */ { - yymsp[-5].minor.yy131 = sqlite3WithAdd(pParse, 0, &yymsp[-5].minor.yy0, yymsp[-4].minor.yy242, yymsp[-1].minor.yy539); /*A-overwrites-X*/ + yymsp[-5].minor.yy297 = sqlite3WithAdd(pParse, 0, &yymsp[-5].minor.yy0, yymsp[-4].minor.yy138, yymsp[-1].minor.yy25); /*A-overwrites-X*/ } break; - case 293: /* wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP */ + case 291: /* wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP */ { - yymsp[-7].minor.yy131 = sqlite3WithAdd(pParse, yymsp[-7].minor.yy131, &yymsp[-5].minor.yy0, yymsp[-4].minor.yy242, yymsp[-1].minor.yy539); + yymsp[-7].minor.yy297 = sqlite3WithAdd(pParse, yymsp[-7].minor.yy297, &yymsp[-5].minor.yy0, yymsp[-4].minor.yy138, yymsp[-1].minor.yy25); } break; - case 294: /* windowdefn_list ::= windowdefn */ -{ yylhsminor.yy303 = yymsp[0].minor.yy303; } - yymsp[0].minor.yy303 = yylhsminor.yy303; + case 292: /* windowdefn_list ::= windowdefn */ +{ yylhsminor.yy455 = yymsp[0].minor.yy455; } + yymsp[0].minor.yy455 = yylhsminor.yy455; break; - case 295: /* windowdefn_list ::= windowdefn_list COMMA windowdefn */ + case 293: /* windowdefn_list ::= windowdefn_list COMMA windowdefn */ { - assert( yymsp[0].minor.yy303!=0 ); - sqlite3WindowChain(pParse, yymsp[0].minor.yy303, yymsp[-2].minor.yy303); - yymsp[0].minor.yy303->pNextWin = yymsp[-2].minor.yy303; - yylhsminor.yy303 = yymsp[0].minor.yy303; + assert( yymsp[0].minor.yy455!=0 ); + sqlite3WindowChain(pParse, yymsp[0].minor.yy455, yymsp[-2].minor.yy455); + yymsp[0].minor.yy455->pNextWin = yymsp[-2].minor.yy455; + yylhsminor.yy455 = yymsp[0].minor.yy455; } - yymsp[-2].minor.yy303 = yylhsminor.yy303; + yymsp[-2].minor.yy455 = yylhsminor.yy455; break; - case 296: /* windowdefn ::= nm AS LP window RP */ + case 294: /* windowdefn ::= nm AS LP window RP */ { - if( ALWAYS(yymsp[-1].minor.yy303) ){ - yymsp[-1].minor.yy303->zName = sqlite3DbStrNDup(pParse->db, yymsp[-4].minor.yy0.z, yymsp[-4].minor.yy0.n); + if( ALWAYS(yymsp[-1].minor.yy455) ){ + yymsp[-1].minor.yy455->zName = sqlite3DbStrNDup(pParse->db, yymsp[-4].minor.yy0.z, yymsp[-4].minor.yy0.n); } - yylhsminor.yy303 = yymsp[-1].minor.yy303; + yylhsminor.yy455 = yymsp[-1].minor.yy455; } - yymsp[-4].minor.yy303 = yylhsminor.yy303; + yymsp[-4].minor.yy455 = yylhsminor.yy455; break; - case 297: /* window ::= PARTITION BY nexprlist orderby_opt frame_opt */ + case 295: /* window ::= PARTITION BY nexprlist orderby_opt frame_opt */ { - yymsp[-4].minor.yy303 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy303, yymsp[-2].minor.yy242, yymsp[-1].minor.yy242, 0); + yymsp[-4].minor.yy455 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy455, yymsp[-2].minor.yy138, yymsp[-1].minor.yy138, 0); } break; - case 298: /* window ::= nm PARTITION BY nexprlist orderby_opt frame_opt */ + case 296: /* window ::= nm PARTITION BY nexprlist orderby_opt frame_opt */ { - yylhsminor.yy303 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy303, yymsp[-2].minor.yy242, yymsp[-1].minor.yy242, &yymsp[-5].minor.yy0); + yylhsminor.yy455 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy455, yymsp[-2].minor.yy138, yymsp[-1].minor.yy138, &yymsp[-5].minor.yy0); } - yymsp[-5].minor.yy303 = yylhsminor.yy303; + yymsp[-5].minor.yy455 = yylhsminor.yy455; break; - case 299: /* window ::= ORDER BY sortlist frame_opt */ + case 297: /* window ::= ORDER BY sortlist frame_opt */ { - yymsp[-3].minor.yy303 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy303, 0, yymsp[-1].minor.yy242, 0); + yymsp[-3].minor.yy455 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy455, 0, yymsp[-1].minor.yy138, 0); } break; - case 300: /* window ::= nm ORDER BY sortlist frame_opt */ + case 298: /* window ::= nm ORDER BY sortlist frame_opt */ { - yylhsminor.yy303 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy303, 0, yymsp[-1].minor.yy242, &yymsp[-4].minor.yy0); + yylhsminor.yy455 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy455, 0, yymsp[-1].minor.yy138, &yymsp[-4].minor.yy0); } - yymsp[-4].minor.yy303 = yylhsminor.yy303; + yymsp[-4].minor.yy455 = yylhsminor.yy455; break; - case 301: /* window ::= frame_opt */ - case 320: /* filter_over ::= over_clause */ yytestcase(yyruleno==320); + case 299: /* window ::= frame_opt */ + case 318: /* filter_over ::= over_clause */ yytestcase(yyruleno==318); { - yylhsminor.yy303 = yymsp[0].minor.yy303; + yylhsminor.yy455 = yymsp[0].minor.yy455; } - yymsp[0].minor.yy303 = yylhsminor.yy303; + yymsp[0].minor.yy455 = yylhsminor.yy455; break; - case 302: /* window ::= nm frame_opt */ + case 300: /* window ::= nm frame_opt */ { - yylhsminor.yy303 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy303, 0, 0, &yymsp[-1].minor.yy0); + yylhsminor.yy455 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy455, 0, 0, &yymsp[-1].minor.yy0); } - yymsp[-1].minor.yy303 = yylhsminor.yy303; + yymsp[-1].minor.yy455 = yylhsminor.yy455; break; - case 303: /* frame_opt ::= */ + case 301: /* frame_opt ::= */ { - yymsp[1].minor.yy303 = sqlite3WindowAlloc(pParse, 0, TK_UNBOUNDED, 0, TK_CURRENT, 0, 0); + yymsp[1].minor.yy455 = sqlite3WindowAlloc(pParse, 0, TK_UNBOUNDED, 0, TK_CURRENT, 0, 0); } break; - case 304: /* frame_opt ::= range_or_rows frame_bound_s frame_exclude_opt */ + case 302: /* frame_opt ::= range_or_rows frame_bound_s frame_exclude_opt */ { - yylhsminor.yy303 = sqlite3WindowAlloc(pParse, yymsp[-2].minor.yy192, yymsp[-1].minor.yy77.eType, yymsp[-1].minor.yy77.pExpr, TK_CURRENT, 0, yymsp[0].minor.yy58); + yylhsminor.yy455 = sqlite3WindowAlloc(pParse, yymsp[-2].minor.yy32, yymsp[-1].minor.yy57.eType, yymsp[-1].minor.yy57.pExpr, TK_CURRENT, 0, yymsp[0].minor.yy118); } - yymsp[-2].minor.yy303 = yylhsminor.yy303; + yymsp[-2].minor.yy455 = yylhsminor.yy455; break; - case 305: /* frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e frame_exclude_opt */ + case 303: /* frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e frame_exclude_opt */ { - yylhsminor.yy303 = sqlite3WindowAlloc(pParse, yymsp[-5].minor.yy192, yymsp[-3].minor.yy77.eType, yymsp[-3].minor.yy77.pExpr, yymsp[-1].minor.yy77.eType, yymsp[-1].minor.yy77.pExpr, yymsp[0].minor.yy58); + yylhsminor.yy455 = sqlite3WindowAlloc(pParse, yymsp[-5].minor.yy32, yymsp[-3].minor.yy57.eType, yymsp[-3].minor.yy57.pExpr, yymsp[-1].minor.yy57.eType, yymsp[-1].minor.yy57.pExpr, yymsp[0].minor.yy118); } - yymsp[-5].minor.yy303 = yylhsminor.yy303; + yymsp[-5].minor.yy455 = yylhsminor.yy455; break; - case 307: /* frame_bound_s ::= frame_bound */ - case 309: /* frame_bound_e ::= frame_bound */ yytestcase(yyruleno==309); -{yylhsminor.yy77 = yymsp[0].minor.yy77;} - yymsp[0].minor.yy77 = yylhsminor.yy77; + case 305: /* frame_bound_s ::= frame_bound */ + case 307: /* frame_bound_e ::= frame_bound */ yytestcase(yyruleno==307); +{yylhsminor.yy57 = yymsp[0].minor.yy57;} + yymsp[0].minor.yy57 = yylhsminor.yy57; break; - case 308: /* frame_bound_s ::= UNBOUNDED PRECEDING */ - case 310: /* frame_bound_e ::= UNBOUNDED FOLLOWING */ yytestcase(yyruleno==310); - case 312: /* frame_bound ::= CURRENT ROW */ yytestcase(yyruleno==312); -{yylhsminor.yy77.eType = yymsp[-1].major; yylhsminor.yy77.pExpr = 0;} - yymsp[-1].minor.yy77 = yylhsminor.yy77; + case 306: /* frame_bound_s ::= UNBOUNDED PRECEDING */ + case 308: /* frame_bound_e ::= UNBOUNDED FOLLOWING */ yytestcase(yyruleno==308); + case 310: /* frame_bound ::= CURRENT ROW */ yytestcase(yyruleno==310); +{yylhsminor.yy57.eType = yymsp[-1].major; yylhsminor.yy57.pExpr = 0;} + yymsp[-1].minor.yy57 = yylhsminor.yy57; break; - case 311: /* frame_bound ::= expr PRECEDING|FOLLOWING */ -{yylhsminor.yy77.eType = yymsp[0].major; yylhsminor.yy77.pExpr = yymsp[-1].minor.yy202;} - yymsp[-1].minor.yy77 = yylhsminor.yy77; + case 309: /* frame_bound ::= expr PRECEDING|FOLLOWING */ +{yylhsminor.yy57.eType = yymsp[0].major; yylhsminor.yy57.pExpr = yymsp[-1].minor.yy46;} + yymsp[-1].minor.yy57 = yylhsminor.yy57; break; - case 313: /* frame_exclude_opt ::= */ -{yymsp[1].minor.yy58 = 0;} + case 311: /* frame_exclude_opt ::= */ +{yymsp[1].minor.yy118 = 0;} break; - case 314: /* frame_exclude_opt ::= EXCLUDE frame_exclude */ -{yymsp[-1].minor.yy58 = yymsp[0].minor.yy58;} + case 312: /* frame_exclude_opt ::= EXCLUDE frame_exclude */ +{yymsp[-1].minor.yy118 = yymsp[0].minor.yy118;} break; - case 315: /* frame_exclude ::= NO OTHERS */ - case 316: /* frame_exclude ::= CURRENT ROW */ yytestcase(yyruleno==316); -{yymsp[-1].minor.yy58 = yymsp[-1].major; /*A-overwrites-X*/} + case 313: /* frame_exclude ::= NO OTHERS */ + case 314: /* frame_exclude ::= CURRENT ROW */ yytestcase(yyruleno==314); +{yymsp[-1].minor.yy118 = yymsp[-1].major; /*A-overwrites-X*/} break; - case 317: /* frame_exclude ::= GROUP|TIES */ -{yymsp[0].minor.yy58 = yymsp[0].major; /*A-overwrites-X*/} + case 315: /* frame_exclude ::= GROUP|TIES */ +{yymsp[0].minor.yy118 = yymsp[0].major; /*A-overwrites-X*/} break; - case 318: /* window_clause ::= WINDOW windowdefn_list */ -{ yymsp[-1].minor.yy303 = yymsp[0].minor.yy303; } + case 316: /* window_clause ::= WINDOW windowdefn_list */ +{ yymsp[-1].minor.yy455 = yymsp[0].minor.yy455; } break; - case 319: /* filter_over ::= filter_clause over_clause */ + case 317: /* filter_over ::= filter_clause over_clause */ { - yymsp[0].minor.yy303->pFilter = yymsp[-1].minor.yy202; - yylhsminor.yy303 = yymsp[0].minor.yy303; + yymsp[0].minor.yy455->pFilter = yymsp[-1].minor.yy46; + yylhsminor.yy455 = yymsp[0].minor.yy455; } - yymsp[-1].minor.yy303 = yylhsminor.yy303; + yymsp[-1].minor.yy455 = yylhsminor.yy455; break; - case 321: /* filter_over ::= filter_clause */ + case 319: /* filter_over ::= filter_clause */ { - yylhsminor.yy303 = (Window*)sqlite3DbMallocZero(pParse->db, sizeof(Window)); - if( yylhsminor.yy303 ){ - yylhsminor.yy303->eFrmType = TK_FILTER; - yylhsminor.yy303->pFilter = yymsp[0].minor.yy202; + yylhsminor.yy455 = (Window*)sqlite3DbMallocZero(pParse->db, sizeof(Window)); + if( yylhsminor.yy455 ){ + yylhsminor.yy455->eFrmType = TK_FILTER; + yylhsminor.yy455->pFilter = yymsp[0].minor.yy46; }else{ - sqlite3ExprDelete(pParse->db, yymsp[0].minor.yy202); + sqlite3ExprDelete(pParse->db, yymsp[0].minor.yy46); } } - yymsp[0].minor.yy303 = yylhsminor.yy303; + yymsp[0].minor.yy455 = yylhsminor.yy455; break; - case 322: /* over_clause ::= OVER LP window RP */ + case 320: /* over_clause ::= OVER LP window RP */ { - yymsp[-3].minor.yy303 = yymsp[-1].minor.yy303; - assert( yymsp[-3].minor.yy303!=0 ); + yymsp[-3].minor.yy455 = yymsp[-1].minor.yy455; + assert( yymsp[-3].minor.yy455!=0 ); } break; - case 323: /* over_clause ::= OVER nm */ + case 321: /* over_clause ::= OVER nm */ { - yymsp[-1].minor.yy303 = (Window*)sqlite3DbMallocZero(pParse->db, sizeof(Window)); - if( yymsp[-1].minor.yy303 ){ - yymsp[-1].minor.yy303->zName = sqlite3DbStrNDup(pParse->db, yymsp[0].minor.yy0.z, yymsp[0].minor.yy0.n); + yymsp[-1].minor.yy455 = (Window*)sqlite3DbMallocZero(pParse->db, sizeof(Window)); + if( yymsp[-1].minor.yy455 ){ + yymsp[-1].minor.yy455->zName = sqlite3DbStrNDup(pParse->db, yymsp[0].minor.yy0.z, yymsp[0].minor.yy0.n); } } break; - case 324: /* filter_clause ::= FILTER LP WHERE expr RP */ -{ yymsp[-4].minor.yy202 = yymsp[-1].minor.yy202; } + case 322: /* filter_clause ::= FILTER LP WHERE expr RP */ +{ yymsp[-4].minor.yy46 = yymsp[-1].minor.yy46; } break; default: - /* (325) input ::= cmdlist */ yytestcase(yyruleno==325); - /* (326) cmdlist ::= cmdlist ecmd */ yytestcase(yyruleno==326); - /* (327) cmdlist ::= ecmd (OPTIMIZED OUT) */ assert(yyruleno!=327); - /* (328) ecmd ::= SEMI */ yytestcase(yyruleno==328); - /* (329) ecmd ::= cmdx SEMI */ yytestcase(yyruleno==329); - /* (330) ecmd ::= explain cmdx SEMI (NEVER REDUCES) */ assert(yyruleno!=330); - /* (331) trans_opt ::= */ yytestcase(yyruleno==331); - /* (332) trans_opt ::= TRANSACTION */ yytestcase(yyruleno==332); - /* (333) trans_opt ::= TRANSACTION nm */ yytestcase(yyruleno==333); - /* (334) savepoint_opt ::= SAVEPOINT */ yytestcase(yyruleno==334); - /* (335) savepoint_opt ::= */ yytestcase(yyruleno==335); - /* (336) cmd ::= create_table create_table_args */ yytestcase(yyruleno==336); - /* (337) columnlist ::= columnlist COMMA columnname carglist */ yytestcase(yyruleno==337); - /* (338) columnlist ::= columnname carglist */ yytestcase(yyruleno==338); - /* (339) nm ::= ID|INDEXED */ yytestcase(yyruleno==339); - /* (340) nm ::= STRING */ yytestcase(yyruleno==340); - /* (341) nm ::= JOIN_KW */ yytestcase(yyruleno==341); - /* (342) typetoken ::= typename */ yytestcase(yyruleno==342); - /* (343) typename ::= ID|STRING */ yytestcase(yyruleno==343); - /* (344) signed ::= plus_num (OPTIMIZED OUT) */ assert(yyruleno!=344); - /* (345) signed ::= minus_num (OPTIMIZED OUT) */ assert(yyruleno!=345); - /* (346) carglist ::= carglist ccons */ yytestcase(yyruleno==346); - /* (347) carglist ::= */ yytestcase(yyruleno==347); - /* (348) ccons ::= NULL onconf */ yytestcase(yyruleno==348); - /* (349) ccons ::= GENERATED ALWAYS AS generated */ yytestcase(yyruleno==349); - /* (350) ccons ::= AS generated */ yytestcase(yyruleno==350); - /* (351) conslist_opt ::= COMMA conslist */ yytestcase(yyruleno==351); - /* (352) conslist ::= conslist tconscomma tcons */ yytestcase(yyruleno==352); - /* (353) conslist ::= tcons (OPTIMIZED OUT) */ assert(yyruleno!=353); - /* (354) tconscomma ::= */ yytestcase(yyruleno==354); - /* (355) defer_subclause_opt ::= defer_subclause (OPTIMIZED OUT) */ assert(yyruleno!=355); - /* (356) resolvetype ::= raisetype (OPTIMIZED OUT) */ assert(yyruleno!=356); - /* (357) selectnowith ::= oneselect (OPTIMIZED OUT) */ assert(yyruleno!=357); - /* (358) oneselect ::= values */ yytestcase(yyruleno==358); - /* (359) sclp ::= selcollist COMMA */ yytestcase(yyruleno==359); - /* (360) as ::= ID|STRING */ yytestcase(yyruleno==360); - /* (361) expr ::= term (OPTIMIZED OUT) */ assert(yyruleno!=361); - /* (362) likeop ::= LIKE_KW|MATCH */ yytestcase(yyruleno==362); - /* (363) exprlist ::= nexprlist */ yytestcase(yyruleno==363); - /* (364) nmnum ::= plus_num (OPTIMIZED OUT) */ assert(yyruleno!=364); - /* (365) nmnum ::= nm (OPTIMIZED OUT) */ assert(yyruleno!=365); - /* (366) nmnum ::= ON */ yytestcase(yyruleno==366); - /* (367) nmnum ::= DELETE */ yytestcase(yyruleno==367); - /* (368) nmnum ::= DEFAULT */ yytestcase(yyruleno==368); - /* (369) plus_num ::= INTEGER|FLOAT */ yytestcase(yyruleno==369); - /* (370) foreach_clause ::= */ yytestcase(yyruleno==370); - /* (371) foreach_clause ::= FOR EACH ROW */ yytestcase(yyruleno==371); - /* (372) trnm ::= nm */ yytestcase(yyruleno==372); - /* (373) tridxby ::= */ yytestcase(yyruleno==373); - /* (374) database_kw_opt ::= DATABASE */ yytestcase(yyruleno==374); - /* (375) database_kw_opt ::= */ yytestcase(yyruleno==375); - /* (376) kwcolumn_opt ::= */ yytestcase(yyruleno==376); - /* (377) kwcolumn_opt ::= COLUMNKW */ yytestcase(yyruleno==377); - /* (378) vtabarglist ::= vtabarg */ yytestcase(yyruleno==378); - /* (379) vtabarglist ::= vtabarglist COMMA vtabarg */ yytestcase(yyruleno==379); - /* (380) vtabarg ::= vtabarg vtabargtoken */ yytestcase(yyruleno==380); - /* (381) anylist ::= */ yytestcase(yyruleno==381); - /* (382) anylist ::= anylist LP anylist RP */ yytestcase(yyruleno==382); - /* (383) anylist ::= anylist ANY */ yytestcase(yyruleno==383); - /* (384) with ::= */ yytestcase(yyruleno==384); + /* (323) input ::= cmdlist */ yytestcase(yyruleno==323); + /* (324) cmdlist ::= cmdlist ecmd */ yytestcase(yyruleno==324); + /* (325) cmdlist ::= ecmd (OPTIMIZED OUT) */ assert(yyruleno!=325); + /* (326) ecmd ::= SEMI */ yytestcase(yyruleno==326); + /* (327) ecmd ::= cmdx SEMI */ yytestcase(yyruleno==327); + /* (328) ecmd ::= explain cmdx */ yytestcase(yyruleno==328); + /* (329) trans_opt ::= */ yytestcase(yyruleno==329); + /* (330) trans_opt ::= TRANSACTION */ yytestcase(yyruleno==330); + /* (331) trans_opt ::= TRANSACTION nm */ yytestcase(yyruleno==331); + /* (332) savepoint_opt ::= SAVEPOINT */ yytestcase(yyruleno==332); + /* (333) savepoint_opt ::= */ yytestcase(yyruleno==333); + /* (334) cmd ::= create_table create_table_args */ yytestcase(yyruleno==334); + /* (335) columnlist ::= columnlist COMMA columnname carglist */ yytestcase(yyruleno==335); + /* (336) columnlist ::= columnname carglist */ yytestcase(yyruleno==336); + /* (337) nm ::= ID|INDEXED */ yytestcase(yyruleno==337); + /* (338) nm ::= STRING */ yytestcase(yyruleno==338); + /* (339) nm ::= JOIN_KW */ yytestcase(yyruleno==339); + /* (340) typetoken ::= typename */ yytestcase(yyruleno==340); + /* (341) typename ::= ID|STRING */ yytestcase(yyruleno==341); + /* (342) signed ::= plus_num (OPTIMIZED OUT) */ assert(yyruleno!=342); + /* (343) signed ::= minus_num (OPTIMIZED OUT) */ assert(yyruleno!=343); + /* (344) carglist ::= carglist ccons */ yytestcase(yyruleno==344); + /* (345) carglist ::= */ yytestcase(yyruleno==345); + /* (346) ccons ::= NULL onconf */ yytestcase(yyruleno==346); + /* (347) conslist_opt ::= COMMA conslist */ yytestcase(yyruleno==347); + /* (348) conslist ::= conslist tconscomma tcons */ yytestcase(yyruleno==348); + /* (349) conslist ::= tcons (OPTIMIZED OUT) */ assert(yyruleno!=349); + /* (350) tconscomma ::= */ yytestcase(yyruleno==350); + /* (351) defer_subclause_opt ::= defer_subclause (OPTIMIZED OUT) */ assert(yyruleno!=351); + /* (352) resolvetype ::= raisetype (OPTIMIZED OUT) */ assert(yyruleno!=352); + /* (353) selectnowith ::= oneselect (OPTIMIZED OUT) */ assert(yyruleno!=353); + /* (354) oneselect ::= values */ yytestcase(yyruleno==354); + /* (355) sclp ::= selcollist COMMA */ yytestcase(yyruleno==355); + /* (356) as ::= ID|STRING */ yytestcase(yyruleno==356); + /* (357) expr ::= term (OPTIMIZED OUT) */ assert(yyruleno!=357); + /* (358) likeop ::= LIKE_KW|MATCH */ yytestcase(yyruleno==358); + /* (359) exprlist ::= nexprlist */ yytestcase(yyruleno==359); + /* (360) nmnum ::= plus_num (OPTIMIZED OUT) */ assert(yyruleno!=360); + /* (361) nmnum ::= nm (OPTIMIZED OUT) */ assert(yyruleno!=361); + /* (362) nmnum ::= ON */ yytestcase(yyruleno==362); + /* (363) nmnum ::= DELETE */ yytestcase(yyruleno==363); + /* (364) nmnum ::= DEFAULT */ yytestcase(yyruleno==364); + /* (365) plus_num ::= INTEGER|FLOAT */ yytestcase(yyruleno==365); + /* (366) foreach_clause ::= */ yytestcase(yyruleno==366); + /* (367) foreach_clause ::= FOR EACH ROW */ yytestcase(yyruleno==367); + /* (368) trnm ::= nm */ yytestcase(yyruleno==368); + /* (369) tridxby ::= */ yytestcase(yyruleno==369); + /* (370) database_kw_opt ::= DATABASE */ yytestcase(yyruleno==370); + /* (371) database_kw_opt ::= */ yytestcase(yyruleno==371); + /* (372) kwcolumn_opt ::= */ yytestcase(yyruleno==372); + /* (373) kwcolumn_opt ::= COLUMNKW */ yytestcase(yyruleno==373); + /* (374) vtabarglist ::= vtabarg */ yytestcase(yyruleno==374); + /* (375) vtabarglist ::= vtabarglist COMMA vtabarg */ yytestcase(yyruleno==375); + /* (376) vtabarg ::= vtabarg vtabargtoken */ yytestcase(yyruleno==376); + /* (377) anylist ::= */ yytestcase(yyruleno==377); + /* (378) anylist ::= anylist LP anylist RP */ yytestcase(yyruleno==378); + /* (379) anylist ::= anylist ANY */ yytestcase(yyruleno==379); + /* (380) with ::= */ yytestcase(yyruleno==380); break; /********** End reduce actions ************************************************/ }; @@ -157300,8 +154633,8 @@ SQLITE_PRIVATE int sqlite3ParserFallback(int iToken){ return yyFallback[iToken]; #else (void)iToken; - return 0; #endif + return 0; } /************** End of parse.c ***********************************************/ @@ -157466,20 +154799,20 @@ const unsigned char ebcdicToAscii[] = { ** is substantially reduced. This is important for embedded applications ** on platforms with limited memory. */ -/* Hash score: 227 */ -/* zKWText[] encodes 984 bytes of keyword text in 648 bytes */ +/* Hash score: 221 */ +/* zKWText[] encodes 967 bytes of keyword text in 638 bytes */ /* REINDEXEDESCAPEACHECKEYBEFOREIGNOREGEXPLAINSTEADDATABASELECT */ /* ABLEFTHENDEFERRABLELSEXCLUDELETEMPORARYISNULLSAVEPOINTERSECT */ /* IESNOTNULLIKEXCEPTRANSACTIONATURALTERAISEXCLUSIVEXISTS */ -/* CONSTRAINTOFFSETRIGGERANGENERATEDETACHAVINGLOBEGINNEREFERENCES */ -/* UNIQUERYWITHOUTERELEASEATTACHBETWEENOTHINGROUPSCASCADEFAULT */ -/* CASECOLLATECREATECURRENT_DATEIMMEDIATEJOINSERTMATCHPLANALYZE */ -/* PRAGMABORTUPDATEVALUESVIRTUALWAYSWHENWHERECURSIVEAFTERENAMEAND */ -/* EFERREDISTINCTAUTOINCREMENTCASTCOLUMNCOMMITCONFLICTCROSS */ -/* CURRENT_TIMESTAMPARTITIONDROPRECEDINGFAILASTFILTEREPLACEFIRST */ -/* FOLLOWINGFROMFULLIMITIFORDERESTRICTOTHERSOVERIGHTROLLBACKROWS */ +/* CONSTRAINTOFFSETRIGGEREFERENCESUNIQUERYWITHOUTERELEASEATTACH */ +/* AVINGLOBEGINNERANGEBETWEENOTHINGROUPSCASCADETACHCASECOLLATE */ +/* CREATECURRENT_DATEIMMEDIATEJOINSERTMATCHPLANALYZEPRAGMABORT */ +/* UPDATEVALUESVIRTUALASTWHENWHERECURSIVEAFTERENAMEANDEFAULT */ +/* AUTOINCREMENTCASTCOLUMNCOMMITCONFLICTCROSSCURRENT_TIMESTAMP */ +/* ARTITIONDEFERREDISTINCTDROPRECEDINGFAILIMITFILTEREPLACEFIRST */ +/* FOLLOWINGFROMFULLIFORDERESTRICTOTHERSOVERIGHTROLLBACKROWS */ /* UNBOUNDEDUNIONUSINGVACUUMVIEWINDOWBYINITIALLYPRIMARY */ -static const char zKWText[647] = { +static const char zKWText[637] = { 'R','E','I','N','D','E','X','E','D','E','S','C','A','P','E','A','C','H', 'E','C','K','E','Y','B','E','F','O','R','E','I','G','N','O','R','E','G', 'E','X','P','L','A','I','N','S','T','E','A','D','D','A','T','A','B','A', @@ -157490,96 +154823,93 @@ static const char zKWText[647] = { 'N','U','L','L','I','K','E','X','C','E','P','T','R','A','N','S','A','C', 'T','I','O','N','A','T','U','R','A','L','T','E','R','A','I','S','E','X', 'C','L','U','S','I','V','E','X','I','S','T','S','C','O','N','S','T','R', - 'A','I','N','T','O','F','F','S','E','T','R','I','G','G','E','R','A','N', - 'G','E','N','E','R','A','T','E','D','E','T','A','C','H','A','V','I','N', - 'G','L','O','B','E','G','I','N','N','E','R','E','F','E','R','E','N','C', - 'E','S','U','N','I','Q','U','E','R','Y','W','I','T','H','O','U','T','E', - 'R','E','L','E','A','S','E','A','T','T','A','C','H','B','E','T','W','E', - 'E','N','O','T','H','I','N','G','R','O','U','P','S','C','A','S','C','A', - 'D','E','F','A','U','L','T','C','A','S','E','C','O','L','L','A','T','E', - 'C','R','E','A','T','E','C','U','R','R','E','N','T','_','D','A','T','E', - 'I','M','M','E','D','I','A','T','E','J','O','I','N','S','E','R','T','M', - 'A','T','C','H','P','L','A','N','A','L','Y','Z','E','P','R','A','G','M', - 'A','B','O','R','T','U','P','D','A','T','E','V','A','L','U','E','S','V', - 'I','R','T','U','A','L','W','A','Y','S','W','H','E','N','W','H','E','R', - 'E','C','U','R','S','I','V','E','A','F','T','E','R','E','N','A','M','E', - 'A','N','D','E','F','E','R','R','E','D','I','S','T','I','N','C','T','A', - 'U','T','O','I','N','C','R','E','M','E','N','T','C','A','S','T','C','O', - 'L','U','M','N','C','O','M','M','I','T','C','O','N','F','L','I','C','T', - 'C','R','O','S','S','C','U','R','R','E','N','T','_','T','I','M','E','S', - 'T','A','M','P','A','R','T','I','T','I','O','N','D','R','O','P','R','E', - 'C','E','D','I','N','G','F','A','I','L','A','S','T','F','I','L','T','E', - 'R','E','P','L','A','C','E','F','I','R','S','T','F','O','L','L','O','W', - 'I','N','G','F','R','O','M','F','U','L','L','I','M','I','T','I','F','O', - 'R','D','E','R','E','S','T','R','I','C','T','O','T','H','E','R','S','O', - 'V','E','R','I','G','H','T','R','O','L','L','B','A','C','K','R','O','W', - 'S','U','N','B','O','U','N','D','E','D','U','N','I','O','N','U','S','I', - 'N','G','V','A','C','U','U','M','V','I','E','W','I','N','D','O','W','B', - 'Y','I','N','I','T','I','A','L','L','Y','P','R','I','M','A','R','Y', + 'A','I','N','T','O','F','F','S','E','T','R','I','G','G','E','R','E','F', + 'E','R','E','N','C','E','S','U','N','I','Q','U','E','R','Y','W','I','T', + 'H','O','U','T','E','R','E','L','E','A','S','E','A','T','T','A','C','H', + 'A','V','I','N','G','L','O','B','E','G','I','N','N','E','R','A','N','G', + 'E','B','E','T','W','E','E','N','O','T','H','I','N','G','R','O','U','P', + 'S','C','A','S','C','A','D','E','T','A','C','H','C','A','S','E','C','O', + 'L','L','A','T','E','C','R','E','A','T','E','C','U','R','R','E','N','T', + '_','D','A','T','E','I','M','M','E','D','I','A','T','E','J','O','I','N', + 'S','E','R','T','M','A','T','C','H','P','L','A','N','A','L','Y','Z','E', + 'P','R','A','G','M','A','B','O','R','T','U','P','D','A','T','E','V','A', + 'L','U','E','S','V','I','R','T','U','A','L','A','S','T','W','H','E','N', + 'W','H','E','R','E','C','U','R','S','I','V','E','A','F','T','E','R','E', + 'N','A','M','E','A','N','D','E','F','A','U','L','T','A','U','T','O','I', + 'N','C','R','E','M','E','N','T','C','A','S','T','C','O','L','U','M','N', + 'C','O','M','M','I','T','C','O','N','F','L','I','C','T','C','R','O','S', + 'S','C','U','R','R','E','N','T','_','T','I','M','E','S','T','A','M','P', + 'A','R','T','I','T','I','O','N','D','E','F','E','R','R','E','D','I','S', + 'T','I','N','C','T','D','R','O','P','R','E','C','E','D','I','N','G','F', + 'A','I','L','I','M','I','T','F','I','L','T','E','R','E','P','L','A','C', + 'E','F','I','R','S','T','F','O','L','L','O','W','I','N','G','F','R','O', + 'M','F','U','L','L','I','F','O','R','D','E','R','E','S','T','R','I','C', + 'T','O','T','H','E','R','S','O','V','E','R','I','G','H','T','R','O','L', + 'L','B','A','C','K','R','O','W','S','U','N','B','O','U','N','D','E','D', + 'U','N','I','O','N','U','S','I','N','G','V','A','C','U','U','M','V','I', + 'E','W','I','N','D','O','W','B','Y','I','N','I','T','I','A','L','L','Y', + 'P','R','I','M','A','R','Y', }; /* aKWHash[i] is the hash value for the i-th keyword */ static const unsigned char aKWHash[127] = { - 84, 102, 132, 82, 114, 29, 0, 0, 91, 0, 85, 72, 0, - 53, 35, 86, 15, 0, 42, 94, 54, 126, 133, 19, 0, 0, - 138, 0, 40, 128, 0, 22, 104, 0, 9, 0, 0, 122, 80, - 0, 78, 6, 0, 65, 99, 145, 0, 134, 112, 0, 0, 48, - 0, 100, 24, 0, 17, 0, 27, 70, 23, 26, 5, 60, 140, - 107, 121, 0, 73, 101, 71, 143, 61, 119, 74, 0, 49, 0, - 11, 41, 0, 110, 0, 0, 0, 106, 10, 108, 113, 124, 14, - 50, 123, 0, 89, 0, 18, 120, 142, 56, 129, 137, 88, 83, - 37, 30, 125, 0, 0, 105, 51, 130, 127, 0, 34, 0, 0, - 44, 0, 95, 38, 39, 0, 20, 45, 116, 90, + 82, 113, 130, 80, 110, 29, 0, 0, 89, 0, 83, 70, 0, + 53, 35, 84, 15, 0, 129, 92, 64, 124, 131, 19, 0, 0, + 136, 0, 134, 126, 0, 22, 100, 0, 9, 0, 0, 121, 78, + 0, 76, 6, 0, 58, 97, 143, 0, 132, 108, 0, 0, 48, + 0, 111, 24, 0, 17, 0, 137, 63, 23, 26, 5, 65, 138, + 103, 120, 0, 142, 114, 69, 141, 66, 118, 72, 0, 98, 0, + 107, 41, 0, 106, 0, 0, 0, 102, 99, 104, 109, 123, 14, + 50, 122, 0, 87, 0, 139, 119, 140, 68, 127, 135, 86, 81, + 37, 91, 117, 0, 0, 101, 51, 128, 125, 0, 133, 0, 0, + 44, 0, 93, 67, 39, 0, 20, 45, 115, 88, }; /* aKWNext[] forms the hash collision chain. If aKWHash[i]==0 ** then the i-th keyword has no more hash collisions. Otherwise, ** the next keyword with the same hash is aKWHash[i]-1. */ -static const unsigned char aKWNext[145] = { - 0, 0, 0, 0, 4, 0, 43, 0, 0, 103, 111, 0, 0, - 0, 2, 0, 0, 141, 0, 0, 0, 13, 0, 0, 0, 0, - 139, 0, 0, 118, 52, 0, 0, 135, 12, 0, 0, 62, 0, - 136, 0, 131, 0, 0, 36, 0, 0, 28, 77, 0, 0, 0, - 0, 59, 0, 47, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 69, 0, 0, 0, 0, 0, 144, 3, 0, 58, 0, 1, - 75, 0, 0, 0, 31, 0, 0, 0, 0, 0, 0, 64, 66, - 63, 0, 0, 0, 0, 46, 0, 16, 0, 115, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 81, 97, 0, 8, 0, 109, - 21, 7, 67, 0, 79, 93, 117, 0, 0, 68, 0, 0, 96, - 0, 55, 0, 76, 0, 92, 32, 33, 57, 25, 0, 98, 0, - 0, 87, +static const unsigned char aKWNext[143] = { + 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 2, 0, 0, 0, 0, 0, 0, 13, 0, 0, 0, 0, + 0, 0, 0, 21, 0, 0, 0, 0, 12, 0, 0, 0, 0, + 0, 0, 0, 7, 0, 36, 0, 0, 28, 0, 0, 0, 31, + 0, 0, 0, 40, 0, 0, 0, 0, 0, 60, 0, 54, 0, + 0, 38, 47, 0, 0, 0, 3, 0, 0, 74, 1, 73, 0, + 0, 0, 52, 0, 0, 0, 0, 0, 0, 57, 59, 56, 30, + 0, 0, 0, 46, 0, 16, 49, 10, 0, 0, 0, 0, 0, + 0, 0, 11, 79, 95, 0, 0, 8, 0, 112, 0, 105, 0, + 43, 62, 0, 77, 0, 116, 0, 61, 0, 0, 94, 42, 55, + 0, 75, 34, 90, 32, 33, 27, 25, 18, 96, 0, 71, 85, }; /* aKWLen[i] is the length (in bytes) of the i-th keyword */ -static const unsigned char aKWLen[145] = { +static const unsigned char aKWLen[143] = { 7, 7, 5, 4, 6, 4, 5, 3, 6, 7, 3, 6, 6, 7, 7, 3, 8, 2, 6, 5, 4, 4, 3, 10, 4, 7, 6, 9, 4, 2, 6, 5, 9, 9, 4, 7, 3, 2, 4, 4, 6, 11, 6, 2, 7, 5, 5, 9, 6, 10, 4, 6, - 2, 3, 7, 5, 9, 6, 6, 4, 5, 5, 10, 6, 5, - 7, 4, 5, 7, 6, 7, 7, 6, 5, 7, 3, 7, 4, - 7, 6, 12, 9, 4, 6, 5, 4, 7, 6, 5, 6, 6, - 7, 6, 4, 5, 9, 5, 6, 3, 8, 8, 2, 13, 2, - 2, 4, 6, 6, 8, 5, 17, 12, 7, 9, 4, 9, 4, - 4, 6, 7, 5, 9, 4, 4, 5, 2, 5, 8, 6, 4, - 5, 8, 4, 3, 9, 5, 5, 6, 4, 6, 2, 2, 9, - 3, 7, + 2, 3, 7, 10, 6, 5, 7, 4, 5, 7, 6, 6, 4, + 5, 5, 5, 7, 7, 6, 5, 7, 3, 6, 4, 7, 6, + 12, 9, 4, 6, 5, 4, 7, 6, 5, 6, 6, 7, 4, + 4, 5, 9, 5, 6, 3, 7, 13, 2, 2, 4, 6, 6, + 8, 5, 17, 12, 7, 9, 8, 8, 2, 4, 9, 4, 5, + 6, 7, 5, 9, 4, 4, 2, 5, 8, 6, 4, 5, 8, + 4, 3, 9, 5, 5, 6, 4, 6, 2, 2, 9, 3, 7, }; /* aKWOffset[i] is the index into zKWText[] of the start of ** the text for the i-th keyword. */ -static const unsigned short int aKWOffset[145] = { +static const unsigned short int aKWOffset[143] = { 0, 2, 2, 8, 9, 14, 16, 20, 23, 25, 25, 29, 33, 36, 41, 46, 48, 53, 54, 59, 62, 65, 67, 69, 78, 81, 86, 90, 90, 94, 99, 101, 105, 111, 119, 123, 123, 123, 126, 129, 132, 137, 142, 146, 147, 152, 156, 160, 168, 174, 181, 184, - 184, 187, 189, 195, 198, 206, 211, 216, 219, 222, 226, 236, 239, - 244, 244, 248, 252, 259, 265, 271, 277, 277, 283, 284, 288, 295, - 299, 306, 312, 324, 333, 335, 341, 346, 348, 355, 360, 365, 371, - 377, 382, 388, 392, 395, 404, 408, 414, 416, 423, 424, 431, 433, - 435, 444, 448, 454, 460, 468, 473, 473, 473, 489, 498, 501, 510, - 513, 517, 522, 529, 534, 543, 547, 550, 555, 557, 561, 569, 575, - 578, 583, 591, 591, 595, 604, 609, 614, 620, 623, 626, 629, 631, - 636, 640, + 184, 187, 189, 195, 205, 208, 213, 213, 217, 221, 228, 233, 238, + 241, 244, 248, 253, 259, 265, 265, 271, 272, 276, 282, 286, 293, + 299, 311, 320, 322, 328, 333, 335, 342, 347, 352, 358, 364, 370, + 374, 378, 381, 390, 394, 400, 402, 409, 411, 413, 422, 426, 432, + 438, 446, 451, 451, 451, 467, 476, 483, 484, 491, 494, 503, 506, + 511, 516, 523, 528, 537, 541, 545, 547, 551, 559, 565, 568, 573, + 581, 581, 585, 594, 599, 604, 610, 613, 616, 619, 621, 626, 630, }; /* aKWCode[i] is the parser symbol code for the i-th keyword */ -static const unsigned char aKWCode[145] = { +static const unsigned char aKWCode[143] = { TK_REINDEX, TK_INDEXED, TK_INDEX, TK_DESC, TK_ESCAPE, TK_EACH, TK_CHECK, TK_KEY, TK_BEFORE, TK_FOREIGN, TK_FOR, TK_IGNORE, TK_LIKE_KW, TK_EXPLAIN, TK_INSTEAD, @@ -157591,154 +154921,25 @@ static const unsigned char aKWCode[145] = { TK_EXCEPT, TK_TRANSACTION,TK_ACTION, TK_ON, TK_JOIN_KW, TK_ALTER, TK_RAISE, TK_EXCLUSIVE, TK_EXISTS, TK_CONSTRAINT, TK_INTO, TK_OFFSET, TK_OF, TK_SET, TK_TRIGGER, - TK_RANGE, TK_GENERATED, TK_DETACH, TK_HAVING, TK_LIKE_KW, - TK_BEGIN, TK_JOIN_KW, TK_REFERENCES, TK_UNIQUE, TK_QUERY, - TK_WITHOUT, TK_WITH, TK_JOIN_KW, TK_RELEASE, TK_ATTACH, - TK_BETWEEN, TK_NOTHING, TK_GROUPS, TK_GROUP, TK_CASCADE, - TK_ASC, TK_DEFAULT, TK_CASE, TK_COLLATE, TK_CREATE, - TK_CTIME_KW, TK_IMMEDIATE, TK_JOIN, TK_INSERT, TK_MATCH, - TK_PLAN, TK_ANALYZE, TK_PRAGMA, TK_ABORT, TK_UPDATE, - TK_VALUES, TK_VIRTUAL, TK_ALWAYS, TK_WHEN, TK_WHERE, - TK_RECURSIVE, TK_AFTER, TK_RENAME, TK_AND, TK_DEFERRED, - TK_DISTINCT, TK_IS, TK_AUTOINCR, TK_TO, TK_IN, - TK_CAST, TK_COLUMNKW, TK_COMMIT, TK_CONFLICT, TK_JOIN_KW, - TK_CTIME_KW, TK_CTIME_KW, TK_CURRENT, TK_PARTITION, TK_DROP, - TK_PRECEDING, TK_FAIL, TK_LAST, TK_FILTER, TK_REPLACE, - TK_FIRST, TK_FOLLOWING, TK_FROM, TK_JOIN_KW, TK_LIMIT, - TK_IF, TK_ORDER, TK_RESTRICT, TK_OTHERS, TK_OVER, - TK_JOIN_KW, TK_ROLLBACK, TK_ROWS, TK_ROW, TK_UNBOUNDED, - TK_UNION, TK_USING, TK_VACUUM, TK_VIEW, TK_WINDOW, - TK_DO, TK_BY, TK_INITIALLY, TK_ALL, TK_PRIMARY, + TK_REFERENCES, TK_UNIQUE, TK_QUERY, TK_WITHOUT, TK_WITH, + TK_JOIN_KW, TK_RELEASE, TK_ATTACH, TK_HAVING, TK_LIKE_KW, + TK_BEGIN, TK_JOIN_KW, TK_RANGE, TK_BETWEEN, TK_NOTHING, + TK_GROUPS, TK_GROUP, TK_CASCADE, TK_ASC, TK_DETACH, + TK_CASE, TK_COLLATE, TK_CREATE, TK_CTIME_KW, TK_IMMEDIATE, + TK_JOIN, TK_INSERT, TK_MATCH, TK_PLAN, TK_ANALYZE, + TK_PRAGMA, TK_ABORT, TK_UPDATE, TK_VALUES, TK_VIRTUAL, + TK_LAST, TK_WHEN, TK_WHERE, TK_RECURSIVE, TK_AFTER, + TK_RENAME, TK_AND, TK_DEFAULT, TK_AUTOINCR, TK_TO, + TK_IN, TK_CAST, TK_COLUMNKW, TK_COMMIT, TK_CONFLICT, + TK_JOIN_KW, TK_CTIME_KW, TK_CTIME_KW, TK_CURRENT, TK_PARTITION, + TK_DEFERRED, TK_DISTINCT, TK_IS, TK_DROP, TK_PRECEDING, + TK_FAIL, TK_LIMIT, TK_FILTER, TK_REPLACE, TK_FIRST, + TK_FOLLOWING, TK_FROM, TK_JOIN_KW, TK_IF, TK_ORDER, + TK_RESTRICT, TK_OTHERS, TK_OVER, TK_JOIN_KW, TK_ROLLBACK, + TK_ROWS, TK_ROW, TK_UNBOUNDED, TK_UNION, TK_USING, + TK_VACUUM, TK_VIEW, TK_WINDOW, TK_DO, TK_BY, + TK_INITIALLY, TK_ALL, TK_PRIMARY, }; -/* Hash table decoded: -** 0: INSERT -** 1: IS -** 2: ROLLBACK TRIGGER -** 3: IMMEDIATE -** 4: PARTITION -** 5: TEMP -** 6: -** 7: -** 8: VALUES WITHOUT -** 9: -** 10: MATCH -** 11: NOTHING -** 12: -** 13: OF -** 14: TIES IGNORE -** 15: PLAN -** 16: INSTEAD INDEXED -** 17: -** 18: TRANSACTION RIGHT -** 19: WHEN -** 20: SET HAVING -** 21: IF -** 22: ROWS -** 23: SELECT -** 24: -** 25: -** 26: VACUUM SAVEPOINT -** 27: -** 28: LIKE UNION VIRTUAL REFERENCES -** 29: RESTRICT -** 30: -** 31: THEN REGEXP -** 32: TO -** 33: -** 34: BEFORE -** 35: -** 36: -** 37: FOLLOWING COLLATE CASCADE -** 38: CREATE -** 39: -** 40: CASE REINDEX -** 41: EACH -** 42: -** 43: QUERY -** 44: AND ADD -** 45: PRIMARY ANALYZE -** 46: -** 47: ROW ASC DETACH -** 48: CURRENT_TIME CURRENT_DATE -** 49: -** 50: -** 51: EXCLUSIVE TEMPORARY -** 52: -** 53: DEFERRED -** 54: DEFERRABLE -** 55: -** 56: DATABASE -** 57: -** 58: DELETE VIEW GENERATED -** 59: ATTACH -** 60: END -** 61: EXCLUDE -** 62: ESCAPE DESC -** 63: GLOB -** 64: WINDOW ELSE -** 65: COLUMN -** 66: FIRST -** 67: -** 68: GROUPS ALL -** 69: DISTINCT DROP KEY -** 70: BETWEEN -** 71: INITIALLY -** 72: BEGIN -** 73: FILTER CHECK ACTION -** 74: GROUP INDEX -** 75: -** 76: EXISTS DEFAULT -** 77: -** 78: FOR CURRENT_TIMESTAMP -** 79: EXCEPT -** 80: -** 81: CROSS -** 82: -** 83: -** 84: -** 85: CAST -** 86: FOREIGN AUTOINCREMENT -** 87: COMMIT -** 88: CURRENT AFTER ALTER -** 89: FULL FAIL CONFLICT -** 90: EXPLAIN -** 91: CONSTRAINT -** 92: FROM ALWAYS -** 93: -** 94: ABORT -** 95: -** 96: AS DO -** 97: REPLACE WITH RELEASE -** 98: BY RENAME -** 99: RANGE RAISE -** 100: OTHERS -** 101: USING NULLS -** 102: PRAGMA -** 103: JOIN ISNULL OFFSET -** 104: NOT -** 105: OR LAST LEFT -** 106: LIMIT -** 107: -** 108: -** 109: IN -** 110: INTO -** 111: OVER RECURSIVE -** 112: ORDER OUTER -** 113: -** 114: INTERSECT UNBOUNDED -** 115: -** 116: -** 117: ON -** 118: -** 119: WHERE -** 120: NO INNER -** 121: NULL -** 122: -** 123: TABLE -** 124: NATURAL NOTNULL -** 125: PRECEDING -** 126: UPDATE UNIQUE -*/ /* Check to see if z[0..n-1] is a keyword. If it is, write the ** parser symbol code for that keyword into *pType. Always ** return the integer n (the length of the token). */ @@ -157813,96 +155014,94 @@ static int keywordCode(const char *z, int n, int *pType){ testcase( i==52 ); /* OF */ testcase( i==53 ); /* SET */ testcase( i==54 ); /* TRIGGER */ - testcase( i==55 ); /* RANGE */ - testcase( i==56 ); /* GENERATED */ - testcase( i==57 ); /* DETACH */ - testcase( i==58 ); /* HAVING */ - testcase( i==59 ); /* GLOB */ - testcase( i==60 ); /* BEGIN */ - testcase( i==61 ); /* INNER */ - testcase( i==62 ); /* REFERENCES */ - testcase( i==63 ); /* UNIQUE */ - testcase( i==64 ); /* QUERY */ - testcase( i==65 ); /* WITHOUT */ - testcase( i==66 ); /* WITH */ - testcase( i==67 ); /* OUTER */ - testcase( i==68 ); /* RELEASE */ - testcase( i==69 ); /* ATTACH */ - testcase( i==70 ); /* BETWEEN */ - testcase( i==71 ); /* NOTHING */ - testcase( i==72 ); /* GROUPS */ - testcase( i==73 ); /* GROUP */ - testcase( i==74 ); /* CASCADE */ - testcase( i==75 ); /* ASC */ - testcase( i==76 ); /* DEFAULT */ - testcase( i==77 ); /* CASE */ - testcase( i==78 ); /* COLLATE */ - testcase( i==79 ); /* CREATE */ - testcase( i==80 ); /* CURRENT_DATE */ - testcase( i==81 ); /* IMMEDIATE */ - testcase( i==82 ); /* JOIN */ - testcase( i==83 ); /* INSERT */ - testcase( i==84 ); /* MATCH */ - testcase( i==85 ); /* PLAN */ - testcase( i==86 ); /* ANALYZE */ - testcase( i==87 ); /* PRAGMA */ - testcase( i==88 ); /* ABORT */ - testcase( i==89 ); /* UPDATE */ - testcase( i==90 ); /* VALUES */ - testcase( i==91 ); /* VIRTUAL */ - testcase( i==92 ); /* ALWAYS */ - testcase( i==93 ); /* WHEN */ - testcase( i==94 ); /* WHERE */ - testcase( i==95 ); /* RECURSIVE */ - testcase( i==96 ); /* AFTER */ - testcase( i==97 ); /* RENAME */ - testcase( i==98 ); /* AND */ - testcase( i==99 ); /* DEFERRED */ - testcase( i==100 ); /* DISTINCT */ - testcase( i==101 ); /* IS */ - testcase( i==102 ); /* AUTOINCREMENT */ - testcase( i==103 ); /* TO */ - testcase( i==104 ); /* IN */ - testcase( i==105 ); /* CAST */ - testcase( i==106 ); /* COLUMN */ - testcase( i==107 ); /* COMMIT */ - testcase( i==108 ); /* CONFLICT */ - testcase( i==109 ); /* CROSS */ - testcase( i==110 ); /* CURRENT_TIMESTAMP */ - testcase( i==111 ); /* CURRENT_TIME */ - testcase( i==112 ); /* CURRENT */ - testcase( i==113 ); /* PARTITION */ - testcase( i==114 ); /* DROP */ - testcase( i==115 ); /* PRECEDING */ - testcase( i==116 ); /* FAIL */ - testcase( i==117 ); /* LAST */ - testcase( i==118 ); /* FILTER */ - testcase( i==119 ); /* REPLACE */ - testcase( i==120 ); /* FIRST */ - testcase( i==121 ); /* FOLLOWING */ - testcase( i==122 ); /* FROM */ - testcase( i==123 ); /* FULL */ - testcase( i==124 ); /* LIMIT */ - testcase( i==125 ); /* IF */ - testcase( i==126 ); /* ORDER */ - testcase( i==127 ); /* RESTRICT */ - testcase( i==128 ); /* OTHERS */ - testcase( i==129 ); /* OVER */ - testcase( i==130 ); /* RIGHT */ - testcase( i==131 ); /* ROLLBACK */ - testcase( i==132 ); /* ROWS */ - testcase( i==133 ); /* ROW */ - testcase( i==134 ); /* UNBOUNDED */ - testcase( i==135 ); /* UNION */ - testcase( i==136 ); /* USING */ - testcase( i==137 ); /* VACUUM */ - testcase( i==138 ); /* VIEW */ - testcase( i==139 ); /* WINDOW */ - testcase( i==140 ); /* DO */ - testcase( i==141 ); /* BY */ - testcase( i==142 ); /* INITIALLY */ - testcase( i==143 ); /* ALL */ - testcase( i==144 ); /* PRIMARY */ + testcase( i==55 ); /* REFERENCES */ + testcase( i==56 ); /* UNIQUE */ + testcase( i==57 ); /* QUERY */ + testcase( i==58 ); /* WITHOUT */ + testcase( i==59 ); /* WITH */ + testcase( i==60 ); /* OUTER */ + testcase( i==61 ); /* RELEASE */ + testcase( i==62 ); /* ATTACH */ + testcase( i==63 ); /* HAVING */ + testcase( i==64 ); /* GLOB */ + testcase( i==65 ); /* BEGIN */ + testcase( i==66 ); /* INNER */ + testcase( i==67 ); /* RANGE */ + testcase( i==68 ); /* BETWEEN */ + testcase( i==69 ); /* NOTHING */ + testcase( i==70 ); /* GROUPS */ + testcase( i==71 ); /* GROUP */ + testcase( i==72 ); /* CASCADE */ + testcase( i==73 ); /* ASC */ + testcase( i==74 ); /* DETACH */ + testcase( i==75 ); /* CASE */ + testcase( i==76 ); /* COLLATE */ + testcase( i==77 ); /* CREATE */ + testcase( i==78 ); /* CURRENT_DATE */ + testcase( i==79 ); /* IMMEDIATE */ + testcase( i==80 ); /* JOIN */ + testcase( i==81 ); /* INSERT */ + testcase( i==82 ); /* MATCH */ + testcase( i==83 ); /* PLAN */ + testcase( i==84 ); /* ANALYZE */ + testcase( i==85 ); /* PRAGMA */ + testcase( i==86 ); /* ABORT */ + testcase( i==87 ); /* UPDATE */ + testcase( i==88 ); /* VALUES */ + testcase( i==89 ); /* VIRTUAL */ + testcase( i==90 ); /* LAST */ + testcase( i==91 ); /* WHEN */ + testcase( i==92 ); /* WHERE */ + testcase( i==93 ); /* RECURSIVE */ + testcase( i==94 ); /* AFTER */ + testcase( i==95 ); /* RENAME */ + testcase( i==96 ); /* AND */ + testcase( i==97 ); /* DEFAULT */ + testcase( i==98 ); /* AUTOINCREMENT */ + testcase( i==99 ); /* TO */ + testcase( i==100 ); /* IN */ + testcase( i==101 ); /* CAST */ + testcase( i==102 ); /* COLUMN */ + testcase( i==103 ); /* COMMIT */ + testcase( i==104 ); /* CONFLICT */ + testcase( i==105 ); /* CROSS */ + testcase( i==106 ); /* CURRENT_TIMESTAMP */ + testcase( i==107 ); /* CURRENT_TIME */ + testcase( i==108 ); /* CURRENT */ + testcase( i==109 ); /* PARTITION */ + testcase( i==110 ); /* DEFERRED */ + testcase( i==111 ); /* DISTINCT */ + testcase( i==112 ); /* IS */ + testcase( i==113 ); /* DROP */ + testcase( i==114 ); /* PRECEDING */ + testcase( i==115 ); /* FAIL */ + testcase( i==116 ); /* LIMIT */ + testcase( i==117 ); /* FILTER */ + testcase( i==118 ); /* REPLACE */ + testcase( i==119 ); /* FIRST */ + testcase( i==120 ); /* FOLLOWING */ + testcase( i==121 ); /* FROM */ + testcase( i==122 ); /* FULL */ + testcase( i==123 ); /* IF */ + testcase( i==124 ); /* ORDER */ + testcase( i==125 ); /* RESTRICT */ + testcase( i==126 ); /* OTHERS */ + testcase( i==127 ); /* OVER */ + testcase( i==128 ); /* RIGHT */ + testcase( i==129 ); /* ROLLBACK */ + testcase( i==130 ); /* ROWS */ + testcase( i==131 ); /* ROW */ + testcase( i==132 ); /* UNBOUNDED */ + testcase( i==133 ); /* UNION */ + testcase( i==134 ); /* USING */ + testcase( i==135 ); /* VACUUM */ + testcase( i==136 ); /* VIEW */ + testcase( i==137 ); /* WINDOW */ + testcase( i==138 ); /* DO */ + testcase( i==139 ); /* BY */ + testcase( i==140 ); /* INITIALLY */ + testcase( i==141 ); /* ALL */ + testcase( i==142 ); /* PRIMARY */ *pType = aKWCode[i]; break; } @@ -157914,7 +155113,7 @@ SQLITE_PRIVATE int sqlite3KeywordCode(const unsigned char *z, int n){ keywordCode((char*)z, n, &id); return id; } -#define SQLITE_N_KEYWORD 145 +#define SQLITE_N_KEYWORD 143 SQLITE_API int sqlite3_keyword_name(int i,const char **pzName,int *pnName){ if( i<0 || i>=SQLITE_N_KEYWORD ) return SQLITE_ERROR; *pzName = zKWText + aKWOffset[i]; @@ -158541,7 +155740,7 @@ SQLITE_PRIVATE char *sqlite3Normalize( int nParen; /* Number of nested levels of parentheses */ int iStartIN; /* Start of RHS of IN operator in z[] */ int nParenAtIN; /* Value of nParent at start of RHS of IN operator */ - u32 j; /* Bytes of normalized SQL generated so far */ + int j; /* Bytes of normalized SQL generated so far */ sqlite3_str *pStr; /* The normalized SQL string under construction */ db = sqlite3VdbeDb(pVdbe); @@ -158585,7 +155784,7 @@ SQLITE_PRIVATE char *sqlite3Normalize( } case TK_RP: { if( iStartIN>0 && nParen==nParenAtIN ){ - assert( pStr->nChar>=(u32)iStartIN ); + assert( pStr->nChar>=iStartIN ); pStr->nChar = iStartIN+1; sqlite3_str_append(pStr, "?,?,?", 5); iStartIN = 0; @@ -159722,9 +156921,6 @@ SQLITE_API int sqlite3_config(int op, ...){ static int setupLookaside(sqlite3 *db, void *pBuf, int sz, int cnt){ #ifndef SQLITE_OMIT_LOOKASIDE void *pStart; - sqlite3_int64 szAlloc = sz*(sqlite3_int64)cnt; - int nBig; /* Number of full-size slots */ - int nSm; /* Number smaller LOOKASIDE_SMALL-byte slots */ if( sqlite3LookasideUsed(db,0)>0 ){ return SQLITE_BUSY; @@ -159747,71 +156943,37 @@ static int setupLookaside(sqlite3 *db, void *pBuf, int sz, int cnt){ pStart = 0; }else if( pBuf==0 ){ sqlite3BeginBenignMalloc(); - pStart = sqlite3Malloc( szAlloc ); /* IMP: R-61949-35727 */ + pStart = sqlite3Malloc( sz*(sqlite3_int64)cnt ); /* IMP: R-61949-35727 */ sqlite3EndBenignMalloc(); - if( pStart ) szAlloc = sqlite3MallocSize(pStart); + if( pStart ) cnt = sqlite3MallocSize(pStart)/sz; }else{ pStart = pBuf; } -#ifndef SQLITE_OMIT_TWOSIZE_LOOKASIDE - if( sz>=LOOKASIDE_SMALL*3 ){ - nBig = szAlloc/(3*LOOKASIDE_SMALL+sz); - nSm = (szAlloc - sz*nBig)/LOOKASIDE_SMALL; - }else if( sz>=LOOKASIDE_SMALL*2 ){ - nBig = szAlloc/(LOOKASIDE_SMALL+sz); - nSm = (szAlloc - sz*nBig)/LOOKASIDE_SMALL; - }else -#endif /* SQLITE_OMIT_TWOSIZE_LOOKASIDE */ - if( sz>0 ){ - nBig = szAlloc/sz; - nSm = 0; - }else{ - nBig = nSm = 0; - } db->lookaside.pStart = pStart; db->lookaside.pInit = 0; db->lookaside.pFree = 0; db->lookaside.sz = (u16)sz; - db->lookaside.szTrue = (u16)sz; if( pStart ){ int i; LookasideSlot *p; assert( sz > (int)sizeof(LookasideSlot*) ); + db->lookaside.nSlot = cnt; p = (LookasideSlot*)pStart; - for(i=0; i=0; i--){ p->pNext = db->lookaside.pInit; db->lookaside.pInit = p; p = (LookasideSlot*)&((u8*)p)[sz]; } -#ifndef SQLITE_OMIT_TWOSIZE_LOOKASIDE - db->lookaside.pSmallInit = 0; - db->lookaside.pSmallFree = 0; - db->lookaside.pMiddle = p; - for(i=0; ipNext = db->lookaside.pSmallInit; - db->lookaside.pSmallInit = p; - p = (LookasideSlot*)&((u8*)p)[LOOKASIDE_SMALL]; - } -#endif /* SQLITE_OMIT_TWOSIZE_LOOKASIDE */ - assert( ((uptr)p)<=szAlloc + (uptr)pStart ); db->lookaside.pEnd = p; db->lookaside.bDisable = 0; db->lookaside.bMalloced = pBuf==0 ?1:0; - db->lookaside.nSlot = nBig+nSm; }else{ db->lookaside.pStart = db; -#ifndef SQLITE_OMIT_TWOSIZE_LOOKASIDE - db->lookaside.pSmallInit = 0; - db->lookaside.pSmallFree = 0; - db->lookaside.pMiddle = db; -#endif /* SQLITE_OMIT_TWOSIZE_LOOKASIDE */ db->lookaside.pEnd = db; db->lookaside.bDisable = 1; - db->lookaside.sz = 0; db->lookaside.bMalloced = 0; db->lookaside.nSlot = 0; } - assert( sqlite3LookasideUsed(db,0)==0 ); #endif /* SQLITE_OMIT_LOOKASIDE */ return SQLITE_OK; } @@ -159925,8 +157087,6 @@ SQLITE_API int sqlite3_db_config(sqlite3 *db, int op, ...){ { SQLITE_DBCONFIG_LEGACY_ALTER_TABLE, SQLITE_LegacyAlter }, { SQLITE_DBCONFIG_DQS_DDL, SQLITE_DqsDDL }, { SQLITE_DBCONFIG_DQS_DML, SQLITE_DqsDML }, - { SQLITE_DBCONFIG_LEGACY_FILE_FORMAT, SQLITE_LegacyFileFmt }, - { SQLITE_DBCONFIG_TRUSTED_SCHEMA, SQLITE_TrustedSchema }, }; unsigned int i; rc = SQLITE_ERROR; /* IMP: R-42790-23372 */ @@ -160465,7 +157625,6 @@ SQLITE_PRIVATE const char *sqlite3ErrName(int rc){ case SQLITE_CANTOPEN_ISDIR: zName = "SQLITE_CANTOPEN_ISDIR"; break; case SQLITE_CANTOPEN_FULLPATH: zName = "SQLITE_CANTOPEN_FULLPATH"; break; case SQLITE_CANTOPEN_CONVPATH: zName = "SQLITE_CANTOPEN_CONVPATH"; break; - case SQLITE_CANTOPEN_SYMLINK: zName = "SQLITE_CANTOPEN_SYMLINK"; break; case SQLITE_PROTOCOL: zName = "SQLITE_PROTOCOL"; break; case SQLITE_EMPTY: zName = "SQLITE_EMPTY"; break; case SQLITE_SCHEMA: zName = "SQLITE_SCHEMA"; break; @@ -160798,15 +157957,8 @@ SQLITE_PRIVATE int sqlite3CreateFunc( assert( SQLITE_FUNC_CONSTANT==SQLITE_DETERMINISTIC ); assert( SQLITE_FUNC_DIRECT==SQLITE_DIRECTONLY ); - extraFlags = enc & (SQLITE_DETERMINISTIC|SQLITE_DIRECTONLY| - SQLITE_SUBTYPE|SQLITE_INNOCUOUS); + extraFlags = enc & (SQLITE_DETERMINISTIC|SQLITE_DIRECTONLY|SQLITE_SUBTYPE); enc &= (SQLITE_FUNC_ENCMASK|SQLITE_ANY); - - /* The SQLITE_INNOCUOUS flag is the same bit as SQLITE_FUNC_UNSAFE. But - ** the meaning is inverted. So flip the bit. */ - assert( SQLITE_FUNC_UNSAFE==SQLITE_INNOCUOUS ); - extraFlags ^= SQLITE_FUNC_UNSAFE; - #ifndef SQLITE_OMIT_UTF16 /* If SQLITE_UTF16 is specified as the encoding type, transform this @@ -160820,13 +157972,11 @@ SQLITE_PRIVATE int sqlite3CreateFunc( enc = SQLITE_UTF16NATIVE; }else if( enc==SQLITE_ANY ){ int rc; - rc = sqlite3CreateFunc(db, zFunctionName, nArg, - (SQLITE_UTF8|extraFlags)^SQLITE_FUNC_UNSAFE, + rc = sqlite3CreateFunc(db, zFunctionName, nArg, SQLITE_UTF8|extraFlags, pUserData, xSFunc, xStep, xFinal, xValue, xInverse, pDestructor); if( rc==SQLITE_OK ){ - rc = sqlite3CreateFunc(db, zFunctionName, nArg, - (SQLITE_UTF16LE|extraFlags)^SQLITE_FUNC_UNSAFE, - pUserData, xSFunc, xStep, xFinal, xValue, xInverse, pDestructor); + rc = sqlite3CreateFunc(db, zFunctionName, nArg, SQLITE_UTF16LE|extraFlags, + pUserData, xSFunc, xStep, xFinal, xValue, xInverse, pDestructor); } if( rc!=SQLITE_OK ){ return rc; @@ -162152,7 +159302,6 @@ static int openDatabase( db->magic = SQLITE_MAGIC_BUSY; db->aDb = db->aDbStatic; db->lookaside.bDisable = 1; - db->lookaside.sz = 0; assert( sizeof(db->aLimit)==sizeof(aHardLimit) ); memcpy(db->aLimit, aHardLimit, sizeof(db->aLimit)); @@ -162166,9 +159315,7 @@ static int openDatabase( | SQLITE_EnableTrigger | SQLITE_EnableView | SQLITE_CacheSpill -#if !defined(SQLITE_TRUSTED_SCHEMA) || SQLITE_TRUSTED_SCHEMA+0!=0 - | SQLITE_TrustedSchema -#endif + /* The SQLITE_DQS compile-time option determines the default settings ** for SQLITE_DBCONFIG_DQS_DDL and SQLITE_DBCONFIG_DQS_DML. ** @@ -162398,13 +159545,6 @@ static int openDatabase( } #endif -#ifdef SQLITE_ENABLE_INTERNAL_FUNCTIONS - /* Testing use only!!! The -DSQLITE_ENABLE_INTERNAL_FUNCTIONS=1 compile-time - ** option gives access to internal functions by default. - ** Testing use only!!! */ - db->mDbFlags |= DBFLAG_InternalFunc; -#endif - /* -DSQLITE_DEFAULT_LOCKING_MODE=1 makes EXCLUSIVE the default locking ** mode. -DSQLITE_DEFAULT_LOCKING_MODE=0 make NORMAL the default locking ** mode. Doing nothing at all also makes NORMAL the default. @@ -162943,7 +160083,6 @@ SQLITE_API int sqlite3_test_control(int op, ...){ ** This test-control also resets the PRNG so that the new seed will ** be used for the next call to sqlite3_randomness(). */ -#ifndef SQLITE_OMIT_WSD case SQLITE_TESTCTRL_PRNG_SEED: { int x = va_arg(ap, int); int y; @@ -162954,7 +160093,6 @@ SQLITE_API int sqlite3_test_control(int op, ...){ sqlite3_randomness(0,0); break; } -#endif /* ** sqlite3_test_control(BITVEC_TEST, size, program) @@ -163139,14 +160277,15 @@ SQLITE_API int sqlite3_test_control(int op, ...){ break; } - /* sqlite3_test_control(SQLITE_TESTCTRL_INTERNAL_FUNCTIONS, sqlite3*); + /* sqlite3_test_control(SQLITE_TESTCTRL_INTERNAL_FUNCS, int onoff); ** - ** Toggle the ability to use internal functions on or off for - ** the database connection given in the argument. + ** If parameter onoff is non-zero, internal-use-only SQL functions + ** are visible to ordinary SQL. This is useful for testing but is + ** unsafe because invalid parameters to those internal-use-only functions + ** can result in crashes or segfaults. */ case SQLITE_TESTCTRL_INTERNAL_FUNCTIONS: { - sqlite3 *db = va_arg(ap, sqlite3*); - db->mDbFlags ^= DBFLAG_InternalFunc; + sqlite3GlobalConfig.bInternalFunctions = va_arg(ap, int); break; } @@ -163305,19 +160444,6 @@ SQLITE_API const char *sqlite3_uri_parameter(const char *zFilename, const char * return 0; } -/* -** Return a pointer to the name of Nth query parameter of the filename. -*/ -SQLITE_API const char *sqlite3_uri_key(const char *zFilename, int N){ - if( zFilename==0 || N<0 ) return 0; - zFilename += sqlite3Strlen30(zFilename) + 1; - while( zFilename[0] && (N--)>0 ){ - zFilename += sqlite3Strlen30(zFilename) + 1; - zFilename += sqlite3Strlen30(zFilename) + 1; - } - return zFilename[0] ? zFilename : 0; -} - /* ** Return a boolean value for a query parameter. */ @@ -163343,46 +160469,6 @@ SQLITE_API sqlite3_int64 sqlite3_uri_int64( return bDflt; } -/* -** The Pager stores the Journal filename, WAL filename, and Database filename -** consecutively in memory, in that order, with prefixes \000\001\000, -** \002\000, and \003\000, in that order. Thus the three names look like query -** parameters if you start at the first prefix. -** -** This routine backs up a filename to the start of the first prefix. -** -** This only works if the filenamed passed in was obtained from the Pager. -*/ -static const char *startOfNameList(const char *zName){ - while( zName[0]!='\001' || zName[1]!=0 ){ - zName -= 3; - while( zName[0]!='\000' ){ zName--; } - zName++; - } - return zName-1; -} - -/* -** Translate a filename that was handed to a VFS routine into the corresponding -** database, journal, or WAL file. -** -** It is an error to pass this routine a filename string that was not -** passed into the VFS from the SQLite core. Doing so is similar to -** passing free() a pointer that was not obtained from malloc() - it is -** an error that we cannot easily detect but that will likely cause memory -** corruption. -*/ -SQLITE_API const char *sqlite3_filename_database(const char *zFilename){ - return sqlite3_uri_parameter(zFilename - 3, "\003"); -} -SQLITE_API const char *sqlite3_filename_journal(const char *zFilename){ - const char *z = sqlite3_uri_parameter(startOfNameList(zFilename), "\001"); - return ALWAYS(z) && z[0] ? z : 0; -} -SQLITE_API const char *sqlite3_filename_wal(const char *zFilename){ - return sqlite3_uri_parameter(startOfNameList(zFilename), "\002"); -} - /* ** Return the Btree pointer identified by zDbName. Return NULL if not found. */ @@ -164716,9 +161802,6 @@ typedef sqlite3_int64 i64; /* 8-byte signed integer */ # define TESTONLY(X) #endif -#define LARGEST_INT64 (0xffffffff|(((i64)0x7fffffff)<<32)) -#define SMALLEST_INT64 (((i64)-1) - LARGEST_INT64) - #endif /* SQLITE_AMALGAMATION */ #ifdef SQLITE_DEBUG @@ -164762,7 +161845,6 @@ struct Fts3Table { char *zLanguageid; /* languageid=xxx option, or NULL */ int nAutoincrmerge; /* Value configured by 'automerge' */ u32 nLeafAdd; /* Number of leaf blocks added this trans */ - int bLock; /* Used to prevent recursive content= tbls */ /* Precompiled statements used by the implementation. Each of these ** statements is run and reset within a single virtual table API call. @@ -164821,23 +161903,13 @@ struct Fts3Table { int mxSavepoint; /* Largest valid xSavepoint integer */ #endif -#if defined(SQLITE_DEBUG) || defined(SQLITE_TEST) +#ifdef SQLITE_TEST /* True to disable the incremental doclist optimization. This is controled ** by special insert command 'test-no-incr-doclist'. */ int bNoIncrDoclist; - - /* Number of segments in a level */ - int nMergeCount; #endif }; -/* Macro to find the number of segments to merge */ -#if defined(SQLITE_DEBUG) || defined(SQLITE_TEST) -# define MergeCount(P) ((P)->nMergeCount) -#else -# define MergeCount(P) FTS3_MERGE_COUNT -#endif - /* ** When the core wants to read from the virtual table, it creates a ** virtual table cursor (an instance of the following structure) using @@ -165101,8 +162173,6 @@ SQLITE_PRIVATE int sqlite3Fts3Incrmerge(Fts3Table*,int,int); SQLITE_PRIVATE void sqlite3Fts3ErrMsg(char**,const char*,...); SQLITE_PRIVATE int sqlite3Fts3PutVarint(char *, sqlite3_int64); SQLITE_PRIVATE int sqlite3Fts3GetVarint(const char *, sqlite_int64 *); -SQLITE_PRIVATE int sqlite3Fts3GetVarintU(const char *, sqlite_uint64 *); -SQLITE_PRIVATE int sqlite3Fts3GetVarintBounded(const char*,const char*,sqlite3_int64*); SQLITE_PRIVATE int sqlite3Fts3GetVarint32(const char *, int *); SQLITE_PRIVATE int sqlite3Fts3VarintLen(sqlite3_uint64); SQLITE_PRIVATE void sqlite3Fts3Dequote(char *); @@ -165189,6 +162259,18 @@ SQLITE_PRIVATE int sqlite3FtsUnicodeIsdiacritic(int); SQLITE_EXTENSION_INIT1 #endif +/* +** The following are copied from sqliteInt.h. +** +** Constants for the largest and smallest possible 64-bit signed integers. +** These macros are designed to work correctly on both 32-bit and 64-bit +** compilers. +*/ +#ifndef SQLITE_AMALGAMATION +# define LARGEST_INT64 (0xffffffff|(((sqlite3_int64)0x7fffffff)<<32)) +# define SMALLEST_INT64 (((sqlite3_int64)-1) - LARGEST_INT64) +#endif + static int fts3EvalNext(Fts3Cursor *pCsr); static int fts3EvalStart(Fts3Cursor *pCsr); static int fts3TermSegReaderCursor( @@ -165233,7 +162315,12 @@ SQLITE_PRIVATE int sqlite3Fts3PutVarint(char *p, sqlite_int64 v){ v = (*ptr++); \ if( (v & mask2)==0 ){ var = v; return ret; } -SQLITE_PRIVATE int sqlite3Fts3GetVarintU(const char *pBuf, sqlite_uint64 *v){ +/* +** Read a 64-bit variable-length integer from memory starting at p[0]. +** Return the number of bytes read, or 0 on error. +** The value is stored in *v. +*/ +SQLITE_PRIVATE int sqlite3Fts3GetVarint(const char *pBuf, sqlite_int64 *v){ const unsigned char *p = (const unsigned char*)pBuf; const unsigned char *pStart = p; u32 a; @@ -165255,41 +162342,6 @@ SQLITE_PRIVATE int sqlite3Fts3GetVarintU(const char *pBuf, sqlite_uint64 *v){ return (int)(p - pStart); } -/* -** Read a 64-bit variable-length integer from memory starting at p[0]. -** Return the number of bytes read, or 0 on error. -** The value is stored in *v. -*/ -SQLITE_PRIVATE int sqlite3Fts3GetVarint(const char *pBuf, sqlite_int64 *v){ - return sqlite3Fts3GetVarintU(pBuf, (sqlite3_uint64*)v); -} - -/* -** Read a 64-bit variable-length integer from memory starting at p[0] and -** not extending past pEnd[-1]. -** Return the number of bytes read, or 0 on error. -** The value is stored in *v. -*/ -SQLITE_PRIVATE int sqlite3Fts3GetVarintBounded( - const char *pBuf, - const char *pEnd, - sqlite_int64 *v -){ - const unsigned char *p = (const unsigned char*)pBuf; - const unsigned char *pStart = p; - const unsigned char *pX = (const unsigned char*)pEnd; - u64 b = 0; - int shift; - for(shift=0; shift<=63; shift+=7){ - u64 c = pnNodeSize = p->nPgsz-35; -#if defined(SQLITE_DEBUG)||defined(SQLITE_TEST) - p->nMergeCount = FTS3_MERGE_COUNT; -#endif - /* Declare the table schema to SQLite. */ fts3DeclareVtab(&rc, p); @@ -166484,10 +163532,6 @@ static int fts3BestIndexMethod(sqlite3_vtab *pVTab, sqlite3_index_info *pInfo){ int iDocidLe = -1; /* Index of docid<=x constraint, if present */ int iIdx; - if( p->bLock ){ - return SQLITE_ERROR; - } - /* By default use a full table scan. This is an expensive option, ** so search through the constraints to see if a more efficient ** strategy is possible. @@ -166686,11 +163730,7 @@ static int fts3CursorSeekStmt(Fts3Cursor *pCsr){ }else{ zSql = sqlite3_mprintf("SELECT %s WHERE rowid = ?", p->zReadExprlist); if( !zSql ) return SQLITE_NOMEM; - p->bLock++; - rc = sqlite3_prepare_v3( - p->db, zSql,-1,SQLITE_PREPARE_PERSISTENT,&pCsr->pStmt,0 - ); - p->bLock--; + rc = sqlite3_prepare_v3(p->db, zSql,-1,SQLITE_PREPARE_PERSISTENT,&pCsr->pStmt,0); sqlite3_free(zSql); } if( rc==SQLITE_OK ) pCsr->bSeekStmt = 1; @@ -166708,15 +163748,11 @@ static int fts3CursorSeek(sqlite3_context *pContext, Fts3Cursor *pCsr){ if( pCsr->isRequireSeek ){ rc = fts3CursorSeekStmt(pCsr); if( rc==SQLITE_OK ){ - Fts3Table *pTab = (Fts3Table*)pCsr->base.pVtab; - pTab->bLock++; sqlite3_bind_int64(pCsr->pStmt, 1, pCsr->iPrevId); pCsr->isRequireSeek = 0; if( SQLITE_ROW==sqlite3_step(pCsr->pStmt) ){ - pTab->bLock--; return SQLITE_OK; }else{ - pTab->bLock--; rc = sqlite3_reset(pCsr->pStmt); if( rc==SQLITE_OK && ((Fts3Table *)pCsr->base.pVtab)->zContentTbl==0 ){ /* If no row was found and no error has occurred, then the %_content @@ -166888,7 +163924,7 @@ static int fts3SelectLeaf( fts3GetVarint32(zNode, &iHeight); rc = fts3ScanInteriorNode(zTerm, nTerm, zNode, nNode, piLeaf, piLeaf2); - assert_fts3_nc( !piLeaf2 || !piLeaf || rc!=SQLITE_OK || (*piLeaf<=*piLeaf2) ); + assert( !piLeaf2 || !piLeaf || rc!=SQLITE_OK || (*piLeaf<=*piLeaf2) ); if( rc==SQLITE_OK && iHeight>1 ){ char *zBlob = 0; /* Blob read from %_segments table */ @@ -166908,13 +163944,7 @@ static int fts3SelectLeaf( rc = sqlite3Fts3ReadBlock(p, piLeaf?*piLeaf:*piLeaf2, &zBlob, &nBlob, 0); } if( rc==SQLITE_OK ){ - int iNewHeight = 0; - fts3GetVarint32(zBlob, &iNewHeight); - if( iNewHeight>=iHeight ){ - rc = FTS_CORRUPT_VTAB; - }else{ - rc = fts3SelectLeaf(p, zTerm, nTerm, zBlob, nBlob, piLeaf, piLeaf2); - } + rc = fts3SelectLeaf(p, zTerm, nTerm, zBlob, nBlob, piLeaf, piLeaf2); } sqlite3_free(zBlob); } @@ -167369,12 +164399,12 @@ static void fts3GetDeltaVarint3( if( *pp>=pEnd ){ *pp = 0; }else{ - u64 iVal; - *pp += sqlite3Fts3GetVarintU(*pp, &iVal); + sqlite3_int64 iVal; + *pp += sqlite3Fts3GetVarint(*pp, &iVal); if( bDescIdx ){ - *pVal = (i64)((u64)*pVal - iVal); + *pVal -= iVal; }else{ - *pVal = (i64)((u64)*pVal + iVal); + *pVal += iVal; } } } @@ -167401,16 +164431,15 @@ static void fts3PutDeltaVarint3( int *pbFirst, /* IN/OUT: True after first int written */ sqlite3_int64 iVal /* Write this value to the list */ ){ - sqlite3_uint64 iWrite; + sqlite3_int64 iWrite; if( bDescIdx==0 || *pbFirst==0 ){ - assert_fts3_nc( *pbFirst==0 || iVal>=*piPrev ); - iWrite = (u64)iVal - (u64)*piPrev; + iWrite = iVal - *piPrev; }else{ - assert_fts3_nc( *piPrev>=iVal ); - iWrite = (u64)*piPrev - (u64)iVal; + iWrite = *piPrev - iVal; } assert( *pbFirst || *piPrev==0 ); assert_fts3_nc( *pbFirst==0 || iWrite>0 ); + assert( *pbFirst==0 || iWrite>=0 ); *pp += sqlite3Fts3PutVarint(*pp, iWrite); *piPrev = iVal; *pbFirst = 1; @@ -167426,8 +164455,7 @@ static void fts3PutDeltaVarint3( ** Using this makes it easier to write code that can merge doclists that are ** sorted in either ascending or descending order. */ -/* #define DOCID_CMP(i1, i2) ((bDescDoclist?-1:1) * (i64)((u64)i1-i2)) */ -#define DOCID_CMP(i1, i2) ((bDescDoclist?-1:1) * (i1>i2?1:((i1==i2)?0:-1))) +#define DOCID_CMP(i1, i2) ((bDescDoclist?-1:1) * (i1-i2)) /* ** This function does an "OR" merge of two doclists (output contains all @@ -167841,7 +164869,7 @@ static int fts3SegReaderCursor( ** Fts3SegReaderPending might segfault, as the data structures used by ** fts4aux are not completely populated. So it's easiest to filter these ** calls out here. */ - if( iLevel<0 && p->aIndex && p->iPrevLangid==iLangid ){ + if( iLevel<0 && p->aIndex ){ Fts3SegReader *pSeg = 0; rc = sqlite3Fts3SegReaderPending(p, iIndex, zTerm, nTerm, isPrefix||isScan, &pSeg); if( rc==SQLITE_OK && pSeg ){ @@ -168104,8 +165132,6 @@ static int fts3NextMethod(sqlite3_vtab_cursor *pCursor){ int rc; Fts3Cursor *pCsr = (Fts3Cursor *)pCursor; if( pCsr->eSearch==FTS3_DOCID_SEARCH || pCsr->eSearch==FTS3_FULLSCAN_SEARCH ){ - Fts3Table *pTab = (Fts3Table*)pCursor->pVtab; - pTab->bLock++; if( SQLITE_ROW!=sqlite3_step(pCsr->pStmt) ){ pCsr->isEof = 1; rc = sqlite3_reset(pCsr->pStmt); @@ -168113,7 +165139,6 @@ static int fts3NextMethod(sqlite3_vtab_cursor *pCursor){ pCsr->iPrevId = sqlite3_column_int64(pCsr->pStmt, 0); rc = SQLITE_OK; } - pTab->bLock--; }else{ rc = fts3EvalNext((Fts3Cursor *)pCursor); } @@ -168174,10 +165199,6 @@ static int fts3FilterMethod( UNUSED_PARAMETER(idxStr); UNUSED_PARAMETER(nVal); - if( p->bLock ){ - return SQLITE_ERROR; - } - eSearch = (idxNum & 0x0000FFFF); assert( eSearch>=0 && eSearch<=(FTS3_FULLTEXT_SEARCH+p->nColumn) ); assert( p->pSegments==0 ); @@ -168249,11 +165270,7 @@ static int fts3FilterMethod( ); } if( zSql ){ - p->bLock++; - rc = sqlite3_prepare_v3( - p->db,zSql,-1,SQLITE_PREPARE_PERSISTENT,&pCsr->pStmt,0 - ); - p->bLock--; + rc = sqlite3_prepare_v3(p->db,zSql,-1,SQLITE_PREPARE_PERSISTENT,&pCsr->pStmt,0); sqlite3_free(zSql); }else{ rc = SQLITE_NOMEM; @@ -169270,7 +166287,7 @@ static int fts3EvalPhraseStart(Fts3Cursor *pCsr, int bOptOk, Fts3Phrase *p){ int bIncrOk = (bOptOk && pCsr->bDesc==pTab->bDescIdx && p->nToken<=MAX_INCR_PHRASE_TOKENS && p->nToken>0 -#if defined(SQLITE_DEBUG) || defined(SQLITE_TEST) +#ifdef SQLITE_TEST && pTab->bNoIncrDoclist==0 #endif ); @@ -169412,16 +166429,15 @@ static void fts3EvalDlPhraseNext( u8 *pbEof ){ char *pIter; /* Used to iterate through aAll */ - char *pEnd; /* 1 byte past end of aAll */ + char *pEnd = &pDL->aAll[pDL->nAll]; /* 1 byte past end of aAll */ if( pDL->pNextDocid ){ pIter = pDL->pNextDocid; - assert( pDL->aAll!=0 || pIter==0 ); }else{ pIter = pDL->aAll; } - if( pIter==0 || pIter>=(pEnd = pDL->aAll + pDL->nAll) ){ + if( pIter>=pEnd ){ /* We have already reached the end of this doclist. EOF. */ *pbEof = 1; }else{ @@ -169793,13 +166809,12 @@ static int fts3EvalAverageDocsize(Fts3Cursor *pCsr, int *pnPage){ rc = sqlite3Fts3SelectDoctotal(p, &pStmt); if( rc!=SQLITE_OK ) return rc; a = sqlite3_column_blob(pStmt, 0); - testcase( a==0 ); /* If %_stat.value set to X'' */ - if( a ){ - pEnd = &a[sqlite3_column_bytes(pStmt, 0)]; - a += sqlite3Fts3GetVarintBounded(a, pEnd, &nDoc); - while( a */ /* #include */ /* #include */ -/* #include */ + #define FTS_MAX_APPENDABLE_HEIGHT 16 @@ -175132,7 +172145,7 @@ int test_fts3_node_chunk_threshold = (4*1024)*4; #endif /* -** The values that may be meaningfully bound to the :1 parameter in +** The two values that may be meaningfully bound to the :1 parameter in ** statements SQL_REPLACE_STAT and SQL_SELECT_STAT. */ #define FTS_STAT_DOCTOTAL 0 @@ -175400,7 +172413,7 @@ static int fts3SqlStmt( ** returns zero rows. */ /* 28 */ "SELECT level, count(*) AS cnt FROM %Q.'%q_segdir' " " GROUP BY level HAVING cnt>=?" - " ORDER BY (level %% 1024) ASC, 2 DESC LIMIT 1", + " ORDER BY (level %% 1024) ASC LIMIT 1", /* Estimate the upper limit on the number of leaf nodes in a new segment ** created by merging the oldest :2 segments from absolute level :1. See @@ -175761,7 +172774,7 @@ static int fts3PendingListAppend( assert( !p || p->iLastDocid<=iDocid ); if( !p || p->iLastDocid!=iDocid ){ - u64 iDelta = (u64)iDocid - (u64)(p ? p->iLastDocid : 0); + sqlite3_int64 iDelta = iDocid - (p ? p->iLastDocid : 0); if( p ){ assert( p->nDatanSpace ); assert( p->aData[p->nData]==0 ); @@ -176218,7 +173231,7 @@ static int fts3AllocateSegdirIdx( ** segment and allocate (newly freed) index 0 at level iLevel. Otherwise, ** if iNext is less than FTS3_MERGE_COUNT, allocate index iNext. */ - if( iNext>=MergeCount(p) ){ + if( iNext>=FTS3_MERGE_COUNT ){ fts3LogMerge(16, getAbsoluteLevel(p, iLangid, iIndex, iLevel)); rc = fts3SegmentMerge(p, iLangid, iIndex, iLevel); *piIdx = 0; @@ -176302,8 +173315,6 @@ SQLITE_PRIVATE int sqlite3Fts3ReadBlock( } *paBlob = aByte; } - }else if( rc==SQLITE_ERROR ){ - rc = FTS_CORRUPT_VTAB; } return rc; @@ -176446,7 +173457,7 @@ static int fts3SegReaderNext( pNext += fts3GetVarint32(pNext, &nSuffix); if( nSuffix<=0 || (&pReader->aNode[pReader->nNode] - pNext)pReader->nTerm + || nPrefix>pReader->nTermAlloc ){ return FTS_CORRUPT_VTAB; } @@ -176596,18 +173607,18 @@ static int fts3SegReaderNextDocid( }else{ rc = fts3SegReaderRequire(pReader, p, FTS3_VARINT_MAX); if( rc==SQLITE_OK ){ - u64 iDelta; - pReader->pOffsetList = p + sqlite3Fts3GetVarintU(p, &iDelta); + sqlite3_int64 iDelta; + pReader->pOffsetList = p + sqlite3Fts3GetVarint(p, &iDelta); if( pTab->bDescIdx ){ - pReader->iDocid = (i64)((u64)pReader->iDocid - iDelta); + pReader->iDocid -= iDelta; }else{ - pReader->iDocid = (i64)((u64)pReader->iDocid + iDelta); + pReader->iDocid += iDelta; } } } } - return rc; + return SQLITE_OK; } @@ -177097,11 +174108,6 @@ static int fts3NodeAddTerm( nPrefix = fts3PrefixCompress(pTree->zTerm, pTree->nTerm, zTerm, nTerm); nSuffix = nTerm-nPrefix; - /* If nSuffix is zero or less, then zTerm/nTerm must be a prefix of - ** pWriter->zTerm/pWriter->nTerm. i.e. must be equal to or less than when - ** compared with BINARY collation. This indicates corruption. */ - if( nSuffix<=0 ) return FTS_CORRUPT_VTAB; - nReq += sqlite3Fts3VarintLen(nPrefix)+sqlite3Fts3VarintLen(nSuffix)+nSuffix; if( nReq<=p->nNodeSize || !pTree->zTerm ){ @@ -177346,7 +174352,6 @@ static int fts3SegWriterAdd( int rc; /* The current leaf node is full. Write it out to the database. */ - if( pWriter->iFree==LARGEST_INT64 ) return FTS_CORRUPT_VTAB; rc = fts3WriteSegment(p, pWriter->iFree++, pWriter->aData, nData); if( rc!=SQLITE_OK ) return rc; p->nLeafAdd++; @@ -177396,11 +174401,9 @@ static int fts3SegWriterAdd( /* Append the prefix-compressed term and doclist to the buffer. */ nData += sqlite3Fts3PutVarint(&pWriter->aData[nData], nPrefix); nData += sqlite3Fts3PutVarint(&pWriter->aData[nData], nSuffix); - assert( nSuffix>0 ); memcpy(&pWriter->aData[nData], &zTerm[nPrefix], nSuffix); nData += nSuffix; nData += sqlite3Fts3PutVarint(&pWriter->aData[nData], nDoclist); - assert( nDoclist>0 ); memcpy(&pWriter->aData[nData], aDoclist, nDoclist); pWriter->nData = nData + nDoclist; @@ -177420,7 +174423,6 @@ static int fts3SegWriterAdd( pWriter->zTerm = zNew; } assert( pWriter->zTerm==pWriter->zMalloc ); - assert( nTerm>0 ); memcpy(pWriter->zTerm, zTerm, nTerm); }else{ pWriter->zTerm = (char *)zTerm; @@ -177729,7 +174731,6 @@ static int fts3MsrBufferData( pMsr->aBuffer = pNew; } - assert( nList>0 ); memcpy(pMsr->aBuffer, pList, nList); return SQLITE_OK; } @@ -178043,12 +175044,14 @@ SQLITE_PRIVATE int sqlite3Fts3SegReaderStep( ** doclist. */ sqlite3_int64 iDelta; if( p->bDescIdx && nDoclist>0 ){ - if( iPrev<=iDocid ) return FTS_CORRUPT_VTAB; - iDelta = (i64)((u64)iPrev - (u64)iDocid); + iDelta = iPrev - iDocid; }else{ - if( nDoclist>0 && iPrev>=iDocid ) return FTS_CORRUPT_VTAB; - iDelta = (i64)((u64)iDocid - (u64)iPrev); + iDelta = iDocid - iPrev; } + if( iDelta<=0 && (nDoclist>0 || iDelta!=iDocid) ){ + return FTS_CORRUPT_VTAB; + } + assert( nDoclist>0 || iDelta==iDocid ); nByte = sqlite3Fts3VarintLen(iDelta) + (isRequirePos?nList+1:0); if( nDoclist+nByte>pCsr->nBuffer ){ @@ -178330,7 +175333,7 @@ static int fts3SegmentMerge( csr.zTerm, csr.nTerm, csr.aDoclist, csr.nDoclist); } if( rc!=SQLITE_OK ) goto finished; - assert_fts3_nc( pWriter || bIgnoreEmpty ); + assert( pWriter || bIgnoreEmpty ); if( iLevel!=FTS3_SEGCURSOR_PENDING ){ rc = fts3DeleteSegdir( @@ -178557,10 +175560,7 @@ static int fts3DoOptimize(Fts3Table *p, int bReturnDone){ int rc; sqlite3_stmt *pAllLangid = 0; - rc = sqlite3Fts3PendingTermsFlush(p); - if( rc==SQLITE_OK ){ - rc = fts3SqlStmt(p, SQL_SELECT_ALL_LANGID, &pAllLangid, 0); - } + rc = fts3SqlStmt(p, SQL_SELECT_ALL_LANGID, &pAllLangid, 0); if( rc==SQLITE_OK ){ int rc2; sqlite3_bind_int(pAllLangid, 1, p->iPrevLangid); @@ -178581,6 +175581,7 @@ static int fts3DoOptimize(Fts3Table *p, int bReturnDone){ } sqlite3Fts3SegmentsClose(p); + sqlite3Fts3PendingTermsClear(p); return (rc==SQLITE_OK && bReturnDone && bSeenDone) ? SQLITE_DONE : rc; } @@ -178918,7 +175919,6 @@ static int fts3IncrmergePush( ** be added to. */ nPrefix = fts3PrefixCompress(pNode->key.a, pNode->key.n, zTerm, nTerm); nSuffix = nTerm - nPrefix; - if(nSuffix<=0 ) return FTS_CORRUPT_VTAB; nSpace = sqlite3Fts3VarintLen(nPrefix); nSpace += sqlite3Fts3VarintLen(nSuffix) + nSuffix; @@ -179313,10 +176313,6 @@ static int fts3IncrmergeLoad( pWriter->bNoLeafData = (pWriter->nLeafData==0); nRoot = sqlite3_column_bytes(pSelect, 4); aRoot = sqlite3_column_blob(pSelect, 4); - if( aRoot==0 ){ - sqlite3_reset(pSelect); - return nRoot ? SQLITE_NOMEM : FTS_CORRUPT_VTAB; - } }else{ return sqlite3_reset(pSelect); } @@ -179352,10 +176348,6 @@ static int fts3IncrmergeLoad( int i; int nHeight = (int)aRoot[0]; NodeWriter *pNode; - if( nHeight<1 || nHeight>FTS_MAX_APPENDABLE_HEIGHT ){ - sqlite3_reset(pSelect); - return FTS_CORRUPT_VTAB; - } pWriter->nLeafEst = (int)((iEnd - iStart) + 1)/FTS_MAX_APPENDABLE_HEIGHT; pWriter->iStart = iStart; @@ -179916,17 +176908,13 @@ static int fts3IncrmergeHintPop(Blob *pHint, i64 *piAbsLevel, int *pnInput){ const int nHint = pHint->n; int i; - i = pHint->n-1; - if( (pHint->a[i] & 0x80) ) return FTS_CORRUPT_VTAB; + i = pHint->n-2; while( i>0 && (pHint->a[i-1] & 0x80) ) i--; - if( i==0 ) return FTS_CORRUPT_VTAB; - i--; while( i>0 && (pHint->a[i-1] & 0x80) ) i--; pHint->n = i; i += sqlite3Fts3GetVarint(&pHint->a[i], piAbsLevel); i += fts3GetVarint32(&pHint->a[i], pnInput); - assert( i<=nHint ); if( i!=nHint ) return FTS_CORRUPT_VTAB; return SQLITE_OK; @@ -179996,14 +176984,8 @@ SQLITE_PRIVATE int sqlite3Fts3Incrmerge(Fts3Table *p, int nMerge, int nMin){ rc = fts3IncrmergeHintPop(&hint, &iHintAbsLevel, &nHintSeg); if( nSeg<0 || (iAbsLevel % nMod) >= (iHintAbsLevel % nMod) ){ - /* Based on the scan in the block above, it is known that there - ** are no levels with a relative level smaller than that of - ** iAbsLevel with more than nSeg segments, or if nSeg is -1, - ** no levels with more than nMin segments. Use this to limit the - ** value of nHintSeg to avoid a large memory allocation in case the - ** merge-hint is corrupt*/ iAbsLevel = iHintAbsLevel; - nSeg = MIN(MAX(nMin,nSeg), nHintSeg); + nSeg = nHintSeg; bUseHint = 1; bDirtyHint = 1; }else{ @@ -180016,7 +176998,7 @@ SQLITE_PRIVATE int sqlite3Fts3Incrmerge(Fts3Table *p, int nMerge, int nMin){ /* If nSeg is less that zero, then there is no level with at least ** nMin segments and no hint in the %_stat table. No work to do. ** Exit early in this case. */ - if( nSeg<=0 ) break; + if( nSeg<0 ) break; /* Open a cursor to iterate through the contents of the oldest nSeg ** indexes of absolute level iAbsLevel. If this cursor is opened using @@ -180044,15 +177026,8 @@ SQLITE_PRIVATE int sqlite3Fts3Incrmerge(Fts3Table *p, int nMerge, int nMin){ } if( SQLITE_OK==rc && pCsr->nSegment==nSeg && SQLITE_OK==(rc = sqlite3Fts3SegReaderStart(p, pCsr, pFilter)) + && SQLITE_ROW==(rc = sqlite3Fts3SegReaderStep(p, pCsr)) ){ - int bEmpty = 0; - rc = sqlite3Fts3SegReaderStep(p, pCsr); - if( rc==SQLITE_OK ){ - bEmpty = 1; - }else if( rc!=SQLITE_ROW ){ - sqlite3Fts3SegReaderFinish(pCsr); - break; - } if( bUseHint && iIdx>0 ){ const char *zKey = pCsr->zTerm; int nKey = pCsr->nTerm; @@ -180063,13 +177038,11 @@ SQLITE_PRIVATE int sqlite3Fts3Incrmerge(Fts3Table *p, int nMerge, int nMin){ if( rc==SQLITE_OK && pWriter->nLeafEst ){ fts3LogMerge(nSeg, iAbsLevel); - if( bEmpty==0 ){ - do { - rc = fts3IncrmergeAppend(p, pWriter, pCsr); - if( rc==SQLITE_OK ) rc = sqlite3Fts3SegReaderStep(p, pCsr); - if( pWriter->nWork>=nRem && rc==SQLITE_ROW ) rc = SQLITE_OK; - }while( rc==SQLITE_ROW ); - } + do { + rc = fts3IncrmergeAppend(p, pWriter, pCsr); + if( rc==SQLITE_OK ) rc = sqlite3Fts3SegReaderStep(p, pCsr); + if( pWriter->nWork>=nRem && rc==SQLITE_ROW ) rc = SQLITE_OK; + }while( rc==SQLITE_ROW ); /* Update or delete the input segments */ if( rc==SQLITE_OK ){ @@ -180134,7 +177107,7 @@ static int fts3DoIncrmerge( const char *zParam /* Nul-terminated string containing "A,B" */ ){ int rc; - int nMin = (MergeCount(p) / 2); + int nMin = (FTS3_MERGE_COUNT / 2); int nMerge = 0; const char *z = zParam; @@ -180179,7 +177152,7 @@ static int fts3DoAutoincrmerge( int rc = SQLITE_OK; sqlite3_stmt *pStmt = 0; p->nAutoincrmerge = fts3Getint(&zParam); - if( p->nAutoincrmerge==1 || p->nAutoincrmerge>MergeCount(p) ){ + if( p->nAutoincrmerge==1 || p->nAutoincrmerge>FTS3_MERGE_COUNT ){ p->nAutoincrmerge = 8; } if( !p->bHasStat ){ @@ -180262,12 +177235,12 @@ static u64 fts3ChecksumIndex( i64 iDocid = 0; i64 iCol = 0; - u64 iPos = 0; + i64 iPos = 0; pCsr += sqlite3Fts3GetVarint(pCsr, &iDocid); while( pCsrbDescIdx ){ - iDocid = (i64)((u64)iDocid - iVal); - }else{ - iDocid = (i64)((u64)iDocid + iVal); - } + pCsr += sqlite3Fts3GetVarint(pCsr, &iVal); + iDocid += iVal; } }else{ iPos += (iVal - 2); @@ -180353,9 +177322,10 @@ static int fts3IntegrityCheck(Fts3Table *p, int *pbOk){ for(iCol=0; rc==SQLITE_OK && iColnColumn; iCol++){ if( p->abNotindexed[iCol]==0 ){ const char *zText = (const char *)sqlite3_column_text(pStmt, iCol+1); + int nText = sqlite3_column_bytes(pStmt, iCol+1); sqlite3_tokenizer_cursor *pT = 0; - rc = sqlite3Fts3OpenTokenizer(p->pTokenizer, iLang, zText, -1, &pT); + rc = sqlite3Fts3OpenTokenizer(p->pTokenizer, iLang, zText, nText,&pT); while( rc==SQLITE_OK ){ char const *zToken; /* Buffer containing token */ int nToken = 0; /* Number of bytes in token */ @@ -180440,7 +177410,7 @@ static int fts3DoIntegrityCheck( ** meaningful value to insert is the text 'optimize'. */ static int fts3SpecialInsert(Fts3Table *p, sqlite3_value *pVal){ - int rc = SQLITE_ERROR; /* Return Code */ + int rc; /* Return Code */ const char *zVal = (const char *)sqlite3_value_text(pVal); int nVal = sqlite3_value_bytes(pVal); @@ -180456,27 +177426,21 @@ static int fts3SpecialInsert(Fts3Table *p, sqlite3_value *pVal){ rc = fts3DoIncrmerge(p, &zVal[6]); }else if( nVal>10 && 0==sqlite3_strnicmp(zVal, "automerge=", 10) ){ rc = fts3DoAutoincrmerge(p, &zVal[10]); -#if defined(SQLITE_DEBUG) || defined(SQLITE_TEST) - }else{ - int v; - if( nVal>9 && 0==sqlite3_strnicmp(zVal, "nodesize=", 9) ){ - v = atoi(&zVal[9]); - if( v>=24 && v<=p->nPgsz-35 ) p->nNodeSize = v; - rc = SQLITE_OK; - }else if( nVal>11 && 0==sqlite3_strnicmp(zVal, "maxpending=", 9) ){ - v = atoi(&zVal[11]); - if( v>=64 && v<=FTS3_MAX_PENDING_DATA ) p->nMaxPendingData = v; - rc = SQLITE_OK; - }else if( nVal>21 && 0==sqlite3_strnicmp(zVal,"test-no-incr-doclist=",21) ){ - p->bNoIncrDoclist = atoi(&zVal[21]); - rc = SQLITE_OK; - }else if( nVal>11 && 0==sqlite3_strnicmp(zVal,"mergecount=",11) ){ - v = atoi(&zVal[11]); - if( v>=4 && v<=FTS3_MERGE_COUNT && (v&1)==0 ) p->nMergeCount = v; - rc = SQLITE_OK; - } +#ifdef SQLITE_TEST + }else if( nVal>9 && 0==sqlite3_strnicmp(zVal, "nodesize=", 9) ){ + p->nNodeSize = atoi(&zVal[9]); + rc = SQLITE_OK; + }else if( nVal>11 && 0==sqlite3_strnicmp(zVal, "maxpending=", 9) ){ + p->nMaxPendingData = atoi(&zVal[11]); + rc = SQLITE_OK; + }else if( nVal>21 && 0==sqlite3_strnicmp(zVal, "test-no-incr-doclist=", 21) ){ + p->bNoIncrDoclist = atoi(&zVal[21]); + rc = SQLITE_OK; #endif + }else{ + rc = SQLITE_ERROR; } + return rc; } @@ -181403,7 +178367,7 @@ static int fts3BestSnippet( /* Set the *pmSeen output variable. */ for(i=0; ipEnd ){ - return FTS_CORRUPT_VTAB; - } - *pnDoc = nDoc; + a += sqlite3Fts3GetVarint(a, &nDoc); + if( nDoc==0 ) return FTS_CORRUPT_VTAB; + *pnDoc = (u32)nDoc; if( paLen ) *paLen = a; - if( ppEnd ) *ppEnd = pEnd; return SQLITE_OK; } @@ -182092,7 +179044,7 @@ static int fts3MatchinfoValues( case FTS3_MATCHINFO_NDOC: if( bGlobal ){ sqlite3_int64 nDoc = 0; - rc = fts3MatchinfoSelectDoctotal(pTab, &pSelect, &nDoc, 0, 0); + rc = fts3MatchinfoSelectDoctotal(pTab, &pSelect, &nDoc, 0); pInfo->aMatchinfo[0] = (u32)nDoc; } break; @@ -182101,19 +179053,14 @@ static int fts3MatchinfoValues( if( bGlobal ){ sqlite3_int64 nDoc; /* Number of rows in table */ const char *a; /* Aggregate column length array */ - const char *pEnd; /* First byte past end of length array */ - rc = fts3MatchinfoSelectDoctotal(pTab, &pSelect, &nDoc, &a, &pEnd); + rc = fts3MatchinfoSelectDoctotal(pTab, &pSelect, &nDoc, &a); if( rc==SQLITE_OK ){ int iCol; for(iCol=0; iColnCol; iCol++){ u32 iVal; sqlite3_int64 nToken; a += sqlite3Fts3GetVarint(a, &nToken); - if( a>pEnd ){ - rc = SQLITE_CORRUPT_VTAB; - break; - } iVal = (u32)(((u32)(nToken&0xffffffff)+nDoc/2)/nDoc); pInfo->aMatchinfo[iCol] = iVal; } @@ -182127,14 +179074,9 @@ static int fts3MatchinfoValues( if( rc==SQLITE_OK ){ int iCol; const char *a = sqlite3_column_blob(pSelectDocsize, 0); - const char *pEnd = a + sqlite3_column_bytes(pSelectDocsize, 0); for(iCol=0; iColnCol; iCol++){ sqlite3_int64 nToken; - a += sqlite3Fts3GetVarintBounded(a, pEnd, &nToken); - if( a>pEnd ){ - rc = SQLITE_CORRUPT_VTAB; - break; - } + a += sqlite3Fts3GetVarint(a, &nToken); pInfo->aMatchinfo[iCol] = (u32)nToken; } } @@ -182165,7 +179107,7 @@ static int fts3MatchinfoValues( if( rc!=SQLITE_OK ) break; if( bGlobal ){ if( pCsr->pDeferred ){ - rc = fts3MatchinfoSelectDoctotal(pTab, &pSelect, &pInfo->nDoc,0,0); + rc = fts3MatchinfoSelectDoctotal(pTab, &pSelect, &pInfo->nDoc, 0); if( rc!=SQLITE_OK ) break; } rc = fts3ExprIterate(pExpr, fts3ExprGlobalHitsCb,(void*)pInfo); @@ -183901,37 +180843,6 @@ static void jsonReturnJson( sqlite3_result_subtype(pCtx, JSON_SUBTYPE); } -/* -** Translate a single byte of Hex into an integer. -** This routine only works if h really is a valid hexadecimal -** character: 0..9a..fA..F -*/ -static u8 jsonHexToInt(int h){ - assert( (h>='0' && h<='9') || (h>='a' && h<='f') || (h>='A' && h<='F') ); -#ifdef SQLITE_EBCDIC - h += 9*(1&~(h>>4)); -#else - h += 9*(1&(h>>6)); -#endif - return (u8)(h & 0xf); -} - -/* -** Convert a 4-byte hex string into an integer -*/ -static u32 jsonHexToInt4(const char *z){ - u32 v; - assert( safe_isxdigit(z[0]) ); - assert( safe_isxdigit(z[1]) ); - assert( safe_isxdigit(z[2]) ); - assert( safe_isxdigit(z[3]) ); - v = (jsonHexToInt(z[0])<<12) - + (jsonHexToInt(z[1])<<8) - + (jsonHexToInt(z[2])<<4) - + jsonHexToInt(z[3]); - return v; -} - /* ** Make the JsonNode the return value of the function. */ @@ -184025,8 +180936,15 @@ static void jsonReturn( }else{ c = z[++i]; if( c=='u' ){ - u32 v = jsonHexToInt4(z+i+1); - i += 4; + u32 v = 0, k; + for(k=0; k<4; i++, k++){ + assert( i>6)); zOut[j++] = 0x80 | (v&0x3f); }else{ - u32 vlo; - if( (v&0xfc00)==0xd800 - && i>18); - zOut[j++] = 0x80 | ((v>>12)&0x3f); - zOut[j++] = 0x80 | ((v>>6)&0x3f); - zOut[j++] = 0x80 | (v&0x3f); - }else{ - zOut[j++] = 0xe0 | (v>>12); - zOut[j++] = 0x80 | ((v>>6)&0x3f); - zOut[j++] = 0x80 | (v&0x3f); - } + zOut[j++] = (char)(0xe0 | (v>>12)); + zOut[j++] = 0x80 | ((v>>6)&0x3f); + zOut[j++] = 0x80 | (v&0x3f); } }else{ if( c=='b' ){ @@ -184555,49 +181457,18 @@ static JsonNode *jsonLookupStep( } return pNode; } - }else if( zPath[0]=='[' ){ + }else if( zPath[0]=='[' && safe_isdigit(zPath[1]) ){ + if( pRoot->eType!=JSON_ARRAY ) return 0; i = 0; j = 1; while( safe_isdigit(zPath[j]) ){ i = i*10 + zPath[j] - '0'; j++; } - if( j<2 || zPath[j]!=']' ){ - if( zPath[1]=='#' ){ - JsonNode *pBase = pRoot; - int iBase = iRoot; - if( pRoot->eType!=JSON_ARRAY ) return 0; - for(;;){ - while( j<=pBase->n ){ - if( (pBase[j].jnFlags & JNODE_REMOVE)==0 ) i++; - j += jsonNodeSize(&pBase[j]); - } - if( (pBase->jnFlags & JNODE_APPEND)==0 ) break; - iBase += pBase->u.iAppend; - pBase = &pParse->aNode[iBase]; - j = 1; - } - j = 2; - if( zPath[2]=='-' && safe_isdigit(zPath[3]) ){ - unsigned int x = 0; - j = 3; - do{ - x = x*10 + zPath[j] - '0'; - j++; - }while( safe_isdigit(zPath[j]) ); - if( x>i ) return 0; - i -= x; - } - if( zPath[j]!=']' ){ - *pzErr = zPath; - return 0; - } - }else{ - *pzErr = zPath; - return 0; - } + if( zPath[j]!=']' ){ + *pzErr = zPath; + return 0; } - if( pRoot->eType!=JSON_ARRAY ) return 0; zPath += j + 1; j = 1; for(;;){ @@ -185470,7 +182341,6 @@ static int jsonEachConnect( pNew = *ppVtab = sqlite3_malloc( sizeof(*pNew) ); if( pNew==0 ) return SQLITE_NOMEM; memset(pNew, 0, sizeof(*pNew)); - sqlite3_vtab_config(db, SQLITE_VTAB_INNOCUOUS); } return rc; } @@ -185961,19 +182831,16 @@ SQLITE_PRIVATE int sqlite3Json1Init(sqlite3 *db){ { "json_tree", &jsonTreeModule }, }; #endif - static const int enc = - SQLITE_UTF8 | - SQLITE_DETERMINISTIC | - SQLITE_INNOCUOUS; for(i=0; ibase.pVtab); - int ii; - sqlite3_stmt *pStmt; +static void freeCursorConstraints(RtreeCursor *pCsr){ if( pCsr->aConstraint ){ int i; /* Used to iterate through constraint array */ for(i=0; inConstraint; i++){ @@ -187090,13 +183947,6 @@ static void resetCursor(RtreeCursor *pCsr){ sqlite3_free(pCsr->aConstraint); pCsr->aConstraint = 0; } - for(ii=0; iiaNode[ii]); - sqlite3_free(pCsr->aPoint); - pStmt = pCsr->pReadAux; - memset(pCsr, 0, sizeof(RtreeCursor)); - pCsr->base.pVtab = (sqlite3_vtab*)pRtree; - pCsr->pReadAux = pStmt; - } /* @@ -187104,10 +183954,13 @@ static void resetCursor(RtreeCursor *pCsr){ */ static int rtreeClose(sqlite3_vtab_cursor *cur){ Rtree *pRtree = (Rtree *)(cur->pVtab); + int ii; RtreeCursor *pCsr = (RtreeCursor *)cur; assert( pRtree->nCursor>0 ); - resetCursor(pCsr); + freeCursorConstraints(pCsr); sqlite3_finalize(pCsr->pReadAux); + sqlite3_free(pCsr->aPoint); + for(ii=0; iiaNode[ii]); sqlite3_free(pCsr); pRtree->nCursor--; nodeBlobReset(pRtree); @@ -187265,12 +184118,9 @@ static void rtreeNonleafConstraint( pCellData += 8 + 4*(p->iCoord&0xfe); assert(p->op==RTREE_LE || p->op==RTREE_LT || p->op==RTREE_GE - || p->op==RTREE_GT || p->op==RTREE_EQ || p->op==RTREE_TRUE - || p->op==RTREE_FALSE ); + || p->op==RTREE_GT || p->op==RTREE_EQ ); assert( ((((char*)pCellData) - (char*)0)&3)==0 ); /* 4-byte aligned */ switch( p->op ){ - case RTREE_TRUE: return; /* Always satisfied */ - case RTREE_FALSE: break; /* Never satisfied */ case RTREE_LE: case RTREE_LT: case RTREE_EQ: @@ -187308,19 +184158,16 @@ static void rtreeLeafConstraint( RtreeDValue xN; /* Coordinate value converted to a double */ assert(p->op==RTREE_LE || p->op==RTREE_LT || p->op==RTREE_GE - || p->op==RTREE_GT || p->op==RTREE_EQ || p->op==RTREE_TRUE - || p->op==RTREE_FALSE ); + || p->op==RTREE_GT || p->op==RTREE_EQ ); pCellData += 8 + p->iCoord*4; assert( ((((char*)pCellData) - (char*)0)&3)==0 ); /* 4-byte aligned */ RTREE_DECODE_COORD(eInt, pCellData, xN); switch( p->op ){ - case RTREE_TRUE: return; /* Always satisfied */ - case RTREE_FALSE: break; /* Never satisfied */ - case RTREE_LE: if( xN <= p->u.rValue ) return; break; - case RTREE_LT: if( xN < p->u.rValue ) return; break; - case RTREE_GE: if( xN >= p->u.rValue ) return; break; - case RTREE_GT: if( xN > p->u.rValue ) return; break; - default: if( xN == p->u.rValue ) return; break; + case RTREE_LE: if( xN <= p->u.rValue ) return; break; + case RTREE_LT: if( xN < p->u.rValue ) return; break; + case RTREE_GE: if( xN >= p->u.rValue ) return; break; + case RTREE_GT: if( xN > p->u.rValue ) return; break; + default: if( xN == p->u.rValue ) return; break; } *peWithin = NOT_WITHIN; } @@ -187813,11 +184660,17 @@ static int rtreeFilter( int ii; int rc = SQLITE_OK; int iCell = 0; + sqlite3_stmt *pStmt; rtreeReference(pRtree); /* Reset the cursor to the same state as rtreeOpen() leaves it in. */ - resetCursor(pCsr); + freeCursorConstraints(pCsr); + sqlite3_free(pCsr->aPoint); + pStmt = pCsr->pReadAux; + memset(pCsr, 0, sizeof(RtreeCursor)); + pCsr->base.pVtab = (sqlite3_vtab*)pRtree; + pCsr->pReadAux = pStmt; pCsr->iStrategy = idxNum; if( idxNum==1 ){ @@ -187826,15 +184679,7 @@ static int rtreeFilter( RtreeSearchPoint *p; /* Search point for the leaf */ i64 iRowid = sqlite3_value_int64(argv[0]); i64 iNode = 0; - int eType = sqlite3_value_numeric_type(argv[0]); - if( eType==SQLITE_INTEGER - || (eType==SQLITE_FLOAT && sqlite3_value_double(argv[0])==iRowid) - ){ - rc = findLeafNode(pRtree, iRowid, &pLeaf, &iNode); - }else{ - rc = SQLITE_OK; - pLeaf = 0; - } + rc = findLeafNode(pRtree, iRowid, &pLeaf, &iNode); if( rc==SQLITE_OK && pLeaf!=0 ){ p = rtreeSearchPointNew(pCsr, RTREE_ZERO, 0); assert( p!=0 ); /* Always returns pCsr->sPoint */ @@ -187864,7 +184709,6 @@ static int rtreeFilter( || (idxStr && (int)strlen(idxStr)==argc*2) ); for(ii=0; iiaConstraint[ii]; - int eType = sqlite3_value_numeric_type(argv[ii]); p->op = idxStr[ii*2]; p->iCoord = idxStr[ii*2+1]-'0'; if( p->op>=RTREE_MATCH ){ @@ -187879,21 +184723,12 @@ static int rtreeFilter( p->pInfo->nCoord = pRtree->nDim2; p->pInfo->anQueue = pCsr->anQueue; p->pInfo->mxLevel = pRtree->iDepth + 1; - }else if( eType==SQLITE_INTEGER || eType==SQLITE_FLOAT ){ + }else{ #ifdef SQLITE_RTREE_INT_ONLY p->u.rValue = sqlite3_value_int64(argv[ii]); #else p->u.rValue = sqlite3_value_double(argv[ii]); #endif - }else{ - p->u.rValue = RTREE_ZERO; - if( eType==SQLITE_NULL ){ - p->op = RTREE_FALSE; - }else if( p->op==RTREE_LT || p->op==RTREE_LE ){ - p->op = RTREE_TRUE; - }else{ - p->op = RTREE_FALSE; - } } } } @@ -189670,14 +186505,6 @@ static int getNodeSize( return rc; } -/* -** Return the length of a token -*/ -static int rtreeTokenLength(const char *z){ - int dummy = 0; - return sqlite3GetToken((const unsigned char*)z,&dummy); -} - /* ** This function is the implementation of both the xConnect and xCreate ** methods of the r-tree virtual table. @@ -189714,8 +186541,8 @@ static int rtreeInit( }; assert( RTREE_MAX_AUX_COLUMN<256 ); /* Aux columns counted by a u8 */ - if( argc<6 || argc>RTREE_MAX_AUX_COLUMN+3 ){ - *pzErr = sqlite3_mprintf("%s", aErrMsg[2 + (argc>=6)]); + if( argc>RTREE_MAX_AUX_COLUMN+3 ){ + *pzErr = sqlite3_mprintf("%s", aErrMsg[3]); return SQLITE_ERROR; } @@ -189743,18 +186570,16 @@ static int rtreeInit( ** the r-tree table schema. */ pSql = sqlite3_str_new(db); - sqlite3_str_appendf(pSql, "CREATE TABLE x(%.*s INT", - rtreeTokenLength(argv[3]), argv[3]); + sqlite3_str_appendf(pSql, "CREATE TABLE x(%s", argv[3]); for(ii=4; iinAux++; - sqlite3_str_appendf(pSql, ",%.*s", rtreeTokenLength(zArg+1), zArg+1); + sqlite3_str_appendf(pSql, ",%s", argv[ii]+1); }else if( pRtree->nAux>0 ){ break; }else{ pRtree->nDim2++; - sqlite3_str_appendf(pSql, ",%.*s NUM", rtreeTokenLength(zArg), zArg); + sqlite3_str_appendf(pSql, ",%s", argv[ii]); } } sqlite3_str_appendf(pSql, ");"); @@ -191702,11 +188527,17 @@ static int geopolyFilter( RtreeNode *pRoot = 0; int rc = SQLITE_OK; int iCell = 0; + sqlite3_stmt *pStmt; rtreeReference(pRtree); /* Reset the cursor to the same state as rtreeOpen() leaves it in. */ - resetCursor(pCsr); + freeCursorConstraints(pCsr); + sqlite3_free(pCsr->aPoint); + pStmt = pCsr->pReadAux; + memset(pCsr, 0, sizeof(RtreeCursor)); + pCsr->base.pVtab = (sqlite3_vtab*)pRtree; + pCsr->pReadAux = pStmt; pCsr->iStrategy = idxNum; if( idxNum==1 ){ @@ -192143,20 +188974,14 @@ static int sqlite3_geopoly_init(sqlite3 *db){ }; int i; for(i=0; izWal = sqlite3_filename_wal(zName); + pFd->zWal = rbuMainToWal(zName, flags); } else if( flags & SQLITE_OPEN_WAL ){ rbu_file *pDb = rbuFindMaindb(pRbuVfs, zName, 0); @@ -198777,7 +195628,7 @@ static int rbuVfsOpen( char *zCopy; if( rbuIsVacuum(pDb->pRbu) ){ zBase = sqlite3_db_filename(pDb->pRbu->dbRbu, "main"); - zBase = sqlite3_filename_wal(zBase); + zBase = rbuMainToWal(zBase, SQLITE_OPEN_URI); } nCopy = strlen(zBase); zCopy = sqlite3_malloc64(nCopy+2); @@ -199097,7 +195948,7 @@ SQLITE_API sqlite3_int64 sqlite3rbu_temp_size(sqlite3rbu *pRbu){ ** ** This file contains an implementation of the "dbstat" virtual table. ** -** The dbstat virtual table is used to extract low-level storage +** The dbstat virtual table is used to extract low-level formatting ** information from an SQLite database in order to implement the ** "sqlite3_analyzer" utility. See the ../tool/spaceanal.tcl script ** for an example implementation. @@ -199141,30 +195992,27 @@ SQLITE_API sqlite3_int64 sqlite3rbu_temp_size(sqlite3rbu *pRbu){ ** ** '/1c2/000/' // Left-most child of 451st child of root */ -static const char zDbstatSchema[] = - "CREATE TABLE x(" - " name TEXT," /* 0 Name of table or index */ - " path TEXT," /* 1 Path to page from root (NULL for agg) */ - " pageno INTEGER," /* 2 Page number (page count for aggregates) */ - " pagetype TEXT," /* 3 'internal', 'leaf', 'overflow', or NULL */ - " ncell INTEGER," /* 4 Cells on page (0 for overflow) */ - " payload INTEGER," /* 5 Bytes of payload on this page */ - " unused INTEGER," /* 6 Bytes of unused space on this page */ - " mx_payload INTEGER," /* 7 Largest payload size of all cells */ - " pgoffset INTEGER," /* 8 Offset of page in file (NULL for agg) */ - " pgsize INTEGER," /* 9 Size of the page (sum for aggregate) */ - " schema TEXT HIDDEN," /* 10 Database schema being analyzed */ - " aggregate BOOLEAN HIDDEN" /* 11 aggregate info for each table */ - ")" -; +#define VTAB_SCHEMA \ + "CREATE TABLE xx( " \ + " name TEXT, /* Name of table or index */" \ + " path TEXT, /* Path to page from root */" \ + " pageno INTEGER, /* Page number */" \ + " pagetype TEXT, /* 'internal', 'leaf' or 'overflow' */" \ + " ncell INTEGER, /* Cells on page (0 for overflow) */" \ + " payload INTEGER, /* Bytes of payload on this page */" \ + " unused INTEGER, /* Bytes of unused space on this page */" \ + " mx_payload INTEGER, /* Largest payload size of all cells */" \ + " pgoffset INTEGER, /* Offset of page in file */" \ + " pgsize INTEGER, /* Size of the page */" \ + " schema TEXT HIDDEN /* Database schema being analyzed */" \ + ");" + -/* Forward reference to data structured used in this module */ typedef struct StatTable StatTable; typedef struct StatCursor StatCursor; typedef struct StatPage StatPage; typedef struct StatCell StatCell; -/* Size information for a single cell within a btree page */ struct StatCell { int nLocal; /* Bytes of local payload */ u32 iChildPg; /* Child node (or 0 if this is a leaf) */ @@ -199174,11 +196022,10 @@ struct StatCell { int iOvfl; /* Iterates through aOvfl[] */ }; -/* Size information for a single btree page */ struct StatPage { - u32 iPgno; /* Page number */ - DbPage *pPg; /* Page content */ - int iCell; /* Current cell */ + u32 iPgno; + DbPage *pPg; + int iCell; char *zPath; /* Path to this page */ @@ -199188,38 +196035,34 @@ struct StatPage { int nUnused; /* Number of unused bytes on page */ StatCell *aCell; /* Array of parsed cells */ u32 iRightChildPg; /* Right-child page number (or 0) */ - int nMxPayload; /* Largest payload of any cell on the page */ + int nMxPayload; /* Largest payload of any cell on this page */ }; -/* The cursor for scanning the dbstat virtual table */ struct StatCursor { - sqlite3_vtab_cursor base; /* base class. MUST BE FIRST! */ + sqlite3_vtab_cursor base; sqlite3_stmt *pStmt; /* Iterates through set of root pages */ - u8 isEof; /* After pStmt has returned SQLITE_DONE */ - u8 isAgg; /* Aggregate results for each table */ + int isEof; /* After pStmt has returned SQLITE_DONE */ int iDb; /* Schema used for this query */ - StatPage aPage[32]; /* Pages in path to current page */ + StatPage aPage[32]; int iPage; /* Current entry in aPage[] */ /* Values to return. */ - u32 iPageno; /* Value of 'pageno' column */ char *zName; /* Value of 'name' column */ char *zPath; /* Value of 'path' column */ + u32 iPageno; /* Value of 'pageno' column */ char *zPagetype; /* Value of 'pagetype' column */ - int nPage; /* Number of pages in current btree */ int nCell; /* Value of 'ncell' column */ + int nPayload; /* Value of 'payload' column */ + int nUnused; /* Value of 'unused' column */ int nMxPayload; /* Value of 'mx_payload' column */ - i64 nUnused; /* Value of 'unused' column */ - i64 nPayload; /* Value of 'payload' column */ i64 iOffset; /* Value of 'pgOffset' column */ - i64 szPage; /* Value of 'pgSize' column */ + int szPage; /* Value of 'pgSize' column */ }; -/* An instance of the DBSTAT virtual table */ struct StatTable { - sqlite3_vtab base; /* base class. MUST BE FIRST! */ - sqlite3 *db; /* Database connection that owns this vtab */ + sqlite3_vtab base; + sqlite3 *db; int iDb; /* Index of database to analyze */ }; @@ -199228,7 +196071,7 @@ struct StatTable { #endif /* -** Connect to or create a new DBSTAT virtual table. +** Connect to or create a statvfs virtual table. */ static int statConnect( sqlite3 *db, @@ -199252,8 +196095,7 @@ static int statConnect( }else{ iDb = 0; } - sqlite3_vtab_config(db, SQLITE_VTAB_DIRECTONLY); - rc = sqlite3_declare_vtab(db, zDbstatSchema); + rc = sqlite3_declare_vtab(db, VTAB_SCHEMA); if( rc==SQLITE_OK ){ pTab = (StatTable *)sqlite3_malloc64(sizeof(StatTable)); if( pTab==0 ) rc = SQLITE_NOMEM_BKPT; @@ -199271,7 +196113,7 @@ static int statConnect( } /* -** Disconnect from or destroy the DBSTAT virtual table. +** Disconnect from or destroy a statvfs virtual table. */ static int statDisconnect(sqlite3_vtab *pVtab){ sqlite3_free(pVtab); @@ -199279,20 +196121,14 @@ static int statDisconnect(sqlite3_vtab *pVtab){ } /* -** Compute the best query strategy and return the result in idxNum. +** There is no "best-index". This virtual table always does a linear +** scan. However, a schema=? constraint should cause this table to +** operate on a different database schema, so check for it. ** -** idxNum-Bit Meaning -** ---------- ---------------------------------------------- -** 0x01 There is a schema=? term in the WHERE clause -** 0x02 There is a name=? term in the WHERE clause -** 0x04 There is an aggregate=? term in the WHERE clause -** 0x08 Output should be ordered by name and path +** idxNum is normally 0, but will be 1 if a schema=? constraint exists. */ static int statBestIndex(sqlite3_vtab *tab, sqlite3_index_info *pIdxInfo){ int i; - int iSchema = -1; - int iName = -1; - int iAgg = -1; /* Look for a valid schema=? constraint. If found, change the idxNum to ** 1 and request the value of that constraint be sent to xFilter. And @@ -199300,40 +196136,16 @@ static int statBestIndex(sqlite3_vtab *tab, sqlite3_index_info *pIdxInfo){ ** used. */ for(i=0; inConstraint; i++){ + if( pIdxInfo->aConstraint[i].iColumn!=10 ) continue; + if( pIdxInfo->aConstraint[i].usable==0 ) return SQLITE_CONSTRAINT; if( pIdxInfo->aConstraint[i].op!=SQLITE_INDEX_CONSTRAINT_EQ ) continue; - if( pIdxInfo->aConstraint[i].usable==0 ){ - /* Force DBSTAT table should always be the right-most table in a join */ - return SQLITE_CONSTRAINT; - } - switch( pIdxInfo->aConstraint[i].iColumn ){ - case 0: { /* name */ - iName = i; - break; - } - case 10: { /* schema */ - iSchema = i; - break; - } - case 11: { /* aggregate */ - iAgg = i; - break; - } - } + pIdxInfo->idxNum = 1; + pIdxInfo->estimatedCost = 1.0; + pIdxInfo->aConstraintUsage[i].argvIndex = 1; + pIdxInfo->aConstraintUsage[i].omit = 1; + break; } - i = 0; - if( iSchema>=0 ){ - pIdxInfo->aConstraintUsage[iSchema].argvIndex = ++i; - pIdxInfo->idxNum |= 0x01; - } - if( iName>=0 ){ - pIdxInfo->aConstraintUsage[iName].argvIndex = ++i; - pIdxInfo->idxNum |= 0x02; - } - if( iAgg>=0 ){ - pIdxInfo->aConstraintUsage[iAgg].argvIndex = ++i; - pIdxInfo->idxNum |= 0x04; - } - pIdxInfo->estimatedCost = 1.0; + /* Records are always returned in ascending order of (name, path). ** If this will satisfy the client, set the orderByConsumed flag so that @@ -199351,14 +196163,13 @@ static int statBestIndex(sqlite3_vtab *tab, sqlite3_index_info *pIdxInfo){ ) ){ pIdxInfo->orderByConsumed = 1; - pIdxInfo->idxNum |= 0x08; } return SQLITE_OK; } /* -** Open a new DBSTAT cursor. +** Open a new statvfs cursor. */ static int statOpen(sqlite3_vtab *pVTab, sqlite3_vtab_cursor **ppCursor){ StatTable *pTab = (StatTable *)pVTab; @@ -199408,18 +196219,8 @@ static void statResetCsr(StatCursor *pCsr){ pCsr->isEof = 0; } -/* Resize the space-used counters inside of the cursor */ -static void statResetCounts(StatCursor *pCsr){ - pCsr->nCell = 0; - pCsr->nMxPayload = 0; - pCsr->nUnused = 0; - pCsr->nPayload = 0; - pCsr->szPage = 0; - pCsr->nPage = 0; -} - /* -** Close a DBSTAT cursor. +** Close a statvfs cursor. */ static int statClose(sqlite3_vtab_cursor *pCursor){ StatCursor *pCsr = (StatCursor *)pCursor; @@ -199429,15 +196230,11 @@ static int statClose(sqlite3_vtab_cursor *pCursor){ return SQLITE_OK; } -/* -** For a single cell on a btree page, compute the number of bytes of -** content (payload) stored on that page. That is to say, compute the -** number of bytes of content not found on overflow pages. -*/ -static int getLocalPayload( +static void getLocalPayload( int nUsable, /* Usable bytes per page */ u8 flags, /* Page flags */ - int nTotal /* Total record (payload) size */ + int nTotal, /* Total record (payload) size */ + int *pnLocal /* OUT: Bytes stored locally */ ){ int nLocal; int nMinLocal; @@ -199453,12 +196250,9 @@ static int getLocalPayload( nLocal = nMinLocal + (nTotal - nMinLocal) % (nUsable - 4); if( nLocal>nMaxLocal ) nLocal = nMinLocal; - return nLocal; + *pnLocal = nLocal; } -/* Populate the StatPage object with information about the all -** cells found on the page currently under analysis. -*/ static int statDecodePage(Btree *pBt, StatPage *p){ int nUnused; int iOff; @@ -199529,7 +196323,7 @@ static int statDecodePage(Btree *pBt, StatPage *p){ iOff += sqlite3GetVarint(&aData[iOff], &dummy); } if( nPayload>(u32)p->nMxPayload ) p->nMxPayload = nPayload; - nLocal = getLocalPayload(nUsable, p->flags, nPayload); + getLocalPayload(nUsable, p->flags, nPayload, &nLocal); if( nLocal<0 ) goto statPageIsCorrupt; pCell->nLocal = nLocal; assert( nPayload>=(u32)nLocal ); @@ -199579,25 +196373,23 @@ static void statSizeAndOffset(StatCursor *pCsr){ sqlite3_file *fd; sqlite3_int64 x[2]; - /* If connected to a ZIPVFS backend, find the page size and - ** offset from ZIPVFS. + /* The default page size and offset */ + pCsr->szPage = sqlite3BtreeGetPageSize(pBt); + pCsr->iOffset = (i64)pCsr->szPage * (pCsr->iPageno - 1); + + /* If connected to a ZIPVFS backend, override the page size and + ** offset with actual values obtained from ZIPVFS. */ fd = sqlite3PagerFile(pPager); x[0] = pCsr->iPageno; if( sqlite3OsFileControl(fd, 230440, &x)==SQLITE_OK ){ pCsr->iOffset = x[0]; - pCsr->szPage += x[1]; - }else{ - /* Not ZIPVFS: The default page size and offset */ - pCsr->szPage += sqlite3BtreeGetPageSize(pBt); - pCsr->iOffset = (i64)pCsr->szPage * (pCsr->iPageno - 1); + pCsr->szPage = (int)x[1]; } } /* -** Move a DBSTAT cursor to the next entry. Normally, the next -** entry will be the next page, but in aggregated mode (pCsr->isAgg!=0), -** the next entry is the next btree. +** Move a statvfs cursor to the next entry in the file. */ static int statNext(sqlite3_vtab_cursor *pCursor){ int rc; @@ -199613,8 +196405,6 @@ static int statNext(sqlite3_vtab_cursor *pCursor){ statNextRestart: if( pCsr->aPage[0].pPg==0 ){ - /* Start measuring space on the next btree */ - statResetCounts(pCsr); rc = sqlite3_step(pCsr->pStmt); if( rc==SQLITE_ROW ){ int nPage; @@ -199627,47 +196417,44 @@ static int statNext(sqlite3_vtab_cursor *pCursor){ rc = sqlite3PagerGet(pPager, iRoot, &pCsr->aPage[0].pPg, 0); pCsr->aPage[0].iPgno = iRoot; pCsr->aPage[0].iCell = 0; - if( !pCsr->isAgg ){ - pCsr->aPage[0].zPath = z = sqlite3_mprintf("/"); - if( z==0 ) rc = SQLITE_NOMEM_BKPT; - } + pCsr->aPage[0].zPath = z = sqlite3_mprintf("/"); pCsr->iPage = 0; - pCsr->nPage = 1; + if( z==0 ) rc = SQLITE_NOMEM_BKPT; }else{ pCsr->isEof = 1; return sqlite3_reset(pCsr->pStmt); } }else{ - /* Continue analyzing the btree previously started */ + + /* Page p itself has already been visited. */ StatPage *p = &pCsr->aPage[pCsr->iPage]; - if( !pCsr->isAgg ) statResetCounts(pCsr); + while( p->iCellnCell ){ StatCell *pCell = &p->aCell[p->iCell]; - while( pCell->iOvflnOvfl ){ - int nUsable, iOvfl; + if( pCell->iOvflnOvfl ){ + int nUsable; sqlite3BtreeEnter(pBt); nUsable = sqlite3BtreeGetPageSize(pBt) - sqlite3BtreeGetReserveNoMutex(pBt); sqlite3BtreeLeave(pBt); - pCsr->nPage++; - statSizeAndOffset(pCsr); + pCsr->zName = (char *)sqlite3_column_text(pCsr->pStmt, 0); + pCsr->iPageno = pCell->aOvfl[pCell->iOvfl]; + pCsr->zPagetype = "overflow"; + pCsr->nCell = 0; + pCsr->nMxPayload = 0; + pCsr->zPath = z = sqlite3_mprintf( + "%s%.3x+%.6x", p->zPath, p->iCell, pCell->iOvfl + ); if( pCell->iOvflnOvfl-1 ){ - pCsr->nPayload += nUsable - 4; + pCsr->nUnused = 0; + pCsr->nPayload = nUsable - 4; }else{ - pCsr->nPayload += pCell->nLastOvfl; - pCsr->nUnused += nUsable - 4 - pCell->nLastOvfl; + pCsr->nPayload = pCell->nLastOvfl; + pCsr->nUnused = nUsable - 4 - pCsr->nPayload; } - iOvfl = pCell->iOvfl; pCell->iOvfl++; - if( !pCsr->isAgg ){ - pCsr->zName = (char *)sqlite3_column_text(pCsr->pStmt, 0); - pCsr->iPageno = pCell->aOvfl[iOvfl]; - pCsr->zPagetype = "overflow"; - pCsr->zPath = z = sqlite3_mprintf( - "%s%.3x+%.6x", p->zPath, p->iCell, iOvfl - ); - return z==0 ? SQLITE_NOMEM_BKPT : SQLITE_OK; - } + statSizeAndOffset(pCsr); + return z==0 ? SQLITE_NOMEM_BKPT : SQLITE_OK; } if( p->iRightChildPg ) break; p->iCell++; @@ -199675,13 +196462,8 @@ static int statNext(sqlite3_vtab_cursor *pCursor){ if( !p->iRightChildPg || p->iCell>p->nCell ){ statClearPage(p); - if( pCsr->iPage>0 ){ - pCsr->iPage--; - }else if( pCsr->isAgg ){ - /* label-statNext-done: When computing aggregate space usage over - ** an entire btree, this is the exit point from this function */ - return SQLITE_OK; - } + if( pCsr->iPage==0 ) return statNext(pCursor); + pCsr->iPage--; goto statNextRestart; /* Tail recursion */ } pCsr->iPage++; @@ -199697,13 +196479,10 @@ static int statNext(sqlite3_vtab_cursor *pCursor){ p[1].iPgno = p->aCell[p->iCell].iChildPg; } rc = sqlite3PagerGet(pPager, p[1].iPgno, &p[1].pPg, 0); - pCsr->nPage++; p[1].iCell = 0; - if( !pCsr->isAgg ){ - p[1].zPath = z = sqlite3_mprintf("%s%.3x/", p->zPath, p->iCell); - if( z==0 ) rc = SQLITE_NOMEM_BKPT; - } + p[1].zPath = z = sqlite3_mprintf("%s%.3x/", p->zPath, p->iCell); p->iCell++; + if( z==0 ) rc = SQLITE_NOMEM_BKPT; } @@ -199733,23 +196512,16 @@ static int statNext(sqlite3_vtab_cursor *pCursor){ pCsr->zPagetype = "corrupted"; break; } - pCsr->nCell += p->nCell; - pCsr->nUnused += p->nUnused; - if( p->nMxPayload>pCsr->nMxPayload ) pCsr->nMxPayload = p->nMxPayload; - if( !pCsr->isAgg ){ - pCsr->zPath = z = sqlite3_mprintf("%s", p->zPath); - if( z==0 ) rc = SQLITE_NOMEM_BKPT; - } + pCsr->nCell = p->nCell; + pCsr->nUnused = p->nUnused; + pCsr->nMxPayload = p->nMxPayload; + pCsr->zPath = z = sqlite3_mprintf("%s", p->zPath); + if( z==0 ) rc = SQLITE_NOMEM_BKPT; nPayload = 0; for(i=0; inCell; i++){ nPayload += p->aCell[i].nLocal; } - pCsr->nPayload += nPayload; - - /* If computing aggregate space usage by btree, continue with the - ** next page. The loop will exit via the return at label-statNext-done - */ - if( pCsr->isAgg ) goto statNextRestart; + pCsr->nPayload = nPayload; } } @@ -199761,10 +196533,6 @@ static int statEof(sqlite3_vtab_cursor *pCursor){ return pCsr->isEof; } -/* Initialize a cursor according to the query plan idxNum using the -** arguments in argv[0]. See statBestIndex() for a description of the -** meaning of the bits in idxNum. -*/ static int statFilter( sqlite3_vtab_cursor *pCursor, int idxNum, const char *idxStr, @@ -199772,52 +196540,29 @@ static int statFilter( ){ StatCursor *pCsr = (StatCursor *)pCursor; StatTable *pTab = (StatTable*)(pCursor->pVtab); - sqlite3_str *pSql; /* Query of btrees to analyze */ - char *zSql; /* String value of pSql */ - int iArg = 0; /* Count of argv[] parameters used so far */ - int rc = SQLITE_OK; /* Result of this operation */ - const char *zName = 0; /* Only provide analysis of this table */ + char *zSql; + int rc = SQLITE_OK; - statResetCsr(pCsr); - sqlite3_finalize(pCsr->pStmt); - pCsr->pStmt = 0; - if( idxNum & 0x01 ){ - /* schema=? constraint is present. Get its value */ - const char *zDbase = (const char*)sqlite3_value_text(argv[iArg++]); + if( idxNum==1 ){ + const char *zDbase = (const char*)sqlite3_value_text(argv[0]); pCsr->iDb = sqlite3FindDbName(pTab->db, zDbase); if( pCsr->iDb<0 ){ - pCsr->iDb = 0; - pCsr->isEof = 1; - return SQLITE_OK; + sqlite3_free(pCursor->pVtab->zErrMsg); + pCursor->pVtab->zErrMsg = sqlite3_mprintf("no such schema: %s", zDbase); + return pCursor->pVtab->zErrMsg ? SQLITE_ERROR : SQLITE_NOMEM_BKPT; } }else{ pCsr->iDb = pTab->iDb; } - if( idxNum & 0x02 ){ - /* name=? constraint is present */ - zName = (const char*)sqlite3_value_text(argv[iArg++]); - } - if( idxNum & 0x04 ){ - /* aggregate=? constraint is present */ - pCsr->isAgg = sqlite3_value_double(argv[iArg++])!=0.0; - }else{ - pCsr->isAgg = 0; - } - pSql = sqlite3_str_new(pTab->db); - sqlite3_str_appendf(pSql, - "SELECT * FROM (" - "SELECT 'sqlite_master' AS name,1 AS rootpage,'table' AS type" - " UNION ALL " - "SELECT name,rootpage,type" - " FROM \"%w\".sqlite_master WHERE rootpage!=0)", - pTab->db->aDb[pCsr->iDb].zDbSName); - if( zName ){ - sqlite3_str_appendf(pSql, "WHERE name=%Q", zName); - } - if( idxNum & 0x08 ){ - sqlite3_str_appendf(pSql, " ORDER BY name"); - } - zSql = sqlite3_str_finish(pSql); + statResetCsr(pCsr); + sqlite3_finalize(pCsr->pStmt); + pCsr->pStmt = 0; + zSql = sqlite3_mprintf( + "SELECT 'sqlite_master' AS name, 1 AS rootpage, 'table' AS type" + " UNION ALL " + "SELECT name, rootpage, type" + " FROM \"%w\".sqlite_master WHERE rootpage!=0" + " ORDER BY name", pTab->db->aDb[pCsr->iDb].zDbSName); if( zSql==0 ){ return SQLITE_NOMEM_BKPT; }else{ @@ -199842,21 +196587,13 @@ static int statColumn( sqlite3_result_text(ctx, pCsr->zName, -1, SQLITE_TRANSIENT); break; case 1: /* path */ - if( !pCsr->isAgg ){ - sqlite3_result_text(ctx, pCsr->zPath, -1, SQLITE_TRANSIENT); - } + sqlite3_result_text(ctx, pCsr->zPath, -1, SQLITE_TRANSIENT); break; case 2: /* pageno */ - if( pCsr->isAgg ){ - sqlite3_result_int64(ctx, pCsr->nPage); - }else{ - sqlite3_result_int64(ctx, pCsr->iPageno); - } + sqlite3_result_int64(ctx, pCsr->iPageno); break; case 3: /* pagetype */ - if( !pCsr->isAgg ){ - sqlite3_result_text(ctx, pCsr->zPagetype, -1, SQLITE_STATIC); - } + sqlite3_result_text(ctx, pCsr->zPagetype, -1, SQLITE_STATIC); break; case 4: /* ncell */ sqlite3_result_int(ctx, pCsr->nCell); @@ -199871,23 +196608,17 @@ static int statColumn( sqlite3_result_int(ctx, pCsr->nMxPayload); break; case 8: /* pgoffset */ - if( !pCsr->isAgg ){ - sqlite3_result_int64(ctx, pCsr->iOffset); - } + sqlite3_result_int64(ctx, pCsr->iOffset); break; case 9: /* pgsize */ sqlite3_result_int(ctx, pCsr->szPage); break; - case 10: { /* schema */ + default: { /* schema */ sqlite3 *db = sqlite3_context_db_handle(ctx); int iDb = pCsr->iDb; sqlite3_result_text(ctx, db->aDb[iDb].zDbSName, -1, SQLITE_STATIC); break; } - default: { /* aggregate */ - sqlite3_result_int(ctx, pCsr->isAgg); - break; - } } return SQLITE_OK; } @@ -200011,7 +196742,6 @@ static int dbpageConnect( DbpageTable *pTab = 0; int rc = SQLITE_OK; - sqlite3_vtab_config(db, SQLITE_VTAB_DIRECTONLY); rc = sqlite3_declare_vtab(db, "CREATE TABLE x(pgno INTEGER PRIMARY KEY, data BLOB, schema HIDDEN)"); if( rc==SQLITE_OK ){ @@ -206000,7 +202730,7 @@ struct Fts5PhraseIter { ** ** xSetAuxdata(pFts5, pAux, xDelete) ** -** Save the pointer passed as the second argument as the extension function's +** Save the pointer passed as the second argument as the extension functions ** "auxiliary data". The pointer may then be retrieved by the current or any ** future invocation of the same fts5 extension function made as part of ** the same MATCH query using the xGetAuxdata() API. @@ -206242,8 +202972,8 @@ struct Fts5ExtensionApi { ** ** There are several ways to approach this in FTS5: ** -**
        1. By mapping all synonyms to a single token. In this case, using -** the above example, this means that the tokenizer returns the +**
          1. By mapping all synonyms to a single token. In this case, the +** In the above example, this means that the tokenizer returns the ** same token for inputs "first" and "1st". Say that token is in ** fact "first", so that when the user inserts the document "I won ** 1st place" entries are added to the index for tokens "i", "won", @@ -206478,11 +203208,6 @@ typedef sqlite3_uint64 u64; */ #define FTS5_MAX_PREFIX_INDEXES 31 -/* -** Maximum segments permitted in a single index -*/ -#define FTS5_MAX_SEGMENT 2000 - #define FTS5_DEFAULT_NEARDIST 10 #define FTS5_DEFAULT_RANK "bm25" @@ -206839,11 +203564,6 @@ static int sqlite3Fts5IterNextFrom(Fts5IndexIter*, i64 iMatch); */ static void sqlite3Fts5IterClose(Fts5IndexIter*); -/* -** Close the reader blob handle, if it is open. -*/ -static void sqlite3Fts5IndexCloseReader(Fts5Index*); - /* ** This interface is used by the fts5vocab module. */ @@ -207404,7 +204124,6 @@ typedef union { #define sqlite3Fts5ParserCTX_STORE #define fts5YYNSTATE 35 #define fts5YYNRULE 28 -#define fts5YYNRULE_WITH_ACTION 28 #define fts5YYNFTS5TOKEN 16 #define fts5YY_MAX_SHIFT 34 #define fts5YY_MIN_SHIFTREDUCE 52 @@ -208234,15 +204953,12 @@ static fts5YYACTIONTYPE fts5yy_reduce( if( fts5yyTraceFILE && fts5yyruleno<(int)(sizeof(fts5yyRuleName)/sizeof(fts5yyRuleName[0])) ){ fts5yysize = fts5yyRuleInfoNRhs[fts5yyruleno]; if( fts5yysize ){ - fprintf(fts5yyTraceFILE, "%sReduce %d [%s]%s, pop back to state %d.\n", + fprintf(fts5yyTraceFILE, "%sReduce %d [%s], go to state %d.\n", fts5yyTracePrompt, - fts5yyruleno, fts5yyRuleName[fts5yyruleno], - fts5yyrulenoFTS5_MAX_PAGE_SIZE ){ + if( pgsz<=0 || pgsz>FTS5_MAX_PAGE_SIZE ){ *pbBadkey = 1; }else{ pConfig->pgsz = pgsz; @@ -210732,7 +207448,6 @@ static int sqlite3Fts5ConfigSetValue( *pbBadkey = 1; }else{ if( nCrisisMerge<=1 ) nCrisisMerge = FTS5_DEFAULT_CRISISMERGE; - if( nCrisisMerge>=FTS5_MAX_SEGMENT ) nCrisisMerge = FTS5_MAX_SEGMENT-1; pConfig->nCrisisMerge = nCrisisMerge; } } @@ -213330,12 +210045,10 @@ static void fts5ExprFunction( azConfig[1] = "main"; azConfig[2] = "tbl"; for(i=3; iArgpReader ){ sqlite3_blob *pReader = p->pReader; p->pReader = 0; @@ -214910,7 +211628,7 @@ static Fts5Data *fts5DataRead(Fts5Index *p, i64 iRowid){ assert( p->pReader==0 ); p->pReader = pBlob; if( rc!=SQLITE_OK ){ - sqlite3Fts5IndexCloseReader(p); + fts5CloseReader(p); } if( rc==SQLITE_ABORT ) rc = SQLITE_OK; } @@ -219471,7 +216189,7 @@ static int sqlite3Fts5IndexBeginWrite(Fts5Index *p, int bDelete, i64 iRowid){ static int sqlite3Fts5IndexSync(Fts5Index *p){ assert( p->rc==SQLITE_OK ); fts5IndexFlush(p); - sqlite3Fts5IndexCloseReader(p); + fts5CloseReader(p); return fts5IndexReturn(p); } @@ -219482,7 +216200,7 @@ static int sqlite3Fts5IndexSync(Fts5Index *p){ ** records must be invalidated. */ static int sqlite3Fts5IndexRollback(Fts5Index *p){ - sqlite3Fts5IndexCloseReader(p); + fts5CloseReader(p); fts5IndexDiscardData(p); fts5StructureInvalidate(p); /* assert( p->rc==SQLITE_OK ); */ @@ -219497,7 +216215,6 @@ static int sqlite3Fts5IndexRollback(Fts5Index *p){ static int sqlite3Fts5IndexReinit(Fts5Index *p){ Fts5Structure s; fts5StructureInvalidate(p); - fts5IndexDiscardData(p); memset(&s, 0, sizeof(Fts5Structure)); fts5DataWrite(p, FTS5_AVERAGES_ROWID, (const u8*)"", 0); fts5StructureWrite(p, &s); @@ -219585,13 +216302,9 @@ static int sqlite3Fts5IndexCharlenToBytelen( for(i=0; i=nByte ) return 0; /* Input contains fewer than nChar chars */ if( (unsigned char)p[n++]>=0xc0 ){ - if( n>=nByte ) return 0; while( (p[n] & 0xc0)==0x80 ){ n++; - if( n>=nByte ){ - if( i+1==nChar ) break; - return 0; - } + if( n>=nByte ) break; } } } @@ -219727,7 +216440,7 @@ static int sqlite3Fts5IndexQuery( if( p->rc ){ sqlite3Fts5IterClose((Fts5IndexIter*)pRet); pRet = 0; - sqlite3Fts5IndexCloseReader(p); + fts5CloseReader(p); } *ppIter = (Fts5IndexIter*)pRet; @@ -219800,7 +216513,7 @@ static void sqlite3Fts5IterClose(Fts5IndexIter *pIndexIter){ Fts5Iter *pIter = (Fts5Iter*)pIndexIter; Fts5Index *pIndex = pIter->pIndex; fts5MultiIterFree(pIter); - sqlite3Fts5IndexCloseReader(pIndex); + fts5CloseReader(pIndex); } } @@ -219993,37 +216706,6 @@ static int fts5QueryCksum( return rc; } -/* -** Check if buffer z[], size n bytes, contains as series of valid utf-8 -** encoded codepoints. If so, return 0. Otherwise, if the buffer does not -** contain valid utf-8, return non-zero. -*/ -static int fts5TestUtf8(const char *z, int n){ - assert_nc( n>0 ); - int i = 0; - while( i=n || (z[i+1] & 0xC0)!=0x80 ) return 1; - i += 2; - }else - if( (z[i] & 0xF0)==0xE0 ){ - if( i+2>=n || (z[i+1] & 0xC0)!=0x80 || (z[i+2] & 0xC0)!=0x80 ) return 1; - i += 3; - }else - if( (z[i] & 0xF8)==0xF0 ){ - if( i+3>=n || (z[i+1] & 0xC0)!=0x80 || (z[i+2] & 0xC0)!=0x80 ) return 1; - if( (z[i+2] & 0xC0)!=0x80 ) return 1; - i += 3; - }else{ - return 1; - } - } - - return 0; -} /* ** This function is also purely an internal test. It does not contribute to @@ -220064,14 +216746,8 @@ static void fts5TestTerm( ** This check may only be performed if the hash table is empty. This ** is because the hash table only supports a single scan query at ** a time, and the multi-iter loop from which this function is called - ** is already performing such a scan. - ** - ** Also only do this if buffer zTerm contains nTerm bytes of valid - ** utf-8. Otherwise, the last part of the buffer contents might contain - ** a non-utf-8 sequence that happens to be a prefix of a valid utf-8 - ** character stored in the main fts index, which will cause the - ** test to fail. */ - if( p->nPendingData==0 && 0==fts5TestUtf8(zTerm, nTerm) ){ + ** is already performing such a scan. */ + if( p->nPendingData==0 ){ if( iIdx>0 && rc==SQLITE_OK ){ int f = flags|FTS5INDEX_QUERY_TEST_NOIDX; ck2 = 0; @@ -220194,8 +216870,7 @@ static void fts5IndexIntegrityCheckSegment( if( pSeg->pgnoFirst==0 ) return; fts5IndexPrepareStmt(p, &pStmt, sqlite3_mprintf( - "SELECT segid, term, (pgno>>1), (pgno&1) FROM %Q.'%q_idx' WHERE segid=%d " - "ORDER BY 1, 2", + "SELECT segid, term, (pgno>>1), (pgno&1) FROM %Q.'%q_idx' WHERE segid=%d", pConfig->zDb, pConfig->zName, pSeg->iSegid )); @@ -220204,8 +216879,8 @@ static void fts5IndexIntegrityCheckSegment( i64 iRow; /* Rowid for this leaf */ Fts5Data *pLeaf; /* Data for this leaf */ - const char *zIdxTerm = (const char*)sqlite3_column_blob(pStmt, 1); int nIdxTerm = sqlite3_column_bytes(pStmt, 1); + const char *zIdxTerm = (const char*)sqlite3_column_text(pStmt, 1); int iIdxLeaf = sqlite3_column_int(pStmt, 2); int bIdxDlidx = sqlite3_column_int(pStmt, 3); @@ -221186,10 +217861,7 @@ static void fts5CheckTransactionState(Fts5FullTable *p, int op, int iSavepoint){ case FTS5_ROLLBACKTO: assert( p->ts.eState==1 ); assert( iSavepoint>=-1 ); - /* The following assert() can fail if another vtab strikes an error - ** within an xSavepoint() call then SQLite calls xRollbackTo() - without - ** having called xSavepoint() on this vtab. */ - /* assert( iSavepoint<=p->ts.iSavepoint ); */ + assert( iSavepoint<=p->ts.iSavepoint ); p->ts.iSavepoint = iSavepoint; break; } @@ -221644,7 +218316,6 @@ static void fts5FreeCursorComponents(Fts5Cursor *pCsr){ sqlite3_free(pCsr->zRankArgs); } - sqlite3Fts5IndexCloseReader(pTab->p.pIndex); memset(&pCsr->ePlan, 0, sizeof(Fts5Cursor) - ((u8*)&pCsr->ePlan - (u8*)pCsr)); } @@ -221795,24 +218466,15 @@ static int fts5NextMethod(sqlite3_vtab_cursor *pCursor){ break; } - default: { - Fts5Config *pConfig = ((Fts5Table*)pCursor->pVtab)->pConfig; - pConfig->bLock++; + default: rc = sqlite3_step(pCsr->pStmt); - pConfig->bLock--; if( rc!=SQLITE_ROW ){ CsrFlagSet(pCsr, FTS5CSR_EOF); rc = sqlite3_reset(pCsr->pStmt); - if( rc!=SQLITE_OK ){ - pCursor->pVtab->zErrMsg = sqlite3_mprintf( - "%s", sqlite3_errmsg(pConfig->db) - ); - } }else{ rc = SQLITE_OK; } break; - } } } @@ -222097,13 +218759,6 @@ static int fts5FilterMethod( int iIdxStr = 0; Fts5Expr *pExpr = 0; - if( pConfig->bLock ){ - pTab->p.base.zErrMsg = sqlite3_mprintf( - "recursively defined fts5 content table" - ); - return SQLITE_ERROR; - } - if( pCsr->ePlan ){ fts5FreeCursorComponents(pCsr); memset(&pCsr->ePlan, 0, sizeof(Fts5Cursor) - ((u8*)&pCsr->ePlan-(u8*)pCsr)); @@ -222324,13 +218979,10 @@ static int fts5SeekCursor(Fts5Cursor *pCsr, int bErrormsg){ } if( rc==SQLITE_OK && CsrFlagTest(pCsr, FTS5CSR_REQUIRE_CONTENT) ){ - Fts5Table *pTab = (Fts5Table*)(pCsr->base.pVtab); assert( pCsr->pExpr ); sqlite3_reset(pCsr->pStmt); sqlite3_bind_int64(pCsr->pStmt, 1, fts5CursorRowid(pCsr)); - pTab->pConfig->bLock++; rc = sqlite3_step(pCsr->pStmt); - pTab->pConfig->bLock--; if( rc==SQLITE_ROW ){ rc = SQLITE_OK; CsrFlagClear(pCsr, FTS5CSR_REQUIRE_CONTENT); @@ -222338,10 +218990,6 @@ static int fts5SeekCursor(Fts5Cursor *pCsr, int bErrormsg){ rc = sqlite3_reset(pCsr->pStmt); if( rc==SQLITE_OK ){ rc = FTS5_CORRUPT; - }else if( pTab->pConfig->pzErrmsg ){ - *pTab->pConfig->pzErrmsg = sqlite3_mprintf( - "%s", sqlite3_errmsg(pTab->pConfig->db) - ); } } } @@ -223357,12 +220005,10 @@ static int fts5ColumnMethod( } } }else if( !fts5IsContentless(pTab) ){ - pConfig->pzErrmsg = &pTab->p.base.zErrMsg; rc = fts5SeekCursor(pCsr, 1); if( rc==SQLITE_OK ){ sqlite3_result_value(pCtx, sqlite3_column_value(pCsr->pStmt, iCol+1)); } - pConfig->pzErrmsg = 0; } return rc; } @@ -223639,7 +220285,7 @@ static void fts5SourceIdFunc( ){ assert( nArg==0 ); UNUSED_PARAM2(nArg, apUnused); - sqlite3_result_text(pCtx, "fts5: 2020-01-22 18:38:59 f6affdd41608946fcfcea914ece149038a8b25a62bbe719ed2561c649b86d824", -1, SQLITE_TRANSIENT); + sqlite3_result_text(pCtx, "fts5: 2019-10-10 20:19:45 18db032d058f1436ce3dea84081f4ee5a0f2259ad97301d43c426bc7f3df1b0b", -1, SQLITE_TRANSIENT); } /* @@ -224333,8 +220979,6 @@ static int sqlite3Fts5StorageDeleteAll(Fts5Storage *p){ Fts5Config *pConfig = p->pConfig; int rc; - p->bTotalsValid = 0; - /* Delete the contents of the %_data and %_docsize tables. */ rc = fts5ExecPrintf(pConfig->db, 0, "DELETE FROM %Q.'%q_data';" @@ -224386,11 +221030,10 @@ static int sqlite3Fts5StorageRebuild(Fts5Storage *p){ for(ctx.iCol=0; rc==SQLITE_OK && ctx.iColnCol; ctx.iCol++){ ctx.szCol = 0; if( pConfig->abUnindexed[ctx.iCol]==0 ){ - const char *zText = (const char*)sqlite3_column_text(pScan, ctx.iCol+1); - int nText = sqlite3_column_bytes(pScan, ctx.iCol+1); rc = sqlite3Fts5Tokenize(pConfig, FTS5_TOKENIZE_DOCUMENT, - zText, nText, + (const char*)sqlite3_column_text(pScan, ctx.iCol+1), + sqlite3_column_bytes(pScan, ctx.iCol+1), (void*)&ctx, fts5StorageInsertCallback ); @@ -224512,11 +221155,10 @@ static int sqlite3Fts5StorageIndexInsert( for(ctx.iCol=0; rc==SQLITE_OK && ctx.iColnCol; ctx.iCol++){ ctx.szCol = 0; if( pConfig->abUnindexed[ctx.iCol]==0 ){ - const char *zText = (const char*)sqlite3_value_text(apVal[ctx.iCol+2]); - int nText = sqlite3_value_bytes(apVal[ctx.iCol+2]); rc = sqlite3Fts5Tokenize(pConfig, FTS5_TOKENIZE_DOCUMENT, - zText, nText, + (const char*)sqlite3_value_text(apVal[ctx.iCol+2]), + sqlite3_value_bytes(apVal[ctx.iCol+2]), (void*)&ctx, fts5StorageInsertCallback ); @@ -224685,11 +221327,10 @@ static int sqlite3Fts5StorageIntegrity(Fts5Storage *p){ rc = sqlite3Fts5TermsetNew(&ctx.pTermset); } if( rc==SQLITE_OK ){ - const char *zText = (const char*)sqlite3_column_text(pScan, i+1); - int nText = sqlite3_column_bytes(pScan, i+1); rc = sqlite3Fts5Tokenize(pConfig, FTS5_TOKENIZE_DOCUMENT, - zText, nText, + (const char*)sqlite3_column_text(pScan, i+1), + sqlite3_column_bytes(pScan, i+1), (void*)&ctx, fts5StorageIntegrityCallback ); @@ -228412,9 +225053,9 @@ SQLITE_API int sqlite3_stmt_init( #endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_STMTVTAB) */ /************** End of stmt.c ************************************************/ -#if __LINE__!=228415 +#if __LINE__!=225056 #undef SQLITE_SOURCE_ID -#define SQLITE_SOURCE_ID "2020-01-22 18:38:59 f6affdd41608946fcfcea914ece149038a8b25a62bbe719ed2561c649b86alt2" +#define SQLITE_SOURCE_ID "2019-10-10 20:19:45 18db032d058f1436ce3dea84081f4ee5a0f2259ad97301d43c426bc7f3dfalt2" #endif /* Return the source-id for this library */ SQLITE_API const char *sqlite3_sourceid(void){ return SQLITE_SOURCE_ID; } diff --git a/contrib/sqlite3/sqlite3.h b/contrib/sqlite3/sqlite3.h index 58526dd0fb55..37bfac528982 100644 --- a/contrib/sqlite3/sqlite3.h +++ b/contrib/sqlite3/sqlite3.h @@ -123,9 +123,9 @@ extern "C" { ** [sqlite3_libversion_number()], [sqlite3_sourceid()], ** [sqlite_version()] and [sqlite_source_id()]. */ -#define SQLITE_VERSION "3.31.0" -#define SQLITE_VERSION_NUMBER 3031000 -#define SQLITE_SOURCE_ID "2020-01-22 18:38:59 f6affdd41608946fcfcea914ece149038a8b25a62bbe719ed2561c649b86d824" +#define SQLITE_VERSION "3.30.1" +#define SQLITE_VERSION_NUMBER 3030001 +#define SQLITE_SOURCE_ID "2019-10-10 20:19:45 18db032d058f1436ce3dea84081f4ee5a0f2259ad97301d43c426bc7f3df1b0b" /* ** CAPI3REF: Run-Time Library Version Numbers @@ -516,7 +516,6 @@ SQLITE_API int sqlite3_exec( #define SQLITE_CANTOPEN_FULLPATH (SQLITE_CANTOPEN | (3<<8)) #define SQLITE_CANTOPEN_CONVPATH (SQLITE_CANTOPEN | (4<<8)) #define SQLITE_CANTOPEN_DIRTYWAL (SQLITE_CANTOPEN | (5<<8)) /* Not Used */ -#define SQLITE_CANTOPEN_SYMLINK (SQLITE_CANTOPEN | (6<<8)) #define SQLITE_CORRUPT_VTAB (SQLITE_CORRUPT | (1<<8)) #define SQLITE_CORRUPT_SEQUENCE (SQLITE_CORRUPT | (2<<8)) #define SQLITE_READONLY_RECOVERY (SQLITE_READONLY | (1<<8)) @@ -536,13 +535,11 @@ SQLITE_API int sqlite3_exec( #define SQLITE_CONSTRAINT_UNIQUE (SQLITE_CONSTRAINT | (8<<8)) #define SQLITE_CONSTRAINT_VTAB (SQLITE_CONSTRAINT | (9<<8)) #define SQLITE_CONSTRAINT_ROWID (SQLITE_CONSTRAINT |(10<<8)) -#define SQLITE_CONSTRAINT_PINNED (SQLITE_CONSTRAINT |(11<<8)) #define SQLITE_NOTICE_RECOVER_WAL (SQLITE_NOTICE | (1<<8)) #define SQLITE_NOTICE_RECOVER_ROLLBACK (SQLITE_NOTICE | (2<<8)) #define SQLITE_WARNING_AUTOINDEX (SQLITE_WARNING | (1<<8)) #define SQLITE_AUTH_USER (SQLITE_AUTH | (1<<8)) #define SQLITE_OK_LOAD_PERMANENTLY (SQLITE_OK | (1<<8)) -#define SQLITE_OK_SYMLINK (SQLITE_OK | (2<<8)) /* ** CAPI3REF: Flags For File Open Operations @@ -571,7 +568,6 @@ SQLITE_API int sqlite3_exec( #define SQLITE_OPEN_SHAREDCACHE 0x00020000 /* Ok for sqlite3_open_v2() */ #define SQLITE_OPEN_PRIVATECACHE 0x00040000 /* Ok for sqlite3_open_v2() */ #define SQLITE_OPEN_WAL 0x00080000 /* VFS only */ -#define SQLITE_OPEN_NOFOLLOW 0x01000000 /* Ok for sqlite3_open_v2() */ /* Reserved: 0x00F00000 */ @@ -983,16 +979,16 @@ struct sqlite3_io_methods { ** ^The [SQLITE_FCNTL_BUSYHANDLER] ** file-control may be invoked by SQLite on the database file handle ** shortly after it is opened in order to provide a custom VFS with access -** to the connection's busy-handler callback. The argument is of type (void**) +** to the connections busy-handler callback. The argument is of type (void **) ** - an array of two (void *) values. The first (void *) actually points -** to a function of type (int (*)(void *)). In order to invoke the connection's +** to a function of type (int (*)(void *)). In order to invoke the connections ** busy-handler, this function should be invoked with the second (void *) in ** the array as the only argument. If it returns non-zero, then the operation ** should be retried. If it returns zero, the custom VFS should abandon the ** current operation. ** **
          2. [[SQLITE_FCNTL_TEMPFILENAME]] -** ^Applications can invoke the [SQLITE_FCNTL_TEMPFILENAME] file-control +** ^Application can invoke the [SQLITE_FCNTL_TEMPFILENAME] file-control ** to have SQLite generate a ** temporary filename using the same algorithm that is followed to generate ** temporary filenames for TEMP tables and other internal uses. The @@ -1105,18 +1101,12 @@ struct sqlite3_io_methods { ** not provide a mechanism to detect changes to MAIN only. Also, the ** [sqlite3_total_changes()] interface responds to internal changes only and ** omits changes made by other database connections. The -** [PRAGMA data_version] command provides a mechanism to detect changes to +** [PRAGMA data_version] command provide a mechanism to detect changes to ** a single attached database that occur due to other database connections, ** but omits changes implemented by the database connection on which it is ** called. This file control is the only mechanism to detect changes that ** happen either internally or externally and that are associated with ** a particular attached database. -** -**
          3. [[SQLITE_FCNTL_CKPT_DONE]] -** The [SQLITE_FCNTL_CKPT_DONE] opcode is invoked from within a checkpoint -** in wal mode after the client has finished copying pages from the wal -** file to the database file, but before the *-shm file is updated to -** record the fact that the pages have been checkpointed. ** */ #define SQLITE_FCNTL_LOCKSTATE 1 @@ -1154,7 +1144,6 @@ struct sqlite3_io_methods { #define SQLITE_FCNTL_LOCK_TIMEOUT 34 #define SQLITE_FCNTL_DATA_VERSION 35 #define SQLITE_FCNTL_SIZE_LIMIT 36 -#define SQLITE_FCNTL_CKPT_DONE 37 /* deprecated names */ #define SQLITE_GET_LOCKPROXYFILE SQLITE_FCNTL_GET_LOCKPROXYFILE @@ -1200,10 +1189,10 @@ typedef struct sqlite3_api_routines sqlite3_api_routines; ** to 3 with SQLite [version 3.7.6] on [dateof:3.7.6]. Additional fields ** may be appended to the sqlite3_vfs object and the iVersion value ** may increase again in future versions of SQLite. -** Note that due to an oversight, the structure -** of the sqlite3_vfs object changed in the transition from +** Note that the structure +** of the sqlite3_vfs object changes in the transition from ** SQLite [version 3.5.9] to [version 3.6.0] on [dateof:3.6.0] -** and yet the iVersion field was not increased. +** and yet the iVersion field was not modified. ** ** The szOsFile field is the size of the subclassed [sqlite3_file] ** structure used by this VFS. mxPathname is the maximum length of @@ -1294,7 +1283,7 @@ typedef struct sqlite3_api_routines sqlite3_api_routines; ** for exclusive access. ** ** ^At least szOsFile bytes of memory are allocated by SQLite -** to hold the [sqlite3_file] structure passed as the third +** to hold the [sqlite3_file] structure passed as the third ** argument to xOpen. The xOpen method does not have to ** allocate the structure; it should just fill it in. Note that ** the xOpen method must set the sqlite3_file.pMethods to either @@ -1631,7 +1620,7 @@ SQLITE_API int sqlite3_db_config(sqlite3*, int op, ...); ** that causes the corresponding memory allocation to fail. ** ** The xInit method initializes the memory allocator. For example, -** it might allocate any required mutexes or initialize internal data +** it might allocate any require mutexes or initialize internal data ** structures. The xShutdown method is invoked (indirectly) by ** [sqlite3_shutdown()] and should deallocate any resources acquired ** by xInit. The pAppData pointer is used as the only parameter to @@ -1753,7 +1742,6 @@ struct sqlite3_mem_methods { ** memory allocation statistics. ^(When memory allocation statistics are ** disabled, the following SQLite interfaces become non-operational: **
              -**
            • [sqlite3_hard_heap_limit64()] **
            • [sqlite3_memory_used()] **
            • [sqlite3_memory_highwater()] **
            • [sqlite3_soft_heap_limit64()] @@ -1772,7 +1760,7 @@ struct sqlite3_mem_methods { **
              ^The SQLITE_CONFIG_PAGECACHE option specifies a memory pool ** that SQLite can use for the database page cache with the default page ** cache implementation. -** This configuration option is a no-op if an application-defined page +** This configuration option is a no-op if an application-define page ** cache implementation is loaded using the [SQLITE_CONFIG_PCACHE2]. ** ^There are three arguments to SQLITE_CONFIG_PAGECACHE: A pointer to ** 8-byte aligned memory (pMem), the size of each page cache line (sz), @@ -2257,7 +2245,7 @@ struct sqlite3_mem_methods { ** [[SQLITE_DBCONFIG_DQS_DML]] **
              SQLITE_DBCONFIG_DQS_DML **
              The SQLITE_DBCONFIG_DQS_DML option activates or deactivates -** the legacy [double-quoted string literal] misfeature for DML statements +** the legacy [double-quoted string literal] misfeature for DML statement ** only, that is DELETE, INSERT, SELECT, and UPDATE statements. The ** default value of this setting is determined by the [-DSQLITE_DQS] ** compile-time option. @@ -2271,49 +2259,6 @@ struct sqlite3_mem_methods { ** default value of this setting is determined by the [-DSQLITE_DQS] ** compile-time option. **
              -** -** [[SQLITE_DBCONFIG_TRUSTED_SCHEMA]] -**
              SQLITE_DBCONFIG_TRUSTED_SCHEMA -**
              The SQLITE_DBCONFIG_TRUSTED_SCHEMA option tells SQLite to -** assume that database schemas (the contents of the [sqlite_master] tables) -** are untainted by malicious content. -** When the SQLITE_DBCONFIG_TRUSTED_SCHEMA option is disabled, SQLite -** takes additional defensive steps to protect the application from harm -** including: -**
                -**
              • Prohibit the use of SQL functions inside triggers, views, -** CHECK constraints, DEFAULT clauses, expression indexes, -** partial indexes, or generated columns -** unless those functions are tagged with [SQLITE_INNOCUOUS]. -**
              • Prohibit the use of virtual tables inside of triggers or views -** unless those virtual tables are tagged with [SQLITE_VTAB_INNOCUOUS]. -**
              -** This setting defaults to "on" for legacy compatibility, however -** all applications are advised to turn it off if possible. This setting -** can also be controlled using the [PRAGMA trusted_schema] statement. -**
              -** -** [[SQLITE_DBCONFIG_LEGACY_FILE_FORMAT]] -**
              SQLITE_DBCONFIG_LEGACY_FILE_FORMAT -**
              The SQLITE_DBCONFIG_LEGACY_FILE_FORMAT option activates or deactivates -** the legacy file format flag. When activated, this flag causes all newly -** created database file to have a schema format version number (the 4-byte -** integer found at offset 44 into the database header) of 1. This in turn -** means that the resulting database file will be readable and writable by -** any SQLite version back to 3.0.0 ([dateof:3.0.0]). Without this setting, -** newly created databases are generally not understandable by SQLite versions -** prior to 3.3.0 ([dateof:3.3.0]). As these words are written, there -** is now scarcely any need to generated database files that are compatible -** all the way back to version 3.0.0, and so this setting is of little -** practical use, but is provided so that SQLite can continue to claim the -** ability to generate new database files that are compatible with version -** 3.0.0. -**

              Note that when the SQLITE_DBCONFIG_LEGACY_FILE_FORMAT setting is on, -** the [VACUUM] command will fail with an obscure error when attempting to -** process a table with generated columns and a descending index. This is -** not considered a bug since SQLite versions 3.3.0 and earlier do not support -** either generated columns or decending indexes. -**

              **
    */ #define SQLITE_DBCONFIG_MAINDBNAME 1000 /* const char* */ @@ -2332,9 +2277,7 @@ struct sqlite3_mem_methods { #define SQLITE_DBCONFIG_DQS_DML 1013 /* int int* */ #define SQLITE_DBCONFIG_DQS_DDL 1014 /* int int* */ #define SQLITE_DBCONFIG_ENABLE_VIEW 1015 /* int int* */ -#define SQLITE_DBCONFIG_LEGACY_FILE_FORMAT 1016 /* int int* */ -#define SQLITE_DBCONFIG_TRUSTED_SCHEMA 1017 /* int int* */ -#define SQLITE_DBCONFIG_MAX 1017 /* Largest DBCONFIG */ +#define SQLITE_DBCONFIG_MAX 1015 /* Largest DBCONFIG */ /* ** CAPI3REF: Enable Or Disable Extended Result Codes @@ -2540,7 +2483,7 @@ SQLITE_API int sqlite3_total_changes(sqlite3*); ** ^The sqlite3_interrupt(D) call is in effect until all currently running ** SQL statements on [database connection] D complete. ^Any new SQL statements ** that are started after the sqlite3_interrupt() call and before the -** running statement count reaches zero are interrupted as if they had been +** running statements reaches zero are interrupted as if they had been ** running prior to the sqlite3_interrupt() call. ^New SQL statements ** that are started after the running statement count reaches zero are ** not effected by the sqlite3_interrupt(). @@ -2708,9 +2651,9 @@ SQLITE_API int sqlite3_busy_timeout(sqlite3*, int ms); ** Cindy | 21 ** ** -** There are two columns (M==2) and three rows (N==3). Thus the +** There are two column (M==2) and three rows (N==3). Thus the ** result table has 8 entries. Suppose the result table is stored -** in an array named azResult. Then azResult holds this content: +** in an array names azResult. Then azResult holds this content: ** **
     **        azResult[0] = "Name";
    @@ -2803,7 +2746,7 @@ SQLITE_API char *sqlite3_vsnprintf(int,char*,const char*, va_list);
     **
     ** The SQLite core uses these three routines for all of its own
     ** internal memory allocation needs. "Core" in the previous sentence
    -** does not include operating-system specific [VFS] implementation.  The
    +** does not include operating-system specific VFS implementation.  The
     ** Windows VFS uses native malloc() and free() for some operations.
     **
     ** ^The sqlite3_malloc() routine returns a pointer to a block
    @@ -2864,6 +2807,19 @@ SQLITE_API char *sqlite3_vsnprintf(int,char*,const char*, va_list);
     ** 4 byte boundary if the [SQLITE_4_BYTE_ALIGNED_MALLOC] compile-time
     ** option is used.
     **
    +** In SQLite version 3.5.0 and 3.5.1, it was possible to define
    +** the SQLITE_OMIT_MEMORY_ALLOCATION which would cause the built-in
    +** implementation of these routines to be omitted.  That capability
    +** is no longer provided.  Only built-in memory allocators can be used.
    +**
    +** Prior to SQLite version 3.7.10, the Windows OS interface layer called
    +** the system malloc() and free() directly when converting
    +** filenames between the UTF-8 encoding used by SQLite
    +** and whatever filename encoding is used by the particular Windows
    +** installation.  Memory allocation errors were detected, but
    +** they were reported back as [SQLITE_CANTOPEN] or
    +** [SQLITE_IOERR] rather than [SQLITE_NOMEM].
    +**
     ** The pointer arguments to [sqlite3_free()] and [sqlite3_realloc()]
     ** must be either NULL or else pointers obtained from a prior
     ** invocation of [sqlite3_malloc()] or [sqlite3_realloc()] that have
    @@ -2912,7 +2868,7 @@ SQLITE_API sqlite3_int64 sqlite3_memory_highwater(int resetFlag);
     ** SQLite contains a high-quality pseudo-random number generator (PRNG) used to
     ** select random [ROWID | ROWIDs] when inserting new records into a table that
     ** already uses the largest possible [ROWID].  The PRNG is also used for
    -** the built-in random() and randomblob() SQL functions.  This interface allows
    +** the build-in random() and randomblob() SQL functions.  This interface allows
     ** applications to access the same PRNG for other purposes.
     **
     ** ^A call to this routine stores N bytes of randomness into buffer P.
    @@ -3286,8 +3242,10 @@ SQLITE_API void sqlite3_progress_handler(sqlite3*, int, int(*)(void*), void*);
     ** The sqlite3_open_v2() interface works like sqlite3_open()
     ** except that it accepts two additional parameters for additional control
     ** over the new database connection.  ^(The flags parameter to
    -** sqlite3_open_v2() must include, at a minimum, one of the following
    -** three flag combinations:)^
    +** sqlite3_open_v2() can take one of
    +** the following three values, optionally combined with the 
    +** [SQLITE_OPEN_NOMUTEX], [SQLITE_OPEN_FULLMUTEX], [SQLITE_OPEN_SHAREDCACHE],
    +** [SQLITE_OPEN_PRIVATECACHE], and/or [SQLITE_OPEN_URI] flags:)^
     **
     ** 
    ** ^(
    [SQLITE_OPEN_READONLY]
    @@ -3305,51 +3263,23 @@ SQLITE_API void sqlite3_progress_handler(sqlite3*, int, int(*)(void*), void*); ** sqlite3_open() and sqlite3_open16().)^ **
    ** -** In addition to the required flags, the following optional flags are -** also supported: -** -**
    -** ^(
    [SQLITE_OPEN_URI]
    -**
    The filename can be interpreted as a URI if this flag is set.
    )^ -** -** ^(
    [SQLITE_OPEN_MEMORY]
    -**
    The database will be opened as an in-memory database. The database -** is named by the "filename" argument for the purposes of cache-sharing, -** if shared cache mode is enabled, but the "filename" is otherwise ignored. -**
    )^ -** -** ^(
    [SQLITE_OPEN_NOMUTEX]
    -**
    The new database connection will use the "multi-thread" -** [threading mode].)^ This means that separate threads are allowed -** to use SQLite at the same time, as long as each thread is using -** a different [database connection]. -** -** ^(
    [SQLITE_OPEN_FULLMUTEX]
    -**
    The new database connection will use the "serialized" -** [threading mode].)^ This means the multiple threads can safely -** attempt to use the same database connection at the same time. -** (Mutexes will block any actual concurrency, but in this mode -** there is no harm in trying.) -** -** ^(
    [SQLITE_OPEN_SHAREDCACHE]
    -**
    The database is opened [shared cache] enabled, overriding -** the default shared cache setting provided by -** [sqlite3_enable_shared_cache()].)^ -** -** ^(
    [SQLITE_OPEN_PRIVATECACHE]
    -**
    The database is opened [shared cache] disabled, overriding -** the default shared cache setting provided by -** [sqlite3_enable_shared_cache()].)^ -** -** [[OPEN_NOFOLLOW]] ^(
    [SQLITE_OPEN_NOFOLLOW]
    -**
    The database filename is not allowed to be a symbolic link
    -**
    )^ -** ** If the 3rd parameter to sqlite3_open_v2() is not one of the -** required combinations shown above optionally combined with other +** combinations shown above optionally combined with other ** [SQLITE_OPEN_READONLY | SQLITE_OPEN_* bits] ** then the behavior is undefined. ** +** ^If the [SQLITE_OPEN_NOMUTEX] flag is set, then the database connection +** opens in the multi-thread [threading mode] as long as the single-thread +** mode has not been set at compile-time or start-time. ^If the +** [SQLITE_OPEN_FULLMUTEX] flag is set then the database connection opens +** in the serialized [threading mode] unless single-thread was +** previously selected at compile-time or start-time. +** ^The [SQLITE_OPEN_SHAREDCACHE] flag causes the database connection to be +** eligible to use [shared cache mode], regardless of whether or not shared +** cache is enabled using [sqlite3_enable_shared_cache()]. ^The +** [SQLITE_OPEN_PRIVATECACHE] flag causes the database connection to not +** participate in [shared cache mode] even if it is enabled. +** ** ^The fourth parameter to sqlite3_open_v2() is the name of the ** [sqlite3_vfs] object that defines the operating system interface that ** the new database connection should use. ^If the fourth parameter is @@ -3529,16 +3459,17 @@ SQLITE_API int sqlite3_open_v2( /* ** CAPI3REF: Obtain Values For URI Parameters ** -** These are utility routines, useful to [VFS|custom VFS implementations], -** that check if a database file was a URI that contained a specific query +** These are utility routines, useful to VFS implementations, that check +** to see if a database file was a URI that contained a specific query ** parameter, and if so obtains the value of that query parameter. ** ** If F is the database filename pointer passed into the xOpen() method of -** a VFS implementation or it is the return value of [sqlite3_db_filename()] -** and if P is the name of the query parameter, then +** a VFS implementation when the flags parameter to xOpen() has one or +** more of the [SQLITE_OPEN_URI] or [SQLITE_OPEN_MAIN_DB] bits set and +** P is the name of the query parameter, then ** sqlite3_uri_parameter(F,P) returns the value of the P ** parameter if it exists or a NULL pointer if P does not appear as a -** query parameter on F. If P is a query parameter of F and it +** query parameter on F. If P is a query parameter of F ** has no explicit value, then sqlite3_uri_parameter(F,P) returns ** a pointer to an empty string. ** @@ -3550,72 +3481,25 @@ SQLITE_API int sqlite3_open_v2( ** sqlite3_uri_boolean(F,P,B) routines returns false (0) if the value of ** query parameter P is one of "no", "false", or "off" in any case or ** if the value begins with a numeric zero. If P is not a query -** parameter on F or if the value of P does not match any of the +** parameter on F or if the value of P is does not match any of the ** above, then sqlite3_uri_boolean(F,P,B) returns (B!=0). ** ** The sqlite3_uri_int64(F,P,D) routine converts the value of P into a ** 64-bit signed integer and returns that integer, or D if P does not ** exist. If the value of P is something other than an integer, then ** zero is returned. -** -** The sqlite3_uri_key(F,N) returns a pointer to the name (not -** the value) of the N-th query parameter for filename F, or a NULL -** pointer if N is less than zero or greater than the number of query -** parameters minus 1. The N value is zero-based so N should be 0 to obtain -** the name of the first query parameter, 1 for the second parameter, and -** so forth. ** ** If F is a NULL pointer, then sqlite3_uri_parameter(F,P) returns NULL and ** sqlite3_uri_boolean(F,P,B) returns B. If F is not a NULL pointer and -** is not a database file pathname pointer that the SQLite core passed -** into the xOpen VFS method, then the behavior of this routine is undefined -** and probably undesirable. -** -** Beginning with SQLite [version 3.31.0] ([dateof:3.31.0]) the input F -** parameter can also be the name of a rollback journal file or WAL file -** in addition to the main database file. Prior to version 3.31.0, these -** routines would only work if F was the name of the main database file. -** When the F parameter is the name of the rollback journal or WAL file, -** it has access to all the same query parameters as were found on the -** main database file. +** is not a database file pathname pointer that SQLite passed into the xOpen +** VFS method, then the behavior of this routine is undefined and probably +** undesirable. ** ** See the [URI filename] documentation for additional information. */ SQLITE_API const char *sqlite3_uri_parameter(const char *zFilename, const char *zParam); SQLITE_API int sqlite3_uri_boolean(const char *zFile, const char *zParam, int bDefault); SQLITE_API sqlite3_int64 sqlite3_uri_int64(const char*, const char*, sqlite3_int64); -SQLITE_API const char *sqlite3_uri_key(const char *zFilename, int N); - -/* -** CAPI3REF: Translate filenames -** -** These routines are available to [VFS|custom VFS implementations] for -** translating filenames between the main database file, the journal file, -** and the WAL file. -** -** If F is the name of an sqlite database file, journal file, or WAL file -** passed by the SQLite core into the VFS, then sqlite3_filename_database(F) -** returns the name of the corresponding database file. -** -** If F is the name of an sqlite database file, journal file, or WAL file -** passed by the SQLite core into the VFS, or if F is a database filename -** obtained from [sqlite3_db_filename()], then sqlite3_filename_journal(F) -** returns the name of the corresponding rollback journal file. -** -** If F is the name of an sqlite database file, journal file, or WAL file -** that was passed by the SQLite core into the VFS, or if F is a database -** filename obtained from [sqlite3_db_filename()], then -** sqlite3_filename_wal(F) returns the name of the corresponding -** WAL file. -** -** In all of the above, if F is not the name of a database, journal or WAL -** filename passed into the VFS from the SQLite core and F is not the -** return value from [sqlite3_db_filename()], then the result is -** undefined and is likely a memory access violation. -*/ -SQLITE_API const char *sqlite3_filename_database(const char*); -SQLITE_API const char *sqlite3_filename_journal(const char*); -SQLITE_API const char *sqlite3_filename_wal(const char*); /* @@ -3934,12 +3818,12 @@ SQLITE_API int sqlite3_limit(sqlite3*, int id, int newVal); **
  • ** **
  • -** ^If the specific value bound to a [parameter | host parameter] in the +** ^If the specific value bound to [parameter | host parameter] in the ** WHERE clause might influence the choice of query plan for a statement, ** then the statement will be automatically recompiled, as if there had been -** a schema change, on the first [sqlite3_step()] call following any change +** a schema change, on the first [sqlite3_step()] call following any change ** to the [sqlite3_bind_text | bindings] of that [parameter]. -** ^The specific value of a WHERE-clause [parameter] might influence the +** ^The specific value of WHERE-clause [parameter] might influence the ** choice of query plan if the parameter is the left-hand side of a [LIKE] ** or [GLOB] operator or if the parameter is compared to an indexed column ** and the [SQLITE_ENABLE_STAT4] compile-time option is enabled. @@ -4448,7 +4332,7 @@ SQLITE_API const void *sqlite3_column_name16(sqlite3_stmt*, int N); ** ** ^If the Nth column returned by the statement is an expression or ** subquery and is not a column value, then all of these functions return -** NULL. ^These routines might also return NULL if a memory allocation error +** NULL. ^These routine might also return NULL if a memory allocation error ** occurs. ^Otherwise, they return the name of the attached database, table, ** or column that query result column was extracted from. ** @@ -4458,6 +4342,10 @@ SQLITE_API const void *sqlite3_column_name16(sqlite3_stmt*, int N); ** ^These APIs are only available if the library was compiled with the ** [SQLITE_ENABLE_COLUMN_METADATA] C-preprocessor symbol. ** +** If two or more threads call one or more of these routines against the same +** prepared statement and column at the same time then the results are +** undefined. +** ** If two or more threads call one or more ** [sqlite3_column_database_name | column metadata interfaces] ** for the same [prepared statement] and result column @@ -4594,7 +4482,7 @@ SQLITE_API int sqlite3_step(sqlite3_stmt*); ** ^The sqlite3_data_count(P) interface returns the number of columns in the ** current row of the result set of [prepared statement] P. ** ^If prepared statement P does not have results ready to return -** (via calls to the [sqlite3_column_int | sqlite3_column()] family of +** (via calls to the [sqlite3_column_int | sqlite3_column_*()] of ** interfaces) then sqlite3_data_count(P) returns 0. ** ^The sqlite3_data_count(P) routine also returns 0 if P is a NULL pointer. ** ^The sqlite3_data_count(P) routine returns 0 if the previous call to @@ -4918,6 +4806,8 @@ SQLITE_API int sqlite3_reset(sqlite3_stmt *pStmt); /* ** CAPI3REF: Create Or Redefine SQL Functions ** KEYWORDS: {function creation routines} +** KEYWORDS: {application-defined SQL function} +** KEYWORDS: {application-defined SQL functions} ** METHOD: sqlite3 ** ** ^These functions (collectively known as "function creation routines") @@ -4973,20 +4863,9 @@ SQLITE_API int sqlite3_reset(sqlite3_stmt *pStmt); ** ** ^The fourth parameter may also optionally include the [SQLITE_DIRECTONLY] ** flag, which if present prevents the function from being invoked from -** within VIEWs, TRIGGERs, CHECK constraints, generated column expressions, -** index expressions, or the WHERE clause of partial indexes. -** -** -** For best security, the [SQLITE_DIRECTONLY] flag is recommended for -** all application-defined SQL functions that do not need to be -** used inside of triggers, view, CHECK constraints, or other elements of -** the database schema. This flags is especially recommended for SQL -** functions that have side effects or reveal internal application state. -** Without this flag, an attacker might be able to modify the schema of -** a database file to include invocations of the function with parameters -** chosen by the attacker, which the application will then execute when -** the database file is opened and read. -** +** within VIEWs or TRIGGERs. For security reasons, the [SQLITE_DIRECTONLY] +** flag is recommended for any application-defined SQL function that has +** side-effects. ** ** ^(The fifth parameter is an arbitrary pointer. The implementation of the ** function can gain access to this pointer using [sqlite3_user_data()].)^ @@ -5105,53 +4984,18 @@ SQLITE_API int sqlite3_create_window_function( ** to [sqlite3_create_function()], [sqlite3_create_function16()], or ** [sqlite3_create_function_v2()]. ** -**
    -** [[SQLITE_DETERMINISTIC]]
    SQLITE_DETERMINISTIC
    -** The SQLITE_DETERMINISTIC flag means that the new function always gives -** the same output when the input parameters are the same. -** The [abs|abs() function] is deterministic, for example, but -** [randomblob|randomblob()] is not. Functions must -** be deterministic in order to be used in certain contexts such as -** with the WHERE clause of [partial indexes] or in [generated columns]. -** SQLite might also optimize deterministic functions by factoring them -** out of inner loops. -**
    -** -** [[SQLITE_DIRECTONLY]]
    SQLITE_DIRECTONLY
    +** The SQLITE_DETERMINISTIC flag means that the new function will always +** maps the same inputs into the same output. The abs() function is +** deterministic, for example, but randomblob() is not. +** ** The SQLITE_DIRECTONLY flag means that the function may only be invoked -** from top-level SQL, and cannot be used in VIEWs or TRIGGERs nor in -** schema structures such as [CHECK constraints], [DEFAULT clauses], -** [expression indexes], [partial indexes], or [generated columns]. -** The SQLITE_DIRECTONLY flags is a security feature which is recommended -** for all [application-defined SQL functions], and especially for functions -** that have side-effects or that could potentially leak sensitive -** information. -**
    +** from top-level SQL, and cannot be used in VIEWs or TRIGGERs. This is +** a security feature which is recommended for all +** [application-defined SQL functions] that have side-effects. This flag +** prevents an attacker from adding triggers and views to a schema then +** tricking a high-privilege application into causing unintended side-effects +** while performing ordinary queries. ** -** [[SQLITE_INNOCUOUS]]
    SQLITE_INNOCUOUS
    -** The SQLITE_INNOCUOUS flag means that the function is unlikely -** to cause problems even if misused. An innocuous function should have -** no side effects and should not depend on any values other than its -** input parameters. The [abs|abs() function] is an example of an -** innocuous function. -** The [load_extension() SQL function] is not innocuous because of its -** side effects. -**

    SQLITE_INNOCUOUS is similar to SQLITE_DETERMINISTIC, but is not -** exactly the same. The [random|random() function] is an example of a -** function that is innocuous but not deterministic. -**

    Some heightened security settings -** ([SQLITE_DBCONFIG_TRUSTED_SCHEMA] and [PRAGMA trusted_schema=OFF]) -** disable the use of SQL functions inside views and triggers and in -** schema structures such as [CHECK constraints], [DEFAULT clauses], -** [expression indexes], [partial indexes], and [generated columns] unless -** the function is tagged with SQLITE_INNOCUOUS. Most built-in functions -** are innocuous. Developers are advised to avoid using the -** SQLITE_INNOCUOUS flag for application-defined functions unless the -** function has been carefully audited and found to be free of potentially -** security-adverse side-effects and information-leaks. -**

    -** -** [[SQLITE_SUBTYPE]]
    SQLITE_SUBTYPE
    ** The SQLITE_SUBTYPE flag indicates to SQLite that a function may call ** [sqlite3_value_subtype()] to inspect the sub-types of its arguments. ** Specifying this flag makes no difference for scalar or aggregate user @@ -5159,13 +5003,10 @@ SQLITE_API int sqlite3_create_window_function( ** function, then any sub-types belonging to arguments passed to the window ** function may be discarded before the window function is called (i.e. ** sqlite3_value_subtype() will always return 0). -**
    -**
    */ #define SQLITE_DETERMINISTIC 0x000000800 #define SQLITE_DIRECTONLY 0x000080000 #define SQLITE_SUBTYPE 0x000100000 -#define SQLITE_INNOCUOUS 0x000200000 /* ** CAPI3REF: Deprecated Functions @@ -5224,8 +5065,8 @@ SQLITE_API SQLITE_DEPRECATED int sqlite3_memory_alarm(void(*)(void*,sqlite3_int6 ** ** These routines extract type, size, and content information from ** [protected sqlite3_value] objects. Protected sqlite3_value objects -** are used to pass parameter information into the functions that -** implement [application-defined SQL functions] and [virtual tables]. +** are used to pass parameter information into implementation of +** [application-defined SQL functions] and [virtual tables]. ** ** These routines work only with [protected sqlite3_value] objects. ** Any attempt to use these routines on an [unprotected sqlite3_value] @@ -5282,7 +5123,7 @@ SQLITE_API SQLITE_DEPRECATED int sqlite3_memory_alarm(void(*)(void*,sqlite3_int6 ** ^The sqlite3_value_frombind(X) interface returns non-zero if the ** value X originated from one of the [sqlite3_bind_int|sqlite3_bind()] ** interfaces. ^If X comes from an SQL literal value, or a table column, -** or an expression, then sqlite3_value_frombind(X) returns zero. +** and expression, then sqlite3_value_frombind(X) returns zero. ** ** Please pay particular attention to the fact that the pointer returned ** from [sqlite3_value_blob()], [sqlite3_value_text()], or @@ -5368,8 +5209,8 @@ SQLITE_API void sqlite3_value_free(sqlite3_value*); ** routine to allocate memory for storing their state. ** ** ^The first time the sqlite3_aggregate_context(C,N) routine is called -** for a particular aggregate function, SQLite allocates -** N bytes of memory, zeroes out that memory, and returns a pointer +** for a particular aggregate function, SQLite +** allocates N of memory, zeroes out that memory, and returns a pointer ** to the new memory. ^On second and subsequent calls to ** sqlite3_aggregate_context() for the same aggregate function instance, ** the same buffer is returned. Sqlite3_aggregate_context() is normally @@ -5386,7 +5227,7 @@ SQLITE_API void sqlite3_value_free(sqlite3_value*); ** ** ^(The amount of space allocated by sqlite3_aggregate_context(C,N) is ** determined by the N parameter on first successful call. Changing the -** value of N in any subsequents call to sqlite3_aggregate_context() within +** value of N in subsequent call to sqlite3_aggregate_context() within ** the same aggregate function instance will not resize the memory ** allocation.)^ Within the xFinal callback, it is customary to set ** N=0 in calls to sqlite3_aggregate_context(C,N) so that no @@ -5697,7 +5538,7 @@ SQLITE_API void sqlite3_result_subtype(sqlite3_context*,unsigned int); **
  • [SQLITE_UTF16_ALIGNED]. ** )^ ** ^The eTextRep argument determines the encoding of strings passed -** to the collating function callback, xCompare. +** to the collating function callback, xCallback. ** ^The [SQLITE_UTF16] and [SQLITE_UTF16_ALIGNED] values for eTextRep ** force strings to be UTF16 with native byte order. ** ^The [SQLITE_UTF16_ALIGNED] value for eTextRep forces strings to begin @@ -5706,19 +5547,18 @@ SQLITE_API void sqlite3_result_subtype(sqlite3_context*,unsigned int); ** ^The fourth argument, pArg, is an application data pointer that is passed ** through as the first argument to the collating function callback. ** -** ^The fifth argument, xCompare, is a pointer to the collating function. +** ^The fifth argument, xCallback, is a pointer to the collating function. ** ^Multiple collating functions can be registered using the same name but ** with different eTextRep parameters and SQLite will use whichever ** function requires the least amount of data transformation. -** ^If the xCompare argument is NULL then the collating function is +** ^If the xCallback argument is NULL then the collating function is ** deleted. ^When all collating functions having the same name are deleted, ** that collation is no longer usable. ** ** ^The collating function callback is invoked with a copy of the pArg ** application data pointer and with two strings in the encoding specified -** by the eTextRep argument. The two integer parameters to the collating -** function callback are the length of the two strings, in bytes. The collating -** function must return an integer that is negative, zero, or positive +** by the eTextRep argument. The collating function must return an +** integer that is negative, zero, or positive ** if the first string is less than, equal to, or greater than the second, ** respectively. A collating function must always return the same answer ** given the same inputs. If two or more collating functions are registered @@ -5735,7 +5575,7 @@ SQLITE_API void sqlite3_result_subtype(sqlite3_context*,unsigned int); ** ** ** If a collating function fails any of the above constraints and that -** collating function is registered and used, then the behavior of SQLite +** collating function is registered and used, then the behavior of SQLite ** is undefined. ** ** ^The sqlite3_create_collation_v2() works like sqlite3_create_collation() @@ -6062,31 +5902,16 @@ SQLITE_API sqlite3 *sqlite3_db_handle(sqlite3_stmt*); ** CAPI3REF: Return The Filename For A Database Connection ** METHOD: sqlite3 ** -** ^The sqlite3_db_filename(D,N) interface returns a pointer to the filename -** associated with database N of connection D. -** ^If there is no attached database N on the database +** ^The sqlite3_db_filename(D,N) interface returns a pointer to a filename +** associated with database N of connection D. ^The main database file +** has the name "main". If there is no attached database N on the database ** connection D, or if database N is a temporary or in-memory database, then ** this function will return either a NULL pointer or an empty string. ** -** ^The string value returned by this routine is owned and managed by -** the database connection. ^The value will be valid until the database N -** is [DETACH]-ed or until the database connection closes. -** ** ^The filename returned by this function is the output of the ** xFullPathname method of the [VFS]. ^In other words, the filename ** will be an absolute pathname, even if the filename used ** to open the database originally was a URI or relative pathname. -** -** If the filename pointer returned by this routine is not NULL, then it -** can be used as the filename input parameter to these routines: -**
      -**
    • [sqlite3_uri_parameter()] -**
    • [sqlite3_uri_boolean()] -**
    • [sqlite3_uri_int64()] -**
    • [sqlite3_filename_database()] -**
    • [sqlite3_filename_journal()] -**
    • [sqlite3_filename_wal()] -**
    */ SQLITE_API const char *sqlite3_db_filename(sqlite3 *db, const char *zDbName); @@ -6236,19 +6061,15 @@ SQLITE_API void *sqlite3_update_hook( ** ** ^(The cache sharing mode set by this interface effects all subsequent ** calls to [sqlite3_open()], [sqlite3_open_v2()], and [sqlite3_open16()]. -** Existing database connections continue to use the sharing mode +** Existing database connections continue use the sharing mode ** that was in effect at the time they were opened.)^ ** ** ^(This routine returns [SQLITE_OK] if shared cache was enabled or disabled ** successfully. An [error code] is returned otherwise.)^ ** -** ^Shared cache is disabled by default. It is recommended that it stay -** that way. In other words, do not use this routine. This interface -** continues to be provided for historical compatibility, but its use is -** discouraged. Any use of shared cache is discouraged. If shared cache -** must be used, it is recommended that shared cache only be enabled for -** individual database connections using the [sqlite3_open_v2()] interface -** with the [SQLITE_OPEN_SHAREDCACHE] flag. +** ^Shared cache is disabled by default. But this might change in +** future releases of SQLite. Applications that care about shared +** cache setting should set it explicitly. ** ** Note: This method is disabled on MacOS X 10.7 and iOS version 5.0 ** and will always return SQLITE_MISUSE. On those systems, @@ -6295,9 +6116,6 @@ SQLITE_API int sqlite3_db_release_memory(sqlite3*); /* ** CAPI3REF: Impose A Limit On Heap Size ** -** These interfaces impose limits on the amount of heap memory that will be -** by all database connections within a single process. -** ** ^The sqlite3_soft_heap_limit64() interface sets and/or queries the ** soft limit on the amount of heap memory that may be allocated by SQLite. ** ^SQLite strives to keep heap memory utilization below the soft heap @@ -6308,41 +6126,20 @@ SQLITE_API int sqlite3_db_release_memory(sqlite3*); ** an [SQLITE_NOMEM] error. In other words, the soft heap limit ** is advisory only. ** -** ^The sqlite3_hard_heap_limit64(N) interface sets a hard upper bound of -** N bytes on the amount of memory that will be allocated. ^The -** sqlite3_hard_heap_limit64(N) interface is similar to -** sqlite3_soft_heap_limit64(N) except that memory allocations will fail -** when the hard heap limit is reached. -** -** ^The return value from both sqlite3_soft_heap_limit64() and -** sqlite3_hard_heap_limit64() is the size of -** the heap limit prior to the call, or negative in the case of an +** ^The return value from sqlite3_soft_heap_limit64() is the size of +** the soft heap limit prior to the call, or negative in the case of an ** error. ^If the argument N is negative -** then no change is made to the heap limit. Hence, the current -** size of heap limits can be determined by invoking -** sqlite3_soft_heap_limit64(-1) or sqlite3_hard_heap_limit(-1). +** then no change is made to the soft heap limit. Hence, the current +** size of the soft heap limit can be determined by invoking +** sqlite3_soft_heap_limit64() with a negative argument. ** -** ^Setting the heap limits to zero disables the heap limiter mechanism. +** ^If the argument N is zero then the soft heap limit is disabled. ** -** ^The soft heap limit may not be greater than the hard heap limit. -** ^If the hard heap limit is enabled and if sqlite3_soft_heap_limit(N) -** is invoked with a value of N that is greater than the hard heap limit, -** the the soft heap limit is set to the value of the hard heap limit. -** ^The soft heap limit is automatically enabled whenever the hard heap -** limit is enabled. ^When sqlite3_hard_heap_limit64(N) is invoked and -** the soft heap limit is outside the range of 1..N, then the soft heap -** limit is set to N. ^Invoking sqlite3_soft_heap_limit64(0) when the -** hard heap limit is enabled makes the soft heap limit equal to the -** hard heap limit. -** -** The memory allocation limits can also be adjusted using -** [PRAGMA soft_heap_limit] and [PRAGMA hard_heap_limit]. -** -** ^(The heap limits are not enforced in the current implementation +** ^(The soft heap limit is not enforced in the current implementation ** if one or more of following conditions are true: ** **
      -**
    • The limit value is set to zero. +**
    • The soft heap limit is set to zero. **
    • Memory accounting is disabled using a combination of the ** [sqlite3_config]([SQLITE_CONFIG_MEMSTATUS],...) start-time option and ** the [SQLITE_DEFAULT_MEMSTATUS] compile-time option. @@ -6353,11 +6150,21 @@ SQLITE_API int sqlite3_db_release_memory(sqlite3*); ** from the heap. **
    )^ ** -** The circumstances under which SQLite will enforce the heap limits may +** Beginning with SQLite [version 3.7.3] ([dateof:3.7.3]), +** the soft heap limit is enforced +** regardless of whether or not the [SQLITE_ENABLE_MEMORY_MANAGEMENT] +** compile-time option is invoked. With [SQLITE_ENABLE_MEMORY_MANAGEMENT], +** the soft heap limit is enforced on every memory allocation. Without +** [SQLITE_ENABLE_MEMORY_MANAGEMENT], the soft heap limit is only enforced +** when memory is allocated by the page cache. Testing suggests that because +** the page cache is the predominate memory user in SQLite, most +** applications will achieve adequate soft heap limit enforcement without +** the use of [SQLITE_ENABLE_MEMORY_MANAGEMENT]. +** +** The circumstances under which SQLite will enforce the soft heap limit may ** changes in future releases of SQLite. */ SQLITE_API sqlite3_int64 sqlite3_soft_heap_limit64(sqlite3_int64 N); -SQLITE_API sqlite3_int64 sqlite3_hard_heap_limit64(sqlite3_int64 N); /* ** CAPI3REF: Deprecated Soft Heap Limit Interface @@ -6381,7 +6188,7 @@ SQLITE_API SQLITE_DEPRECATED void sqlite3_soft_heap_limit(int N); ** interface returns SQLITE_OK and fills in the non-NULL pointers in ** the final five arguments with appropriate values if the specified ** column exists. ^The sqlite3_table_column_metadata() interface returns -** SQLITE_ERROR if the specified column does not exist. +** SQLITE_ERROR and if the specified column does not exist. ** ^If the column-name parameter to sqlite3_table_column_metadata() is a ** NULL pointer, then this routine simply checks for the existence of the ** table and returns SQLITE_OK if the table exists and SQLITE_ERROR if it @@ -6523,7 +6330,7 @@ SQLITE_API int sqlite3_load_extension( ** to enable or disable only the C-API.)^ ** ** Security warning: It is recommended that extension loading -** be enabled using the [SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION] method +** be disabled using the [SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION] method ** rather than this interface, so the [load_extension()] SQL function ** remains disabled. This will prevent SQL injections from giving attackers ** access to extension loading capabilities. @@ -6610,7 +6417,7 @@ typedef struct sqlite3_module sqlite3_module; ** KEYWORDS: sqlite3_module {virtual table module} ** ** This structure, sometimes called a "virtual table module", -** defines the implementation of a [virtual table]. +** defines the implementation of a [virtual tables]. ** This structure consists mostly of methods for the module. ** ** ^A virtual table module is created by filling in a persistent @@ -6707,13 +6514,7 @@ struct sqlite3_module { ** the right-hand side of the corresponding aConstraint[] is evaluated ** and becomes the argvIndex-th entry in argv. ^(If aConstraintUsage[].omit ** is true, then the constraint is assumed to be fully handled by the -** virtual table and might not be checked again by the byte code.)^ ^(The -** aConstraintUsage[].omit flag is an optimization hint. When the omit flag -** is left in its default setting of false, the constraint will always be -** checked separately in byte code. If the omit flag is change to true, then -** the constraint may or may not be checked in byte code. In other words, -** when the omit flag is true there is no guarantee that the constraint will -** not be checked again using byte code.)^ +** virtual table and is not checked again by SQLite.)^ ** ** ^The idxNum and idxPtr values are recorded and passed into the ** [xFilter] method. @@ -6753,7 +6554,7 @@ struct sqlite3_module { ** If a virtual table extension is ** used with an SQLite version earlier than 3.8.2, the results of attempting ** to read or write the estimatedRows field are undefined (but are likely -** to include crashing the application). The estimatedRows field should +** to included crashing the application). The estimatedRows field should ** therefore only be used if [sqlite3_libversion_number()] returns a ** value greater than or equal to 3008002. Similarly, the idxFlags field ** was added for [version 3.9.0] ([dateof:3.9.0]). @@ -6805,7 +6606,7 @@ struct sqlite3_index_info { /* ** CAPI3REF: Virtual Table Constraint Operator Codes ** -** These macros define the allowed values for the +** These macros defined the allowed values for the ** [sqlite3_index_info].aConstraint[].op field. Each value represents ** an operator that is part of a constraint term in the wHERE clause of ** a query that uses a [virtual table]. @@ -7415,7 +7216,7 @@ SQLITE_API void sqlite3_mutex_leave(sqlite3_mutex*); ** The only difference is that the public sqlite3_XXX functions enumerated ** above silently ignore any invocations that pass a NULL pointer instead ** of a valid mutex handle. The implementations of the methods defined -** by this structure are not required to handle this case. The results +** by this structure are not required to handle this case, the results ** of passing a NULL pointer instead of a valid mutex handle are undefined ** (i.e. it is acceptable to provide an implementation that segfaults if ** it is passed a NULL pointer). @@ -7888,7 +7689,7 @@ SQLITE_API int sqlite3_status64( ** ** [[SQLITE_STATUS_PAGECACHE_SIZE]] ^(
    SQLITE_STATUS_PAGECACHE_SIZE
    **
    This parameter records the largest memory allocation request -** handed to the [pagecache memory allocator]. Only the value returned in the +** handed to [pagecache memory allocator]. Only the value returned in the ** *pHighwater parameter to [sqlite3_status()] is of interest. ** The value written into the *pCurrent parameter is undefined.
    )^ ** @@ -7964,7 +7765,7 @@ SQLITE_API int sqlite3_db_status(sqlite3*, int op, int *pCur, int *pHiwtr, int r ** checked out.)^ ** ** [[SQLITE_DBSTATUS_LOOKASIDE_HIT]] ^(
    SQLITE_DBSTATUS_LOOKASIDE_HIT
    -**
    This parameter returns the number of malloc attempts that were +**
    This parameter returns the number malloc attempts that were ** satisfied using lookaside memory. Only the high-water value is meaningful; ** the current value is always zero.)^ ** @@ -8046,7 +7847,7 @@ SQLITE_API int sqlite3_db_status(sqlite3*, int op, int *pCur, int *pHiwtr, int r ** cache overflowing. Transactions are more efficient if they are written ** to disk all at once. When pages spill mid-transaction, that introduces ** additional overhead. This parameter can be used help identify -** inefficiencies that can be resolved by increasing the cache size. +** inefficiencies that can be resolve by increasing the cache size. **
    ** ** [[SQLITE_DBSTATUS_DEFERRED_FKS]] ^(
    SQLITE_DBSTATUS_DEFERRED_FKS
    @@ -8135,7 +7936,7 @@ SQLITE_API int sqlite3_stmt_status(sqlite3_stmt*, int op,int resetFlg); ** ** [[SQLITE_STMTSTATUS_REPREPARE]]
    SQLITE_STMTSTATUS_REPREPARE
    **
    ^This is the number of times that the prepare statement has been -** automatically regenerated due to schema changes or changes to +** automatically regenerated due to schema changes or change to ** [bound parameters] that might affect the query plan. ** ** [[SQLITE_STMTSTATUS_RUN]]
    SQLITE_STMTSTATUS_RUN
    @@ -8306,7 +8107,7 @@ struct sqlite3_pcache_page { ** ** ^(SQLite will normally invoke xFetch() with a createFlag of 0 or 1. SQLite ** will only use a createFlag of 2 after a prior call with a createFlag of 1 -** failed.)^ In between the xFetch() calls, SQLite may +** failed.)^ In between the to xFetch() calls, SQLite may ** attempt to unpin one or more cache pages by spilling the content of ** pinned pages to disk and synching the operating system disk cache. ** @@ -8624,7 +8425,7 @@ SQLITE_API int sqlite3_backup_pagecount(sqlite3_backup *p); ** the first argument to register for a callback that will be invoked ** when the blocking connections current transaction is concluded. ^The ** callback is invoked from within the [sqlite3_step] or [sqlite3_close] -** call that concludes the blocking connection's transaction. +** call that concludes the blocking connections transaction. ** ** ^(If sqlite3_unlock_notify() is called in a multi-threaded application, ** there is a chance that the blocking connection will have already @@ -8662,7 +8463,7 @@ SQLITE_API int sqlite3_backup_pagecount(sqlite3_backup *p); ** an unlock-notify callback is a pointer to an array of void* pointers, ** and the second is the number of entries in the array. ** -** When a blocking connection's transaction is concluded, there may be +** When a blocking connections transaction is concluded, there may be ** more than one blocked connection that has registered for an unlock-notify ** callback. ^If two or more such blocked connections have specified the ** same callback function, then instead of invoking the callback function @@ -9010,20 +8811,14 @@ SQLITE_API int sqlite3_wal_checkpoint_v2( ** If this interface is invoked outside the context of an xConnect or ** xCreate virtual table method then the behavior is undefined. ** -** In the call sqlite3_vtab_config(D,C,...) the D parameter is the -** [database connection] in which the virtual table is being created and -** which is passed in as the first argument to the [xConnect] or [xCreate] -** method that is invoking sqlite3_vtab_config(). The C parameter is one -** of the [virtual table configuration options]. The presence and meaning -** of parameters after C depend on which [virtual table configuration option] -** is used. +** At present, there is only one option that may be configured using +** this function. (See [SQLITE_VTAB_CONSTRAINT_SUPPORT].) Further options +** may be added in the future. */ SQLITE_API int sqlite3_vtab_config(sqlite3*, int op, ...); /* ** CAPI3REF: Virtual Table Configuration Options -** KEYWORDS: {virtual table configuration options} -** KEYWORDS: {virtual table configuration option} ** ** These macros define the various options to the ** [sqlite3_vtab_config()] interface that [virtual table] implementations @@ -9031,7 +8826,7 @@ SQLITE_API int sqlite3_vtab_config(sqlite3*, int op, ...); ** **
    ** [[SQLITE_VTAB_CONSTRAINT_SUPPORT]] -**
    SQLITE_VTAB_CONSTRAINT_SUPPORT
    +**
    SQLITE_VTAB_CONSTRAINT_SUPPORT **
    Calls of the form ** [sqlite3_vtab_config](db,SQLITE_VTAB_CONSTRAINT_SUPPORT,X) are supported, ** where X is an integer. If X is zero, then the [virtual table] whose @@ -9060,31 +8855,9 @@ SQLITE_API int sqlite3_vtab_config(sqlite3*, int op, ...); ** return SQLITE_OK. Or, if this is not possible, it may return ** SQLITE_CONSTRAINT, in which case SQLite falls back to OR ABORT ** constraint handling. -**
    -** -** [[SQLITE_VTAB_DIRECTONLY]]
    SQLITE_VTAB_DIRECTONLY
    -**
    Calls of the form -** [sqlite3_vtab_config](db,SQLITE_VTAB_DIRECTONLY) from within the -** the [xConnect] or [xCreate] methods of a [virtual table] implmentation -** prohibits that virtual table from being used from within triggers and -** views. -**
    -** -** [[SQLITE_VTAB_INNOCUOUS]]
    SQLITE_VTAB_INNOCUOUS
    -**
    Calls of the form -** [sqlite3_vtab_config](db,SQLITE_VTAB_INNOCUOUS) from within the -** the [xConnect] or [xCreate] methods of a [virtual table] implmentation -** identify that virtual table as being safe to use from within triggers -** and views. Conceptually, the SQLITE_VTAB_INNOCUOUS tag means that the -** virtual table can do no serious harm even if it is controlled by a -** malicious hacker. Developers should avoid setting the SQLITE_VTAB_INNOCUOUS -** flag unless absolutely necessary. -**
    **
    */ #define SQLITE_VTAB_CONSTRAINT_SUPPORT 1 -#define SQLITE_VTAB_INNOCUOUS 2 -#define SQLITE_VTAB_DIRECTONLY 3 /* ** CAPI3REF: Determine The Virtual Table Conflict Policy @@ -9164,15 +8937,15 @@ SQLITE_API SQLITE_EXPERIMENTAL const char *sqlite3_vtab_collation(sqlite3_index_ ** **
    ** [[SQLITE_SCANSTAT_NLOOP]]
    SQLITE_SCANSTAT_NLOOP
    -**
    ^The [sqlite3_int64] variable pointed to by the V parameter will be +**
    ^The [sqlite3_int64] variable pointed to by the T parameter will be ** set to the total number of times that the X-th loop has run.
    ** ** [[SQLITE_SCANSTAT_NVISIT]]
    SQLITE_SCANSTAT_NVISIT
    -**
    ^The [sqlite3_int64] variable pointed to by the V parameter will be set +**
    ^The [sqlite3_int64] variable pointed to by the T parameter will be set ** to the total number of rows examined by all iterations of the X-th loop.
    ** ** [[SQLITE_SCANSTAT_EST]]
    SQLITE_SCANSTAT_EST
    -**
    ^The "double" variable pointed to by the V parameter will be set to the +**
    ^The "double" variable pointed to by the T parameter will be set to the ** query planner's estimate for the average number of rows output from each ** iteration of the X-th loop. If the query planner's estimates was accurate, ** then this value will approximate the quotient NVISIT/NLOOP and the @@ -9180,17 +8953,17 @@ SQLITE_API SQLITE_EXPERIMENTAL const char *sqlite3_vtab_collation(sqlite3_index_ ** be the NLOOP value for the current loop. ** ** [[SQLITE_SCANSTAT_NAME]]
    SQLITE_SCANSTAT_NAME
    -**
    ^The "const char *" variable pointed to by the V parameter will be set +**
    ^The "const char *" variable pointed to by the T parameter will be set ** to a zero-terminated UTF-8 string containing the name of the index or table ** used for the X-th loop. ** ** [[SQLITE_SCANSTAT_EXPLAIN]]
    SQLITE_SCANSTAT_EXPLAIN
    -**
    ^The "const char *" variable pointed to by the V parameter will be set +**
    ^The "const char *" variable pointed to by the T parameter will be set ** to a zero-terminated UTF-8 string containing the [EXPLAIN QUERY PLAN] ** description for the X-th loop. ** ** [[SQLITE_SCANSTAT_SELECTID]]
    SQLITE_SCANSTAT_SELECT
    -**
    ^The "int" variable pointed to by the V parameter will be set to the +**
    ^The "int" variable pointed to by the T parameter will be set to the ** "select-id" for the X-th loop. The select-id identifies which query or ** subquery the loop is part of. The main query has a select-id of zero. ** The select-id is the same value as is output in the first column @@ -10045,7 +9818,7 @@ SQLITE_API int sqlite3session_attach( ** The second argument (xFilter) is the "filter callback". For changes to rows ** in tables that are not attached to the Session object, the filter is called ** to determine whether changes to the table's rows should be tracked or not. -** If xFilter returns 0, changes are not tracked. Note that once a table is +** If xFilter returns 0, changes is not tracked. Note that once a table is ** attached, xFilter will not be called again. */ SQLITE_API void sqlite3session_table_filter( @@ -10219,7 +9992,7 @@ SQLITE_API int sqlite3session_changeset( ** It an error if database zFrom does not exist or does not contain the ** required compatible table. ** -** If the operation is successful, SQLITE_OK is returned. Otherwise, an SQLite +** If the operation successful, SQLITE_OK is returned. Otherwise, an SQLite ** error code. In this case, if argument pzErrMsg is not NULL, *pzErrMsg ** may be set to point to a buffer containing an English language error ** message. It is the responsibility of the caller to free this buffer using @@ -10356,7 +10129,7 @@ SQLITE_API int sqlite3changeset_start_v2( ** CAPI3REF: Advance A Changeset Iterator ** METHOD: sqlite3_changeset_iter ** -** This function may only be used with iterators created by the function +** This function may only be used with iterators created by function ** [sqlite3changeset_start()]. If it is called on an iterator passed to ** a conflict-handler callback by [sqlite3changeset_apply()], SQLITE_MISUSE ** is returned and the call has no effect. @@ -10772,8 +10545,8 @@ SQLITE_API int sqlite3changegroup_new(sqlite3_changegroup **pp); ** case, this function fails with SQLITE_SCHEMA. If the input changeset ** appears to be corrupt and the corruption is detected, SQLITE_CORRUPT is ** returned. Or, if an out-of-memory condition occurs during processing, this -** function returns SQLITE_NOMEM. In all cases, if an error occurs the state -** of the final contents of the changegroup is undefined. +** function returns SQLITE_NOMEM. In all cases, if an error occurs the +** final contents of the changegroup is undefined. ** ** If no error occurs, SQLITE_OK is returned. */ @@ -10948,7 +10721,7 @@ SQLITE_API void sqlite3changegroup_delete(sqlite3_changegroup*); ** ** It is safe to execute SQL statements, including those that write to the ** table that the callback related to, from within the xConflict callback. -** This can be used to further customize the application's conflict +** This can be used to further customize the applications conflict ** resolution strategy. ** ** All changes made by these functions are enclosed in a savepoint transaction. @@ -11258,7 +11031,7 @@ SQLITE_API int sqlite3rebaser_configure( ** ** Argument pIn must point to a buffer containing a changeset nIn bytes ** in size. This function allocates and populates a buffer with a copy -** of the changeset rebased according to the configuration of the +** of the changeset rebased rebased according to the configuration of the ** rebaser object passed as the first argument. If successful, (*ppOut) ** is set to point to the new buffer containing the rebased changeset and ** (*pnOut) to its size in bytes and SQLITE_OK returned. It is the @@ -11666,7 +11439,7 @@ struct Fts5PhraseIter { ** ** xSetAuxdata(pFts5, pAux, xDelete) ** -** Save the pointer passed as the second argument as the extension function's +** Save the pointer passed as the second argument as the extension functions ** "auxiliary data". The pointer may then be retrieved by the current or any ** future invocation of the same fts5 extension function made as part of ** the same MATCH query using the xGetAuxdata() API. @@ -11908,8 +11681,8 @@ struct Fts5ExtensionApi { ** ** There are several ways to approach this in FTS5: ** -**
    1. By mapping all synonyms to a single token. In this case, using -** the above example, this means that the tokenizer returns the +**
      1. By mapping all synonyms to a single token. In this case, the +** In the above example, this means that the tokenizer returns the ** same token for inputs "first" and "1st". Say that token is in ** fact "first", so that when the user inserts the document "I won ** 1st place" entries are added to the index for tokens "i", "won", diff --git a/contrib/sqlite3/sqlite3ext.h b/contrib/sqlite3/sqlite3ext.h index b5258e0da004..416ac94231a3 100644 --- a/contrib/sqlite3/sqlite3ext.h +++ b/contrib/sqlite3/sqlite3ext.h @@ -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) diff --git a/contrib/sqlite3/tea/configure b/contrib/sqlite3/tea/configure index 78ad8bbfbc53..761aad3eee2e 100755 --- a/contrib/sqlite3/tea/configure +++ b/contrib/sqlite3/tea/configure @@ -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\\" diff --git a/contrib/sqlite3/tea/configure.ac b/contrib/sqlite3/tea/configure.ac index f6bea0f87a2b..5d75c72d73c9 100644 --- a/contrib/sqlite3/tea/configure.ac +++ b/contrib/sqlite3/tea/configure.ac @@ -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. diff --git a/contrib/sqlite3/tea/generic/tclsqlite3.c b/contrib/sqlite3/tea/generic/tclsqlite3.c index 20fc24564722..524b897eaf2c 100644 --- a/contrib/sqlite3/tea/generic/tclsqlite3.c +++ b/contrib/sqlite3/tea/generic/tclsqlite3.c @@ -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; diff --git a/contrib/sqlite3/tea/win/makefile.vc b/contrib/sqlite3/tea/win/makefile.vc index 88b66f173cb3..a5e462770721 100644 --- a/contrib/sqlite3/tea/win/makefile.vc +++ b/contrib/sqlite3/tea/win/makefile.vc @@ -153,7 +153,7 @@ Please `cd` to its location first. # #------------------------------------------------------------------------- -PROJECT = tclsqlite3 +PROJECT = sqlite3 !include "rules.vc" # nmakehelp -V 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__ \ diff --git a/contrib/xz/src/common/tuklib_physmem.c b/contrib/xz/src/common/tuklib_physmem.c index 01f6d1779510..4053ad006a64 100644 --- a/contrib/xz/src/common/tuklib_physmem.c +++ b/contrib/xz/src/common/tuklib_physmem.c @@ -45,7 +45,6 @@ # include #elif defined(TUKLIB_PHYSMEM_SYSCONF) -# include # include #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] = { diff --git a/contrib/xz/src/xz/hardware.c b/contrib/xz/src/xz/hardware.c index ff32f6d30148..e746cf91a76f 100644 --- a/contrib/xz/src/xz/hardware.c +++ b/contrib/xz/src/xz/hardware.c @@ -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; diff --git a/contrib/xz/src/xz/xz.1 b/contrib/xz/src/xz/xz.1 index 9dffdc6f82be..a4aaa0027ecb 100644 --- a/contrib/xz/src/xz/xz.1 +++ b/contrib/xz/src/xz/xz.1 @@ -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 diff --git a/gnu/lib/csu/Makefile b/gnu/lib/csu/Makefile deleted file mode 100644 index b2aff8e6fba0..000000000000 --- a/gnu/lib/csu/Makefile +++ /dev/null @@ -1,74 +0,0 @@ -# $FreeBSD$ - -.include -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 diff --git a/gnu/lib/csu/Makefile.depend b/gnu/lib/csu/Makefile.depend deleted file mode 100644 index 18be76b0cb6f..000000000000 --- a/gnu/lib/csu/Makefile.depend +++ /dev/null @@ -1,13 +0,0 @@ -# $FreeBSD$ -# Autogenerated - do NOT edit! - -DIRDEPS = \ - include \ - include/xlocale \ - - -.include - -.if ${DEP_RELDIR} == ${_DEP_RELDIR} -# local dependencies - needed for -jN in clean tree -.endif diff --git a/include/stdio.h b/include/stdio.h index 279160912ba9..e392bd5eb3e2 100644 --- a/include/stdio.h +++ b/include/stdio.h @@ -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, diff --git a/lib/libc/Makefile b/lib/libc/Makefile index ea3879ece592..518058b1cd6c 100644 --- a/lib/libc/Makefile +++ b/lib/libc/Makefile @@ -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 diff --git a/lib/libc/net/rcmd.c b/lib/libc/net/rcmd.c index 3cb475a6bece..e8b4ffd356c4 100644 --- a/lib/libc/net/rcmd.c +++ b/lib/libc/net/rcmd.c @@ -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; diff --git a/lib/libc/riscv/gen/_set_tp.c b/lib/libc/riscv/gen/_set_tp.c index a880465253a4..49295e26857c 100644 --- a/lib/libc/riscv/gen/_set_tp.c +++ b/lib/libc/riscv/gen/_set_tp.c @@ -38,13 +38,14 @@ __FBSDID("$FreeBSD$"); #include #include -#include - #include +/* 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)); } diff --git a/lib/libc/rpc/rpcb_st_xdr.c b/lib/libc/rpc/rpcb_st_xdr.c index 2a102a5786be..5b0462715aec 100644 --- a/lib/libc/rpc/rpcb_st_xdr.c +++ b/lib/libc/rpc/rpcb_st_xdr.c @@ -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); diff --git a/lib/libc/stdio/Symbol.map b/lib/libc/stdio/Symbol.map index a17830d9cebf..4926b6f35729 100644 --- a/lib/libc/stdio/Symbol.map +++ b/lib/libc/stdio/Symbol.map @@ -173,6 +173,7 @@ FBSD_1.5 { FBSD_1.6 { fflush_unlocked; + fputc_unlocked; fputs_unlocked; fread_unlocked; fwrite_unlocked; diff --git a/lib/libc/stdio/fputc.c b/lib/libc/stdio/fputc.c index 7a48a93a0071..a2d2d14655bc 100644 --- a/lib/libc/stdio/fputc.c +++ b/lib/libc/stdio/fputc.c @@ -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); } diff --git a/lib/libc/sys/open.2 b/lib/libc/sys/open.2 index 95996230558e..59397d76be70 100644 --- a/lib/libc/sys/open.2 +++ b/lib/libc/sys/open.2 @@ -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 diff --git a/lib/libc/tests/c063/Makefile b/lib/libc/tests/c063/Makefile index 05da6ea212a9..3be612dcaa42 100644 --- a/lib/libc/tests/c063/Makefile +++ b/lib/libc/tests/c063/Makefile @@ -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 diff --git a/lib/libc/xdr/xdr_array.c b/lib/libc/xdr/xdr_array.c index f081c8644872..591c8b816f75 100644 --- a/lib/libc/xdr/xdr_array.c +++ b/lib/libc/xdr/xdr_array.c @@ -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. diff --git a/lib/libc/xdr/xdr_reference.c b/lib/libc/xdr/xdr_reference.c index 76fc115dd30c..d18670f28ea6 100644 --- a/lib/libc/xdr/xdr_reference.c +++ b/lib/libc/xdr/xdr_reference.c @@ -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. diff --git a/lib/libfetch/fetch.c b/lib/libfetch/fetch.c index 9eec0730fa7d..82a3c5e451a9 100644 --- a/lib/libfetch/fetch.c +++ b/lib/libfetch/fetch.c @@ -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; } diff --git a/lib/libkvm/Makefile b/lib/libkvm/Makefile index 11c095a2255d..cd4872bd5b03 100644 --- a/lib/libkvm/Makefile +++ b/lib/libkvm/Makefile @@ -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 \ diff --git a/lib/libkvm/kvm.3 b/lib/libkvm/kvm.3 index 7fd5373eec7a..fbddcd475cc8 100644 --- a/lib/libkvm/kvm.3 +++ b/lib/libkvm/kvm.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 , diff --git a/lib/libkvm/kvm.c b/lib/libkvm/kvm.c index 2f35f26df1ca..c22f84ed64fa 100644 --- a/lib/libkvm/kvm.c +++ b/lib/libkvm/kvm.c @@ -46,6 +46,7 @@ __SCCSID("@(#)kvm.c 8.2 (Berkeley) 2/13/94"); #include #include #include +#include #include #include @@ -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)); +} diff --git a/lib/libkvm/kvm.h b/lib/libkvm/kvm.h index d568a27e6963..e6dd767c9193 100644 --- a/lib/libkvm/kvm.h +++ b/lib/libkvm/kvm.h @@ -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 *); diff --git a/usr.bin/elf2aout/elf2aout.1 b/lib/libkvm/kvm_kerndisp.3 similarity index 62% rename from usr.bin/elf2aout/elf2aout.1 rename to lib/libkvm/kvm_kerndisp.3 index 33c603629868..a1d53a4ecb2f 100644 --- a/usr.bin/elf2aout/elf2aout.1 +++ b/lib/libkvm/kvm_kerndisp.3 @@ -1,5 +1,5 @@ -.\" Copyright (c) 2008 Tom Rhodes -.\" All rights reserved. +.\" +.\" Copyright (c) 2020 Leandro Lupori .\" .\" 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 diff --git a/lib/libkvm/kvm_minidump_powerpc64.c b/lib/libkvm/kvm_minidump_powerpc64.c index 39c8d03fefa6..6e95b40aab2a 100644 --- a/lib/libkvm/kvm_minidump_powerpc64.c +++ b/lib/libkvm/kvm_minidump_powerpc64.c @@ -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); diff --git a/lib/libkvm/kvm_private.h b/lib/libkvm/kvm_private.h index 39a743c922fc..e71dde92a2f1 100644 --- a/lib/libkvm/kvm_private.h +++ b/lib/libkvm/kvm_private.h @@ -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) diff --git a/lib/libmemstat/memstat_uma.c b/lib/libmemstat/memstat_uma.c index caf7ed99d969..c063a33604de 100644 --- a/lib/libmemstat/memstat_uma.c +++ b/lib/libmemstat/memstat_uma.c @@ -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) diff --git a/lib/libutil/login.conf.5 b/lib/libutil/login.conf.5 index 1c3cfee02e74..47b0daf91c0d 100644 --- a/lib/libutil/login.conf.5 +++ b/lib/libutil/login.conf.5 @@ -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" diff --git a/lib/libutil/login_class.c b/lib/libutil/login_class.c index 532b2bed3059..fd0b232d0a43 100644 --- a/lib/libutil/login_class.c +++ b/lib/libutil/login_class.c @@ -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} diff --git a/lib/msun/powerpc/fenv.h b/lib/msun/powerpc/fenv.h index 3e2a11c48c50..22bc4e0f902f 100644 --- a/lib/msun/powerpc/fenv.h +++ b/lib/msun/powerpc/fenv.h @@ -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); diff --git a/libexec/rc/rc.d/auditd b/libexec/rc/rc.d/auditd index 8e078ec4c856..637214282de0 100755 --- a/libexec/rc/rc.d/auditd +++ b/libexec/rc/rc.d/auditd @@ -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 diff --git a/sbin/Makefile.sparc64 b/sbin/Makefile.sparc64 deleted file mode 100644 index 9a5bbe63bf17..000000000000 --- a/sbin/Makefile.sparc64 +++ /dev/null @@ -1,4 +0,0 @@ -# $FreeBSD$ - -SUBDIR += bsdlabel -SUBDIR += sunlabel diff --git a/sbin/fsck_msdosfs/boot.c b/sbin/fsck_msdosfs/boot.c index 86528ce83df9..887312ed7c41 100644 --- a/sbin/fsck_msdosfs/boot.c +++ b/sbin/fsck_msdosfs/boot.c @@ -28,7 +28,7 @@ #include #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; diff --git a/sbin/init/init.c b/sbin/init/init.c index 35291a674d73..58bd07a3c27b 100644 --- a/sbin/init/init.c +++ b/sbin/init/init.c @@ -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); diff --git a/sbin/sunlabel/Makefile b/sbin/sunlabel/Makefile deleted file mode 100644 index 05ae28c0da20..000000000000 --- a/sbin/sunlabel/Makefile +++ /dev/null @@ -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 - -test: ${PROG} - sh ${.CURDIR}/runtest.sh - -testx: ${PROG} - sh -x ${.CURDIR}/runtest.sh diff --git a/sbin/sunlabel/Makefile.depend b/sbin/sunlabel/Makefile.depend deleted file mode 100644 index a05551ae5136..000000000000 --- a/sbin/sunlabel/Makefile.depend +++ /dev/null @@ -1,16 +0,0 @@ -# $FreeBSD$ -# Autogenerated - do NOT edit! - -DIRDEPS = \ - include \ - include/xlocale \ - lib/${CSU_DIR} \ - lib/libc \ - lib/libgeom \ - - -.include - -.if ${DEP_RELDIR} == ${_DEP_RELDIR} -# local dependencies - needed for -jN in clean tree -.endif diff --git a/sbin/sunlabel/runtest.sh b/sbin/sunlabel/runtest.sh deleted file mode 100644 index 73833e0b7fee..000000000000 --- a/sbin/sunlabel/runtest.sh +++ /dev/null @@ -1,157 +0,0 @@ -#!/bin/sh -# $FreeBSD$ - -TMP=/tmp/$$. -set -e -MD=`mdconfig -a -t malloc -s 2m` -trap "exec 7 /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 diff --git a/sbin/sunlabel/sun_disklabel.h b/sbin/sunlabel/sun_disklabel.h deleted file mode 100644 index 942e1d3d11c2..000000000000 --- a/sbin/sunlabel/sun_disklabel.h +++ /dev/null @@ -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_ */ diff --git a/sbin/sunlabel/sunlabel.8 b/sbin/sunlabel/sunlabel.8 deleted file mode 100644 index fc6afa407658..000000000000 --- a/sbin/sunlabel/sunlabel.8 +++ /dev/null @@ -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. diff --git a/sbin/sunlabel/sunlabel.c b/sbin/sunlabel/sunlabel.c deleted file mode 100644 index c4f59b1170c6..000000000000 --- a/sbin/sunlabel/sunlabel.c +++ /dev/null @@ -1,1002 +0,0 @@ -/*- - * Copyright (c) 2003 Jake Burkholder. - * 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. - */ -/*- - * SPDX-License-Identifier: BSD-4-Clause - * - * Copyright (c) 1994, 1995 Gordon W. Ross - * Copyright (c) 1994 Theo de Raadt - * All rights reserved. - * Copyright (c) 1987, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Symmetric Computer Systems. - * - * 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. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * This product includes software developed by Theo de Raadt. - * 4. 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. - * - * from: $NetBSD: disksubr.c,v 1.13 2000/12/17 22:39:18 pk $ - */ - -#include -__FBSDID("$FreeBSD$"); - -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "sun_disklabel.h" - -#define _PATH_TMPFILE "/tmp/EdDk.XXXXXXXXXX" -#define _PATH_BOOT "/boot/boot1" - -static int bflag; -static int Bflag; -static int cflag; -static int eflag; -static int hflag; -static int nflag; -static int Rflag; -static int wflag; - -static off_t mediasize; -static uint32_t sectorsize; - -struct tags { - const char *name; - unsigned int id; -}; - -static int check_label(struct sun_disklabel *sl); -static void read_label(struct sun_disklabel *sl, const char *disk); -static void write_label(struct sun_disklabel *sl, const char *disk, - const char *bootpath); -static void edit_label(struct sun_disklabel *sl, const char *disk, - const char *bootpath); -static int parse_label(struct sun_disklabel *sl, const char *file); -static void print_label(struct sun_disklabel *sl, const char *disk, FILE *out); - -static int parse_size(struct sun_disklabel *sl, int part, char *size); -static int parse_offset(struct sun_disklabel *sl, int part, char *offset); - -static const char *flagname(unsigned int tag); -static const char *tagname(unsigned int tag); -static unsigned int parse_flag(struct sun_disklabel *sl, int part, - const char *flag); -static unsigned int parse_tag(struct sun_disklabel *sl, int part, - const char *tag); -static const char *make_h_number(uintmax_t u); - -static void usage(void); - -extern char *__progname; - -static struct tags knowntags[] = { - { "unassigned", VTOC_UNASSIGNED }, - { "boot", VTOC_BOOT }, - { "root", VTOC_ROOT }, - { "swap", VTOC_SWAP }, - { "usr", VTOC_USR }, - { "backup", VTOC_BACKUP }, - { "stand", VTOC_STAND }, - { "var", VTOC_VAR }, - { "home", VTOC_HOME }, - { "altsctr", VTOC_ALTSCTR }, - { "cache", VTOC_CACHE }, - { "VxVM_pub", VTOC_VXVM_PUB }, - { "VxVM_priv", VTOC_VXVM_PRIV }, -}; - -static struct tags knownflags[] = { - { "wm", 0 }, - { "wu", VTOC_UNMNT }, - { "rm", VTOC_RONLY }, - { "ru", VTOC_UNMNT | VTOC_RONLY }, -}; - -/* - * Disk label editor for sun disklabels. - */ -int -main(int ac, char **av) -{ - struct sun_disklabel sl; - const char *bootpath; - const char *proto; - const char *disk; - int ch; - - bootpath = _PATH_BOOT; - while ((ch = getopt(ac, av, "b:BcehnrRw")) != -1) - switch (ch) { - case 'b': - bflag = 1; - bootpath = optarg; - break; - case 'B': - Bflag = 1; - break; - case 'c': - cflag = 1; - break; - case 'e': - eflag = 1; - break; - case 'h': - hflag = 1; - break; - case 'n': - nflag = 1; - break; - case 'r': - fprintf(stderr, "Obsolete -r flag ignored\n"); - break; - case 'R': - Rflag = 1; - break; - case 'w': - wflag = 1; - break; - default: - usage(); - break; - } - if (bflag && !Bflag) - usage(); - if (nflag && !(Bflag || eflag || Rflag || wflag)) - usage(); - if (eflag && (Rflag || wflag)) - usage(); - if (eflag) - hflag = 0; - ac -= optind; - av += optind; - if (ac == 0) - usage(); - bzero(&sl, sizeof(sl)); - disk = av[0]; - if (wflag) { - if (ac != 2 || strcmp(av[1], "auto") != 0) - usage(); - read_label(&sl, disk); - bzero(sl.sl_part, sizeof(sl.sl_part)); - sl.sl_part[SUN_RAWPART].sdkp_cyloffset = 0; - sl.sl_part[SUN_RAWPART].sdkp_nsectors = sl.sl_ncylinders * - sl.sl_ntracks * sl.sl_nsectors; - write_label(&sl, disk, bootpath); - } else if (eflag) { - if (ac != 1) - usage(); - read_label(&sl, disk); - if (sl.sl_magic != SUN_DKMAGIC) - errx(1, "%s%s has no sun disklabel", _PATH_DEV, disk); - edit_label(&sl, disk, bootpath); - } else if (Rflag) { - if (ac != 2) - usage(); - proto = av[1]; - read_label(&sl, disk); - if (parse_label(&sl, proto) != 0) - errx(1, "%s: invalid label", proto); - write_label(&sl, disk, bootpath); - } else if (Bflag) { - read_label(&sl, disk); - if (sl.sl_magic != SUN_DKMAGIC) - errx(1, "%s%s has no sun disklabel", _PATH_DEV, disk); - write_label(&sl, disk, bootpath); - } else { - read_label(&sl, disk); - if (sl.sl_magic != SUN_DKMAGIC) - errx(1, "%s%s has no sun disklabel", _PATH_DEV, disk); - print_label(&sl, disk, stdout); - } - return (0); -} - -static int -check_label(struct sun_disklabel *sl) -{ - uint64_t nsectors; - uint64_t ostart; - uint64_t start; - uint64_t oend; - uint64_t end; - int havevtoc; - int warnonly; - int i; - int j; - - havevtoc = sl->sl_vtoc_sane == SUN_VTOC_SANE; - - nsectors = sl->sl_ncylinders * sl->sl_ntracks * sl->sl_nsectors; - if (sl->sl_part[SUN_RAWPART].sdkp_cyloffset != 0 || - sl->sl_part[SUN_RAWPART].sdkp_nsectors != nsectors) { - warnx("partition c is incorrect, must start at 0 and cover " - "whole disk"); - return (1); - } - if (havevtoc && sl->sl_vtoc_map[2].svtoc_tag != VTOC_BACKUP) { - warnx("partition c must have tag \"backup\""); - return (1); - } - for (i = 0; i < SUN_NPART; i++) { - if (i == 2 || sl->sl_part[i].sdkp_nsectors == 0) - continue; - start = (uint64_t)sl->sl_part[i].sdkp_cyloffset * - sl->sl_ntracks * sl->sl_nsectors; - end = start + sl->sl_part[i].sdkp_nsectors; - if (end > nsectors) { - warnx("partition %c extends past end of disk", - 'a' + i); - return (1); - } - if (havevtoc) { - if (sl->sl_vtoc_map[i].svtoc_tag == VTOC_BACKUP) { - warnx("only partition c is allowed to have " - "tag \"backup\""); - return (1); - } - } - for (j = 0; j < SUN_NPART; j++) { - /* - * Overlaps for unmountable partitions are - * non-fatal but will be warned anyway. - */ - warnonly = havevtoc && - ((sl->sl_vtoc_map[i].svtoc_flag & VTOC_UNMNT) != 0 || - (sl->sl_vtoc_map[j].svtoc_flag & VTOC_UNMNT) != 0); - - if (j == 2 || j == i || - sl->sl_part[j].sdkp_nsectors == 0) - continue; - ostart = (uint64_t)sl->sl_part[j].sdkp_cyloffset * - sl->sl_ntracks * sl->sl_nsectors; - oend = ostart + sl->sl_part[j].sdkp_nsectors; - if ((start <= ostart && end >= oend) || - (start > ostart && start < oend) || - (end > ostart && end < oend)) { - warnx("partition %c overlaps partition %c", - 'a' + i, 'a' + j); - if (!warnonly) - return (1); - } - } - } - return (0); -} - -static void -read_label(struct sun_disklabel *sl, const char *disk) -{ - char path[MAXPATHLEN]; - uint32_t fwsectors; - uint32_t fwheads; - char buf[SUN_SIZE]; - int fd, error; - - snprintf(path, sizeof(path), "%s%s", _PATH_DEV, disk); - if ((fd = open(path, O_RDONLY)) < 0) - err(1, "open %s", path); - if (read(fd, buf, sizeof(buf)) != sizeof(buf)) - err(1, "read"); - error = sunlabel_dec(buf, sl); - if (ioctl(fd, DIOCGMEDIASIZE, &mediasize) != 0) - if (error) - err(1, "%s: ioctl(DIOCGMEDIASIZE) failed", disk); - if (ioctl(fd, DIOCGSECTORSIZE, §orsize) != 0) { - if (error) - err(1, "%s: DIOCGSECTORSIZE failed", disk); - else - sectorsize = 512; - } - if (error) { - bzero(sl, sizeof(*sl)); - if (ioctl(fd, DIOCGFWSECTORS, &fwsectors) != 0) - fwsectors = 63; - if (ioctl(fd, DIOCGFWHEADS, &fwheads) != 0) { - if (mediasize <= 63 * 1024 * sectorsize) - fwheads = 1; - else if (mediasize <= 63 * 16 * 1024 * sectorsize) - fwheads = 16; - else - fwheads = 255; - } - sl->sl_rpm = 3600; - sl->sl_pcylinders = mediasize / (fwsectors * fwheads * - sectorsize); - sl->sl_sparespercyl = 0; - sl->sl_interleave = 1; - sl->sl_ncylinders = sl->sl_pcylinders - 2; - sl->sl_acylinders = 2; - sl->sl_nsectors = fwsectors; - sl->sl_ntracks = fwheads; - sl->sl_part[SUN_RAWPART].sdkp_cyloffset = 0; - sl->sl_part[SUN_RAWPART].sdkp_nsectors = sl->sl_ncylinders * - sl->sl_ntracks * sl->sl_nsectors; - if (mediasize > (off_t)4999L * 1024L * 1024L) { - sprintf(sl->sl_text, - "FreeBSD%jdG cyl %u alt %u hd %u sec %u", - (intmax_t)(mediasize + 512 * 1024 * 1024) / - (1024 * 1024 * 1024), - sl->sl_ncylinders, sl->sl_acylinders, - sl->sl_ntracks, sl->sl_nsectors); - } else { - sprintf(sl->sl_text, - "FreeBSD%jdM cyl %u alt %u hd %u sec %u", - (intmax_t)(mediasize + 512 * 1024) / (1024 * 1024), - sl->sl_ncylinders, sl->sl_acylinders, - sl->sl_ntracks, sl->sl_nsectors); - } - } - close(fd); -} - -static void -write_label(struct sun_disklabel *sl, const char *disk, const char *bootpath) -{ - char path[MAXPATHLEN]; - char boot[SUN_BOOTSIZE]; - char buf[SUN_SIZE]; - const char *errstr; - off_t off; - int bfd; - int fd; - int i; - struct gctl_req *grq; - - sl->sl_magic = SUN_DKMAGIC; - - if (check_label(sl) != 0) - errx(1, "invalid label"); - - bzero(buf, sizeof(buf)); - sunlabel_enc(buf, sl); - - if (nflag) { - print_label(sl, disk, stdout); - return; - } - if (Bflag) { - if ((bfd = open(bootpath, O_RDONLY)) < 0) - err(1, "open %s", bootpath); - i = read(bfd, boot, sizeof(boot)); - if (i < 0) - err(1, "read"); - else if (i != sizeof (boot)) - errx(1, "read wrong size boot code (%d)", i); - close(bfd); - } - snprintf(path, sizeof(path), "%s%s", _PATH_DEV, disk); - fd = open(path, O_RDWR); - if (fd < 0) { - grq = gctl_get_handle(); - gctl_ro_param(grq, "verb", -1, "write label"); - gctl_ro_param(grq, "class", -1, "SUN"); - gctl_ro_param(grq, "geom", -1, disk); - gctl_ro_param(grq, "label", sizeof buf, buf); - errstr = gctl_issue(grq); - if (errstr != NULL) - errx(1, "%s", errstr); - gctl_free(grq); - if (Bflag) { - grq = gctl_get_handle(); - gctl_ro_param(grq, "verb", -1, "write bootcode"); - gctl_ro_param(grq, "class", -1, "SUN"); - gctl_ro_param(grq, "geom", -1, disk); - gctl_ro_param(grq, "bootcode", sizeof boot, boot); - errstr = gctl_issue(grq); - if (errstr != NULL) - errx(1, "%s", errstr); - gctl_free(grq); - } - } else { - if (lseek(fd, 0, SEEK_SET) < 0) - err(1, "lseek"); - if (write(fd, buf, sizeof(buf)) != sizeof(buf)) - err (1, "write"); - if (Bflag) { - for (i = 0; i < SUN_NPART; i++) { - if (sl->sl_part[i].sdkp_nsectors == 0) - continue; - off = sl->sl_part[i].sdkp_cyloffset * - sl->sl_ntracks * sl->sl_nsectors * 512; - /* - * Ignore first SUN_SIZE bytes of boot code to - * avoid overwriting the label. - */ - if (lseek(fd, off + SUN_SIZE, SEEK_SET) < 0) - err(1, "lseek"); - if (write(fd, boot + SUN_SIZE, - sizeof(boot) - SUN_SIZE) != - sizeof(boot) - SUN_SIZE) - err(1, "write"); - } - } - close(fd); - } - exit(0); -} - -static void -edit_label(struct sun_disklabel *sl, const char *disk, const char *bootpath) -{ - char tmpfil[] = _PATH_TMPFILE; - const char *editor; - int status; - FILE *fp; - pid_t pid; - pid_t r; - int fd; - int c; - - if ((fd = mkstemp(tmpfil)) < 0) - err(1, "mkstemp"); - if ((fp = fdopen(fd, "w")) == NULL) - err(1, "fdopen"); - print_label(sl, disk, fp); - fflush(fp); - for (;;) { - if ((pid = fork()) < 0) - err(1, "fork"); - if (pid == 0) { - if ((editor = getenv("EDITOR")) == NULL) - editor = _PATH_VI; - execlp(editor, editor, tmpfil, (char *)NULL); - err(1, "execlp %s", editor); - } - status = 0; - while ((r = wait(&status)) > 0 && r != pid) - ; - if (WIFEXITED(status)) { - if (parse_label(sl, tmpfil) == 0) { - fclose(fp); - unlink(tmpfil); - write_label(sl, disk, bootpath); - return; - } - printf("re-edit the label? [y]: "); - fflush(stdout); - c = getchar(); - if (c != EOF && c != '\n') - while (getchar() != '\n') - ; - if (c == 'n') { - fclose(fp); - unlink(tmpfil); - return; - } - } - } - fclose(fp); - unlink(tmpfil); - return; -} - -static int -parse_label(struct sun_disklabel *sl, const char *file) -{ - char offset[32]; - char size[32]; - char flag[32]; - char tag[32]; - char buf[128]; - char text[128]; - char volname[SUN_VOLNAME_LEN + 1]; - struct sun_disklabel sl1; - char *bp; - const char *what; - uint8_t part; - FILE *fp; - int line; - int rv; - int wantvtoc; - unsigned alt, cyl, hd, nr, sec; - - line = wantvtoc = 0; - if ((fp = fopen(file, "r")) == NULL) - err(1, "fopen"); - sl1 = *sl; - bzero(&sl1.sl_part, sizeof(sl1.sl_part)); - while (fgets(buf, sizeof(buf), fp) != NULL) { - /* - * In order to recognize a partition entry, we search - * for lines starting with a single letter followed by - * a colon as their first non-white characters. We - * silently ignore any other lines, so any comment etc. - * lines in the label template will be ignored. - * - * XXX We should probably also recognize the geometry - * fields on top, and allow changing the geometry - * emulated by this disk. - */ - for (bp = buf; isspace(*bp); bp++) - ; - if (strncmp(bp, "text:", strlen("text:")) == 0) { - bp += strlen("text:"); - rv = sscanf(bp, - " %s cyl %u alt %u hd %u sec %u", - text, &cyl, &alt, &hd, &sec); - if (rv != 5) { - warnx("%s, line %d: text label does not " - "contain required fields", - file, line + 1); - fclose(fp); - return (1); - } - if (alt != 2) { - warnx("%s, line %d: # alt must be equal 2", - file, line + 1); - fclose(fp); - return (1); - } - if (cyl == 0 || cyl > USHRT_MAX) { - what = "cyl"; - nr = cyl; - unreasonable: - warnx("%s, line %d: # %s %d unreasonable", - file, line + 1, what, nr); - fclose(fp); - return (1); - } - if (hd == 0 || hd > USHRT_MAX) { - what = "hd"; - nr = hd; - goto unreasonable; - } - if (sec == 0 || sec > USHRT_MAX) { - what = "sec"; - nr = sec; - goto unreasonable; - } - if (mediasize == 0) - warnx("unit size unknown, no sector count " - "check could be done"); - else if ((uintmax_t)(cyl + alt) * sec * hd > - (uintmax_t)mediasize / sectorsize) { - warnx("%s, line %d: sector count %ju exceeds " - "unit size %ju", - file, line + 1, - (uintmax_t)(cyl + alt) * sec * hd, - (uintmax_t)mediasize / sectorsize); - fclose(fp); - return (1); - } - sl1.sl_pcylinders = cyl + alt; - sl1.sl_ncylinders = cyl; - sl1.sl_acylinders = alt; - sl1.sl_nsectors = sec; - sl1.sl_ntracks = hd; - memset(sl1.sl_text, 0, sizeof(sl1.sl_text)); - snprintf(sl1.sl_text, sizeof(sl1.sl_text), - "%s cyl %u alt %u hd %u sec %u", - text, cyl, alt, hd, sec); - continue; - } - if (strncmp(bp, "volume name:", strlen("volume name:")) == 0) { - wantvtoc = 1; /* Volume name requires VTOC. */ - bp += strlen("volume name:"); -#if SUN_VOLNAME_LEN != 8 -# error "scanf field width does not match SUN_VOLNAME_LEN" -#endif - /* - * We set the field length to one more than - * SUN_VOLNAME_LEN to allow detecting an - * overflow. - */ - memset(volname, 0, sizeof volname); - rv = sscanf(bp, " %9[^\n]", volname); - if (rv != 1) { - /* Clear the volume name. */ - memset(sl1.sl_vtoc_volname, 0, - SUN_VOLNAME_LEN); - } else { - memcpy(sl1.sl_vtoc_volname, volname, - SUN_VOLNAME_LEN); - if (volname[SUN_VOLNAME_LEN] != '\0') - warnx( -"%s, line %d: volume name longer than %d characters, truncating", - file, line + 1, SUN_VOLNAME_LEN); - } - continue; - } - if (strlen(bp) < 2 || bp[1] != ':') { - line++; - continue; - } - rv = sscanf(bp, "%c: %30s %30s %30s %30s", - &part, size, offset, tag, flag); - if (rv < 3) { - syntaxerr: - warnx("%s: syntax error on line %d", - file, line + 1); - fclose(fp); - return (1); - } - if (parse_size(&sl1, part - 'a', size) || - parse_offset(&sl1, part - 'a', offset)) - goto syntaxerr; - if (rv > 3) { - wantvtoc = 1; - if (rv == 5 && parse_flag(&sl1, part - 'a', flag)) - goto syntaxerr; - if (parse_tag(&sl1, part - 'a', tag)) - goto syntaxerr; - } - line++; - } - fclose(fp); - if (wantvtoc) { - sl1.sl_vtoc_sane = SUN_VTOC_SANE; - sl1.sl_vtoc_vers = SUN_VTOC_VERSION; - sl1.sl_vtoc_nparts = SUN_NPART; - } else { - sl1.sl_vtoc_sane = 0; - sl1.sl_vtoc_vers = 0; - sl1.sl_vtoc_nparts = 0; - bzero(&sl1.sl_vtoc_map, sizeof(sl1.sl_vtoc_map)); - } - *sl = sl1; - return (check_label(sl)); -} - -static int -parse_size(struct sun_disklabel *sl, int part, char *size) -{ - uintmax_t nsectors; - uintmax_t total; - uintmax_t n; - char *p; - int i; - - nsectors = 0; - n = strtoumax(size, &p, 10); - if (*p != '\0') { - if (strcmp(size, "*") == 0) { - total = sl->sl_ncylinders * sl->sl_ntracks * - sl->sl_nsectors; - for (i = 0; i < part; i++) { - if (i == 2) - continue; - nsectors += sl->sl_part[i].sdkp_nsectors; - } - n = total - nsectors; - } else if (p[1] == '\0' && (p[0] == 'C' || p[0] == 'c')) { - n = n * sl->sl_ntracks * sl->sl_nsectors; - } else if (p[1] == '\0' && (p[0] == 'K' || p[0] == 'k')) { - n = roundup((n * 1024) / 512, - sl->sl_ntracks * sl->sl_nsectors); - } else if (p[1] == '\0' && (p[0] == 'M' || p[0] == 'm')) { - n = roundup((n * 1024 * 1024) / 512, - sl->sl_ntracks * sl->sl_nsectors); - } else if (p[1] == '\0' && (p[0] == 'S' || p[0] == 's')) { - /* size in sectors, no action neded */ - } else if (p[1] == '\0' && (p[0] == 'G' || p[0] == 'g')) { - n = roundup((n * 1024 * 1024 * 1024) / 512, - sl->sl_ntracks * sl->sl_nsectors); - } else - return (-1); - } else if (cflag) { - n = n * sl->sl_ntracks * sl->sl_nsectors; - } - sl->sl_part[part].sdkp_nsectors = n; - return (0); -} - -static int -parse_offset(struct sun_disklabel *sl, int part, char *offset) -{ - uintmax_t nsectors; - uintmax_t n; - char *p; - int i; - - nsectors = 0; - n = strtoumax(offset, &p, 10); - if (*p != '\0') { - if (strcmp(offset, "*") == 0) { - for (i = 0; i < part; i++) { - if (i == 2) - continue; - nsectors += sl->sl_part[i].sdkp_nsectors; - } - n = nsectors / (sl->sl_nsectors * sl->sl_ntracks); - } else - return (-1); - } - sl->sl_part[part].sdkp_cyloffset = n; - return (0); -} - -static void -print_label(struct sun_disklabel *sl, const char *disk, FILE *out) -{ - int i, j; - int havevtoc; - uintmax_t secpercyl; - /* Long enough to hex-encode each character. */ - char volname[4 * SUN_VOLNAME_LEN + 1]; - - havevtoc = sl->sl_vtoc_sane == SUN_VTOC_SANE; - secpercyl = sl->sl_nsectors * sl->sl_ntracks; - - fprintf(out, -"# /dev/%s:\n" -"text: %s\n" -"bytes/sector: %d\n" -"sectors/cylinder: %ju\n", - disk, - sl->sl_text, - sectorsize, - secpercyl); - if (eflag) - fprintf(out, - "# max sectors/unit (including alt cylinders): %ju\n", - (uintmax_t)mediasize / sectorsize); - fprintf(out, -"sectors/unit: %ju\n", - secpercyl * sl->sl_ncylinders); - if (havevtoc && sl->sl_vtoc_volname[0] != '\0') { - for (i = j = 0; i < SUN_VOLNAME_LEN; i++) { - if (sl->sl_vtoc_volname[i] == '\0') - break; - if (isprint(sl->sl_vtoc_volname[i])) - volname[j++] = sl->sl_vtoc_volname[i]; - else - j += sprintf(volname + j, "\\x%02X", - sl->sl_vtoc_volname[i]); - } - volname[j] = '\0'; - fprintf(out, "volume name: %s\n", volname); - } - fprintf(out, -"\n" -"%d partitions:\n" -"#\n", - SUN_NPART); - if (!hflag) { - fprintf(out, "# Size is in %s.", cflag? "cylinders": "sectors"); - if (eflag) - fprintf(out, -" Use %%d%c, %%dK, %%dM or %%dG to specify in %s,\n" -"# kilobytes, megabytes or gigabytes respectively, or '*' to specify rest of\n" -"# disk.\n", - cflag? 's': 'c', - cflag? "sectors": "cylinders"); - else - putc('\n', out); - fprintf(out, "# Offset is in cylinders."); - if (eflag) - fprintf(out, -" Use '*' to calculate offsets automatically.\n" -"#\n"); - else - putc('\n', out); - } - if (havevtoc) - fprintf(out, -"# size offset tag flag\n" -"# ---------- ---------- ---------- ----\n" - ); - else - fprintf(out, -"# size offset\n" -"# ---------- ----------\n" - ); - - for (i = 0; i < SUN_NPART; i++) { - if (sl->sl_part[i].sdkp_nsectors == 0) - continue; - if (hflag) { - fprintf(out, " %c: %10s", - 'a' + i, - make_h_number((uintmax_t) - sl->sl_part[i].sdkp_nsectors * 512)); - fprintf(out, " %10s", - make_h_number((uintmax_t) - sl->sl_part[i].sdkp_cyloffset * 512 - * secpercyl)); - } else { - fprintf(out, " %c: %10ju %10u", - 'a' + i, - sl->sl_part[i].sdkp_nsectors / (cflag? secpercyl: 1), - sl->sl_part[i].sdkp_cyloffset); - } - if (havevtoc) - fprintf(out, " %11s %5s", - tagname(sl->sl_vtoc_map[i].svtoc_tag), - flagname(sl->sl_vtoc_map[i].svtoc_flag)); - putc('\n', out); - } -} - -static void -usage(void) -{ - - fprintf(stderr, "usage:" -"\t%s [-r] [-c | -h] disk\n" -"\t\t(to read label)\n" -"\t%s -B [-b boot1] [-n] disk\n" -"\t\t(to install boot program only)\n" -"\t%s -R [-B [-b boot1]] [-r] [-n] [-c] disk protofile\n" -"\t\t(to restore label)\n" -"\t%s -e [-B [-b boot1]] [-r] [-n] [-c] disk\n" -"\t\t(to edit label)\n" -"\t%s -w [-B [-b boot1]] [-r] [-n] disk type\n" -"\t\t(to write default label)\n", - __progname, - __progname, - __progname, - __progname, - __progname); - exit(1); -} - -/* - * Return VTOC tag and flag names for tag or flag ID, resp. - */ -static const char * -tagname(unsigned int tag) -{ - static char buf[32]; - size_t i; - struct tags *tp; - - for (i = 0, tp = knowntags; i < nitems(knowntags); i++, tp++) - if (tp->id == tag) - return (tp->name); - - sprintf(buf, "%u", tag); - - return (buf); -} - -static const char * -flagname(unsigned int flag) -{ - static char buf[32]; - size_t i; - struct tags *tp; - - for (i = 0, tp = knownflags; i < nitems(knownflags); i++, tp++) - if (tp->id == flag) - return (tp->name); - - sprintf(buf, "%u", flag); - - return (buf); -} - -static unsigned int -parse_tag(struct sun_disklabel *sl, int part, const char *tag) -{ - struct tags *tp; - char *endp; - size_t i; - unsigned long l; - - for (i = 0, tp = knowntags; i < nitems(knowntags); i++, tp++) - if (strcmp(tp->name, tag) == 0) { - sl->sl_vtoc_map[part].svtoc_tag = (uint16_t)tp->id; - return (0); - } - - l = strtoul(tag, &endp, 0); - if (*tag != '\0' && *endp == '\0') { - sl->sl_vtoc_map[part].svtoc_tag = (uint16_t)l; - return (0); - } - - return (-1); -} - -static unsigned int -parse_flag(struct sun_disklabel *sl, int part, const char *flag) -{ - struct tags *tp; - char *endp; - size_t i; - unsigned long l; - - for (i = 0, tp = knownflags; i < nitems(knownflags); i++, tp++) - if (strcmp(tp->name, flag) == 0) { - sl->sl_vtoc_map[part].svtoc_flag = (uint16_t)tp->id; - return (0); - } - - l = strtoul(flag, &endp, 0); - if (*flag != '\0' && *endp == '\0') { - sl->sl_vtoc_map[part].svtoc_flag = (uint16_t)l; - return (0); - } - - return (-1); -} - -/* - * Convert argument into `human readable' byte number form. - */ -static const char * -make_h_number(uintmax_t u) -{ - static char buf[32]; - double d; - - if (u == 0) { - strcpy(buf, "0B"); - } else if (u > 2000000000UL) { - d = (double)u / 1e9; - sprintf(buf, "%.1fG", d); - } else if (u > 2000000UL) { - d = (double)u / 1e6; - sprintf(buf, "%.1fM", d); - } else { - d = (double)u / 1e3; - sprintf(buf, "%.1fK", d); - } - - return (buf); -} diff --git a/sbin/sunlabel/sunlabel_enc.c b/sbin/sunlabel/sunlabel_enc.c deleted file mode 100644 index 4146442589e5..000000000000 --- a/sbin/sunlabel/sunlabel_enc.c +++ /dev/null @@ -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 -__FBSDID("$FreeBSD$"); - -#include -#include -#include -#ifdef _KERNEL -#include -#else -#include -#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); -} diff --git a/share/man/man4/cxgbe.4 b/share/man/man4/cxgbe.4 index 506966f632c3..14af7f9561ba 100644 --- a/share/man/man4/cxgbe.4 +++ b/share/man/man4/cxgbe.4 @@ -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. diff --git a/share/man/man5/make.conf.5 b/share/man/man5/make.conf.5 index f8c148e62ccb..78f8350b8392 100644 --- a/share/man/man5/make.conf.5 +++ b/share/man/man5/make.conf.5 @@ -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 diff --git a/share/man/man5/rc.conf.5 b/share/man/man5/rc.conf.5 index 50230e11ddb5..b38073191828 100644 --- a/share/man/man5/rc.conf.5 +++ b/share/man/man5/rc.conf.5 @@ -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 diff --git a/share/man/man5/src.conf.5 b/share/man/man5/src.conf.5 index 6b3bc1c37576..4086ac2f2ed0 100644 --- a/share/man/man5/src.conf.5 +++ b/share/man/man5/src.conf.5 @@ -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 diff --git a/share/man/man7/ports.7 b/share/man/man7/ports.7 index 7f23ff2e4d60..3a382f9e07e3 100644 --- a/share/man/man7/ports.7 +++ b/share/man/man7/ports.7 @@ -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 diff --git a/share/man/man7/security.7 b/share/man/man7/security.7 index 04d220a9d0aa..a09d9ef88cc1 100644 --- a/share/man/man7/security.7 +++ b/share/man/man7/security.7 @@ -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 diff --git a/share/man/man9/zone.9 b/share/man/man9/zone.9 index fff55eb0f035..756cf77f8a83 100644 --- a/share/man/man9/zone.9 +++ b/share/man/man9/zone.9 @@ -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 diff --git a/share/mk/bsd.linker.mk b/share/mk/bsd.linker.mk index 68419982882f..edeea6089de4 100644 --- a/share/mk/bsd.linker.mk +++ b/share/mk/bsd.linker.mk @@ -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 diff --git a/share/mk/src.libnames.mk b/share/mk/src.libnames.mk index e4ff7013d7de..927958711d85 100644 --- a/share/mk/src.libnames.mk +++ b/share/mk/src.libnames.mk @@ -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 diff --git a/share/mk/src.opts.mk b/share/mk/src.opts.mk index 51fc798a71f1..fc5a2a8ba4f9 100644 --- a/share/mk/src.opts.mk +++ b/share/mk/src.opts.mk @@ -205,7 +205,6 @@ __DEFAULT_NO_OPTIONS = \ GNU_GREP_COMPAT \ GPL_DTC \ HESIOD \ - HTTPD \ LIBSOFT \ LOADER_FIREWIRE \ LOADER_FORCE_LE \ diff --git a/stand/common/metadata.c b/stand/common/metadata.c index 427a867bda6c..e0a9518ab233 100644 --- a/stand/common/metadata.c +++ b/stand/common/metadata.c @@ -49,55 +49,6 @@ __FBSDID("$FreeBSD$"); #include "geliboot.h" #endif -#if defined(__sparc64__) -#include - -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) { diff --git a/stand/ficl/sparc64/sysdep.c b/stand/ficl/sparc64/sysdep.c deleted file mode 100644 index 43e7c3c91f1d..000000000000 --- a/stand/ficl/sparc64/sysdep.c +++ /dev/null @@ -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 -#include -#else -#include -#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); -** -** 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 */ diff --git a/stand/ficl/sparc64/sysdep.h b/stand/ficl/sparc64/sysdep.h deleted file mode 100644 index 0a6ca33363dd..000000000000 --- a/stand/ficl/sparc64/sysdep.h +++ /dev/null @@ -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 - -#include /* size_t, NULL */ -#include -#include - -#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); -** -** 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__*/ diff --git a/stand/i386/libi386/biosdisk.c b/stand/i386/libi386/biosdisk.c index d473f65e23f6..00d2de5de418 100644 --- a/stand/i386/libi386/biosdisk.c +++ b/stand/i386/libi386/biosdisk.c @@ -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; diff --git a/stand/i386/zfsboot/zfsboot.c b/stand/i386/zfsboot/zfsboot.c index 25c0c1d8407a..03edb08409c6 100644 --- a/stand/i386/zfsboot/zfsboot.c +++ b/stand/i386/zfsboot/zfsboot.c @@ -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 diff --git a/stand/libofw/libofw.h b/stand/libofw/libofw.h index 4a1e6a34bb2e..a4bfc27699a4 100644 --- a/stand/libofw/libofw.h +++ b/stand/libofw/libofw.h @@ -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); diff --git a/stand/libsa/sparc64/_setjmp.S b/stand/libsa/sparc64/_setjmp.S deleted file mode 100644 index 8df29e6ba750..000000000000 --- a/stand/libsa/sparc64/_setjmp.S +++ /dev/null @@ -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 -__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) diff --git a/stand/libsa/zfs/zfsimpl.c b/stand/libsa/zfs/zfsimpl.c index 0d16b63a575a..50ebe6293c33 100644 --- a/stand/libsa/zfs/zfsimpl.c +++ b/stand/libsa/zfs/zfsimpl.c @@ -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); } diff --git a/stand/loader.mk b/stand/loader.mk index 61c04f53d74f..1cef7d2535b1 100644 --- a/stand/loader.mk +++ b/stand/loader.mk @@ -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 diff --git a/stand/man/loader.8 b/stand/man/loader.8 index e242e41176fd..33101659db7b 100644 --- a/stand/man/loader.8 +++ b/stand/man/loader.8 @@ -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. diff --git a/stand/sparc64/Makefile b/stand/sparc64/Makefile deleted file mode 100644 index da9fba32e071..000000000000 --- a/stand/sparc64/Makefile +++ /dev/null @@ -1,10 +0,0 @@ -# $FreeBSD$ - -NO_OBJ=t - -.include - -SUBDIR.yes= boot1 loader -SUBDIR.${MK_LOADER_ZFS}+=zfsboot - -.include diff --git a/stand/sparc64/Makefile.inc b/stand/sparc64/Makefile.inc deleted file mode 100644 index 5a7b18e393c0..000000000000 --- a/stand/sparc64/Makefile.inc +++ /dev/null @@ -1,5 +0,0 @@ -# $FreeBSD$ - -LDFLAGS+= -nostdlib - -.include "../Makefile.inc" diff --git a/stand/sparc64/boot1/Makefile b/stand/sparc64/boot1/Makefile deleted file mode 100644 index 7dbd297152eb..000000000000 --- a/stand/sparc64/boot1/Makefile +++ /dev/null @@ -1,29 +0,0 @@ -# $FreeBSD$ - -.include - -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 diff --git a/stand/sparc64/boot1/_start.s b/stand/sparc64/boot1/_start.s deleted file mode 100644 index 30f8019cc863..000000000000 --- a/stand/sparc64/boot1/_start.s +++ /dev/null @@ -1,8 +0,0 @@ -/* $FreeBSD$ */ - - .text - .globl _start -_start: - call ofw_init - nop - sir diff --git a/stand/sparc64/boot1/boot1.c b/stand/sparc64/boot1/boot1.c deleted file mode 100644 index 3a84d234e69d..000000000000 --- a/stand/sparc64/boot1/boot1.c +++ /dev/null @@ -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 -__FBSDID("$FreeBSD$"); - -#include -#include - -#include -#include - -#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); -} diff --git a/stand/sparc64/loader/Makefile b/stand/sparc64/loader/Makefile deleted file mode 100644 index c85093c0745a..000000000000 --- a/stand/sparc64/loader/Makefile +++ /dev/null @@ -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 - -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 diff --git a/stand/sparc64/loader/help.sparc64 b/stand/sparc64/loader/help.sparc64 deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/stand/sparc64/loader/locore.S b/stand/sparc64/loader/locore.S deleted file mode 100644 index a73f5bfa7f98..000000000000 --- a/stand/sparc64/loader/locore.S +++ /dev/null @@ -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 -__FBSDID("$FreeBSD$"); - -#define LOCORE - -#include -#include -#include -#include - -#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 diff --git a/stand/sparc64/loader/main.c b/stand/sparc64/loader/main.c deleted file mode 100644 index c7e880caefee..000000000000 --- a/stand/sparc64/loader/main.c +++ /dev/null @@ -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 - * 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 -__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 -#include -#include -#include -#include -#include -#ifdef LOADER_ZFS_SUPPORT -#include -#include "libzfs.h" -#endif - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#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 diff --git a/stand/sparc64/loader/version b/stand/sparc64/loader/version deleted file mode 100644 index bef4091e58f6..000000000000 --- a/stand/sparc64/loader/version +++ /dev/null @@ -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. diff --git a/stand/sparc64/zfsboot/Makefile b/stand/sparc64/zfsboot/Makefile deleted file mode 100644 index 9e58c27eb067..000000000000 --- a/stand/sparc64/zfsboot/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -# $FreeBSD$ - -.PATH: ${.CURDIR}/../boot1 - -PROGNAME= zfsboot -CFLAGS+= -DZFSBOOT -FILES= zfsboot - -.include "${.CURDIR}/../boot1/Makefile" diff --git a/sys/Makefile b/sys/Makefile index 760c2073e5ee..688a00453b2d 100644 --- a/sys/Makefile +++ b/sys/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} diff --git a/sys/amd64/amd64/sys_machdep.c b/sys/amd64/amd64/sys_machdep.c index 28be748d3fdd..5a0145e76ccd 100644 --- a/sys/amd64/amd64/sys_machdep.c +++ b/sys/amd64/amd64/sys_machdep.c @@ -380,7 +380,7 @@ sysarch(struct thread *td, struct sysarch_args *uap) error = pmap_pkru_clear(PCPU_GET(curpmap), (vm_offset_t)a64pkru.addr, (vm_offset_t)a64pkru.addr + a64pkru.len); - vm_map_unlock(map); + vm_map_unlock_read(map); break; default: diff --git a/sys/amd64/include/counter.h b/sys/amd64/include/counter.h index cc0e74064a5f..e1b159482a6e 100644 --- a/sys/amd64/include/counter.h +++ b/sys/amd64/include/counter.h @@ -40,21 +40,21 @@ #ifdef IN_SUBR_COUNTER_C static inline uint64_t -counter_u64_read_one(uint64_t *p, int cpu) +counter_u64_read_one(counter_u64_t c, int cpu) { - return (*(uint64_t *)((char *)p + UMA_PCPU_ALLOC_SIZE * cpu)); + return (*zpcpu_get_cpu(c, cpu)); } static inline uint64_t -counter_u64_fetch_inline(uint64_t *p) +counter_u64_fetch_inline(uint64_t *c) { uint64_t r; - int i; + int cpu; r = 0; - CPU_FOREACH(i) - r += counter_u64_read_one((uint64_t *)p, i); + CPU_FOREACH(cpu) + r += counter_u64_read_one(c, cpu); return (r); } @@ -62,9 +62,10 @@ counter_u64_fetch_inline(uint64_t *p) static void counter_u64_zero_one_cpu(void *arg) { + counter_u64_t c; - *((uint64_t *)((char *)arg + UMA_PCPU_ALLOC_SIZE * - PCPU_GET(cpuid))) = 0; + c = arg; + *(zpcpu_get(c)) = 0; } static inline void diff --git a/sys/amd64/include/param.h b/sys/amd64/include/param.h index 86f7e08d9725..ac3df693e4d4 100644 --- a/sys/amd64/include/param.h +++ b/sys/amd64/include/param.h @@ -65,7 +65,7 @@ #define MACHINE_ARCH32 "i386" #endif -#if defined(SMP) || defined(KLD_MODULE) +#ifdef SMP #ifndef MAXCPU #define MAXCPU 256 #endif diff --git a/sys/amd64/linux/linux_dummy.c b/sys/amd64/linux/linux_dummy.c index cec90d18baae..5cf7f49bc5ae 100644 --- a/sys/amd64/linux/linux_dummy.c +++ b/sys/amd64/linux/linux_dummy.c @@ -53,25 +53,33 @@ UNIMPLEMENTED(getpmsg); UNIMPLEMENTED(nfsservctl); /* Added in Linux 2.2 removed in 3.1. */ UNIMPLEMENTED(putpmsg); UNIMPLEMENTED(query_module); /* Added in Linux 2.2 removed in 2.6. */ +UNIMPLEMENTED(tuxcall); UNIMPLEMENTED(security); UNIMPLEMENTED(set_thread_area); -UNIMPLEMENTED(tuxcall); UNIMPLEMENTED(uselib); UNIMPLEMENTED(vserver); -DUMMY(sendfile); DUMMY(setfsuid); DUMMY(setfsgid); DUMMY(sysfs); DUMMY(vhangup); +DUMMY(modify_ldt); DUMMY(pivot_root); DUMMY(adjtimex); DUMMY(swapoff); DUMMY(init_module); +DUMMY(ioperm); DUMMY(delete_module); DUMMY(quotactl); +DUMMY(readahead); +DUMMY(io_setup); +DUMMY(io_destroy); +DUMMY(io_getevents); +DUMMY(io_submit); +DUMMY(io_cancel); DUMMY(lookup_dcookie); DUMMY(remap_file_pages); +DUMMY(restart_syscall); DUMMY(semtimedop); DUMMY(mbind); DUMMY(get_mempolicy); diff --git a/sys/amd64/linux/linux_proto.h b/sys/amd64/linux/linux_proto.h index 938edfe276fb..6142e97641b0 100644 --- a/sys/amd64/linux/linux_proto.h +++ b/sys/amd64/linux/linux_proto.h @@ -551,6 +551,9 @@ struct linux_sched_rr_get_interval_args { struct linux_vhangup_args { register_t dummy; }; +struct linux_modify_ldt_args { + register_t dummy; +}; struct linux_pivot_root_args { register_t dummy; }; @@ -606,6 +609,9 @@ struct linux_setdomainname_args { struct linux_iopl_args { char level_l_[PADL_(l_uint)]; l_uint level; char level_r_[PADR_(l_uint)]; }; +struct linux_ioperm_args { + register_t dummy; +}; struct linux_init_module_args { register_t dummy; }; @@ -618,6 +624,9 @@ struct linux_quotactl_args { struct linux_gettid_args { register_t dummy; }; +struct linux_readahead_args { + register_t dummy; +}; struct linux_setxattr_args { register_t dummy; }; @@ -679,6 +688,21 @@ struct linux_sched_getaffinity_args { char len_l_[PADL_(l_uint)]; l_uint len; char len_r_[PADR_(l_uint)]; char user_mask_ptr_l_[PADL_(l_ulong *)]; l_ulong * user_mask_ptr; char user_mask_ptr_r_[PADR_(l_ulong *)]; }; +struct linux_io_setup_args { + register_t dummy; +}; +struct linux_io_destroy_args { + register_t dummy; +}; +struct linux_io_getevents_args { + register_t dummy; +}; +struct linux_io_submit_args { + register_t dummy; +}; +struct linux_io_cancel_args { + register_t dummy; +}; struct linux_lookup_dcookie_args { register_t dummy; }; @@ -696,6 +720,9 @@ struct linux_getdents64_args { struct linux_set_tid_address_args { char tidptr_l_[PADL_(l_int *)]; l_int * tidptr; char tidptr_r_[PADR_(l_int *)]; }; +struct linux_restart_syscall_args { + register_t dummy; +}; struct linux_semtimedop_args { register_t dummy; }; @@ -1360,6 +1387,7 @@ int linux_sched_get_priority_max(struct thread *, struct linux_sched_get_priorit int linux_sched_get_priority_min(struct thread *, struct linux_sched_get_priority_min_args *); int linux_sched_rr_get_interval(struct thread *, struct linux_sched_rr_get_interval_args *); int linux_vhangup(struct thread *, struct linux_vhangup_args *); +int linux_modify_ldt(struct thread *, struct linux_modify_ldt_args *); int linux_pivot_root(struct thread *, struct linux_pivot_root_args *); int linux_sysctl(struct thread *, struct linux_sysctl_args *); int linux_prctl(struct thread *, struct linux_prctl_args *); @@ -1373,10 +1401,12 @@ int linux_reboot(struct thread *, struct linux_reboot_args *); int linux_sethostname(struct thread *, struct linux_sethostname_args *); int linux_setdomainname(struct thread *, struct linux_setdomainname_args *); int linux_iopl(struct thread *, struct linux_iopl_args *); +int linux_ioperm(struct thread *, struct linux_ioperm_args *); int linux_init_module(struct thread *, struct linux_init_module_args *); int linux_delete_module(struct thread *, struct linux_delete_module_args *); int linux_quotactl(struct thread *, struct linux_quotactl_args *); int linux_gettid(struct thread *, struct linux_gettid_args *); +int linux_readahead(struct thread *, struct linux_readahead_args *); int linux_setxattr(struct thread *, struct linux_setxattr_args *); int linux_lsetxattr(struct thread *, struct linux_lsetxattr_args *); int linux_fsetxattr(struct thread *, struct linux_fsetxattr_args *); @@ -1394,11 +1424,17 @@ int linux_time(struct thread *, struct linux_time_args *); int linux_sys_futex(struct thread *, struct linux_sys_futex_args *); int linux_sched_setaffinity(struct thread *, struct linux_sched_setaffinity_args *); int linux_sched_getaffinity(struct thread *, struct linux_sched_getaffinity_args *); +int linux_io_setup(struct thread *, struct linux_io_setup_args *); +int linux_io_destroy(struct thread *, struct linux_io_destroy_args *); +int linux_io_getevents(struct thread *, struct linux_io_getevents_args *); +int linux_io_submit(struct thread *, struct linux_io_submit_args *); +int linux_io_cancel(struct thread *, struct linux_io_cancel_args *); int linux_lookup_dcookie(struct thread *, struct linux_lookup_dcookie_args *); int linux_epoll_create(struct thread *, struct linux_epoll_create_args *); int linux_remap_file_pages(struct thread *, struct linux_remap_file_pages_args *); int linux_getdents64(struct thread *, struct linux_getdents64_args *); int linux_set_tid_address(struct thread *, struct linux_set_tid_address_args *); +int linux_restart_syscall(struct thread *, struct linux_restart_syscall_args *); int linux_semtimedop(struct thread *, struct linux_semtimedop_args *); int linux_fadvise64(struct thread *, struct linux_fadvise64_args *); int linux_timer_create(struct thread *, struct linux_timer_create_args *); @@ -1681,6 +1717,7 @@ int linux_io_uring_register(struct thread *, struct linux_io_uring_register_args #define LINUX_SYS_AUE_linux_sched_get_priority_min AUE_SCHED_GET_PRIORITY_MIN #define LINUX_SYS_AUE_linux_sched_rr_get_interval AUE_SCHED_RR_GET_INTERVAL #define LINUX_SYS_AUE_linux_vhangup AUE_NULL +#define LINUX_SYS_AUE_linux_modify_ldt AUE_NULL #define LINUX_SYS_AUE_linux_pivot_root AUE_PIVOT_ROOT #define LINUX_SYS_AUE_linux_sysctl AUE_SYSCTL #define LINUX_SYS_AUE_linux_prctl AUE_PRCTL @@ -1694,10 +1731,12 @@ int linux_io_uring_register(struct thread *, struct linux_io_uring_register_args #define LINUX_SYS_AUE_linux_sethostname AUE_SYSCTL #define LINUX_SYS_AUE_linux_setdomainname AUE_SYSCTL #define LINUX_SYS_AUE_linux_iopl AUE_NULL +#define LINUX_SYS_AUE_linux_ioperm AUE_NULL #define LINUX_SYS_AUE_linux_init_module AUE_NULL #define LINUX_SYS_AUE_linux_delete_module AUE_NULL #define LINUX_SYS_AUE_linux_quotactl AUE_QUOTACTL #define LINUX_SYS_AUE_linux_gettid AUE_NULL +#define LINUX_SYS_AUE_linux_readahead AUE_NULL #define LINUX_SYS_AUE_linux_setxattr AUE_NULL #define LINUX_SYS_AUE_linux_lsetxattr AUE_NULL #define LINUX_SYS_AUE_linux_fsetxattr AUE_NULL @@ -1715,11 +1754,17 @@ int linux_io_uring_register(struct thread *, struct linux_io_uring_register_args #define LINUX_SYS_AUE_linux_sys_futex AUE_NULL #define LINUX_SYS_AUE_linux_sched_setaffinity AUE_NULL #define LINUX_SYS_AUE_linux_sched_getaffinity AUE_NULL +#define LINUX_SYS_AUE_linux_io_setup AUE_NULL +#define LINUX_SYS_AUE_linux_io_destroy AUE_NULL +#define LINUX_SYS_AUE_linux_io_getevents AUE_NULL +#define LINUX_SYS_AUE_linux_io_submit AUE_NULL +#define LINUX_SYS_AUE_linux_io_cancel AUE_NULL #define LINUX_SYS_AUE_linux_lookup_dcookie AUE_NULL #define LINUX_SYS_AUE_linux_epoll_create AUE_NULL #define LINUX_SYS_AUE_linux_remap_file_pages AUE_NULL #define LINUX_SYS_AUE_linux_getdents64 AUE_GETDIRENTRIES #define LINUX_SYS_AUE_linux_set_tid_address AUE_NULL +#define LINUX_SYS_AUE_linux_restart_syscall AUE_NULL #define LINUX_SYS_AUE_linux_semtimedop AUE_NULL #define LINUX_SYS_AUE_linux_fadvise64 AUE_NULL #define LINUX_SYS_AUE_linux_timer_create AUE_NULL diff --git a/sys/amd64/linux/linux_syscall.h b/sys/amd64/linux/linux_syscall.h index f6cc340df372..ffa183b83e4c 100644 --- a/sys/amd64/linux/linux_syscall.h +++ b/sys/amd64/linux/linux_syscall.h @@ -158,6 +158,7 @@ #define LINUX_SYS_mlockall 151 #define LINUX_SYS_munlockall 152 #define LINUX_SYS_linux_vhangup 153 +#define LINUX_SYS_linux_modify_ldt 154 #define LINUX_SYS_linux_pivot_root 155 #define LINUX_SYS_linux_sysctl 156 #define LINUX_SYS_linux_prctl 157 @@ -176,10 +177,12 @@ #define LINUX_SYS_linux_sethostname 170 #define LINUX_SYS_linux_setdomainname 171 #define LINUX_SYS_linux_iopl 172 +#define LINUX_SYS_linux_ioperm 173 #define LINUX_SYS_linux_init_module 175 #define LINUX_SYS_linux_delete_module 176 #define LINUX_SYS_linux_quotactl 179 #define LINUX_SYS_linux_gettid 186 +#define LINUX_SYS_linux_readahead 187 #define LINUX_SYS_linux_setxattr 188 #define LINUX_SYS_linux_lsetxattr 189 #define LINUX_SYS_linux_fsetxattr 190 @@ -197,11 +200,17 @@ #define LINUX_SYS_linux_sys_futex 202 #define LINUX_SYS_linux_sched_setaffinity 203 #define LINUX_SYS_linux_sched_getaffinity 204 +#define LINUX_SYS_linux_io_setup 206 +#define LINUX_SYS_linux_io_destroy 207 +#define LINUX_SYS_linux_io_getevents 208 +#define LINUX_SYS_linux_io_submit 209 +#define LINUX_SYS_linux_io_cancel 210 #define LINUX_SYS_linux_lookup_dcookie 212 #define LINUX_SYS_linux_epoll_create 213 #define LINUX_SYS_linux_remap_file_pages 216 #define LINUX_SYS_linux_getdents64 217 #define LINUX_SYS_linux_set_tid_address 218 +#define LINUX_SYS_linux_restart_syscall 219 #define LINUX_SYS_linux_semtimedop 220 #define LINUX_SYS_linux_fadvise64 221 #define LINUX_SYS_linux_timer_create 222 diff --git a/sys/amd64/linux/linux_syscalls.c b/sys/amd64/linux/linux_syscalls.c index bc58127c11f1..bb30d57196df 100644 --- a/sys/amd64/linux/linux_syscalls.c +++ b/sys/amd64/linux/linux_syscalls.c @@ -161,7 +161,7 @@ const char *linux_syscallnames[] = { "mlockall", /* 151 = mlockall */ "munlockall", /* 152 = munlockall */ "linux_vhangup", /* 153 = linux_vhangup */ - "#154", /* 154 = modify_ldt */ + "linux_modify_ldt", /* 154 = linux_modify_ldt */ "linux_pivot_root", /* 155 = linux_pivot_root */ "linux_sysctl", /* 156 = linux_sysctl */ "linux_prctl", /* 157 = linux_prctl */ @@ -180,7 +180,7 @@ const char *linux_syscallnames[] = { "linux_sethostname", /* 170 = linux_sethostname */ "linux_setdomainname", /* 171 = linux_setdomainname */ "linux_iopl", /* 172 = linux_iopl */ - "#173", /* 173 = ioperm */ + "linux_ioperm", /* 173 = linux_ioperm */ "#174", /* 174 = create_module */ "linux_init_module", /* 175 = linux_init_module */ "linux_delete_module", /* 176 = linux_delete_module */ @@ -194,7 +194,7 @@ const char *linux_syscallnames[] = { "#184", /* 184 = tuxcall */ "#185", /* 185 = security */ "linux_gettid", /* 186 = linux_gettid */ - "#187", /* 187 = linux_readahead */ + "linux_readahead", /* 187 = linux_readahead */ "linux_setxattr", /* 188 = linux_setxattr */ "linux_lsetxattr", /* 189 = linux_lsetxattr */ "linux_fsetxattr", /* 190 = linux_fsetxattr */ @@ -213,11 +213,11 @@ const char *linux_syscallnames[] = { "linux_sched_setaffinity", /* 203 = linux_sched_setaffinity */ "linux_sched_getaffinity", /* 204 = linux_sched_getaffinity */ "#205", /* 205 = set_thread_area */ - "#206", /* 206 = linux_io_setup */ - "#207", /* 207 = linux_io_destroy */ - "#208", /* 208 = linux_io_getevents */ - "#209", /* 209 = linux_io_submit */ - "#210", /* 210 = linux_io_cancel */ + "linux_io_setup", /* 206 = linux_io_setup */ + "linux_io_destroy", /* 207 = linux_io_destroy */ + "linux_io_getevents", /* 208 = linux_io_getevents */ + "linux_io_submit", /* 209 = linux_io_submit */ + "linux_io_cancel", /* 210 = linux_io_cancel */ "#211", /* 211 = get_thread_area */ "linux_lookup_dcookie", /* 212 = linux_lookup_dcookie */ "linux_epoll_create", /* 213 = linux_epoll_create */ @@ -226,7 +226,7 @@ const char *linux_syscallnames[] = { "linux_remap_file_pages", /* 216 = linux_remap_file_pages */ "linux_getdents64", /* 217 = linux_getdents64 */ "linux_set_tid_address", /* 218 = linux_set_tid_address */ - "#219", /* 219 = restart_syscall */ + "linux_restart_syscall", /* 219 = linux_restart_syscall */ "linux_semtimedop", /* 220 = linux_semtimedop */ "linux_fadvise64", /* 221 = linux_fadvise64 */ "linux_timer_create", /* 222 = linux_timer_create */ diff --git a/sys/amd64/linux/linux_sysent.c b/sys/amd64/linux/linux_sysent.c index 4d08d69363af..e6e04399097c 100644 --- a/sys/amd64/linux/linux_sysent.c +++ b/sys/amd64/linux/linux_sysent.c @@ -171,7 +171,7 @@ struct sysent linux_sysent[] = { { AS(mlockall_args), (sy_call_t *)sys_mlockall, AUE_MLOCKALL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 151 = mlockall */ { 0, (sy_call_t *)sys_munlockall, AUE_MUNLOCKALL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 152 = munlockall */ { 0, (sy_call_t *)linux_vhangup, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 153 = linux_vhangup */ - { 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0, 0, SY_THR_ABSENT }, /* 154 = modify_ldt */ + { 0, (sy_call_t *)linux_modify_ldt, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 154 = linux_modify_ldt */ { 0, (sy_call_t *)linux_pivot_root, AUE_PIVOT_ROOT, NULL, 0, 0, 0, SY_THR_STATIC }, /* 155 = linux_pivot_root */ { AS(linux_sysctl_args), (sy_call_t *)linux_sysctl, AUE_SYSCTL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 156 = linux_sysctl */ { AS(linux_prctl_args), (sy_call_t *)linux_prctl, AUE_PRCTL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 157 = linux_prctl */ @@ -190,7 +190,7 @@ struct sysent linux_sysent[] = { { AS(linux_sethostname_args), (sy_call_t *)linux_sethostname, AUE_SYSCTL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 170 = linux_sethostname */ { AS(linux_setdomainname_args), (sy_call_t *)linux_setdomainname, AUE_SYSCTL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 171 = linux_setdomainname */ { AS(linux_iopl_args), (sy_call_t *)linux_iopl, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 172 = linux_iopl */ - { 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0, 0, SY_THR_ABSENT }, /* 173 = ioperm */ + { 0, (sy_call_t *)linux_ioperm, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 173 = linux_ioperm */ { 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0, 0, SY_THR_ABSENT }, /* 174 = create_module */ { 0, (sy_call_t *)linux_init_module, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 175 = linux_init_module */ { 0, (sy_call_t *)linux_delete_module, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 176 = linux_delete_module */ @@ -204,7 +204,7 @@ struct sysent linux_sysent[] = { { 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0, 0, SY_THR_ABSENT }, /* 184 = tuxcall */ { 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0, 0, SY_THR_ABSENT }, /* 185 = security */ { 0, (sy_call_t *)linux_gettid, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 186 = linux_gettid */ - { 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0, 0, SY_THR_ABSENT }, /* 187 = linux_readahead */ + { 0, (sy_call_t *)linux_readahead, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 187 = linux_readahead */ { 0, (sy_call_t *)linux_setxattr, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 188 = linux_setxattr */ { 0, (sy_call_t *)linux_lsetxattr, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 189 = linux_lsetxattr */ { 0, (sy_call_t *)linux_fsetxattr, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 190 = linux_fsetxattr */ @@ -223,11 +223,11 @@ struct sysent linux_sysent[] = { { AS(linux_sched_setaffinity_args), (sy_call_t *)linux_sched_setaffinity, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 203 = linux_sched_setaffinity */ { AS(linux_sched_getaffinity_args), (sy_call_t *)linux_sched_getaffinity, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 204 = linux_sched_getaffinity */ { 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0, 0, SY_THR_ABSENT }, /* 205 = set_thread_area */ - { 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0, 0, SY_THR_ABSENT }, /* 206 = linux_io_setup */ - { 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0, 0, SY_THR_ABSENT }, /* 207 = linux_io_destroy */ - { 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0, 0, SY_THR_ABSENT }, /* 208 = linux_io_getevents */ - { 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0, 0, SY_THR_ABSENT }, /* 209 = linux_io_submit */ - { 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0, 0, SY_THR_ABSENT }, /* 210 = linux_io_cancel */ + { 0, (sy_call_t *)linux_io_setup, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 206 = linux_io_setup */ + { 0, (sy_call_t *)linux_io_destroy, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 207 = linux_io_destroy */ + { 0, (sy_call_t *)linux_io_getevents, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 208 = linux_io_getevents */ + { 0, (sy_call_t *)linux_io_submit, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 209 = linux_io_submit */ + { 0, (sy_call_t *)linux_io_cancel, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 210 = linux_io_cancel */ { 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0, 0, SY_THR_ABSENT }, /* 211 = get_thread_area */ { 0, (sy_call_t *)linux_lookup_dcookie, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 212 = linux_lookup_dcookie */ { AS(linux_epoll_create_args), (sy_call_t *)linux_epoll_create, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 213 = linux_epoll_create */ @@ -236,7 +236,7 @@ struct sysent linux_sysent[] = { { 0, (sy_call_t *)linux_remap_file_pages, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 216 = linux_remap_file_pages */ { AS(linux_getdents64_args), (sy_call_t *)linux_getdents64, AUE_GETDIRENTRIES, NULL, 0, 0, 0, SY_THR_STATIC }, /* 217 = linux_getdents64 */ { AS(linux_set_tid_address_args), (sy_call_t *)linux_set_tid_address, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 218 = linux_set_tid_address */ - { 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0, 0, SY_THR_ABSENT }, /* 219 = restart_syscall */ + { 0, (sy_call_t *)linux_restart_syscall, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 219 = linux_restart_syscall */ { 0, (sy_call_t *)linux_semtimedop, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 220 = linux_semtimedop */ { AS(linux_fadvise64_args), (sy_call_t *)linux_fadvise64, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 221 = linux_fadvise64 */ { AS(linux_timer_create_args), (sy_call_t *)linux_timer_create, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 222 = linux_timer_create */ diff --git a/sys/amd64/linux/linux_systrace_args.c b/sys/amd64/linux/linux_systrace_args.c index 5d7afd1f47db..93c3f440e149 100644 --- a/sys/amd64/linux/linux_systrace_args.c +++ b/sys/amd64/linux/linux_systrace_args.c @@ -1261,6 +1261,11 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args) *n_args = 0; break; } + /* linux_modify_ldt */ + case 154: { + *n_args = 0; + break; + } /* linux_pivot_root */ case 155: { *n_args = 0; @@ -1396,6 +1401,11 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args) *n_args = 1; break; } + /* linux_ioperm */ + case 173: { + *n_args = 0; + break; + } /* linux_init_module */ case 175: { *n_args = 0; @@ -1416,6 +1426,11 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args) *n_args = 0; break; } + /* linux_readahead */ + case 187: { + *n_args = 0; + break; + } /* linux_setxattr */ case 188: { *n_args = 0; @@ -1521,6 +1536,31 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args) *n_args = 3; break; } + /* linux_io_setup */ + case 206: { + *n_args = 0; + break; + } + /* linux_io_destroy */ + case 207: { + *n_args = 0; + break; + } + /* linux_io_getevents */ + case 208: { + *n_args = 0; + break; + } + /* linux_io_submit */ + case 209: { + *n_args = 0; + break; + } + /* linux_io_cancel */ + case 210: { + *n_args = 0; + break; + } /* linux_lookup_dcookie */ case 212: { *n_args = 0; @@ -1554,6 +1594,11 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args) *n_args = 1; break; } + /* linux_restart_syscall */ + case 219: { + *n_args = 0; + break; + } /* linux_semtimedop */ case 220: { *n_args = 0; @@ -4559,6 +4604,9 @@ systrace_entry_setargdesc(int sysnum, int ndx, char *desc, size_t descsz) /* linux_vhangup */ case 153: break; + /* linux_modify_ldt */ + case 154: + break; /* linux_pivot_root */ case 155: break; @@ -4762,6 +4810,9 @@ systrace_entry_setargdesc(int sysnum, int ndx, char *desc, size_t descsz) break; }; break; + /* linux_ioperm */ + case 173: + break; /* linux_init_module */ case 175: break; @@ -4774,6 +4825,9 @@ systrace_entry_setargdesc(int sysnum, int ndx, char *desc, size_t descsz) /* linux_gettid */ case 186: break; + /* linux_readahead */ + case 187: + break; /* linux_setxattr */ case 188: break; @@ -4890,6 +4944,21 @@ systrace_entry_setargdesc(int sysnum, int ndx, char *desc, size_t descsz) break; }; break; + /* linux_io_setup */ + case 206: + break; + /* linux_io_destroy */ + case 207: + break; + /* linux_io_getevents */ + case 208: + break; + /* linux_io_submit */ + case 209: + break; + /* linux_io_cancel */ + case 210: + break; /* linux_lookup_dcookie */ case 212: break; @@ -4932,6 +5001,9 @@ systrace_entry_setargdesc(int sysnum, int ndx, char *desc, size_t descsz) break; }; break; + /* linux_restart_syscall */ + case 219: + break; /* linux_semtimedop */ case 220: break; @@ -7163,6 +7235,8 @@ systrace_return_setargdesc(int sysnum, int ndx, char *desc, size_t descsz) case 152: /* linux_vhangup */ case 153: + /* linux_modify_ldt */ + case 154: /* linux_pivot_root */ case 155: /* linux_sysctl */ @@ -7241,6 +7315,8 @@ systrace_return_setargdesc(int sysnum, int ndx, char *desc, size_t descsz) if (ndx == 0 || ndx == 1) p = "int"; break; + /* linux_ioperm */ + case 173: /* linux_init_module */ case 175: /* linux_delete_module */ @@ -7249,6 +7325,8 @@ systrace_return_setargdesc(int sysnum, int ndx, char *desc, size_t descsz) case 179: /* linux_gettid */ case 186: + /* linux_readahead */ + case 187: /* linux_setxattr */ case 188: /* linux_lsetxattr */ @@ -7298,6 +7376,16 @@ systrace_return_setargdesc(int sysnum, int ndx, char *desc, size_t descsz) if (ndx == 0 || ndx == 1) p = "int"; break; + /* linux_io_setup */ + case 206: + /* linux_io_destroy */ + case 207: + /* linux_io_getevents */ + case 208: + /* linux_io_submit */ + case 209: + /* linux_io_cancel */ + case 210: /* linux_lookup_dcookie */ case 212: /* linux_epoll_create */ @@ -7317,6 +7405,8 @@ systrace_return_setargdesc(int sysnum, int ndx, char *desc, size_t descsz) if (ndx == 0 || ndx == 1) p = "int"; break; + /* linux_restart_syscall */ + case 219: /* linux_semtimedop */ case 220: /* linux_fadvise64 */ diff --git a/sys/amd64/linux/syscalls.master b/sys/amd64/linux/syscalls.master index ea8b973edb72..c3936a926da3 100644 --- a/sys/amd64/linux/syscalls.master +++ b/sys/amd64/linux/syscalls.master @@ -304,7 +304,7 @@ 151 AUE_MLOCKALL NOPROTO { int mlockall(int how); } 152 AUE_MUNLOCKALL NOPROTO { int munlockall(void); } 153 AUE_NULL STD { int linux_vhangup(void); } -154 AUE_NULL UNIMPL modify_ldt +154 AUE_NULL STD { int linux_modify_ldt(void); } 155 AUE_PIVOT_ROOT STD { int linux_pivot_root(void); } 156 AUE_SYSCTL STD { int linux_sysctl( \ struct l___sysctl_args *args); } @@ -332,7 +332,7 @@ 171 AUE_SYSCTL STD { int linux_setdomainname(char *name, \ l_int len); } 172 AUE_NULL STD { int linux_iopl(l_uint level); } -173 AUE_NULL UNIMPL ioperm +173 AUE_NULL STD { int linux_ioperm(void); } 174 AUE_NULL UNIMPL create_module 175 AUE_NULL STD { int linux_init_module(void); } 176 AUE_NULL STD { int linux_delete_module(void); } @@ -346,7 +346,7 @@ 184 AUE_NULL UNIMPL tuxcall 185 AUE_NULL UNIMPL security 186 AUE_NULL STD { int linux_gettid(void); } -187 AUE_NULL UNIMPL linux_readahead +187 AUE_NULL STD { int linux_readahead(void); } 188 AUE_NULL STD { int linux_setxattr(void); } 189 AUE_NULL STD { int linux_lsetxattr(void); } 190 AUE_NULL STD { int linux_fsetxattr(void); } @@ -368,11 +368,11 @@ 204 AUE_NULL STD { int linux_sched_getaffinity(l_pid_t pid, l_uint len, \ l_ulong *user_mask_ptr); } 205 AUE_NULL UNIMPL set_thread_area -206 AUE_NULL UNIMPL linux_io_setup -207 AUE_NULL UNIMPL linux_io_destroy -208 AUE_NULL UNIMPL linux_io_getevents -209 AUE_NULL UNIMPL linux_io_submit -210 AUE_NULL UNIMPL linux_io_cancel +206 AUE_NULL STD { int linux_io_setup(void); } +207 AUE_NULL STD { int linux_io_destroy(void); } +208 AUE_NULL STD { int linux_io_getevents(void); } +209 AUE_NULL STD { int linux_io_submit(void); } +210 AUE_NULL STD { int linux_io_cancel(void); } 211 AUE_NULL UNIMPL get_thread_area 212 AUE_NULL STD { int linux_lookup_dcookie(void); } 213 AUE_NULL STD { int linux_epoll_create(l_int size); } @@ -382,7 +382,7 @@ 217 AUE_GETDIRENTRIES STD { int linux_getdents64(l_uint fd, \ void *dirent, l_uint count); } 218 AUE_NULL STD { int linux_set_tid_address(l_int *tidptr); } -219 AUE_NULL UNIMPL restart_syscall +219 AUE_NULL STD { int linux_restart_syscall(void); } 220 AUE_NULL STD { int linux_semtimedop(void); } 221 AUE_NULL STD { int linux_fadvise64(l_int fd, l_loff_t offset, \ l_size_t len, l_int advice); } diff --git a/sys/amd64/linux32/linux32_dummy.c b/sys/amd64/linux32/linux32_dummy.c index bd1dbde1ed3d..95c81b26ee0a 100644 --- a/sys/amd64/linux32/linux32_dummy.c +++ b/sys/amd64/linux32/linux32_dummy.c @@ -72,7 +72,6 @@ DUMMY(delete_module); DUMMY(quotactl); DUMMY(bdflush); DUMMY(sysfs); -DUMMY(sendfile); DUMMY(setfsuid); DUMMY(setfsgid); DUMMY(pivot_root); diff --git a/sys/amd64/linux32/linux32_proto.h b/sys/amd64/linux32/linux32_proto.h index ed89d8dbc554..eec0898d03f6 100644 --- a/sys/amd64/linux32/linux32_proto.h +++ b/sys/amd64/linux32/linux32_proto.h @@ -606,7 +606,10 @@ struct linux_sigaltstack_args { char uoss_l_[PADL_(l_stack_t *)]; l_stack_t * uoss; char uoss_r_[PADR_(l_stack_t *)]; }; struct linux_sendfile_args { - register_t dummy; + char out_l_[PADL_(l_int)]; l_int out; char out_r_[PADR_(l_int)]; + char in_l_[PADL_(l_int)]; l_int in; char in_r_[PADR_(l_int)]; + char offset_l_[PADL_(l_long *)]; l_long * offset; char offset_r_[PADR_(l_long *)]; + char count_l_[PADL_(l_size_t)]; l_size_t count; char count_r_[PADR_(l_size_t)]; }; struct linux_vfork_args { register_t dummy; @@ -737,6 +740,12 @@ struct linux_tkill_args { char tid_l_[PADL_(int)]; int tid; char tid_r_[PADR_(int)]; char sig_l_[PADL_(int)]; int sig; char sig_r_[PADR_(int)]; }; +struct linux_sendfile64_args { + char out_l_[PADL_(l_int)]; l_int out; char out_r_[PADR_(l_int)]; + char in_l_[PADL_(l_int)]; l_int in; char in_r_[PADR_(l_int)]; + char offset_l_[PADL_(l_loff_t *)]; l_loff_t * offset; char offset_r_[PADR_(l_loff_t *)]; + char count_l_[PADL_(l_size_t)]; l_size_t count; char count_r_[PADR_(l_size_t)]; +}; struct linux_sys_futex_args { char uaddr_l_[PADL_(void *)]; void * uaddr; char uaddr_r_[PADR_(void *)]; char op_l_[PADL_(int)]; int op; char op_r_[PADR_(int)]; @@ -1698,6 +1707,7 @@ int linux_removexattr(struct thread *, struct linux_removexattr_args *); int linux_lremovexattr(struct thread *, struct linux_lremovexattr_args *); int linux_fremovexattr(struct thread *, struct linux_fremovexattr_args *); int linux_tkill(struct thread *, struct linux_tkill_args *); +int linux_sendfile64(struct thread *, struct linux_sendfile64_args *); int linux_sys_futex(struct thread *, struct linux_sys_futex_args *); int linux_sched_setaffinity(struct thread *, struct linux_sched_setaffinity_args *); int linux_sched_getaffinity(struct thread *, struct linux_sched_getaffinity_args *); @@ -2092,6 +2102,7 @@ int linux_io_uring_register(struct thread *, struct linux_io_uring_register_args #define LINUX32_SYS_AUE_linux_lremovexattr AUE_NULL #define LINUX32_SYS_AUE_linux_fremovexattr AUE_NULL #define LINUX32_SYS_AUE_linux_tkill AUE_NULL +#define LINUX32_SYS_AUE_linux_sendfile64 AUE_SENDFILE #define LINUX32_SYS_AUE_linux_sys_futex AUE_NULL #define LINUX32_SYS_AUE_linux_sched_setaffinity AUE_NULL #define LINUX32_SYS_AUE_linux_sched_getaffinity AUE_NULL diff --git a/sys/amd64/linux32/linux32_syscall.h b/sys/amd64/linux32/linux32_syscall.h index 5a49ace25301..e285a94c90fa 100644 --- a/sys/amd64/linux32/linux32_syscall.h +++ b/sys/amd64/linux32/linux32_syscall.h @@ -216,6 +216,7 @@ #define LINUX32_SYS_linux_lremovexattr 236 #define LINUX32_SYS_linux_fremovexattr 237 #define LINUX32_SYS_linux_tkill 238 +#define LINUX32_SYS_linux_sendfile64 239 #define LINUX32_SYS_linux_sys_futex 240 #define LINUX32_SYS_linux_sched_setaffinity 241 #define LINUX32_SYS_linux_sched_getaffinity 242 diff --git a/sys/amd64/linux32/linux32_syscalls.c b/sys/amd64/linux32/linux32_syscalls.c index 588e08c0a606..e6c08f1bda6f 100644 --- a/sys/amd64/linux32/linux32_syscalls.c +++ b/sys/amd64/linux32/linux32_syscalls.c @@ -246,7 +246,7 @@ const char *linux32_syscallnames[] = { "linux_lremovexattr", /* 236 = linux_lremovexattr */ "linux_fremovexattr", /* 237 = linux_fremovexattr */ "linux_tkill", /* 238 = linux_tkill */ - "#239", /* 239 = linux_sendfile64 */ + "linux_sendfile64", /* 239 = linux_sendfile64 */ "linux_sys_futex", /* 240 = linux_sys_futex */ "linux_sched_setaffinity", /* 241 = linux_sched_setaffinity */ "linux_sched_getaffinity", /* 242 = linux_sched_getaffinity */ diff --git a/sys/amd64/linux32/linux32_sysent.c b/sys/amd64/linux32/linux32_sysent.c index b935790758aa..3cb51b959812 100644 --- a/sys/amd64/linux32/linux32_sysent.c +++ b/sys/amd64/linux32/linux32_sysent.c @@ -204,7 +204,7 @@ struct sysent linux32_sysent[] = { { AS(linux_capget_args), (sy_call_t *)linux_capget, AUE_CAPGET, NULL, 0, 0, 0, SY_THR_STATIC }, /* 184 = linux_capget */ { AS(linux_capset_args), (sy_call_t *)linux_capset, AUE_CAPSET, NULL, 0, 0, 0, SY_THR_STATIC }, /* 185 = linux_capset */ { AS(linux_sigaltstack_args), (sy_call_t *)linux_sigaltstack, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 186 = linux_sigaltstack */ - { 0, (sy_call_t *)linux_sendfile, AUE_SENDFILE, NULL, 0, 0, 0, SY_THR_STATIC }, /* 187 = linux_sendfile */ + { AS(linux_sendfile_args), (sy_call_t *)linux_sendfile, AUE_SENDFILE, NULL, 0, 0, 0, SY_THR_STATIC }, /* 187 = linux_sendfile */ { 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0, 0, SY_THR_ABSENT }, /* 188 = getpmsg */ { 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0, 0, SY_THR_ABSENT }, /* 189 = putpmsg */ { 0, (sy_call_t *)linux_vfork, AUE_VFORK, NULL, 0, 0, 0, SY_THR_STATIC }, /* 190 = linux_vfork */ @@ -256,7 +256,7 @@ struct sysent linux32_sysent[] = { { 0, (sy_call_t *)linux_lremovexattr, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 236 = linux_lremovexattr */ { 0, (sy_call_t *)linux_fremovexattr, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 237 = linux_fremovexattr */ { AS(linux_tkill_args), (sy_call_t *)linux_tkill, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 238 = linux_tkill */ - { 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0, 0, SY_THR_ABSENT }, /* 239 = linux_sendfile64 */ + { AS(linux_sendfile64_args), (sy_call_t *)linux_sendfile64, AUE_SENDFILE, NULL, 0, 0, 0, SY_THR_STATIC }, /* 239 = linux_sendfile64 */ { AS(linux_sys_futex_args), (sy_call_t *)linux_sys_futex, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 240 = linux_sys_futex */ { AS(linux_sched_setaffinity_args), (sy_call_t *)linux_sched_setaffinity, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 241 = linux_sched_setaffinity */ { AS(linux_sched_getaffinity_args), (sy_call_t *)linux_sched_getaffinity, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 242 = linux_sched_getaffinity */ diff --git a/sys/amd64/linux32/linux32_systrace_args.c b/sys/amd64/linux32/linux32_systrace_args.c index d7b7fdc29ad3..85bab10bd459 100644 --- a/sys/amd64/linux32/linux32_systrace_args.c +++ b/sys/amd64/linux32/linux32_systrace_args.c @@ -1294,7 +1294,12 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args) } /* linux_sendfile */ case 187: { - *n_args = 0; + struct linux_sendfile_args *p = params; + iarg[0] = p->out; /* l_int */ + iarg[1] = p->in; /* l_int */ + uarg[2] = (intptr_t) p->offset; /* l_long * */ + iarg[3] = p->count; /* l_size_t */ + *n_args = 4; break; } /* linux_vfork */ @@ -1620,6 +1625,16 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args) *n_args = 2; break; } + /* linux_sendfile64 */ + case 239: { + struct linux_sendfile64_args *p = params; + iarg[0] = p->out; /* l_int */ + iarg[1] = p->in; /* l_int */ + uarg[2] = (intptr_t) p->offset; /* l_loff_t * */ + iarg[3] = p->count; /* l_size_t */ + *n_args = 4; + break; + } /* linux_sys_futex */ case 240: { struct linux_sys_futex_args *p = params; @@ -4987,6 +5002,22 @@ systrace_entry_setargdesc(int sysnum, int ndx, char *desc, size_t descsz) break; /* linux_sendfile */ case 187: + switch(ndx) { + case 0: + p = "l_int"; + break; + case 1: + p = "l_int"; + break; + case 2: + p = "userland l_long *"; + break; + case 3: + p = "l_size_t"; + break; + default: + break; + }; break; /* linux_vfork */ case 190: @@ -5432,6 +5463,25 @@ systrace_entry_setargdesc(int sysnum, int ndx, char *desc, size_t descsz) break; }; break; + /* linux_sendfile64 */ + case 239: + switch(ndx) { + case 0: + p = "l_int"; + break; + case 1: + p = "l_int"; + break; + case 2: + p = "userland l_loff_t *"; + break; + case 3: + p = "l_size_t"; + break; + default: + break; + }; + break; /* linux_sys_futex */ case 240: switch(ndx) { @@ -8305,6 +8355,9 @@ systrace_return_setargdesc(int sysnum, int ndx, char *desc, size_t descsz) break; /* linux_sendfile */ case 187: + if (ndx == 0 || ndx == 1) + p = "int"; + break; /* linux_vfork */ case 190: /* linux_getrlimit */ @@ -8478,6 +8531,11 @@ systrace_return_setargdesc(int sysnum, int ndx, char *desc, size_t descsz) if (ndx == 0 || ndx == 1) p = "int"; break; + /* linux_sendfile64 */ + case 239: + if (ndx == 0 || ndx == 1) + p = "int"; + break; /* linux_sys_futex */ case 240: if (ndx == 0 || ndx == 1) diff --git a/sys/amd64/linux32/syscalls.master b/sys/amd64/linux32/syscalls.master index 602c51447214..96933bb970b3 100644 --- a/sys/amd64/linux32/syscalls.master +++ b/sys/amd64/linux32/syscalls.master @@ -338,7 +338,8 @@ struct l_user_cap_data *datap); } 186 AUE_NULL STD { int linux_sigaltstack(l_stack_t *uss, \ l_stack_t *uoss); } -187 AUE_SENDFILE STD { int linux_sendfile(void); } +187 AUE_SENDFILE STD { int linux_sendfile(l_int out, l_int in, \ + l_long *offset, l_size_t count); } 188 AUE_GETPMSG UNIMPL getpmsg 189 AUE_PUTPMSG UNIMPL putpmsg 190 AUE_VFORK STD { int linux_vfork(void); } @@ -412,7 +413,8 @@ 236 AUE_NULL STD { int linux_lremovexattr(void); } 237 AUE_NULL STD { int linux_fremovexattr(void); } 238 AUE_NULL STD { int linux_tkill(int tid, int sig); } -239 AUE_SENDFILE UNIMPL linux_sendfile64 +239 AUE_SENDFILE STD { int linux_sendfile64(l_int out, l_int in, \ + l_loff_t *offset, l_size_t count); } 240 AUE_NULL STD { int linux_sys_futex(void *uaddr, int op, uint32_t val, \ struct l_timespec *timeout, uint32_t *uaddr2, uint32_t val3); } 241 AUE_NULL STD { int linux_sched_setaffinity(l_pid_t pid, l_uint len, \ diff --git a/sys/arm/include/param.h b/sys/arm/include/param.h index 39dcc5e341bf..ff5c271dfb2e 100644 --- a/sys/arm/include/param.h +++ b/sys/arm/include/param.h @@ -75,13 +75,13 @@ #define MACHINE_ARCH "arm" _V_SUFFIX _EB_SUFFIX #endif -#if defined(SMP) || defined(KLD_MODULE) +#ifdef SMP #ifndef MAXCPU #define MAXCPU 4 #endif #else #define MAXCPU 1 -#endif /* SMP || KLD_MODULE */ +#endif #ifndef MAXMEMDOM #define MAXMEMDOM 1 diff --git a/sys/arm/linux/linux_proto.h b/sys/arm/linux/linux_proto.h index b1030f4acfde..71225320bea1 100644 --- a/sys/arm/linux/linux_proto.h +++ b/sys/arm/linux/linux_proto.h @@ -509,7 +509,10 @@ struct linux_sigaltstack_args { char uoss_l_[PADL_(l_stack_t *)]; l_stack_t * uoss; char uoss_r_[PADR_(l_stack_t *)]; }; struct linux_sendfile_args { - register_t dummy; + char out_l_[PADL_(l_int)]; l_int out; char out_r_[PADR_(l_int)]; + char in_l_[PADL_(l_int)]; l_int in; char in_r_[PADR_(l_int)]; + char offset_l_[PADL_(l_long *)]; l_long * offset; char offset_r_[PADR_(l_long *)]; + char count_l_[PADL_(l_size_t)]; l_size_t count; char count_r_[PADR_(l_size_t)]; }; struct linux_vfork_args { register_t dummy; @@ -638,6 +641,12 @@ struct linux_tkill_args { char tid_l_[PADL_(int)]; int tid; char tid_r_[PADR_(int)]; char sig_l_[PADL_(int)]; int sig; char sig_r_[PADR_(int)]; }; +struct linux_sendfile64_args { + char out_l_[PADL_(l_int)]; l_int out; char out_r_[PADR_(l_int)]; + char in_l_[PADL_(l_int)]; l_int in; char in_r_[PADR_(l_int)]; + char offset_l_[PADL_(l_loff_t *)]; l_loff_t * offset; char offset_r_[PADR_(l_loff_t *)]; + char count_l_[PADL_(l_size_t)]; l_size_t count; char count_r_[PADR_(l_size_t)]; +}; struct linux_sys_futex_args { char uaddr_l_[PADL_(void *)]; void * uaddr; char uaddr_r_[PADR_(void *)]; char op_l_[PADL_(int)]; int op; char op_r_[PADR_(int)]; @@ -1371,6 +1380,7 @@ int linux_removexattr(struct thread *, struct linux_removexattr_args *); int linux_lremovexattr(struct thread *, struct linux_lremovexattr_args *); int linux_fremovexattr(struct thread *, struct linux_fremovexattr_args *); int linux_tkill(struct thread *, struct linux_tkill_args *); +int linux_sendfile64(struct thread *, struct linux_sendfile64_args *); int linux_sys_futex(struct thread *, struct linux_sys_futex_args *); int linux_sched_setaffinity(struct thread *, struct linux_sched_setaffinity_args *); int linux_sched_getaffinity(struct thread *, struct linux_sched_getaffinity_args *); @@ -1696,6 +1706,7 @@ int linux_set_tls(struct thread *, struct linux_set_tls_args *); #define LINUX_SYS_AUE_linux_lremovexattr AUE_NULL #define LINUX_SYS_AUE_linux_fremovexattr AUE_NULL #define LINUX_SYS_AUE_linux_tkill AUE_NULL +#define LINUX_SYS_AUE_linux_sendfile64 AUE_SENDFILE #define LINUX_SYS_AUE_linux_sys_futex AUE_NULL #define LINUX_SYS_AUE_linux_sched_setaffinity AUE_NULL #define LINUX_SYS_AUE_linux_sched_getaffinity AUE_NULL diff --git a/sys/arm/linux/linux_syscall.h b/sys/arm/linux/linux_syscall.h index 7d484ea9d2dc..1621fde6c0b8 100644 --- a/sys/arm/linux/linux_syscall.h +++ b/sys/arm/linux/linux_syscall.h @@ -195,6 +195,7 @@ #define LINUX_SYS_linux_lremovexattr 236 #define LINUX_SYS_linux_fremovexattr 237 #define LINUX_SYS_linux_tkill 238 +#define LINUX_SYS_linux_sendfile64 239 #define LINUX_SYS_linux_sys_futex 240 #define LINUX_SYS_linux_sched_setaffinity 241 #define LINUX_SYS_linux_sched_getaffinity 242 diff --git a/sys/arm/linux/linux_syscalls.c b/sys/arm/linux/linux_syscalls.c index 991e962d78df..d7f743f1a825 100644 --- a/sys/arm/linux/linux_syscalls.c +++ b/sys/arm/linux/linux_syscalls.c @@ -246,7 +246,7 @@ const char *linux_syscallnames[] = { "linux_lremovexattr", /* 236 = linux_lremovexattr */ "linux_fremovexattr", /* 237 = linux_fremovexattr */ "linux_tkill", /* 238 = linux_tkill */ - "#239", /* 239 = linux_sendfile64 */ + "linux_sendfile64", /* 239 = linux_sendfile64 */ "linux_sys_futex", /* 240 = linux_sys_futex */ "linux_sched_setaffinity", /* 241 = linux_sched_setaffinity */ "linux_sched_getaffinity", /* 242 = linux_sched_getaffinity */ diff --git a/sys/arm/linux/linux_sysent.c b/sys/arm/linux/linux_sysent.c index 7f3b785db595..38e14f29d867 100644 --- a/sys/arm/linux/linux_sysent.c +++ b/sys/arm/linux/linux_sysent.c @@ -204,7 +204,7 @@ struct sysent linux_sysent[] = { { AS(linux_capget_args), (sy_call_t *)linux_capget, AUE_CAPGET, NULL, 0, 0, 0, SY_THR_STATIC }, /* 184 = linux_capget */ { AS(linux_capset_args), (sy_call_t *)linux_capset, AUE_CAPSET, NULL, 0, 0, 0, SY_THR_STATIC }, /* 185 = linux_capset */ { AS(linux_sigaltstack_args), (sy_call_t *)linux_sigaltstack, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 186 = linux_sigaltstack */ - { 0, (sy_call_t *)linux_sendfile, AUE_SENDFILE, NULL, 0, 0, 0, SY_THR_STATIC }, /* 187 = linux_sendfile */ + { AS(linux_sendfile_args), (sy_call_t *)linux_sendfile, AUE_SENDFILE, NULL, 0, 0, 0, SY_THR_STATIC }, /* 187 = linux_sendfile */ { 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0, 0, SY_THR_ABSENT }, /* 188 = ; */ { 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0, 0, SY_THR_ABSENT }, /* 189 = ; */ { 0, (sy_call_t *)linux_vfork, AUE_VFORK, NULL, 0, 0, 0, SY_THR_STATIC }, /* 190 = linux_vfork */ @@ -256,7 +256,7 @@ struct sysent linux_sysent[] = { { 0, (sy_call_t *)linux_lremovexattr, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 236 = linux_lremovexattr */ { 0, (sy_call_t *)linux_fremovexattr, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 237 = linux_fremovexattr */ { AS(linux_tkill_args), (sy_call_t *)linux_tkill, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 238 = linux_tkill */ - { 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0, 0, SY_THR_ABSENT }, /* 239 = linux_sendfile64 */ + { AS(linux_sendfile64_args), (sy_call_t *)linux_sendfile64, AUE_SENDFILE, NULL, 0, 0, 0, SY_THR_STATIC }, /* 239 = linux_sendfile64 */ { AS(linux_sys_futex_args), (sy_call_t *)linux_sys_futex, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 240 = linux_sys_futex */ { AS(linux_sched_setaffinity_args), (sy_call_t *)linux_sched_setaffinity, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 241 = linux_sched_setaffinity */ { AS(linux_sched_getaffinity_args), (sy_call_t *)linux_sched_getaffinity, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 242 = linux_sched_getaffinity */ diff --git a/sys/arm/linux/linux_systrace_args.c b/sys/arm/linux/linux_systrace_args.c index e21a6721877f..2129b996b173 100644 --- a/sys/arm/linux/linux_systrace_args.c +++ b/sys/arm/linux/linux_systrace_args.c @@ -1135,7 +1135,12 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args) } /* linux_sendfile */ case 187: { - *n_args = 0; + struct linux_sendfile_args *p = params; + iarg[0] = p->out; /* l_int */ + iarg[1] = p->in; /* l_int */ + uarg[2] = (intptr_t) p->offset; /* l_long * */ + iarg[3] = p->count; /* l_size_t */ + *n_args = 4; break; } /* linux_vfork */ @@ -1459,6 +1464,16 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args) *n_args = 2; break; } + /* linux_sendfile64 */ + case 239: { + struct linux_sendfile64_args *p = params; + iarg[0] = p->out; /* l_int */ + iarg[1] = p->in; /* l_int */ + uarg[2] = (intptr_t) p->offset; /* l_loff_t * */ + iarg[3] = p->count; /* l_size_t */ + *n_args = 4; + break; + } /* linux_sys_futex */ case 240: { struct linux_sys_futex_args *p = params; @@ -4248,6 +4263,22 @@ systrace_entry_setargdesc(int sysnum, int ndx, char *desc, size_t descsz) break; /* linux_sendfile */ case 187: + switch(ndx) { + case 0: + p = "l_int"; + break; + case 1: + p = "l_int"; + break; + case 2: + p = "userland l_long *"; + break; + case 3: + p = "l_size_t"; + break; + default: + break; + }; break; /* linux_vfork */ case 190: @@ -4687,6 +4718,25 @@ systrace_entry_setargdesc(int sysnum, int ndx, char *desc, size_t descsz) break; }; break; + /* linux_sendfile64 */ + case 239: + switch(ndx) { + case 0: + p = "l_int"; + break; + case 1: + p = "l_int"; + break; + case 2: + p = "userland l_loff_t *"; + break; + case 3: + p = "l_size_t"; + break; + default: + break; + }; + break; /* linux_sys_futex */ case 240: switch(ndx) { @@ -6978,6 +7028,9 @@ systrace_return_setargdesc(int sysnum, int ndx, char *desc, size_t descsz) break; /* linux_sendfile */ case 187: + if (ndx == 0 || ndx == 1) + p = "int"; + break; /* linux_vfork */ case 190: /* linux_getrlimit */ @@ -7151,6 +7204,11 @@ systrace_return_setargdesc(int sysnum, int ndx, char *desc, size_t descsz) if (ndx == 0 || ndx == 1) p = "int"; break; + /* linux_sendfile64 */ + case 239: + if (ndx == 0 || ndx == 1) + p = "int"; + break; /* linux_sys_futex */ case 240: if (ndx == 0 || ndx == 1) diff --git a/sys/arm/linux/syscalls.master b/sys/arm/linux/syscalls.master index fd03018507b4..02a504459760 100644 --- a/sys/arm/linux/syscalls.master +++ b/sys/arm/linux/syscalls.master @@ -868,7 +868,12 @@ ); } 187 AUE_SENDFILE STD { - int linux_sendfile(void); + int linux_sendfile( + l_int out, + l_int in, + l_long *offset, + l_size_t count + ); } 188 AUE_NULL UNIMPL ; was getpmsg 189 AUE_NULL UNIMPL ; was putpmsg @@ -1090,7 +1095,14 @@ int sig ); } -239 AUE_SENDFILE UNIMPL linux_sendfile64 +239 AUE_SENDFILE STD { + int linux_sendfile64( + l_int out, + l_int in, + l_loff_t *offset, + l_size_t count + ); + } 240 AUE_NULL STD { int linux_sys_futex(void *uaddr, int op, diff --git a/sys/arm64/arm64/gicv3_its.c b/sys/arm64/arm64/gicv3_its.c index 4fa471c14120..e69981f1b686 100644 --- a/sys/arm64/arm64/gicv3_its.c +++ b/sys/arm64/arm64/gicv3_its.c @@ -223,7 +223,7 @@ struct its_col { struct gicv3_its_irqsrc { struct intr_irqsrc gi_isrc; - u_int gi_irq; + u_int gi_id; u_int gi_lpi; struct its_dev *gi_its_dev; }; @@ -799,14 +799,14 @@ gicv3_its_attach(device_t dev) * XXX: This assumes there are no other interrupt controllers in the * system. */ - sc->sc_irq_alloc = vmem_create("GICv3 ITS IRQs", 0, - gicv3_get_nirqs(dev), 1, 1, M_FIRSTFIT | M_WAITOK); + sc->sc_irq_alloc = vmem_create(device_get_nameunit(dev), 0, + gicv3_get_nirqs(dev), 1, 0, M_FIRSTFIT | M_WAITOK); sc->sc_irqs = malloc(sizeof(*sc->sc_irqs) * sc->sc_irq_length, M_GICV3_ITS, M_WAITOK | M_ZERO); name = device_get_nameunit(dev); for (i = 0; i < sc->sc_irq_length; i++) { - sc->sc_irqs[i].gi_irq = i; + sc->sc_irqs[i].gi_id = -1; sc->sc_irqs[i].gi_lpi = i + sc->sc_irq_base - GIC_FIRST_LPI; err = intr_isrc_register(&sc->sc_irqs[i].gi_isrc, dev, 0, "%s,%u", name, i); @@ -906,7 +906,7 @@ gicv3_its_pre_ithread(device_t dev, struct intr_irqsrc *isrc) sc = device_get_softc(dev); girq = (struct gicv3_its_irqsrc *)isrc; gicv3_its_disable_intr(dev, isrc); - gic_icc_write(EOIR1, girq->gi_irq + sc->sc_irq_base); + gic_icc_write(EOIR1, girq->gi_lpi + GIC_FIRST_LPI); } static void @@ -924,7 +924,7 @@ gicv3_its_post_filter(device_t dev, struct intr_irqsrc *isrc) sc = device_get_softc(dev); girq = (struct gicv3_its_irqsrc *)isrc; - gic_icc_write(EOIR1, girq->gi_irq + sc->sc_irq_base); + gic_icc_write(EOIR1, girq->gi_lpi + GIC_FIRST_LPI); } static int @@ -1135,6 +1135,7 @@ gicv3_its_alloc_msi(device_t dev, device_t child, int count, int maxcount, for (i = 0; i < count; i++, irq++) { its_dev->lpis.lpi_free--; girq = &sc->sc_irqs[irq]; + girq->gi_id = i; girq->gi_its_dev = its_dev; srcs[i] = (struct intr_irqsrc *)girq; @@ -1167,6 +1168,7 @@ gicv3_its_release_msi(device_t dev, device_t child, int count, its_dev->lpis.lpi_busy)); for (i = 0; i < count; i++) { girq = (struct gicv3_its_irqsrc *)isrc[i]; + girq->gi_id = -1; girq->gi_its_dev = NULL; } its_dev->lpis.lpi_busy -= count; @@ -1196,10 +1198,12 @@ gicv3_its_alloc_msix(device_t dev, device_t child, device_t *pic, sc = device_get_softc(dev); irq = its_dev->lpis.lpi_base + its_dev->lpis.lpi_num - its_dev->lpis.lpi_free; + girq = &sc->sc_irqs[irq]; + girq->gi_id = its_dev->lpis.lpi_busy; + girq->gi_its_dev = its_dev; + its_dev->lpis.lpi_free--; its_dev->lpis.lpi_busy++; - girq = &sc->sc_irqs[irq]; - girq->gi_its_dev = its_dev; /* Map the message to the given IRQ */ gicv3_its_select_cpu(dev, (struct intr_irqsrc *)girq); @@ -1227,6 +1231,7 @@ gicv3_its_release_msix(device_t dev, device_t child, struct intr_irqsrc *isrc) "were allocated: allocated %d", its_dev->lpis.lpi_busy)); girq = (struct gicv3_its_irqsrc *)isrc; girq->gi_its_dev = NULL; + girq->gi_id = -1; its_dev->lpis.lpi_busy--; if (its_dev->lpis.lpi_busy == 0) @@ -1246,7 +1251,7 @@ gicv3_its_map_msi(device_t dev, device_t child, struct intr_irqsrc *isrc, girq = (struct gicv3_its_irqsrc *)isrc; *addr = vtophys(rman_get_virtual(sc->sc_its_res)) + GITS_TRANSLATER; - *data = girq->gi_irq - girq->gi_its_dev->lpis.lpi_base; + *data = girq->gi_id; return (0); } @@ -1581,7 +1586,7 @@ its_cmd_movi(device_t dev, struct gicv3_its_irqsrc *girq) desc.cmd_type = ITS_CMD_MOVI; desc.cmd_desc_movi.its_dev = girq->gi_its_dev; desc.cmd_desc_movi.col = col; - desc.cmd_desc_movi.id = girq->gi_irq - girq->gi_its_dev->lpis.lpi_base; + desc.cmd_desc_movi.id = girq->gi_id; its_cmd_send(dev, &desc); } @@ -1619,9 +1624,9 @@ its_cmd_mapti(device_t dev, struct gicv3_its_irqsrc *girq) desc.cmd_desc_mapvi.its_dev = girq->gi_its_dev; desc.cmd_desc_mapvi.col = col; /* The EventID sent to the device */ - desc.cmd_desc_mapvi.id = girq->gi_irq - girq->gi_its_dev->lpis.lpi_base; + desc.cmd_desc_mapvi.id = girq->gi_id; /* The physical interrupt presented to softeware */ - desc.cmd_desc_mapvi.pid = girq->gi_irq + sc->sc_irq_base; + desc.cmd_desc_mapvi.pid = girq->gi_lpi + GIC_FIRST_LPI; its_cmd_send(dev, &desc); } @@ -1651,7 +1656,7 @@ its_cmd_inv(device_t dev, struct its_dev *its_dev, desc.cmd_type = ITS_CMD_INV; /* The EventID sent to the device */ - desc.cmd_desc_inv.pid = girq->gi_irq - its_dev->lpis.lpi_base; + desc.cmd_desc_inv.pid = girq->gi_id; desc.cmd_desc_inv.its_dev = its_dev; desc.cmd_desc_inv.col = col; diff --git a/sys/arm64/arm64/identcpu.c b/sys/arm64/arm64/identcpu.c index 157353e12e5d..4bfd5f06bae4 100644 --- a/sys/arm64/arm64/identcpu.c +++ b/sys/arm64/arm64/identcpu.c @@ -114,8 +114,8 @@ struct cpu_desc { uint64_t id_aa64pfr1; }; -struct cpu_desc cpu_desc[MAXCPU]; -struct cpu_desc user_cpu_desc; +static struct cpu_desc cpu_desc[MAXCPU]; +static struct cpu_desc user_cpu_desc; static u_int cpu_print_regs; #define PRINT_ID_AA64_AFR0 0x00000001 #define PRINT_ID_AA64_AFR1 0x00000002 @@ -961,6 +961,7 @@ update_user_regs(u_int cpu) /* HWCAP */ extern u_long elf_hwcap; +bool __read_frequently lse_supported = false; static void identify_cpu_sysinit(void *dummy __unused) @@ -975,7 +976,6 @@ identify_cpu_sysinit(void *dummy __unused) ID_AA64PFR0_FP_NONE | ID_AA64PFR0_EL1_64 | ID_AA64PFR0_EL0_64; user_cpu_desc.id_aa64dfr0 = ID_AA64DFR0_DebugVer_8; - CPU_FOREACH(cpu) { print_cpu_features(cpu); hwcap = parse_cpu_features_hwcap(cpu); @@ -986,6 +986,16 @@ identify_cpu_sysinit(void *dummy __unused) update_user_regs(cpu); } + if ((elf_hwcap & HWCAP_ATOMICS) != 0) { + lse_supported = true; + if (bootverbose) + printf("Enabling LSE atomics in the kernel\n"); + } +#ifdef LSE_ATOMICS + if (!lse_supported) + panic("CPU does not support LSE atomic instructions"); +#endif + install_undef_handler(true, user_mrs_handler); } SYSINIT(idenrity_cpu, SI_SUB_SMP, SI_ORDER_ANY, identify_cpu_sysinit, NULL); diff --git a/sys/arm64/arm64/trap.c b/sys/arm64/arm64/trap.c index 079061cad56d..629f9114cc04 100644 --- a/sys/arm64/arm64/trap.c +++ b/sys/arm64/arm64/trap.c @@ -357,12 +357,15 @@ do_el1h_sync(struct thread *td, struct trapframe *frame) far = READ_SPECIALREG(far_el1); dfsc = esr & ISS_DATA_DFSC_MASK; if (dfsc < nitems(abort_handlers) && - abort_handlers[dfsc] != NULL) + abort_handlers[dfsc] != NULL) { abort_handlers[dfsc](td, frame, esr, far, 0); - else + } else { + print_registers(frame); + printf(" far: %16lx\n", far); panic("Unhandled EL1 %s abort: %x", exception == EXCP_INSN_ABORT ? "instruction" : "data", dfsc); + } break; case EXCP_BRK: #ifdef KDTRACE_HOOKS diff --git a/sys/arm64/include/atomic.h b/sys/arm64/include/atomic.h index 97d286c9bba5..19fb1aff735a 100644 --- a/sys/arm64/include/atomic.h +++ b/sys/arm64/include/atomic.h @@ -59,102 +59,159 @@ #include -#define ATOMIC_OP(op, asm_op, bar, a, l) \ +#ifdef _KERNEL +extern bool lse_supported; + +#ifdef LSE_ATOMICS +#define _ATOMIC_LSE_SUPPORTED 1 +#else +#define _ATOMIC_LSE_SUPPORTED lse_supported +#endif +#else +#define _ATOMIC_LSE_SUPPORTED 0 +#endif + +#define _ATOMIC_OP_PROTO(t, op, bar, flav) \ static __inline void \ -atomic_##op##_##bar##8(volatile uint8_t *p, uint8_t val) \ +atomic_##op##_##bar##t##flav(volatile uint##t##_t *p, uint##t##_t val) + +#define _ATOMIC_OP_IMPL(t, w, s, op, llsc_asm_op, lse_asm_op, pre, bar, a, l) \ +_ATOMIC_OP_PROTO(t, op, bar, _llsc) \ { \ - uint8_t tmp; \ + uint##t##_t tmp; \ int res; \ \ + pre; \ __asm __volatile( \ - "1: ld"#a"xrb %w0, [%2] \n" \ - " "#asm_op" %w0, %w0, %w3 \n" \ - " st"#l"xrb %w1, %w0, [%2] \n" \ - " cbnz %w1, 1b \n" \ + "1: ld"#a"xr"#s" %"#w"0, [%2]\n" \ + " "#llsc_asm_op" %"#w"0, %"#w"0, %"#w"3\n" \ + " st"#l"xr"#s" %w1, %"#w"0, [%2]\n" \ + " cbnz %w1, 1b\n" \ : "=&r"(tmp), "=&r"(res) \ : "r" (p), "r" (val) \ : "memory" \ ); \ } \ \ -static __inline void \ -atomic_##op##_##bar##16(volatile uint16_t *p, uint16_t val) \ +_ATOMIC_OP_PROTO(t, op, bar, _lse) \ { \ - uint16_t tmp; \ - int res; \ + uint##t##_t tmp; \ \ + pre; \ __asm __volatile( \ - "1: ld"#a"xrh %w0, [%2] \n" \ - " "#asm_op" %w0, %w0, %w3 \n" \ - " st"#l"xrh %w1, %w0, [%2] \n" \ - " cbnz %w1, 1b \n" \ - : "=&r"(tmp), "=&r"(res) \ + ".arch_extension lse\n" \ + "ld"#lse_asm_op#a#l#s" %"#w"2, %"#w"0, [%1]\n" \ + ".arch_extension nolse\n" \ + : "=r" (tmp) \ : "r" (p), "r" (val) \ : "memory" \ ); \ } \ \ -static __inline void \ -atomic_##op##_##bar##32(volatile uint32_t *p, uint32_t val) \ +_ATOMIC_OP_PROTO(t, op, bar, ) \ { \ - uint32_t tmp; \ - int res; \ - \ - __asm __volatile( \ - "1: ld"#a"xr %w0, [%2] \n" \ - " "#asm_op" %w0, %w0, %w3 \n" \ - " st"#l"xr %w1, %w0, [%2] \n" \ - " cbnz %w1, 1b \n" \ - : "=&r"(tmp), "=&r"(res) \ - : "r" (p), "r" (val) \ - : "memory" \ - ); \ -} \ - \ -static __inline void \ -atomic_##op##_##bar##64(volatile uint64_t *p, uint64_t val) \ -{ \ - uint64_t tmp; \ - int res; \ - \ - __asm __volatile( \ - "1: ld"#a"xr %0, [%2] \n" \ - " "#asm_op" %0, %0, %3 \n" \ - " st"#l"xr %w1, %0, [%2] \n" \ - " cbnz %w1, 1b \n" \ - : "=&r"(tmp), "=&r"(res) \ - : "r" (p), "r" (val) \ - : "memory" \ - ); \ + if (_ATOMIC_LSE_SUPPORTED) \ + atomic_##op##_##bar##t##_lse(p, val); \ + else \ + atomic_##op##_##bar##t##_llsc(p, val); \ } -#define ATOMIC(op, asm_op) \ - ATOMIC_OP(op, asm_op, , , ) \ - ATOMIC_OP(op, asm_op, acq_, a, ) \ - ATOMIC_OP(op, asm_op, rel_, , l) \ +#define __ATOMIC_OP(op, llsc_asm_op, lse_asm_op, pre, bar, a, l) \ + _ATOMIC_OP_IMPL(8, w, b, op, llsc_asm_op, lse_asm_op, pre, \ + bar, a, l) \ + _ATOMIC_OP_IMPL(16, w, h, op, llsc_asm_op, lse_asm_op, pre, \ + bar, a, l) \ + _ATOMIC_OP_IMPL(32, w, , op, llsc_asm_op, lse_asm_op, pre, \ + bar, a, l) \ + _ATOMIC_OP_IMPL(64, , , op, llsc_asm_op, lse_asm_op, pre, \ + bar, a, l) -ATOMIC(add, add) -ATOMIC(clear, bic) -ATOMIC(set, orr) -ATOMIC(subtract, sub) +#define _ATOMIC_OP(op, llsc_asm_op, lse_asm_op, pre) \ + __ATOMIC_OP(op, llsc_asm_op, lse_asm_op, pre, , , ) \ + __ATOMIC_OP(op, llsc_asm_op, lse_asm_op, pre, acq_, a, ) \ + __ATOMIC_OP(op, llsc_asm_op, lse_asm_op, pre, rel_, , l) -#define ATOMIC_FCMPSET(bar, a, l) \ +_ATOMIC_OP(add, add, add, ) +_ATOMIC_OP(clear, bic, clr, ) +_ATOMIC_OP(set, orr, set, ) +_ATOMIC_OP(subtract, add, add, val = -val) + +#define _ATOMIC_CMPSET_PROTO(t, bar, flav) \ static __inline int \ -atomic_fcmpset_##bar##8(volatile uint8_t *p, uint8_t *cmpval, \ - uint8_t newval) \ +atomic_cmpset_##bar##t##flav(volatile uint##t##_t *p, \ + uint##t##_t cmpval, uint##t##_t newval) + +#define _ATOMIC_FCMPSET_PROTO(t, bar, flav) \ +static __inline int \ +atomic_fcmpset_##bar##t##flav(volatile uint##t##_t *p, \ + uint##t##_t *cmpval, uint##t##_t newval) + +#define _ATOMIC_CMPSET_IMPL(t, w, s, bar, a, l) \ +_ATOMIC_CMPSET_PROTO(t, bar, _llsc) \ { \ - uint8_t tmp; \ - uint8_t _cmpval = *cmpval; \ + uint##t##_t tmp; \ int res; \ \ __asm __volatile( \ - "1: mov %w1, #1 \n" \ - " ld"#a"xrb %w0, [%2] \n" \ - " cmp %w0, %w3 \n" \ - " b.ne 2f \n" \ - " st"#l"xrb %w1, %w4, [%2]\n" \ + "1: mov %w1, #1\n" \ + " ld"#a"xr"#s" %"#w"0, [%2]\n" \ + " cmp %"#w"0, %"#w"3\n" \ + " b.ne 2f\n" \ + " st"#l"xr"#s" %w1, %"#w"4, [%2]\n" \ + " cbnz %w1, 1b\n" \ "2:" \ : "=&r"(tmp), "=&r"(res) \ + : "r" (p), "r" (cmpval), "r" (newval) \ + : "cc", "memory" \ + ); \ + \ + return (!res); \ +} \ + \ +_ATOMIC_CMPSET_PROTO(t, bar, _lse) \ +{ \ + uint##t##_t oldval; \ + int res; \ + \ + oldval = cmpval; \ + __asm __volatile( \ + ".arch_extension lse\n" \ + "cas"#a#l#s" %"#w"1, %"#w"4, [%3]\n" \ + "cmp %"#w"1, %"#w"2\n" \ + "cset %w0, eq\n" \ + ".arch_extension nolse\n" \ + : "=r" (res), "+&r" (cmpval) \ + : "r" (oldval), "r" (p), "r" (newval) \ + : "cc", "memory" \ + ); \ + \ + return (res); \ +} \ + \ +_ATOMIC_CMPSET_PROTO(t, bar, ) \ +{ \ + if (_ATOMIC_LSE_SUPPORTED) \ + return (atomic_cmpset_##bar##t##_lse(p, cmpval, \ + newval)); \ + else \ + return (atomic_cmpset_##bar##t##_llsc(p, cmpval, \ + newval)); \ +} \ + \ +_ATOMIC_FCMPSET_PROTO(t, bar, _llsc) \ +{ \ + uint##t##_t _cmpval, tmp; \ + int res; \ + \ + _cmpval = *cmpval; \ + __asm __volatile( \ + " mov %w1, #1\n" \ + " ld"#a"xr"#s" %"#w"0, [%2]\n" \ + " cmp %"#w"0, %"#w"3\n" \ + " b.ne 1f\n" \ + " st"#l"xr"#s" %w1, %"#w"4, [%2]\n" \ + "1:" \ + : "=&r"(tmp), "=&r"(res) \ : "r" (p), "r" (_cmpval), "r" (newval) \ : "cc", "memory" \ ); \ @@ -163,471 +220,271 @@ atomic_fcmpset_##bar##8(volatile uint8_t *p, uint8_t *cmpval, \ return (!res); \ } \ \ -static __inline int \ -atomic_fcmpset_##bar##16(volatile uint16_t *p, uint16_t *cmpval, \ - uint16_t newval) \ +_ATOMIC_FCMPSET_PROTO(t, bar, _lse) \ { \ - uint16_t tmp; \ - uint16_t _cmpval = *cmpval; \ + uint##t##_t _cmpval, tmp; \ int res; \ \ + _cmpval = tmp = *cmpval; \ __asm __volatile( \ - "1: mov %w1, #1 \n" \ - " ld"#a"xrh %w0, [%2] \n" \ - " cmp %w0, %w3 \n" \ - " b.ne 2f \n" \ - " st"#l"xrh %w1, %w4, [%2] \n" \ - "2:" \ - : "=&r"(tmp), "=&r"(res) \ - : "r" (p), "r" (_cmpval), "r" (newval) \ + ".arch_extension lse\n" \ + "cas"#a#l#s" %"#w"1, %"#w"4, [%3]\n" \ + "cmp %"#w"1, %"#w"2\n" \ + "cset %w0, eq\n" \ + ".arch_extension nolse\n" \ + : "=r" (res), "+&r" (tmp) \ + : "r" (_cmpval), "r" (p), "r" (newval) \ : "cc", "memory" \ ); \ *cmpval = tmp; \ \ - return (!res); \ + return (res); \ } \ \ -static __inline int \ -atomic_fcmpset_##bar##32(volatile uint32_t *p, uint32_t *cmpval, \ - uint32_t newval) \ +_ATOMIC_FCMPSET_PROTO(t, bar, ) \ { \ - uint32_t tmp; \ - uint32_t _cmpval = *cmpval; \ + if (_ATOMIC_LSE_SUPPORTED) \ + return (atomic_fcmpset_##bar##t##_lse(p, cmpval, \ + newval)); \ + else \ + return (atomic_fcmpset_##bar##t##_llsc(p, cmpval, \ + newval)); \ +} + +#define _ATOMIC_CMPSET(bar, a, l) \ + _ATOMIC_CMPSET_IMPL(8, w, b, bar, a, l) \ + _ATOMIC_CMPSET_IMPL(16, w, h, bar, a, l) \ + _ATOMIC_CMPSET_IMPL(32, w, , bar, a, l) \ + _ATOMIC_CMPSET_IMPL(64, , , bar, a, l) + +_ATOMIC_CMPSET( , , ) +_ATOMIC_CMPSET(acq_, a, ) +_ATOMIC_CMPSET(rel_, ,l) + +#define _ATOMIC_FETCHADD_PROTO(t, flav) \ +static __inline uint##t##_t \ +atomic_fetchadd_##t##flav(volatile uint##t##_t *p, uint##t##_t val) + +#define _ATOMIC_FETCHADD_IMPL(t, w) \ +_ATOMIC_FETCHADD_PROTO(t, _llsc) \ +{ \ + uint##t##_t ret, tmp; \ int res; \ \ __asm __volatile( \ - "1: mov %w1, #1 \n" \ - " ld"#a"xr %w0, [%2] \n" \ - " cmp %w0, %w3 \n" \ - " b.ne 2f \n" \ - " st"#l"xr %w1, %w4, [%2] \n" \ - "2:" \ - : "=&r"(tmp), "=&r"(res) \ - : "r" (p), "r" (_cmpval), "r" (newval) \ - : "cc", "memory" \ + "1: ldxr %"#w"2, [%3]\n" \ + " add %"#w"0, %"#w"2, %"#w"4\n" \ + " stxr %w1, %"#w"0, [%3]\n" \ + " cbnz %w1, 1b\n" \ + : "=&r" (tmp), "=&r" (res), "=&r" (ret) \ + : "r" (p), "r" (val) \ + : "memory" \ ); \ - *cmpval = tmp; \ \ - return (!res); \ + return (ret); \ } \ \ -static __inline int \ -atomic_fcmpset_##bar##64(volatile uint64_t *p, uint64_t *cmpval, \ - uint64_t newval) \ +_ATOMIC_FETCHADD_PROTO(t, _lse) \ { \ - uint64_t tmp; \ - uint64_t _cmpval = *cmpval; \ - int res; \ + uint##t##_t ret; \ \ __asm __volatile( \ - "1: mov %w1, #1 \n" \ - " ld"#a"xr %0, [%2] \n" \ - " cmp %0, %3 \n" \ - " b.ne 2f \n" \ - " st"#l"xr %w1, %4, [%2] \n" \ - "2:" \ - : "=&r"(tmp), "=&r"(res) \ - : "r" (p), "r" (_cmpval), "r" (newval) \ - : "cc", "memory" \ - ); \ - *cmpval = tmp; \ - \ - return (!res); \ -} - -ATOMIC_FCMPSET( , , ) -ATOMIC_FCMPSET(acq_, a, ) -ATOMIC_FCMPSET(rel_, ,l) - -#undef ATOMIC_FCMPSET - -#define ATOMIC_CMPSET(bar, a, l) \ -static __inline int \ -atomic_cmpset_##bar##8(volatile uint8_t *p, uint8_t cmpval, \ - uint8_t newval) \ -{ \ - uint8_t tmp; \ - int res; \ - \ - __asm __volatile( \ - "1: mov %w1, #1 \n" \ - " ld"#a"xrb %w0, [%2] \n" \ - " cmp %w0, %w3 \n" \ - " b.ne 2f \n" \ - " st"#l"xrb %w1, %w4, [%2] \n" \ - " cbnz %w1, 1b \n" \ - "2:" \ - : "=&r"(tmp), "=&r"(res) \ - : "r" (p), "r" (cmpval), "r" (newval) \ - : "cc", "memory" \ + ".arch_extension lse\n" \ + "ldadd %"#w"2, %"#w"0, [%1]\n" \ + ".arch_extension nolse\n" \ + : "=r" (ret) \ + : "r" (p), "r" (val) \ + : "memory" \ ); \ \ - return (!res); \ + return (ret); \ } \ \ -static __inline int \ -atomic_cmpset_##bar##16(volatile uint16_t *p, uint16_t cmpval, \ - uint16_t newval) \ +_ATOMIC_FETCHADD_PROTO(t, ) \ { \ - uint16_t tmp; \ + if (_ATOMIC_LSE_SUPPORTED) \ + return (atomic_fetchadd_##t##_lse(p, val)); \ + else \ + return (atomic_fetchadd_##t##_llsc(p, val)); \ +} + +_ATOMIC_FETCHADD_IMPL(32, w) +_ATOMIC_FETCHADD_IMPL(64, ) + +#define _ATOMIC_SWAP_PROTO(t, flav) \ +static __inline uint##t##_t \ +atomic_swap_##t##flav(volatile uint##t##_t *p, uint##t##_t val) + +#define _ATOMIC_READANDCLEAR_PROTO(t, flav) \ +static __inline uint##t##_t \ +atomic_readandclear_##t##flav(volatile uint##t##_t *p) + +#define _ATOMIC_SWAP_IMPL(t, w, zreg) \ +_ATOMIC_SWAP_PROTO(t, _llsc) \ +{ \ + uint##t##_t ret; \ int res; \ \ __asm __volatile( \ - "1: mov %w1, #1 \n" \ - " ld"#a"xrh %w0, [%2] \n" \ - " cmp %w0, %w3 \n" \ - " b.ne 2f \n" \ - " st"#l"xrh %w1, %w4, [%2] \n" \ - " cbnz %w1, 1b \n" \ - "2:" \ - : "=&r"(tmp), "=&r"(res) \ - : "r" (p), "r" (cmpval), "r" (newval) \ - : "cc", "memory" \ + "1: ldxr %"#w"1, [%2]\n" \ + " stxr %w0, %"#w"3, [%2]\n" \ + " cbnz %w0, 1b\n" \ + : "=&r" (res), "=&r" (ret) \ + : "r" (p), "r" (val) \ + : "memory" \ ); \ \ - return (!res); \ + return (ret); \ } \ \ -static __inline int \ -atomic_cmpset_##bar##32(volatile uint32_t *p, uint32_t cmpval, \ - uint32_t newval) \ +_ATOMIC_SWAP_PROTO(t, _lse) \ { \ - uint32_t tmp; \ - int res; \ + uint##t##_t ret; \ \ __asm __volatile( \ - "1: mov %w1, #1 \n" \ - " ld"#a"xr %w0, [%2] \n" \ - " cmp %w0, %w3 \n" \ - " b.ne 2f \n" \ - " st"#l"xr %w1, %w4, [%2] \n" \ - " cbnz %w1, 1b \n" \ - "2:" \ - : "=&r"(tmp), "=&r"(res) \ - : "r" (p), "r" (cmpval), "r" (newval) \ - : "cc", "memory" \ + ".arch_extension lse\n" \ + "swp %"#w"2, %"#w"0, [%1]\n" \ + ".arch_extension nolse\n" \ + : "=r" (ret) \ + : "r" (p), "r" (val) \ + : "memory" \ ); \ \ - return (!res); \ + return (ret); \ } \ \ -static __inline int \ -atomic_cmpset_##bar##64(volatile uint64_t *p, uint64_t cmpval, \ - uint64_t newval) \ +_ATOMIC_SWAP_PROTO(t, ) \ { \ - uint64_t tmp; \ + if (_ATOMIC_LSE_SUPPORTED) \ + return (atomic_swap_##t##_lse(p, val)); \ + else \ + return (atomic_swap_##t##_llsc(p, val)); \ +} \ + \ +_ATOMIC_READANDCLEAR_PROTO(t, _llsc) \ +{ \ + uint##t##_t ret; \ int res; \ \ __asm __volatile( \ - "1: mov %w1, #1 \n" \ - " ld"#a"xr %0, [%2] \n" \ - " cmp %0, %3 \n" \ - " b.ne 2f \n" \ - " st"#l"xr %w1, %4, [%2] \n" \ - " cbnz %w1, 1b \n" \ - "2:" \ - : "=&r"(tmp), "=&r"(res) \ - : "r" (p), "r" (cmpval), "r" (newval) \ - : "cc", "memory" \ + "1: ldxr %"#w"1, [%2]\n" \ + " stxr %w0, "#zreg", [%2]\n" \ + " cbnz %w0, 1b\n" \ + : "=&r" (res), "=&r" (ret) \ + : "r" (p) \ + : "memory" \ ); \ \ - return (!res); \ + return (ret); \ +} \ + \ +_ATOMIC_READANDCLEAR_PROTO(t, _lse) \ +{ \ + return (atomic_swap_##t##_lse(p, 0)); \ +} \ + \ +_ATOMIC_READANDCLEAR_PROTO(t, ) \ +{ \ + if (_ATOMIC_LSE_SUPPORTED) \ + return (atomic_readandclear_##t##_lse(p)); \ + else \ + return (atomic_readandclear_##t##_llsc(p)); \ } -ATOMIC_CMPSET( , , ) -ATOMIC_CMPSET(acq_, a, ) -ATOMIC_CMPSET(rel_, ,l) +_ATOMIC_SWAP_IMPL(32, w, wzr) +_ATOMIC_SWAP_IMPL(64, , xzr) -static __inline uint32_t -atomic_fetchadd_32(volatile uint32_t *p, uint32_t val) -{ - uint32_t tmp, ret; - int res; +#define _ATOMIC_TEST_OP_PROTO(t, op, flav) \ +static __inline int \ +atomic_testand##op##_##t##flav(volatile uint##t##_t *p, u_int val) - __asm __volatile( - "1: ldxr %w2, [%3] \n" - " add %w0, %w2, %w4 \n" - " stxr %w1, %w0, [%3] \n" - " cbnz %w1, 1b \n" - : "=&r"(tmp), "=&r"(res), "=&r"(ret) - : "r" (p), "r" (val) - : "memory" - ); - - return (ret); +#define _ATOMIC_TEST_OP_IMPL(t, w, op, llsc_asm_op, lse_asm_op) \ +_ATOMIC_TEST_OP_PROTO(t, op, _llsc) \ +{ \ + uint##t##_t mask, old, tmp; \ + int res; \ + \ + mask = 1u << (val & 0x1f); \ + __asm __volatile( \ + "1: ldxr %"#w"2, [%3]\n" \ + " "#llsc_asm_op" %"#w"0, %"#w"2, %"#w"4\n" \ + " stxr %w1, %"#w"0, [%3]\n" \ + " cbnz %w1, 1b\n" \ + : "=&r" (tmp), "=&r" (res), "=&r" (old) \ + : "r" (p), "r" (mask) \ + : "memory" \ + ); \ + \ + return ((old & mask) != 0); \ +} \ + \ +_ATOMIC_TEST_OP_PROTO(t, op, _lse) \ +{ \ + uint##t##_t mask, old; \ + \ + mask = 1u << (val & 0x1f); \ + __asm __volatile( \ + ".arch_extension lse\n" \ + "ld"#lse_asm_op" %"#w"2, %"#w"0, [%1]\n" \ + ".arch_extension nolse\n" \ + : "=r" (old) \ + : "r" (p), "r" (mask) \ + : "memory" \ + ); \ + \ + return ((old & mask) != 0); \ +} \ + \ +_ATOMIC_TEST_OP_PROTO(t, op, ) \ +{ \ + if (_ATOMIC_LSE_SUPPORTED) \ + return (atomic_testand##op##_##t##_lse(p, val)); \ + else \ + return (atomic_testand##op##_##t##_llsc(p, val)); \ } -static __inline uint64_t -atomic_fetchadd_64(volatile uint64_t *p, uint64_t val) -{ - uint64_t tmp, ret; - int res; +#define _ATOMIC_TEST_OP(op, llsc_asm_op, lse_asm_op) \ + _ATOMIC_TEST_OP_IMPL(32, w, op, llsc_asm_op, lse_asm_op) \ + _ATOMIC_TEST_OP_IMPL(64, , op, llsc_asm_op, lse_asm_op) - __asm __volatile( - "1: ldxr %2, [%3] \n" - " add %0, %2, %4 \n" - " stxr %w1, %0, [%3] \n" - " cbnz %w1, 1b \n" - : "=&r"(tmp), "=&r"(res), "=&r"(ret) - : "r" (p), "r" (val) - : "memory" - ); +_ATOMIC_TEST_OP(clear, bic, clr) +_ATOMIC_TEST_OP(set, orr, set) - return (ret); +#define _ATOMIC_LOAD_ACQ_IMPL(t, w, s) \ +static __inline uint##t##_t \ +atomic_load_acq_##t(volatile uint##t##_t *p) \ +{ \ + uint##t##_t ret; \ + \ + __asm __volatile( \ + "ldar"#s" %"#w"0, [%1]\n" \ + : "=&r" (ret) \ + : "r" (p) \ + : "memory"); \ + \ + return (ret); \ } -static __inline uint32_t -atomic_readandclear_32(volatile uint32_t *p) -{ - uint32_t ret; - int res; +_ATOMIC_LOAD_ACQ_IMPL(8, w, b) +_ATOMIC_LOAD_ACQ_IMPL(16, w, h) +_ATOMIC_LOAD_ACQ_IMPL(32, w, ) +_ATOMIC_LOAD_ACQ_IMPL(64, , ) - __asm __volatile( - "1: ldxr %w1, [%2] \n" - " stxr %w0, wzr, [%2] \n" - " cbnz %w0, 1b \n" - : "=&r"(res), "=&r"(ret) - : "r" (p) - : "memory" - ); - - return (ret); -} - -static __inline uint64_t -atomic_readandclear_64(volatile uint64_t *p) -{ - uint64_t ret; - int res; - - __asm __volatile( - "1: ldxr %1, [%2] \n" - " stxr %w0, xzr, [%2] \n" - " cbnz %w0, 1b \n" - : "=&r"(res), "=&r"(ret) - : "r" (p) - : "memory" - ); - - return (ret); -} - -static __inline uint32_t -atomic_swap_32(volatile uint32_t *p, uint32_t val) -{ - uint32_t ret; - int res; - - __asm __volatile( - "1: ldxr %w0, [%2] \n" - " stxr %w1, %w3, [%2] \n" - " cbnz %w1, 1b \n" - : "=&r"(ret), "=&r"(res) - : "r" (p), "r" (val) - : "memory" - ); - - return (ret); -} - -static __inline uint64_t -atomic_swap_64(volatile uint64_t *p, uint64_t val) -{ - uint64_t ret; - int res; - - __asm __volatile( - "1: ldxr %0, [%2] \n" - " stxr %w1, %3, [%2] \n" - " cbnz %w1, 1b \n" - : "=&r"(ret), "=&r"(res) - : "r" (p), "r" (val) - : "memory" - ); - - return (ret); -} - -static __inline uint8_t -atomic_load_acq_8(volatile uint8_t *p) -{ - uint8_t ret; - - __asm __volatile( - "ldarb %w0, [%1] \n" - : "=&r" (ret) - : "r" (p) - : "memory"); - - return (ret); -} - -static __inline uint16_t -atomic_load_acq_16(volatile uint16_t *p) -{ - uint16_t ret; - - __asm __volatile( - "ldarh %w0, [%1] \n" - : "=&r" (ret) - : "r" (p) - : "memory"); - - return (ret); -} - -static __inline uint32_t -atomic_load_acq_32(volatile uint32_t *p) -{ - uint32_t ret; - - __asm __volatile( - "ldar %w0, [%1] \n" - : "=&r" (ret) - : "r" (p) - : "memory"); - - return (ret); -} - -static __inline uint64_t -atomic_load_acq_64(volatile uint64_t *p) -{ - uint64_t ret; - - __asm __volatile( - "ldar %0, [%1] \n" - : "=&r" (ret) - : "r" (p) - : "memory"); - - return (ret); -} - -static __inline void -atomic_store_rel_8(volatile uint8_t *p, uint8_t val) -{ - - __asm __volatile( - "stlrb %w0, [%1] \n" - : - : "r" (val), "r" (p) - : "memory"); -} - -static __inline void -atomic_store_rel_16(volatile uint16_t *p, uint16_t val) -{ - - __asm __volatile( - "stlrh %w0, [%1] \n" - : - : "r" (val), "r" (p) - : "memory"); -} - -static __inline void -atomic_store_rel_32(volatile uint32_t *p, uint32_t val) -{ - - __asm __volatile( - "stlr %w0, [%1] \n" - : - : "r" (val), "r" (p) - : "memory"); -} - -static __inline void -atomic_store_rel_64(volatile uint64_t *p, uint64_t val) -{ - - __asm __volatile( - "stlr %0, [%1] \n" - : - : "r" (val), "r" (p) - : "memory"); -} - -static __inline int -atomic_testandclear_32(volatile uint32_t *p, u_int val) -{ - uint32_t mask, old, tmp; - int res; - - mask = 1u << (val & 0x1f); - __asm __volatile( - "1: ldxr %w2, [%3] \n" - " bic %w0, %w2, %w4 \n" - " stxr %w1, %w0, [%3] \n" - " cbnz %w1, 1b \n" - : "=&r"(tmp), "=&r"(res), "=&r"(old) - : "r" (p), "r" (mask) - : "memory" - ); - - return ((old & mask) != 0); -} - -static __inline int -atomic_testandclear_64(volatile uint64_t *p, u_int val) -{ - uint64_t mask, old, tmp; - int res; - - mask = 1ul << (val & 0x1f); - __asm __volatile( - "1: ldxr %2, [%3] \n" - " bic %0, %2, %4 \n" - " stxr %w1, %0, [%3] \n" - " cbnz %w1, 1b \n" - : "=&r"(tmp), "=&r"(res), "=&r"(old) - : "r" (p), "r" (mask) - : "memory" - ); - - return ((old & mask) != 0); -} - -static __inline int -atomic_testandset_32(volatile uint32_t *p, u_int val) -{ - uint32_t mask, old, tmp; - int res; - - mask = 1u << (val & 0x1f); - __asm __volatile( - "1: ldxr %w2, [%3] \n" - " orr %w0, %w2, %w4 \n" - " stxr %w1, %w0, [%3] \n" - " cbnz %w1, 1b \n" - : "=&r"(tmp), "=&r"(res), "=&r"(old) - : "r" (p), "r" (mask) - : "memory" - ); - - return ((old & mask) != 0); -} - -static __inline int -atomic_testandset_64(volatile uint64_t *p, u_int val) -{ - uint64_t mask, old, tmp; - int res; - - mask = 1ul << (val & 0x1f); - __asm __volatile( - "1: ldxr %2, [%3] \n" - " orr %0, %2, %4 \n" - " stxr %w1, %0, [%3] \n" - " cbnz %w1, 1b \n" - : "=&r"(tmp), "=&r"(res), "=&r"(old) - : "r" (p), "r" (mask) - : "memory" - ); - - return ((old & mask) != 0); +#define _ATOMIC_STORE_REL_IMPL(t, w, s) \ +static __inline void \ +atomic_store_rel_##t(volatile uint##t##_t *p, uint##t##_t val) \ +{ \ + __asm __volatile( \ + "stlr"#s" %"#w"0, [%1]\n" \ + : \ + : "r" (val), "r" (p) \ + : "memory"); \ } +_ATOMIC_STORE_REL_IMPL(8, w, b) +_ATOMIC_STORE_REL_IMPL(16, w, h) +_ATOMIC_STORE_REL_IMPL(32, w, ) +_ATOMIC_STORE_REL_IMPL(64, , ) #define atomic_add_int atomic_add_32 #define atomic_fcmpset_int atomic_fcmpset_32 @@ -740,6 +597,4 @@ atomic_thread_fence_seq_cst(void) } #endif /* KCSAN && !KCSAN_RUNTIME */ - #endif /* _MACHINE_ATOMIC_H_ */ - diff --git a/sys/arm64/include/param.h b/sys/arm64/include/param.h index 63c603bed3ed..1164965ca12f 100644 --- a/sys/arm64/include/param.h +++ b/sys/arm64/include/param.h @@ -54,13 +54,13 @@ #define MACHINE_ARCH32 "armv7" #endif -#if defined(SMP) || defined(KLD_MODULE) +#ifdef SMP #ifndef MAXCPU #define MAXCPU 256 #endif #else #define MAXCPU 1 -#endif /* SMP || KLD_MODULE */ +#endif #ifndef MAXMEMDOM #define MAXMEMDOM 2 diff --git a/sys/arm64/linux/linux_dummy.c b/sys/arm64/linux/linux_dummy.c index 3b11c86b66ad..9f388d41c8c8 100644 --- a/sys/arm64/linux/linux_dummy.c +++ b/sys/arm64/linux/linux_dummy.c @@ -64,7 +64,6 @@ UNIMPLEMENTED(tuxcall); UNIMPLEMENTED(uselib); UNIMPLEMENTED(vserver); -DUMMY(sendfile); DUMMY(setfsuid); DUMMY(setfsgid); DUMMY(vhangup); diff --git a/sys/cam/ata/ata_da.c b/sys/cam/ata/ata_da.c index 39b8bc77c70f..fd8bb6e427f6 100644 --- a/sys/cam/ata/ata_da.c +++ b/sys/cam/ata/ata_da.c @@ -2430,6 +2430,10 @@ adastart(struct cam_periph *periph, union ccb *start_ccb) } break; } + default: + biofinish(bp, NULL, EOPNOTSUPP); + xpt_release_ccb(start_ccb); + return; } start_ccb->ccb_h.ccb_state = ADA_CCB_BUFFER_IO; start_ccb->ccb_h.flags |= CAM_UNLOCKED; diff --git a/sys/cam/cam_xpt.c b/sys/cam/cam_xpt.c index e58209300088..6ab6e94e8e38 100644 --- a/sys/cam/cam_xpt.c +++ b/sys/cam/cam_xpt.c @@ -2716,17 +2716,6 @@ xpt_action_default(union ccb *start_ccb) start_ccb->ccb_h.status = CAM_REQ_CMP; break; } -#if defined(__sparc64__) - /* - * For sparc64, we may need adjust the geometry of large - * disks in order to fit the limitations of the 16-bit - * fields of the VTOC8 disk label. - */ - if (scsi_da_bios_params(&start_ccb->ccg) != 0) { - start_ccb->ccb_h.status = CAM_REQ_CMP; - break; - } -#endif goto call_sim; case XPT_ABORT: { diff --git a/sys/cam/mmc/mmc_da.c b/sys/cam/mmc/mmc_da.c index b5f8a106c679..1132bf8ba86d 100644 --- a/sys/cam/mmc/mmc_da.c +++ b/sys/cam/mmc/mmc_da.c @@ -1834,6 +1834,10 @@ sddastart(struct cam_periph *periph, union ccb *start_ccb) CAM_DEBUG(periph->path, CAM_DEBUG_TRACE, ("BIO_DELETE\n")); sddaschedule(periph); break; + default: + biofinish(bp, NULL, EOPNOTSUPP); + xpt_release_ccb(start_ccb); + return; } start_ccb->ccb_h.ccb_bp = bp; softc->outstanding_cmds++; diff --git a/sys/cam/nvme/nvme_da.c b/sys/cam/nvme/nvme_da.c index b17983eff541..1af306206637 100644 --- a/sys/cam/nvme/nvme_da.c +++ b/sys/cam/nvme/nvme_da.c @@ -994,6 +994,11 @@ ndastart(struct cam_periph *periph, union ccb *start_ccb) case BIO_FLUSH: nda_nvme_flush(softc, nvmeio); break; + default: + biofinish(bp, NULL, EOPNOTSUPP); + xpt_release_ccb(start_ccb); + ndaschedule(periph); + return; } start_ccb->ccb_state = NDA_CCB_BUFFER_IO; start_ccb->ccb_bp = bp; diff --git a/sys/cam/scsi/scsi_cd.c b/sys/cam/scsi/scsi_cd.c index 8b8a7e9e164d..ea178f9314ce 100644 --- a/sys/cam/scsi/scsi_cd.c +++ b/sys/cam/scsi/scsi_cd.c @@ -927,6 +927,13 @@ cdstart(struct cam_periph *periph, union ccb *start_ccb) } bioq_remove(&softc->bio_queue, bp); + if ((bp->bio_cmd != BIO_READ) && + (bp->bio_cmd != BIO_WRITE)) { + biofinish(bp, NULL, EOPNOTSUPP); + xpt_release_ccb(start_ccb); + return; + } + scsi_read_write(&start_ccb->csio, /*retries*/ cd_retry_count, /* cbfcnp */ cddone, diff --git a/sys/cam/scsi/scsi_da.c b/sys/cam/scsi/scsi_da.c index d4d85016e298..cadc438b60e0 100644 --- a/sys/cam/scsi/scsi_da.c +++ b/sys/cam/scsi/scsi_da.c @@ -3381,6 +3381,10 @@ dastart(struct cam_periph *periph, union ccb *start_ccb) } break; } + default: + biofinish(bp, NULL, EOPNOTSUPP); + xpt_release_ccb(start_ccb); + return; } start_ccb->ccb_h.ccb_state = DA_CCB_BUFFER_IO; start_ccb->ccb_h.flags |= CAM_UNLOCKED; diff --git a/sys/cam/scsi/scsi_sa.c b/sys/cam/scsi/scsi_sa.c index 4b71a4179efc..dbe81d758be0 100644 --- a/sys/cam/scsi/scsi_sa.c +++ b/sys/cam/scsi/scsi_sa.c @@ -2683,6 +2683,12 @@ sastart(struct cam_periph *periph, union ccb *start_ccb) bioq_remove(&softc->bio_queue, bp); softc->queue_count--; + if ((bp->bio_cmd != BIO_READ) && + (bp->bio_cmd != BIO_WRITE)) { + biofinish(bp, NULL, EOPNOTSUPP); + xpt_release_ccb(start_ccb); + return; + } length = bp->bio_bcount; if ((softc->flags & SA_FLAG_FIXED) != 0) { diff --git a/sys/cddl/boot/zfs/zfsimpl.h b/sys/cddl/boot/zfs/zfsimpl.h index 4f3d8e69b2aa..65b5bcfbf90d 100644 --- a/sys/cddl/boot/zfs/zfsimpl.h +++ b/sys/cddl/boot/zfs/zfsimpl.h @@ -1174,7 +1174,7 @@ typedef enum dmu_objset_type { DMU_OST_NUMTYPES } dmu_objset_type_t; -#define ZAP_MAXVALUELEN (1024 * 8) +#define ZAP_MAXVALUELEN (1024 * 8) /* * header for all bonus and spill buffers. @@ -1333,8 +1333,7 @@ typedef struct dsl_dataset_phys { #define ZAP_HASHBITS 28 #define MZAP_ENT_LEN 64 #define MZAP_NAME_LEN (MZAP_ENT_LEN - 8 - 4 - 2) -#define MZAP_MAX_BLKSHIFT SPA_MAXBLOCKSHIFT -#define MZAP_MAX_BLKSZ (1 << MZAP_MAX_BLKSHIFT) +#define MZAP_MAX_BLKSZ SPA_OLD_MAXBLOCKSIZE typedef struct mzap_ent_phys { uint64_t mze_value; @@ -1346,7 +1345,8 @@ typedef struct mzap_ent_phys { typedef struct mzap_phys { uint64_t mz_block_type; /* ZBT_MICRO */ uint64_t mz_salt; - uint64_t mz_pad[6]; + uint64_t mz_normflags; + uint64_t mz_pad[5]; mzap_ent_phys_t mz_chunk[1]; /* actually variable size depending on block size */ } mzap_phys_t; @@ -1403,6 +1403,8 @@ typedef struct zap_phys { uint64_t zap_num_leafs; /* number of leafs */ uint64_t zap_num_entries; /* number of entries */ uint64_t zap_salt; /* salt to stir into hash function */ + uint64_t zap_normflags; /* flags for u8_textprep_str() */ + uint64_t zap_flags; /* zap_flags_t */ /* * This structure is followed by padding, and then the embedded * pointer table. The embedded pointer table takes up second @@ -1413,9 +1415,12 @@ typedef struct zap_phys { typedef struct zap_table_phys zap_table_phys_t; +struct spa; typedef struct fat_zap { int zap_block_shift; /* block size shift */ zap_phys_t *zap_phys; + const struct spa *zap_spa; + const dnode_phys_t *zap_dnode; } fat_zap_t; #define ZAP_LEAF_MAGIC 0x2AB1EAF diff --git a/sys/cddl/compat/opensolaris/kern/opensolaris_vm.c b/sys/cddl/compat/opensolaris/kern/opensolaris_vm.c index fe444ecc2873..fcfc28861925 100644 --- a/sys/cddl/compat/opensolaris/kern/opensolaris_vm.c +++ b/sys/cddl/compat/opensolaris/kern/opensolaris_vm.c @@ -28,6 +28,7 @@ __FBSDID("$FreeBSD$"); #include +#include #include #include diff --git a/sys/cddl/compat/opensolaris/sys/atomic.h b/sys/cddl/compat/opensolaris/sys/atomic.h index b3a2f393afa4..674ca5b1ff24 100644 --- a/sys/cddl/compat/opensolaris/sys/atomic.h +++ b/sys/cddl/compat/opensolaris/sys/atomic.h @@ -91,7 +91,6 @@ atomic_dec_32_nv(volatile uint32_t *target) return (atomic_add_32_nv(target, -1)); } -#ifndef __sparc64__ static inline uint32_t atomic_cas_32(volatile uint32_t *target, uint32_t cmp, uint32_t newval) { @@ -107,7 +106,6 @@ atomic_cas_32(volatile uint32_t *target, uint32_t cmp, uint32_t newval) #endif return (cmp); } -#endif #if defined(__LP64__) || defined(__mips_n32) || \ defined(ARM_HAVE_ATOMIC64) || defined(I386_HAVE_ATOMIC64) || \ @@ -124,7 +122,6 @@ atomic_add_64_nv(volatile uint64_t *target, int64_t delta) return (atomic_fetchadd_64(target, delta) + delta); } -#ifndef __sparc64__ static inline uint64_t atomic_cas_64(volatile uint64_t *target, uint64_t cmp, uint64_t newval) { @@ -141,7 +138,6 @@ atomic_cas_64(volatile uint64_t *target, uint64_t cmp, uint64_t newval) return (cmp); } #endif -#endif static __inline void atomic_inc_64(volatile uint64_t *target) diff --git a/sys/cddl/contrib/opensolaris/common/lz4/lz4.c b/sys/cddl/contrib/opensolaris/common/lz4/lz4.c index 3a875565f4b4..ee7f1fbe99e2 100644 --- a/sys/cddl/contrib/opensolaris/common/lz4/lz4.c +++ b/sys/cddl/contrib/opensolaris/common/lz4/lz4.c @@ -245,16 +245,6 @@ lz4_decompress(void *s_start, void *d_start, size_t s_len, size_t d_len, #define LZ4_FORCE_UNALIGNED_ACCESS 1 #endif -/* - * FreeBSD: can't use GCC's __builtin_ctz when using sparc64 because - * gcc currently rely on libcompiler_rt. - * - * TODO: revisit this when situation changes. - */ -#if defined(__sparc64__) -#define LZ4_FORCE_SW_BITCOUNT -#endif - /* * Compiler Options */ diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/aggsum.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/aggsum.c index c4e78e2a6d37..713ff2b0116c 100644 --- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/aggsum.c +++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/aggsum.c @@ -125,13 +125,11 @@ aggsum_flush_bucket(aggsum_t *as, struct aggsum_bucket *asb) * We use atomic instructions for this because we read the upper and * lower bounds without the lock, so we need stores to be atomic. */ - atomic_add_64((volatile uint64_t *)&as->as_lower_bound, asb->asc_delta); - atomic_add_64((volatile uint64_t *)&as->as_upper_bound, asb->asc_delta); - asb->asc_delta = 0; - atomic_add_64((volatile uint64_t *)&as->as_upper_bound, - -asb->asc_borrowed); atomic_add_64((volatile uint64_t *)&as->as_lower_bound, - asb->asc_borrowed); + asb->asc_delta + asb->asc_borrowed); + atomic_add_64((volatile uint64_t *)&as->as_upper_bound, + asb->asc_delta - asb->asc_borrowed); + asb->asc_delta = 0; asb->asc_borrowed = 0; } @@ -163,40 +161,43 @@ aggsum_value(aggsum_t *as) return (rv); } -static void -aggsum_borrow(aggsum_t *as, int64_t delta, struct aggsum_bucket *asb) -{ - int64_t abs_delta = (delta < 0 ? -delta : delta); - mutex_enter(&as->as_lock); - mutex_enter(&asb->asc_lock); - - aggsum_flush_bucket(as, asb); - - atomic_add_64((volatile uint64_t *)&as->as_upper_bound, abs_delta); - atomic_add_64((volatile uint64_t *)&as->as_lower_bound, -abs_delta); - asb->asc_borrowed = abs_delta; - - mutex_exit(&asb->asc_lock); - mutex_exit(&as->as_lock); -} - void aggsum_add(aggsum_t *as, int64_t delta) { struct aggsum_bucket *asb = &as->as_buckets[CPU_SEQID % as->as_numbuckets]; + int64_t borrow; - for (;;) { - mutex_enter(&asb->asc_lock); - if (asb->asc_delta + delta <= (int64_t)asb->asc_borrowed && - asb->asc_delta + delta >= -(int64_t)asb->asc_borrowed) { - asb->asc_delta += delta; - mutex_exit(&asb->asc_lock); - return; - } + /* Try fast path if we already borrowed enough before. */ + mutex_enter(&asb->asc_lock); + if (asb->asc_delta + delta <= (int64_t)asb->asc_borrowed && + asb->asc_delta + delta >= -(int64_t)asb->asc_borrowed) { + asb->asc_delta += delta; mutex_exit(&asb->asc_lock); - aggsum_borrow(as, delta * aggsum_borrow_multiplier, asb); + return; } + mutex_exit(&asb->asc_lock); + + /* + * We haven't borrowed enough. Take the global lock and borrow + * considering what is requested now and what we borrowed before. + */ + borrow = (delta < 0 ? -delta : delta) * aggsum_borrow_multiplier; + mutex_enter(&as->as_lock); + mutex_enter(&asb->asc_lock); + delta += asb->asc_delta; + asb->asc_delta = 0; + if (borrow >= asb->asc_borrowed) + borrow -= asb->asc_borrowed; + else + borrow = (borrow - (int64_t)asb->asc_borrowed) / 4; + asb->asc_borrowed += borrow; + atomic_add_64((volatile uint64_t *)&as->as_lower_bound, + delta - borrow); + atomic_add_64((volatile uint64_t *)&as->as_upper_bound, + delta + borrow); + mutex_exit(&asb->asc_lock); + mutex_exit(&as->as_lock); } /* diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dbuf.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dbuf.c index 2d1d72096eec..651fd3897132 100644 --- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dbuf.c +++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dbuf.c @@ -670,13 +670,6 @@ dbuf_cache_lowater_bytes(void) (dbuf_cache_target * dbuf_cache_lowater_pct) / 100); } -static inline boolean_t -dbuf_cache_above_hiwater(void) -{ - return (zfs_refcount_count(&dbuf_caches[DB_DBUF_CACHE].size) > - dbuf_cache_hiwater_bytes()); -} - static inline boolean_t dbuf_cache_above_lowater(void) { @@ -717,8 +710,6 @@ dbuf_evict_one(void) ASSERT3U(db->db_caching_status, ==, DB_DBUF_CACHE); db->db_caching_status = DB_NO_CACHE; dbuf_destroy(db); - DBUF_STAT_MAX(cache_size_bytes_max, - zfs_refcount_count(&dbuf_caches[DB_DBUF_CACHE].size)); DBUF_STAT_BUMP(cache_total_evicts); } else { multilist_sublist_unlock(mls); @@ -747,6 +738,10 @@ dbuf_evict_thread(void *unused __unused) (void) cv_timedwait_hires(&dbuf_evict_cv, &dbuf_evict_lock, SEC2NSEC(1), MSEC2NSEC(1), 0); CALLB_CPR_SAFE_END(&cpr, &dbuf_evict_lock); +#ifdef __FreeBSD__ + if (dbuf_ksp != NULL) + dbuf_ksp->ks_update(dbuf_ksp, KSTAT_READ); +#endif } mutex_exit(&dbuf_evict_lock); @@ -774,16 +769,15 @@ dbuf_evict_thread(void *unused __unused) * dbuf cache using the callers context. */ static void -dbuf_evict_notify(void) +dbuf_evict_notify(uint64_t size) { /* * We check if we should evict without holding the dbuf_evict_lock, * because it's OK to occasionally make the wrong decision here, * and grabbing the lock results in massive lock contention. */ - if (zfs_refcount_count(&dbuf_caches[DB_DBUF_CACHE].size) > - dbuf_cache_max_bytes) { - if (dbuf_cache_above_hiwater()) + if (size > dbuf_cache_max_bytes) { + if (size > dbuf_cache_hiwater_bytes()) dbuf_evict_one(); cv_signal(&dbuf_evict_cv); } @@ -880,18 +874,10 @@ dbuf_init(void) dbuf_cache_evict_thread = thread_create(NULL, 0, dbuf_evict_thread, NULL, 0, &p0, TS_RUN, minclsyspri); -#ifdef __linux__ - /* - * XXX FreeBSD's SPL lacks KSTAT_TYPE_NAMED support - TODO - */ dbuf_ksp = kstat_create("zfs", 0, "dbufstats", "misc", KSTAT_TYPE_NAMED, sizeof (dbuf_stats) / sizeof (kstat_named_t), KSTAT_FLAG_VIRTUAL); if (dbuf_ksp != NULL) { - dbuf_ksp->ks_data = &dbuf_stats; - dbuf_ksp->ks_update = dbuf_kstat_update; - kstat_install(dbuf_ksp); - for (i = 0; i < DN_MAX_LEVELS; i++) { snprintf(dbuf_stats.cache_levels[i].name, KSTAT_STRLEN, "cache_level_%d", i); @@ -902,8 +888,10 @@ dbuf_init(void) dbuf_stats.cache_levels_bytes[i].data_type = KSTAT_DATA_UINT64; } + dbuf_ksp->ks_data = &dbuf_stats; + dbuf_ksp->ks_update = dbuf_kstat_update; + kstat_install(dbuf_ksp); } -#endif } void @@ -2387,7 +2375,6 @@ dbuf_destroy(dmu_buf_impl_t *db) if (needlock) mutex_enter(&dn->dn_dbufs_mtx); avl_remove(&dn->dn_dbufs, db); - atomic_dec_32(&dn->dn_dbufs_count); membar_producer(); DB_DNODE_EXIT(db); if (needlock) @@ -2612,7 +2599,6 @@ dbuf_create(dnode_t *dn, uint8_t level, uint64_t blkid, ASSERT(dn->dn_object == DMU_META_DNODE_OBJECT || zfs_refcount_count(&dn->dn_holds) > 0); (void) zfs_refcount_add(&dn->dn_holds, db); - atomic_inc_32(&dn->dn_dbufs_count); dprintf_dbuf(db, "db=%p\n", db); @@ -3188,6 +3174,7 @@ void dbuf_rele_and_unlock(dmu_buf_impl_t *db, void *tag, boolean_t evicting) { int64_t holds; + uint64_t size; ASSERT(MUTEX_HELD(&db->db_mtx)); DBUF_VERIFY(db); @@ -3284,15 +3271,14 @@ dbuf_rele_and_unlock(dmu_buf_impl_t *db, void *tag, boolean_t evicting) db->db_caching_status = dcs; multilist_insert(dbuf_caches[dcs].cache, db); - (void) zfs_refcount_add_many( + size = zfs_refcount_add_many( &dbuf_caches[dcs].size, db->db.db_size, db); if (dcs == DB_DBUF_METADATA_CACHE) { DBUF_STAT_BUMP(metadata_cache_count); DBUF_STAT_MAX( metadata_cache_size_bytes_max, - zfs_refcount_count( - &dbuf_caches[dcs].size)); + size); } else { DBUF_STAT_BUMP( cache_levels[db->db_level]); @@ -3301,15 +3287,12 @@ dbuf_rele_and_unlock(dmu_buf_impl_t *db, void *tag, boolean_t evicting) cache_levels_bytes[db->db_level], db->db.db_size); DBUF_STAT_MAX(cache_size_bytes_max, - zfs_refcount_count( - &dbuf_caches[dcs].size)); + size); } mutex_exit(&db->db_mtx); - if (db->db_caching_status == DB_DBUF_CACHE && - !evicting) { - dbuf_evict_notify(); - } + if (dcs == DB_DBUF_CACHE && !evicting) + dbuf_evict_notify(size); } if (do_arc_evict) diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dnode.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dnode.c index 7ab1c14eb1ec..50a7338fb9e8 100644 --- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dnode.c +++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dnode.c @@ -998,7 +998,7 @@ dnode_move(void *buf, void *newbuf, size_t size, void *arg) */ refcount = zfs_refcount_count(&odn->dn_holds); ASSERT(refcount >= 0); - dbufs = odn->dn_dbufs_count; + dbufs = DN_DBUFS_COUNT(odn); /* We can't have more dbufs than dnode holds. */ ASSERT3U(dbufs, <=, refcount); @@ -1025,7 +1025,7 @@ dnode_move(void *buf, void *newbuf, size_t size, void *arg) list_link_replace(&odn->dn_link, &ndn->dn_link); /* If the dnode was safe to move, the refcount cannot have changed. */ ASSERT(refcount == zfs_refcount_count(&ndn->dn_holds)); - ASSERT(dbufs == ndn->dn_dbufs_count); + ASSERT(dbufs == DN_DBUFS_COUNT(ndn)); zrl_exit(&ndn->dn_handle->dnh_zrlock); /* handle has moved */ mutex_exit(&os->os_lock); diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/aggsum.h b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/aggsum.h index 4d64e05a1adf..2ae0835e55a2 100644 --- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/aggsum.h +++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/aggsum.h @@ -39,7 +39,7 @@ typedef struct aggsum { kmutex_t as_lock; int64_t as_lower_bound; int64_t as_upper_bound; - uint64_t as_numbuckets; + uint_t as_numbuckets; aggsum_bucket_t *as_buckets; } aggsum_t; diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dbuf.h b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dbuf.h index 40d3878ee384..4b1a9e11b165 100644 --- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dbuf.h +++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dbuf.h @@ -189,6 +189,13 @@ typedef struct dmu_buf_impl { */ struct dmu_buf_impl *db_hash_next; + /* + * Our link on the owner dnodes's dn_dbufs list. + * Protected by its dn_dbufs_mtx. Should be on the same cache line + * as db_level and db_blkid for the best avl_add() performance. + */ + avl_node_t db_link; + /* our block number */ uint64_t db_blkid; @@ -230,12 +237,6 @@ typedef struct dmu_buf_impl { /* pointer to most recent dirty record for this buffer */ dbuf_dirty_record_t *db_last_dirty; - /* - * Our link on the owner dnodes's dn_dbufs list. - * Protected by its dn_dbufs_mtx. - */ - avl_node_t db_link; - /* Link in dbuf_cache or dbuf_metadata_cache */ multilist_node_t db_cache_link; diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dnode.h b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dnode.h index 7602a093bac2..b1a8547013c5 100644 --- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dnode.h +++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dnode.h @@ -345,6 +345,13 @@ struct dnode { struct zfetch dn_zfetch; }; +/* + * Since AVL already has embedded element counter, use dn_dbufs_count + * only for dbufs not counted there (bonus buffers) and just add them. + */ +#define DN_DBUFS_COUNT(dn) ((dn)->dn_dbufs_count + \ + avl_numnodes(&(dn)->dn_dbufs)) + /* * Adds a level of indirection between the dbuf and the dnode to avoid * iterating descendent dbufs in dnode_move(). Handles are not allocated diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c index 61cf98a39cad..26cce46bc92e 100644 --- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c +++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c @@ -1470,7 +1470,7 @@ zfs_lookup_lock(vnode_t *dvp, vnode_t *vp, const char *name, int lkflags) /* ARGSUSED */ static int zfs_lookup(vnode_t *dvp, char *nm, vnode_t **vpp, struct componentname *cnp, - int nameiop, cred_t *cr, kthread_t *td, int flags) + int nameiop, cred_t *cr, kthread_t *td, int flags, boolean_t cached) { znode_t *zdp = VTOZ(dvp); znode_t *zp; @@ -1542,9 +1542,16 @@ zfs_lookup(vnode_t *dvp, char *nm, vnode_t **vpp, struct componentname *cnp, /* * Check accessibility of directory. */ - if (error = zfs_zaccess(zdp, ACE_EXECUTE, 0, B_FALSE, cr)) { - ZFS_EXIT(zfsvfs); - return (error); + if (!cached) { + if ((cnp->cn_flags & NOEXECCHECK) != 0) { + cnp->cn_flags &= ~NOEXECCHECK; + } else { + error = zfs_zaccess(zdp, ACE_EXECUTE, 0, B_FALSE, cr); + if (error != 0) { + ZFS_EXIT(zfsvfs); + return (error); + } + } } if (zfsvfs->z_utf8 && u8_validate(nm, strlen(nm), @@ -4894,12 +4901,7 @@ zfs_freebsd_access(ap) } static int -zfs_freebsd_lookup(ap) - struct vop_lookup_args /* { - struct vnode *a_dvp; - struct vnode **a_vpp; - struct componentname *a_cnp; - } */ *ap; +zfs_freebsd_lookup(struct vop_lookup_args *ap, boolean_t cached) { struct componentname *cnp = ap->a_cnp; char nm[NAME_MAX + 1]; @@ -4908,7 +4910,14 @@ zfs_freebsd_lookup(ap) strlcpy(nm, cnp->cn_nameptr, MIN(cnp->cn_namelen + 1, sizeof(nm))); return (zfs_lookup(ap->a_dvp, nm, ap->a_vpp, cnp, cnp->cn_nameiop, - cnp->cn_cred, cnp->cn_thread, 0)); + cnp->cn_cred, cnp->cn_thread, 0, cached)); +} + +static int +zfs_freebsd_cachedlookup(struct vop_cachedlookup_args *ap) +{ + + return (zfs_freebsd_lookup((struct vop_lookup_args *)ap, B_TRUE)); } static int @@ -4925,7 +4934,7 @@ zfs_cache_lookup(ap) if (zfsvfs->z_use_namecache) return (vfs_cache_lookup(ap)); else - return (zfs_freebsd_lookup(ap)); + return (zfs_freebsd_lookup(ap, B_FALSE)); } static int @@ -5507,7 +5516,7 @@ vop_getextattr { ZFS_ENTER(zfsvfs); error = zfs_lookup(ap->a_vp, NULL, &xvp, NULL, 0, ap->a_cred, td, - LOOKUP_XATTR); + LOOKUP_XATTR, B_FALSE); if (error != 0) { ZFS_EXIT(zfsvfs); return (error); @@ -5576,7 +5585,7 @@ vop_deleteextattr { ZFS_ENTER(zfsvfs); error = zfs_lookup(ap->a_vp, NULL, &xvp, NULL, 0, ap->a_cred, td, - LOOKUP_XATTR); + LOOKUP_XATTR, B_FALSE); if (error != 0) { ZFS_EXIT(zfsvfs); return (error); @@ -5644,7 +5653,7 @@ vop_setextattr { ZFS_ENTER(zfsvfs); error = zfs_lookup(ap->a_vp, NULL, &xvp, NULL, 0, ap->a_cred, td, - LOOKUP_XATTR | CREATE_XATTR_DIR); + LOOKUP_XATTR | CREATE_XATTR_DIR, B_FALSE); if (error != 0) { ZFS_EXIT(zfsvfs); return (error); @@ -5721,7 +5730,7 @@ vop_listextattr { *sizep = 0; error = zfs_lookup(ap->a_vp, NULL, &xvp, NULL, 0, ap->a_cred, td, - LOOKUP_XATTR); + LOOKUP_XATTR, B_FALSE); if (error != 0) { ZFS_EXIT(zfsvfs); /* @@ -5982,7 +5991,7 @@ struct vop_vector zfs_vnodeops = { .vop_access = zfs_freebsd_access, .vop_allocate = VOP_EINVAL, .vop_lookup = zfs_cache_lookup, - .vop_cachedlookup = zfs_freebsd_lookup, + .vop_cachedlookup = zfs_freebsd_cachedlookup, .vop_getattr = zfs_freebsd_getattr, .vop_setattr = zfs_freebsd_setattr, .vop_create = zfs_freebsd_create, diff --git a/sys/cddl/contrib/opensolaris/uts/common/sys/asm_linkage.h b/sys/cddl/contrib/opensolaris/uts/common/sys/asm_linkage.h index d694ea4844c3..f10bcec40a7b 100644 --- a/sys/cddl/contrib/opensolaris/uts/common/sys/asm_linkage.h +++ b/sys/cddl/contrib/opensolaris/uts/common/sys/asm_linkage.h @@ -41,11 +41,6 @@ extern "C" { #define ASM_ENTRY_ALIGN 16 -#elif defined(__sparc64__) - -/* GCC uses 32-byte function alignment for UltraSPARC CPUs. */ -#define ASM_ENTRY_ALIGN 32 - #else #error Unsupported architecture. diff --git a/sys/compat/cloudabi/cloudabi_vdso.c b/sys/compat/cloudabi/cloudabi_vdso.c index b89dd68e683c..ab621b3c18b0 100644 --- a/sys/compat/cloudabi/cloudabi_vdso.c +++ b/sys/compat/cloudabi/cloudabi_vdso.c @@ -26,7 +26,8 @@ #include __FBSDID("$FreeBSD$"); -#include +#include +#include #include #include #include diff --git a/sys/compat/linux/linux_socket.c b/sys/compat/linux/linux_socket.c index 989c503d8921..7d297733d96e 100644 --- a/sys/compat/linux/linux_socket.c +++ b/sys/compat/linux/linux_socket.c @@ -49,8 +49,12 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include +#include + +#include #include #include @@ -1581,7 +1585,134 @@ linux_getsockopt(struct thread *td, struct linux_getsockopt_args *args) return (error); } -#if defined(__i386__) || (defined(__amd64__) && defined(COMPAT_LINUX32)) +static int +linux_sendfile_common(struct thread *td, l_int out, l_int in, + l_loff_t *offset, l_size_t count) +{ + off_t bytes_read; + int error; + l_loff_t current_offset; + struct file *fp; + + AUDIT_ARG_FD(in); + error = fget_read(td, in, &cap_pread_rights, &fp); + if (error != 0) + return (error); + + if (offset != NULL) { + current_offset = *offset; + } else { + error = (fp->f_ops->fo_flags & DFLAG_SEEKABLE) != 0 ? + fo_seek(fp, 0, SEEK_CUR, td) : ESPIPE; + if (error != 0) + goto drop; + current_offset = td->td_uretoff.tdu_off; + } + + bytes_read = 0; + + /* Linux cannot have 0 count. */ + if (count <= 0 || current_offset < 0) { + error = EINVAL; + goto drop; + } + + error = fo_sendfile(fp, out, NULL, NULL, current_offset, count, + &bytes_read, 0, td); + if (error != 0) + goto drop; + current_offset += bytes_read; + + if (offset != NULL) { + *offset = current_offset; + } else { + error = fo_seek(fp, current_offset, SEEK_SET, td); + if (error != 0) + goto drop; + } + + td->td_retval[0] = (ssize_t)bytes_read; +drop: + fdrop(fp, td); + return (error); +} + +int +linux_sendfile(struct thread *td, struct linux_sendfile_args *arg) +{ + /* + * Differences between FreeBSD and Linux sendfile: + * - Linux doesn't send anything when count is 0 (FreeBSD uses 0 to + * mean send the whole file.) In linux_sendfile given fds are still + * checked for validity when the count is 0. + * - Linux can send to any fd whereas FreeBSD only supports sockets. + * The same restriction follows for linux_sendfile. + * - Linux doesn't have an equivalent for FreeBSD's flags and sf_hdtr. + * - Linux takes an offset pointer and updates it to the read location. + * FreeBSD takes in an offset and a 'bytes read' parameter which is + * only filled if it isn't NULL. We use this parameter to update the + * offset pointer if it exists. + * - Linux sendfile returns bytes read on success while FreeBSD + * returns 0. We use the 'bytes read' parameter to get this value. + */ + + l_loff_t offset64; + l_long offset; + int ret; + int error; + + if (arg->offset != NULL) { + error = copyin(arg->offset, &offset, sizeof(offset)); + if (error != 0) + return (error); + offset64 = (l_loff_t)offset; + } + + ret = linux_sendfile_common(td, arg->out, arg->in, + arg->offset != NULL ? &offset64 : NULL, arg->count); + + if (arg->offset != NULL) { +#if defined(__i386__) || defined(__arm__) || \ + (defined(__amd64__) && defined(COMPAT_LINUX32)) + if (offset64 > INT32_MAX) + return (EOVERFLOW); +#endif + offset = (l_long)offset64; + error = copyout(&offset, arg->offset, sizeof(offset)); + if (error != 0) + return (error); + } + + return (ret); +} + +#if defined(__i386__) || defined(__arm__) || \ + (defined(__amd64__) && defined(COMPAT_LINUX32)) + +int +linux_sendfile64(struct thread *td, struct linux_sendfile64_args *arg) +{ + l_loff_t offset; + int ret; + int error; + + if (arg->offset != NULL) { + error = copyin(arg->offset, &offset, sizeof(offset)); + if (error != 0) + return (error); + } + + ret = linux_sendfile_common(td, arg->out, arg->in, + arg->offset != NULL ? &offset : NULL, arg->count); + + if (arg->offset != NULL) { + error = copyout(&offset, arg->offset, sizeof(offset)); + if (error != 0) + return (error); + } + + return (ret); +} /* Argument list sizes for linux_socketcall */ static const unsigned char lxs_args_cnt[] = { @@ -1595,7 +1726,7 @@ static const unsigned char lxs_args_cnt[] = { 5 /* setsockopt */, 5 /* getsockopt */, 3 /* sendmsg */, 3 /* recvmsg */, 4 /* accept4 */, 5 /* recvmmsg */, - 4 /* sendmmsg */ + 4 /* sendmmsg */, 4 /* sendfile */ }; #define LINUX_ARGS_CNT (nitems(lxs_args_cnt) - 1) #define LINUX_ARG_SIZE(x) (lxs_args_cnt[x] * sizeof(l_ulong)) @@ -1664,9 +1795,11 @@ linux_socketcall(struct thread *td, struct linux_socketcall_args *args) return (linux_recvmmsg(td, arg)); case LINUX_SENDMMSG: return (linux_sendmmsg(td, arg)); + case LINUX_SENDFILE: + return (linux_sendfile(td, arg)); } uprintf("LINUX: 'socket' typ=%d not implemented\n", args->what); return (ENOSYS); } -#endif /* __i386__ || (__amd64__ && COMPAT_LINUX32) */ +#endif /* __i386__ || __arm__ || (__amd64__ && COMPAT_LINUX32) */ diff --git a/sys/compat/linux/linux_socket.h b/sys/compat/linux/linux_socket.h index de858afbdec1..efe21c6f2f94 100644 --- a/sys/compat/linux/linux_socket.h +++ b/sys/compat/linux/linux_socket.h @@ -132,7 +132,9 @@ struct l_ucred { uint32_t gid; }; -#if defined(__i386__) || (defined(__amd64__) && defined(COMPAT_LINUX32)) +#if defined(__i386__) || defined(__arm__) || \ + (defined(__amd64__) && defined(COMPAT_LINUX32)) + struct linux_accept_args { register_t s; register_t addr; @@ -162,7 +164,9 @@ int linux_accept(struct thread *td, struct linux_accept_args *args); #define LINUX_ACCEPT4 18 #define LINUX_RECVMMSG 19 #define LINUX_SENDMMSG 20 -#endif /* __i386__ || (__amd64__ && COMPAT_LINUX32) */ +#define LINUX_SENDFILE 21 + +#endif /* __i386__ || __arm__ || (__amd64__ && COMPAT_LINUX32) */ /* Socket defines */ #define LINUX_SOL_SOCKET 1 diff --git a/sys/compat/linux/linux_time.c b/sys/compat/linux/linux_time.c index ad3f7ad5c614..452188f057a3 100644 --- a/sys/compat/linux/linux_time.c +++ b/sys/compat/linux/linux_time.c @@ -65,6 +65,7 @@ __KERNEL_RCSID(0, "$NetBSD: linux_time.c,v 1.14 2006/05/14 03:40:54 christos Exp #endif #include +#include #include /* DTrace init */ @@ -203,6 +204,12 @@ linux_to_native_clockid(clockid_t *n, clockid_t l) case LINUX_CLOCK_MONOTONIC: *n = CLOCK_MONOTONIC; break; + case LINUX_CLOCK_PROCESS_CPUTIME_ID: + *n = CLOCK_PROCESS_CPUTIME_ID; + break; + case LINUX_CLOCK_THREAD_CPUTIME_ID: + *n = CLOCK_THREAD_CPUTIME_ID; + break; case LINUX_CLOCK_REALTIME_COARSE: *n = CLOCK_REALTIME_FAST; break; @@ -253,7 +260,7 @@ linux_clock_gettime(struct thread *td, struct linux_clock_gettime_args *args) struct thread *targettd; struct proc *p; int error, clockwhich; - clockid_t nwhich = 0; /* XXX: GCC */ + clockid_t nwhich; pid_t pid; lwpid_t tid; @@ -269,8 +276,13 @@ linux_clock_gettime(struct thread *td, struct linux_clock_gettime_args *args) switch (nwhich) { case CLOCK_PROCESS_CPUTIME_ID: - clockwhich = LINUX_CPUCLOCK_WHICH(args->which); - pid = LINUX_CPUCLOCK_ID(args->which); + if (args->which < 0) { + clockwhich = LINUX_CPUCLOCK_WHICH(args->which); + pid = LINUX_CPUCLOCK_ID(args->which); + } else { + clockwhich = LINUX_CPUCLOCK_SCHED; + pid = 0; + } if (pid == 0) { p = td->td_proc; PROC_LOCK(p); @@ -296,12 +308,8 @@ linux_clock_gettime(struct thread *td, struct linux_clock_gettime_args *args) TIMEVAL_TO_TIMESPEC(&ru.ru_utime, &tp); break; case LINUX_CPUCLOCK_SCHED: + kern_process_cputime(p, &tp); PROC_UNLOCK(p); - error = kern_clock_getcpuclockid2(td, pid, - CPUCLOCK_WHICH_PID, &nwhich); - if (error != 0) - return (EINVAL); - error = kern_clock_gettime(td, nwhich, &tp); break; default: PROC_UNLOCK(p); @@ -311,14 +319,19 @@ linux_clock_gettime(struct thread *td, struct linux_clock_gettime_args *args) break; case CLOCK_THREAD_CPUTIME_ID: - clockwhich = LINUX_CPUCLOCK_WHICH(args->which); + if (args->which < 0) { + clockwhich = LINUX_CPUCLOCK_WHICH(args->which); + tid = LINUX_CPUCLOCK_ID(args->which); + } else { + clockwhich = LINUX_CPUCLOCK_SCHED; + tid = 0; + } p = td->td_proc; - tid = LINUX_CPUCLOCK_ID(args->which); if (tid == 0) { targettd = td; PROC_LOCK(p); } else { - targettd = tdfind(tid, p->p_pid); + targettd = linux_tdfind(td, tid, p->p_pid); if (targettd == NULL) return (EINVAL); } @@ -343,12 +356,10 @@ linux_clock_gettime(struct thread *td, struct linux_clock_gettime_args *args) TIMEVAL_TO_TIMESPEC(&ru.ru_utime, &tp); break; case LINUX_CPUCLOCK_SCHED: - error = kern_clock_getcpuclockid2(td, tid, - CPUCLOCK_WHICH_TID, &nwhich); + if (td == targettd) + targettd = NULL; + kern_thread_cputime(targettd, &tp); PROC_UNLOCK(p); - if (error != 0) - return (EINVAL); - error = kern_clock_gettime(td, nwhich, &tp); break; default: PROC_UNLOCK(p); @@ -382,7 +393,7 @@ linux_clock_settime(struct thread *td, struct linux_clock_settime_args *args) struct timespec ts; struct l_timespec lts; int error; - clockid_t nwhich = 0; /* XXX: GCC */ + clockid_t nwhich; LIN_SDT_PROBE2(time, linux_clock_settime, entry, args->which, args->tp); @@ -422,7 +433,7 @@ linux_clock_getres(struct thread *td, struct linux_clock_getres_args *args) struct timespec ts; struct l_timespec lts; int error, clockwhich; - clockid_t nwhich = 0; /* XXX: GCC */ + clockid_t nwhich; pid_t pid; lwpid_t tid; @@ -440,25 +451,27 @@ linux_clock_getres(struct thread *td, struct linux_clock_getres_args *args) * Check user supplied clock id in case of per-process * or thread-specific cpu-time clock. */ - switch (nwhich) { - case CLOCK_THREAD_CPUTIME_ID: - tid = LINUX_CPUCLOCK_ID(args->which); - if (tid != 0) { - p = td->td_proc; - if (tdfind(tid, p->p_pid) == NULL) - return (ESRCH); - PROC_UNLOCK(p); + if (args->which < 0) { + switch (nwhich) { + case CLOCK_THREAD_CPUTIME_ID: + tid = LINUX_CPUCLOCK_ID(args->which); + if (tid != 0) { + p = td->td_proc; + if (linux_tdfind(td, tid, p->p_pid) == NULL) + return (EINVAL); + PROC_UNLOCK(p); + } + break; + case CLOCK_PROCESS_CPUTIME_ID: + pid = LINUX_CPUCLOCK_ID(args->which); + if (pid != 0) { + error = pget(pid, PGET_CANSEE, &p); + if (error != 0) + return (EINVAL); + PROC_UNLOCK(p); + } + break; } - break; - case CLOCK_PROCESS_CPUTIME_ID: - pid = LINUX_CPUCLOCK_ID(args->which); - if (pid != 0) { - error = pget(pid, PGET_CANSEE, &p); - if (error != 0) - return (EINVAL); - PROC_UNLOCK(p); - } - break; } if (args->tp == NULL) { @@ -471,6 +484,20 @@ linux_clock_getres(struct thread *td, struct linux_clock_getres_args *args) case CLOCK_THREAD_CPUTIME_ID: case CLOCK_PROCESS_CPUTIME_ID: clockwhich = LINUX_CPUCLOCK_WHICH(args->which); + /* + * In both cases (when the clock id obtained by a call to + * clock_getcpuclockid() or using the clock + * ID CLOCK_PROCESS_CPUTIME_ID Linux hardcodes precision + * of clock. The same for the CLOCK_THREAD_CPUTIME_ID clock. + * + * See Linux posix_cpu_clock_getres() implementation. + */ + if (args->which > 0 || clockwhich == LINUX_CPUCLOCK_SCHED) { + ts.tv_sec = 0; + ts.tv_nsec = 1; + goto out; + } + switch (clockwhich) { case LINUX_CPUCLOCK_PROF: nwhich = CLOCK_PROF; @@ -478,8 +505,6 @@ linux_clock_getres(struct thread *td, struct linux_clock_getres_args *args) case LINUX_CPUCLOCK_VIRT: nwhich = CLOCK_VIRTUAL; break; - case LINUX_CPUCLOCK_SCHED: - break; default: return (EINVAL); } @@ -494,6 +519,8 @@ linux_clock_getres(struct thread *td, struct linux_clock_getres_args *args) LIN_SDT_PROBE1(time, linux_clock_getres, return, error); return (error); } + +out: error = native_to_linux_timespec(<s, &ts); if (error != 0) return (error); diff --git a/sys/compat/linuxkpi/common/include/linux/file.h b/sys/compat/linuxkpi/common/include/linux/file.h index acbb43bac1b5..21b254211cfd 100644 --- a/sys/compat/linuxkpi/common/include/linux/file.h +++ b/sys/compat/linuxkpi/common/include/linux/file.h @@ -54,7 +54,7 @@ linux_fget(unsigned int fd) /* lookup file pointer by file descriptor index */ if (fget_unlocked(curthread->td_proc->p_fd, fd, - &cap_no_rights, &file, NULL) != 0) + &cap_no_rights, &file) != 0) return (NULL); /* check if file handle really belongs to us */ @@ -90,7 +90,7 @@ put_unused_fd(unsigned int fd) struct file *file; if (fget_unlocked(curthread->td_proc->p_fd, fd, - &cap_no_rights, &file, NULL) != 0) { + &cap_no_rights, &file) != 0) { return; } /* @@ -110,7 +110,7 @@ fd_install(unsigned int fd, struct linux_file *filp) struct file *file; if (fget_unlocked(curthread->td_proc->p_fd, fd, - &cap_no_rights, &file, NULL) != 0) { + &cap_no_rights, &file) != 0) { filp->_file = NULL; } else { filp->_file = file; diff --git a/sys/conf/Makefile.riscv b/sys/conf/Makefile.riscv index 1285acc886a2..183fa6dd4482 100644 --- a/sys/conf/Makefile.riscv +++ b/sys/conf/Makefile.riscv @@ -28,8 +28,17 @@ S= ../../.. INCLUDES+= -I$S/contrib/libfdt +# Set the ELF LMA to the address that OpenSBI's fw_jump jumps to. This allows +# us to load the kernel with the -kernel flag in QEMU without having to embed +# it inside BBL or OpenSBI's fw_payload first. +# Note: For rv32 the start address is different (0x80400000). +# We set this value using --defsym rather than hardcoding it in ldscript.riscv +# so that different kernel configs can override the load address. +KERNEL_LMA?= 0x80200000 + SYSTEM_LD= @${LD} -N -m ${LD_EMULATION} -Bdynamic -T ${LDSCRIPT} ${_LDFLAGS} \ --no-warn-mismatch --warn-common --export-dynamic \ + --defsym='kernel_lma=${KERNEL_LMA}' \ --dynamic-linker /red/herring \ -o ${.TARGET} -X ${SYSTEM_OBJS} vers.o diff --git a/sys/conf/Makefile.sparc64 b/sys/conf/Makefile.sparc64 deleted file mode 100644 index 736f9cba3638..000000000000 --- a/sys/conf/Makefile.sparc64 +++ /dev/null @@ -1,49 +0,0 @@ -# Makefile.sparc64 -- with config changes. -# Copyright 1990 W. Jolitz -# from: @(#)Makefile.i386 7.1 5/10/91 -# $FreeBSD$ -# -# Makefile for FreeBSD -# -# This makefile is constructed from a machine description: -# config machineid -# Most changes should be made in the machine description -# /sys/sparc64/conf/``machineid'' -# after which you should do -# config machineid -# Generic makefile changes should be made in -# /sys/conf/Makefile.sparc64 -# after which config should be rerun for all machines. -# - -# Which version of config(8) is required. -%VERSREQ= 600012 - -STD8X16FONT?= iso - -.if !defined(S) -.if exists(./@/.) -S= ./@ -.else -S= ../../.. -.endif -.endif -.include "$S/conf/kern.pre.mk" - -MDOBJS= exception.o interrupt.o - -%BEFORE_DEPEND - -%OBJS - -%FILES.c - -%FILES.s - -%FILES.m - -%CLEAN - -%RULES - -.include "$S/conf/kern.post.mk" diff --git a/sys/conf/NOTES b/sys/conf/NOTES index 0f570e89b781..2b67f4960eec 100644 --- a/sys/conf/NOTES +++ b/sys/conf/NOTES @@ -2045,8 +2045,6 @@ device sound # snd_ad1816: Analog Devices AD1816 ISA PnP/non-PnP. # snd_als4000: Avance Logic ALS4000 PCI. # snd_atiixp: ATI IXP 200/300/400 PCI. -# snd_audiocs: Crystal Semiconductor CS4231 SBus/EBus. Only -# for sparc64. # snd_cmi: CMedia CMI8338/CMI8738 PCI. # snd_cs4281: Crystal Semiconductor CS4281 PCI. # snd_csa: Crystal Semiconductor CS461x/428x PCI. (except @@ -2089,7 +2087,6 @@ device sound device snd_ad1816 device snd_als4000 device snd_atiixp -#device snd_audiocs device snd_cmi device snd_cs4281 device snd_csa diff --git a/sys/conf/config.mk b/sys/conf/config.mk index cc8d7b34edcd..6b405890458e 100644 --- a/sys/conf/config.mk +++ b/sys/conf/config.mk @@ -11,8 +11,9 @@ opt_global.h: touch ${.TARGET} .if ${MACHINE} != "mips" - @echo "#define VIMAGE 1" >> ${.TARGET} + @echo "#define SMP 1" >> ${.TARGET} @echo "#define MAC 1" >> ${.TARGET} + @echo "#define VIMAGE 1" >> ${.TARGET} .endif opt_bpf.h: echo "#define DEV_BPF 1" > ${.TARGET} diff --git a/sys/conf/files b/sys/conf/files index 060253916f33..32443799dc01 100644 --- a/sys/conf/files +++ b/sys/conf/files @@ -35,7 +35,7 @@ feeder_rate_gen.h optional sound \ no-obj no-implicit-rule before-depend \ clean "feeder_rate_gen.h" font.h optional sc_dflt_font \ - compile-with "uudecode < ${SRCTOP}/share/syscons/fonts/${SC_DFLT_FONT}-8x16.fnt && file2c 'static u_char dflt_font_16[16*256] = {' '};' < ${SC_DFLT_FONT}-8x16 > font.h && uudecode < ${SRCTOP}/share/syscons/fonts/${SC_DFLT_FONT}-8x14.fnt && file2c 'static u_char dflt_font_14[14*256] = {' '};' < ${SC_DFLT_FONT}-8x14 >> font.h && uudecode < ${SRCTOP}/share/syscons/fonts/${SC_DFLT_FONT}-8x8.fnt && file2c 'static u_char dflt_font_8[8*256] = {' '};' < ${SC_DFLT_FONT}-8x8 >> font.h" \ + compile-with "uudecode < ${SRCTOP}/share/syscons/fonts/${SC_DFLT_FONT}-8x16.fnt && file2c 'u_char dflt_font_16[16*256] = {' '};' < ${SC_DFLT_FONT}-8x16 > font.h && uudecode < ${SRCTOP}/share/syscons/fonts/${SC_DFLT_FONT}-8x14.fnt && file2c 'u_char dflt_font_14[14*256] = {' '};' < ${SC_DFLT_FONT}-8x14 >> font.h && uudecode < ${SRCTOP}/share/syscons/fonts/${SC_DFLT_FONT}-8x8.fnt && file2c 'u_char dflt_font_8[8*256] = {' '};' < ${SC_DFLT_FONT}-8x8 >> font.h" \ no-obj no-implicit-rule before-depend \ clean "font.h ${SC_DFLT_FONT}-8x14 ${SC_DFLT_FONT}-8x16 ${SC_DFLT_FONT}-8x8" snd_fxdiv_gen.h optional sound \ @@ -1743,7 +1743,6 @@ dev/fxp/if_fxp.c optional fxp dev/fxp/inphy.c optional fxp dev/gem/if_gem.c optional gem dev/gem/if_gem_pci.c optional gem pci -dev/gem/if_gem_sbus.c optional gem sbus dev/gpio/dwgpio/dwgpio.c optional gpio dwgpio fdt dev/gpio/dwgpio/dwgpio_bus.c optional gpio dwgpio fdt dev/gpio/dwgpio/dwgpio_if.m optional gpio dwgpio fdt @@ -1769,7 +1768,6 @@ dev/gpio/ofw_gpiobus.c optional fdt gpio dev/hifn/hifn7751.c optional hifn dev/hme/if_hme.c optional hme dev/hme/if_hme_pci.c optional hme pci -dev/hme/if_hme_sbus.c optional hme sbus dev/hptiop/hptiop.c optional hptiop scbus dev/hwpmc/hwpmc_logging.c optional hwpmc dev/hwpmc/hwpmc_mod.c optional hwpmc @@ -1885,7 +1883,6 @@ dev/isp/isp.c optional isp dev/isp/isp_freebsd.c optional isp dev/isp/isp_library.c optional isp dev/isp/isp_pci.c optional isp pci -dev/isp/isp_sbus.c optional isp sbus dev/isp/isp_target.c optional isp dev/ispfw/ispfw.c optional ispfw dev/iwi/if_iwi.c optional iwi @@ -3009,9 +3006,7 @@ rtwn-rtl8821aufw.fw optional rtwn-rtl8821aufw | rtwnfw \ clean "rtwn-rtl8821aufw.fw" dev/safe/safe.c optional safe dev/scc/scc_if.m optional scc -dev/scc/scc_bfe_ebus.c optional scc ebus dev/scc/scc_bfe_quicc.c optional scc quicc -dev/scc/scc_bfe_sbus.c optional scc fhc | scc sbus dev/scc/scc_core.c optional scc dev/scc/scc_dev_quicc.c optional scc quicc dev/scc/scc_dev_sab82532.c optional scc @@ -3171,7 +3166,6 @@ dev/tws/tws_hdm.c optional tws dev/tws/tws_services.c optional tws dev/tws/tws_user.c optional tws dev/uart/uart_bus_acpi.c optional uart acpi -dev/uart/uart_bus_ebus.c optional uart ebus dev/uart/uart_bus_fdt.c optional uart fdt dev/uart/uart_bus_isa.c optional uart isa dev/uart/uart_bus_pccard.c optional uart pccard diff --git a/sys/conf/files.sparc64 b/sys/conf/files.sparc64 deleted file mode 100644 index 66d039934f98..000000000000 --- a/sys/conf/files.sparc64 +++ /dev/null @@ -1,146 +0,0 @@ -# This file tells config what files go into building a kernel, -# files marked standard are always included. -# -# $FreeBSD$ -# -# The long compile-with and dependency lines are required because of -# limitations in config: backslash-newline doesn't work in strings, and -# dependency lines other than the first are silently ignored. -# -atkbdmap.h optional atkbd_dflt_keymap \ - compile-with "kbdcontrol -P ${S:S/sys$/share/}/vt/keymaps -P ${S:S/sys$/share/}/syscons/keymaps -L ${ATKBD_DFLT_KEYMAP} | sed -e 's/^static keymap_t.* = /static keymap_t key_map = /' -e 's/^static accentmap_t.* = /static accentmap_t accent_map = /' > atkbdmap.h" \ - no-obj no-implicit-rule before-depend \ - clean "atkbdmap.h" -# -sunkbdmap.h optional sunkbd_dflt_keymap \ - compile-with "kbdcontrol -P ${S:S/sys$/share/}/vt/keymaps -P ${S:S/sys$/share/}/syscons/keymaps -L ${SUNKBD_DFLT_KEYMAP} | sed -e 's/^static keymap_t.* = /static keymap_t key_map = /' -e 's/^static accentmap_t.* = /static accentmap_t accent_map = /' > sunkbdmap.h" \ - no-obj no-implicit-rule before-depend \ - clean "sunkbdmap.h" -# -crypto/blowfish/bf_enc.c optional crypto | ipsec | ipsec_support -crypto/des/des_enc.c optional crypto | ipsec | ipsec_support | netsmb -dev/atkbdc/atkbd.c optional atkbd atkbdc -dev/atkbdc/atkbd_atkbdc.c optional atkbd atkbdc -dev/atkbdc/atkbdc.c optional atkbdc -dev/atkbdc/atkbdc_ebus.c optional atkbdc ebus -dev/atkbdc/atkbdc_isa.c optional atkbdc isa -dev/atkbdc/atkbdc_subr.c optional atkbdc -dev/atkbdc/psm.c optional psm atkbdc -dev/auxio/auxio.c optional auxio sbus | auxio ebus -dev/esp/esp_sbus.c optional esp sbus -dev/fb/creator.c optional creator sc -dev/fb/creator_vt.c optional creator vt -dev/fb/fb.c optional sc -dev/fb/gallant12x22.c optional sc -dev/fb/machfb.c optional machfb sc -dev/hwpmc/hwpmc_sparc64.c optional hwpmc -dev/le/if_le_lebuffer.c optional le sbus -dev/le/if_le_ledma.c optional le sbus -dev/le/lebuffer_sbus.c optional le sbus -dev/ofw/ofw_bus_if.m standard -dev/ofw/ofw_bus_subr.c standard -dev/ofw/ofw_console.c optional ofw_console -dev/ofw/ofw_if.m standard -dev/ofw/ofw_standard.c standard -dev/ofw/openfirm.c standard -dev/ofw/openfirmio.c standard -dev/ofw/openpromio.c standard -dev/pcf/envctrl.c optional pcf ebus -dev/pcf/pcf_ebus.c optional pcf ebus -dev/sound/sbus/cs4231.c optional snd_audiocs ebus | \ - snd_audiocs sbus -dev/syscons/scgfbrndr.c optional sc -dev/uart/uart_cpu_sparc64.c optional uart -dev/uart/uart_kbd_sun.c optional uart sc | vt -dev/vt/hw/ofwfb/ofwfb.c optional vt -kern/kern_clocksource.c standard -kern/subr_dummy_vdso_tc.c standard -kern/syscalls.c optional ktr -kern/subr_sfbuf.c standard -libkern/ffs.c standard -libkern/ffsl.c standard -libkern/ffsll.c standard -libkern/fls.c standard -libkern/flsl.c standard -libkern/flsll.c standard -libkern/memcmp.c standard -sparc64/central/central.c optional central -sparc64/ebus/ebus.c optional ebus -sparc64/ebus/epic.c optional epic ebus -sparc64/fhc/clkbrd.c optional fhc -sparc64/fhc/fhc.c optional fhc -sparc64/isa/isa.c optional isa -sparc64/isa/isa_dma.c optional isa -sparc64/isa/ofw_isa.c optional ebus | isa -sparc64/pci/apb.c optional pci -sparc64/pci/fire.c optional pci -sparc64/pci/ofw_pci.c optional pci -sparc64/pci/ofw_pcib.c optional pci -sparc64/pci/ofw_pcib_subr.c optional pci -sparc64/pci/ofw_pcibus.c optional pci -sparc64/pci/ofw_pci_if.m optional pci -sparc64/pci/psycho.c optional pci -sparc64/pci/sbbc.c optional sbbc uart -sparc64/pci/schizo.c optional pci -sparc64/sbus/dma_sbus.c optional sbus -sparc64/sbus/sbus.c optional sbus -sparc64/sbus/lsi64854.c optional sbus -sparc64/sparc64/ata_machdep.c optional ada | da -sparc64/sparc64/autoconf.c standard -sparc64/sparc64/bus_machdep.c standard -sparc64/sparc64/cache.c standard -sparc64/sparc64/cam_machdep.c optional scbus -sparc64/sparc64/cheetah.c standard -sparc64/sparc64/clock.c standard -sparc64/sparc64/counter.c standard -sparc64/sparc64/db_disasm.c optional ddb -sparc64/sparc64/db_interface.c optional ddb -sparc64/sparc64/db_trace.c optional ddb -sparc64/sparc64/db_hwwatch.c optional ddb -sparc64/sparc64/dump_machdep.c standard -sparc64/sparc64/elf_machdep.c standard -sparc64/sparc64/exception.S standard no-obj \ - compile-with "${NORMAL_S} -mcpu=ultrasparc" -sparc64/sparc64/eeprom.c optional eeprom ebus | eeprom fhc | \ - eeprom sbus -sparc64/sparc64/gdb_machdep.c optional gdb -sparc64/sparc64/identcpu.c standard -sparc64/sparc64/in_cksum.c optional inet | inet6 -sparc64/sparc64/interrupt.S standard no-obj \ - compile-with "${NORMAL_S} -mcpu=ultrasparc" -sparc64/sparc64/intr_machdep.c standard -sparc64/sparc64/iommu.c standard -sparc64/sparc64/jbusppm.c standard -sparc64/sparc64/locore.S standard no-obj -sparc64/sparc64/machdep.c standard -sparc64/sparc64/mem.c optional mem -sparc64/sparc64/mp_exception.S optional smp \ - compile-with "${NORMAL_S} -mcpu=ultrasparc" -sparc64/sparc64/mp_locore.S optional smp -sparc64/sparc64/mp_machdep.c optional smp -sparc64/sparc64/nexus.c standard -sparc64/sparc64/ofw_machdep.c standard -sparc64/sparc64/pmap.c standard -sparc64/sparc64/prof_machdep.c optional profiling-routine -sparc64/sparc64/rtc.c optional rtc ebus | rtc isa -sparc64/sparc64/rwindow.c standard -sparc64/sparc64/sc_machdep.c optional sc -sparc64/sparc64/schppm.c standard -sparc64/sparc64/spitfire.c standard -sparc64/sparc64/ssm.c standard -sparc64/sparc64/stack_machdep.c optional ddb | stack -sparc64/sparc64/support.S standard \ - compile-with "${NORMAL_S} -mcpu=ultrasparc" -sparc64/sparc64/sys_machdep.c standard -sparc64/sparc64/swtch.S standard -sparc64/sparc64/tick.c standard -sparc64/sparc64/tlb.c standard -sparc64/sparc64/trap.c standard -sparc64/sparc64/tsb.c standard -sparc64/sparc64/uio_machdep.c standard -sparc64/sparc64/upa.c optional creator -sparc64/sparc64/vm_machdep.c standard -sparc64/sparc64/zeus.c standard - -# Zstd -contrib/zstd/lib/freebsd/zstd_kfreebsd.c optional zstdio compile-with ${ZSTD_C} diff --git a/sys/conf/kern.mk b/sys/conf/kern.mk index 1e29b58663d4..56c0e76c25f6 100644 --- a/sys/conf/kern.mk +++ b/sys/conf/kern.mk @@ -153,18 +153,6 @@ CFLAGS+= -mno-relax .endif .endif -# -# For sparc64 we want the medany code model so modules may be located -# anywhere in the 64-bit address space. We also tell GCC to use floating -# point emulation. This avoids using floating point registers for integer -# operations which it has a tendency to do. -# -.if ${MACHINE_CPUARCH} == "sparc64" -CFLAGS.clang+= -mcmodel=large -fno-dwarf2-cfi-asm -CFLAGS.gcc+= -mcmodel=medany -msoft-float -INLINE_LIMIT?= 15000 -.endif - # # For AMD64, we explicitly prohibit the use of FPU, SSE and other SIMD # operations inside the kernel itself. These operations are exclusively @@ -315,5 +303,4 @@ LD_EMULATION_powerpc= elf32ppc_fbsd LD_EMULATION_powerpcspe= elf32ppc_fbsd LD_EMULATION_powerpc64= elf64ppc_fbsd LD_EMULATION_riscv64= elf64lriscv -LD_EMULATION_sparc64= elf64_sparc_fbsd LD_EMULATION=${LD_EMULATION_${MACHINE_ARCH}} diff --git a/sys/conf/kern.opts.mk b/sys/conf/kern.opts.mk index 3819acce8c1f..078d79913634 100644 --- a/sys/conf/kern.opts.mk +++ b/sys/conf/kern.opts.mk @@ -93,8 +93,8 @@ BROKEN_OPTIONS+= OFED BROKEN_OPTIONS+= KERNEL_RETPOLINE .endif -# EFI doesn't exist on mips, powerpc, sparc or riscv. -.if ${MACHINE:Mmips} || ${MACHINE:Mpowerpc} || ${MACHINE:Msparc64} || ${MACHINE:Mriscv} +# EFI doesn't exist on mips, powerpc, or riscv. +.if ${MACHINE:Mmips} || ${MACHINE:Mpowerpc} || ${MACHINE:Mriscv} BROKEN_OPTIONS+=EFI .endif diff --git a/sys/conf/ldscript.riscv b/sys/conf/ldscript.riscv index 2986486cf844..b8ebf047f996 100644 --- a/sys/conf/ldscript.riscv +++ b/sys/conf/ldscript.riscv @@ -7,7 +7,8 @@ SECTIONS { /* Read-only sections, merged into text segment: */ . = kernbase; - .text : AT(ADDR(.text) - kernbase) + /* The load address kernel_lma is set using --defsym= on the command line. */ + .text : AT(kernel_lma) { *(.text) *(.stub) diff --git a/sys/conf/ldscript.sparc64 b/sys/conf/ldscript.sparc64 deleted file mode 100644 index aec138ed295f..000000000000 --- a/sys/conf/ldscript.sparc64 +++ /dev/null @@ -1,269 +0,0 @@ -/* $FreeBSD$ */ -OUTPUT_FORMAT("elf64-sparc-freebsd", "elf64-sparc-freebsd", - "elf64-sparc-freebsd") -OUTPUT_ARCH(sparc:v9) -ENTRY(_start) -SEARCH_DIR(/usr/lib); -SECTIONS -{ - /* Read-only sections, merged into text segment: */ - . = kernbase + SIZEOF_HEADERS; - .interp : { *(.interp) } - .hash : { *(.hash) } - .dynsym : { *(.dynsym) } - .dynstr : { *(.dynstr) } - .gnu.version : { *(.gnu.version) } - .gnu.version_d : { *(.gnu.version_d) } - .gnu.version_r : { *(.gnu.version_r) } - .rel.init : { *(.rel.init) } - .rela.init : { *(.rela.init) } - .rel.text : - { - *(.rel.text) - *(.rel.text.*) - *(.rel.gnu.linkonce.t.*) - } - .rela.text : - { - *(.rela.text) - *(.rela.text.*) - *(.rela.gnu.linkonce.t.*) - } - .rel.fini : { *(.rel.fini) } - .rela.fini : { *(.rela.fini) } - .rel.rodata : - { - *(.rel.rodata) - *(.rel.rodata.*) - *(.rel.gnu.linkonce.r.*) - } - .rela.rodata : - { - *(.rela.rodata) - *(.rela.rodata.*) - *(.rela.gnu.linkonce.r.*) - } - .rel.data : - { - *(.rel.data) - *(.rel.data.*) - *(.rel.gnu.linkonce.d.*) - } - .rela.data : - { - *(.rela.data) - *(.rela.data.*) - *(.rela.gnu.linkonce.d.*) - } - .rel.ctors : { *(.rel.ctors) } - .rela.ctors : { *(.rela.ctors) } - .rel.dtors : { *(.rel.dtors) } - .rela.dtors : { *(.rela.dtors) } - .rel.got : { *(.rel.got) } - .rela.got : { *(.rela.got) } - .rel.sdata : - { - *(.rel.sdata) - *(.rel.sdata.*) - *(.rel.gnu.linkonce.s.*) - } - .rela.sdata : - { - *(.rela.sdata) - *(.rela.sdata.*) - *(.rela.gnu.linkonce.s.*) - } - .rel.sbss : - { - *(.rel.sbss) - *(.rel.sbss.*) - *(.rel.gnu.linkonce.sb.*) - } - .rela.sbss : - { - *(.rela.sbss) - *(.rela.sbss.*) - *(.rel.gnu.linkonce.sb.*) - } - .rel.sdata2 : - { - *(.rel.sdata2) - *(.rel.sdata2.*) - *(.rel.gnu.linkonce.s2.*) - } - .rela.sdata2 : - { - *(.rela.sdata2) - *(.rela.sdata2.*) - *(.rela.gnu.linkonce.s2.*) - } - .rel.sbss2 : - { - *(.rel.sbss2) - *(.rel.sbss2.*) - *(.rel.gnu.linkonce.sb2.*) - } - .rela.sbss2 : - { - *(.rela.sbss2) - *(.rela.sbss2.*) - *(.rela.gnu.linkonce.sb2.*) - } - .rel.bss : - { - *(.rel.bss) - *(.rel.bss.*) - *(.rel.gnu.linkonce.b.*) - } - .rela.bss : - { - *(.rela.bss) - *(.rela.bss.*) - *(.rela.gnu.linkonce.b.*) - } - .rel.plt : { *(.rel.plt) } - .rela.plt : { *(.rela.plt) } - .init : - { - KEEP (*(.init)) - } =0x1000000 - .text : - { - *(.trap) - *(.text) - *(.text.*) - *(.stub) - /* .gnu.warning sections are handled specially by elf32.em. */ - *(.gnu.warning) - *(.gnu.linkonce.t.*) - } =0x1000000 - .fini : - { - KEEP (*(.fini)) - } =0x1000000 - PROVIDE (__etext = .); - PROVIDE (_etext = .); - PROVIDE (etext = .); - .rodata : { *(.rodata) *(.rodata.*) *(.gnu.linkonce.r.*) } - .rodata1 : { *(.rodata1) } - .note.gnu.build-id : { - PROVIDE (__build_id_start = .); - *(.note.gnu.build-id) - PROVIDE (__build_id_end = .); - } - .sdata2 : { *(.sdata2) *(.sdata2.*) *(.gnu.linkonce.s2.*) } - .sbss2 : { *(.sbss2) *(.sbss2.*) *(.gnu.linkonce.sb2.*) } - . = ALIGN(0x2000) + (. & (0x2000 - 1)); - .data : - { - *(.data) - *(.data.*) - *(.gnu.linkonce.d.*) - } - .data1 : { *(.data1) } - .eh_frame : { KEEP (*(.eh_frame)) } - .gcc_except_table : { *(.gcc_except_table) } - .ctors : - { - /* gcc uses crtbegin.o to find the start of - the constructors, so we make sure it is - first. Because this is a wildcard, it - doesn't matter if the user does not - actually link against crtbegin.o; the - linker won't look for a file to match a - wildcard. The wildcard also means that it - doesn't matter which directory crtbegin.o - is in. */ - KEEP (*crtbegin.o(.ctors)) - /* We don't want to include the .ctor section from - from the crtend.o file until after the sorted ctors. - The .ctor section from the crtend file contains the - end of ctors marker and it must be last */ - KEEP (*(EXCLUDE_FILE (*crtend.o ) .ctors)) - KEEP (*(SORT(.ctors.*))) - KEEP (*(.ctors)) - } - .dtors : - { - KEEP (*crtbegin.o(.dtors)) - KEEP (*(EXCLUDE_FILE (*crtend.o ) .dtors)) - KEEP (*(SORT(.dtors.*))) - KEEP (*(.dtors)) - } - .plt : { *(.plt) } - .got : { *(.got.plt) *(.got) } - .dynamic : { *(.dynamic) } - /* We want the small data sections together, so single-instruction offsets - can access them all, and initialized data all before uninitialized, so - we can shorten the on-disk segment size. */ - .sdata : - { - *(.sdata) - *(.sdata.*) - *(.gnu.linkonce.s.*) - } - _edata = .; - PROVIDE (edata = .); - __bss_start = .; - .sbss : - { - PROVIDE (__sbss_start = .); - PROVIDE (___sbss_start = .); - *(.dynsbss) - *(.sbss) - *(.sbss.*) - *(.gnu.linkonce.sb.*) - *(.scommon) - PROVIDE (__sbss_end = .); - PROVIDE (___sbss_end = .); - } - .bss : - { - *(.dynbss) - *(.bss) - *(.bss.*) - *(.gnu.linkonce.b.*) - *(COMMON) - /* Align here to ensure that the .bss section occupies space up to - _end. Align after .bss to ensure correct alignment even if the - .bss section disappears because there are no input sections. */ - . = ALIGN(64 / 8); - } - . = ALIGN(64 / 8); - _end = .; - PROVIDE (end = .); - /* Stabs debugging sections. */ - .stab 0 : { *(.stab) } - .stabstr 0 : { *(.stabstr) } - .stab.excl 0 : { *(.stab.excl) } - .stab.exclstr 0 : { *(.stab.exclstr) } - .stab.index 0 : { *(.stab.index) } - .stab.indexstr 0 : { *(.stab.indexstr) } - .comment 0 : { *(.comment) } - /* DWARF debug sections. - Symbols in the DWARF debugging sections are relative to the beginning - of the section so we begin them at 0. */ - /* DWARF 1 */ - .debug 0 : { *(.debug) } - .line 0 : { *(.line) } - /* GNU DWARF 1 extensions */ - .debug_srcinfo 0 : { *(.debug_srcinfo) } - .debug_sfnames 0 : { *(.debug_sfnames) } - /* DWARF 1.1 and DWARF 2 */ - .debug_aranges 0 : { *(.debug_aranges) } - .debug_pubnames 0 : { *(.debug_pubnames) } - /* DWARF 2 */ - .debug_info 0 : { *(.debug_info) *(.gnu.linkonce.wi.*) } - .debug_abbrev 0 : { *(.debug_abbrev) } - .debug_line 0 : { *(.debug_line) } - .debug_frame 0 : { *(.debug_frame) } - .debug_str 0 : { *(.debug_str) } - .debug_loc 0 : { *(.debug_loc) } - .debug_macinfo 0 : { *(.debug_macinfo) } - /* SGI/MIPS DWARF 2 extensions */ - .debug_weaknames 0 : { *(.debug_weaknames) } - .debug_funcnames 0 : { *(.debug_funcnames) } - .debug_typenames 0 : { *(.debug_typenames) } - .debug_varnames 0 : { *(.debug_varnames) } - /* These must appear regardless of . */ -} diff --git a/sys/conf/options.arm64 b/sys/conf/options.arm64 index 02da846c8ca9..dc2a0c6f98fa 100644 --- a/sys/conf/options.arm64 +++ b/sys/conf/options.arm64 @@ -7,6 +7,7 @@ SOCDEV_VA opt_global.h THUNDERX_PASS_1_1_ERRATA opt_global.h VFP opt_global.h LINUX_BOOT_ABI opt_global.h +LSE_ATOMICS opt_global.h # Binary compatibility COMPAT_FREEBSD32 opt_global.h diff --git a/sys/conf/options.sparc64 b/sys/conf/options.sparc64 deleted file mode 100644 index 883db1669279..000000000000 --- a/sys/conf/options.sparc64 +++ /dev/null @@ -1,31 +0,0 @@ -# $FreeBSD$ - -GFB_DEBUG opt_gfb.h -GFB_NO_FONT_LOADING opt_gfb.h -GFB_NO_MODE_CHANGE opt_gfb.h - -SUN4U opt_global.h - -ATKBD_DFLT_KEYMAP opt_atkbd.h - -FIRE_DEBUG opt_fire.h - -# Debug IOMMU inserts/removes using diagnostic accesses. This is very loud. -IOMMU_DIAG opt_iommu.h - -OFWCONS_POLL_HZ opt_ofw.h - -OFW_PCI_DEBUG opt_ofw_pci.h - -PMAP_STATS opt_pmap.h - -PSM_DEBUG opt_psm.h -PSM_HOOKRESUME opt_psm.h -PSM_RESETAFTERSUSPEND opt_psm.h - -PSYCHO_DEBUG opt_psycho.h - -SCHIZO_DEBUG opt_schizo.h - -SUNKBD_DFLT_KEYMAP opt_sunkbd.h -SUNKBD_EMULATE_ATKBD opt_sunkbd.h diff --git a/sys/contrib/ck/include/ck_md.h b/sys/contrib/ck/include/ck_md.h index 8e452c7d35de..51649597b254 100644 --- a/sys/contrib/ck/include/ck_md.h +++ b/sys/contrib/ck/include/ck_md.h @@ -114,9 +114,6 @@ net $ #define CK_MD_SSE_DISABLE 1 #elif defined(__amd64__) #define CK_MD_TSO -#elif defined(__sparc64__) && !defined(__sparcv9__) -#define __sparcv9__ -#define CK_MD_TSO #elif defined(__powerpc64__) && !defined(__ppc64__) #define __ppc64__ #elif defined(__powerpc__) && !defined(__ppc__) diff --git a/sys/dev/aac/aac_disk.c b/sys/dev/aac/aac_disk.c index 1a547ed039ab..284c1472d7ea 100644 --- a/sys/dev/aac/aac_disk.c +++ b/sys/dev/aac/aac_disk.c @@ -163,6 +163,11 @@ aac_disk_strategy(struct bio *bp) return; } + if ((bp->bio_cmd != BIO_READ) && (bp->bio_cmd != BIO_WRITE)) { + biofinish(bp, NULL, EOPNOTSUPP); + return; + } + /* perform accounting */ /* pass the bio to the controller - it can work out who we are */ diff --git a/sys/dev/acpi_support/acpi_ibm.c b/sys/dev/acpi_support/acpi_ibm.c index eee0c8ee9c08..376b61095d6e 100644 --- a/sys/dev/acpi_support/acpi_ibm.c +++ b/sys/dev/acpi_support/acpi_ibm.c @@ -276,9 +276,9 @@ static struct { .description = "Mic led", }, { - .name = "privacyguard", - .method = ACPI_IBM_METHOD_PRIVACYGUARD, - .description = "PrivacyGuard enable", + .name = "privacyguard", + .method = ACPI_IBM_METHOD_PRIVACYGUARD, + .description = "PrivacyGuard enable", }, { NULL, 0, NULL, 0 } }; @@ -363,8 +363,7 @@ static driver_t acpi_ibm_driver = { static devclass_t acpi_ibm_devclass; -DRIVER_MODULE(acpi_ibm, acpi, acpi_ibm_driver, acpi_ibm_devclass, - 0, 0); +DRIVER_MODULE(acpi_ibm, acpi, acpi_ibm_driver, acpi_ibm_devclass, 0, 0); MODULE_DEPEND(acpi_ibm, acpi, 1, 1, 1); static char *ibm_ids[] = {"IBM0068", "LEN0068", "LEN0268", NULL}; @@ -384,7 +383,7 @@ acpi_status_to_errno(ACPI_STATUS status) static void ibm_led(void *softc, int onoff) { - struct acpi_ibm_softc* sc = (struct acpi_ibm_softc*) softc; + struct acpi_ibm_softc *sc = softc; ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__); @@ -410,7 +409,7 @@ ibm_led_task(struct acpi_ibm_softc *sc, int pending __unused) } static int -acpi_ibm_mic_led_set (struct acpi_ibm_softc *sc, int arg) +acpi_ibm_mic_led_set(struct acpi_ibm_softc *sc, int arg) { ACPI_OBJECT_LIST input; ACPI_OBJECT params[1]; @@ -429,10 +428,10 @@ acpi_ibm_mic_led_set (struct acpi_ibm_softc *sc, int arg) input.Pointer = params; input.Count = 1; - status = AcpiEvaluateObject (sc->handle, "MMTS", &input, NULL); + status = AcpiEvaluateObject(sc->handle, "MMTS", &input, NULL); if (ACPI_SUCCESS(status)) sc->mic_led_state = arg; - return(status); + return (status); } return (0); @@ -443,14 +442,13 @@ acpi_ibm_probe(device_t dev) { int rv; - if (acpi_disabled("ibm") || - device_get_unit(dev) != 0) + if (acpi_disabled("ibm") || device_get_unit(dev) != 0) return (ENXIO); rv = ACPI_ID_PROBE(device_get_parent(dev), dev, ibm_ids, NULL); - if (rv <= 0) + if (rv <= 0) device_set_desc(dev, "ThinkPad ACPI Extras"); - + return (rv); } @@ -459,7 +457,7 @@ acpi_ibm_attach(device_t dev) { int i; int hkey; - struct acpi_ibm_softc *sc; + struct acpi_ibm_softc *sc; char *maker, *product; ACPI_OBJECT_LIST input; ACPI_OBJECT params[1]; @@ -474,12 +472,12 @@ acpi_ibm_attach(device_t dev) sc->handle = acpi_get_handle(dev); /* Look for the first embedded controller */ - if (!(ec_devclass = devclass_find ("acpi_ec"))) { + if (!(ec_devclass = devclass_find ("acpi_ec"))) { if (bootverbose) device_printf(dev, "Couldn't find acpi_ec devclass\n"); return (EINVAL); } - if (!(sc->ec_dev = devclass_get_device(ec_devclass, 0))) { + if (!(sc->ec_dev = devclass_get_device(ec_devclass, 0))) { if (bootverbose) device_printf(dev, "Couldn't find acpi_ec device\n"); return (EINVAL); @@ -496,14 +494,13 @@ acpi_ibm_attach(device_t dev) if (sc->events_mask_supported) { SYSCTL_ADD_UINT(sc->sysctl_ctx, - SYSCTL_CHILDREN(sc->sysctl_tree), OID_AUTO, - "initialmask", CTLFLAG_RD, - &sc->events_initialmask, 0, "Initial eventmask"); + SYSCTL_CHILDREN(sc->sysctl_tree), OID_AUTO, "initialmask", + CTLFLAG_RD, &sc->events_initialmask, 0, + "Initial eventmask"); if (ACPI_SUCCESS (acpi_GetInteger(sc->handle, "MHKV", &hkey))) { device_printf(dev, "Firmware version is 0x%X\n", hkey); - switch(hkey >> 8) - { + switch (hkey >> 8) { case 1: /* The availmask is the bitmask of supported events */ if (ACPI_FAILURE(acpi_GetInteger(sc->handle, @@ -561,18 +558,17 @@ acpi_ibm_attach(device_t dev) /* Hook up thermal node */ if (acpi_ibm_sysctl_init(sc, ACPI_IBM_METHOD_THERMAL)) { SYSCTL_ADD_PROC(sc->sysctl_ctx, - SYSCTL_CHILDREN(sc->sysctl_tree), OID_AUTO, - "thermal", CTLTYPE_INT | CTLFLAG_RD, - sc, 0, acpi_ibm_thermal_sysctl, "I", - "Thermal zones"); + SYSCTL_CHILDREN(sc->sysctl_tree), OID_AUTO, "thermal", + CTLTYPE_INT | CTLFLAG_RD, sc, 0, acpi_ibm_thermal_sysctl, + "I", "Thermal zones"); } /* Hook up handlerevents node */ if (acpi_ibm_sysctl_init(sc, ACPI_IBM_METHOD_HANDLEREVENTS)) { SYSCTL_ADD_PROC(sc->sysctl_ctx, - SYSCTL_CHILDREN(sc->sysctl_tree), OID_AUTO, - "handlerevents", CTLTYPE_STRING | CTLFLAG_RW, - sc, 0, acpi_ibm_handlerevents_sysctl, "I", + SYSCTL_CHILDREN(sc->sysctl_tree), OID_AUTO, "handlerevents", + CTLTYPE_STRING | CTLFLAG_RW, sc, 0, + acpi_ibm_handlerevents_sysctl, "I", "devd(8) events handled by acpi_ibm"); } @@ -610,7 +606,6 @@ acpi_ibm_attach(device_t dev) acpi_ibm_sysctl_set(sc, ACPI_IBM_METHOD_EVENTS, 1); ACPI_SERIAL_END(ibm); - return (0); } @@ -677,7 +672,7 @@ acpi_ibm_eventmask_set(struct acpi_ibm_softc *sc, int val) arg[1].Type = ACPI_TYPE_INTEGER; for (int i = 0; i < 32; ++i) { - arg[0].Integer.Value = i+1; + arg[0].Integer.Value = i + 1; arg[1].Integer.Value = (((1 << i) & val) != 0); status = AcpiEvaluateObject(sc->handle, IBM_NAME_EVENTS_MASK_SET, &args, NULL); @@ -814,8 +809,7 @@ acpi_ibm_sysctl_get(struct acpi_ibm_softc *sc, int method) if (sc->fan_handle) { if(ACPI_FAILURE(acpi_GetInteger(sc->fan_handle, NULL, &val))) val = -1; - } - else { + } else { ACPI_EC_READ(sc->ec_dev, IBM_EC_FANSPEED, &val_ec, 2); val = val_ec; } @@ -841,10 +835,10 @@ acpi_ibm_sysctl_get(struct acpi_ibm_softc *sc, int method) if (!sc->fan_handle) { ACPI_EC_READ(sc->ec_dev, IBM_EC_FANSTATUS, &val_ec, 1); val = (val_ec & IBM_EC_MASK_FANSTATUS) == IBM_EC_MASK_FANSTATUS; - } - else + } else val = -1; break; + case ACPI_IBM_METHOD_MIC_LED: if (sc->mic_led_handle) return sc->mic_led_state; @@ -855,7 +849,6 @@ acpi_ibm_sysctl_get(struct acpi_ibm_softc *sc, int method) case ACPI_IBM_METHOD_PRIVACYGUARD: val = acpi_ibm_privacyguard_get(sc); break; - } return (val); @@ -901,7 +894,7 @@ acpi_ibm_sysctl_set(struct acpi_ibm_softc *sc, int method, int arg) break; case ACPI_IBM_METHOD_MIC_LED: - return acpi_ibm_mic_led_set (sc, arg); + return acpi_ibm_mic_led_set(sc, arg); break; case ACPI_IBM_METHOD_THINKLIGHT: @@ -971,10 +964,9 @@ acpi_ibm_sysctl_init(struct acpi_ibm_softc *sc, int method) if (ACPI_SUCCESS(AcpiGetHandle(sc->handle, "MMTS", &sc->mic_led_handle))) { /* Turn off mic led by default */ - acpi_ibm_mic_led_set (sc, 0); - return(TRUE); - } - else + acpi_ibm_mic_led_set(sc, 0); + return (TRUE); + } else sc->mic_led_handle = NULL; return (FALSE); @@ -995,8 +987,7 @@ acpi_ibm_sysctl_init(struct acpi_ibm_softc *sc, int method) else if (ACPI_SUCCESS(AcpiGetHandle(sc->handle, "\\LGHT", &sc->light_handle))) { sc->light_cmd_on = 1; sc->light_cmd_off = 0; - } - else + } else sc->light_handle = NULL; sc->light_set_supported = (sc->light_handle && @@ -1050,7 +1041,6 @@ acpi_ibm_sysctl_init(struct acpi_ibm_softc *sc, int method) case ACPI_IBM_METHOD_PRIVACYGUARD: return (acpi_ibm_privacyguard_get(sc) != -1); - } return (FALSE); } @@ -1273,7 +1263,8 @@ acpi_ibm_thinklight_set(struct acpi_ibm_softc *sc, int arg) * Only meant to be used internally by the get/set functions below. */ static ACPI_STATUS -acpi_ibm_privacyguard_acpi_call(struct acpi_ibm_softc *sc, bool write, int *arg) { +acpi_ibm_privacyguard_acpi_call(struct acpi_ibm_softc *sc, bool write, int *arg) +{ ACPI_OBJECT Arg; ACPI_OBJECT_LIST Args; ACPI_STATUS status; @@ -1485,7 +1476,6 @@ acpi_ibm_notify(ACPI_HANDLE h, UINT32 notify, void *context) if (event == 0) break; - type = (event >> 12) & 0xf; arg = event & 0xfff; switch (type) { diff --git a/sys/dev/altera/avgen/altera_avgen.c b/sys/dev/altera/avgen/altera_avgen.c index 86f45ea42f4a..d7dd7d29b1e0 100644 --- a/sys/dev/altera/avgen/altera_avgen.c +++ b/sys/dev/altera/avgen/altera_avgen.c @@ -252,11 +252,13 @@ altera_avgen_disk_strategy(struct bio *bp) void *data; long bcount; daddr_t pblkno; + int error; sc = bp->bio_disk->d_drv1; data = bp->bio_data; bcount = bp->bio_bcount; pblkno = bp->bio_pblkno; + error = 0; /* * Serialize block reads / writes. @@ -265,7 +267,7 @@ altera_avgen_disk_strategy(struct bio *bp) switch (bp->bio_cmd) { case BIO_READ: if (!(sc->avg_flags & ALTERA_AVALON_FLAG_GEOM_READ)) { - biofinish(bp, NULL, EIO); + error = EROFS; break; } switch (sc->avg_width) { @@ -324,11 +326,11 @@ altera_avgen_disk_strategy(struct bio *bp) break; default: - panic("%s: unsupported I/O operation %d", __func__, - bp->bio_cmd); + error = EOPNOTSUPP; + break; } mtx_unlock(&sc->avg_disk_mtx); - biofinish(bp, NULL, 0); + biofinish(bp, NULL, error); } static int diff --git a/sys/dev/altera/sdcard/altera_sdcard_io.c b/sys/dev/altera/sdcard/altera_sdcard_io.c index dc1b615bd60a..546e0af2b907 100644 --- a/sys/dev/altera/sdcard/altera_sdcard_io.c +++ b/sys/dev/altera/sdcard/altera_sdcard_io.c @@ -293,27 +293,27 @@ altera_sdcard_write_rxtx_buffer(struct altera_sdcard_softc *sc, void *data, } static void -altera_sdcard_io_start_internal(struct altera_sdcard_softc *sc, struct bio *bp) +altera_sdcard_io_start_internal(struct altera_sdcard_softc *sc, struct bio **bp) { - switch (bp->bio_cmd) { + switch (*bp->bio_cmd) { case BIO_READ: - altera_sdcard_write_cmd_arg(sc, bp->bio_pblkno * + altera_sdcard_write_cmd_arg(sc, *bp->bio_pblkno * ALTERA_SDCARD_SECTORSIZE); altera_sdcard_write_cmd(sc, ALTERA_SDCARD_CMD_READ_BLOCK); break; case BIO_WRITE: - altera_sdcard_write_rxtx_buffer(sc, bp->bio_data, - bp->bio_bcount); - altera_sdcard_write_cmd_arg(sc, bp->bio_pblkno * + altera_sdcard_write_rxtx_buffer(sc, *bp->bio_data, + *bp->bio_bcount); + altera_sdcard_write_cmd_arg(sc, *bp->bio_pblkno * ALTERA_SDCARD_SECTORSIZE); altera_sdcard_write_cmd(sc, ALTERA_SDCARD_CMD_WRITE_BLOCK); break; default: - panic("%s: unsupported I/O operation %d", __func__, - bp->bio_cmd); + biofinish(*bp, NULL, EOPNOTSUPP); + *bp = NULL; } } @@ -332,8 +332,8 @@ altera_sdcard_io_start(struct altera_sdcard_softc *sc, struct bio *bp) */ KASSERT(bp->bio_bcount == ALTERA_SDCARD_SECTORSIZE, ("%s: I/O size not %d", __func__, ALTERA_SDCARD_SECTORSIZE)); - altera_sdcard_io_start_internal(sc, bp); - sc->as_currentbio = bp; + altera_sdcard_io_start_internal(sc, &bp); + sc->as_currentbio = *bp; sc->as_retriesleft = ALTERA_SDCARD_RETRY_LIMIT; } @@ -406,7 +406,7 @@ altera_sdcard_io_complete(struct altera_sdcard_softc *sc, uint16_t asr) */ if (sc->as_retriesleft != 0) { sc->as_flags |= ALTERA_SDCARD_FLAG_IOERROR; - altera_sdcard_io_start_internal(sc, bp); + altera_sdcard_io_start_internal(sc, &bp); return (0); } sc->as_flags &= ~ALTERA_SDCARD_FLAG_IOERROR; diff --git a/sys/dev/amr/amr.c b/sys/dev/amr/amr.c index 375fa6c533e5..2e77c3e4befc 100644 --- a/sys/dev/amr/amr.c +++ b/sys/dev/amr/amr.c @@ -1315,6 +1315,10 @@ amr_bio_command(struct amr_softc *sc, struct amr_command **acp) ac->ac_flags |= AMR_CMD_PRIORITY | AMR_CMD_DATAOUT; cmd = AMR_CMD_FLUSH; break; + default: + biofinish(bio, NULL, EOPNOTSUPP); + amr_releasecmd(ac); + return (0); } amrd = (struct amrd_softc *)bio->bio_disk->d_drv1; driveno = amrd->amrd_drive - sc->amr_drive; diff --git a/sys/dev/ata/ata-pci.c b/sys/dev/ata/ata-pci.c index 48a31e69883d..426c1ee36e0b 100644 --- a/sys/dev/ata/ata-pci.c +++ b/sys/dev/ata/ata-pci.c @@ -147,17 +147,9 @@ ata_pci_detach(device_t dev) if (ctlr->chipdeinit != NULL) ctlr->chipdeinit(dev); if (ctlr->r_res2) { -#ifdef __sparc64__ - bus_space_unmap(rman_get_bustag(ctlr->r_res2), - rman_get_bushandle(ctlr->r_res2), rman_get_size(ctlr->r_res2)); -#endif bus_release_resource(dev, ctlr->r_type2, ctlr->r_rid2, ctlr->r_res2); } if (ctlr->r_res1) { -#ifdef __sparc64__ - bus_space_unmap(rman_get_bustag(ctlr->r_res1), - rman_get_bushandle(ctlr->r_res1), rman_get_size(ctlr->r_res1)); -#endif bus_release_resource(dev, ctlr->r_type1, ctlr->r_rid1, ctlr->r_res1); } diff --git a/sys/dev/ata/chipsets/ata-promise.c b/sys/dev/ata/chipsets/ata-promise.c index c189509201d8..c9518f18d3dd 100644 --- a/sys/dev/ata/chipsets/ata-promise.c +++ b/sys/dev/ata/chipsets/ata-promise.c @@ -250,14 +250,6 @@ ata_promise_chipinit(device_t dev) &ctlr->r_rid1, RF_ACTIVE))) goto failnfree; -#ifdef __sparc64__ - if (ctlr->chip->cfg2 == PR_SX4X && - !bus_space_map(rman_get_bustag(ctlr->r_res1), - rman_get_bushandle(ctlr->r_res1), rman_get_size(ctlr->r_res1), - BUS_SPACE_MAP_LINEAR, NULL)) - goto failnfree; -#endif - ctlr->r_type2 = SYS_RES_MEMORY; ctlr->r_rid2 = PCIR_BAR(3); if (!(ctlr->r_res2 = bus_alloc_resource_any(dev, ctlr->r_type2, diff --git a/sys/dev/atkbdc/atkbd.c b/sys/dev/atkbdc/atkbd.c index b74587635d9e..ddf266abf531 100644 --- a/sys/dev/atkbdc/atkbd.c +++ b/sys/dev/atkbdc/atkbd.c @@ -74,7 +74,6 @@ typedef struct atkbd_state { } atkbd_state_t; static void atkbd_timeout(void *arg); -static void atkbd_shutdown_final(void *v); static int atkbd_reset(KBDC kbdc, int flags, int c); #define HAS_QUIRK(p, q) (((atkbdc_softc_t *)(p))->quirks & q) @@ -151,9 +150,6 @@ atkbd_attach_unit(device_t dev, keyboard_t **kbd, int irq, int flags) if (bootverbose) (*sw->diag)(*kbd, bootverbose); - EVENTHANDLER_REGISTER(shutdown_final, atkbd_shutdown_final, *kbd, - SHUTDOWN_PRI_DEFAULT); - return 0; } @@ -1148,30 +1144,6 @@ atkbd_poll(keyboard_t *kbd, int on) return 0; } -static void -atkbd_shutdown_final(void *v) -{ -#ifdef __sparc64__ - keyboard_t *kbd = v; - KBDC kbdc = ((atkbd_state_t *)kbd->kb_data)->kbdc; - - /* - * Turn off the translation in preparation for handing the keyboard - * over to the OFW as the OBP driver doesn't use translation and - * also doesn't disable it itself resulting in a broken keymap at - * the boot prompt. Also disable the aux port and the interrupts as - * the OBP driver doesn't use them, i.e. polls the keyboard. Not - * disabling the interrupts doesn't cause real problems but the - * responsiveness is a bit better when they are turned off. - */ - send_kbd_command(kbdc, KBDC_DISABLE_KBD); - set_controller_command_byte(kbdc, - KBD_AUX_CONTROL_BITS | KBD_KBD_CONTROL_BITS | KBD_TRANSLATION, - KBD_DISABLE_AUX_PORT | KBD_DISABLE_KBD_INT | KBD_ENABLE_KBD_PORT); - send_kbd_command(kbdc, KBDC_ENABLE_KBD); -#endif -} - static int atkbd_reset(KBDC kbdc, int flags, int c) { @@ -1468,14 +1440,6 @@ init_keyboard(KBDC kbdc, int *type, int flags) } } -#if defined(__sparc64__) - if (send_kbd_command_and_data( - kbdc, KBDC_SET_SCANCODE_SET, 2) != KBD_ACK) { - printf("atkbd: can't set translation.\n"); - } - c |= KBD_TRANSLATION; -#endif - /* * Some keyboards require a SETLEDS command to be sent after * the reset command before they will send keystrokes to us diff --git a/sys/dev/atkbdc/atkbdc.c b/sys/dev/atkbdc/atkbdc.c index bcb47e645177..23ccbab3142b 100644 --- a/sys/dev/atkbdc/atkbdc.c +++ b/sys/dev/atkbdc/atkbdc.c @@ -52,13 +52,7 @@ __FBSDID("$FreeBSD$"); #include -#ifdef __sparc64__ -#include -#include -#include -#else #include -#endif /* constants */ @@ -98,10 +92,6 @@ static atkbdc_softc_t *atkbdc_softc[MAXKBDC] = { &default_kbdc }; static int verbose = KBDIO_DEBUG; -#ifdef __sparc64__ -static struct bus_space_tag atkbdc_bst_store[MAXKBDC]; -#endif - /* function prototypes */ static int atkbdc_setup(atkbdc_softc_t *sc, bus_space_tag_t tag, @@ -197,55 +187,16 @@ atkbdc_configure(void) volatile int i; register_t flags; #endif -#ifdef __sparc64__ - char name[32]; - phandle_t chosen, node; - ihandle_t stdin; - bus_addr_t port0; - bus_addr_t port1; - int space; -#else int port0; int port1; -#endif /* XXX: tag should be passed from the caller */ #if defined(__amd64__) || defined(__i386__) tag = X86_BUS_SPACE_IO; -#elif defined(__sparc64__) - tag = &atkbdc_bst_store[0]; #else #error "define tag!" #endif -#ifdef __sparc64__ - if ((chosen = OF_finddevice("/chosen")) == -1) - return 0; - if (OF_getprop(chosen, "stdin", &stdin, sizeof(stdin)) == -1) - return 0; - if ((node = OF_instance_to_package(stdin)) == -1) - return 0; - if (OF_getprop(node, "name", name, sizeof(name)) == -1) - return 0; - name[sizeof(name) - 1] = '\0'; - if (strcmp(name, "kb_ps2") != 0) - return 0; - /* - * The stdin handle points to an instance of a PS/2 keyboard - * package but we want the 8042 controller, which is the parent - * of that keyboard node. - */ - if ((node = OF_parent(node)) == 0) - return 0; - if (OF_decode_addr(node, 0, &space, &port0) != 0) - return 0; - h0 = sparc64_fake_bustag(space, port0, tag); - bus_space_subregion(tag, h0, KBD_DATA_PORT, 1, &h0); - if (OF_decode_addr(node, 1, &space, &port1) != 0) - return 0; - h1 = sparc64_fake_bustag(space, port1, tag); - bus_space_subregion(tag, h1, KBD_STATUS_PORT, 1, &h1); -#else port0 = IO_KBD; resource_int_value("atkbdc", 0, "port", &port0); port1 = IO_KBD + KBD_STATUS_PORT; @@ -256,7 +207,6 @@ atkbdc_configure(void) h0 = (bus_space_handle_t)port0; h1 = (bus_space_handle_t)port1; #endif -#endif #if defined(__i386__) || defined(__amd64__) /* diff --git a/sys/dev/atkbdc/atkbdc_ebus.c b/sys/dev/atkbdc/atkbdc_ebus.c deleted file mode 100644 index 53c40433d6ba..000000000000 --- a/sys/dev/atkbdc/atkbdc_ebus.c +++ /dev/null @@ -1,307 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD - * - * Copyright (c) 1999 Kazutaka YOKOTA - * Copyright (c) 2005 Marius Strobl - * 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 as - * the first lines of this file unmodified. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHORS 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. - * - * from: FreeBSD: src/sys/isa/atkbdc_isa.c,v 1.31 2005/05/29 04:42:28 nyan - */ - -#include -__FBSDID("$FreeBSD$"); - -#include "opt_kbd.h" - -#include -#include -#include -#include -#include -#include -#include - -#include - -#include -#include - -#include - -#include -#include -#include -#include -#include - -static device_probe_t atkbdc_ebus_probe; -static device_attach_t atkbdc_ebus_attach; - -static device_method_t atkbdc_ebus_methods[] = { - DEVMETHOD(device_probe, atkbdc_ebus_probe), - DEVMETHOD(device_attach, atkbdc_ebus_attach), - DEVMETHOD(device_suspend, bus_generic_suspend), - DEVMETHOD(device_resume, bus_generic_resume), - - DEVMETHOD(bus_print_child, atkbdc_print_child), - DEVMETHOD(bus_read_ivar, atkbdc_read_ivar), - DEVMETHOD(bus_write_ivar, atkbdc_write_ivar), - DEVMETHOD(bus_get_resource_list,atkbdc_get_resource_list), - DEVMETHOD(bus_alloc_resource, bus_generic_rl_alloc_resource), - DEVMETHOD(bus_release_resource, bus_generic_rl_release_resource), - DEVMETHOD(bus_activate_resource, bus_generic_activate_resource), - DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource), - DEVMETHOD(bus_get_resource, bus_generic_rl_get_resource), - DEVMETHOD(bus_set_resource, bus_generic_rl_set_resource), - DEVMETHOD(bus_delete_resource, bus_generic_rl_delete_resource), - DEVMETHOD(bus_setup_intr, bus_generic_setup_intr), - DEVMETHOD(bus_teardown_intr, bus_generic_teardown_intr), - - { 0, 0 } -}; - -static driver_t atkbdc_ebus_driver = { - ATKBDC_DRIVER_NAME, - atkbdc_ebus_methods, - sizeof(atkbdc_softc_t *), -}; - -DRIVER_MODULE(atkbdc, ebus, atkbdc_ebus_driver, atkbdc_devclass, 0, 0); - -static int -atkbdc_ebus_probe(device_t dev) -{ - struct resource *port0, *port1; - rman_res_t count, start; - int error, rid; - - if (strcmp(ofw_bus_get_name(dev), "8042") != 0) - return (ENXIO); - - /* - * On AXi and AXmp boards the NS16550 (used to connect keyboard/ - * mouse) share their IRQ lines with the i8042. Any IRQ activity - * (typically during attach) of the NS16550 used to connect the - * keyboard when actually the PS/2 keyboard is selected in OFW - * causes interaction with the OBP i8042 driver resulting in a - * hang and vice versa. As RS232 keyboards and mice obviously - * aren't meant to be used in parallel with PS/2 ones on these - * boards don't attach to the i8042 in case the PS/2 keyboard - * isn't selected in order to prevent such hangs. - * Note that it's not sufficient here to rely on the '8042' node - * only showing up when a PS/2 keyboard is actually connected as - * the user still might have adjusted the 'keyboard' alias to - * point to the RS232 keyboard. - */ - if ((!strcmp(sparc64_model, "SUNW,UltraAX-MP") || - !strcmp(sparc64_model, "SUNW,UltraSPARC-IIi-Engine")) && - OF_finddevice("keyboard") != ofw_bus_get_node(dev)) { - device_disable(dev); - return (ENXIO); - } - - device_set_desc(dev, "Keyboard controller (i8042)"); - - /* - * The '8042' node has two identical 8 addresses wide resources - * which are apparently meant to be used one for the keyboard - * half and the other one for the mouse half. To simplify matters - * we use one for the command/data port resource and the other - * one for the status port resource as the atkbdc(4) back-end - * expects two struct resource rather than two bus space handles. - */ - rid = 0; - if (bus_get_resource(dev, SYS_RES_MEMORY, rid, &start, &count) != 0) { - device_printf(dev, - "cannot determine command/data port resource\n"); - return (ENXIO); - } - port0 = bus_alloc_resource(dev, SYS_RES_MEMORY, &rid, start, start, 1, - RF_ACTIVE); - if (port0 == NULL) { - device_printf(dev, - "cannot allocate command/data port resource\n"); - return (ENXIO); - } - - rid = 1; - if (bus_get_resource(dev, SYS_RES_MEMORY, rid, &start, &count) != 0) { - device_printf(dev, "cannot determine status port resource\n"); - error = ENXIO; - goto fail_port0; - } - start += KBD_STATUS_PORT; - port1 = bus_alloc_resource(dev, SYS_RES_MEMORY, &rid, start, start, 1, - RF_ACTIVE); - if (port1 == NULL) { - device_printf(dev, "cannot allocate status port resource\n"); - error = ENXIO; - goto fail_port0; - } - - error = atkbdc_probe_unit(device_get_unit(dev), port0, port1); - if (error != 0) - device_printf(dev, "atkbdc_porbe_unit failed\n"); - - bus_release_resource(dev, SYS_RES_MEMORY, 1, port1); - fail_port0: - bus_release_resource(dev, SYS_RES_MEMORY, 0, port0); - - return (error); -} - -static int -atkbdc_ebus_attach(device_t dev) -{ - atkbdc_softc_t *sc; - atkbdc_device_t *adi; - device_t cdev; - phandle_t child; - rman_res_t count, intr, start; - int children, error, rid, unit; - char *cname, *dname; - - unit = device_get_unit(dev); - sc = *(atkbdc_softc_t **)device_get_softc(dev); - if (sc == NULL) { - /* - * We have to maintain two copies of the kbdc_softc struct, - * as the low-level console needs to have access to the - * keyboard controller before kbdc is probed and attached. - * kbdc_soft[] contains the default entry for that purpose. - * See atkbdc.c. XXX - */ - sc = atkbdc_get_softc(unit); - if (sc == NULL) - return (ENOMEM); - device_set_softc(dev, sc); - } - - rid = 0; - if (bus_get_resource(dev, SYS_RES_MEMORY, rid, &start, &count) != 0) { - device_printf(dev, - "cannot determine command/data port resource\n"); - return (ENXIO); - } - sc->retry = 5000; - sc->port0 = bus_alloc_resource(dev, SYS_RES_MEMORY, &rid, start, start, - 1, RF_ACTIVE); - if (sc->port0 == NULL) { - device_printf(dev, - "cannot allocate command/data port resource\n"); - return (ENXIO); - } - - rid = 1; - if (bus_get_resource(dev, SYS_RES_MEMORY, rid, &start, &count) != 0) { - device_printf(dev, "cannot determine status port resource\n"); - error = ENXIO; - goto fail_port0; - } - start += KBD_STATUS_PORT; - sc->port1 = bus_alloc_resource(dev, SYS_RES_MEMORY, &rid, start, start, - 1, RF_ACTIVE); - if (sc->port1 == NULL) { - device_printf(dev, "cannot allocate status port resource\n"); - error = ENXIO; - goto fail_port0; - } - - error = atkbdc_attach_unit(unit, sc, sc->port0, sc->port1); - if (error != 0) { - device_printf(dev, "atkbdc_attach_unit failed\n"); - goto fail_port1; - } - - /* Attach children. */ - children = 0; - for (child = OF_child(ofw_bus_get_node(dev)); child != 0; - child = OF_peer(child)) { - if ((OF_getprop_alloc(child, "name", (void **)&cname)) == -1) - continue; - if (children >= 2) { - device_printf(dev, - "<%s>: only two children per 8042 supported\n", - cname); - OF_prop_free(cname); - continue; - } - adi = malloc(sizeof(struct atkbdc_device), M_ATKBDDEV, - M_NOWAIT | M_ZERO); - if (adi == NULL) { - device_printf(dev, "<%s>: malloc failed\n", cname); - OF_prop_free(cname); - continue; - } - if (strcmp(cname, "kb_ps2") == 0) { - adi->rid = KBDC_RID_KBD; - dname = ATKBD_DRIVER_NAME; - } else if (strcmp(cname, "kdmouse") == 0) { - adi->rid = KBDC_RID_AUX; - dname = PSM_DRIVER_NAME; - } else { - device_printf(dev, "<%s>: unknown device\n", cname); - free(adi, M_ATKBDDEV); - OF_prop_free(cname); - continue; - } - intr = bus_get_resource_start(dev, SYS_RES_IRQ, adi->rid); - if (intr == 0) { - device_printf(dev, - "<%s>: cannot determine interrupt resource\n", - cname); - free(adi, M_ATKBDDEV); - OF_prop_free(cname); - continue; - } - resource_list_init(&adi->resources); - resource_list_add(&adi->resources, SYS_RES_IRQ, adi->rid, - intr, intr, 1); - if ((cdev = device_add_child(dev, dname, -1)) == NULL) { - device_printf(dev, "<%s>: device_add_child failed\n", - cname); - resource_list_free(&adi->resources); - free(adi, M_ATKBDDEV); - OF_prop_free(cname); - continue; - } - device_set_ivars(cdev, adi); - children++; - } - - error = bus_generic_attach(dev); - if (error != 0) { - device_printf(dev, "bus_generic_attach failed\n"); - goto fail_port1; - } - - return (0); - - fail_port1: - bus_release_resource(dev, SYS_RES_MEMORY, 1, sc->port1); - fail_port0: - bus_release_resource(dev, SYS_RES_MEMORY, 0, sc->port0); - - return (error); -} diff --git a/sys/dev/atkbdc/psm.c b/sys/dev/atkbdc/psm.c index e3ed5bc3f66d..67890f45bb1e 100644 --- a/sys/dev/atkbdc/psm.c +++ b/sys/dev/atkbdc/psm.c @@ -1948,6 +1948,7 @@ psm_register_elantech(device_t dev) static int psmattach(device_t dev) { + struct make_dev_args mda; int unit = device_get_unit(dev); struct psm_softc *sc = device_get_softc(dev); int error; @@ -1965,16 +1966,19 @@ psmattach(device_t dev) return (ENXIO); error = bus_setup_intr(dev, sc->intr, INTR_TYPE_TTY, NULL, psmintr, sc, &sc->ih); - if (error) { - bus_release_resource(dev, SYS_RES_IRQ, rid, sc->intr); - return (error); - } + if (error) + goto out; /* Done */ - sc->dev = make_dev(&psm_cdevsw, 0, 0, 0, 0666, "psm%d", unit); - sc->dev->si_drv1 = sc; - sc->bdev = make_dev(&psm_cdevsw, 0, 0, 0, 0666, "bpsm%d", unit); - sc->bdev->si_drv1 = sc; + make_dev_args_init(&mda); + mda.mda_devsw = &psm_cdevsw; + mda.mda_mode = 0666; + mda.mda_si_drv1 = sc; + + if ((error = make_dev_s(&mda, &sc->dev, "psm%d", unit)) != 0) + goto out; + if ((error = make_dev_s(&mda, &sc->bdev, "bpsm%d", unit)) != 0) + goto out; #ifdef EVDEV_SUPPORT switch (sc->hw.model) { @@ -1991,7 +1995,7 @@ psmattach(device_t dev) } if (error) - return (error); + goto out; #endif /* Some touchpad devices need full reinitialization after suspend. */ @@ -2032,7 +2036,15 @@ psmattach(device_t dev) if (bootverbose) --verbose; - return (0); +out: + if (error != 0) { + bus_release_resource(dev, SYS_RES_IRQ, rid, sc->intr); + if (sc->dev != NULL) + destroy_dev(sc->dev); + if (sc->bdev != NULL) + destroy_dev(sc->bdev); + } + return (error); } static int diff --git a/sys/dev/auxio/auxio.c b/sys/dev/auxio/auxio.c deleted file mode 100644 index 8c5f28d50e8a..000000000000 --- a/sys/dev/auxio/auxio.c +++ /dev/null @@ -1,325 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD AND BSD-3-Clause - * - * Copyright (c) 2004 Pyun YongHyeon - * 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. - * - */ - -/* $NetBSD: auxio.c,v 1.11 2003/07/15 03:36:04 lukem Exp $ */ - -/*- - * Copyright (c) 2000, 2001 Matthew R. Green - * 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. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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. - */ - -/* - * AUXIO registers support on the SBus & EBus2, used for the floppy driver - * and to control the system LED, for the BLINK option. - */ - -#include -__FBSDID("$FreeBSD$"); - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include -#include -#include - -#include -#include - -/* - * On sun4u, auxio exists with one register (LED) on the SBus, and 5 - * registers on the EBus2 (pci) (LED, PCIMODE, FREQUENCY, SCSI - * OSCILLATOR, and TEMP SENSE. - */ - -#define AUXIO_PCIO_LED 0 -#define AUXIO_PCIO_PCI 1 -#define AUXIO_PCIO_FREQ 2 -#define AUXIO_PCIO_OSC 3 -#define AUXIO_PCIO_TEMP 4 -#define AUXIO_PCIO_NREG 5 - -struct auxio_softc { - device_t sc_dev; - - int sc_nauxio; - struct resource *sc_res[AUXIO_PCIO_NREG]; - int sc_rid[AUXIO_PCIO_NREG]; - bus_space_tag_t sc_regt[AUXIO_PCIO_NREG]; - bus_space_handle_t sc_regh[AUXIO_PCIO_NREG]; - struct cdev *sc_led_dev; - u_int32_t sc_led_stat; - - int sc_flags; -#define AUXIO_LEDONLY 0x1 -#define AUXIO_EBUS 0x2 -#define AUXIO_SBUS 0x4 - - struct mtx sc_lock; -}; - -static void auxio_led_func(void *arg, int onoff); -static int auxio_attach_common(struct auxio_softc *); -static int auxio_bus_probe(device_t); -static int auxio_sbus_attach(device_t); -static int auxio_ebus_attach(device_t); -static int auxio_bus_detach(device_t); -static void auxio_free_resource(struct auxio_softc *); -static __inline u_int32_t auxio_led_read(struct auxio_softc *); -static __inline void auxio_led_write(struct auxio_softc *, u_int32_t); - -/* SBus */ -static device_method_t auxio_sbus_methods[] = { - DEVMETHOD(device_probe, auxio_bus_probe), - DEVMETHOD(device_attach, auxio_sbus_attach), - DEVMETHOD(device_detach, auxio_bus_detach), - - DEVMETHOD_END -}; - -static driver_t auxio_sbus_driver = { - "auxio", - auxio_sbus_methods, - sizeof(struct auxio_softc) -}; - -static devclass_t auxio_devclass; -/* The probe order is handled by sbus(4). */ -EARLY_DRIVER_MODULE(auxio, sbus, auxio_sbus_driver, auxio_devclass, 0, 0, - BUS_PASS_DEFAULT); -MODULE_DEPEND(auxio, sbus, 1, 1, 1); - -/* EBus */ -static device_method_t auxio_ebus_methods[] = { - DEVMETHOD(device_probe, auxio_bus_probe), - DEVMETHOD(device_attach, auxio_ebus_attach), - DEVMETHOD(device_detach, auxio_bus_detach), - - DEVMETHOD_END -}; - -static driver_t auxio_ebus_driver = { - "auxio", - auxio_ebus_methods, - sizeof(struct auxio_softc) -}; - -EARLY_DRIVER_MODULE(auxio, ebus, auxio_ebus_driver, auxio_devclass, 0, 0, - BUS_PASS_DEFAULT); -MODULE_DEPEND(auxio, ebus, 1, 1, 1); -MODULE_VERSION(auxio, 1); - -#define AUXIO_LOCK_INIT(sc) \ - mtx_init(&sc->sc_lock, "auxio mtx", NULL, MTX_DEF) -#define AUXIO_LOCK(sc) mtx_lock(&sc->sc_lock) -#define AUXIO_UNLOCK(sc) mtx_unlock(&sc->sc_lock) -#define AUXIO_LOCK_DESTROY(sc) mtx_destroy(&sc->sc_lock) - -static __inline void -auxio_led_write(struct auxio_softc *sc, u_int32_t v) -{ - if (sc->sc_flags & AUXIO_EBUS) - bus_space_write_4(sc->sc_regt[AUXIO_PCIO_LED], - sc->sc_regh[AUXIO_PCIO_LED], 0, v); - else - bus_space_write_1(sc->sc_regt[AUXIO_PCIO_LED], - sc->sc_regh[AUXIO_PCIO_LED], 0, v); -} - -static __inline u_int32_t -auxio_led_read(struct auxio_softc *sc) -{ - u_int32_t led; - - if (sc->sc_flags & AUXIO_EBUS) - led = bus_space_read_4(sc->sc_regt[AUXIO_PCIO_LED], - sc->sc_regh[AUXIO_PCIO_LED], 0); - else - led = bus_space_read_1(sc->sc_regt[AUXIO_PCIO_LED], - sc->sc_regh[AUXIO_PCIO_LED], 0); - - return (led); -} - -static void -auxio_led_func(void *arg, int onoff) -{ - struct auxio_softc *sc; - u_int32_t led; - - sc = (struct auxio_softc *)arg; - - AUXIO_LOCK(sc); - /* - * NB: We must not touch the other bits of the SBus AUXIO reg. - */ - led = auxio_led_read(sc); - if (onoff) - led |= AUXIO_LED_LED; - else - led &= ~AUXIO_LED_LED; - auxio_led_write(sc, led); - AUXIO_UNLOCK(sc); -} - -static int -auxio_bus_probe(device_t dev) -{ - const char *name; - - name = ofw_bus_get_name(dev); - if (strcmp("auxio", name) == 0) { - device_set_desc(dev, "Sun Auxiliary I/O"); - return (0); - } - - return (ENXIO); -} - -static int -auxio_ebus_attach(device_t dev) -{ - struct auxio_softc *sc; - - sc = device_get_softc(dev); - sc->sc_dev = dev; - - AUXIO_LOCK_INIT(sc); - sc->sc_nauxio = AUXIO_PCIO_NREG; - sc->sc_flags = AUXIO_LEDONLY | AUXIO_EBUS; - - return(auxio_attach_common(sc)); -} - -static int -auxio_attach_common(struct auxio_softc *sc) -{ - struct resource *res; - int i; - - for (i = 0; i < sc->sc_nauxio; i++) { - sc->sc_rid[i] = i; - res = bus_alloc_resource_any(sc->sc_dev, SYS_RES_MEMORY, - &sc->sc_rid[i], RF_ACTIVE); - if (res == NULL) { - device_printf(sc->sc_dev, - "could not allocate resources\n"); - goto attach_fail; - } - sc->sc_res[i] = res; - sc->sc_regt[i] = rman_get_bustag(res); - sc->sc_regh[i] = rman_get_bushandle(res); - } - - sc->sc_led_stat = auxio_led_read(sc) & AUXIO_LED_LED; - sc->sc_led_dev = led_create(auxio_led_func, sc, "auxioled"); - /* turn on the LED */ - auxio_led_func(sc, 1); - - return (0); - -attach_fail: - auxio_free_resource(sc); - - return (ENXIO); -} - -static int -auxio_bus_detach(device_t dev) -{ - struct auxio_softc *sc; - - sc = device_get_softc(dev); - led_destroy(sc->sc_led_dev); - auxio_led_func(sc, sc->sc_led_stat); - auxio_free_resource(sc); - - return (0); -} - -static void -auxio_free_resource(struct auxio_softc *sc) -{ - int i; - - for (i = 0; i < sc->sc_nauxio; i++) - if (sc->sc_res[i]) - bus_release_resource(sc->sc_dev, SYS_RES_MEMORY, - sc->sc_rid[i], sc->sc_res[i]); - AUXIO_LOCK_DESTROY(sc); -} - -static int -auxio_sbus_attach(device_t dev) -{ - struct auxio_softc *sc; - - sc = device_get_softc(dev); - sc->sc_dev = dev; - - AUXIO_LOCK_INIT(sc); - sc->sc_nauxio = 1; - sc->sc_flags = AUXIO_LEDONLY | AUXIO_SBUS; - - return (auxio_attach_common(sc)); -} diff --git a/sys/dev/auxio/auxioreg.h b/sys/dev/auxio/auxioreg.h deleted file mode 100644 index 3f93cf40635e..000000000000 --- a/sys/dev/auxio/auxioreg.h +++ /dev/null @@ -1,75 +0,0 @@ -/* $FreeBSD$ */ -/* $NetBSD: auxioreg.h,v 1.4 2001/10/22 07:31:41 mrg Exp $ */ - -/*- - * SPDX-License-Identifier: BSD-3-Clause - * - * Copyright (c) 2000 Matthew R. Green - * 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. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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. - */ - -/* - * The AUXIO registers; their offset in the Ebus2 address space, plus the - * bits for each register. Note that the fdthree (FD), SUNW,CS4231 (AUDIO) - * and power (POWER) devices on the Ebus2 have their AUXIO regsiters mapped - * into their own "reg" properties, not the "auxio" device's "reg" properties. - */ -#define AUXIO_FD 0x00720000 -#define AUXIO_FD_DENSENSE_INPUT 0x0 -#define AUXIO_FD_DENSENSE_OUTPUT 0x1 - -#define AUXIO_AUDIO 0x00722000 -#define AUXIO_AUDIO_POWERDOWN 0x0 - -#define AUXIO_POWER 0x00724000 -#define AUXIO_POWER_SYSTEM_OFF 0x0 -#define AUXIO_POWER_COURTESY_OFF 0x1 - -#define AUXIO_LED 0x00726000 -#define AUXIO_LED_LED 1 - -#define AUXIO_PCI 0x00728000 -#define AUXIO_PCI_SLOT0 0x0 /* two bits each */ -#define AUXIO_PCI_SLOT1 0x2 -#define AUXIO_PCI_SLOT2 0x4 -#define AUXIO_PCI_SLOT3 0x6 -#define AUXIO_PCI_MODE 0x8 - -#define AUXIO_FREQ 0x0072a000 -#define AUXIO_FREQ_FREQ0 0x0 -#define AUXIO_FREQ_FREQ1 0x1 -#define AUXIO_FREQ_FREQ2 0x2 - -#define AUXIO_SCSI 0x0072c000 -#define AUXIO_SCSI_INT_OSC_EN 0x0 -#define AUXIO_SCSI_EXT_OSC_EN 0x1 - -#define AUXIO_TEMP 0x0072f000 -#define AUXIO_TEMP_SELECT 0x0 -#define AUXIO_TEMP_CLOCK 0x1 -#define AUXIO_TEMP_ENABLE 0x2 -#define AUXIO_TEMP_DATAOUT 0x3 -#define AUXIO_TEMP_DATAINT 0x4 diff --git a/sys/dev/bge/if_bge.c b/sys/dev/bge/if_bge.c index fab4c1bb4bb2..b91ee5de9649 100644 --- a/sys/dev/bge/if_bge.c +++ b/sys/dev/bge/if_bge.c @@ -112,13 +112,6 @@ __FBSDID("$FreeBSD$"); #include "miidevs.h" #include -#ifdef __sparc64__ -#include -#include -#include -#include -#endif - #include #include @@ -557,47 +550,9 @@ static SYSCTL_NODE(_hw, OID_AUTO, bge, CTLFLAG_RD, 0, "BGE driver parameters"); SYSCTL_INT(_hw_bge, OID_AUTO, allow_asf, CTLFLAG_RDTUN, &bge_allow_asf, 0, "Allow ASF mode if available"); -#define SPARC64_BLADE_1500_MODEL "SUNW,Sun-Blade-1500" -#define SPARC64_BLADE_1500_PATH_BGE "/pci@1f,700000/network@2" -#define SPARC64_BLADE_2500_MODEL "SUNW,Sun-Blade-2500" -#define SPARC64_BLADE_2500_PATH_BGE "/pci@1c,600000/network@3" -#define SPARC64_OFW_SUBVENDOR "subsystem-vendor-id" - static int bge_has_eaddr(struct bge_softc *sc) { -#ifdef __sparc64__ - char buf[sizeof(SPARC64_BLADE_1500_PATH_BGE)]; - device_t dev; - uint32_t subvendor; - - dev = sc->bge_dev; - - /* - * The on-board BGEs found in sun4u machines aren't fitted with - * an EEPROM which means that we have to obtain the MAC address - * via OFW and that some tests will always fail. We distinguish - * such BGEs by the subvendor ID, which also has to be obtained - * from OFW instead of the PCI configuration space as the latter - * indicates Broadcom as the subvendor of the netboot interface. - * For early Blade 1500 and 2500 we even have to check the OFW - * device path as the subvendor ID always defaults to Broadcom - * there. - */ - if (OF_getprop(ofw_bus_get_node(dev), SPARC64_OFW_SUBVENDOR, - &subvendor, sizeof(subvendor)) == sizeof(subvendor) && - (subvendor == FJTSU_VENDORID || subvendor == SUN_VENDORID)) - return (0); - memset(buf, 0, sizeof(buf)); - if (OF_package_to_path(ofw_bus_get_node(dev), buf, sizeof(buf)) > 0) { - if (strcmp(sparc64_model, SPARC64_BLADE_1500_MODEL) == 0 && - strcmp(buf, SPARC64_BLADE_1500_PATH_BGE) == 0) - return (0); - if (strcmp(sparc64_model, SPARC64_BLADE_2500_MODEL) == 0 && - strcmp(buf, SPARC64_BLADE_2500_PATH_BGE) == 0) - return (0); - } -#endif return (1); } @@ -6744,15 +6699,7 @@ bge_sysctl_mem_read(SYSCTL_HANDLER_ARGS) static int bge_get_eaddr_fw(struct bge_softc *sc, uint8_t ether_addr[]) { -#ifdef __sparc64__ - if (sc->bge_flags & BGE_FLAG_EADDR) - return (1); - - OF_getetheraddr(sc->bge_dev, ether_addr); - return (0); -#else return (1); -#endif } static int diff --git a/sys/dev/cas/if_cas.c b/sys/dev/cas/if_cas.c index 88408e2f3bca..1a20596f2923 100644 --- a/sys/dev/cas/if_cas.c +++ b/sys/dev/cas/if_cas.c @@ -78,7 +78,7 @@ __FBSDID("$FreeBSD$"); #include #include -#if defined(__powerpc__) || defined(__sparc64__) +#if defined(__powerpc__) #include #include #include @@ -1045,14 +1045,10 @@ cas_init_locked(struct cas_softc *sc) /* * Enable infinite bursts for revisions without PCI issues if - * applicable. Doing so greatly improves the TX performance on - * !__sparc64__ (on sparc64, setting CAS_INF_BURST improves TX - * performance only marginally but hurts RX throughput quite a bit). + * applicable. Doing so greatly improves the TX performance. */ CAS_WRITE_4(sc, CAS_INF_BURST, -#if !defined(__sparc64__) (sc->sc_flags & CAS_TABORT) == 0 ? CAS_INF_BURST_EN : -#endif 0); /* Set up interrupts. */ @@ -2652,7 +2648,7 @@ cas_pci_attach(device_t dev) char buf[sizeof(CAS_LOCAL_MAC_ADDRESS)]; struct cas_softc *sc; int i; -#if !(defined(__powerpc__) || defined(__sparc64__)) +#if !defined(__powerpc__) u_char enaddr[4][ETHER_ADDR_LEN]; u_int j, k, lma, pcs[4], phy; #endif @@ -2696,7 +2692,7 @@ cas_pci_attach(device_t dev) CAS_LOCK_INIT(sc, device_get_nameunit(dev)); -#if defined(__powerpc__) || defined(__sparc64__) +#if defined(__powerpc__) OF_getetheraddr(dev, sc->sc_enaddr); if (OF_getprop(ofw_bus_get_node(dev), CAS_PHY_INTERFACE, buf, sizeof(buf)) > 0 || OF_getprop(ofw_bus_get_node(dev), diff --git a/sys/dev/cfi/cfi_disk.c b/sys/dev/cfi/cfi_disk.c index c09946634b08..08aef986b257 100644 --- a/sys/dev/cfi/cfi_disk.c +++ b/sys/dev/cfi/cfi_disk.c @@ -315,8 +315,10 @@ cfi_disk_strategy(struct bio *bp) { struct cfi_disk_softc *sc = bp->bio_disk->d_drv1; - if (sc == NULL) - goto invalid; + if (sc == NULL) { + biofinish(bp, NULL, EINVAL); + return; + } if (bp->bio_bcount == 0) { bp->bio_resid = bp->bio_bcount; biodone(bp); @@ -330,13 +332,11 @@ cfi_disk_strategy(struct bio *bp) bioq_insert_tail(&sc->bioq, bp); mtx_unlock(&sc->qlock); taskqueue_enqueue(sc->tq, &sc->iotask); - return; + break; + default: + biofinish(bp, NULL, EOPNOTSUPP); + break; } - /* fall thru... */ -invalid: - bp->bio_flags |= BIO_ERROR; - bp->bio_error = EINVAL; - biodone(bp); } static int diff --git a/sys/dev/cxgbe/adapter.h b/sys/dev/cxgbe/adapter.h index 21a985687afd..6a9e86a51225 100644 --- a/sys/dev/cxgbe/adapter.h +++ b/sys/dev/cxgbe/adapter.h @@ -54,6 +54,7 @@ #include #include #include +#include #include #include @@ -191,6 +192,7 @@ struct vi_info { struct port_info *pi; struct ifnet *ifp; + struct pfil_head *pfil; unsigned long flags; int if_flags; @@ -316,24 +318,17 @@ struct port_info { #define IS_MAIN_VI(vi) ((vi) == &((vi)->pi->vi[0])) -/* Where the cluster came from, how it has been carved up. */ -struct cluster_layout { - int8_t zidx; - int8_t hwidx; - uint16_t region1; /* mbufs laid out within this region */ - /* region2 is the DMA region */ - uint16_t region3; /* cluster_metadata within this region */ -}; - struct cluster_metadata { + uma_zone_t zone; + caddr_t cl; u_int refcount; - struct fl_sdesc *sd; /* For debug only. Could easily be stale */ }; struct fl_sdesc { caddr_t cl; uint16_t nmbuf; /* # of driver originated mbufs with ref on cluster */ - struct cluster_layout cll; + int16_t moff; /* offset of metadata from cl */ + uint8_t zidx; }; struct tx_desc { @@ -465,18 +460,15 @@ struct sge_eq { char lockname[16]; }; -struct sw_zone_info { +struct rx_buf_info { uma_zone_t zone; /* zone that this cluster comes from */ - int size; /* size of cluster: 2K, 4K, 9K, 16K, etc. */ - int type; /* EXT_xxx type of the cluster */ - int8_t head_hwidx; - int8_t tail_hwidx; -}; - -struct hw_buf_info { - int8_t zidx; /* backpointer to zone; -ve means unused */ - int8_t next; /* next hwidx for this zone; -1 means no more */ - int size; + uint16_t size1; /* same as size of cluster: 2K/4K/9K/16K. + * hwsize[hwidx1] = size1. No spare. */ + uint16_t size2; /* hwsize[hwidx2] = size2. + * spare in cluster = size1 - size2. */ + int8_t hwidx1; /* SGE bufsize idx for size1 */ + int8_t hwidx2; /* SGE bufsize idx for size2 */ + uint8_t type; /* EXT_xxx type of the cluster */ }; enum { @@ -518,7 +510,8 @@ struct sge_fl { struct mtx fl_lock; __be64 *desc; /* KVA of descriptor ring, ptr to addresses */ struct fl_sdesc *sdesc; /* KVA of software descriptor ring */ - struct cluster_layout cll_def; /* default refill zone, layout */ + uint16_t zidx; /* refill zone idx */ + uint16_t safe_zidx; uint16_t lowat; /* # of buffers <= this means fl needs help */ int flags; uint16_t buf_boundary; @@ -536,8 +529,6 @@ struct sge_fl { u_int rx_offset; /* offset in fl buf (when buffer packing) */ volatile uint32_t *udb; - uint64_t mbuf_allocated;/* # of mbuf allocated from zone_mbuf */ - uint64_t mbuf_inlined; /* # of mbuf created within clusters */ uint64_t cl_allocated; /* # of clusters allocated */ uint64_t cl_recycled; /* # of clusters recycled */ uint64_t cl_fast_recycled; /* # of clusters recycled (fast) */ @@ -554,7 +545,6 @@ struct sge_fl { bus_dmamap_t desc_map; char lockname[16]; bus_addr_t ba; /* bus address of descriptor ring */ - struct cluster_layout cll_alt; /* alternate refill zone, layout */ }; struct mp_ring; @@ -780,10 +770,8 @@ struct sge { struct sge_iq **iqmap; /* iq->cntxt_id to iq mapping */ struct sge_eq **eqmap; /* eq->cntxt_id to eq mapping */ - int8_t safe_hwidx1; /* may not have room for metadata */ - int8_t safe_hwidx2; /* with room for metadata and maybe more */ - struct sw_zone_info sw_zone_info[SW_ZONE_SIZES]; - struct hw_buf_info hw_buf_info[SGE_FLBUF_SIZES]; + int8_t safe_zidx; + struct rx_buf_info rx_buf_info[SW_ZONE_SIZES]; }; struct devnames { diff --git a/sys/dev/cxgbe/t4_main.c b/sys/dev/cxgbe/t4_main.c index ef175b97a2a1..48263bf5fef7 100644 --- a/sys/dev/cxgbe/t4_main.c +++ b/sys/dev/cxgbe/t4_main.c @@ -401,6 +401,22 @@ SYSCTL_INT(_hw_cxgbe_toe_rexmt_backoff, OID_AUTO, 15, CTLFLAG_RDTUN, #endif #ifdef DEV_NETMAP +#define NN_MAIN_VI (1 << 0) /* Native netmap on the main VI */ +#define NN_EXTRA_VI (1 << 1) /* Native netmap on the extra VI(s) */ +static int t4_native_netmap = NN_EXTRA_VI; +SYSCTL_INT(_hw_cxgbe, OID_AUTO, native_netmap, CTLFLAG_RDTUN, &t4_native_netmap, + 0, "Native netmap support. bit 0 = main VI, bit 1 = extra VIs"); + +#define NNMTXQ 8 +static int t4_nnmtxq = -NNMTXQ; +SYSCTL_INT(_hw_cxgbe, OID_AUTO, nnmtxq, CTLFLAG_RDTUN, &t4_nnmtxq, 0, + "Number of netmap TX queues"); + +#define NNMRXQ 8 +static int t4_nnmrxq = -NNMRXQ; +SYSCTL_INT(_hw_cxgbe, OID_AUTO, nnmrxq, CTLFLAG_RDTUN, &t4_nnmrxq, 0, + "Number of netmap RX queues"); + #define NNMTXQ_VI 2 static int t4_nnmtxq_vi = -NNMTXQ_VI; SYSCTL_INT(_hw_cxgbe, OID_AUTO, nnmtxq_vi, CTLFLAG_RDTUN, &t4_nnmtxq_vi, 0, @@ -621,6 +637,8 @@ struct intrs_and_queues { uint16_t nrxq; /* # of NIC rxq's for each port */ uint16_t nofldtxq; /* # of TOE/ETHOFLD txq's for each port */ uint16_t nofldrxq; /* # of TOE rxq's for each port */ + uint16_t nnmtxq; /* # of netmap txq's */ + uint16_t nnmrxq; /* # of netmap rxq's */ /* The vcxgbe/vcxl interfaces use these and not the ones above. */ uint16_t ntxq_vi; /* # of NIC txq's */ @@ -1247,9 +1265,15 @@ t4_attach(device_t dev) } #endif #ifdef DEV_NETMAP - if (num_vis > 1) { - s->nnmrxq = nports * (num_vis - 1) * iaq.nnmrxq_vi; - s->nnmtxq = nports * (num_vis - 1) * iaq.nnmtxq_vi; + s->nnmrxq = 0; + s->nnmtxq = 0; + if (t4_native_netmap & NN_MAIN_VI) { + s->nnmrxq += nports * iaq.nnmrxq; + s->nnmtxq += nports * iaq.nnmtxq; + } + if (num_vis > 1 && t4_native_netmap & NN_EXTRA_VI) { + s->nnmrxq += nports * (num_vis - 1) * iaq.nnmrxq_vi; + s->nnmtxq += nports * (num_vis - 1) * iaq.nnmtxq_vi; } s->neq += s->nnmtxq + s->nnmrxq; s->niq += s->nnmrxq; @@ -1344,14 +1368,17 @@ t4_attach(device_t dev) ofld_rqidx += vi->nofldrxq; #endif #ifdef DEV_NETMAP - if (j > 0) { - vi->first_nm_rxq = nm_rqidx; - vi->first_nm_txq = nm_tqidx; + vi->first_nm_rxq = nm_rqidx; + vi->first_nm_txq = nm_tqidx; + if (j == 0) { + vi->nnmrxq = iaq.nnmrxq; + vi->nnmtxq = iaq.nnmtxq; + } else { vi->nnmrxq = iaq.nnmrxq_vi; vi->nnmtxq = iaq.nnmtxq_vi; - nm_rqidx += vi->nnmrxq; - nm_tqidx += vi->nnmtxq; } + nm_rqidx += vi->nnmrxq; + nm_tqidx += vi->nnmtxq; #endif } } @@ -1673,6 +1700,7 @@ cxgbe_vi_attach(device_t dev, struct vi_info *vi) { struct ifnet *ifp; struct sbuf *sb; + struct pfil_head_args pa; vi->xact_addr_filt = -1; callout_init(&vi->tick, 1); @@ -1768,6 +1796,12 @@ cxgbe_vi_attach(device_t dev, struct vi_info *vi) vi_sysctls(vi); + pa.pa_version = PFIL_VERSION; + pa.pa_flags = PFIL_IN; + pa.pa_type = PFIL_TYPE_ETHERNET; + pa.pa_headname = ifp->if_xname; + vi->pfil = pfil_head_register(&pa); + return (0); } @@ -1808,6 +1842,11 @@ cxgbe_vi_detach(struct vi_info *vi) { struct ifnet *ifp = vi->ifp; + if (vi->pfil != NULL) { + pfil_head_unregister(vi->pfil); + vi->pfil = NULL; + } + ether_ifdetach(ifp); /* Let detach proceed even if these fail. */ @@ -3304,10 +3343,10 @@ fixup_devlog_params(struct adapter *sc) static void update_nirq(struct intrs_and_queues *iaq, int nports) { - int extra = T4_EXTRA_INTR; - iaq->nirq = extra; - iaq->nirq += nports * (iaq->nrxq + iaq->nofldrxq); + iaq->nirq = T4_EXTRA_INTR; + iaq->nirq += nports * max(iaq->nrxq, iaq->nnmrxq); + iaq->nirq += nports * iaq->nofldrxq; iaq->nirq += nports * (iaq->num_vis - 1) * max(iaq->nrxq_vi, iaq->nnmrxq_vi); iaq->nirq += nports * (iaq->num_vis - 1) * iaq->nofldrxq_vi; @@ -3346,8 +3385,14 @@ calculate_iaq(struct adapter *sc, struct intrs_and_queues *iaq, int itype, } #endif #ifdef DEV_NETMAP - iaq->nnmtxq_vi = t4_nnmtxq_vi; - iaq->nnmrxq_vi = t4_nnmrxq_vi; + if (t4_native_netmap & NN_MAIN_VI) { + iaq->nnmtxq = t4_nnmtxq; + iaq->nnmrxq = t4_nnmrxq; + } + if (t4_native_netmap & NN_EXTRA_VI) { + iaq->nnmtxq_vi = t4_nnmtxq_vi; + iaq->nnmrxq_vi = t4_nnmrxq_vi; + } #endif update_nirq(iaq, nports); @@ -3405,6 +3450,8 @@ calculate_iaq(struct adapter *sc, struct intrs_and_queues *iaq, int itype, do { iaq->nrxq--; } while (!powerof2(iaq->nrxq)); + if (iaq->nnmrxq > iaq->nrxq) + iaq->nnmrxq = iaq->nrxq; } if (iaq->nofldrxq > 1) iaq->nofldrxq >>= 1; @@ -3426,10 +3473,14 @@ calculate_iaq(struct adapter *sc, struct intrs_and_queues *iaq, int itype, device_printf(sc->dev, "running with minimal number of queues. " "itype %d, navail %u.\n", itype, navail); iaq->nirq = 1; - MPASS(iaq->nrxq == 1); + iaq->nrxq = 1; iaq->ntxq = 1; - if (iaq->nofldrxq > 1) + if (iaq->nofldrxq > 0) { + iaq->nofldrxq = 1; iaq->nofldtxq = 1; + } + iaq->nnmtxq = 0; + iaq->nnmrxq = 0; done: MPASS(iaq->num_vis > 0); if (iaq->num_vis > 1) { @@ -10291,8 +10342,6 @@ clear_stats(struct adapter *sc, u_int port_id) rxq->rxcsum = 0; rxq->vlan_extraction = 0; - rxq->fl.mbuf_allocated = 0; - rxq->fl.mbuf_inlined = 0; rxq->fl.cl_allocated = 0; rxq->fl.cl_recycled = 0; rxq->fl.cl_fast_recycled = 0; @@ -10334,8 +10383,6 @@ clear_stats(struct adapter *sc, u_int port_id) #endif #ifdef TCP_OFFLOAD for_each_ofld_rxq(vi, i, ofld_rxq) { - ofld_rxq->fl.mbuf_allocated = 0; - ofld_rxq->fl.mbuf_inlined = 0; ofld_rxq->fl.cl_allocated = 0; ofld_rxq->fl.cl_recycled = 0; ofld_rxq->fl.cl_fast_recycled = 0; @@ -10884,6 +10931,8 @@ tweak_tunables(void) #endif #ifdef DEV_NETMAP + calculate_nqueues(&t4_nnmtxq, nc, NNMTXQ); + calculate_nqueues(&t4_nnmrxq, nc, NNMRXQ); calculate_nqueues(&t4_nnmtxq_vi, nc, NNMTXQ_VI); calculate_nqueues(&t4_nnmrxq_vi, nc, NNMRXQ_VI); #endif diff --git a/sys/dev/cxgbe/t4_netmap.c b/sys/dev/cxgbe/t4_netmap.c index f354f4e3d4b5..221ad823eb7f 100644 --- a/sys/dev/cxgbe/t4_netmap.c +++ b/sys/dev/cxgbe/t4_netmap.c @@ -63,7 +63,7 @@ extern int fl_pad; /* XXXNM */ * 2 = supermassive black hole (buffer packing enabled) */ int black_hole = 0; -SYSCTL_INT(_hw_cxgbe, OID_AUTO, nm_black_hole, CTLFLAG_RDTUN, &black_hole, 0, +SYSCTL_INT(_hw_cxgbe, OID_AUTO, nm_black_hole, CTLFLAG_RWTUN, &black_hole, 0, "Sink incoming packets."); int rx_ndesc = 256; @@ -85,7 +85,7 @@ SYSCTL_INT(_hw_cxgbe, OID_AUTO, nm_holdoff_tmr_idx, CTLFLAG_RWTUN, * 1: no backpressure, drop packets for the congested queue immediately. */ static int nm_cong_drop = 1; -SYSCTL_INT(_hw_cxgbe, OID_AUTO, nm_cong_drop, CTLFLAG_RDTUN, +SYSCTL_INT(_hw_cxgbe, OID_AUTO, nm_cong_drop, CTLFLAG_RWTUN, &nm_cong_drop, 0, "Congestion control for netmap rx queues (0 = backpressure, 1 = drop"); @@ -110,6 +110,16 @@ static int nm_split_rss = 0; SYSCTL_INT(_hw_cxgbe, OID_AUTO, nm_split_rss, CTLFLAG_RWTUN, &nm_split_rss, 0, "Split the netmap rx queues into two groups."); +/* + * netmap(4) says "netmap does not use features such as checksum offloading, TCP + * segmentation offloading, encryption, VLAN encapsulation/decapsulation, etc." + * but this knob can be used to get the hardware to checksum all tx traffic + * anyway. + */ +static int nm_txcsum = 0; +SYSCTL_INT(_hw_cxgbe, OID_AUTO, nm_txcsum, CTLFLAG_RWTUN, + &nm_txcsum, 0, "Enable transmit checksum offloading."); + static int alloc_nm_rxq_hwq(struct vi_info *vi, struct sge_nm_rxq *nm_rxq, int cong) { @@ -345,7 +355,7 @@ cxgbe_netmap_on(struct adapter *sc, struct vi_info *vi, struct ifnet *ifp, struct sge_nm_rxq *nm_rxq; struct sge_nm_txq *nm_txq; int rc, i, j, hwidx, defq, nrssq; - struct hw_buf_info *hwb; + struct rx_buf_info *rxb; ASSERT_SYNCHRONIZED_OP(sc); @@ -353,17 +363,22 @@ cxgbe_netmap_on(struct adapter *sc, struct vi_info *vi, struct ifnet *ifp, (ifp->if_drv_flags & IFF_DRV_RUNNING) == 0) return (EAGAIN); - hwb = &sc->sge.hw_buf_info[0]; - for (i = 0; i < SGE_FLBUF_SIZES; i++, hwb++) { - if (hwb->size == NETMAP_BUF_SIZE(na)) + rxb = &sc->sge.rx_buf_info[0]; + for (i = 0; i < SW_ZONE_SIZES; i++, rxb++) { + if (rxb->size1 == NETMAP_BUF_SIZE(na)) { + hwidx = rxb->hwidx1; break; + } + if (rxb->size2 == NETMAP_BUF_SIZE(na)) { + hwidx = rxb->hwidx2; + break; + } } - if (i >= SGE_FLBUF_SIZES) { + if (i >= SW_ZONE_SIZES) { if_printf(ifp, "no hwidx for netmap buffer size %d.\n", NETMAP_BUF_SIZE(na)); return (ENXIO); } - hwidx = i; /* Must set caps before calling netmap_reset */ nm_set_native_flags(na); @@ -691,13 +706,8 @@ cxgbe_nm_tx(struct adapter *sc, struct sge_nm_txq *nm_txq, cpl->ctrl0 = nm_txq->cpl_ctrl0; cpl->pack = 0; cpl->len = htobe16(slot->len); - /* - * netmap(4) says "netmap does not use features such as - * checksum offloading, TCP segmentation offloading, - * encryption, VLAN encapsulation/decapsulation, etc." - */ - cpl->ctrl1 = htobe64(F_TXPKT_IPCSUM_DIS | - F_TXPKT_L4CSUM_DIS); + cpl->ctrl1 = nm_txcsum ? 0 : + htobe64(F_TXPKT_IPCSUM_DIS | F_TXPKT_L4CSUM_DIS); usgl = (void *)(cpl + 1); usgl->cmd_nsge = htobe32(V_ULPTX_CMD(ULP_TX_SC_DSGL) | @@ -986,6 +996,7 @@ cxgbe_nm_attach(struct vi_info *vi) na.nm_register = cxgbe_netmap_reg; na.num_tx_rings = vi->nnmtxq; na.num_rx_rings = vi->nnmrxq; + na.rx_buf_maxsize = MAX_MTU; netmap_attach(&na); /* This adds IFCAP_NETMAP to if_capabilities */ } diff --git a/sys/dev/cxgbe/t4_sge.c b/sys/dev/cxgbe/t4_sge.c index 53b7673374bf..3a144ae817ff 100644 --- a/sys/dev/cxgbe/t4_sge.c +++ b/sys/dev/cxgbe/t4_sge.c @@ -147,16 +147,6 @@ static int fl_pack = -1; SYSCTL_INT(_hw_cxgbe, OID_AUTO, fl_pack, CTLFLAG_RDTUN, &fl_pack, 0, "payload pack boundary (bytes)"); -/* - * Allow the driver to create mbuf(s) in a cluster allocated for rx. - * 0: never; always allocate mbufs from the zone_mbuf UMA zone. - * 1: ok to create mbuf(s) within a cluster if there is room. - */ -static int allow_mbufs_in_cluster = 1; -SYSCTL_INT(_hw_cxgbe, OID_AUTO, allow_mbufs_in_cluster, CTLFLAG_RDTUN, - &allow_mbufs_in_cluster, 0, - "Allow driver to create mbufs within a rx cluster"); - /* * Largest rx cluster size that the driver is allowed to allocate. */ @@ -229,7 +219,8 @@ struct sgl { static int service_iq(struct sge_iq *, int); static int service_iq_fl(struct sge_iq *, int); static struct mbuf *get_fl_payload(struct adapter *, struct sge_fl *, uint32_t); -static int t4_eth_rx(struct sge_iq *, const struct rss_header *, struct mbuf *); +static int eth_rx(struct adapter *, struct sge_rxq *, const struct iq_desc *, + u_int); static inline void init_iq(struct sge_iq *, struct adapter *, int, int, int); static inline void init_fl(struct adapter *, struct sge_fl *, int, int, char *); static inline void init_eq(struct adapter *, struct sge_eq *, int, int, uint8_t, @@ -284,8 +275,7 @@ static int refill_fl(struct adapter *, struct sge_fl *, int); static void refill_sfl(void *); static int alloc_fl_sdesc(struct sge_fl *); static void free_fl_sdesc(struct adapter *, struct sge_fl *); -static void find_best_refill_source(struct adapter *, struct sge_fl *, int); -static void find_safe_refill_source(struct adapter *, struct sge_fl *); +static int find_refill_source(struct adapter *, int, bool); static void add_fl_to_sfl(struct adapter *, struct sge_fl *); static inline void get_pkt_gl(struct mbuf *, struct sglist *); @@ -561,7 +551,6 @@ t4_sge_modload(void) t4_register_cpl_handler(CPL_FW4_MSG, handle_fw_msg); t4_register_cpl_handler(CPL_FW6_MSG, handle_fw_msg); t4_register_cpl_handler(CPL_SGE_EGR_UPDATE, handle_sge_egr_update); - t4_register_cpl_handler(CPL_RX_PKT, t4_eth_rx); #ifdef RATELIMIT t4_register_shared_cpl_handler(CPL_FW4_ACK, ethofld_fw4_ack, CPL_COOKIE_ETHOFLD); @@ -589,6 +578,9 @@ t4_sge_extfree_refs(void) return (refs - rels); } +/* max 4096 */ +#define MAX_PACK_BOUNDARY 512 + static inline void setup_pad_and_pack_boundaries(struct adapter *sc) { @@ -635,7 +627,10 @@ setup_pad_and_pack_boundaries(struct adapter *sc) pack = fl_pack; if (fl_pack < 16 || fl_pack == 32 || fl_pack > 4096 || !powerof2(fl_pack)) { - pack = max(sc->params.pci.mps, CACHE_LINE_SIZE); + if (sc->params.pci.mps > MAX_PACK_BOUNDARY) + pack = MAX_PACK_BOUNDARY; + else + pack = max(sc->params.pci.mps, CACHE_LINE_SIZE); MPASS(powerof2(pack)); if (pack < 16) pack = 16; @@ -664,24 +659,19 @@ setup_pad_and_pack_boundaries(struct adapter *sc) void t4_tweak_chip_settings(struct adapter *sc) { - int i; + int i, reg; uint32_t v, m; int intr_timer[SGE_NTIMERS] = {1, 5, 10, 50, 100, 200}; int timer_max = M_TIMERVALUE0 * 1000 / sc->params.vpd.cclk; int intr_pktcount[SGE_NCOUNTERS] = {1, 8, 16, 32}; /* 63 max */ uint16_t indsz = min(RX_COPY_THRESHOLD - 1, M_INDICATESIZE); - static int sge_flbuf_sizes[] = { + static int sw_buf_sizes[] = { MCLBYTES, #if MJUMPAGESIZE != MCLBYTES MJUMPAGESIZE, - MJUMPAGESIZE - CL_METADATA_SIZE, - MJUMPAGESIZE - 2 * MSIZE - CL_METADATA_SIZE, #endif MJUM9BYTES, - MJUM16BYTES, - MCLBYTES - MSIZE - CL_METADATA_SIZE, - MJUM9BYTES - CL_METADATA_SIZE, - MJUM16BYTES - CL_METADATA_SIZE, + MJUM16BYTES }; KASSERT(sc->flags & MASTER_PF, @@ -704,13 +694,16 @@ t4_tweak_chip_settings(struct adapter *sc) V_HOSTPAGESIZEPF7(PAGE_SHIFT - 10); t4_write_reg(sc, A_SGE_HOST_PAGE_SIZE, v); - KASSERT(nitems(sge_flbuf_sizes) <= SGE_FLBUF_SIZES, - ("%s: hw buffer size table too big", __func__)); t4_write_reg(sc, A_SGE_FL_BUFFER_SIZE0, 4096); t4_write_reg(sc, A_SGE_FL_BUFFER_SIZE1, 65536); - for (i = 0; i < min(nitems(sge_flbuf_sizes), SGE_FLBUF_SIZES); i++) { - t4_write_reg(sc, A_SGE_FL_BUFFER_SIZE15 - (4 * i), - sge_flbuf_sizes[i]); + reg = A_SGE_FL_BUFFER_SIZE2; + for (i = 0; i < nitems(sw_buf_sizes); i++) { + MPASS(reg <= A_SGE_FL_BUFFER_SIZE15); + t4_write_reg(sc, reg, sw_buf_sizes[i]); + reg += 4; + MPASS(reg <= A_SGE_FL_BUFFER_SIZE15); + t4_write_reg(sc, reg, sw_buf_sizes[i] - CL_METADATA_SIZE); + reg += 4; } v = V_THRESHOLD_0(intr_pktcount[0]) | V_THRESHOLD_1(intr_pktcount[1]) | @@ -787,11 +780,11 @@ t4_tweak_chip_settings(struct adapter *sc) } /* - * SGE wants the buffer to be at least 64B and then a multiple of 16. If - * padding is in use, the buffer's start and end need to be aligned to the pad - * boundary as well. We'll just make sure that the size is a multiple of the - * boundary here, it is up to the buffer allocation code to make sure the start - * of the buffer is aligned as well. + * SGE wants the buffer to be at least 64B and then a multiple of 16. Its + * address mut be 16B aligned. If padding is in use the buffer's start and end + * need to be aligned to the pad boundary as well. We'll just make sure that + * the size is a multiple of the pad boundary here, it is up to the buffer + * allocation code to make sure the start of the buffer is aligned. */ static inline int hwsz_ok(struct adapter *sc, int hwsz) @@ -820,8 +813,7 @@ t4_read_chip_settings(struct adapter *sc) MJUM9BYTES, MJUM16BYTES }; - struct sw_zone_info *swz, *safe_swz; - struct hw_buf_info *hwb; + struct rx_buf_info *rxb; m = F_RXPKTCPLMODE; v = F_RXPKTCPLMODE; @@ -840,112 +832,49 @@ t4_read_chip_settings(struct adapter *sc) rc = EINVAL; } - /* Filter out unusable hw buffer sizes entirely (mark with -2). */ - hwb = &s->hw_buf_info[0]; - for (i = 0; i < nitems(s->hw_buf_info); i++, hwb++) { - r = sc->params.sge.sge_fl_buffer_size[i]; - hwb->size = r; - hwb->zidx = hwsz_ok(sc, r) ? -1 : -2; - hwb->next = -1; - } + s->safe_zidx = -1; + rxb = &s->rx_buf_info[0]; + for (i = 0; i < SW_ZONE_SIZES; i++, rxb++) { + rxb->size1 = sw_buf_sizes[i]; + rxb->zone = m_getzone(rxb->size1); + rxb->type = m_gettype(rxb->size1); + rxb->size2 = 0; + rxb->hwidx1 = -1; + rxb->hwidx2 = -1; + for (j = 0; j < SGE_FLBUF_SIZES; j++) { + int hwsize = sp->sge_fl_buffer_size[j]; - /* - * Create a sorted list in decreasing order of hw buffer sizes (and so - * increasing order of spare area) for each software zone. - * - * If padding is enabled then the start and end of the buffer must align - * to the pad boundary; if packing is enabled then they must align with - * the pack boundary as well. Allocations from the cluster zones are - * aligned to min(size, 4K), so the buffer starts at that alignment and - * ends at hwb->size alignment. If mbuf inlining is allowed the - * starting alignment will be reduced to MSIZE and the driver will - * exercise appropriate caution when deciding on the best buffer layout - * to use. - */ - n = 0; /* no usable buffer size to begin with */ - swz = &s->sw_zone_info[0]; - safe_swz = NULL; - for (i = 0; i < SW_ZONE_SIZES; i++, swz++) { - int8_t head = -1, tail = -1; - - swz->size = sw_buf_sizes[i]; - swz->zone = m_getzone(swz->size); - swz->type = m_gettype(swz->size); - - if (swz->size < PAGE_SIZE) { - MPASS(powerof2(swz->size)); - if (fl_pad && (swz->size % sp->pad_boundary != 0)) + if (!hwsz_ok(sc, hwsize)) continue; - } - if (swz->size == safest_rx_cluster) - safe_swz = swz; + /* hwidx for size1 */ + if (rxb->hwidx1 == -1 && rxb->size1 == hwsize) + rxb->hwidx1 = j; - hwb = &s->hw_buf_info[0]; - for (j = 0; j < SGE_FLBUF_SIZES; j++, hwb++) { - if (hwb->zidx != -1 || hwb->size > swz->size) + /* hwidx for size2 (buffer packing) */ + if (rxb->size1 - CL_METADATA_SIZE < hwsize) continue; -#ifdef INVARIANTS - if (fl_pad) - MPASS(hwb->size % sp->pad_boundary == 0); -#endif - hwb->zidx = i; - if (head == -1) - head = tail = j; - else if (hwb->size < s->hw_buf_info[tail].size) { - s->hw_buf_info[tail].next = j; - tail = j; - } else { - int8_t *cur; - struct hw_buf_info *t; - - for (cur = &head; *cur != -1; cur = &t->next) { - t = &s->hw_buf_info[*cur]; - if (hwb->size == t->size) { - hwb->zidx = -2; - break; - } - if (hwb->size > t->size) { - hwb->next = *cur; - *cur = j; - break; - } + n = rxb->size1 - hwsize - CL_METADATA_SIZE; + if (n == 0) { + rxb->hwidx2 = j; + rxb->size2 = hwsize; + break; /* stop looking */ + } + if (rxb->hwidx2 != -1) { + if (n < sp->sge_fl_buffer_size[rxb->hwidx2] - + hwsize - CL_METADATA_SIZE) { + rxb->hwidx2 = j; + rxb->size2 = hwsize; } + } else if (n <= 2 * CL_METADATA_SIZE) { + rxb->hwidx2 = j; + rxb->size2 = hwsize; } } - swz->head_hwidx = head; - swz->tail_hwidx = tail; - - if (tail != -1) { - n++; - if (swz->size - s->hw_buf_info[tail].size >= - CL_METADATA_SIZE) - sc->flags |= BUF_PACKING_OK; - } - } - if (n == 0) { - device_printf(sc->dev, "no usable SGE FL buffer size.\n"); - rc = EINVAL; - } - - s->safe_hwidx1 = -1; - s->safe_hwidx2 = -1; - if (safe_swz != NULL) { - s->safe_hwidx1 = safe_swz->head_hwidx; - for (i = safe_swz->head_hwidx; i != -1; i = hwb->next) { - int spare; - - hwb = &s->hw_buf_info[i]; -#ifdef INVARIANTS - if (fl_pad) - MPASS(hwb->size % sp->pad_boundary == 0); -#endif - spare = safe_swz->size - hwb->size; - if (spare >= CL_METADATA_SIZE) { - s->safe_hwidx2 = i; - break; - } - } + if (rxb->hwidx2 != -1) + sc->flags |= BUF_PACKING_OK; + if (s->safe_zidx == -1 && rxb->size1 == safest_rx_cluster) + s->safe_zidx = i; } if (sc->flags & IS_VF) @@ -1006,7 +935,7 @@ t4_sge_sysctls(struct adapter *sc, struct sysctl_ctx_list *ctx, struct sge_params *sp = &sc->params.sge; SYSCTL_ADD_PROC(ctx, children, OID_AUTO, "buffer_sizes", - CTLTYPE_STRING | CTLFLAG_RD, &sc->sge, 0, sysctl_bufsizes, "A", + CTLTYPE_STRING | CTLFLAG_RD, sc, 0, sysctl_bufsizes, "A", "freelist buffer sizes"); SYSCTL_ADD_INT(ctx, children, OID_AUTO, "fl_pktshift", CTLFLAG_RD, @@ -1602,6 +1531,20 @@ last_flit_to_ns(struct adapter *sc, uint64_t lf) return (n * 1000000 / sc->params.vpd.cclk); } +static inline void +move_to_next_rxbuf(struct sge_fl *fl) +{ + + fl->rx_offset = 0; + if (__predict_false((++fl->cidx & 7) == 0)) { + uint16_t cidx = fl->cidx >> 3; + + if (__predict_false(cidx == fl->sidx)) + fl->cidx = cidx = 0; + fl->hw_cidx = cidx; + } +} + /* * Deals with interrupts on an iq+fl queue. */ @@ -1612,8 +1555,8 @@ service_iq_fl(struct sge_iq *iq, int budget) struct sge_fl *fl; struct adapter *sc = iq->adapter; struct iq_desc *d = &iq->desc[iq->cidx]; - int ndescs = 0, limit; - int rsp_type, refill, starved; + int ndescs, limit; + int rsp_type, starved; uint32_t lq; uint16_t fl_hw_cidx; struct mbuf *m0; @@ -1625,10 +1568,7 @@ service_iq_fl(struct sge_iq *iq, int budget) KASSERT(iq->state == IQS_BUSY, ("%s: iq %p not BUSY", __func__, iq)); MPASS(iq->flags & IQ_HAS_FL); - limit = budget ? budget : iq->qsize / 16; - fl = &rxq->fl; - fl_hw_cidx = fl->hw_cidx; /* stable snapshot */ - + ndescs = 0; #if defined(INET) || defined(INET6) if (iq->flags & IQ_ADJ_CREDIT) { MPASS(sort_before_lro(lro)); @@ -1646,37 +1586,39 @@ service_iq_fl(struct sge_iq *iq, int budget) MPASS((iq->flags & IQ_ADJ_CREDIT) == 0); #endif + limit = budget ? budget : iq->qsize / 16; + fl = &rxq->fl; + fl_hw_cidx = fl->hw_cidx; /* stable snapshot */ while ((d->rsp.u.type_gen & F_RSPD_GEN) == iq->gen) { rmb(); - refill = 0; m0 = NULL; rsp_type = G_RSPD_TYPE(d->rsp.u.type_gen); lq = be32toh(d->rsp.pldbuflen_qid); switch (rsp_type) { case X_RSPD_TYPE_FLBUF: + if (lq & F_RSPD_NEWBUF) { + if (fl->rx_offset > 0) + move_to_next_rxbuf(fl); + lq = G_RSPD_LEN(lq); + } + if (IDXDIFF(fl->hw_cidx, fl_hw_cidx, fl->sidx) > 4) { + FL_LOCK(fl); + refill_fl(sc, fl, 64); + FL_UNLOCK(fl); + fl_hw_cidx = fl->hw_cidx; + } + if (d->rss.opcode == CPL_RX_PKT) { + if (__predict_true(eth_rx(sc, rxq, d, lq) == 0)) + break; + goto out; + } m0 = get_fl_payload(sc, fl, lq); if (__predict_false(m0 == NULL)) goto out; - refill = IDXDIFF(fl->hw_cidx, fl_hw_cidx, fl->sidx) > 2; - - if (iq->flags & IQ_RX_TIMESTAMP) { - /* - * Fill up rcv_tstmp but do not set M_TSTMP. - * rcv_tstmp is not in the format that the - * kernel expects and we don't want to mislead - * it. For now this is only for custom code - * that knows how to interpret cxgbe's stamp. - */ - m0->m_pkthdr.rcv_tstmp = - last_flit_to_ns(sc, d->rsp.u.last_flit); -#ifdef notyet - m0->m_flags |= M_TSTMP; -#endif - } /* fall through */ @@ -1721,7 +1663,6 @@ service_iq_fl(struct sge_iq *iq, int budget) t4_write_reg(sc, sc->sge_gts_reg, V_CIDXINC(ndescs) | V_INGRESSQID(iq->cntxt_id) | V_SEINTARM(V_QINTR_TIMER_IDX(X_TIMERREG_UPDATE_CIDX))); - ndescs = 0; #if defined(INET) || defined(INET6) if (iq->flags & IQ_LRO_ENABLED && @@ -1730,19 +1671,9 @@ service_iq_fl(struct sge_iq *iq, int budget) tcp_lro_flush_inactive(lro, &lro_timeout); } #endif - if (budget) { - FL_LOCK(fl); - refill_fl(sc, fl, 32); - FL_UNLOCK(fl); - + if (budget) return (EINPROGRESS); - } - } - if (refill) { - FL_LOCK(fl); - refill_fl(sc, fl, 32); - FL_UNLOCK(fl); - fl_hw_cidx = fl->hw_cidx; + ndescs = 0; } } out: @@ -1771,49 +1702,28 @@ service_iq_fl(struct sge_iq *iq, int budget) return (0); } -static inline int -cl_has_metadata(struct sge_fl *fl, struct cluster_layout *cll) -{ - int rc = fl->flags & FL_BUF_PACKING || cll->region1 > 0; - - if (rc) - MPASS(cll->region3 >= CL_METADATA_SIZE); - - return (rc); -} - static inline struct cluster_metadata * -cl_metadata(struct adapter *sc, struct sge_fl *fl, struct cluster_layout *cll, - caddr_t cl) +cl_metadata(struct fl_sdesc *sd) { - if (cl_has_metadata(fl, cll)) { - struct sw_zone_info *swz = &sc->sge.sw_zone_info[cll->zidx]; - - return ((struct cluster_metadata *)(cl + swz->size) - 1); - } - return (NULL); + return ((void *)(sd->cl + sd->moff)); } static void rxb_free(struct mbuf *m) { - uma_zone_t zone = m->m_ext.ext_arg1; - void *cl = m->m_ext.ext_arg2; + struct cluster_metadata *clm = m->m_ext.ext_arg1; - uma_zfree(zone, cl); + uma_zfree(clm->zone, clm->cl); counter_u64_add(extfree_rels, 1); } /* - * The mbuf returned by this function could be allocated from zone_mbuf or - * constructed in spare room in the cluster. - * - * The mbuf carries the payload in one of these ways - * a) frame inside the mbuf (mbuf from zone_mbuf) - * b) m_cljset (for clusters without metadata) zone_mbuf - * c) m_extaddref (cluster with metadata) inline mbuf - * d) m_extaddref (cluster with metadata) zone_mbuf + * The mbuf returned comes from zone_muf and carries the payload in one of these + * ways + * a) complete frame inside the mbuf + * b) m_cljset (for clusters without metadata) + * d) m_extaddref (cluster with metadata) */ static struct mbuf * get_scatter_segment(struct adapter *sc, struct sge_fl *fl, int fr_offset, @@ -1821,118 +1731,86 @@ get_scatter_segment(struct adapter *sc, struct sge_fl *fl, int fr_offset, { struct mbuf *m; struct fl_sdesc *sd = &fl->sdesc[fl->cidx]; - struct cluster_layout *cll = &sd->cll; - struct sw_zone_info *swz = &sc->sge.sw_zone_info[cll->zidx]; - struct hw_buf_info *hwb = &sc->sge.hw_buf_info[cll->hwidx]; - struct cluster_metadata *clm = cl_metadata(sc, fl, cll, sd->cl); + struct rx_buf_info *rxb = &sc->sge.rx_buf_info[sd->zidx]; + struct cluster_metadata *clm; int len, blen; caddr_t payload; - blen = hwb->size - fl->rx_offset; /* max possible in this buf */ - len = min(remaining, blen); - payload = sd->cl + cll->region1 + fl->rx_offset; if (fl->flags & FL_BUF_PACKING) { - const u_int l = fr_offset + len; - const u_int pad = roundup2(l, fl->buf_boundary) - l; + u_int l, pad; - if (fl->rx_offset + len + pad < hwb->size) + blen = rxb->size2 - fl->rx_offset; /* max possible in this buf */ + len = min(remaining, blen); + payload = sd->cl + fl->rx_offset; + + l = fr_offset + len; + pad = roundup2(l, fl->buf_boundary) - l; + if (fl->rx_offset + len + pad < rxb->size2) blen = len + pad; - MPASS(fl->rx_offset + blen <= hwb->size); + MPASS(fl->rx_offset + blen <= rxb->size2); } else { MPASS(fl->rx_offset == 0); /* not packing */ + blen = rxb->size1; + len = min(remaining, blen); + payload = sd->cl; } - - if (sc->sc_do_rxcopy && len < RX_COPY_THRESHOLD) { - - /* - * Copy payload into a freshly allocated mbuf. - */ - - m = fr_offset == 0 ? - m_gethdr(M_NOWAIT, MT_DATA) : m_get(M_NOWAIT, MT_DATA); - if (m == NULL) + if (fr_offset == 0) { + m = m_gethdr(M_NOWAIT, MT_DATA); + if (__predict_false(m == NULL)) return (NULL); - fl->mbuf_allocated++; - - /* copy data to mbuf */ - bcopy(payload, mtod(m, caddr_t), len); - - } else if (sd->nmbuf * MSIZE < cll->region1) { - - /* - * There's spare room in the cluster for an mbuf. Create one - * and associate it with the payload that's in the cluster. - */ - - MPASS(clm != NULL); - m = (struct mbuf *)(sd->cl + sd->nmbuf * MSIZE); - /* No bzero required */ - if (m_init(m, M_NOWAIT, MT_DATA, - fr_offset == 0 ? M_PKTHDR | M_NOFREE : M_NOFREE)) - return (NULL); - fl->mbuf_inlined++; - m_extaddref(m, payload, blen, &clm->refcount, rxb_free, - swz->zone, sd->cl); - if (sd->nmbuf++ == 0) - counter_u64_add(extfree_refs, 1); - - } else { - - /* - * Grab an mbuf from zone_mbuf and associate it with the - * payload in the cluster. - */ - - m = fr_offset == 0 ? - m_gethdr(M_NOWAIT, MT_DATA) : m_get(M_NOWAIT, MT_DATA); - if (m == NULL) - return (NULL); - fl->mbuf_allocated++; - if (clm != NULL) { - m_extaddref(m, payload, blen, &clm->refcount, - rxb_free, swz->zone, sd->cl); - if (sd->nmbuf++ == 0) - counter_u64_add(extfree_refs, 1); - } else { - m_cljset(m, sd->cl, swz->type); - sd->cl = NULL; /* consumed, not a recycle candidate */ - } - } - if (fr_offset == 0) m->m_pkthdr.len = remaining; + } else { + m = m_get(M_NOWAIT, MT_DATA); + if (__predict_false(m == NULL)) + return (NULL); + } m->m_len = len; - if (fl->flags & FL_BUF_PACKING) { + if (sc->sc_do_rxcopy && len < RX_COPY_THRESHOLD) { + /* copy data to mbuf */ + bcopy(payload, mtod(m, caddr_t), len); + if (fl->flags & FL_BUF_PACKING) { + fl->rx_offset += blen; + MPASS(fl->rx_offset <= rxb->size2); + if (fl->rx_offset < rxb->size2) + return (m); /* without advancing the cidx */ + } + } else if (fl->flags & FL_BUF_PACKING) { + clm = cl_metadata(sd); + if (sd->nmbuf++ == 0) { + clm->refcount = 1; + clm->zone = rxb->zone; + clm->cl = sd->cl; + counter_u64_add(extfree_refs, 1); + } + m_extaddref(m, payload, blen, &clm->refcount, rxb_free, clm, + NULL); + fl->rx_offset += blen; - MPASS(fl->rx_offset <= hwb->size); - if (fl->rx_offset < hwb->size) + MPASS(fl->rx_offset <= rxb->size2); + if (fl->rx_offset < rxb->size2) return (m); /* without advancing the cidx */ + } else { + m_cljset(m, sd->cl, rxb->type); + sd->cl = NULL; /* consumed, not a recycle candidate */ } - if (__predict_false(++fl->cidx % 8 == 0)) { - uint16_t cidx = fl->cidx / 8; - - if (__predict_false(cidx == fl->sidx)) - fl->cidx = cidx = 0; - fl->hw_cidx = cidx; - } - fl->rx_offset = 0; + move_to_next_rxbuf(fl); return (m); } static struct mbuf * -get_fl_payload(struct adapter *sc, struct sge_fl *fl, uint32_t len_newbuf) +get_fl_payload(struct adapter *sc, struct sge_fl *fl, const u_int plen) { struct mbuf *m0, *m, **pnext; u_int remaining; - const u_int total = G_RSPD_LEN(len_newbuf); if (__predict_false(fl->flags & FL_BUF_RESUME)) { M_ASSERTPKTHDR(fl->m0); - MPASS(fl->m0->m_pkthdr.len == total); - MPASS(fl->remaining < total); + MPASS(fl->m0->m_pkthdr.len == plen); + MPASS(fl->remaining < plen); m0 = fl->m0; pnext = fl->pnext; @@ -1941,31 +1819,20 @@ get_fl_payload(struct adapter *sc, struct sge_fl *fl, uint32_t len_newbuf) goto get_segment; } - if (fl->rx_offset > 0 && len_newbuf & F_RSPD_NEWBUF) { - fl->rx_offset = 0; - if (__predict_false(++fl->cidx % 8 == 0)) { - uint16_t cidx = fl->cidx / 8; - - if (__predict_false(cidx == fl->sidx)) - fl->cidx = cidx = 0; - fl->hw_cidx = cidx; - } - } - /* * Payload starts at rx_offset in the current hw buffer. Its length is * 'len' and it may span multiple hw buffers. */ - m0 = get_scatter_segment(sc, fl, 0, total); + m0 = get_scatter_segment(sc, fl, 0, plen); if (m0 == NULL) return (NULL); - remaining = total - m0->m_len; + remaining = plen - m0->m_len; pnext = &m0->m_next; while (remaining > 0) { get_segment: MPASS(fl->rx_offset == 0); - m = get_scatter_segment(sc, fl, total - remaining, remaining); + m = get_scatter_segment(sc, fl, plen - remaining, remaining); if (__predict_false(m == NULL)) { fl->m0 = m0; fl->pnext = pnext; @@ -1984,12 +1851,74 @@ get_fl_payload(struct adapter *sc, struct sge_fl *fl, uint32_t len_newbuf) } static int -t4_eth_rx(struct sge_iq *iq, const struct rss_header *rss, struct mbuf *m0) +skip_scatter_segment(struct adapter *sc, struct sge_fl *fl, int fr_offset, + int remaining) { - struct sge_rxq *rxq = iq_to_rxq(iq); + struct fl_sdesc *sd = &fl->sdesc[fl->cidx]; + struct rx_buf_info *rxb = &sc->sge.rx_buf_info[sd->zidx]; + int len, blen; + + if (fl->flags & FL_BUF_PACKING) { + u_int l, pad; + + blen = rxb->size2 - fl->rx_offset; /* max possible in this buf */ + len = min(remaining, blen); + + l = fr_offset + len; + pad = roundup2(l, fl->buf_boundary) - l; + if (fl->rx_offset + len + pad < rxb->size2) + blen = len + pad; + fl->rx_offset += blen; + MPASS(fl->rx_offset <= rxb->size2); + if (fl->rx_offset < rxb->size2) + return (len); /* without advancing the cidx */ + } else { + MPASS(fl->rx_offset == 0); /* not packing */ + blen = rxb->size1; + len = min(remaining, blen); + } + move_to_next_rxbuf(fl); + return (len); +} + +static inline void +skip_fl_payload(struct adapter *sc, struct sge_fl *fl, int plen) +{ + int remaining, fr_offset, len; + + fr_offset = 0; + remaining = plen; + while (remaining > 0) { + len = skip_scatter_segment(sc, fl, fr_offset, remaining); + fr_offset += len; + remaining -= len; + } +} + +static inline int +get_segment_len(struct adapter *sc, struct sge_fl *fl, int plen) +{ + int len; + struct fl_sdesc *sd = &fl->sdesc[fl->cidx]; + struct rx_buf_info *rxb = &sc->sge.rx_buf_info[sd->zidx]; + + if (fl->flags & FL_BUF_PACKING) + len = rxb->size2 - fl->rx_offset; + else + len = rxb->size1; + + return (min(plen, len)); +} + +static int +eth_rx(struct adapter *sc, struct sge_rxq *rxq, const struct iq_desc *d, + u_int plen) +{ + struct mbuf *m0; struct ifnet *ifp = rxq->ifp; - struct adapter *sc = iq->adapter; - const struct cpl_rx_pkt *cpl = (const void *)(rss + 1); + struct sge_fl *fl = &rxq->fl; + struct vi_info *vi = ifp->if_softc; + const struct cpl_rx_pkt *cpl; #if defined(INET) || defined(INET6) struct lro_ctrl *lro = &rxq->lro; #endif @@ -2000,17 +1929,45 @@ t4_eth_rx(struct sge_iq *iq, const struct rss_header *rss, struct mbuf *m0) {M_HASHTYPE_RSS_UDP_IPV4, M_HASHTYPE_RSS_UDP_IPV6}, }; - KASSERT(m0 != NULL, ("%s: no payload with opcode %02x", __func__, - rss->opcode)); + MPASS(plen > sc->params.sge.fl_pktshift); + if (vi->pfil != NULL && PFIL_HOOKED_IN(vi->pfil) && + __predict_true((fl->flags & FL_BUF_RESUME) == 0)) { + struct fl_sdesc *sd = &fl->sdesc[fl->cidx]; + caddr_t frame; + int rc, slen; + + slen = get_segment_len(sc, fl, plen) - + sc->params.sge.fl_pktshift; + frame = sd->cl + fl->rx_offset + sc->params.sge.fl_pktshift; + CURVNET_SET_QUIET(ifp->if_vnet); + rc = pfil_run_hooks(vi->pfil, frame, ifp, + slen | PFIL_MEMPTR | PFIL_IN, NULL); + CURVNET_RESTORE(); + if (rc == PFIL_DROPPED || rc == PFIL_CONSUMED) { + skip_fl_payload(sc, fl, plen); + return (0); + } + if (rc == PFIL_REALLOCED) { + skip_fl_payload(sc, fl, plen); + m0 = pfil_mem2mbuf(frame); + goto have_mbuf; + } + } + + m0 = get_fl_payload(sc, fl, plen); + if (__predict_false(m0 == NULL)) + return (ENOMEM); m0->m_pkthdr.len -= sc->params.sge.fl_pktshift; m0->m_len -= sc->params.sge.fl_pktshift; m0->m_data += sc->params.sge.fl_pktshift; +have_mbuf: m0->m_pkthdr.rcvif = ifp; - M_HASHTYPE_SET(m0, sw_hashtype[rss->hash_type][rss->ipv6]); - m0->m_pkthdr.flowid = be32toh(rss->hash_val); + M_HASHTYPE_SET(m0, sw_hashtype[d->rss.hash_type][d->rss.ipv6]); + m0->m_pkthdr.flowid = be32toh(d->rss.hash_val); + cpl = (const void *)(&d->rss + 1); if (cpl->csum_calc && !(cpl->err_vec & sc->params.tp.err_vec_mask)) { if (ifp->if_capenable & IFCAP_RXCSUM && cpl->l2info & htobe32(F_RXF_IP)) { @@ -2036,11 +1993,28 @@ t4_eth_rx(struct sge_iq *iq, const struct rss_header *rss, struct mbuf *m0) rxq->vlan_extraction++; } + if (rxq->iq.flags & IQ_RX_TIMESTAMP) { + /* + * Fill up rcv_tstmp but do not set M_TSTMP. + * rcv_tstmp is not in the format that the + * kernel expects and we don't want to mislead + * it. For now this is only for custom code + * that knows how to interpret cxgbe's stamp. + */ + m0->m_pkthdr.rcv_tstmp = + last_flit_to_ns(sc, d->rsp.u.last_flit); +#ifdef notyet + m0->m_flags |= M_TSTMP; +#endif + } + #ifdef NUMA m0->m_pkthdr.numa_domain = ifp->if_numa_domain; #endif #if defined(INET) || defined(INET6) - if (iq->flags & IQ_LRO_ENABLED) { + if (rxq->iq.flags & IQ_LRO_ENABLED && + (M_HASHTYPE_GET(m0) == M_HASHTYPE_RSS_TCP_IPV4 || + M_HASHTYPE_GET(m0) == M_HASHTYPE_RSS_TCP_IPV6)) { if (sort_before_lro(lro)) { tcp_lro_queue_mbuf(lro, m0); return (0); /* queued for sort, then LRO */ @@ -2188,7 +2162,8 @@ t4_update_fl_bufsize(struct ifnet *ifp) fl = &rxq->fl; FL_LOCK(fl); - find_best_refill_source(sc, fl, maxp); + fl->zidx = find_refill_source(sc, maxp, + fl->flags & FL_BUF_PACKING); FL_UNLOCK(fl); } #ifdef TCP_OFFLOAD @@ -2196,7 +2171,8 @@ t4_update_fl_bufsize(struct ifnet *ifp) fl = &ofld_rxq->fl; FL_LOCK(fl); - find_best_refill_source(sc, fl, maxp); + fl->zidx = find_refill_source(sc, maxp, + fl->flags & FL_BUF_PACKING); FL_UNLOCK(fl); } #endif @@ -3082,8 +3058,8 @@ init_fl(struct adapter *sc, struct sge_fl *fl, int qsize, int maxp, char *name) ((!is_t4(sc) && buffer_packing) || /* T5+: enabled unless 0 */ (is_t4(sc) && buffer_packing == 1)))/* T4: disabled unless 1 */ fl->flags |= FL_BUF_PACKING; - find_best_refill_source(sc, fl, maxp); - find_safe_refill_source(sc, fl); + fl->zidx = find_refill_source(sc, maxp, fl->flags & FL_BUF_PACKING); + fl->safe_zidx = sc->sge.safe_zidx; } static inline void @@ -3445,10 +3421,6 @@ add_fl_sysctls(struct adapter *sc, struct sysctl_ctx_list *ctx, } SYSCTL_ADD_UINT(ctx, children, OID_AUTO, "pidx", CTLFLAG_RD, &fl->pidx, 0, "producer index"); - SYSCTL_ADD_UQUAD(ctx, children, OID_AUTO, "mbuf_allocated", - CTLFLAG_RD, &fl->mbuf_allocated, "# of mbuf allocated"); - SYSCTL_ADD_UQUAD(ctx, children, OID_AUTO, "mbuf_inlined", - CTLFLAG_RD, &fl->mbuf_inlined, "# of mbuf inlined in clusters"); SYSCTL_ADD_UQUAD(ctx, children, OID_AUTO, "cluster_allocated", CTLFLAG_RD, &fl->cl_allocated, "# of clusters allocated"); SYSCTL_ADD_UQUAD(ctx, children, OID_AUTO, "cluster_recycled", @@ -4333,7 +4305,7 @@ ring_fl_db(struct adapter *sc, struct sge_fl *fl) { uint32_t n, v; - n = IDXDIFF(fl->pidx / 8, fl->dbidx, fl->sidx); + n = IDXDIFF(fl->pidx >> 3, fl->dbidx, fl->sidx); MPASS(n > 0); wmb(); @@ -4359,8 +4331,7 @@ refill_fl(struct adapter *sc, struct sge_fl *fl, int n) struct fl_sdesc *sd; uintptr_t pa; caddr_t cl; - struct cluster_layout *cll; - struct sw_zone_info *swz; + struct rx_buf_info *rxb; struct cluster_metadata *clm; uint16_t max_pidx; uint16_t hw_cidx = fl->hw_cidx; /* stable snapshot */ @@ -4378,8 +4349,6 @@ refill_fl(struct adapter *sc, struct sge_fl *fl, int n) d = &fl->desc[fl->pidx]; sd = &fl->sdesc[fl->pidx]; - cll = &fl->cll_def; /* default layout */ - swz = &sc->sge.sw_zone_info[cll->zidx]; while (n > 0) { @@ -4394,12 +4363,7 @@ refill_fl(struct adapter *sc, struct sge_fl *fl, int n) * fit within a single mbuf each. */ fl->cl_fast_recycled++; -#ifdef INVARIANTS - clm = cl_metadata(sc, fl, &sd->cll, sd->cl); - if (clm != NULL) - MPASS(clm->refcount == 1); -#endif - goto recycled_fast; + goto recycled; } /* @@ -4407,7 +4371,7 @@ refill_fl(struct adapter *sc, struct sge_fl *fl, int n) * without metadata always take the fast recycle path * when they're recycled. */ - clm = cl_metadata(sc, fl, &sd->cll, sd->cl); + clm = cl_metadata(sd); MPASS(clm != NULL); if (atomic_fetchadd_int(&clm->refcount, -1) == 1) { @@ -4418,40 +4382,34 @@ refill_fl(struct adapter *sc, struct sge_fl *fl, int n) sd->cl = NULL; /* gave up my reference */ } MPASS(sd->cl == NULL); -alloc: - cl = uma_zalloc(swz->zone, M_NOWAIT); - if (__predict_false(cl == NULL)) { - if (cll == &fl->cll_alt || fl->cll_alt.zidx == -1 || - fl->cll_def.zidx == fl->cll_alt.zidx) + rxb = &sc->sge.rx_buf_info[fl->zidx]; + cl = uma_zalloc(rxb->zone, M_NOWAIT); + if (__predict_false(cl == NULL) && fl->zidx != fl->safe_zidx) { + rxb = &sc->sge.rx_buf_info[fl->safe_zidx]; + cl = uma_zalloc(rxb->zone, M_NOWAIT); + if (__predict_false(cl == NULL)) break; - - /* fall back to the safe zone */ - cll = &fl->cll_alt; - swz = &sc->sge.sw_zone_info[cll->zidx]; - goto alloc; } fl->cl_allocated++; n--; pa = pmap_kextract((vm_offset_t)cl); - pa += cll->region1; sd->cl = cl; - sd->cll = *cll; - *d = htobe64(pa | cll->hwidx); - clm = cl_metadata(sc, fl, cll, cl); - if (clm != NULL) { -recycled: -#ifdef INVARIANTS - clm->sd = sd; -#endif - clm->refcount = 1; + sd->zidx = fl->zidx; + + if (fl->flags & FL_BUF_PACKING) { + *d = htobe64(pa | rxb->hwidx2); + sd->moff = rxb->size2; + } else { + *d = htobe64(pa | rxb->hwidx1); + sd->moff = 0; } +recycled: sd->nmbuf = 0; -recycled_fast: d++; sd++; - if (__predict_false(++fl->pidx % 8 == 0)) { - uint16_t pidx = fl->pidx / 8; + if (__predict_false((++fl->pidx & 7) == 0)) { + uint16_t pidx = fl->pidx >> 3; if (__predict_false(pidx == fl->sidx)) { fl->pidx = 0; @@ -4459,7 +4417,7 @@ refill_fl(struct adapter *sc, struct sge_fl *fl, int n) sd = fl->sdesc; d = fl->desc; } - if (pidx == max_pidx) + if (n < 8 || pidx == max_pidx) break; if (IDXDIFF(pidx, fl->dbidx, fl->sidx) >= 4) @@ -4467,7 +4425,7 @@ refill_fl(struct adapter *sc, struct sge_fl *fl, int n) } } - if (fl->pidx / 8 != fl->dbidx) + if ((fl->pidx >> 3) != fl->dbidx) ring_fl_db(sc, fl); return (FL_RUNNING_LOW(fl) && !(fl->flags & FL_STARVING)); @@ -4512,7 +4470,6 @@ free_fl_sdesc(struct adapter *sc, struct sge_fl *fl) { struct fl_sdesc *sd; struct cluster_metadata *clm; - struct cluster_layout *cll; int i; sd = fl->sdesc; @@ -4520,13 +4477,15 @@ free_fl_sdesc(struct adapter *sc, struct sge_fl *fl) if (sd->cl == NULL) continue; - cll = &sd->cll; - clm = cl_metadata(sc, fl, cll, sd->cl); if (sd->nmbuf == 0) - uma_zfree(sc->sge.sw_zone_info[cll->zidx].zone, sd->cl); - else if (clm && atomic_fetchadd_int(&clm->refcount, -1) == 1) { - uma_zfree(sc->sge.sw_zone_info[cll->zidx].zone, sd->cl); - counter_u64_add(extfree_rels, 1); + uma_zfree(sc->sge.rx_buf_info[sd->zidx].zone, sd->cl); + else if (fl->flags & FL_BUF_PACKING) { + clm = cl_metadata(sd); + if (atomic_fetchadd_int(&clm->refcount, -1) == 1) { + uma_zfree(sc->sge.rx_buf_info[sd->zidx].zone, + sd->cl); + counter_u64_add(extfree_rels, 1); + } } sd->cl = NULL; } @@ -5422,179 +5381,39 @@ get_flit(struct sglist_seg *segs, int nsegs, int idx) return (0); } -static void -find_best_refill_source(struct adapter *sc, struct sge_fl *fl, int maxp) +static int +find_refill_source(struct adapter *sc, int maxp, bool packing) { - int8_t zidx, hwidx, idx; - uint16_t region1, region3; - int spare, spare_needed, n; - struct sw_zone_info *swz; - struct hw_buf_info *hwb, *hwb_list = &sc->sge.hw_buf_info[0]; + int i, zidx = -1; + struct rx_buf_info *rxb = &sc->sge.rx_buf_info[0]; - /* - * Buffer Packing: Look for PAGE_SIZE or larger zone which has a bufsize - * large enough for the max payload and cluster metadata. Otherwise - * settle for the largest bufsize that leaves enough room in the cluster - * for metadata. - * - * Without buffer packing: Look for the smallest zone which has a - * bufsize large enough for the max payload. Settle for the largest - * bufsize available if there's nothing big enough for max payload. - */ - spare_needed = fl->flags & FL_BUF_PACKING ? CL_METADATA_SIZE : 0; - swz = &sc->sge.sw_zone_info[0]; - hwidx = -1; - for (zidx = 0; zidx < SW_ZONE_SIZES; zidx++, swz++) { - if (swz->size > largest_rx_cluster) { - if (__predict_true(hwidx != -1)) - break; - - /* - * This is a misconfiguration. largest_rx_cluster is - * preventing us from finding a refill source. See - * dev.t5nex..buffer_sizes to figure out why. - */ - device_printf(sc->dev, "largest_rx_cluster=%u leaves no" - " refill source for fl %p (dma %u). Ignored.\n", - largest_rx_cluster, fl, maxp); - } - for (idx = swz->head_hwidx; idx != -1; idx = hwb->next) { - hwb = &hwb_list[idx]; - spare = swz->size - hwb->size; - if (spare < spare_needed) + if (packing) { + for (i = 0; i < SW_ZONE_SIZES; i++, rxb++) { + if (rxb->hwidx2 == -1) continue; - - hwidx = idx; /* best option so far */ - if (hwb->size >= maxp) { - - if ((fl->flags & FL_BUF_PACKING) == 0) - goto done; /* stop looking (not packing) */ - - if (swz->size >= safest_rx_cluster) - goto done; /* stop looking (packing) */ - } - break; /* keep looking, next zone */ + if (rxb->size1 < PAGE_SIZE && + rxb->size1 < largest_rx_cluster) + continue; + if (rxb->size1 > largest_rx_cluster) + break; + MPASS(rxb->size1 - rxb->size2 >= CL_METADATA_SIZE); + if (rxb->size2 >= maxp) + return (i); + zidx = i; } - } -done: - /* A usable hwidx has been located. */ - MPASS(hwidx != -1); - hwb = &hwb_list[hwidx]; - zidx = hwb->zidx; - swz = &sc->sge.sw_zone_info[zidx]; - region1 = 0; - region3 = swz->size - hwb->size; - - /* - * Stay within this zone and see if there is a better match when mbuf - * inlining is allowed. Remember that the hwidx's are sorted in - * decreasing order of size (so in increasing order of spare area). - */ - for (idx = hwidx; idx != -1; idx = hwb->next) { - hwb = &hwb_list[idx]; - spare = swz->size - hwb->size; - - if (allow_mbufs_in_cluster == 0 || hwb->size < maxp) - break; - - /* - * Do not inline mbufs if doing so would violate the pad/pack - * boundary alignment requirement. - */ - if (fl_pad && (MSIZE % sc->params.sge.pad_boundary) != 0) - continue; - if (fl->flags & FL_BUF_PACKING && - (MSIZE % sc->params.sge.pack_boundary) != 0) - continue; - - if (spare < CL_METADATA_SIZE + MSIZE) - continue; - n = (spare - CL_METADATA_SIZE) / MSIZE; - if (n > howmany(hwb->size, maxp)) - break; - - hwidx = idx; - if (fl->flags & FL_BUF_PACKING) { - region1 = n * MSIZE; - region3 = spare - region1; - } else { - region1 = MSIZE; - region3 = spare - region1; - break; + } else { + for (i = 0; i < SW_ZONE_SIZES; i++, rxb++) { + if (rxb->hwidx1 == -1) + continue; + if (rxb->size1 > largest_rx_cluster) + break; + if (rxb->size1 >= maxp) + return (i); + zidx = i; } } - KASSERT(zidx >= 0 && zidx < SW_ZONE_SIZES, - ("%s: bad zone %d for fl %p, maxp %d", __func__, zidx, fl, maxp)); - KASSERT(hwidx >= 0 && hwidx <= SGE_FLBUF_SIZES, - ("%s: bad hwidx %d for fl %p, maxp %d", __func__, hwidx, fl, maxp)); - KASSERT(region1 + sc->sge.hw_buf_info[hwidx].size + region3 == - sc->sge.sw_zone_info[zidx].size, - ("%s: bad buffer layout for fl %p, maxp %d. " - "cl %d; r1 %d, payload %d, r3 %d", __func__, fl, maxp, - sc->sge.sw_zone_info[zidx].size, region1, - sc->sge.hw_buf_info[hwidx].size, region3)); - if (fl->flags & FL_BUF_PACKING || region1 > 0) { - KASSERT(region3 >= CL_METADATA_SIZE, - ("%s: no room for metadata. fl %p, maxp %d; " - "cl %d; r1 %d, payload %d, r3 %d", __func__, fl, maxp, - sc->sge.sw_zone_info[zidx].size, region1, - sc->sge.hw_buf_info[hwidx].size, region3)); - KASSERT(region1 % MSIZE == 0, - ("%s: bad mbuf region for fl %p, maxp %d. " - "cl %d; r1 %d, payload %d, r3 %d", __func__, fl, maxp, - sc->sge.sw_zone_info[zidx].size, region1, - sc->sge.hw_buf_info[hwidx].size, region3)); - } - - fl->cll_def.zidx = zidx; - fl->cll_def.hwidx = hwidx; - fl->cll_def.region1 = region1; - fl->cll_def.region3 = region3; -} - -static void -find_safe_refill_source(struct adapter *sc, struct sge_fl *fl) -{ - struct sge *s = &sc->sge; - struct hw_buf_info *hwb; - struct sw_zone_info *swz; - int spare; - int8_t hwidx; - - if (fl->flags & FL_BUF_PACKING) - hwidx = s->safe_hwidx2; /* with room for metadata */ - else if (allow_mbufs_in_cluster && s->safe_hwidx2 != -1) { - hwidx = s->safe_hwidx2; - hwb = &s->hw_buf_info[hwidx]; - swz = &s->sw_zone_info[hwb->zidx]; - spare = swz->size - hwb->size; - - /* no good if there isn't room for an mbuf as well */ - if (spare < CL_METADATA_SIZE + MSIZE) - hwidx = s->safe_hwidx1; - } else - hwidx = s->safe_hwidx1; - - if (hwidx == -1) { - /* No fallback source */ - fl->cll_alt.hwidx = -1; - fl->cll_alt.zidx = -1; - - return; - } - - hwb = &s->hw_buf_info[hwidx]; - swz = &s->sw_zone_info[hwb->zidx]; - spare = swz->size - hwb->size; - fl->cll_alt.hwidx = hwidx; - fl->cll_alt.zidx = hwb->zidx; - if (allow_mbufs_in_cluster && - (fl_pad == 0 || (MSIZE % sc->params.sge.pad_boundary) == 0)) - fl->cll_alt.region1 = ((spare - CL_METADATA_SIZE) / MSIZE) * MSIZE; - else - fl->cll_alt.region1 = 0; - fl->cll_alt.region3 = spare - fl->cll_alt.region1; + return (zidx); } static void @@ -5751,24 +5570,39 @@ sysctl_uint16(SYSCTL_HANDLER_ARGS) return sysctl_handle_int(oidp, &i, 0, req); } +static inline bool +bufidx_used(struct adapter *sc, int idx) +{ + struct rx_buf_info *rxb = &sc->sge.rx_buf_info[0]; + int i; + + for (i = 0; i < SW_ZONE_SIZES; i++, rxb++) { + if (rxb->size1 > largest_rx_cluster) + continue; + if (rxb->hwidx1 == idx || rxb->hwidx2 == idx) + return (true); + } + + return (false); +} + static int sysctl_bufsizes(SYSCTL_HANDLER_ARGS) { - struct sge *s = arg1; - struct hw_buf_info *hwb = &s->hw_buf_info[0]; - struct sw_zone_info *swz = &s->sw_zone_info[0]; + struct adapter *sc = arg1; + struct sge_params *sp = &sc->params.sge; int i, rc; struct sbuf sb; char c; - sbuf_new(&sb, NULL, 32, SBUF_AUTOEXTEND); - for (i = 0; i < SGE_FLBUF_SIZES; i++, hwb++) { - if (hwb->zidx >= 0 && swz[hwb->zidx].size <= largest_rx_cluster) + sbuf_new(&sb, NULL, 128, SBUF_AUTOEXTEND); + for (i = 0; i < SGE_FLBUF_SIZES; i++) { + if (bufidx_used(sc, i)) c = '*'; else c = '\0'; - sbuf_printf(&sb, "%u%c ", hwb->size, c); + sbuf_printf(&sb, "%u%c ", sp->sge_fl_buffer_size[i], c); } sbuf_trim(&sb); sbuf_finish(&sb); diff --git a/sys/dev/dc/if_dc.c b/sys/dev/dc/if_dc.c index b7504a7200c6..f471d1192dcb 100644 --- a/sys/dev/dc/if_dc.c +++ b/sys/dev/dc/if_dc.c @@ -135,11 +135,6 @@ __FBSDID("$FreeBSD$"); #include -#ifdef __sparc64__ -#include -#include -#endif - MODULE_DEPEND(dc, pci, 1, 1, 1); MODULE_DEPEND(dc, ether, 1, 1, 1); MODULE_DEPEND(dc, miibus, 1, 1, 1); @@ -2293,14 +2288,6 @@ dc_attach(device_t dev) break; case DC_TYPE_DM9102: dc_read_eeprom(sc, (caddr_t)&eaddr, DC_EE_NODEADDR, 3, 0); -#ifdef __sparc64__ - /* - * If this is an onboard dc(4) the station address read from - * the EEPROM is all zero and we have to get it from the FCode. - */ - if (eaddr[0] == 0 && (eaddr[1] & ~0xffff) == 0) - OF_getetheraddr(dev, (caddr_t)&eaddr); -#endif break; case DC_TYPE_21143: case DC_TYPE_ASIX: diff --git a/sys/dev/esp/esp_sbus.c b/sys/dev/esp/esp_sbus.c deleted file mode 100644 index c7f4cbbc9d29..000000000000 --- a/sys/dev/esp/esp_sbus.c +++ /dev/null @@ -1,846 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD AND BSD-2-Clause-NetBSD - * - * Copyright (c) 2004 Scott Long - * Copyright (c) 2005 Marius Strobl - * 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. - * - */ - -/* $NetBSD: esp_sbus.c,v 1.51 2009/09/17 16:28:12 tsutsui Exp $ */ - -/*- - * Copyright (c) 1997, 1998 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Charles M. Hannum; Jason R. Thorpe of the Numerical Aerospace - * Simulation Facility, NASA Ames Research Center; Paul Kranenburg. - * - * 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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 -__FBSDID("$FreeBSD$"); - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include -#include -#include - -#include -#include - -/* #define ESP_SBUS_DEBUG */ - -struct esp_softc { - struct ncr53c9x_softc sc_ncr53c9x; /* glue to MI code */ - device_t sc_dev; - - struct resource *sc_res; - - struct resource *sc_irqres; - void *sc_irq; - - struct lsi64854_softc *sc_dma; /* pointer to my DMA */ -}; - -static int esp_probe(device_t); -static int esp_dma_attach(device_t); -static int esp_dma_detach(device_t); -static int esp_sbus_attach(device_t); -static int esp_sbus_detach(device_t); -static int esp_suspend(device_t); -static int esp_resume(device_t); - -static device_method_t esp_dma_methods[] = { - DEVMETHOD(device_probe, esp_probe), - DEVMETHOD(device_attach, esp_dma_attach), - DEVMETHOD(device_detach, esp_dma_detach), - DEVMETHOD(device_suspend, esp_suspend), - DEVMETHOD(device_resume, esp_resume), - - DEVMETHOD_END -}; - -static driver_t esp_dma_driver = { - "esp", - esp_dma_methods, - sizeof(struct esp_softc) -}; - -DRIVER_MODULE(esp, dma, esp_dma_driver, esp_devclass, 0, 0); -MODULE_DEPEND(esp, dma, 1, 1, 1); - -static device_method_t esp_sbus_methods[] = { - DEVMETHOD(device_probe, esp_probe), - DEVMETHOD(device_attach, esp_sbus_attach), - DEVMETHOD(device_detach, esp_sbus_detach), - DEVMETHOD(device_suspend, esp_suspend), - DEVMETHOD(device_resume, esp_resume), - - DEVMETHOD_END -}; - -static driver_t esp_sbus_driver = { - "esp", - esp_sbus_methods, - sizeof(struct esp_softc) -}; - -DRIVER_MODULE(esp, sbus, esp_sbus_driver, esp_devclass, 0, 0); -MODULE_DEPEND(esp, sbus, 1, 1, 1); - -/* - * Functions and the switch for the MI code - */ -static uint8_t esp_read_reg(struct ncr53c9x_softc *sc, int reg); -static void esp_write_reg(struct ncr53c9x_softc *sc, int reg, uint8_t v); -static int esp_dma_isintr(struct ncr53c9x_softc *sc); -static void esp_dma_reset(struct ncr53c9x_softc *sc); -static int esp_dma_intr(struct ncr53c9x_softc *sc); -static int esp_dma_setup(struct ncr53c9x_softc *sc, void **addr, - size_t *len, int datain, size_t *dmasize); -static void esp_dma_go(struct ncr53c9x_softc *sc); -static void esp_dma_stop(struct ncr53c9x_softc *sc); -static int esp_dma_isactive(struct ncr53c9x_softc *sc); -static int espattach(struct esp_softc *esc, - const struct ncr53c9x_glue *gluep); -static int espdetach(struct esp_softc *esc); - -static const struct ncr53c9x_glue esp_sbus_glue = { - esp_read_reg, - esp_write_reg, - esp_dma_isintr, - esp_dma_reset, - esp_dma_intr, - esp_dma_setup, - esp_dma_go, - esp_dma_stop, - esp_dma_isactive, -}; - -static int -esp_probe(device_t dev) -{ - const char *name; - - name = ofw_bus_get_name(dev); - if (strcmp("SUNW,fas", name) == 0) { - device_set_desc(dev, "Sun FAS366 Fast-Wide SCSI"); - return (BUS_PROBE_DEFAULT); - } else if (strcmp("esp", name) == 0) { - device_set_desc(dev, "Sun ESP SCSI/Sun FAS Fast-SCSI"); - return (BUS_PROBE_DEFAULT); - } - - return (ENXIO); -} - -static int -esp_sbus_attach(device_t dev) -{ - struct esp_softc *esc; - struct ncr53c9x_softc *sc; - struct lsi64854_softc *lsc; - device_t *children; - int error, i, nchildren; - - esc = device_get_softc(dev); - sc = &esc->sc_ncr53c9x; - - lsc = NULL; - esc->sc_dev = dev; - sc->sc_freq = sbus_get_clockfreq(dev); - - if (strcmp(ofw_bus_get_name(dev), "SUNW,fas") == 0) { - /* - * Allocate space for DMA, in SUNW,fas there are no - * separate DMA devices. - */ - lsc = malloc(sizeof (struct lsi64854_softc), M_DEVBUF, - M_NOWAIT | M_ZERO); - if (lsc == NULL) { - device_printf(dev, "out of memory (lsi64854_softc)\n"); - return (ENOMEM); - } - esc->sc_dma = lsc; - - /* - * SUNW,fas have 2 register spaces: DMA (lsi64854) and - * SCSI core (ncr53c9x). - */ - - /* Allocate DMA registers. */ - i = 0; - if ((lsc->sc_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, - &i, RF_ACTIVE)) == NULL) { - device_printf(dev, "cannot allocate DMA registers\n"); - error = ENXIO; - goto fail_sbus_lsc; - } - - /* Create a parent DMA tag based on this bus. */ - error = bus_dma_tag_create( - bus_get_dma_tag(dev), /* parent */ - 1, 0, /* alignment, boundary */ - BUS_SPACE_MAXADDR, /* lowaddr */ - BUS_SPACE_MAXADDR, /* highaddr */ - NULL, NULL, /* filter, filterarg */ - BUS_SPACE_MAXSIZE, /* maxsize */ - BUS_SPACE_UNRESTRICTED, /* nsegments */ - BUS_SPACE_MAXSIZE, /* maxsegsize */ - 0, /* flags */ - NULL, NULL, /* no locking */ - &lsc->sc_parent_dmat); - if (error != 0) { - device_printf(dev, "cannot allocate parent DMA tag\n"); - goto fail_sbus_lres; - } - - i = sbus_get_burstsz(dev); - -#ifdef ESP_SBUS_DEBUG - printf("%s: burst 0x%x\n", __func__, i); -#endif - - lsc->sc_burst = (i & SBUS_BURST_32) ? 32 : - (i & SBUS_BURST_16) ? 16 : 0; - - lsc->sc_channel = L64854_CHANNEL_SCSI; - lsc->sc_client = sc; - lsc->sc_dev = dev; - - /* - * Allocate SCSI core registers. - */ - i = 1; - if ((esc->sc_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, - &i, RF_ACTIVE)) == NULL) { - device_printf(dev, - "cannot allocate SCSI core registers\n"); - error = ENXIO; - goto fail_sbus_lpdma; - } - } else { - /* - * Search accompanying DMA engine. It should have been - * already attached otherwise there isn't much we can do. - */ - if (device_get_children(device_get_parent(dev), &children, - &nchildren) != 0) { - device_printf(dev, "cannot determine siblings\n"); - return (ENXIO); - } - for (i = 0; i < nchildren; i++) { - if (device_is_attached(children[i]) && - sbus_get_slot(children[i]) == - sbus_get_slot(dev) && - strcmp(ofw_bus_get_name(children[i]), - "dma") == 0) { - /* XXX hackery */ - esc->sc_dma = (struct lsi64854_softc *) - device_get_softc(children[i]); - break; - } - } - free(children, M_TEMP); - if (esc->sc_dma == NULL) { - device_printf(dev, "cannot find DMA engine\n"); - return (ENXIO); - } - esc->sc_dma->sc_client = sc; - - /* - * Allocate SCSI core registers. - */ - i = 0; - if ((esc->sc_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, - &i, RF_ACTIVE)) == NULL) { - device_printf(dev, - "cannot allocate SCSI core registers\n"); - return (ENXIO); - } - } - - error = espattach(esc, &esp_sbus_glue); - if (error != 0) { - device_printf(dev, "espattach failed\n"); - goto fail_sbus_eres; - } - - return (0); - - fail_sbus_eres: - bus_release_resource(dev, SYS_RES_MEMORY, rman_get_rid(esc->sc_res), - esc->sc_res); - if (strcmp(ofw_bus_get_name(dev), "SUNW,fas") != 0) - return (error); - fail_sbus_lpdma: - bus_dma_tag_destroy(lsc->sc_parent_dmat); - fail_sbus_lres: - bus_release_resource(dev, SYS_RES_MEMORY, rman_get_rid(lsc->sc_res), - lsc->sc_res); - fail_sbus_lsc: - free(lsc, M_DEVBUF); - return (error); -} - -static int -esp_sbus_detach(device_t dev) -{ - struct esp_softc *esc; - struct lsi64854_softc *lsc; - int error; - - esc = device_get_softc(dev); - lsc = esc->sc_dma; - - error = espdetach(esc); - if (error != 0) - return (error); - bus_release_resource(dev, SYS_RES_MEMORY, rman_get_rid(esc->sc_res), - esc->sc_res); - if (strcmp(ofw_bus_get_name(dev), "SUNW,fas") != 0) - return (0); - bus_dma_tag_destroy(lsc->sc_parent_dmat); - bus_release_resource(dev, SYS_RES_MEMORY, rman_get_rid(lsc->sc_res), - lsc->sc_res); - free(lsc, M_DEVBUF); - - return (0); -} - -static int -esp_dma_attach(device_t dev) -{ - struct esp_softc *esc; - struct ncr53c9x_softc *sc; - int error, i; - - esc = device_get_softc(dev); - sc = &esc->sc_ncr53c9x; - - esc->sc_dev = dev; - if (OF_getprop(ofw_bus_get_node(dev), "clock-frequency", - &sc->sc_freq, sizeof(sc->sc_freq)) == -1) { - printf("failed to query OFW for clock-frequency\n"); - return (ENXIO); - } - - /* XXX hackery */ - esc->sc_dma = (struct lsi64854_softc *) - device_get_softc(device_get_parent(dev)); - esc->sc_dma->sc_client = sc; - - /* - * Allocate SCSI core registers. - */ - i = 0; - if ((esc->sc_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, - &i, RF_ACTIVE)) == NULL) { - device_printf(dev, "cannot allocate SCSI core registers\n"); - return (ENXIO); - } - - error = espattach(esc, &esp_sbus_glue); - if (error != 0) { - device_printf(dev, "espattach failed\n"); - goto fail_dma_eres; - } - - return (0); - - fail_dma_eres: - bus_release_resource(dev, SYS_RES_MEMORY, rman_get_rid(esc->sc_res), - esc->sc_res); - return (error); -} - -static int -esp_dma_detach(device_t dev) -{ - struct esp_softc *esc; - int error; - - esc = device_get_softc(dev); - - error = espdetach(esc); - if (error != 0) - return (error); - bus_release_resource(dev, SYS_RES_MEMORY, rman_get_rid(esc->sc_res), - esc->sc_res); - - return (0); -} - -static int -esp_suspend(device_t dev) -{ - - return (ENXIO); -} - -static int -esp_resume(device_t dev) -{ - - return (ENXIO); -} - -static int -espattach(struct esp_softc *esc, const struct ncr53c9x_glue *gluep) -{ - struct ncr53c9x_softc *sc = &esc->sc_ncr53c9x; - unsigned int uid = 0; - int error, i; - - NCR_LOCK_INIT(sc); - - sc->sc_id = OF_getscsinitid(esc->sc_dev); - -#ifdef ESP_SBUS_DEBUG - device_printf(esc->sc_dev, "%s: sc_id %d, freq %d\n", - __func__, sc->sc_id, sc->sc_freq); -#endif - - /* - * The `ESC' DMA chip must be reset before we can access - * the ESP registers. - */ - if (esc->sc_dma->sc_rev == DMAREV_ESC) - DMA_RESET(esc->sc_dma); - - /* - * Set up glue for MI code early; we use some of it here. - */ - sc->sc_glue = gluep; - - /* gimme MHz */ - sc->sc_freq /= 1000000; - - /* - * XXX More of this should be in ncr53c9x_attach(), but - * XXX should we really poke around the chip that much in - * XXX the MI code? Think about this more... - */ - - /* - * Read the part-unique ID code of the SCSI chip. The contained - * value is only valid if all of the following conditions are met: - * - After power-up or chip reset. - * - Before any value is written to this register. - * - The NCRCFG2_FE bit is set. - * - A (NCRCMD_NOP | NCRCMD_DMA) command has been issued. - */ - NCRCMD(sc, NCRCMD_RSTCHIP); - NCRCMD(sc, NCRCMD_NOP); - sc->sc_cfg2 = NCRCFG2_FE; - NCR_WRITE_REG(sc, NCR_CFG2, sc->sc_cfg2); - NCRCMD(sc, NCRCMD_NOP | NCRCMD_DMA); - uid = NCR_READ_REG(sc, NCR_UID); - - /* - * It is necessary to try to load the 2nd config register here, - * to find out what rev the esp chip is, else the ncr53c9x_reset - * will not set up the defaults correctly. - */ - sc->sc_cfg1 = sc->sc_id | NCRCFG1_PARENB; - NCR_WRITE_REG(sc, NCR_CFG1, sc->sc_cfg1); - sc->sc_cfg2 = 0; - NCR_WRITE_REG(sc, NCR_CFG2, sc->sc_cfg2); - sc->sc_cfg2 = NCRCFG2_SCSI2 | NCRCFG2_RPE; - NCR_WRITE_REG(sc, NCR_CFG2, sc->sc_cfg2); - - if ((NCR_READ_REG(sc, NCR_CFG2) & ~NCRCFG2_RSVD) != - (NCRCFG2_SCSI2 | NCRCFG2_RPE)) - sc->sc_rev = NCR_VARIANT_ESP100; - else { - sc->sc_cfg2 = NCRCFG2_SCSI2; - NCR_WRITE_REG(sc, NCR_CFG2, sc->sc_cfg2); - sc->sc_cfg3 = 0; - NCR_WRITE_REG(sc, NCR_CFG3, sc->sc_cfg3); - sc->sc_cfg3 = (NCRCFG3_CDB | NCRCFG3_FCLK); - NCR_WRITE_REG(sc, NCR_CFG3, sc->sc_cfg3); - if (NCR_READ_REG(sc, NCR_CFG3) != - (NCRCFG3_CDB | NCRCFG3_FCLK)) - sc->sc_rev = NCR_VARIANT_ESP100A; - else { - /* NCRCFG2_FE enables > 64K transfers. */ - sc->sc_cfg2 |= NCRCFG2_FE; - sc->sc_cfg3 = 0; - NCR_WRITE_REG(sc, NCR_CFG3, sc->sc_cfg3); - if (sc->sc_freq <= 25) - sc->sc_rev = NCR_VARIANT_ESP200; - else { - switch ((uid & 0xf8) >> 3) { - case 0x00: - sc->sc_rev = NCR_VARIANT_FAS100A; - break; - - case 0x02: - if ((uid & 0x07) == 0x02) - sc->sc_rev = - NCR_VARIANT_FAS216; - else - sc->sc_rev = - NCR_VARIANT_FAS236; - break; - - case 0x0a: - sc->sc_rev = NCR_VARIANT_FAS366; - break; - - default: - /* - * We could just treat unknown chips - * as ESP200 but then we would most - * likely drive them out of specs. - */ - device_printf(esc->sc_dev, - "Unknown chip\n"); - error = ENXIO; - goto fail_lock; - } - } - } - } - -#ifdef ESP_SBUS_DEBUG - printf("%s: revision %d, uid 0x%x\n", __func__, sc->sc_rev, uid); -#endif - - /* - * This is the value used to start sync negotiations - * Note that the NCR register "SYNCTP" is programmed - * in "clocks per byte", and has a minimum value of 4. - * The SCSI period used in negotiation is one-fourth - * of the time (in nanoseconds) needed to transfer one byte. - * Since the chip's clock is given in MHz, we have the following - * formula: 4 * period = (1000 / freq) * 4 - */ - sc->sc_minsync = 1000 / sc->sc_freq; - - /* - * Except for some variants the maximum transfer size is 64k. - */ - sc->sc_maxxfer = 64 * 1024; - sc->sc_maxoffset = 15; - sc->sc_extended_geom = 1; - - /* - * Alas, we must now modify the value a bit, because it's - * only valid when we can switch on FASTCLK and FASTSCSI bits - * in the config register 3... - */ - switch (sc->sc_rev) { - case NCR_VARIANT_ESP100: - sc->sc_maxwidth = MSG_EXT_WDTR_BUS_8_BIT; - sc->sc_minsync = 0; /* No synch on old chip? */ - break; - - case NCR_VARIANT_ESP100A: - case NCR_VARIANT_ESP200: - sc->sc_maxwidth = MSG_EXT_WDTR_BUS_8_BIT; - /* Min clocks/byte is 5 */ - sc->sc_minsync = ncr53c9x_cpb2stp(sc, 5); - break; - - case NCR_VARIANT_FAS100A: - case NCR_VARIANT_FAS216: - case NCR_VARIANT_FAS236: - /* - * The onboard SCSI chips in Sun Ultra 1 are actually - * documented to be NCR53C9X which use NCRCFG3_FCLK and - * NCRCFG3_FSCSI. BSD/OS however probes these chips as - * FAS100A and uses NCRF9XCFG3_FCLK and NCRF9XCFG3_FSCSI - * instead which seems to be correct as otherwise sync - * negotiation just doesn't work. Using NCRF9XCFG3_FCLK - * and NCRF9XCFG3_FSCSI with these chips in fact also - * yields Fast-SCSI speed. - */ - sc->sc_features = NCR_F_FASTSCSI; - sc->sc_cfg3 = NCRF9XCFG3_FCLK; - sc->sc_cfg3_fscsi = NCRF9XCFG3_FSCSI; - sc->sc_maxwidth = MSG_EXT_WDTR_BUS_8_BIT; - sc->sc_maxxfer = 16 * 1024 * 1024; - break; - - case NCR_VARIANT_FAS366: - sc->sc_maxwidth = MSG_EXT_WDTR_BUS_16_BIT; - sc->sc_maxxfer = 16 * 1024 * 1024; - break; - } - - /* - * Given that we allocate resources based on sc->sc_maxxfer it doesn't - * make sense to supply a value higher than the maximum actually used. - */ - sc->sc_maxxfer = min(sc->sc_maxxfer, MAXPHYS); - - /* Attach the DMA engine. */ - error = lsi64854_attach(esc->sc_dma); - if (error != 0) { - device_printf(esc->sc_dev, "lsi64854_attach failed\n"); - goto fail_lock; - } - - /* Establish interrupt channel. */ - i = 0; - if ((esc->sc_irqres = bus_alloc_resource_any(esc->sc_dev, SYS_RES_IRQ, - &i, RF_SHAREABLE|RF_ACTIVE)) == NULL) { - device_printf(esc->sc_dev, "cannot allocate interrupt\n"); - goto fail_lsi; - } - if (bus_setup_intr(esc->sc_dev, esc->sc_irqres, - INTR_MPSAFE | INTR_TYPE_CAM, NULL, ncr53c9x_intr, sc, - &esc->sc_irq)) { - device_printf(esc->sc_dev, "cannot set up interrupt\n"); - error = ENXIO; - goto fail_ires; - } - - /* Turn on target selection using the `DMA' method. */ - if (sc->sc_rev != NCR_VARIANT_FAS366) - sc->sc_features |= NCR_F_DMASELECT; - - /* Do the common parts of attachment. */ - sc->sc_dev = esc->sc_dev; - error = ncr53c9x_attach(sc); - if (error != 0) { - device_printf(esc->sc_dev, "ncr53c9x_attach failed\n"); - goto fail_intr; - } - - return (0); - - fail_intr: - bus_teardown_intr(esc->sc_dev, esc->sc_irqres, esc->sc_irq); - fail_ires: - bus_release_resource(esc->sc_dev, SYS_RES_IRQ, - rman_get_rid(esc->sc_irqres), esc->sc_irqres); - fail_lsi: - lsi64854_detach(esc->sc_dma); - fail_lock: - NCR_LOCK_DESTROY(sc); - return (error); -} - -static int -espdetach(struct esp_softc *esc) -{ - struct ncr53c9x_softc *sc = &esc->sc_ncr53c9x; - int error; - - bus_teardown_intr(esc->sc_dev, esc->sc_irqres, esc->sc_irq); - error = ncr53c9x_detach(sc); - if (error != 0) - return (error); - error = lsi64854_detach(esc->sc_dma); - if (error != 0) - return (error); - NCR_LOCK_DESTROY(sc); - bus_release_resource(esc->sc_dev, SYS_RES_IRQ, - rman_get_rid(esc->sc_irqres), esc->sc_irqres); - - return (0); -} - -/* - * Glue functions - */ - -#ifdef ESP_SBUS_DEBUG -static int esp_sbus_debug = 0; - -static const struct { - const char *r_name; - int r_flag; -} const esp__read_regnames [] = { - { "TCL", 0}, /* 0/00 */ - { "TCM", 0}, /* 1/04 */ - { "FIFO", 0}, /* 2/08 */ - { "CMD", 0}, /* 3/0c */ - { "STAT", 0}, /* 4/10 */ - { "INTR", 0}, /* 5/14 */ - { "STEP", 0}, /* 6/18 */ - { "FFLAGS", 1}, /* 7/1c */ - { "CFG1", 1}, /* 8/20 */ - { "STAT2", 0}, /* 9/24 */ - { "CFG4", 1}, /* a/28 */ - { "CFG2", 1}, /* b/2c */ - { "CFG3", 1}, /* c/30 */ - { "-none", 1}, /* d/34 */ - { "TCH", 1}, /* e/38 */ - { "TCX", 1}, /* f/3c */ -}; - -static const const struct { - const char *r_name; - int r_flag; -} const esp__write_regnames[] = { - { "TCL", 1}, /* 0/00 */ - { "TCM", 1}, /* 1/04 */ - { "FIFO", 0}, /* 2/08 */ - { "CMD", 0}, /* 3/0c */ - { "SELID", 1}, /* 4/10 */ - { "TIMEOUT", 1}, /* 5/14 */ - { "SYNCTP", 1}, /* 6/18 */ - { "SYNCOFF", 1}, /* 7/1c */ - { "CFG1", 1}, /* 8/20 */ - { "CCF", 1}, /* 9/24 */ - { "TEST", 1}, /* a/28 */ - { "CFG2", 1}, /* b/2c */ - { "CFG3", 1}, /* c/30 */ - { "-none", 1}, /* d/34 */ - { "TCH", 1}, /* e/38 */ - { "TCX", 1}, /* f/3c */ -}; -#endif - -static uint8_t -esp_read_reg(struct ncr53c9x_softc *sc, int reg) -{ - struct esp_softc *esc = (struct esp_softc *)sc; - uint8_t v; - - v = bus_read_1(esc->sc_res, reg * 4); - -#ifdef ESP_SBUS_DEBUG - if (esp_sbus_debug && (reg < 0x10) && esp__read_regnames[reg].r_flag) - printf("RD:%x <%s> %x\n", reg * 4, ((unsigned)reg < 0x10) ? - esp__read_regnames[reg].r_name : "<***>", v); -#endif - - return (v); -} - -static void -esp_write_reg(struct ncr53c9x_softc *sc, int reg, uint8_t v) -{ - struct esp_softc *esc = (struct esp_softc *)sc; - -#ifdef ESP_SBUS_DEBUG - if (esp_sbus_debug && (reg < 0x10) && esp__write_regnames[reg].r_flag) - printf("WR:%x <%s> %x\n", reg * 4, ((unsigned)reg < 0x10) ? - esp__write_regnames[reg].r_name : "<***>", v); -#endif - - bus_write_1(esc->sc_res, reg * 4, v); -} - -static int -esp_dma_isintr(struct ncr53c9x_softc *sc) -{ - struct esp_softc *esc = (struct esp_softc *)sc; - - return (DMA_ISINTR(esc->sc_dma)); -} - -static void -esp_dma_reset(struct ncr53c9x_softc *sc) -{ - struct esp_softc *esc = (struct esp_softc *)sc; - - DMA_RESET(esc->sc_dma); -} - -static int -esp_dma_intr(struct ncr53c9x_softc *sc) -{ - struct esp_softc *esc = (struct esp_softc *)sc; - - return (DMA_INTR(esc->sc_dma)); -} - -static int -esp_dma_setup(struct ncr53c9x_softc *sc, void **addr, size_t *len, - int datain, size_t *dmasize) -{ - struct esp_softc *esc = (struct esp_softc *)sc; - - return (DMA_SETUP(esc->sc_dma, addr, len, datain, dmasize)); -} - -static void -esp_dma_go(struct ncr53c9x_softc *sc) -{ - struct esp_softc *esc = (struct esp_softc *)sc; - - DMA_GO(esc->sc_dma); -} - -static void -esp_dma_stop(struct ncr53c9x_softc *sc) -{ - struct esp_softc *esc = (struct esp_softc *)sc; - - L64854_SCSR(esc->sc_dma, L64854_GCSR(esc->sc_dma) & ~D_EN_DMA); -} - -static int -esp_dma_isactive(struct ncr53c9x_softc *sc) -{ - struct esp_softc *esc = (struct esp_softc *)sc; - - return (DMA_ISACTIVE(esc->sc_dma)); -} diff --git a/sys/dev/fb/creator.c b/sys/dev/fb/creator.c deleted file mode 100644 index 0c0f083aaaf7..000000000000 --- a/sys/dev/fb/creator.c +++ /dev/null @@ -1,1130 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD - * - * Copyright (c) 2003 Jake Burkholder. - * Copyright (c) 2005 - 2006 Marius Strobl - * 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 -__FBSDID("$FreeBSD$"); - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include -#include -#include -#include -#include - -#include - -#include -#include -#include -#include - -#define CREATOR_DRIVER_NAME "creator" - -struct creator_softc { - video_adapter_t sc_va; /* XXX must be first */ - - phandle_t sc_node; - - struct cdev *sc_si; - - struct resource *sc_reg[FFB_NREG]; - bus_space_tag_t sc_bt[FFB_NREG]; - bus_space_handle_t sc_bh[FFB_NREG]; - u_long sc_reg_size; - - u_int sc_height; - u_int sc_width; - - u_int sc_xmargin; - u_int sc_ymargin; - - const u_char *sc_font; - - int sc_bg_cache; - int sc_fg_cache; - int sc_fifo_cache; - int sc_fontinc_cache; - int sc_fontw_cache; - int sc_pmask_cache; - - u_int sc_flags; -#define CREATOR_AFB (1 << 0) -#define CREATOR_CONSOLE (1 << 1) -#define CREATOR_CUREN (1 << 2) -#define CREATOR_CURINV (1 << 3) -#define CREATOR_PAC1 (1 << 4) -}; - -#define FFB_READ(sc, reg, off) \ - bus_space_read_4((sc)->sc_bt[(reg)], (sc)->sc_bh[(reg)], (off)) -#define FFB_WRITE(sc, reg, off, val) \ - bus_space_write_4((sc)->sc_bt[(reg)], (sc)->sc_bh[(reg)], (off), (val)) - -#define C(r, g, b) ((b << 16) | (g << 8) | (r)) -static const uint32_t creator_cmap[] = { - C(0x00, 0x00, 0x00), /* black */ - C(0x00, 0x00, 0xff), /* blue */ - C(0x00, 0xff, 0x00), /* green */ - C(0x00, 0xc0, 0xc0), /* cyan */ - C(0xff, 0x00, 0x00), /* red */ - C(0xc0, 0x00, 0xc0), /* magenta */ - C(0xc0, 0xc0, 0x00), /* brown */ - C(0xc0, 0xc0, 0xc0), /* light grey */ - C(0x80, 0x80, 0x80), /* dark grey */ - C(0x80, 0x80, 0xff), /* light blue */ - C(0x80, 0xff, 0x80), /* light green */ - C(0x80, 0xff, 0xff), /* light cyan */ - C(0xff, 0x80, 0x80), /* light red */ - C(0xff, 0x80, 0xff), /* light magenta */ - C(0xff, 0xff, 0x80), /* yellow */ - C(0xff, 0xff, 0xff), /* white */ -}; -#undef C - -static const struct { - vm_offset_t virt; - vm_paddr_t phys; - vm_size_t size; -} creator_fb_map[] = { - { FFB_VIRT_SFB8R, FFB_PHYS_SFB8R, FFB_SIZE_SFB8R }, - { FFB_VIRT_SFB8G, FFB_PHYS_SFB8G, FFB_SIZE_SFB8G }, - { FFB_VIRT_SFB8B, FFB_PHYS_SFB8B, FFB_SIZE_SFB8B }, - { FFB_VIRT_SFB8X, FFB_PHYS_SFB8X, FFB_SIZE_SFB8X }, - { FFB_VIRT_SFB32, FFB_PHYS_SFB32, FFB_SIZE_SFB32 }, - { FFB_VIRT_SFB64, FFB_PHYS_SFB64, FFB_SIZE_SFB64 }, - { FFB_VIRT_FBC, FFB_PHYS_FBC, FFB_SIZE_FBC }, - { FFB_VIRT_FBC_BM, FFB_PHYS_FBC_BM, FFB_SIZE_FBC_BM }, - { FFB_VIRT_DFB8R, FFB_PHYS_DFB8R, FFB_SIZE_DFB8R }, - { FFB_VIRT_DFB8G, FFB_PHYS_DFB8G, FFB_SIZE_DFB8G }, - { FFB_VIRT_DFB8B, FFB_PHYS_DFB8B, FFB_SIZE_DFB8B }, - { FFB_VIRT_DFB8X, FFB_PHYS_DFB8X, FFB_SIZE_DFB8X }, - { FFB_VIRT_DFB24, FFB_PHYS_DFB24, FFB_SIZE_DFB24 }, - { FFB_VIRT_DFB32, FFB_PHYS_DFB32, FFB_SIZE_DFB32 }, - { FFB_VIRT_DFB422A, FFB_PHYS_DFB422A, FFB_SIZE_DFB422A }, - { FFB_VIRT_DFB422AD, FFB_PHYS_DFB422AD, FFB_SIZE_DFB422AD }, - { FFB_VIRT_DFB24B, FFB_PHYS_DFB24B, FFB_SIZE_DFB24B }, - { FFB_VIRT_DFB422B, FFB_PHYS_DFB422B, FFB_SIZE_DFB422B }, - { FFB_VIRT_DFB422BD, FFB_PHYS_DFB422BD, FFB_SIZE_DFB422BD }, - { FFB_VIRT_SFB16Z, FFB_PHYS_SFB16Z, FFB_SIZE_SFB16Z }, - { FFB_VIRT_SFB8Z, FFB_PHYS_SFB8Z, FFB_SIZE_SFB8Z }, - { FFB_VIRT_SFB422, FFB_PHYS_SFB422, FFB_SIZE_SFB422 }, - { FFB_VIRT_SFB422D, FFB_PHYS_SFB422D, FFB_SIZE_SFB422D }, - { FFB_VIRT_FBC_KREG, FFB_PHYS_FBC_KREG, FFB_SIZE_FBC_KREG }, - { FFB_VIRT_DAC, FFB_PHYS_DAC, FFB_SIZE_DAC }, - { FFB_VIRT_PROM, FFB_PHYS_PROM, FFB_SIZE_PROM }, - { FFB_VIRT_EXP, FFB_PHYS_EXP, FFB_SIZE_EXP }, -}; - -#define CREATOR_FB_MAP_SIZE nitems(creator_fb_map) - -extern const struct gfb_font gallant12x22; - -static struct creator_softc creator_softc; -static struct bus_space_tag creator_bst_store[FFB_FBC]; - -static device_probe_t creator_bus_probe; -static device_attach_t creator_bus_attach; - -static device_method_t creator_bus_methods[] = { - DEVMETHOD(device_probe, creator_bus_probe), - DEVMETHOD(device_attach, creator_bus_attach), - - { 0, 0 } -}; - -static devclass_t creator_devclass; - -DEFINE_CLASS_0(creator, creator_bus_driver, creator_bus_methods, - sizeof(struct creator_softc)); -DRIVER_MODULE(creator, nexus, creator_bus_driver, creator_devclass, 0, 0); -DRIVER_MODULE(creator, upa, creator_bus_driver, creator_devclass, 0, 0); - -static d_open_t creator_fb_open; -static d_close_t creator_fb_close; -static d_ioctl_t creator_fb_ioctl; -static d_mmap_t creator_fb_mmap; - -static struct cdevsw creator_fb_devsw = { - .d_version = D_VERSION, - .d_flags = D_NEEDGIANT, - .d_open = creator_fb_open, - .d_close = creator_fb_close, - .d_ioctl = creator_fb_ioctl, - .d_mmap = creator_fb_mmap, - .d_name = "fb", -}; - -static void creator_cursor_enable(struct creator_softc *sc, int onoff); -static void creator_cursor_install(struct creator_softc *sc); -static void creator_shutdown(void *xsc); - -static int creator_configure(int flags); - -static vi_probe_t creator_probe; -static vi_init_t creator_init; -static vi_get_info_t creator_get_info; -static vi_query_mode_t creator_query_mode; -static vi_set_mode_t creator_set_mode; -static vi_save_font_t creator_save_font; -static vi_load_font_t creator_load_font; -static vi_show_font_t creator_show_font; -static vi_save_palette_t creator_save_palette; -static vi_load_palette_t creator_load_palette; -static vi_set_border_t creator_set_border; -static vi_save_state_t creator_save_state; -static vi_load_state_t creator_load_state; -static vi_set_win_org_t creator_set_win_org; -static vi_read_hw_cursor_t creator_read_hw_cursor; -static vi_set_hw_cursor_t creator_set_hw_cursor; -static vi_set_hw_cursor_shape_t creator_set_hw_cursor_shape; -static vi_blank_display_t creator_blank_display; -static vi_mmap_t creator_mmap; -static vi_ioctl_t creator_ioctl; -static vi_clear_t creator_clear; -static vi_fill_rect_t creator_fill_rect; -static vi_bitblt_t creator_bitblt; -static vi_diag_t creator_diag; -static vi_save_cursor_palette_t creator_save_cursor_palette; -static vi_load_cursor_palette_t creator_load_cursor_palette; -static vi_copy_t creator_copy; -static vi_putp_t creator_putp; -static vi_putc_t creator_putc; -static vi_puts_t creator_puts; -static vi_putm_t creator_putm; - -static video_switch_t creatorvidsw = { - .probe = creator_probe, - .init = creator_init, - .get_info = creator_get_info, - .query_mode = creator_query_mode, - .set_mode = creator_set_mode, - .save_font = creator_save_font, - .load_font = creator_load_font, - .show_font = creator_show_font, - .save_palette = creator_save_palette, - .load_palette = creator_load_palette, - .set_border = creator_set_border, - .save_state = creator_save_state, - .load_state = creator_load_state, - .set_win_org = creator_set_win_org, - .read_hw_cursor = creator_read_hw_cursor, - .set_hw_cursor = creator_set_hw_cursor, - .set_hw_cursor_shape = creator_set_hw_cursor_shape, - .blank_display = creator_blank_display, - .mmap = creator_mmap, - .ioctl = creator_ioctl, - .clear = creator_clear, - .fill_rect = creator_fill_rect, - .bitblt = creator_bitblt, - .diag = creator_diag, - .save_cursor_palette = creator_save_cursor_palette, - .load_cursor_palette = creator_load_cursor_palette, - .copy = creator_copy, - .putp = creator_putp, - .putc = creator_putc, - .puts = creator_puts, - .putm = creator_putm -}; - -VIDEO_DRIVER(creator, creatorvidsw, creator_configure); - -extern sc_rndr_sw_t txtrndrsw; -RENDERER(creator, 0, txtrndrsw, gfb_set); - -RENDERER_MODULE(creator, gfb_set); - -static const u_char creator_mouse_pointer[64][8] __aligned(8) = { - { 0x00, 0x00, }, /* ............ */ - { 0x80, 0x00, }, /* *........... */ - { 0xc0, 0x00, }, /* **.......... */ - { 0xe0, 0x00, }, /* ***......... */ - { 0xf0, 0x00, }, /* ****........ */ - { 0xf8, 0x00, }, /* *****....... */ - { 0xfc, 0x00, }, /* ******...... */ - { 0xfe, 0x00, }, /* *******..... */ - { 0xff, 0x00, }, /* ********.... */ - { 0xff, 0x80, }, /* *********... */ - { 0xfc, 0xc0, }, /* ******..**.. */ - { 0xdc, 0x00, }, /* **.***...... */ - { 0x8e, 0x00, }, /* *...***..... */ - { 0x0e, 0x00, }, /* ....***..... */ - { 0x07, 0x00, }, /* .....***.... */ - { 0x04, 0x00, }, /* .....*...... */ - { 0x00, 0x00, }, /* ............ */ - { 0x00, 0x00, }, /* ............ */ - { 0x00, 0x00, }, /* ............ */ - { 0x00, 0x00, }, /* ............ */ - { 0x00, 0x00, }, /* ............ */ - { 0x00, 0x00, }, /* ............ */ -}; - -static inline void creator_ras_fifo_wait(struct creator_softc *sc, int n); -static inline void creator_ras_setfontinc(struct creator_softc *sc, int fontinc); -static inline void creator_ras_setfontw(struct creator_softc *sc, int fontw); -static inline void creator_ras_setbg(struct creator_softc *sc, int bg); -static inline void creator_ras_setfg(struct creator_softc *sc, int fg); -static inline void creator_ras_setpmask(struct creator_softc *sc, int pmask); -static inline void creator_ras_wait(struct creator_softc *sc); - -static inline void -creator_ras_wait(struct creator_softc *sc) -{ - int ucsr; - int r; - - for (;;) { - ucsr = FFB_READ(sc, FFB_FBC, FFB_FBC_UCSR); - if ((ucsr & (FBC_UCSR_FB_BUSY | FBC_UCSR_RP_BUSY)) == 0) - break; - r = ucsr & (FBC_UCSR_READ_ERR | FBC_UCSR_FIFO_OVFL); - if (r != 0) - FFB_WRITE(sc, FFB_FBC, FFB_FBC_UCSR, r); - } -} - -static inline void -creator_ras_fifo_wait(struct creator_softc *sc, int n) -{ - int cache; - - cache = sc->sc_fifo_cache; - while (cache < n) - cache = (FFB_READ(sc, FFB_FBC, FFB_FBC_UCSR) & - FBC_UCSR_FIFO_MASK) - 8; - sc->sc_fifo_cache = cache - n; -} - -static inline void -creator_ras_setfontinc(struct creator_softc *sc, int fontinc) -{ - - if (fontinc == sc->sc_fontinc_cache) - return; - sc->sc_fontinc_cache = fontinc; - creator_ras_fifo_wait(sc, 1); - FFB_WRITE(sc, FFB_FBC, FFB_FBC_FONTINC, fontinc); - creator_ras_wait(sc); -} - -static inline void -creator_ras_setfontw(struct creator_softc *sc, int fontw) -{ - - if (fontw == sc->sc_fontw_cache) - return; - sc->sc_fontw_cache = fontw; - creator_ras_fifo_wait(sc, 1); - FFB_WRITE(sc, FFB_FBC, FFB_FBC_FONTW, fontw); - creator_ras_wait(sc); -} - -static inline void -creator_ras_setbg(struct creator_softc *sc, int bg) -{ - - if (bg == sc->sc_bg_cache) - return; - sc->sc_bg_cache = bg; - creator_ras_fifo_wait(sc, 1); - FFB_WRITE(sc, FFB_FBC, FFB_FBC_BG, bg); - creator_ras_wait(sc); -} - -static inline void -creator_ras_setfg(struct creator_softc *sc, int fg) -{ - - if (fg == sc->sc_fg_cache) - return; - sc->sc_fg_cache = fg; - creator_ras_fifo_wait(sc, 1); - FFB_WRITE(sc, FFB_FBC, FFB_FBC_FG, fg); - creator_ras_wait(sc); -} - -static inline void -creator_ras_setpmask(struct creator_softc *sc, int pmask) -{ - - if (pmask == sc->sc_pmask_cache) - return; - sc->sc_pmask_cache = pmask; - creator_ras_fifo_wait(sc, 1); - FFB_WRITE(sc, FFB_FBC, FFB_FBC_PMASK, pmask); - creator_ras_wait(sc); -} - -/* - * video driver interface - */ -static int -creator_configure(int flags) -{ - struct creator_softc *sc; - phandle_t chosen; - phandle_t output; - ihandle_t stdout; - bus_addr_t addr; - char buf[sizeof("SUNW,ffb")]; - int i; - int space; - - /* - * For the high-level console probing return the number of - * registered adapters. - */ - if (!(flags & VIO_PROBE_ONLY)) { - for (i = 0; vid_find_adapter(CREATOR_DRIVER_NAME, i) >= 0; i++) - ; - return (i); - } - - /* Low-level console probing and initialization. */ - - sc = &creator_softc; - if (sc->sc_va.va_flags & V_ADP_REGISTERED) - goto found; - - if ((chosen = OF_finddevice("/chosen")) == -1) - return (0); - if (OF_getprop(chosen, "stdout", &stdout, sizeof(stdout)) == -1) - return (0); - if ((output = OF_instance_to_package(stdout)) == -1) - return (0); - if (OF_getprop(output, "name", buf, sizeof(buf)) == -1) - return (0); - if (strcmp(buf, "SUNW,ffb") == 0 || strcmp(buf, "SUNW,afb") == 0) { - sc->sc_flags = CREATOR_CONSOLE; - if (strcmp(buf, "SUNW,afb") == 0) - sc->sc_flags |= CREATOR_AFB; - sc->sc_node = output; - } else - return (0); - - for (i = FFB_DAC; i <= FFB_FBC; i++) { - if (OF_decode_addr(output, i, &space, &addr) != 0) - return (0); - sc->sc_bt[i] = &creator_bst_store[i - FFB_DAC]; - sc->sc_bh[i] = sparc64_fake_bustag(space, addr, sc->sc_bt[i]); - } - - if (creator_init(0, &sc->sc_va, 0) < 0) - return (0); - - found: - /* Return number of found adapters. */ - return (1); -} - -static int -creator_probe(int unit, video_adapter_t **adpp, void *arg, int flags) -{ - - return (0); -} - -static int -creator_init(int unit, video_adapter_t *adp, int flags) -{ - struct creator_softc *sc; - phandle_t options; - video_info_t *vi; - char buf[sizeof("screen-#columns")]; - - sc = (struct creator_softc *)adp; - vi = &adp->va_info; - - vid_init_struct(adp, CREATOR_DRIVER_NAME, -1, unit); - - if (OF_getprop(sc->sc_node, "height", &sc->sc_height, - sizeof(sc->sc_height)) == -1) - return (ENXIO); - if (OF_getprop(sc->sc_node, "width", &sc->sc_width, - sizeof(sc->sc_width)) == -1) - return (ENXIO); - if ((options = OF_finddevice("/options")) == -1) - return (ENXIO); - if (OF_getprop(options, "screen-#rows", buf, sizeof(buf)) == -1) - return (ENXIO); - vi->vi_height = strtol(buf, NULL, 10); - if (OF_getprop(options, "screen-#columns", buf, sizeof(buf)) == -1) - return (ENXIO); - vi->vi_width = strtol(buf, NULL, 10); - vi->vi_cwidth = gallant12x22.width; - vi->vi_cheight = gallant12x22.height; - vi->vi_flags = V_INFO_COLOR; - vi->vi_mem_model = V_INFO_MM_OTHER; - - sc->sc_font = gallant12x22.data; - sc->sc_xmargin = (sc->sc_width - (vi->vi_width * vi->vi_cwidth)) / 2; - sc->sc_ymargin = (sc->sc_height - (vi->vi_height * vi->vi_cheight)) / 2; - - creator_set_mode(adp, 0); - - if (!(sc->sc_flags & CREATOR_AFB)) { - FFB_WRITE(sc, FFB_DAC, FFB_DAC_TYPE, FFB_DAC_CFG_DID); - if (((FFB_READ(sc, FFB_DAC, FFB_DAC_VALUE) & - FFB_DAC_CFG_DID_PNUM) >> 12) != 0x236e) { - sc->sc_flags |= CREATOR_PAC1; - FFB_WRITE(sc, FFB_DAC, FFB_DAC_TYPE, FFB_DAC_CFG_UCTRL); - if (((FFB_READ(sc, FFB_DAC, FFB_DAC_VALUE) & - FFB_DAC_UCTRL_MANREV) >> 8) <= 2) - sc->sc_flags |= CREATOR_CURINV; - } - } - - creator_blank_display(adp, V_DISPLAY_ON); - creator_clear(adp); - - /* - * Setting V_ADP_MODECHANGE serves as hack so creator_set_mode() - * (which will invalidate our caches and restore our settings) is - * called when the X server shuts down. Otherwise screen corruption - * happens most of the time. - */ - adp->va_flags |= V_ADP_COLOR | V_ADP_MODECHANGE | V_ADP_BORDER | - V_ADP_INITIALIZED; - if (vid_register(adp) < 0) - return (ENXIO); - adp->va_flags |= V_ADP_REGISTERED; - - return (0); -} - -static int -creator_get_info(video_adapter_t *adp, int mode, video_info_t *info) -{ - - bcopy(&adp->va_info, info, sizeof(*info)); - return (0); -} - -static int -creator_query_mode(video_adapter_t *adp, video_info_t *info) -{ - - return (ENODEV); -} - -static int -creator_set_mode(video_adapter_t *adp, int mode) -{ - struct creator_softc *sc; - - sc = (struct creator_softc *)adp; - sc->sc_bg_cache = -1; - sc->sc_fg_cache = -1; - sc->sc_fontinc_cache = -1; - sc->sc_fontw_cache = -1; - sc->sc_pmask_cache = -1; - - creator_ras_wait(sc); - sc->sc_fifo_cache = 0; - creator_ras_fifo_wait(sc, 2); - FFB_WRITE(sc, FFB_FBC, FFB_FBC_PPC, FBC_PPC_VCE_DIS | - FBC_PPC_TBE_OPAQUE | FBC_PPC_APE_DIS | FBC_PPC_CS_CONST); - FFB_WRITE(sc, FFB_FBC, FFB_FBC_FBC, FFB_FBC_WB_A | FFB_FBC_RB_A | - FFB_FBC_SB_BOTH | FFB_FBC_XE_OFF | FFB_FBC_RGBE_MASK); - return (0); -} - -static int -creator_save_font(video_adapter_t *adp, int page, int size, int width, - u_char *data, int c, int count) -{ - - return (ENODEV); -} - -static int -creator_load_font(video_adapter_t *adp, int page, int size, int width, - u_char *data, int c, int count) -{ - - return (ENODEV); -} - -static int -creator_show_font(video_adapter_t *adp, int page) -{ - - return (ENODEV); -} - -static int -creator_save_palette(video_adapter_t *adp, u_char *palette) -{ - - return (ENODEV); -} - -static int -creator_load_palette(video_adapter_t *adp, u_char *palette) -{ - - return (ENODEV); -} - -static int -creator_set_border(video_adapter_t *adp, int border) -{ - struct creator_softc *sc; - - sc = (struct creator_softc *)adp; - creator_fill_rect(adp, border, 0, 0, sc->sc_width, sc->sc_ymargin); - creator_fill_rect(adp, border, 0, sc->sc_height - sc->sc_ymargin, - sc->sc_width, sc->sc_ymargin); - creator_fill_rect(adp, border, 0, 0, sc->sc_xmargin, sc->sc_height); - creator_fill_rect(adp, border, sc->sc_width - sc->sc_xmargin, 0, - sc->sc_xmargin, sc->sc_height); - return (0); -} - -static int -creator_save_state(video_adapter_t *adp, void *p, size_t size) -{ - - return (ENODEV); -} - -static int -creator_load_state(video_adapter_t *adp, void *p) -{ - - return (ENODEV); -} - -static int -creator_set_win_org(video_adapter_t *adp, off_t offset) -{ - - return (ENODEV); -} - -static int -creator_read_hw_cursor(video_adapter_t *adp, int *col, int *row) -{ - - *col = 0; - *row = 0; - return (0); -} - -static int -creator_set_hw_cursor(video_adapter_t *adp, int col, int row) -{ - - return (ENODEV); -} - -static int -creator_set_hw_cursor_shape(video_adapter_t *adp, int base, int height, - int celsize, int blink) -{ - - return (ENODEV); -} - -static int -creator_blank_display(video_adapter_t *adp, int mode) -{ - struct creator_softc *sc; - uint32_t v; - int i; - - sc = (struct creator_softc *)adp; - FFB_WRITE(sc, FFB_DAC, FFB_DAC_TYPE, FFB_DAC_CFG_TGEN); - v = FFB_READ(sc, FFB_DAC, FFB_DAC_VALUE); - switch (mode) { - case V_DISPLAY_ON: - v |= FFB_DAC_CFG_TGEN_VIDE; - break; - case V_DISPLAY_BLANK: - case V_DISPLAY_STAND_BY: - case V_DISPLAY_SUSPEND: - v &= ~FFB_DAC_CFG_TGEN_VIDE; - break; - } - FFB_WRITE(sc, FFB_DAC, FFB_DAC_TYPE, FFB_DAC_CFG_TGEN); - FFB_WRITE(sc, FFB_DAC, FFB_DAC_VALUE, v); - for (i = 0; i < 10; i++) { - FFB_WRITE(sc, FFB_DAC, FFB_DAC_TYPE, FFB_DAC_CFG_TGEN); - (void)FFB_READ(sc, FFB_DAC, FFB_DAC_VALUE); - } - return (0); -} - -static int -creator_mmap(video_adapter_t *adp, vm_ooffset_t offset, vm_paddr_t *paddr, - int prot, vm_memattr_t *memattr) -{ - - return (EINVAL); -} - -static int -creator_ioctl(video_adapter_t *adp, u_long cmd, caddr_t data) -{ - struct creator_softc *sc; - struct fbcursor *fbc; - struct fbtype *fb; - - sc = (struct creator_softc *)adp; - switch (cmd) { - case FBIOGTYPE: - fb = (struct fbtype *)data; - fb->fb_type = FBTYPE_CREATOR; - fb->fb_height = sc->sc_height; - fb->fb_width = sc->sc_width; - fb->fb_depth = fb->fb_cmsize = fb->fb_size = 0; - break; - case FBIOSCURSOR: - fbc = (struct fbcursor *)data; - if (fbc->set & FB_CUR_SETCUR && fbc->enable == 0) { - creator_cursor_enable(sc, 0); - sc->sc_flags &= ~CREATOR_CUREN; - } else - return (ENODEV); - break; - break; - default: - return (fb_commonioctl(adp, cmd, data)); - } - return (0); -} - -static int -creator_clear(video_adapter_t *adp) -{ - struct creator_softc *sc; - - sc = (struct creator_softc *)adp; - creator_fill_rect(adp, (SC_NORM_ATTR >> 4) & 0xf, 0, 0, sc->sc_width, - sc->sc_height); - return (0); -} - -static int -creator_fill_rect(video_adapter_t *adp, int val, int x, int y, int cx, int cy) -{ - struct creator_softc *sc; - - sc = (struct creator_softc *)adp; - creator_ras_setpmask(sc, 0xffffffff); - creator_ras_fifo_wait(sc, 2); - FFB_WRITE(sc, FFB_FBC, FFB_FBC_ROP, FBC_ROP_NEW); - FFB_WRITE(sc, FFB_FBC, FFB_FBC_DRAWOP, FBC_DRAWOP_RECTANGLE); - creator_ras_setfg(sc, creator_cmap[val & 0xf]); - /* - * Note that at least the Elite3D cards are sensitive to the order - * of operations here. - */ - creator_ras_fifo_wait(sc, 4); - FFB_WRITE(sc, FFB_FBC, FFB_FBC_BY, y); - FFB_WRITE(sc, FFB_FBC, FFB_FBC_BX, x); - FFB_WRITE(sc, FFB_FBC, FFB_FBC_BH, cy); - FFB_WRITE(sc, FFB_FBC, FFB_FBC_BW, cx); - creator_ras_wait(sc); - return (0); -} - -static int -creator_bitblt(video_adapter_t *adp, ...) -{ - - return (ENODEV); -} - -static int -creator_diag(video_adapter_t *adp, int level) -{ - video_info_t info; - - fb_dump_adp_info(adp->va_name, adp, level); - creator_get_info(adp, 0, &info); - fb_dump_mode_info(adp->va_name, adp, &info, level); - return (0); -} - -static int -creator_save_cursor_palette(video_adapter_t *adp, u_char *palette) -{ - - return (ENODEV); -} - -static int -creator_load_cursor_palette(video_adapter_t *adp, u_char *palette) -{ - - return (ENODEV); -} - -static int -creator_copy(video_adapter_t *adp, vm_offset_t src, vm_offset_t dst, int n) -{ - - return (ENODEV); -} - -static int -creator_putp(video_adapter_t *adp, vm_offset_t off, u_int32_t p, u_int32_t a, - int size, int bpp, int bit_ltor, int byte_ltor) -{ - - return (ENODEV); -} - -static int -creator_putc(video_adapter_t *adp, vm_offset_t off, u_int8_t c, u_int8_t a) -{ - struct creator_softc *sc; - const uint16_t *p; - int row; - int col; - int i; - - sc = (struct creator_softc *)adp; - row = (off / adp->va_info.vi_width) * adp->va_info.vi_cheight; - col = (off % adp->va_info.vi_width) * adp->va_info.vi_cwidth; - p = (const uint16_t *)sc->sc_font + (c * adp->va_info.vi_cheight); - creator_ras_setfg(sc, creator_cmap[a & 0xf]); - creator_ras_setbg(sc, creator_cmap[(a >> 4) & 0xf]); - creator_ras_fifo_wait(sc, 1 + adp->va_info.vi_cheight); - FFB_WRITE(sc, FFB_FBC, FFB_FBC_FONTXY, - ((row + sc->sc_ymargin) << 16) | (col + sc->sc_xmargin)); - creator_ras_setfontw(sc, adp->va_info.vi_cwidth); - creator_ras_setfontinc(sc, 0x10000); - for (i = 0; i < adp->va_info.vi_cheight; i++) { - FFB_WRITE(sc, FFB_FBC, FFB_FBC_FONT, *p++ << 16); - } - return (0); -} - -static int -creator_puts(video_adapter_t *adp, vm_offset_t off, u_int16_t *s, int len) -{ - int i; - - for (i = 0; i < len; i++) { - vidd_putc(adp, off + i, s[i] & 0xff, (s[i] & 0xff00) >> 8); - } - - return (0); -} - -static int -creator_putm(video_adapter_t *adp, int x, int y, u_int8_t *pixel_image, - u_int32_t pixel_mask, int size, int width) -{ - struct creator_softc *sc; - - sc = (struct creator_softc *)adp; - if (!(sc->sc_flags & CREATOR_CUREN)) { - creator_cursor_install(sc); - creator_cursor_enable(sc, 1); - sc->sc_flags |= CREATOR_CUREN; - } - FFB_WRITE(sc, FFB_DAC, FFB_DAC_TYPE2, FFB_DAC_CUR_POS); - FFB_WRITE(sc, FFB_DAC, FFB_DAC_VALUE2, - ((y + sc->sc_ymargin) << 16) | (x + sc->sc_xmargin)); - return (0); -} - -/* - * bus interface - */ -static int -creator_bus_probe(device_t dev) -{ - const char *name; - phandle_t node; - int type; - - name = ofw_bus_get_name(dev); - node = ofw_bus_get_node(dev); - if (strcmp(name, "SUNW,ffb") == 0) { - if (OF_getprop(node, "board_type", &type, sizeof(type)) == -1) - return (ENXIO); - switch (type & 7) { - case 0x0: - device_set_desc(dev, "Creator"); - break; - case 0x3: - device_set_desc(dev, "Creator3D"); - break; - default: - return (ENXIO); - } - } else if (strcmp(name, "SUNW,afb") == 0) - device_set_desc(dev, "Elite3D"); - else - return (ENXIO); - return (BUS_PROBE_DEFAULT); -} - -static int -creator_bus_attach(device_t dev) -{ - struct creator_softc *sc; - video_adapter_t *adp; - video_switch_t *sw; - phandle_t node; - int error; - int rid; - int unit; - int i; - - node = ofw_bus_get_node(dev); - if ((sc = (struct creator_softc *)vid_get_adapter(vid_find_adapter( - CREATOR_DRIVER_NAME, 0))) != NULL && sc->sc_node == node) { - device_printf(dev, "console\n"); - device_set_softc(dev, sc); - } else { - sc = device_get_softc(dev); - sc->sc_node = node; - } - adp = &sc->sc_va; - - /* - * Allocate resources regardless of whether we are the console - * and already obtained the bus tags and handles for the FFB_DAC - * and FFB_FBC register banks in creator_configure() or not so - * the resources are marked as taken in the respective RMAN. - * The supported cards use either 15 (Creator, Elite3D?) or 24 - * (Creator3D?) register banks. We make sure that we can also - * allocate the resources for at least the FFB_DAC and FFB_FBC - * banks here. We try but don't actually care whether we can - * allocate more than these two resources and just limit the - * range accessible via creator_fb_mmap() accordingly. - */ - for (i = 0; i < FFB_NREG; i++) { - rid = i; - sc->sc_reg[i] = bus_alloc_resource_any(dev, SYS_RES_MEMORY, - &rid, RF_ACTIVE); - if (sc->sc_reg[i] == NULL) { - if (i <= FFB_FBC) { - device_printf(dev, - "cannot allocate resources\n"); - error = ENXIO; - goto fail; - } - break; - } - sc->sc_bt[i] = rman_get_bustag(sc->sc_reg[i]); - sc->sc_bh[i] = rman_get_bushandle(sc->sc_reg[i]); - } - /* - * The XFree86/X.Org sunffb(4) expects to be able to access the - * memory spanned by the first and the last resource as one chunk - * via creator_fb_mmap(), using offsets from the first resource, - * even though the backing resources are actually non-continuous. - * So make sure that the memory we provide is at least backed by - * increasing resources. - */ - for (i = 1; i < FFB_NREG && sc->sc_reg[i] != NULL && - rman_get_start(sc->sc_reg[i]) > rman_get_start(sc->sc_reg[i - 1]); - i++) - ; - sc->sc_reg_size = rman_get_end(sc->sc_reg[i - 1]) - - rman_get_start(sc->sc_reg[0]) + 1; - - if (!(sc->sc_flags & CREATOR_CONSOLE)) { - if ((sw = vid_get_switch(CREATOR_DRIVER_NAME)) == NULL) { - device_printf(dev, "cannot get video switch\n"); - error = ENODEV; - goto fail; - } - /* - * During device configuration we don't necessarily probe - * the adapter which is the console first so we can't use - * the device unit number for the video adapter unit. The - * worst case would be that we use the video adapter unit - * 0 twice. As it doesn't really matter which unit number - * the corresponding video adapter has just use the next - * unused one. - */ - for (i = 0; i < devclass_get_maxunit(creator_devclass); i++) - if (vid_find_adapter(CREATOR_DRIVER_NAME, i) < 0) - break; - if (strcmp(ofw_bus_get_name(dev), "SUNW,afb") == 0) - sc->sc_flags |= CREATOR_AFB; - if ((error = sw->init(i, adp, 0)) != 0) { - device_printf(dev, "cannot initialize adapter\n"); - goto fail; - } - } - - if (bootverbose) { - if (sc->sc_flags & CREATOR_PAC1) - device_printf(dev, - "BT9068/PAC1 RAMDAC (%s cursor control)\n", - sc->sc_flags & CREATOR_CURINV ? "inverted" : - "normal"); - else - device_printf(dev, "BT498/PAC2 RAMDAC\n"); - } - device_printf(dev, "resolution %dx%d\n", sc->sc_width, sc->sc_height); - - unit = device_get_unit(dev); - sc->sc_si = make_dev(&creator_fb_devsw, unit, UID_ROOT, GID_WHEEL, - 0600, "fb%d", unit); - sc->sc_si->si_drv1 = sc; - - EVENTHANDLER_REGISTER(shutdown_final, creator_shutdown, sc, - SHUTDOWN_PRI_DEFAULT); - - return (0); - - fail: - for (i = 0; i < FFB_NREG && sc->sc_reg[i] != NULL; i++) - bus_release_resource(dev, SYS_RES_MEMORY, - rman_get_rid(sc->sc_reg[i]), sc->sc_reg[i]); - return (error); -} - -/* - * /dev/fb interface - */ -static int -creator_fb_open(struct cdev *dev, int flags, int mode, struct thread *td) -{ - - return (0); -} - -static int -creator_fb_close(struct cdev *dev, int flags, int mode, struct thread *td) -{ - - return (0); -} - -static int -creator_fb_ioctl(struct cdev *dev, u_long cmd, caddr_t data, int flags, - struct thread *td) -{ - struct creator_softc *sc; - - sc = dev->si_drv1; - return (creator_ioctl(&sc->sc_va, cmd, data)); -} - -static int -creator_fb_mmap(struct cdev *dev, vm_ooffset_t offset, vm_paddr_t *paddr, - int prot, vm_memattr_t *memattr) -{ - struct creator_softc *sc; - int i; - - /* - * NB: This is a special implementation based on the /dev/fb - * requirements of the XFree86/X.Org sunffb(4). - */ - sc = dev->si_drv1; - for (i = 0; i < CREATOR_FB_MAP_SIZE; i++) { - if (offset >= creator_fb_map[i].virt && - offset < creator_fb_map[i].virt + creator_fb_map[i].size) { - offset += creator_fb_map[i].phys - - creator_fb_map[i].virt; - if (offset >= sc->sc_reg_size) - return (EINVAL); - *paddr = sc->sc_bh[0] + offset; - return (0); - } - } - return (EINVAL); -} - -/* - * internal functions - */ -static void -creator_cursor_enable(struct creator_softc *sc, int onoff) -{ - int v; - - FFB_WRITE(sc, FFB_DAC, FFB_DAC_TYPE2, FFB_DAC_CUR_CTRL); - if (sc->sc_flags & CREATOR_CURINV) - v = onoff ? FFB_DAC_CUR_CTRL_P0 | FFB_DAC_CUR_CTRL_P1 : 0; - else - v = onoff ? 0 : FFB_DAC_CUR_CTRL_P0 | FFB_DAC_CUR_CTRL_P1; - FFB_WRITE(sc, FFB_DAC, FFB_DAC_VALUE2, v); -} - -static void -creator_cursor_install(struct creator_softc *sc) -{ - int i, j; - - creator_cursor_enable(sc, 0); - FFB_WRITE(sc, FFB_DAC, FFB_DAC_TYPE2, FFB_DAC_CUR_COLOR1); - FFB_WRITE(sc, FFB_DAC, FFB_DAC_VALUE2, 0xffffff); - FFB_WRITE(sc, FFB_DAC, FFB_DAC_VALUE2, 0x0); - for (i = 0; i < 2; i++) { - FFB_WRITE(sc, FFB_DAC, FFB_DAC_TYPE2, - i ? FFB_DAC_CUR_BITMAP_P0 : FFB_DAC_CUR_BITMAP_P1); - for (j = 0; j < 64; j++) { - FFB_WRITE(sc, FFB_DAC, FFB_DAC_VALUE2, - *(const uint32_t *)(&creator_mouse_pointer[j][0])); - FFB_WRITE(sc, FFB_DAC, FFB_DAC_VALUE2, - *(const uint32_t *)(&creator_mouse_pointer[j][4])); - } - } -} - -static void -creator_shutdown(void *xsc) -{ - struct creator_softc *sc = xsc; - - creator_cursor_enable(sc, 0); - /* - * In case this is the console set the cursor of the stdout - * instance to the start of the last line so OFW output ends - * up beneath what FreeBSD left on the screen. - */ - if (sc->sc_flags & CREATOR_CONSOLE) { - OF_interpret("stdout @ is my-self 0 to column#", 0); - OF_interpret("stdout @ is my-self #lines 1 - to line#", 0); - } -} diff --git a/sys/dev/fb/creator_vt.c b/sys/dev/fb/creator_vt.c deleted file mode 100644 index f811f309b0fa..000000000000 --- a/sys/dev/fb/creator_vt.c +++ /dev/null @@ -1,274 +0,0 @@ -/*- - * Copyright (c) 2014 Nathan Whitehorn - * 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 -__FBSDID("$FreeBSD$"); - -#include -#include -#include -#include - -#include -#include -#include - -#include -#include - -#include -#include "creatorreg.h" - -static vd_probe_t creatorfb_probe; -static vd_init_t creatorfb_init; -static vd_blank_t creatorfb_blank; -static vd_bitblt_text_t creatorfb_bitblt_text; -static vd_bitblt_bmp_t creatorfb_bitblt_bitmap; - -static const struct vt_driver vt_creatorfb_driver = { - .vd_name = "creatorfb", - .vd_probe = creatorfb_probe, - .vd_init = creatorfb_init, - .vd_blank = creatorfb_blank, - .vd_bitblt_text = creatorfb_bitblt_text, - .vd_bitblt_bmp = creatorfb_bitblt_bitmap, - .vd_fb_ioctl = vt_fb_ioctl, - .vd_fb_mmap = vt_fb_mmap, - .vd_priority = VD_PRIORITY_SPECIFIC -}; - -struct creatorfb_softc { - struct fb_info fb; - struct bus_space_tag memt[1]; - bus_space_handle_t memh; -}; - -static struct creatorfb_softc creatorfb_conssoftc; -VT_DRIVER_DECLARE(vt_creatorfb, vt_creatorfb_driver); - -static int -creatorfb_probe(struct vt_device *vd) -{ - phandle_t chosen, node; - ihandle_t stdout; - char type[64], name[64]; - - chosen = OF_finddevice("/chosen"); - OF_getprop(chosen, "stdout", &stdout, sizeof(stdout)); - node = OF_instance_to_package(stdout); - if (node == -1) { - /* - * The "/chosen/stdout" does not exist try - * using "screen" directly. - */ - node = OF_finddevice("screen"); - } - OF_getprop(node, "device_type", type, sizeof(type)); - if (strcmp(type, "display") != 0) - return (CN_DEAD); - - OF_getprop(node, "name", name, sizeof(name)); - if (strcmp(name, "SUNW,ffb") != 0 && strcmp(name, "SUNW,afb") != 0) - return (CN_DEAD); - - /* Looks OK... */ - return (CN_INTERNAL); -} - -static int -creatorfb_init(struct vt_device *vd) -{ - struct creatorfb_softc *sc; - phandle_t chosen; - phandle_t node; - ihandle_t handle; - uint32_t height, width; - char type[64], name[64]; - bus_addr_t phys; - int space; - - /* Initialize softc */ - vd->vd_softc = sc = &creatorfb_conssoftc; - - chosen = OF_finddevice("/chosen"); - OF_getprop(chosen, "stdout", &handle, sizeof(ihandle_t)); - node = OF_instance_to_package(handle); - if (node == -1) { - /* - * The "/chosen/stdout" does not exist try - * using "screen" directly. - */ - node = OF_finddevice("screen"); - handle = OF_open("screen"); - } - OF_getprop(node, "device_type", type, sizeof(type)); - if (strcmp(type, "display") != 0) - return (CN_DEAD); - - OF_getprop(node, "name", name, sizeof(name)); - if (strcmp(name, "SUNW,ffb") != 0 && strcmp(name, "SUNW,afb") != 0) - return (CN_DEAD); - - /* Make sure we have needed properties */ - if (OF_getproplen(node, "height") != sizeof(height) || - OF_getproplen(node, "width") != sizeof(width)) - return (CN_DEAD); - - OF_getprop(node, "height", &height, sizeof(height)); - OF_getprop(node, "width", &width, sizeof(width)); - - sc->fb.fb_height = height; - sc->fb.fb_width = width; - sc->fb.fb_bpp = sc->fb.fb_depth = 32; - sc->fb.fb_stride = 8192; /* Fixed */ - sc->fb.fb_size = sc->fb.fb_height * sc->fb.fb_stride; - - /* Map linear framebuffer */ - if (OF_decode_addr(node, FFB_DFB24, &space, &phys) != 0) - return (CN_DEAD); - sc->fb.fb_pbase = phys; - sc->memh = sparc64_fake_bustag(space, phys, &sc->memt[0]); - - /* 32-bit VGA palette */ - vt_generate_cons_palette(sc->fb.fb_cmap, COLOR_FORMAT_RGB, - 255, 0, 255, 8, 255, 16); - sc->fb.fb_cmsize = 16; - - vt_fb_init(vd); - - return (CN_INTERNAL); -} - -static void -creatorfb_blank(struct vt_device *vd, term_color_t color) -{ - struct creatorfb_softc *sc; - uint32_t c; - int i; - - sc = vd->vd_softc; - c = sc->fb.fb_cmap[color]; - - for (i = 0; i < sc->fb.fb_height; i++) - bus_space_set_region_4(sc->memt, sc->memh, i*sc->fb.fb_stride, - c, sc->fb.fb_width); -} - -static void -creatorfb_bitblt_bitmap(struct vt_device *vd, const struct vt_window *vw, - const uint8_t *pattern, const uint8_t *mask, - unsigned int width, unsigned int height, - unsigned int x, unsigned int y, term_color_t fg, term_color_t bg) -{ - struct creatorfb_softc *sc = vd->vd_softc; - u_long line; - uint32_t fgc, bgc; - int c, l; - uint8_t b, m; - - fgc = sc->fb.fb_cmap[fg]; - bgc = sc->fb.fb_cmap[bg]; - b = m = 0; - - line = (sc->fb.fb_stride * y) + 4*x; - for (l = 0; - l < height && y + l < vw->vw_draw_area.tr_end.tp_row; - l++) { - for (c = 0; - c < width && x + c < vw->vw_draw_area.tr_end.tp_col; - c++) { - if (c % 8 == 0) - b = *pattern++; - else - b <<= 1; - if (mask != NULL) { - if (c % 8 == 0) - m = *mask++; - else - m <<= 1; - /* Skip pixel write if mask not set. */ - if ((m & 0x80) == 0) - continue; - } - bus_space_write_4(sc->memt, sc->memh, line + 4*c, - (b & 0x80) ? fgc : bgc); - } - line += sc->fb.fb_stride; - } -} - -void -creatorfb_bitblt_text(struct vt_device *vd, const struct vt_window *vw, - const term_rect_t *area) -{ - unsigned int col, row, x, y; - struct vt_font *vf; - term_char_t c; - term_color_t fg, bg; - const uint8_t *pattern; - - vf = vw->vw_font; - - for (row = area->tr_begin.tp_row; row < area->tr_end.tp_row; ++row) { - for (col = area->tr_begin.tp_col; col < area->tr_end.tp_col; - ++col) { - x = col * vf->vf_width + - vw->vw_draw_area.tr_begin.tp_col; - y = row * vf->vf_height + - vw->vw_draw_area.tr_begin.tp_row; - - c = VTBUF_GET_FIELD(&vw->vw_buf, row, col); - pattern = vtfont_lookup(vf, c); - vt_determine_colors(c, - VTBUF_ISCURSOR(&vw->vw_buf, row, col), &fg, &bg); - - creatorfb_bitblt_bitmap(vd, vw, - pattern, NULL, vf->vf_width, vf->vf_height, - x, y, fg, bg); - } - } - -#ifndef SC_NO_CUTPASTE - if (!vd->vd_mshown) - return; - - term_rect_t drawn_area; - - drawn_area.tr_begin.tp_col = area->tr_begin.tp_col * vf->vf_width; - drawn_area.tr_begin.tp_row = area->tr_begin.tp_row * vf->vf_height; - drawn_area.tr_end.tp_col = area->tr_end.tp_col * vf->vf_width; - drawn_area.tr_end.tp_row = area->tr_end.tp_row * vf->vf_height; - - if (vt_is_cursor_in_area(vd, &drawn_area)) { - creatorfb_bitblt_bitmap(vd, vw, - vd->vd_mcursor->map, vd->vd_mcursor->mask, - vd->vd_mcursor->width, vd->vd_mcursor->height, - vd->vd_mx_drawn + vw->vw_draw_area.tr_begin.tp_col, - vd->vd_my_drawn + vw->vw_draw_area.tr_begin.tp_row, - vd->vd_mcursor_fg, vd->vd_mcursor_bg); - } -#endif -} diff --git a/sys/dev/fb/creatorreg.h b/sys/dev/fb/creatorreg.h deleted file mode 100644 index 2cdb2dff1b93..000000000000 --- a/sys/dev/fb/creatorreg.h +++ /dev/null @@ -1,249 +0,0 @@ -/*- - * Copyright (C) 2000 David S. Miller (davem@redhat.com) - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * DAVID MILLER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * from: XFree86: ffb_dac.h,v 1.1 2000/05/23 04:47:44 dawes Exp - */ -/*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD - * - * Copyright (c) 2003 Jake Burkholder. - * 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$ - */ - -#ifndef _DEV_FB_CREATORREG_H_ -#define _DEV_FB_CREATORREG_H_ - -#define FFB_NREG 24 - -#define FFB_PROM 0 -#define FFB_DAC 1 -#define FFB_FBC 2 -#define FFB_DFB8R 3 -#define FFB_DFB8G 4 -#define FFB_DFB8B 5 -#define FFB_DFB8X 6 -#define FFB_DFB24 7 -#define FFB_DFB32 8 -#define FFB_SFB8R 9 -#define FFB_SFB8G 10 -#define FFB_SFB8B 11 -#define FFB_SFB8X 12 -#define FFB_SFB32 13 -#define FFB_SFB64 14 -#define FFB_DFB422A 15 - -#define FFB_DAC_TYPE 0x0 -#define FFB_DAC_VALUE 0x4 -#define FFB_DAC_TYPE2 0x8 -#define FFB_DAC_VALUE2 0xc - -/* FFB_DAC_TYPE configuration and palette register addresses */ -#define FFB_DAC_CFG_UCTRL 0x1001 /* User Control */ -#define FFB_DAC_CFG_TGEN 0x6000 /* Timing Generator Control */ -#define FFB_DAC_CFG_DID 0x8000 /* Device Identification */ - -/* FFB_DAC_CFG_UCTRL register */ -#define FFB_DAC_UCTRL_IPDISAB 0x0001 /* Input Pullup Resistor Dis. */ -#define FFB_DAC_UCTRL_ABLANK 0x0002 /* Asynchronous Blank */ -#define FFB_DAC_UCTRL_DBENAB 0x0004 /* Double-Buffer Enable */ -#define FFB_DAC_UCTRL_OVENAB 0x0008 /* Overlay Enable */ -#define FFB_DAC_UCTRL_WMODE 0x0030 /* Window Mode */ -#define FFB_DAC_UCTRL_WM_COMB 0x0000 /* Window Mode Combined */ -#define FFB_DAC_UCTRL_WM_S4 0x0010 /* Window Mode Separate 4 */ -#define FFB_DAC_UCTRL_WM_S8 0x0020 /* Window Mode Separate 8 */ -#define FFB_DAC_UCTRL_WM_RESV 0x0030 /* Window Mode Reserved */ -#define FFB_DAC_UCTRL_MANREV 0x0f00 /* Manufacturing Revision */ - -/* FFB_DAC_CFG_TGEN register */ -#define FFB_DAC_CFG_TGEN_VIDE 0x01 /* Video Enable */ -#define FFB_DAC_CFG_TGEN_TGE 0x02 /* Timing Generator Enable */ -#define FFB_DAC_CFG_TGEN_HSD 0x04 /* HSYNC* Disable */ -#define FFB_DAC_CFG_TGEN_VSD 0x08 /* VSYNC* Disable */ -#define FFB_DAC_CFG_TGEN_EQD 0x10 /* Equalization Disable */ -#define FFB_DAC_CFG_TGEN_MM 0x20 /* 0 = Slave, 1 = Master */ -#define FFB_DAC_CFG_TGEN_IM 0x40 /* 1 = Interlaced Mode */ - -/* FFB_DAC_CFG_DID register */ -#define FFB_DAC_CFG_DID_ONE 0x00000001 /* Always Set */ -#define FFB_DAC_CFG_DID_MANUF 0x00000ffe /* DAC Manufacturer ID */ -#define FFB_DAC_CFG_DID_PNUM 0x0ffff000 /* DAC Part Number */ -#define FFB_DAC_CFG_DID_REV 0xf0000000 /* DAC Revision */ - -/* FFB_DAC_TYPE2 cursor register addresses */ -#define FFB_DAC_CUR_BITMAP_P0 0x0 /* Plane 0 Cursor Bitmap */ -#define FFB_DAC_CUR_BITMAP_P1 0x80 /* Plane 1 Cursor Bitmap */ -#define FFB_DAC_CUR_CTRL 0x100 /* Cursor Control */ -#define FFB_DAC_CUR_COLOR0 0x101 /* Cursor Color 0 */ -#define FFB_DAC_CUR_COLOR1 0x102 /* Cursor Color 1 (bg) */ -#define FFB_DAC_CUR_COLOR2 0x103 /* Cursor Color 2 (fg) */ -#define FFB_DAC_CUR_POS 0x104 /* Active Cursor Position */ - -/* FFB_DAC_CUR_CTRL register (might be inverted on PAC1 DACs) */ -#define FFB_DAC_CUR_CTRL_P0 0x1 /* Plane0 Display Disable */ -#define FFB_DAC_CUR_CTRL_P1 0x2 /* Plane1 Display Disable */ - -#define FFB_FBC_BY 0x60 -#define FFB_FBC_BX 0x64 -#define FFB_FBC_DY 0x68 -#define FFB_FBC_DX 0x6c -#define FFB_FBC_BH 0x70 -#define FFB_FBC_BW 0x74 -#define FFB_FBC_PPC 0x200 /* Pixel Processor Control */ -#define FFB_FBC_FG 0x208 /* Foreground */ -#define FFB_FBC_BG 0x20c /* Background */ -#define FFB_FBC_FBC 0x254 /* Frame Buffer Control */ -#define FFB_FBC_ROP 0x258 /* Raster Operation */ -#define FFB_FBC_PMASK 0x290 /* Pixel Mask */ -#define FFB_FBC_DRAWOP 0x300 /* Draw Operation */ -#define FFB_FBC_FONTXY 0x314 /* Font X/Y */ -#define FFB_FBC_FONTW 0x318 /* Font Width */ -#define FFB_FBC_FONTINC 0x31c /* Font Increment */ -#define FFB_FBC_FONT 0x320 /* Font Data */ -#define FFB_FBC_UCSR 0x900 /* User Control & Status */ - -#define FBC_PPC_VCE_DIS 0x00001000 -#define FBC_PPC_APE_DIS 0x00000800 -#define FBC_PPC_TBE_OPAQUE 0x00000200 -#define FBC_PPC_CS_CONST 0x00000003 - -#define FFB_FBC_WB_A 0x20000000 -#define FFB_FBC_RB_A 0x00004000 -#define FFB_FBC_SB_BOTH 0x00003000 -#define FFB_FBC_XE_OFF 0x00000040 -#define FFB_FBC_RGBE_MASK 0x0000003f - -#define FBC_ROP_NEW 0x83 - -#define FBC_DRAWOP_RECTANGLE 0x08 - -#define FBC_UCSR_FIFO_OVFL 0x80000000 -#define FBC_UCSR_READ_ERR 0x40000000 -#define FBC_UCSR_RP_BUSY 0x02000000 -#define FBC_UCSR_FB_BUSY 0x01000000 -#define FBC_UCSR_FIFO_MASK 0x00000fff - -#define FFB_VIRT_SFB8R 0x00000000 -#define FFB_VIRT_SFB8G 0x00400000 -#define FFB_VIRT_SFB8B 0x00800000 -#define FFB_VIRT_SFB8X 0x00c00000 -#define FFB_VIRT_SFB32 0x01000000 -#define FFB_VIRT_SFB64 0x02000000 -#define FFB_VIRT_FBC 0x04000000 -#define FFB_VIRT_FBC_BM 0x04002000 -#define FFB_VIRT_DFB8R 0x04004000 -#define FFB_VIRT_DFB8G 0x04404000 -#define FFB_VIRT_DFB8B 0x04804000 -#define FFB_VIRT_DFB8X 0x04c04000 -#define FFB_VIRT_DFB24 0x05004000 -#define FFB_VIRT_DFB32 0x06004000 -#define FFB_VIRT_DFB422A 0x07004000 -#define FFB_VIRT_DFB422AD 0x07804000 -#define FFB_VIRT_DFB24B 0x08004000 -#define FFB_VIRT_DFB422B 0x09004000 -#define FFB_VIRT_DFB422BD 0x09804000 -#define FFB_VIRT_SFB16Z 0x0a004000 -#define FFB_VIRT_SFB8Z 0x0a404000 -#define FFB_VIRT_SFB422 0x0ac04000 -#define FFB_VIRT_SFB422D 0x0b404000 -#define FFB_VIRT_FBC_KREG 0x0bc04000 -#define FFB_VIRT_DAC 0x0bc06000 -#define FFB_VIRT_PROM 0x0bc08000 -#define FFB_VIRT_EXP 0x0bc18000 - -#define FFB_PHYS_SFB8R 0x04000000 -#define FFB_PHYS_SFB8G 0x04400000 -#define FFB_PHYS_SFB8B 0x04800000 -#define FFB_PHYS_SFB8X 0x04c00000 -#define FFB_PHYS_SFB32 0x05000000 -#define FFB_PHYS_SFB64 0x06000000 -#define FFB_PHYS_FBC 0x00600000 -#define FFB_PHYS_FBC_BM 0x00600000 -#define FFB_PHYS_DFB8R 0x01000000 -#define FFB_PHYS_DFB8G 0x01400000 -#define FFB_PHYS_DFB8B 0x01800000 -#define FFB_PHYS_DFB8X 0x01c00000 -#define FFB_PHYS_DFB24 0x02000000 -#define FFB_PHYS_DFB32 0x03000000 -#define FFB_PHYS_DFB422A 0x09000000 -#define FFB_PHYS_DFB422AD 0x09800000 -#define FFB_PHYS_DFB24B 0x0a000000 -#define FFB_PHYS_DFB422B 0x0b000000 -#define FFB_PHYS_DFB422BD 0x0b800000 -#define FFB_PHYS_SFB16Z 0x0c800000 -#define FFB_PHYS_SFB8Z 0x0c000000 -#define FFB_PHYS_SFB422 0x0d000000 -#define FFB_PHYS_SFB422D 0x0d800000 -#define FFB_PHYS_FBC_KREG 0x00610000 -#define FFB_PHYS_DAC 0x00400000 -#define FFB_PHYS_PROM 0x00000000 -#define FFB_PHYS_EXP 0x00200000 - -#define FFB_SIZE_SFB8R 0x00400000 -#define FFB_SIZE_SFB8G 0x00400000 -#define FFB_SIZE_SFB8B 0x00400000 -#define FFB_SIZE_SFB8X 0x00400000 -#define FFB_SIZE_SFB32 0x01000000 -#define FFB_SIZE_SFB64 0x02000000 -#define FFB_SIZE_FBC 0x00002000 -#define FFB_SIZE_FBC_BM 0x00002000 -#define FFB_SIZE_DFB8R 0x00400000 -#define FFB_SIZE_DFB8G 0x00400000 -#define FFB_SIZE_DFB8B 0x00400000 -#define FFB_SIZE_DFB8X 0x00400000 -#define FFB_SIZE_DFB24 0x01000000 -#define FFB_SIZE_DFB32 0x01000000 -#define FFB_SIZE_DFB422A 0x00800000 -#define FFB_SIZE_DFB422AD 0x00800000 -#define FFB_SIZE_DFB24B 0x01000000 -#define FFB_SIZE_DFB422B 0x00800000 -#define FFB_SIZE_DFB422BD 0x00800000 -#define FFB_SIZE_SFB16Z 0x00800000 -#define FFB_SIZE_SFB8Z 0x00800000 -#define FFB_SIZE_SFB422 0x00800000 -#define FFB_SIZE_SFB422D 0x00800000 -#define FFB_SIZE_FBC_KREG 0x00002000 -#define FFB_SIZE_DAC 0x00002000 -#define FFB_SIZE_PROM 0x00010000 -#define FFB_SIZE_EXP 0x00002000 - -#endif /* !_DEV_FB_CREATORREG_H_ */ diff --git a/sys/dev/fb/fbreg.h b/sys/dev/fb/fbreg.h index d5bfd0daa0cd..7637f06a86b4 100644 --- a/sys/dev/fb/fbreg.h +++ b/sys/dev/fb/fbreg.h @@ -51,13 +51,6 @@ copyw(uint16_t *src, uint16_t *dst, size_t size) #define bzero_io(d, c) bzero((void *)(d), (c)) #define fill_io(p, d, c) fill((p), (void *)(d), (c)) #define fillw_io(p, d, c) fillw((p), (void *)(d), (c)) -#elif defined(__sparc64__) -static __inline void -fillw(int val, uint16_t *buf, size_t size) -{ - while (size--) - *buf++ = val; -} #elif defined(__powerpc__) #define bcopy_io(s, d, c) ofwfb_bcopy((void *)(s), (void *)(d), (c)) @@ -102,7 +95,7 @@ fillw(int val, uint16_t *buf, size_t size) #define writew(a, v) (*(uint16_t*)(a) = (v)) #endif -#else /* !__i386__ && !__amd64__ && !__sparc64__ && !__powerpc__ */ +#else /* !__i386__ && !__amd64__ && !__powerpc__ */ #define bcopy_io(s, d, c) memcpy_io((d), (s), (c)) #define bcopy_toio(s, d, c) memcpy_toio((d), (void *)(s), (c)) #define bcopy_fromio(s, d, c) memcpy_fromio((void *)(d), (s), (c)) diff --git a/sys/dev/fb/machfb.c b/sys/dev/fb/machfb.c deleted file mode 100644 index 7c719bbe1cd9..000000000000 --- a/sys/dev/fb/machfb.c +++ /dev/null @@ -1,1581 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-3-Clause - * - * Copyright (c) 2002 Bang Jun-Young - * Copyright (c) 2005 Marius Strobl - * 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. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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. - * - * from: NetBSD: machfb.c,v 1.23 2005/03/07 21:45:24 martin Exp - */ - -#include -__FBSDID("$FreeBSD$"); - -/* - * Driver for ATI Mach64 graphics chips. Some code is derived from the - * ATI Rage Pro and Derivatives Programmer's Guide. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include -#include - -#include -#include -#include -#include -#include - -#include - -#include -#include -#include -#include -#include -#include - -/* #define MACHFB_DEBUG */ - -#define MACHFB_DRIVER_NAME "machfb" - -#define MACH64_REG_OFF 0x7ffc00 -#define MACH64_REG_SIZE 1024 - -struct machfb_softc { - video_adapter_t sc_va; /* must be first */ - - phandle_t sc_node; - uint16_t sc_chip_id; - uint8_t sc_chip_rev; - - struct resource *sc_memres; - struct resource *sc_vmemres; - bus_space_tag_t sc_memt; - bus_space_tag_t sc_regt; - bus_space_tag_t sc_vmemt; - bus_space_handle_t sc_memh; - bus_space_handle_t sc_vmemh; - bus_space_handle_t sc_regh; - u_long sc_mem; - u_long sc_vmem; - - u_int sc_height; - u_int sc_width; - u_int sc_depth; - u_int sc_xmargin; - u_int sc_ymargin; - - size_t sc_memsize; - u_int sc_memtype; - u_int sc_mem_freq; - u_int sc_ramdac_freq; - u_int sc_ref_freq; - - u_int sc_ref_div; - u_int sc_mclk_post_div; - u_int sc_mclk_fb_div; - - const u_char *sc_font; - u_int sc_cbwidth; - vm_offset_t sc_curoff; - - int sc_bg_cache; - int sc_fg_cache; - u_int sc_draw_cache; -#define MACHFB_DRAW_CHAR (1 << 0) -#define MACHFB_DRAW_FILLRECT (1 << 1) - - u_int sc_flags; -#define MACHFB_CONSOLE (1 << 0) -#define MACHFB_CUREN (1 << 1) -#define MACHFB_DSP (1 << 2) -#define MACHFB_SWAP (1 << 3) -}; - -static const struct { - uint16_t chip_id; - const char *name; - uint32_t ramdac_freq; -} machfb_info[] = { - { ATI_MACH64_CT, "ATI Mach64 CT", 135000 }, - { ATI_RAGE_PRO_AGP, "ATI 3D Rage Pro (AGP)", 230000 }, - { ATI_RAGE_PRO_AGP1X, "ATI 3D Rage Pro (AGP 1x)", 230000 }, - { ATI_RAGE_PRO_PCI_B, "ATI 3D Rage Pro Turbo", 230000 }, - { ATI_RAGE_XC_PCI66, "ATI Rage XL (PCI66)", 230000 }, - { ATI_RAGE_XL_AGP, "ATI Rage XL (AGP)", 230000 }, - { ATI_RAGE_XC_AGP, "ATI Rage XC (AGP)", 230000 }, - { ATI_RAGE_XL_PCI66, "ATI Rage XL (PCI66)", 230000 }, - { ATI_RAGE_PRO_PCI_P, "ATI 3D Rage Pro", 230000 }, - { ATI_RAGE_PRO_PCI_L, "ATI 3D Rage Pro (limited 3D)", 230000 }, - { ATI_RAGE_XL_PCI, "ATI Rage XL", 230000 }, - { ATI_RAGE_XC_PCI, "ATI Rage XC", 230000 }, - { ATI_RAGE_II, "ATI 3D Rage I/II", 135000 }, - { ATI_RAGE_IIP, "ATI 3D Rage II+", 200000 }, - { ATI_RAGE_IIC_PCI, "ATI 3D Rage IIC", 230000 }, - { ATI_RAGE_IIC_AGP_B, "ATI 3D Rage IIC (AGP)", 230000 }, - { ATI_RAGE_IIC_AGP_P, "ATI 3D Rage IIC (AGP)", 230000 }, - { ATI_RAGE_LT_PRO_AGP, "ATI 3D Rage LT Pro (AGP 133MHz)", 230000 }, - { ATI_RAGE_MOB_M3_PCI, "ATI Rage Mobility M3", 230000 }, - { ATI_RAGE_MOB_M3_AGP, "ATI Rage Mobility M3 (AGP)", 230000 }, - { ATI_RAGE_LT, "ATI 3D Rage LT", 230000 }, - { ATI_RAGE_LT_PRO_PCI, "ATI 3D Rage LT Pro", 230000 }, - { ATI_RAGE_MOBILITY, "ATI Rage Mobility", 230000 }, - { ATI_RAGE_L_MOBILITY, "ATI Rage L Mobility", 230000 }, - { ATI_RAGE_LT_PRO, "ATI 3D Rage LT Pro", 230000 }, - { ATI_RAGE_LT_PRO2, "ATI 3D Rage LT Pro", 230000 }, - { ATI_RAGE_MOB_M1_PCI, "ATI Rage Mobility M1 (PCI)", 230000 }, - { ATI_RAGE_L_MOB_M1_PCI, "ATI Rage L Mobility (PCI)", 230000 }, - { ATI_MACH64_VT, "ATI Mach64 VT", 170000 }, - { ATI_MACH64_VTB, "ATI Mach64 VTB", 200000 }, - { ATI_MACH64_VT4, "ATI Mach64 VT4", 230000 } -}; - -static const struct machfb_cmap { - uint8_t red; - uint8_t green; - uint8_t blue; -} machfb_default_cmap[16] = { - {0x00, 0x00, 0x00}, /* black */ - {0x00, 0x00, 0xff}, /* blue */ - {0x00, 0xff, 0x00}, /* green */ - {0x00, 0xc0, 0xc0}, /* cyan */ - {0xff, 0x00, 0x00}, /* red */ - {0xc0, 0x00, 0xc0}, /* magenta */ - {0xc0, 0xc0, 0x00}, /* brown */ - {0xc0, 0xc0, 0xc0}, /* light grey */ - {0x80, 0x80, 0x80}, /* dark grey */ - {0x80, 0x80, 0xff}, /* light blue */ - {0x80, 0xff, 0x80}, /* light green */ - {0x80, 0xff, 0xff}, /* light cyan */ - {0xff, 0x80, 0x80}, /* light red */ - {0xff, 0x80, 0xff}, /* light magenta */ - {0xff, 0xff, 0x80}, /* yellow */ - {0xff, 0xff, 0xff} /* white */ -}; - -#define MACHFB_CMAP_OFF 16 - -static const u_char machfb_mouse_pointer_bits[64][8] = { - { 0x00, 0x00, }, /* ............ */ - { 0x80, 0x00, }, /* *........... */ - { 0xc0, 0x00, }, /* **.......... */ - { 0xe0, 0x00, }, /* ***......... */ - { 0xf0, 0x00, }, /* ****........ */ - { 0xf8, 0x00, }, /* *****....... */ - { 0xfc, 0x00, }, /* ******...... */ - { 0xfe, 0x00, }, /* *******..... */ - { 0xff, 0x00, }, /* ********.... */ - { 0xff, 0x80, }, /* *********... */ - { 0xfc, 0xc0, }, /* ******..**.. */ - { 0xdc, 0x00, }, /* **.***...... */ - { 0x8e, 0x00, }, /* *...***..... */ - { 0x0e, 0x00, }, /* ....***..... */ - { 0x07, 0x00, }, /* .....***.... */ - { 0x04, 0x00, }, /* .....*...... */ - { 0x00, 0x00, }, /* ............ */ - { 0x00, 0x00, }, /* ............ */ - { 0x00, 0x00, }, /* ............ */ - { 0x00, 0x00, }, /* ............ */ - { 0x00, 0x00, }, /* ............ */ - { 0x00, 0x00, }, /* ............ */ -}; - -/* - * Lookup table to perform a bit-swap of the mouse pointer bits, - * map set bits to CUR_CLR0 and unset bits to transparent. - */ -static const u_char machfb_mouse_pointer_lut[] = { - 0xaa, 0x2a, 0x8a, 0x0a, 0xa2, 0x22, 0x82, 0x02, - 0xa8, 0x28, 0x88, 0x08, 0xa0, 0x20, 0x80, 0x00 -}; - -static const char *const machfb_memtype_names[] = { - "(N/A)", "DRAM", "EDO DRAM", "EDO DRAM", "SDRAM", "SGRAM", "WRAM", - "(unknown type)" -}; - -extern const struct gfb_font gallant12x22; - -static struct machfb_softc machfb_softc; -static struct bus_space_tag machfb_bst_store[1]; - -static device_probe_t machfb_pci_probe; -static device_attach_t machfb_pci_attach; -static device_detach_t machfb_pci_detach; - -static device_method_t machfb_methods[] = { - /* Device interface */ - DEVMETHOD(device_probe, machfb_pci_probe), - DEVMETHOD(device_attach, machfb_pci_attach), - DEVMETHOD(device_detach, machfb_pci_detach), - - { 0, 0 } -}; - -static driver_t machfb_pci_driver = { - MACHFB_DRIVER_NAME, - machfb_methods, - sizeof(struct machfb_softc), -}; - -static devclass_t machfb_devclass; - -DRIVER_MODULE(machfb, pci, machfb_pci_driver, machfb_devclass, 0, 0); -MODULE_DEPEND(machfb, pci, 1, 1, 1); - -static void machfb_cursor_enable(struct machfb_softc *, int); -static int machfb_cursor_install(struct machfb_softc *); -static int machfb_get_memsize(struct machfb_softc *); -static void machfb_reset_engine(struct machfb_softc *); -static void machfb_init_engine(struct machfb_softc *); -#if 0 -static void machfb_adjust_frame(struct machfb_softc *, int, int); -#endif -static void machfb_shutdown_final(void *); -static void machfb_shutdown_reset(void *); - -static int machfb_configure(int); - -static vi_probe_t machfb_probe; -static vi_init_t machfb_init; -static vi_get_info_t machfb_get_info; -static vi_query_mode_t machfb_query_mode; -static vi_set_mode_t machfb_set_mode; -static vi_save_font_t machfb_save_font; -static vi_load_font_t machfb_load_font; -static vi_show_font_t machfb_show_font; -static vi_save_palette_t machfb_save_palette; -static vi_load_palette_t machfb_load_palette; -static vi_set_border_t machfb_set_border; -static vi_save_state_t machfb_save_state; -static vi_load_state_t machfb_load_state; -static vi_set_win_org_t machfb_set_win_org; -static vi_read_hw_cursor_t machfb_read_hw_cursor; -static vi_set_hw_cursor_t machfb_set_hw_cursor; -static vi_set_hw_cursor_shape_t machfb_set_hw_cursor_shape; -static vi_blank_display_t machfb_blank_display; -static vi_mmap_t machfb_mmap; -static vi_ioctl_t machfb_ioctl; -static vi_clear_t machfb_clear; -static vi_fill_rect_t machfb_fill_rect; -static vi_bitblt_t machfb_bitblt; -static vi_diag_t machfb_diag; -static vi_save_cursor_palette_t machfb_save_cursor_palette; -static vi_load_cursor_palette_t machfb_load_cursor_palette; -static vi_copy_t machfb_copy; -static vi_putp_t machfb_putp; -static vi_putc_t machfb_putc; -static vi_puts_t machfb_puts; -static vi_putm_t machfb_putm; - -static video_switch_t machfbvidsw = { - .probe = machfb_probe, - .init = machfb_init, - .get_info = machfb_get_info, - .query_mode = machfb_query_mode, - .set_mode = machfb_set_mode, - .save_font = machfb_save_font, - .load_font = machfb_load_font, - .show_font = machfb_show_font, - .save_palette = machfb_save_palette, - .load_palette = machfb_load_palette, - .set_border = machfb_set_border, - .save_state = machfb_save_state, - .load_state = machfb_load_state, - .set_win_org = machfb_set_win_org, - .read_hw_cursor = machfb_read_hw_cursor, - .set_hw_cursor = machfb_set_hw_cursor, - .set_hw_cursor_shape = machfb_set_hw_cursor_shape, - .blank_display = machfb_blank_display, - .mmap = machfb_mmap, - .ioctl = machfb_ioctl, - .clear = machfb_clear, - .fill_rect = machfb_fill_rect, - .bitblt = machfb_bitblt, - .diag = machfb_diag, - .save_cursor_palette = machfb_save_cursor_palette, - .load_cursor_palette = machfb_load_cursor_palette, - .copy = machfb_copy, - .putp = machfb_putp, - .putc = machfb_putc, - .puts = machfb_puts, - .putm = machfb_putm -}; - -VIDEO_DRIVER(machfb, machfbvidsw, machfb_configure); - -extern sc_rndr_sw_t txtrndrsw; -RENDERER(machfb, 0, txtrndrsw, gfb_set); - -RENDERER_MODULE(machfb, gfb_set); - -/* - * Inline functions for getting access to register aperture. - */ -static inline uint32_t regr(struct machfb_softc *, uint32_t); -static inline uint8_t regrb(struct machfb_softc *, uint32_t); -static inline void regw(struct machfb_softc *, uint32_t, uint32_t); -static inline void regwb(struct machfb_softc *, uint32_t, uint8_t); -static inline void regwb_pll(struct machfb_softc *, uint32_t, uint8_t); - -static inline uint32_t -regr(struct machfb_softc *sc, uint32_t index) -{ - - return bus_space_read_4(sc->sc_regt, sc->sc_regh, index); -} - -static inline uint8_t -regrb(struct machfb_softc *sc, uint32_t index) -{ - - return bus_space_read_1(sc->sc_regt, sc->sc_regh, index); -} - -static inline void -regw(struct machfb_softc *sc, uint32_t index, uint32_t data) -{ - - bus_space_write_4(sc->sc_regt, sc->sc_regh, index, data); - bus_space_barrier(sc->sc_regt, sc->sc_regh, index, 4, - BUS_SPACE_BARRIER_WRITE); -} - -static inline void -regwb(struct machfb_softc *sc, uint32_t index, uint8_t data) -{ - - bus_space_write_1(sc->sc_regt, sc->sc_regh, index, data); - bus_space_barrier(sc->sc_regt, sc->sc_regh, index, 1, - BUS_SPACE_BARRIER_WRITE); -} - -static inline void -regwb_pll(struct machfb_softc *sc, uint32_t index, uint8_t data) -{ - - regwb(sc, CLOCK_CNTL + 1, (index << 2) | PLL_WR_EN); - regwb(sc, CLOCK_CNTL + 2, data); - regwb(sc, CLOCK_CNTL + 1, (index << 2) & ~PLL_WR_EN); -} - -static inline void -wait_for_fifo(struct machfb_softc *sc, uint8_t v) -{ - - while ((regr(sc, FIFO_STAT) & 0xffff) > (0x8000 >> v)) - ; -} - -static inline void -wait_for_idle(struct machfb_softc *sc) -{ - - wait_for_fifo(sc, 16); - while ((regr(sc, GUI_STAT) & 1) != 0) - ; -} - -/* - * Inline functions for setting the background and foreground colors. - */ -static inline void machfb_setbg(struct machfb_softc *sc, int bg); -static inline void machfb_setfg(struct machfb_softc *sc, int fg); - -static inline void -machfb_setbg(struct machfb_softc *sc, int bg) -{ - - if (bg == sc->sc_bg_cache) - return; - sc->sc_bg_cache = bg; - wait_for_fifo(sc, 1); - regw(sc, DP_BKGD_CLR, bg + MACHFB_CMAP_OFF); -} - -static inline void -machfb_setfg(struct machfb_softc *sc, int fg) -{ - - if (fg == sc->sc_fg_cache) - return; - sc->sc_fg_cache = fg; - wait_for_fifo(sc, 1); - regw(sc, DP_FRGD_CLR, fg + MACHFB_CMAP_OFF); -} - -/* - * video driver interface - */ -static int -machfb_configure(int flags) -{ - struct machfb_softc *sc; - phandle_t chosen, output; - ihandle_t stdout; - bus_addr_t addr; - uint32_t id; - int i, space; - - /* - * For the high-level console probing return the number of - * registered adapters. - */ - if (!(flags & VIO_PROBE_ONLY)) { - for (i = 0; vid_find_adapter(MACHFB_DRIVER_NAME, i) >= 0; i++) - ; - return (i); - } - - /* Low-level console probing and initialization. */ - - sc = &machfb_softc; - if (sc->sc_va.va_flags & V_ADP_REGISTERED) - goto found; - - if ((chosen = OF_finddevice("/chosen")) == -1) /* Quis contra nos? */ - return (0); - if (OF_getprop(chosen, "stdout", &stdout, sizeof(stdout)) == -1) - return (0); - if ((output = OF_instance_to_package(stdout)) == -1) - return (0); - if ((OF_getprop(output, "vendor-id", &id, sizeof(id)) == -1) || - id != ATI_VENDOR) - return (0); - if (OF_getprop(output, "device-id", &id, sizeof(id)) == -1) - return (0); - for (i = 0; i < nitems(machfb_info); i++) { - if (id == machfb_info[i].chip_id) { - sc->sc_flags = MACHFB_CONSOLE; - sc->sc_node = output; - sc->sc_chip_id = id; - break; - } - } - if (!(sc->sc_flags & MACHFB_CONSOLE)) - return (0); - - if (OF_getprop(output, "revision-id", &sc->sc_chip_rev, - sizeof(sc->sc_chip_rev)) == -1) - return (0); - if (OF_decode_addr(output, 0, &space, &addr) != 0) - return (0); - sc->sc_memt = &machfb_bst_store[0]; - sc->sc_memh = sparc64_fake_bustag(space, addr, sc->sc_memt); - sc->sc_regt = sc->sc_memt; - bus_space_subregion(sc->sc_regt, sc->sc_memh, MACH64_REG_OFF, - MACH64_REG_SIZE, &sc->sc_regh); - - if (machfb_init(0, &sc->sc_va, 0) < 0) - return (0); - - found: - /* Return number of found adapters. */ - return (1); -} - -static int -machfb_probe(int unit, video_adapter_t **adpp, void *arg, int flags) -{ - - return (0); -} - -static int -machfb_init(int unit, video_adapter_t *adp, int flags) -{ - struct machfb_softc *sc; - phandle_t options; - video_info_t *vi; - char buf[32]; - int i; - uint8_t dac_mask, dac_rindex, dac_windex; - - sc = (struct machfb_softc *)adp; - vi = &adp->va_info; - - if ((regr(sc, CONFIG_CHIP_ID) & 0xffff) != sc->sc_chip_id) - return (ENXIO); - - sc->sc_ramdac_freq = 0; - for (i = 0; i < nitems(machfb_info); i++) { - if (sc->sc_chip_id == machfb_info[i].chip_id) { - sc->sc_ramdac_freq = machfb_info[i].ramdac_freq; - break; - } - } - if (sc->sc_ramdac_freq == 0) - return (ENXIO); - if (sc->sc_chip_id == ATI_RAGE_II && sc->sc_chip_rev & 0x07) - sc->sc_ramdac_freq = 170000; - - vid_init_struct(adp, MACHFB_DRIVER_NAME, -1, unit); - - if (OF_getprop(sc->sc_node, "height", &sc->sc_height, - sizeof(sc->sc_height)) == -1) - return (ENXIO); - if (OF_getprop(sc->sc_node, "width", &sc->sc_width, - sizeof(sc->sc_width)) == -1) - return (ENXIO); - if (OF_getprop(sc->sc_node, "depth", &sc->sc_depth, - sizeof(sc->sc_depth)) == -1) - return (ENXIO); - if ((options = OF_finddevice("/options")) == -1) - return (ENXIO); - if (OF_getprop(options, "screen-#rows", buf, sizeof(buf)) == -1) - return (ENXIO); - vi->vi_height = strtol(buf, NULL, 10); - if (OF_getprop(options, "screen-#columns", buf, sizeof(buf)) == -1) - return (ENXIO); - vi->vi_width = strtol(buf, NULL, 10); - vi->vi_cwidth = gallant12x22.width; - vi->vi_cheight = gallant12x22.height; - vi->vi_flags = V_INFO_COLOR; - vi->vi_mem_model = V_INFO_MM_OTHER; - - sc->sc_font = gallant12x22.data; - sc->sc_cbwidth = howmany(vi->vi_cwidth, NBBY); /* width in bytes */ - sc->sc_xmargin = (sc->sc_width - (vi->vi_width * vi->vi_cwidth)) / 2; - sc->sc_ymargin = (sc->sc_height - (vi->vi_height * vi->vi_cheight)) / 2; - - if (sc->sc_chip_id != ATI_MACH64_CT && - !((sc->sc_chip_id == ATI_MACH64_VT || - sc->sc_chip_id == ATI_RAGE_II) && - (sc->sc_chip_rev & 0x07) == 0)) - sc->sc_flags |= MACHFB_DSP; - - sc->sc_memsize = machfb_get_memsize(sc); - if (sc->sc_memsize == 8192) - /* The last page is used as register aperture. */ - sc->sc_memsize -= 4; - sc->sc_memtype = regr(sc, CONFIG_STAT0) & 0x07; - - if ((sc->sc_chip_id >= ATI_RAGE_XC_PCI66 && - sc->sc_chip_id <= ATI_RAGE_XL_PCI66) || - (sc->sc_chip_id >= ATI_RAGE_XL_PCI && - sc->sc_chip_id <= ATI_RAGE_XC_PCI)) - sc->sc_ref_freq = 29498; - else - sc->sc_ref_freq = 14318; - - regwb(sc, CLOCK_CNTL + 1, PLL_REF_DIV << 2); - sc->sc_ref_div = regrb(sc, CLOCK_CNTL + 2); - regwb(sc, CLOCK_CNTL + 1, MCLK_FB_DIV << 2); - sc->sc_mclk_fb_div = regrb(sc, CLOCK_CNTL + 2); - sc->sc_mem_freq = (2 * sc->sc_ref_freq * sc->sc_mclk_fb_div) / - (sc->sc_ref_div * 2); - sc->sc_mclk_post_div = (sc->sc_mclk_fb_div * 2 * sc->sc_ref_freq) / - (sc->sc_mem_freq * sc->sc_ref_div); - - machfb_init_engine(sc); -#if 0 - machfb_adjust_frame(0, 0); -#endif - machfb_set_mode(adp, 0); - - /* - * Install our 16-color color map. This is done only once and with - * an offset of 16 on sparc64 as there the OBP driver expects white - * to be at index 0 and black at 255 (some versions also use 1 - 8 - * for color text support or the full palette for the boot banner - * logo but no versions seems to use the ISO 6429-1983 color map). - * Otherwise the colors are inverted when back in the OFW. - */ - dac_rindex = regrb(sc, DAC_RINDEX); - dac_windex = regrb(sc, DAC_WINDEX); - dac_mask = regrb(sc, DAC_MASK); - regwb(sc, DAC_MASK, 0xff); - regwb(sc, DAC_WINDEX, MACHFB_CMAP_OFF); - for (i = 0; i < 16; i++) { - regwb(sc, DAC_DATA, machfb_default_cmap[i].red); - regwb(sc, DAC_DATA, machfb_default_cmap[i].green); - regwb(sc, DAC_DATA, machfb_default_cmap[i].blue); - } - regwb(sc, DAC_MASK, dac_mask); - regwb(sc, DAC_RINDEX, dac_rindex); - regwb(sc, DAC_WINDEX, dac_windex); - - machfb_blank_display(adp, V_DISPLAY_ON); - machfb_clear(adp); - - /* - * Setting V_ADP_MODECHANGE serves as hack so machfb_set_mode() - * (which will invalidate our caches) is called as a precaution - * when the X server shuts down. - */ - adp->va_flags |= V_ADP_COLOR | V_ADP_MODECHANGE | V_ADP_PALETTE | - V_ADP_BORDER | V_ADP_INITIALIZED; - if (vid_register(adp) < 0) - return (ENXIO); - adp->va_flags |= V_ADP_REGISTERED; - - return (0); -} - -static int -machfb_get_info(video_adapter_t *adp, int mode, video_info_t *info) -{ - - bcopy(&adp->va_info, info, sizeof(*info)); - - return (0); -} - -static int -machfb_query_mode(video_adapter_t *adp, video_info_t *info) -{ - - return (ENODEV); -} - -static int -machfb_set_mode(video_adapter_t *adp, int mode) -{ - struct machfb_softc *sc; - - sc = (struct machfb_softc *)adp; - - sc->sc_bg_cache = -1; - sc->sc_fg_cache = -1; - sc->sc_draw_cache = 0; - - return (0); -} - -static int -machfb_save_font(video_adapter_t *adp, int page, int size, int width, - u_char *data, int c, int count) -{ - - return (ENODEV); -} - -static int -machfb_load_font(video_adapter_t *adp, int page, int size, int width, - u_char *data, int c, int count) -{ - - return (ENODEV); -} - -static int -machfb_show_font(video_adapter_t *adp, int page) -{ - - return (ENODEV); -} - -static int -machfb_save_palette(video_adapter_t *adp, u_char *palette) -{ - struct machfb_softc *sc; - int i; - uint8_t dac_mask, dac_rindex, dac_windex; - - sc = (struct machfb_softc *)adp; - - dac_rindex = regrb(sc, DAC_RINDEX); - dac_windex = regrb(sc, DAC_WINDEX); - dac_mask = regrb(sc, DAC_MASK); - regwb(sc, DAC_MASK, 0xff); - regwb(sc, DAC_RINDEX, 0x0); - for (i = 0; i < 256 * 3; i++) - palette[i] = regrb(sc, DAC_DATA); - regwb(sc, DAC_MASK, dac_mask); - regwb(sc, DAC_RINDEX, dac_rindex); - regwb(sc, DAC_WINDEX, dac_windex); - - return (0); -} - -static int -machfb_load_palette(video_adapter_t *adp, u_char *palette) -{ - struct machfb_softc *sc; - int i; - uint8_t dac_mask, dac_rindex, dac_windex; - - sc = (struct machfb_softc *)adp; - - dac_rindex = regrb(sc, DAC_RINDEX); - dac_windex = regrb(sc, DAC_WINDEX); - dac_mask = regrb(sc, DAC_MASK); - regwb(sc, DAC_MASK, 0xff); - regwb(sc, DAC_WINDEX, 0x0); - for (i = 0; i < 256 * 3; i++) - regwb(sc, DAC_DATA, palette[i]); - regwb(sc, DAC_MASK, dac_mask); - regwb(sc, DAC_RINDEX, dac_rindex); - regwb(sc, DAC_WINDEX, dac_windex); - - return (0); -} - -static int -machfb_set_border(video_adapter_t *adp, int border) -{ - struct machfb_softc *sc; - - sc = (struct machfb_softc *)adp; - - machfb_fill_rect(adp, border, 0, 0, sc->sc_width, sc->sc_ymargin); - machfb_fill_rect(adp, border, 0, sc->sc_height - sc->sc_ymargin, - sc->sc_width, sc->sc_ymargin); - machfb_fill_rect(adp, border, 0, 0, sc->sc_xmargin, sc->sc_height); - machfb_fill_rect(adp, border, sc->sc_width - sc->sc_xmargin, 0, - sc->sc_xmargin, sc->sc_height); - - return (0); -} - -static int -machfb_save_state(video_adapter_t *adp, void *p, size_t size) -{ - - return (ENODEV); -} - -static int -machfb_load_state(video_adapter_t *adp, void *p) -{ - - return (ENODEV); -} - -static int -machfb_set_win_org(video_adapter_t *adp, off_t offset) -{ - - return (ENODEV); -} - -static int -machfb_read_hw_cursor(video_adapter_t *adp, int *col, int *row) -{ - - *col = 0; - *row = 0; - - return (0); -} - -static int -machfb_set_hw_cursor(video_adapter_t *adp, int col, int row) -{ - - return (ENODEV); -} - -static int -machfb_set_hw_cursor_shape(video_adapter_t *adp, int base, int height, - int celsize, int blink) -{ - - return (ENODEV); -} - -static int -machfb_blank_display(video_adapter_t *adp, int mode) -{ - struct machfb_softc *sc; - uint32_t crtc_gen_cntl; - - sc = (struct machfb_softc *)adp; - - crtc_gen_cntl = (regr(sc, CRTC_GEN_CNTL) | CRTC_EXT_DISP_EN | CRTC_EN) & - ~(CRTC_HSYNC_DIS | CRTC_VSYNC_DIS | CRTC_DISPLAY_DIS); - switch (mode) { - case V_DISPLAY_ON: - break; - case V_DISPLAY_BLANK: - crtc_gen_cntl |= CRTC_HSYNC_DIS | CRTC_VSYNC_DIS | - CRTC_DISPLAY_DIS; - break; - case V_DISPLAY_STAND_BY: - crtc_gen_cntl |= CRTC_HSYNC_DIS | CRTC_DISPLAY_DIS; - break; - case V_DISPLAY_SUSPEND: - crtc_gen_cntl |= CRTC_VSYNC_DIS | CRTC_DISPLAY_DIS; - break; - } - regw(sc, CRTC_GEN_CNTL, crtc_gen_cntl); - - return (0); -} - -static int -machfb_mmap(video_adapter_t *adp, vm_ooffset_t offset, vm_paddr_t *paddr, - int prot, vm_memattr_t *memattr) -{ - struct machfb_softc *sc; - video_info_t *vi; - - sc = (struct machfb_softc *)adp; - vi = &adp->va_info; - - /* BAR 2 - VGA memory */ - if (sc->sc_vmem != 0 && offset >= sc->sc_vmem && - offset < sc->sc_vmem + vi->vi_registers_size) { - *paddr = vi->vi_registers + offset - sc->sc_vmem; - return (0); - } - - /* BAR 0 - framebuffer */ - if (offset >= sc->sc_mem && - offset < sc->sc_mem + vi->vi_buffer_size) { - *paddr = vi->vi_buffer + offset - sc->sc_mem; - return (0); - } - - /* 'regular' framebuffer mmap()ing */ - if (offset < adp->va_window_size) { - *paddr = vi->vi_window + offset; - return (0); - } - - return (EINVAL); -} - -static int -machfb_ioctl(video_adapter_t *adp, u_long cmd, caddr_t data) -{ - struct machfb_softc *sc; - struct fbcursor *fbc; - struct fbtype *fb; - - sc = (struct machfb_softc *)adp; - - switch (cmd) { - case FBIOGTYPE: - fb = (struct fbtype *)data; - fb->fb_type = FBTYPE_PCIMISC; - fb->fb_height = sc->sc_height; - fb->fb_width = sc->sc_width; - fb->fb_depth = sc->sc_depth; - if (sc->sc_depth <= 1 || sc->sc_depth > 8) - fb->fb_cmsize = 0; - else - fb->fb_cmsize = 1 << sc->sc_depth; - fb->fb_size = adp->va_buffer_size; - break; - case FBIOSCURSOR: - fbc = (struct fbcursor *)data; - if (fbc->set & FB_CUR_SETCUR && fbc->enable == 0) { - machfb_cursor_enable(sc, 0); - sc->sc_flags &= ~MACHFB_CUREN; - } else - return (ENODEV); - break; - default: - return (fb_commonioctl(adp, cmd, data)); - } - - return (0); -} - -static int -machfb_clear(video_adapter_t *adp) -{ - struct machfb_softc *sc; - - sc = (struct machfb_softc *)adp; - - machfb_fill_rect(adp, (SC_NORM_ATTR >> 4) & 0xf, 0, 0, sc->sc_width, - sc->sc_height); - - return (0); -} - -static int -machfb_fill_rect(video_adapter_t *adp, int val, int x, int y, int cx, int cy) -{ - struct machfb_softc *sc; - - sc = (struct machfb_softc *)adp; - - if (sc->sc_draw_cache != MACHFB_DRAW_FILLRECT) { - wait_for_fifo(sc, 7); - regw(sc, DP_WRITE_MASK, 0xff); - regw(sc, DP_PIX_WIDTH, DST_8BPP | SRC_8BPP | HOST_8BPP); - regw(sc, DP_SRC, FRGD_SRC_FRGD_CLR); - regw(sc, DP_MIX, MIX_SRC << 16); - regw(sc, CLR_CMP_CNTL, 0); /* no transparency */ - regw(sc, SRC_CNTL, SRC_LINE_X_LEFT_TO_RIGHT); - regw(sc, DST_CNTL, DST_X_LEFT_TO_RIGHT | DST_Y_TOP_TO_BOTTOM); - sc->sc_draw_cache = MACHFB_DRAW_FILLRECT; - } - machfb_setfg(sc, val); - wait_for_fifo(sc, 4); - regw(sc, SRC_Y_X, (x << 16) | y); - regw(sc, SRC_WIDTH1, cx); - regw(sc, DST_Y_X, (x << 16) | y); - regw(sc, DST_HEIGHT_WIDTH, (cx << 16) | cy); - - return (0); -} - -static int -machfb_bitblt(video_adapter_t *adp, ...) -{ - - return (ENODEV); -} - -static int -machfb_diag(video_adapter_t *adp, int level) -{ - video_info_t info; - - fb_dump_adp_info(adp->va_name, adp, level); - machfb_get_info(adp, 0, &info); - fb_dump_mode_info(adp->va_name, adp, &info, level); - - return (0); -} - -static int -machfb_save_cursor_palette(video_adapter_t *adp, u_char *palette) -{ - - return (ENODEV); -} - -static int -machfb_load_cursor_palette(video_adapter_t *adp, u_char *palette) -{ - - return (ENODEV); -} - -static int -machfb_copy(video_adapter_t *adp, vm_offset_t src, vm_offset_t dst, int n) -{ - - return (ENODEV); -} - -static int -machfb_putp(video_adapter_t *adp, vm_offset_t off, uint32_t p, uint32_t a, - int size, int bpp, int bit_ltor, int byte_ltor) -{ - - return (ENODEV); -} - -static int -machfb_putc(video_adapter_t *adp, vm_offset_t off, uint8_t c, uint8_t a) -{ - struct machfb_softc *sc; - const uint8_t *p; - int i; - - sc = (struct machfb_softc *)adp; - - if (sc->sc_draw_cache != MACHFB_DRAW_CHAR) { - wait_for_fifo(sc, 8); - regw(sc, DP_WRITE_MASK, 0xff); /* XXX only good for 8 bit */ - regw(sc, DP_PIX_WIDTH, DST_8BPP | SRC_1BPP | HOST_1BPP); - regw(sc, DP_SRC, MONO_SRC_HOST | BKGD_SRC_BKGD_CLR | - FRGD_SRC_FRGD_CLR); - regw(sc, DP_MIX ,((MIX_SRC & 0xffff) << 16) | MIX_SRC); - regw(sc, CLR_CMP_CNTL, 0); /* no transparency */ - regw(sc, SRC_CNTL, SRC_LINE_X_LEFT_TO_RIGHT); - regw(sc, DST_CNTL, DST_Y_TOP_TO_BOTTOM | DST_X_LEFT_TO_RIGHT); - regw(sc, HOST_CNTL, HOST_BYTE_ALIGN); - sc->sc_draw_cache = MACHFB_DRAW_CHAR; - } - machfb_setbg(sc, (a >> 4) & 0xf); - machfb_setfg(sc, a & 0xf); - wait_for_fifo(sc, 4 + (adp->va_info.vi_cheight / sc->sc_cbwidth)); - regw(sc, SRC_Y_X, 0); - regw(sc, SRC_WIDTH1, adp->va_info.vi_cwidth); - regw(sc, DST_Y_X, ((((off % adp->va_info.vi_width) * - adp->va_info.vi_cwidth) + sc->sc_xmargin) << 16) | - (((off / adp->va_info.vi_width) * adp->va_info.vi_cheight) + - sc->sc_ymargin)); - regw(sc, DST_HEIGHT_WIDTH, (adp->va_info.vi_cwidth << 16) | - adp->va_info.vi_cheight); - p = sc->sc_font + (c * adp->va_info.vi_cheight * sc->sc_cbwidth); - for (i = 0; i < adp->va_info.vi_cheight * sc->sc_cbwidth; i += 4) - regw(sc, HOST_DATA0 + i, (p[i + 3] << 24 | p[i + 2] << 16 | - p[i + 1] << 8 | p[i])); - - return (0); -} - -static int -machfb_puts(video_adapter_t *adp, vm_offset_t off, uint16_t *s, int len) -{ - struct machfb_softc *sc; - int blanks, i, x1, x2, y1, y2; - uint8_t a, c, color1, color2; - - sc = (struct machfb_softc *)adp; - -#define MACHFB_BLANK machfb_fill_rect(adp, color1, x1, y1, \ - blanks * adp->va_info.vi_cwidth, \ - adp->va_info.vi_cheight) - - blanks = color1 = x1 = y1 = 0; - for (i = 0; i < len; i++) { - /* - * Accelerate continuous blanks by drawing a respective - * rectangle instead. Drawing a rectangle of any size - * takes about the same number of operations as drawing - * a single character. - */ - c = s[i] & 0xff; - a = (s[i] & 0xff00) >> 8; - if (c == 0x00 || c == 0x20 || c == 0xdb || c == 0xff) { - color2 = (a >> (c == 0xdb ? 0 : 4) & 0xf); - x2 = (((off + i) % adp->va_info.vi_width) * - adp->va_info.vi_cwidth) + sc->sc_xmargin; - y2 = (((off + i) / adp->va_info.vi_width) * - adp->va_info.vi_cheight) + sc->sc_ymargin; - if (blanks == 0) { - color1 = color2; - x1 = x2; - y1 = y2; - blanks++; - } else if (color1 != color2 || y1 != y2) { - MACHFB_BLANK; - color1 = color2; - x1 = x2; - y1 = y2; - blanks = 1; - } else - blanks++; - } else { - if (blanks != 0) { - MACHFB_BLANK; - blanks = 0; - } - vidd_putc(adp, off + i, c, a); - } - } - if (blanks != 0) - MACHFB_BLANK; - -#undef MACHFB_BLANK - - return (0); -} - -static int -machfb_putm(video_adapter_t *adp, int x, int y, uint8_t *pixel_image, - uint32_t pixel_mask, int size, int width) -{ - struct machfb_softc *sc; - int error; - - sc = (struct machfb_softc *)adp; - - if ((!(sc->sc_flags & MACHFB_CUREN)) && - (error = machfb_cursor_install(sc)) < 0) - return (error); - else { - /* - * The hardware cursor always must be disabled when - * fiddling with its bits otherwise some artifacts - * may appear on the screen. - */ - machfb_cursor_enable(sc, 0); - } - - regw(sc, CUR_HORZ_VERT_OFF, 0); - if ((regr(sc, GEN_TEST_CNTL) & CRTC_DBL_SCAN_EN) != 0) - y <<= 1; - regw(sc, CUR_HORZ_VERT_POSN, ((y + sc->sc_ymargin) << 16) | - (x + sc->sc_xmargin)); - machfb_cursor_enable(sc, 1); - sc->sc_flags |= MACHFB_CUREN; - - return (0); -} - -/* - * PCI bus interface - */ -static int -machfb_pci_probe(device_t dev) -{ - int i; - - if (pci_get_class(dev) != PCIC_DISPLAY || - pci_get_subclass(dev) != PCIS_DISPLAY_VGA) - return (ENXIO); - - for (i = 0; i < nitems(machfb_info); i++) { - if (pci_get_device(dev) == machfb_info[i].chip_id) { - device_set_desc(dev, machfb_info[i].name); - return (BUS_PROBE_DEFAULT); - } - } - - return (ENXIO); -} - -static int -machfb_pci_attach(device_t dev) -{ - struct machfb_softc *sc; - video_adapter_t *adp; - video_switch_t *sw; - video_info_t *vi; - phandle_t node; - int error, i, rid; - uint32_t *p32, u32; - uint8_t *p; - - node = ofw_bus_get_node(dev); - if ((sc = (struct machfb_softc *)vid_get_adapter(vid_find_adapter( - MACHFB_DRIVER_NAME, 0))) != NULL && sc->sc_node == node) { - device_printf(dev, "console\n"); - device_set_softc(dev, sc); - } else { - sc = device_get_softc(dev); - - sc->sc_node = node; - sc->sc_chip_id = pci_get_device(dev); - sc->sc_chip_rev = pci_get_revid(dev); - } - adp = &sc->sc_va; - vi = &adp->va_info; - - rid = PCIR_BAR(0); - if ((sc->sc_memres = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid, - RF_ACTIVE)) == NULL) { - device_printf(dev, "cannot allocate memory resources\n"); - return (ENXIO); - } - sc->sc_memt = rman_get_bustag(sc->sc_memres); - sc->sc_memh = rman_get_bushandle(sc->sc_memres); - sc->sc_mem = rman_get_start(sc->sc_memres); - vi->vi_buffer = sc->sc_memh; - vi->vi_buffer_size = rman_get_size(sc->sc_memres); - if (OF_getprop(sc->sc_node, "address", &u32, sizeof(u32)) > 0 && - vtophys(u32) == sc->sc_memh) - adp->va_mem_base = u32; - else { - if (bus_space_map(sc->sc_memt, vi->vi_buffer, - vi->vi_buffer_size, BUS_SPACE_MAP_LINEAR, - &sc->sc_memh) != 0) { - device_printf(dev, "cannot map memory resources\n"); - error = ENXIO; - goto fail_memres; - } - adp->va_mem_base = - (vm_offset_t)rman_get_virtual(sc->sc_memres); - } - adp->va_mem_size = vi->vi_buffer_size; - adp->va_buffer = adp->va_mem_base; - adp->va_buffer_size = adp->va_mem_size; - sc->sc_regt = sc->sc_memt; - if (bus_space_subregion(sc->sc_regt, sc->sc_memh, MACH64_REG_OFF, - MACH64_REG_SIZE, &sc->sc_regh) != 0) { - device_printf(dev, "cannot allocate register resources\n"); - error = ENXIO; - goto fail_memmap; - } - - /* - * Depending on the firmware version the VGA I/O and/or memory - * resources of the Mach64 chips come up disabled. These will be - * enabled by pci(4) when activating the resource in question but - * this doesn't necessarily mean that the resource is valid. - * Invalid resources seem to have in common that they start at - * address 0. We don't allocate the VGA memory in this case in - * order to avoid warnings in apb(4) and crashes when using this - * invalid resources. X.Org is aware of this and doesn't use the - * VGA memory resource in this case (but demands it if it's valid). - */ - rid = PCIR_BAR(2); - if (bus_get_resource_start(dev, SYS_RES_MEMORY, rid) != 0) { - if ((sc->sc_vmemres = bus_alloc_resource_any(dev, - SYS_RES_MEMORY, &rid, RF_ACTIVE)) == NULL) { - device_printf(dev, - "cannot allocate VGA memory resources\n"); - error = ENXIO; - goto fail_memmap; - } - sc->sc_vmemt = rman_get_bustag(sc->sc_vmemres); - sc->sc_vmemh = rman_get_bushandle(sc->sc_vmemres); - sc->sc_vmem = rman_get_start(sc->sc_vmemres); - vi->vi_registers = sc->sc_vmemh; - vi->vi_registers_size = rman_get_size(sc->sc_vmemres); - if (bus_space_map(sc->sc_vmemt, vi->vi_registers, - vi->vi_registers_size, BUS_SPACE_MAP_LINEAR, - &sc->sc_vmemh) != 0) { - device_printf(dev, - "cannot map VGA memory resources\n"); - error = ENXIO; - goto fail_vmemres; - } - adp->va_registers = - (vm_offset_t)rman_get_virtual(sc->sc_vmemres); - adp->va_registers_size = vi->vi_registers_size; - } - - if (!(sc->sc_flags & MACHFB_CONSOLE)) { - if ((sw = vid_get_switch(MACHFB_DRIVER_NAME)) == NULL) { - device_printf(dev, "cannot get video switch\n"); - error = ENODEV; - goto fail_vmemmap; - } - /* - * During device configuration we don't necessarily probe - * the adapter which is the console first so we can't use - * the device unit number for the video adapter unit. The - * worst case would be that we use the video adapter unit - * 0 twice. As it doesn't really matter which unit number - * the corresponding video adapter has just use the next - * unused one. - */ - for (i = 0; i < devclass_get_maxunit(machfb_devclass); i++) - if (vid_find_adapter(MACHFB_DRIVER_NAME, i) < 0) - break; - if ((error = sw->init(i, adp, 0)) != 0) { - device_printf(dev, "cannot initialize adapter\n"); - goto fail_vmemmap; - } - } - - /* - * Test whether the aperture is byte swapped or not, set - * va_window and va_window_size as appropriate. Note that - * the aperture could be mapped either big or little endian - * independently of the endianness of the host so this has - * to be a runtime test. - */ - p32 = (uint32_t *)adp->va_buffer; - u32 = *p32; - p = (uint8_t *)adp->va_buffer; - *p32 = 0x12345678; - if (!(p[0] == 0x12 && p[1] == 0x34 && p[2] == 0x56 && p[3] == 0x78)) { - adp->va_window = adp->va_buffer + 0x800000; - adp->va_window_size = adp->va_buffer_size - 0x800000; - vi->vi_window = vi->vi_buffer + 0x800000; - vi->vi_window_size = vi->vi_buffer_size - 0x800000; - sc->sc_flags |= MACHFB_SWAP; - } else { - adp->va_window = adp->va_buffer; - adp->va_window_size = adp->va_buffer_size; - vi->vi_window = vi->vi_buffer; - vi->vi_window_size = vi->vi_buffer_size; - } - *p32 = u32; - adp->va_window_gran = adp->va_window_size; - - device_printf(dev, - "%d MB aperture at %p %sswapped\n", - (u_int)(adp->va_window_size / (1024 * 1024)), - (void *)adp->va_window, (sc->sc_flags & MACHFB_SWAP) ? - "" : "not "); - device_printf(dev, - "%ld KB %s %d.%d MHz, maximum RAMDAC clock %d MHz, %sDSP\n", - (u_long)sc->sc_memsize, machfb_memtype_names[sc->sc_memtype], - sc->sc_mem_freq / 1000, sc->sc_mem_freq % 1000, - sc->sc_ramdac_freq / 1000, - (sc->sc_flags & MACHFB_DSP) ? "" : "no "); - device_printf(dev, "resolution %dx%d at %d bpp\n", - sc->sc_width, sc->sc_height, sc->sc_depth); - - /* - * Allocate one page for the mouse pointer image at the end of - * the little endian aperture, right before the memory mapped - * registers that might also reside there. Must be done after - * sc_memsize was set and possibly adjusted to account for the - * memory mapped registers. - */ - sc->sc_curoff = (sc->sc_memsize * 1024) - PAGE_SIZE; - sc->sc_memsize -= PAGE_SIZE / 1024; - machfb_cursor_enable(sc, 0); - /* Initialize with an all transparent image. */ - memset((void *)(adp->va_buffer + sc->sc_curoff), 0xaa, PAGE_SIZE); - - /* - * Register a handler that performs some cosmetic surgery like - * turning off the mouse pointer on halt in preparation for - * handing the screen over to the OFW. Register another handler - * that turns off the CRTC when resetting, otherwise the OFW - * boot command issued by cpu_reset() just doesn't work. - */ - EVENTHANDLER_REGISTER(shutdown_final, machfb_shutdown_final, sc, - SHUTDOWN_PRI_DEFAULT); - EVENTHANDLER_REGISTER(shutdown_reset, machfb_shutdown_reset, sc, - SHUTDOWN_PRI_DEFAULT); - - return (0); - - fail_vmemmap: - if (adp->va_registers != 0) - bus_space_unmap(sc->sc_vmemt, sc->sc_vmemh, - vi->vi_registers_size); - fail_vmemres: - if (sc->sc_vmemres != NULL) - bus_release_resource(dev, SYS_RES_MEMORY, - rman_get_rid(sc->sc_vmemres), sc->sc_vmemres); - fail_memmap: - bus_space_unmap(sc->sc_memt, sc->sc_memh, vi->vi_buffer_size); - fail_memres: - bus_release_resource(dev, SYS_RES_MEMORY, - rman_get_rid(sc->sc_memres), sc->sc_memres); - - return (error); -} - -static int -machfb_pci_detach(device_t dev) -{ - - return (EINVAL); -} - -/* - * internal functions - */ -static void -machfb_cursor_enable(struct machfb_softc *sc, int onoff) -{ - - if (onoff) - regw(sc, GEN_TEST_CNTL, - regr(sc, GEN_TEST_CNTL) | HWCURSOR_ENABLE); - else - regw(sc, GEN_TEST_CNTL, - regr(sc, GEN_TEST_CNTL) &~ HWCURSOR_ENABLE); -} - -static int -machfb_cursor_install(struct machfb_softc *sc) -{ - uint16_t *p, v; - uint8_t fg; - int i, j; - - if (sc->sc_curoff == 0) - return (ENODEV); - - machfb_cursor_enable(sc, 0); - regw(sc, CUR_OFFSET, sc->sc_curoff >> 3); - fg = SC_NORM_ATTR & 0xf; - regw(sc, CUR_CLR0, machfb_default_cmap[fg].red << 24 | - machfb_default_cmap[fg].green << 16 | - machfb_default_cmap[fg].blue << 8); - p = (uint16_t *)(sc->sc_va.va_buffer + sc->sc_curoff); - for (i = 0; i < 64; i++) { - for (j = 0; j < 8; j++) { - v = machfb_mouse_pointer_lut[ - machfb_mouse_pointer_bits[i][j] >> 4] << 8 | - machfb_mouse_pointer_lut[ - machfb_mouse_pointer_bits[i][j] & 0x0f]; - if (sc->sc_flags & MACHFB_SWAP) - *(p++) = bswap16(v); - else - *(p++) = v; - } - } - - return (0); -} - -static int -machfb_get_memsize(struct machfb_softc *sc) -{ - int tmp, memsize; - const int mem_tab[] = { - 512, 1024, 2048, 4096, 6144, 8192, 12288, 16384 - }; - - tmp = regr(sc, MEM_CNTL); -#ifdef MACHFB_DEBUG - printf("memcntl=0x%08x\n", tmp); -#endif - if (sc->sc_flags & MACHFB_DSP) { - tmp &= 0x0000000f; - if (tmp < 8) - memsize = (tmp + 1) * 512; - else if (tmp < 12) - memsize = (tmp - 3) * 1024; - else - memsize = (tmp - 7) * 2048; - } else - memsize = mem_tab[tmp & 0x07]; - - return (memsize); -} - -static void -machfb_reset_engine(struct machfb_softc *sc) -{ - - /* Reset engine.*/ - regw(sc, GEN_TEST_CNTL, regr(sc, GEN_TEST_CNTL) & ~GUI_ENGINE_ENABLE); - - /* Enable engine. */ - regw(sc, GEN_TEST_CNTL, regr(sc, GEN_TEST_CNTL) | GUI_ENGINE_ENABLE); - - /* - * Ensure engine is not locked up by clearing any FIFO or - * host errors. - */ - regw(sc, BUS_CNTL, regr(sc, BUS_CNTL) | BUS_HOST_ERR_ACK | - BUS_FIFO_ERR_ACK); -} - -static void -machfb_init_engine(struct machfb_softc *sc) -{ - uint32_t pitch_value; - - pitch_value = sc->sc_width; - - if (sc->sc_depth == 24) - pitch_value *= 3; - - machfb_reset_engine(sc); - - wait_for_fifo(sc, 14); - - regw(sc, CONTEXT_MASK, 0xffffffff); - - regw(sc, DST_OFF_PITCH, (pitch_value / 8) << 22); - - regw(sc, DST_Y_X, 0); - regw(sc, DST_HEIGHT, 0); - regw(sc, DST_BRES_ERR, 0); - regw(sc, DST_BRES_INC, 0); - regw(sc, DST_BRES_DEC, 0); - - regw(sc, DST_CNTL, DST_LAST_PEL | DST_X_LEFT_TO_RIGHT | - DST_Y_TOP_TO_BOTTOM); - - regw(sc, SRC_OFF_PITCH, (pitch_value / 8) << 22); - - regw(sc, SRC_Y_X, 0); - regw(sc, SRC_HEIGHT1_WIDTH1, 1); - regw(sc, SRC_Y_X_START, 0); - regw(sc, SRC_HEIGHT2_WIDTH2, 1); - - regw(sc, SRC_CNTL, SRC_LINE_X_LEFT_TO_RIGHT); - - wait_for_fifo(sc, 13); - regw(sc, HOST_CNTL, 0); - - regw(sc, PAT_REG0, 0); - regw(sc, PAT_REG1, 0); - regw(sc, PAT_CNTL, 0); - - regw(sc, SC_LEFT, 0); - regw(sc, SC_TOP, 0); - regw(sc, SC_BOTTOM, sc->sc_height - 1); - regw(sc, SC_RIGHT, pitch_value - 1); - - regw(sc, DP_BKGD_CLR, 0); - regw(sc, DP_FRGD_CLR, 0xffffffff); - regw(sc, DP_WRITE_MASK, 0xffffffff); - regw(sc, DP_MIX, (MIX_SRC << 16) | MIX_DST); - - regw(sc, DP_SRC, FRGD_SRC_FRGD_CLR); - - wait_for_fifo(sc, 3); - regw(sc, CLR_CMP_CLR, 0); - regw(sc, CLR_CMP_MASK, 0xffffffff); - regw(sc, CLR_CMP_CNTL, 0); - - wait_for_fifo(sc, 2); - switch (sc->sc_depth) { - case 8: - regw(sc, DP_PIX_WIDTH, HOST_8BPP | SRC_8BPP | DST_8BPP); - regw(sc, DP_CHAIN_MASK, DP_CHAIN_8BPP); - regw(sc, DAC_CNTL, regr(sc, DAC_CNTL) | DAC_8BIT_EN); - break; -#if 0 - case 32: - regw(sc, DP_PIX_WIDTH, HOST_32BPP | SRC_32BPP | DST_32BPP); - regw(sc, DP_CHAIN_MASK, DP_CHAIN_32BPP); - regw(sc, DAC_CNTL, regr(sc, DAC_CNTL) | DAC_8BIT_EN); - break; -#endif - } - - wait_for_fifo(sc, 2); - regw(sc, CRTC_INT_CNTL, regr(sc, CRTC_INT_CNTL) & ~0x20); - regw(sc, GUI_TRAJ_CNTL, DST_X_LEFT_TO_RIGHT | DST_Y_TOP_TO_BOTTOM); - - wait_for_idle(sc); -} - -#if 0 -static void -machfb_adjust_frame(struct machfb_softc *sc, int x, int y) -{ - int offset; - - offset = ((x + y * sc->sc_width) * (sc->sc_depth >> 3)) >> 3; - - regw(sc, CRTC_OFF_PITCH, (regr(sc, CRTC_OFF_PITCH) & 0xfff00000) | - offset); -} -#endif - -static void -machfb_shutdown_final(void *v) -{ - struct machfb_softc *sc = v; - - machfb_cursor_enable(sc, 0); - /* - * In case this is the console set the cursor of the stdout - * instance to the start of the last line so OFW output ends - * up beneath what FreeBSD left on the screen. - */ - if (sc->sc_flags & MACHFB_CONSOLE) { - OF_interpret("stdout @ is my-self 0 to column#", 0); - OF_interpret("stdout @ is my-self #lines 1 - to line#", 0); - } -} - -static void -machfb_shutdown_reset(void *v) -{ - struct machfb_softc *sc = v; - - machfb_blank_display(&sc->sc_va, V_DISPLAY_STAND_BY); -} diff --git a/sys/dev/fb/machfbreg.h b/sys/dev/fb/machfbreg.h deleted file mode 100644 index 8990a4e3993a..000000000000 --- a/sys/dev/fb/machfbreg.h +++ /dev/null @@ -1,458 +0,0 @@ -/*- - * Copyright 1992,1993,1994,1995,1996,1997 by Kevin E. Martin, Chapel Hill, North Carolina. - * - * Permission to use, copy, modify, distribute, and sell this software and - * its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and that - * both that copyright notice and this permission notice appear in - * supporting documentation, and that the name of Kevin E. Martin not be - * used in advertising or publicity pertaining to distribution of the - * software without specific, written prior permission. Kevin E. Martin - * makes no representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - * - * KEVIN E. MARTIN, RICKARD E. FAITH, AND TIAGO GONS DISCLAIM ALL - * WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL THE - * AUTHORS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR - * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, - * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS - * SOFTWARE. - * - * Modified for the Mach-8 by Rickard E. Faith (faith@cs.unc.edu) - * Modified for the Mach32 by Kevin E. Martin (martin@cs.unc.edu) - * Modified for the Mach64 by Kevin E. Martin (martin@cs.unc.edu) - * - * from: NetBSD: machfbreg.h,v 1.1 2002/10/24 18:15:57 junyoung Exp - * - * $FreeBSD$ - */ - -#ifndef _DEV_FB_MACHFB_H_ -#define _DEV_FB_MACHFB_H_ - -/* NON-GUI MEMORY MAPPED Registers - expressed in BYTE offsets */ - -#define CRTC_H_TOTAL_DISP 0x0000 /* Dword offset 00 */ -#define CRTC_H_SYNC_STRT_WID 0x0004 /* Dword offset 01 */ -#define CRTC_V_TOTAL_DISP 0x0008 /* Dword offset 02 */ -#define CRTC_V_SYNC_STRT_WID 0x000C /* Dword offset 03 */ -#define CRTC_VLINE_CRNT_VLINE 0x0010 /* Dword offset 04 */ -#define CRTC_OFF_PITCH 0x0014 /* Dword offset 05 */ -#define CRTC_INT_CNTL 0x0018 /* Dword offset 06 */ -#define CRTC_GEN_CNTL 0x001C /* Dword offset 07 */ - -#define DSP_CONFIG 0x0020 /* Dword offset 08 */ -#define DSP_ON_OFF 0x0024 /* Dword offset 09 */ - -#define SHARED_CNTL 0x0038 /* Dword offset 0E */ - -#define OVR_CLR 0x0040 /* Dword offset 10 */ -#define OVR_WID_LEFT_RIGHT 0x0044 /* Dword offset 11 */ -#define OVR_WID_TOP_BOTTOM 0x0048 /* Dword offset 12 */ - -#define CUR_CLR0 0x0060 /* Dword offset 18 */ -#define CUR_CLR1 0x0064 /* Dword offset 19 */ -#define CUR_OFFSET 0x0068 /* Dword offset 1A */ -#define CUR_HORZ_VERT_POSN 0x006C /* Dword offset 1B */ -#define CUR_HORZ_VERT_OFF 0x0070 /* Dword offset 1C */ - -#define HW_DEBUG 0x007C /* Dword offset 1F */ - -#define SCRATCH_REG0 0x0080 /* Dword offset 20 */ -#define SCRATCH_REG1 0x0084 /* Dword offset 21 */ - -#define CLOCK_CNTL 0x0090 /* Dword offset 24 */ - -#define BUS_CNTL 0x00A0 /* Dword offset 28 */ - -#define LCD_INDEX 0x00A4 /* Dword offset 29 (LTPro) */ -#define LCD_DATA 0x00A8 /* Dword offset 2A (LTPro) */ - -#define MEM_CNTL 0x00B0 /* Dword offset 2C */ - -#define MEM_VGA_WP_SEL 0x00B4 /* Dword offset 2D */ -#define MEM_VGA_RP_SEL 0x00B8 /* Dword offset 2E */ - -#define DAC_REGS 0x00C0 /* Dword offset 30 */ -#define DAC_WINDEX 0x00C0 /* Dword offset 30 */ -#define DAC_DATA 0x00C1 /* Dword offset 30 */ -#define DAC_MASK 0x00C2 /* Dword offset 30 */ -#define DAC_RINDEX 0x00C3 /* Dword offset 30 */ -#define DAC_CNTL 0x00C4 /* Dword offset 31 */ - -#define HORZ_STRETCHING 0x00C8 /* Dword offset 32 (LT) */ -#define VERT_STRETCHING 0x00CC /* Dword offset 33 (LT) */ - -#define GEN_TEST_CNTL 0x00D0 /* Dword offset 34 */ - -#define LCD_GEN_CNTL 0x00D4 /* Dword offset 35 (LT) */ -#define POWER_MANAGEMENT 0x00D8 /* Dword offset 36 (LT) */ - -#define CONFIG_CNTL 0x00DC /* Dword offset 37 (CT, ET, VT) */ -#define CONFIG_CHIP_ID 0x00E0 /* Dword offset 38 */ -#define CONFIG_STAT0 0x00E4 /* Dword offset 39 */ -#define CONFIG_STAT1 0x00E8 /* Dword offset 3A */ - - -/* GUI MEMORY MAPPED Registers */ - -#define DST_OFF_PITCH 0x0100 /* Dword offset 40 */ -#define DST_X 0x0104 /* Dword offset 41 */ -#define DST_Y 0x0108 /* Dword offset 42 */ -#define DST_Y_X 0x010C /* Dword offset 43 */ -#define DST_WIDTH 0x0110 /* Dword offset 44 */ -#define DST_HEIGHT 0x0114 /* Dword offset 45 */ -#define DST_HEIGHT_WIDTH 0x0118 /* Dword offset 46 */ -#define DST_X_WIDTH 0x011C /* Dword offset 47 */ -#define DST_BRES_LNTH 0x0120 /* Dword offset 48 */ -#define DST_BRES_ERR 0x0124 /* Dword offset 49 */ -#define DST_BRES_INC 0x0128 /* Dword offset 4A */ -#define DST_BRES_DEC 0x012C /* Dword offset 4B */ -#define DST_CNTL 0x0130 /* Dword offset 4C */ - -#define SRC_OFF_PITCH 0x0180 /* Dword offset 60 */ -#define SRC_X 0x0184 /* Dword offset 61 */ -#define SRC_Y 0x0188 /* Dword offset 62 */ -#define SRC_Y_X 0x018C /* Dword offset 63 */ -#define SRC_WIDTH1 0x0190 /* Dword offset 64 */ -#define SRC_HEIGHT1 0x0194 /* Dword offset 65 */ -#define SRC_HEIGHT1_WIDTH1 0x0198 /* Dword offset 66 */ -#define SRC_X_START 0x019C /* Dword offset 67 */ -#define SRC_Y_START 0x01A0 /* Dword offset 68 */ -#define SRC_Y_X_START 0x01A4 /* Dword offset 69 */ -#define SRC_WIDTH2 0x01A8 /* Dword offset 6A */ -#define SRC_HEIGHT2 0x01AC /* Dword offset 6B */ -#define SRC_HEIGHT2_WIDTH2 0x01B0 /* Dword offset 6C */ -#define SRC_CNTL 0x01B4 /* Dword offset 6D */ - -#define HOST_DATA0 0x0200 /* Dword offset 80 */ -#define HOST_DATA1 0x0204 /* Dword offset 81 */ -#define HOST_DATA2 0x0208 /* Dword offset 82 */ -#define HOST_DATA3 0x020C /* Dword offset 83 */ -#define HOST_DATA4 0x0210 /* Dword offset 84 */ -#define HOST_DATA5 0x0214 /* Dword offset 85 */ -#define HOST_DATA6 0x0218 /* Dword offset 86 */ -#define HOST_DATA7 0x021C /* Dword offset 87 */ -#define HOST_DATA8 0x0220 /* Dword offset 88 */ -#define HOST_DATA9 0x0224 /* Dword offset 89 */ -#define HOST_DATAA 0x0228 /* Dword offset 8A */ -#define HOST_DATAB 0x022C /* Dword offset 8B */ -#define HOST_DATAC 0x0230 /* Dword offset 8C */ -#define HOST_DATAD 0x0234 /* Dword offset 8D */ -#define HOST_DATAE 0x0238 /* Dword offset 8E */ -#define HOST_DATAF 0x023C /* Dword offset 8F */ -#define HOST_CNTL 0x0240 /* Dword offset 90 */ - -#define PAT_REG0 0x0280 /* Dword offset A0 */ -#define PAT_REG1 0x0284 /* Dword offset A1 */ -#define PAT_CNTL 0x0288 /* Dword offset A2 */ - -#define SC_LEFT 0x02A0 /* Dword offset A8 */ -#define SC_RIGHT 0x02A4 /* Dword offset A9 */ -#define SC_LEFT_RIGHT 0x02A8 /* Dword offset AA */ -#define SC_TOP 0x02AC /* Dword offset AB */ -#define SC_BOTTOM 0x02B0 /* Dword offset AC */ -#define SC_TOP_BOTTOM 0x02B4 /* Dword offset AD */ - -#define DP_BKGD_CLR 0x02C0 /* Dword offset B0 */ -#define DP_FRGD_CLR 0x02C4 /* Dword offset B1 */ -#define DP_WRITE_MASK 0x02C8 /* Dword offset B2 */ -#define DP_CHAIN_MASK 0x02CC /* Dword offset B3 */ -#define DP_PIX_WIDTH 0x02D0 /* Dword offset B4 */ -#define DP_MIX 0x02D4 /* Dword offset B5 */ -#define DP_SRC 0x02D8 /* Dword offset B6 */ - -#define CLR_CMP_CLR 0x0300 /* Dword offset C0 */ -#define CLR_CMP_MASK 0x0304 /* Dword offset C1 */ -#define CLR_CMP_CNTL 0x0308 /* Dword offset C2 */ - -#define FIFO_STAT 0x0310 /* Dword offset C4 */ - -#define CONTEXT_MASK 0x0320 /* Dword offset C8 */ -#define CONTEXT_LOAD_CNTL 0x032C /* Dword offset CB */ - -#define GUI_TRAJ_CNTL 0x0330 /* Dword offset CC */ -#define GUI_STAT 0x0338 /* Dword offset CE */ - - -/* CRTC control values */ - -#define CRTC_HSYNC_NEG 0x00200000 -#define CRTC_VSYNC_NEG 0x00200000 - -#define CRTC_DBL_SCAN_EN 0x00000001 -#define CRTC_INTERLACE_EN 0x00000002 -#define CRTC_HSYNC_DIS 0x00000004 -#define CRTC_VSYNC_DIS 0x00000008 -#define CRTC_CSYNC_EN 0x00000010 -#define CRTC_PIX_BY_2_EN 0x00000020 -#define CRTC_DISPLAY_DIS 0x00000040 -#define CRTC_VGA_XOVERSCAN 0x00000080 - -#define CRTC_PIX_WIDTH 0x00000700 -#define CRTC_PIX_WIDTH_4BPP 0x00000100 -#define CRTC_PIX_WIDTH_8BPP 0x00000200 -#define CRTC_PIX_WIDTH_15BPP 0x00000300 -#define CRTC_PIX_WIDTH_16BPP 0x00000400 -#define CRTC_PIX_WIDTH_24BPP 0x00000500 -#define CRTC_PIX_WIDTH_32BPP 0x00000600 - -#define CRTC_BYTE_PIX_ORDER 0x00000800 -#define CRTC_PIX_ORDER_MSN_LSN 0x00000000 -#define CRTC_PIX_ORDER_LSN_MSN 0x00000800 - -#define CRTC_FIFO_LWM 0x000f0000 -#define CRTC_LOCK_REGS 0x00400000 -#define CRTC_EXT_DISP_EN 0x01000000 -#define CRTC_EN 0x02000000 -#define CRTC_DISP_REQ_EN 0x04000000 -#define CRTC_VGA_LINEAR 0x08000000 -#define CRTC_VSYNC_FALL_EDGE 0x10000000 -#define CRTC_VGA_TEXT_132 0x20000000 -#define CRTC_CNT_EN 0x40000000 -#define CRTC_CUR_B_TEST 0x80000000 - -#define CRTC_CRNT_VLINE 0x07f00000 -#define CRTC_VBLANK 0x00000001 - -/* DAC control values */ - -#define DAC_EXT_SEL_RS2 0x01 -#define DAC_EXT_SEL_RS3 0x02 -#define DAC_8BIT_EN 0x00000100 -#define DAC_PIX_DLY_MASK 0x00000600 -#define DAC_PIX_DLY_0NS 0x00000000 -#define DAC_PIX_DLY_2NS 0x00000200 -#define DAC_PIX_DLY_4NS 0x00000400 -#define DAC_BLANK_ADJ_MASK 0x00001800 -#define DAC_BLANK_ADJ_0 0x00000000 -#define DAC_BLANK_ADJ_1 0x00000800 -#define DAC_BLANK_ADJ_2 0x00001000 - - -/* Mix control values */ - -#define MIX_NOT_DST 0x0000 -#define MIX_0 0x0001 -#define MIX_1 0x0002 -#define MIX_DST 0x0003 -#define MIX_NOT_SRC 0x0004 -#define MIX_XOR 0x0005 -#define MIX_XNOR 0x0006 -#define MIX_SRC 0x0007 -#define MIX_NAND 0x0008 -#define MIX_NOT_SRC_OR_DST 0x0009 -#define MIX_SRC_OR_NOT_DST 0x000a -#define MIX_OR 0x000b -#define MIX_AND 0x000c -#define MIX_SRC_AND_NOT_DST 0x000d -#define MIX_NOT_SRC_AND_DST 0x000e -#define MIX_NOR 0x000f - -/* Maximum engine dimensions */ -#define ENGINE_MIN_X 0 -#define ENGINE_MIN_Y 0 -#define ENGINE_MAX_X 4095 -#define ENGINE_MAX_Y 16383 - -/* Mach64 engine bit constants - these are typically ORed together */ - -/* HW_DEBUG register constants */ -/* For RagePro only... */ -#define AUTO_FF_DIS 0x000001000 -#define AUTO_BLKWRT_DIS 0x000002000 - -/* BUS_CNTL register constants */ -#define BUS_FIFO_ERR_ACK 0x00200000 -#define BUS_HOST_ERR_ACK 0x00800000 -#define BUS_APER_REG_DIS 0x00000010 - -/* GEN_TEST_CNTL register constants */ -#define GEN_OVR_OUTPUT_EN 0x20 -#define HWCURSOR_ENABLE 0x80 -#define GUI_ENGINE_ENABLE 0x100 -#define BLOCK_WRITE_ENABLE 0x200 - -/* DSP_CONFIG register constants */ -#define DSP_XCLKS_PER_QW 0x00003fff -#define DSP_LOOP_LATENCY 0x000f0000 -#define DSP_PRECISION 0x00700000 - -/* DSP_ON_OFF register constants */ -#define DSP_OFF 0x000007ff -#define DSP_ON 0x07ff0000 - -/* SHARED_CNTL register constants */ -#define CTD_FIFO5 0x01000000 - -/* CLOCK_CNTL register constants */ -#define CLOCK_SEL 0x0f -#define CLOCK_DIV 0x30 -#define CLOCK_DIV1 0x00 -#define CLOCK_DIV2 0x10 -#define CLOCK_DIV4 0x20 -#define CLOCK_STROBE 0x40 -#define PLL_WR_EN 0x02 - -/* PLL registers */ -#define PLL_MACRO_CNTL 0x01 -#define PLL_REF_DIV 0x02 -#define PLL_GEN_CNTL 0x03 -#define MCLK_FB_DIV 0x04 -#define PLL_VCLK_CNTL 0x05 -#define VCLK_POST_DIV 0x06 -#define VCLK0_FB_DIV 0x07 -#define VCLK1_FB_DIV 0x08 -#define VCLK2_FB_DIV 0x09 -#define VCLK3_FB_DIV 0x0A -#define PLL_XCLK_CNTL 0x0B -#define PLL_TEST_CTRL 0x0E -#define PLL_TEST_COUNT 0x0F - -/* Memory types for CT, ET, VT, GT */ -#define DRAM 1 -#define EDO_DRAM 2 -#define PSEUDO_EDO 3 -#define SDRAM 4 -#define SGRAM 5 -#define SGRAM32 6 - -#define DAC_INTERNAL 0x00 -#define DAC_IBMRGB514 0x01 -#define DAC_ATI68875 0x02 -#define DAC_TVP3026_A 0x72 -#define DAC_BT476 0x03 -#define DAC_BT481 0x04 -#define DAC_ATT20C491 0x14 -#define DAC_SC15026 0x24 -#define DAC_MU9C1880 0x34 -#define DAC_IMSG174 0x44 -#define DAC_ATI68860_B 0x05 -#define DAC_ATI68860_C 0x15 -#define DAC_TVP3026_B 0x75 -#define DAC_STG1700 0x06 -#define DAC_ATT498 0x16 -#define DAC_STG1702 0x07 -#define DAC_SC15021 0x17 -#define DAC_ATT21C498 0x27 -#define DAC_STG1703 0x37 -#define DAC_CH8398 0x47 -#define DAC_ATT20C408 0x57 - -#define CLK_ATI18818_0 0 -#define CLK_ATI18818_1 1 -#define CLK_STG1703 2 -#define CLK_CH8398 3 -#define CLK_INTERNAL 4 -#define CLK_ATT20C408 5 -#define CLK_IBMRGB514 6 - -/* DST_CNTL register constants */ -#define DST_X_RIGHT_TO_LEFT 0 -#define DST_X_LEFT_TO_RIGHT 1 -#define DST_Y_BOTTOM_TO_TOP 0 -#define DST_Y_TOP_TO_BOTTOM 2 -#define DST_X_MAJOR 0 -#define DST_Y_MAJOR 4 -#define DST_X_TILE 8 -#define DST_Y_TILE 0x10 -#define DST_LAST_PEL 0x20 -#define DST_POLYGON_ENABLE 0x40 -#define DST_24_ROTATION_ENABLE 0x80 - -/* SRC_CNTL register constants */ -#define SRC_PATTERN_ENABLE 1 -#define SRC_ROTATION_ENABLE 2 -#define SRC_LINEAR_ENABLE 4 -#define SRC_BYTE_ALIGN 8 -#define SRC_LINE_X_RIGHT_TO_LEFT 0 -#define SRC_LINE_X_LEFT_TO_RIGHT 0x10 - -/* HOST_CNTL register constants */ -#define HOST_BYTE_ALIGN 1 - -/* DP_CHAIN_MASK register constants */ -#define DP_CHAIN_4BPP 0x8888 -#define DP_CHAIN_7BPP 0xD2D2 -#define DP_CHAIN_8BPP 0x8080 -#define DP_CHAIN_8BPP_RGB 0x9292 -#define DP_CHAIN_15BPP 0x4210 -#define DP_CHAIN_16BPP 0x8410 -#define DP_CHAIN_24BPP 0x8080 -#define DP_CHAIN_32BPP 0x8080 - -/* DP_PIX_WIDTH register constants */ -#define DST_1BPP 0 -#define DST_4BPP 1 -#define DST_8BPP 2 -#define DST_15BPP 3 -#define DST_16BPP 4 -#define DST_32BPP 6 -#define SRC_1BPP 0 -#define SRC_4BPP 0x100 -#define SRC_8BPP 0x200 -#define SRC_15BPP 0x300 -#define SRC_16BPP 0x400 -#define SRC_32BPP 0x600 -#define HOST_1BPP 0 -#define HOST_4BPP 0x10000 -#define HOST_8BPP 0x20000 -#define HOST_15BPP 0x30000 -#define HOST_16BPP 0x40000 -#define HOST_32BPP 0x60000 -#define BYTE_ORDER_MSB_TO_LSB 0 -#define BYTE_ORDER_LSB_TO_MSB 0x1000000 - -/* DP_SRC register constants */ -#define BKGD_SRC_BKGD_CLR 0 -#define BKGD_SRC_FRGD_CLR 1 -#define BKGD_SRC_HOST 2 -#define BKGD_SRC_BLIT 3 -#define BKGD_SRC_PATTERN 4 -#define FRGD_SRC_BKGD_CLR 0 -#define FRGD_SRC_FRGD_CLR 0x100 -#define FRGD_SRC_HOST 0x200 -#define FRGD_SRC_BLIT 0x300 -#define FRGD_SRC_PATTERN 0x400 -#define MONO_SRC_ONE 0 -#define MONO_SRC_PATTERN 0x10000 -#define MONO_SRC_HOST 0x20000 -#define MONO_SRC_BLIT 0x30000 - -/* PCI IDs */ -#define ATI_VENDOR 0x1002 -#define ATI_MACH64_CT 0x4354 /* Mach64 CT */ -#define ATI_RAGE_PRO_AGP 0x4742 /* 3D Rage Pro (AGP) */ -#define ATI_RAGE_PRO_AGP1X 0x4744 /* 3D Rage Pro (AGP 1x) */ -#define ATI_RAGE_PRO_PCI_B 0x4749 /* 3D Rage Pro Turbo */ -#define ATI_RAGE_XC_PCI66 0x474c /* Rage XC (PCI66) */ -#define ATI_RAGE_XL_AGP 0x474d /* Rage XL (AGP) */ -#define ATI_RAGE_XC_AGP 0x474e /* Rage XC (AGP) */ -#define ATI_RAGE_XL_PCI66 0x474f /* Rage XL (PCI66) */ -#define ATI_RAGE_PRO_PCI_P 0x4750 /* 3D Rage Pro */ -#define ATI_RAGE_PRO_PCI_L 0x4751 /* 3D Rage Pro (limited 3D) */ -#define ATI_RAGE_XL_PCI 0x4752 /* Rage XL */ -#define ATI_RAGE_XC_PCI 0x4753 /* Rage XC */ -#define ATI_RAGE_II 0x4754 /* 3D Rage I/II */ -#define ATI_RAGE_IIP 0x4755 /* 3D Rage II+ */ -#define ATI_RAGE_IIC_PCI 0x4756 /* 3D Rage IIC */ -#define ATI_RAGE_IIC_AGP_B 0x4757 /* 3D Rage IIC (AGP) */ -#define ATI_RAGE_IIC_AGP_P 0x475a /* 3D Rage IIC (AGP) */ -#define ATI_RAGE_LT_PRO_AGP 0x4c42 /* 3D Rage LT Pro (AGP 133MHz) */ -#define ATI_RAGE_MOB_M3_PCI 0x4c45 /* Rage Mobility M3 */ -#define ATI_RAGE_MOB_M3_AGP 0x4c46 /* Rage Mobility M3 (AGP) */ -#define ATI_RAGE_LT 0x4c47 /* 3D Rage LT */ -#define ATI_RAGE_LT_PRO_PCI 0x4c49 /* 3D Rage LT Pro */ -#define ATI_RAGE_MOBILITY 0x4c4d /* Rage Mobility */ -#define ATI_RAGE_L_MOBILITY 0x4c4e /* Rage L Mobility */ -#define ATI_RAGE_LT_PRO 0x4c50 /* 3D Rage LT Pro */ -#define ATI_RAGE_LT_PRO2 0x4c51 /* 3D Rage LT Pro */ -#define ATI_RAGE_MOB_M1_PCI 0x4c52 /* Rage Mobility M1 (PCI) */ -#define ATI_RAGE_L_MOB_M1_PCI 0x4c53 /* Rage L Mobility (PCI) */ -#define ATI_MACH64_VT 0x5654 /* Mach64 VT */ -#define ATI_MACH64_VTB 0x5655 /* Mach64 VTB */ -#define ATI_MACH64_VT4 0x5656 /* Mach64 VT4 */ - -#endif /* !_DEV_FB_MACHFB_H_ */ diff --git a/sys/dev/firewire/sbp.c b/sys/dev/firewire/sbp.c index 9daa9f001661..38e44193cf58 100644 --- a/sys/dev/firewire/sbp.c +++ b/sys/dev/firewire/sbp.c @@ -134,11 +134,7 @@ SYSCTL_INT(_hw_firewire_sbp, OID_AUTO, tags, CTLFLAG_RWTUN, &sbp_tags, 0, #define NEED_RESPONSE 0 #define SBP_SEG_MAX rounddown(0xffff, PAGE_SIZE) -#ifdef __sparc64__ /* iommu */ -#define SBP_IND_MAX howmany(SBP_MAXPHYS, SBP_SEG_MAX) -#else #define SBP_IND_MAX howmany(SBP_MAXPHYS, PAGE_SIZE) -#endif struct sbp_ocb { STAILQ_ENTRY(sbp_ocb) ocb; union ccb *ccb; diff --git a/sys/dev/flash/at45d.c b/sys/dev/flash/at45d.c index c5339576c3d1..2c7402dbbe82 100644 --- a/sys/dev/flash/at45d.c +++ b/sys/dev/flash/at45d.c @@ -493,7 +493,7 @@ at45d_task(void *arg) len = sc->pagesize - offset; break; default: - berr = EINVAL; + berr = EOPNOTSUPP; goto out; } diff --git a/sys/dev/flash/mx25l.c b/sys/dev/flash/mx25l.c index 3d146882eea7..916829dc6c97 100644 --- a/sys/dev/flash/mx25l.c +++ b/sys/dev/flash/mx25l.c @@ -658,7 +658,7 @@ mx25l_task(void *arg) bp->bio_data, bp->bio_bcount); break; default: - bp->bio_error = EINVAL; + bp->bio_error = EOPNOTSUPP; } diff --git a/sys/dev/flash/n25q.c b/sys/dev/flash/n25q.c index b885da983fcb..cf7bfeef1ee1 100644 --- a/sys/dev/flash/n25q.c +++ b/sys/dev/flash/n25q.c @@ -462,7 +462,7 @@ n25q_task(void *arg) bp->bio_data, bp->bio_bcount); break; default: - bp->bio_error = EINVAL; + bp->bio_error = EOPNOTSUPP; } biodone(bp); diff --git a/sys/dev/gem/if_gem_pci.c b/sys/dev/gem/if_gem_pci.c index ce3027fb3441..1b20d9352a71 100644 --- a/sys/dev/gem/if_gem_pci.c +++ b/sys/dev/gem/if_gem_pci.c @@ -53,7 +53,7 @@ __FBSDID("$FreeBSD$"); #include #include -#if defined(__powerpc__) || defined(__sparc64__) +#if defined(__powerpc__) #include #include #include @@ -149,7 +149,7 @@ gem_pci_attach(device_t dev) { struct gem_softc *sc; int i; -#if defined(__powerpc__) || defined(__sparc64__) +#if defined(__powerpc__) char buf[sizeof(GEM_SHARED_PINS)]; #else int j; @@ -215,7 +215,7 @@ gem_pci_attach(device_t dev) GEM_PCI_BIF_CNF_M66EN) != 0) sc->sc_flags |= GEM_PCI66; -#if defined(__powerpc__) || defined(__sparc64__) +#if defined(__powerpc__) OF_getetheraddr(dev, sc->sc_enaddr); if (OF_getprop(ofw_bus_get_node(dev), GEM_SHARED_PINS, buf, sizeof(buf)) > 0) { diff --git a/sys/dev/gem/if_gem_sbus.c b/sys/dev/gem/if_gem_sbus.c deleted file mode 100644 index 59f79e216781..000000000000 --- a/sys/dev/gem/if_gem_sbus.c +++ /dev/null @@ -1,210 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause-NetBSD - * - * Copyright (C) 2001 Eduardo Horvath. - * Copyright (c) 2007 Marius Strobl - * 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 ``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 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. - * - * from: NetBSD: if_gem_pci.c,v 1.7 2001/10/18 15:09:15 thorpej Exp - */ - -#include -__FBSDID("$FreeBSD$"); - -/* - * SBus bindings for Sun GEM Ethernet controllers - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include - -#include -#include -#include - -#include - -#include -#include - -#include "miibus_if.h" - -static device_probe_t gem_sbus_probe; -static device_attach_t gem_sbus_attach; -static device_detach_t gem_sbus_detach; -static device_suspend_t gem_sbus_suspend; -static device_resume_t gem_sbus_resume; - -static device_method_t gem_sbus_methods[] = { - /* Device interface */ - DEVMETHOD(device_probe, gem_sbus_probe), - DEVMETHOD(device_attach, gem_sbus_attach), - DEVMETHOD(device_detach, gem_sbus_detach), - DEVMETHOD(device_suspend, gem_sbus_suspend), - DEVMETHOD(device_resume, gem_sbus_resume), - /* Use the suspend handler here, it is all that is required. */ - DEVMETHOD(device_shutdown, gem_sbus_suspend), - - /* MII interface */ - DEVMETHOD(miibus_readreg, gem_mii_readreg), - DEVMETHOD(miibus_writereg, gem_mii_writereg), - DEVMETHOD(miibus_statchg, gem_mii_statchg), - - DEVMETHOD_END -}; - -static driver_t gem_sbus_driver = { - "gem", - gem_sbus_methods, - sizeof(struct gem_softc) -}; - -DRIVER_MODULE(gem, sbus, gem_sbus_driver, gem_devclass, 0, 0); -MODULE_DEPEND(gem, sbus, 1, 1, 1); -MODULE_DEPEND(gem, ether, 1, 1, 1); - -static int -gem_sbus_probe(device_t dev) -{ - - if (strcmp(ofw_bus_get_name(dev), "network") == 0 && - ofw_bus_get_compat(dev) != NULL && - strcmp(ofw_bus_get_compat(dev), "SUNW,sbus-gem") == 0) { - device_set_desc(dev, "Sun GEM Gigabit Ethernet"); - return (0); - } - - return (ENXIO); -} - -static struct resource_spec gem_sbus_res_spec[] = { - { SYS_RES_IRQ, 0, RF_SHAREABLE | RF_ACTIVE }, /* GEM_RES_INTR */ - { SYS_RES_MEMORY, 1, RF_ACTIVE }, /* GEM_RES_BANK1 */ - { SYS_RES_MEMORY, 0, RF_ACTIVE }, /* GEM_RES_BANK2 */ - { -1, 0 } -}; - -static int -gem_sbus_attach(device_t dev) -{ - struct gem_softc *sc; - int burst; - uint32_t val; - - sc = device_get_softc(dev); - sc->sc_variant = GEM_SUN_GEM; - sc->sc_dev = dev; - /* All known SBus models use a SERDES. */ - sc->sc_flags = GEM_SERDES; - - if (bus_alloc_resources(dev, gem_sbus_res_spec, sc->sc_res)) { - device_printf(dev, "failed to allocate resources\n"); - bus_release_resources(dev, gem_sbus_res_spec, sc->sc_res); - return (ENXIO); - } - - GEM_LOCK_INIT(sc, device_get_nameunit(dev)); - - OF_getetheraddr(dev, sc->sc_enaddr); - - burst = sbus_get_burstsz(dev); - val = GEM_SBUS_CFG_PARITY; - if ((burst & SBUS_BURST64_MASK) != 0) { - val |= GEM_SBUS_CFG_64BIT; - burst >>= SBUS_BURST64_SHIFT; - } - if ((burst & SBUS_BURST_64) != 0) - val |= GEM_SBUS_CFG_BURST_64; - else if ((burst & SBUS_BURST_32) != 0) - val |= GEM_SBUS_CFG_BURST_32; - else { - device_printf(dev, "unsupported burst size\n"); - goto fail; - } - /* Reset the SBus interface only. */ - (void)GEM_BANK2_READ_4(sc, GEM_SBUS_BIF_RESET); - DELAY(100); - GEM_BANK2_WRITE_4(sc, GEM_SBUS_CONFIG, val); - - if (gem_attach(sc) != 0) { - device_printf(dev, "could not be attached\n"); - goto fail; - } - - if (bus_setup_intr(dev, sc->sc_res[GEM_RES_INTR], INTR_TYPE_NET | - INTR_MPSAFE, NULL, gem_intr, sc, &sc->sc_ih) != 0) { - device_printf(dev, "failed to set up interrupt\n"); - gem_detach(sc); - goto fail; - } - return (0); - - fail: - GEM_LOCK_DESTROY(sc); - bus_release_resources(dev, gem_sbus_res_spec, sc->sc_res); - return (ENXIO); -} - -static int -gem_sbus_detach(device_t dev) -{ - struct gem_softc *sc; - - sc = device_get_softc(dev); - bus_teardown_intr(dev, sc->sc_res[GEM_RES_INTR], sc->sc_ih); - gem_detach(sc); - GEM_LOCK_DESTROY(sc); - bus_release_resources(dev, gem_sbus_res_spec, sc->sc_res); - return (0); -} - -static int -gem_sbus_suspend(device_t dev) -{ - - gem_suspend(device_get_softc(dev)); - return (0); -} - -static int -gem_sbus_resume(device_t dev) -{ - - gem_resume(device_get_softc(dev)); - return (0); -} diff --git a/sys/dev/hme/if_hme_pci.c b/sys/dev/hme/if_hme_pci.c index a7ba6f24fdbc..35cf3f7f90de 100644 --- a/sys/dev/hme/if_hme_pci.c +++ b/sys/dev/hme/if_hme_pci.c @@ -50,7 +50,7 @@ __FBSDID("$FreeBSD$"); #include #include -#if defined(__powerpc__) || defined(__sparc64__) +#if defined(__powerpc__) #include #include #endif @@ -140,7 +140,7 @@ hme_pci_attach(device_t dev) bus_space_tag_t memt; bus_space_handle_t memh; int i, error = 0; -#if !(defined(__powerpc__) || defined(__sparc64__)) +#if !defined(__powerpc__) device_t *children, ebus_dev; struct resource *ebus_rres; int j, slot; @@ -197,7 +197,7 @@ hme_pci_attach(device_t dev) bus_space_subregion(memt, memh, 0x6000, 0x1000, &sc->sc_mach); bus_space_subregion(memt, memh, 0x7000, 0x1000, &sc->sc_mifh); -#if defined(__powerpc__) || defined(__sparc64__) +#if defined(__powerpc__) OF_getetheraddr(dev, sc->sc_enaddr); #else /* diff --git a/sys/dev/hme/if_hme_sbus.c b/sys/dev/hme/if_hme_sbus.c deleted file mode 100644 index 0ea789adac71..000000000000 --- a/sys/dev/hme/if_hme_sbus.c +++ /dev/null @@ -1,338 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD - * - * Copyright (c) 1999 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Paul Kranenburg. - * - * 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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. - * - * from: NetBSD: if_hme_sbus.c,v 1.19 2004/03/17 17:04:58 pk Exp - */ - -#include -__FBSDID("$FreeBSD$"); - -/* - * SBus front-end device driver for the HME ethernet device. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include -#include -#include - -#include - -#include -#include -#include - -#include -#include - -#include - -#include -#include - -#include "miibus_if.h" - -struct hme_sbus_softc { - struct hme_softc hsc_hme; /* HME device */ - struct resource *hsc_seb_res; - struct resource *hsc_etx_res; - struct resource *hsc_erx_res; - struct resource *hsc_mac_res; - struct resource *hsc_mif_res; - struct resource *hsc_ires; - void *hsc_ih; -}; - -static int hme_sbus_probe(device_t); -static int hme_sbus_attach(device_t); -static int hme_sbus_detach(device_t); -static int hme_sbus_suspend(device_t); -static int hme_sbus_resume(device_t); - -static device_method_t hme_sbus_methods[] = { - /* Device interface */ - DEVMETHOD(device_probe, hme_sbus_probe), - DEVMETHOD(device_attach, hme_sbus_attach), - DEVMETHOD(device_detach, hme_sbus_detach), - DEVMETHOD(device_suspend, hme_sbus_suspend), - DEVMETHOD(device_resume, hme_sbus_resume), - /* Can just use the suspend method here. */ - DEVMETHOD(device_shutdown, hme_sbus_suspend), - - /* MII interface */ - DEVMETHOD(miibus_readreg, hme_mii_readreg), - DEVMETHOD(miibus_writereg, hme_mii_writereg), - DEVMETHOD(miibus_statchg, hme_mii_statchg), - - DEVMETHOD_END -}; - -static driver_t hme_sbus_driver = { - "hme", - hme_sbus_methods, - sizeof(struct hme_sbus_softc) -}; - -DRIVER_MODULE(hme, sbus, hme_sbus_driver, hme_devclass, 0, 0); -MODULE_DEPEND(hme, sbus, 1, 1, 1); -MODULE_DEPEND(hme, ether, 1, 1, 1); - -static int -hme_sbus_probe(device_t dev) -{ - const char *name; - - name = ofw_bus_get_name(dev); - if (strcmp(name, "SUNW,qfe") == 0 || - strcmp(name, "SUNW,hme") == 0) { - device_set_desc(dev, "Sun HME 10/100 Ethernet"); - return (0); - } - return (ENXIO); -} - -static int -hme_sbus_attach(device_t dev) -{ - struct hme_sbus_softc *hsc; - struct hme_softc *sc; - u_long start, count; - uint32_t burst; - int i, error = 0; - - hsc = device_get_softc(dev); - sc = &hsc->hsc_hme; - mtx_init(&sc->sc_lock, device_get_nameunit(dev), MTX_NETWORK_LOCK, - MTX_DEF); - /* - * Map five register banks: - * - * bank 0: HME SEB registers - * bank 1: HME ETX registers - * bank 2: HME ERX registers - * bank 3: HME MAC registers - * bank 4: HME MIF registers - * - */ - i = 0; - hsc->hsc_seb_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, - &i, RF_ACTIVE); - if (hsc->hsc_seb_res == NULL) { - device_printf(dev, "cannot map SEB registers\n"); - error = ENXIO; - goto fail_mtx_res; - } - sc->sc_sebt = rman_get_bustag(hsc->hsc_seb_res); - sc->sc_sebh = rman_get_bushandle(hsc->hsc_seb_res); - - i = 1; - hsc->hsc_etx_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, - &i, RF_ACTIVE); - if (hsc->hsc_etx_res == NULL) { - device_printf(dev, "cannot map ETX registers\n"); - error = ENXIO; - goto fail_seb_res; - } - sc->sc_etxt = rman_get_bustag(hsc->hsc_etx_res); - sc->sc_etxh = rman_get_bushandle(hsc->hsc_etx_res); - - i = 2; - hsc->hsc_erx_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, - &i, RF_ACTIVE); - if (hsc->hsc_erx_res == NULL) { - device_printf(dev, "cannot map ERX registers\n"); - error = ENXIO; - goto fail_etx_res; - } - sc->sc_erxt = rman_get_bustag(hsc->hsc_erx_res); - sc->sc_erxh = rman_get_bushandle(hsc->hsc_erx_res); - - i = 3; - hsc->hsc_mac_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, - &i, RF_ACTIVE); - if (hsc->hsc_mac_res == NULL) { - device_printf(dev, "cannot map MAC registers\n"); - error = ENXIO; - goto fail_erx_res; - } - sc->sc_mact = rman_get_bustag(hsc->hsc_mac_res); - sc->sc_mach = rman_get_bushandle(hsc->hsc_mac_res); - - /* - * At least on some HMEs, the MIF registers seem to be inside the MAC - * range, so try to kludge around it. - */ - i = 4; - hsc->hsc_mif_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, - &i, RF_ACTIVE); - if (hsc->hsc_mif_res == NULL) { - if (bus_get_resource(dev, SYS_RES_MEMORY, i, - &start, &count) != 0) { - device_printf(dev, "cannot get MIF registers\n"); - error = ENXIO; - goto fail_mac_res; - } - if (start < rman_get_start(hsc->hsc_mac_res) || - start + count - 1 > rman_get_end(hsc->hsc_mac_res)) { - device_printf(dev, "cannot move MIF registers to MAC " - "bank\n"); - error = ENXIO; - goto fail_mac_res; - } - sc->sc_mift = sc->sc_mact; - bus_space_subregion(sc->sc_mact, sc->sc_mach, - start - rman_get_start(hsc->hsc_mac_res), count, - &sc->sc_mifh); - } else { - sc->sc_mift = rman_get_bustag(hsc->hsc_mif_res); - sc->sc_mifh = rman_get_bushandle(hsc->hsc_mif_res); - } - - i = 0; - hsc->hsc_ires = bus_alloc_resource_any(dev, SYS_RES_IRQ, - &i, RF_SHAREABLE | RF_ACTIVE); - if (hsc->hsc_ires == NULL) { - device_printf(dev, "could not allocate interrupt\n"); - error = ENXIO; - goto fail_mif_res; - } - - OF_getetheraddr(dev, sc->sc_enaddr); - - burst = sbus_get_burstsz(dev); - /* Translate into plain numerical format */ - if ((burst & SBUS_BURST_64)) - sc->sc_burst = 64; - else if ((burst & SBUS_BURST_32)) - sc->sc_burst = 32; - else if ((burst & SBUS_BURST_16)) - sc->sc_burst = 16; - else - sc->sc_burst = 0; - - sc->sc_dev = dev; - sc->sc_flags = 0; - - if ((error = hme_config(sc)) != 0) { - device_printf(dev, "could not be configured\n"); - goto fail_ires; - } - - if ((error = bus_setup_intr(dev, hsc->hsc_ires, INTR_TYPE_NET | - INTR_MPSAFE, NULL, hme_intr, sc, &hsc->hsc_ih)) != 0) { - device_printf(dev, "couldn't establish interrupt\n"); - hme_detach(sc); - goto fail_ires; - } - return (0); - -fail_ires: - bus_release_resource(dev, SYS_RES_IRQ, - rman_get_rid(hsc->hsc_ires), hsc->hsc_ires); -fail_mif_res: - if (hsc->hsc_mif_res != NULL) { - bus_release_resource(dev, SYS_RES_MEMORY, - rman_get_rid(hsc->hsc_mif_res), hsc->hsc_mif_res); - } -fail_mac_res: - bus_release_resource(dev, SYS_RES_MEMORY, - rman_get_rid(hsc->hsc_mac_res), hsc->hsc_mac_res); -fail_erx_res: - bus_release_resource(dev, SYS_RES_MEMORY, - rman_get_rid(hsc->hsc_erx_res), hsc->hsc_erx_res); -fail_etx_res: - bus_release_resource(dev, SYS_RES_MEMORY, - rman_get_rid(hsc->hsc_etx_res), hsc->hsc_etx_res); -fail_seb_res: - bus_release_resource(dev, SYS_RES_MEMORY, - rman_get_rid(hsc->hsc_seb_res), hsc->hsc_seb_res); -fail_mtx_res: - mtx_destroy(&sc->sc_lock); - return (error); -} - -static int -hme_sbus_detach(device_t dev) -{ - struct hme_sbus_softc *hsc; - struct hme_softc *sc; - - hsc = device_get_softc(dev); - sc = &hsc->hsc_hme; - bus_teardown_intr(dev, hsc->hsc_ires, hsc->hsc_ih); - hme_detach(sc); - bus_release_resource(dev, SYS_RES_IRQ, - rman_get_rid(hsc->hsc_ires), hsc->hsc_ires); - if (hsc->hsc_mif_res != NULL) { - bus_release_resource(dev, SYS_RES_MEMORY, - rman_get_rid(hsc->hsc_mif_res), hsc->hsc_mif_res); - } - bus_release_resource(dev, SYS_RES_MEMORY, - rman_get_rid(hsc->hsc_mac_res), hsc->hsc_mac_res); - bus_release_resource(dev, SYS_RES_MEMORY, - rman_get_rid(hsc->hsc_erx_res), hsc->hsc_erx_res); - bus_release_resource(dev, SYS_RES_MEMORY, - rman_get_rid(hsc->hsc_etx_res), hsc->hsc_etx_res); - bus_release_resource(dev, SYS_RES_MEMORY, - rman_get_rid(hsc->hsc_seb_res), hsc->hsc_seb_res); - mtx_destroy(&sc->sc_lock); - return (0); -} - -static int -hme_sbus_suspend(device_t dev) -{ - struct hme_sbus_softc *hsc; - - hsc = device_get_softc(dev); - hme_suspend(&hsc->hsc_hme); - return (0); -} - -static int -hme_sbus_resume(device_t dev) -{ - struct hme_sbus_softc *hsc; - - hsc = device_get_softc(dev); - hme_resume(&hsc->hsc_hme); - return (0); -} diff --git a/sys/dev/hwpmc/hwpmc_sparc64.c b/sys/dev/hwpmc/hwpmc_sparc64.c deleted file mode 100644 index 3ded908e2529..000000000000 --- a/sys/dev/hwpmc/hwpmc_sparc64.c +++ /dev/null @@ -1,68 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD - * - * Copyright (c) 2005, Joseph Koshy - * 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 -__FBSDID("$FreeBSD$"); - -#include -#include - -#include - -struct pmc_mdep * -pmc_md_initialize() -{ - return NULL; -} - -void -pmc_md_finalize(struct pmc_mdep *md) -{ - (void) md; -} - -int -pmc_save_kernel_callchain(uintptr_t *cc, int maxsamples, - struct trapframe *tf) -{ - (void) cc; - (void) maxsamples; - (void) tf; - return (0); -} - -int -pmc_save_user_callchain(uintptr_t *cc, int maxsamples, - struct trapframe *tf) -{ - (void) cc; - (void) maxsamples; - (void) tf; - return (0); -} diff --git a/sys/dev/ida/ida_disk.c b/sys/dev/ida/ida_disk.c index c38b3795e219..db84f905ff50 100644 --- a/sys/dev/ida/ida_disk.c +++ b/sys/dev/ida/ida_disk.c @@ -106,6 +106,11 @@ idad_strategy(struct bio *bp) goto bad; } + if ((bp->bio_cmd != BIO_READ) && (bp->bio_cmd != BIO_WRITE)) { + bp->bio_error = EOPNOTSUPP; + goto bad; + } + bp->bio_driver1 = drv; ida_submit_buf(drv->controller, bp); return; diff --git a/sys/dev/ips/ips_disk.c b/sys/dev/ips/ips_disk.c index 1d2732260792..7ae489ea8201 100644 --- a/sys/dev/ips/ips_disk.c +++ b/sys/dev/ips/ips_disk.c @@ -109,6 +109,13 @@ static void ipsd_strategy(struct bio *iobuf) dsc = iobuf->bio_disk->d_drv1; DEVICE_PRINTF(8,dsc->dev,"in strategy\n"); iobuf->bio_driver1 = (void *)(uintptr_t)dsc->sc->drives[dsc->disk_number].drivenum; + + if ((iobuf->bio_cmd != BIO_READ) && + (iobuf->bio_cmd != BIO_WRITE)) { + biofinish(iobuf, NULL, EOPNOTSUPP); + return; + } + mtx_lock(&dsc->sc->queue_mtx); bioq_insert_tail(&dsc->sc->queue, iobuf); ips_start_io_request(dsc->sc); diff --git a/sys/dev/isp/isp_freebsd.h b/sys/dev/isp/isp_freebsd.h index 6bd2a71b5f0f..971fc0b05d84 100644 --- a/sys/dev/isp/isp_freebsd.h +++ b/sys/dev/isp/isp_freebsd.h @@ -71,11 +71,7 @@ /* * Efficiency- get rid of SBus code && tests unless we need them. */ -#ifdef __sparc64__ -#define ISP_SBUS_SUPPORTED 1 -#else #define ISP_SBUS_SUPPORTED 0 -#endif #define ISP_IFLAGS INTR_TYPE_CAM | INTR_ENTROPY | INTR_MPSAFE diff --git a/sys/dev/isp/isp_pci.c b/sys/dev/isp/isp_pci.c index 42415f5091b2..6cd7fa7ebd0a 100644 --- a/sys/dev/isp/isp_pci.c +++ b/sys/dev/isp/isp_pci.c @@ -48,12 +48,6 @@ __FBSDID("$FreeBSD$"); #include #include #include - -#ifdef __sparc64__ -#include -#include -#endif - #include static uint32_t isp_pci_rd_reg(ispsoftc_t *, int); @@ -493,11 +487,7 @@ isp_get_specific_options(device_t dev, int chan, ispsoftc_t *isp) if (IS_FC(isp)) { ISP_FC_PC(isp, chan)->default_id = 109 - chan; } else { -#ifdef __sparc64__ - ISP_SPI_PC(isp, chan)->iid = OF_getscsinitid(dev); -#else ISP_SPI_PC(isp, chan)->iid = 7; -#endif } } else { if (IS_FC(isp)) { diff --git a/sys/dev/isp/isp_sbus.c b/sys/dev/isp/isp_sbus.c deleted file mode 100644 index 35e3e220b276..000000000000 --- a/sys/dev/isp/isp_sbus.c +++ /dev/null @@ -1,701 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD - * - * Copyright (c) 1997-2006 by Matthew Jacob - * 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 immediately at the beginning of the file, without modification, - * this list of conditions, and the following disclaimer. - * 2. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * 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. - */ -/* - * SBus specific probe and attach routines for Qlogic ISP SCSI adapters. - * FreeBSD Version. - */ - -#include -__FBSDID("$FreeBSD$"); - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include -#include -#include -#include -#include - -#include - -static uint32_t isp_sbus_rd_reg(ispsoftc_t *, int); -static void isp_sbus_wr_reg(ispsoftc_t *, int, uint32_t); -static void isp_sbus_run_isr(ispsoftc_t *); -static int isp_sbus_mbxdma(ispsoftc_t *); -static void isp_sbus_mbxdmafree(ispsoftc_t *); -static int isp_sbus_dmasetup(ispsoftc_t *, XS_T *, void *); -static void isp_sbus_dumpregs(ispsoftc_t *, const char *); - -static struct ispmdvec mdvec = { - isp_sbus_run_isr, - isp_sbus_rd_reg, - isp_sbus_wr_reg, - isp_sbus_mbxdma, - isp_sbus_dmasetup, - isp_common_dmateardown, - NULL, - isp_sbus_dumpregs, - NULL, - BIU_BURST_ENABLE|BIU_PCI_CONF1_FIFO_64 -}; - -static int isp_sbus_probe (device_t); -static int isp_sbus_attach (device_t); -static int isp_sbus_detach (device_t); - - -#define ISP_SBD(isp) ((struct isp_sbussoftc *)isp)->sbus_dev -struct isp_sbussoftc { - ispsoftc_t sbus_isp; - device_t sbus_dev; - struct resource * regs; - void * irq; - int iqd; - int rgd; - void * ih; - int16_t sbus_poff[_NREG_BLKS]; - sdparam sbus_param; - struct isp_spi sbus_spi; - struct ispmdvec sbus_mdvec; -}; - - -static device_method_t isp_sbus_methods[] = { - /* Device interface */ - DEVMETHOD(device_probe, isp_sbus_probe), - DEVMETHOD(device_attach, isp_sbus_attach), - DEVMETHOD(device_detach, isp_sbus_detach), - { 0, 0 } -}; - -static driver_t isp_sbus_driver = { - "isp", isp_sbus_methods, sizeof (struct isp_sbussoftc) -}; -static devclass_t isp_devclass; -DRIVER_MODULE(isp, sbus, isp_sbus_driver, isp_devclass, 0, 0); -MODULE_DEPEND(isp, cam, 1, 1, 1); -MODULE_DEPEND(isp, firmware, 1, 1, 1); - -static int -isp_sbus_probe(device_t dev) -{ - int found = 0; - const char *name = ofw_bus_get_name(dev); - if (strcmp(name, "SUNW,isp") == 0 || - strcmp(name, "QLGC,isp") == 0 || - strcmp(name, "ptisp") == 0 || - strcmp(name, "PTI,ptisp") == 0) { - found++; - } - if (!found) - return (ENXIO); - - if (isp_announced == 0 && bootverbose) { - printf("Qlogic ISP Driver, FreeBSD Version %d.%d, " - "Core Version %d.%d\n", - ISP_PLATFORM_VERSION_MAJOR, ISP_PLATFORM_VERSION_MINOR, - ISP_CORE_VERSION_MAJOR, ISP_CORE_VERSION_MINOR); - isp_announced++; - } - return (0); -} - -static int -isp_sbus_attach(device_t dev) -{ - struct isp_sbussoftc *sbs = device_get_softc(dev); - ispsoftc_t *isp = &sbs->sbus_isp; - int tval, isp_debug, role, ispburst, default_id; - - sbs->sbus_dev = dev; - sbs->sbus_mdvec = mdvec; - isp->isp_dev = dev; - mtx_init(&isp->isp_lock, "isp", NULL, MTX_DEF); - - role = 0; - if (resource_int_value(device_get_name(dev), device_get_unit(dev), - "role", &role) == 0 && - ((role & ~(ISP_ROLE_INITIATOR|ISP_ROLE_TARGET)) == 0)) { - device_printf(dev, "setting role to 0x%x\n", role); - } else { - role = ISP_DEFAULT_ROLES; - } - - sbs->irq = sbs->regs = NULL; - sbs->rgd = sbs->iqd = 0; - - sbs->regs = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &sbs->rgd, - RF_ACTIVE); - if (sbs->regs == NULL) { - device_printf(dev, "unable to map registers\n"); - goto bad; - } - - sbs->sbus_poff[BIU_BLOCK >> _BLK_REG_SHFT] = BIU_REGS_OFF; - sbs->sbus_poff[MBOX_BLOCK >> _BLK_REG_SHFT] = SBUS_MBOX_REGS_OFF; - sbs->sbus_poff[SXP_BLOCK >> _BLK_REG_SHFT] = SBUS_SXP_REGS_OFF; - sbs->sbus_poff[RISC_BLOCK >> _BLK_REG_SHFT] = SBUS_RISC_REGS_OFF; - sbs->sbus_poff[DMA_BLOCK >> _BLK_REG_SHFT] = DMA_REGS_OFF; - isp->isp_regs = sbs->regs; - isp->isp_mdvec = &sbs->sbus_mdvec; - isp->isp_bustype = ISP_BT_SBUS; - isp->isp_type = ISP_HA_SCSI_UNKNOWN; - isp->isp_param = &sbs->sbus_param; - isp->isp_osinfo.pc.ptr = &sbs->sbus_spi; - isp->isp_revision = 0; /* XXX */ - isp->isp_nchan = 1; - if (IS_FC(isp)) - ISP_FC_PC(isp, 0)->def_role = role; - - /* - * Get the clock frequency and convert it from HZ to MHz, - * rounding up. This defaults to 25MHz if there isn't a - * device specific one in the OFW device tree. - */ - sbs->sbus_mdvec.dv_clock = (sbus_get_clockfreq(dev) + 500000)/1000000; - - /* - * Now figure out what the proper burst sizes, etc., to use. - * Unfortunately, there is no ddi_dma_burstsizes here which - * walks up the tree finding the limiting burst size node (if - * any). We just use what's here for isp. - */ - ispburst = sbus_get_burstsz(dev); - if (ispburst == 0) { - ispburst = SBUS_BURST_32 - 1; - } - sbs->sbus_mdvec.dv_conf1 = 0; - if (ispburst & (1 << 5)) { - sbs->sbus_mdvec.dv_conf1 = BIU_SBUS_CONF1_FIFO_32; - } else if (ispburst & (1 << 4)) { - sbs->sbus_mdvec.dv_conf1 = BIU_SBUS_CONF1_FIFO_16; - } else if (ispburst & (1 << 3)) { - sbs->sbus_mdvec.dv_conf1 = - BIU_SBUS_CONF1_BURST8 | BIU_SBUS_CONF1_FIFO_8; - } - if (sbs->sbus_mdvec.dv_conf1) { - sbs->sbus_mdvec.dv_conf1 |= BIU_BURST_ENABLE; - } - - /* - * We don't trust NVRAM on SBus cards - */ - isp->isp_confopts |= ISP_CFG_NONVRAM; - - /* - * Mark things if we're a PTI SBus adapter. - */ - if (strcmp("PTI,ptisp", ofw_bus_get_name(dev)) == 0 || - strcmp("ptisp", ofw_bus_get_name(dev)) == 0) { - SDPARAM(isp, 0)->isp_ptisp = 1; - } - - isp->isp_osinfo.fw = firmware_get("isp_1000"); - if (isp->isp_osinfo.fw) { - union { - const void *cp; - uint16_t *sp; - } stupid; - stupid.cp = isp->isp_osinfo.fw->data; - isp->isp_mdvec->dv_ispfw = stupid.sp; - } - - tval = 0; - if (resource_int_value(device_get_name(dev), device_get_unit(dev), - "fwload_disable", &tval) == 0 && tval != 0) { - isp->isp_confopts |= ISP_CFG_NORELOAD; - } - - default_id = -1; - if (resource_int_value(device_get_name(dev), device_get_unit(dev), - "iid", &tval) == 0) { - default_id = tval; - isp->isp_confopts |= ISP_CFG_OWNLOOPID; - } - if (default_id == -1) { - default_id = OF_getscsinitid(dev); - } - ISP_SPI_PC(isp, 0)->iid = default_id; - - isp_debug = 0; - (void) resource_int_value(device_get_name(dev), device_get_unit(dev), - "debug", &isp_debug); - - sbs->irq = bus_alloc_resource_any(dev, SYS_RES_IRQ, &sbs->iqd, - RF_ACTIVE | RF_SHAREABLE); - if (sbs->irq == NULL) { - device_printf(dev, "could not allocate interrupt\n"); - goto bad; - } - - if (bus_setup_intr(dev, sbs->irq, ISP_IFLAGS, NULL, isp_platform_intr, - isp, &sbs->ih)) { - device_printf(dev, "could not setup interrupt\n"); - (void) bus_release_resource(dev, SYS_RES_IRQ, - sbs->iqd, sbs->irq); - goto bad; - } - isp->isp_nirq = 1; - - /* - * Set up logging levels. - */ - if (isp_debug) { - isp->isp_dblev = isp_debug; - } else { - isp->isp_dblev = ISP_LOGWARN|ISP_LOGERR; - } - if (bootverbose) { - isp->isp_dblev |= ISP_LOGCONFIG|ISP_LOGINFO; - } - - /* - * Make sure we're in reset state. - */ - ISP_LOCK(isp); - if (isp_reinit(isp, 1) != 0) { - ISP_UNLOCK(isp); - goto bad; - } - ISP_UNLOCK(isp); - if (isp_attach(isp)) { - ISP_LOCK(isp); - isp_shutdown(isp); - ISP_UNLOCK(isp); - goto bad; - } - return (0); - -bad: - if (isp->isp_nirq > 0) { - (void) bus_teardown_intr(dev, sbs->irq, sbs->ih); - (void) bus_release_resource(dev, SYS_RES_IRQ, sbs->iqd, - sbs->irq); - } - - if (sbs->regs) { - (void) bus_release_resource(dev, SYS_RES_MEMORY, sbs->rgd, - sbs->regs); - } - mtx_destroy(&isp->isp_lock); - return (ENXIO); -} - -static int -isp_sbus_detach(device_t dev) -{ - struct isp_sbussoftc *sbs = device_get_softc(dev); - ispsoftc_t *isp = &sbs->sbus_isp; - int status; - - status = isp_detach(isp); - if (status) - return (status); - ISP_LOCK(isp); - isp_shutdown(isp); - ISP_UNLOCK(isp); - if (isp->isp_nirq > 0) { - (void) bus_teardown_intr(dev, sbs->irq, sbs->ih); - (void) bus_release_resource(dev, SYS_RES_IRQ, sbs->iqd, - sbs->irq); - } - (void) bus_release_resource(dev, SYS_RES_MEMORY, sbs->rgd, sbs->regs); - isp_sbus_mbxdmafree(isp); - mtx_destroy(&isp->isp_lock); - return (0); -} - -#define IspVirt2Off(a, x) \ - (((struct isp_sbussoftc *)a)->sbus_poff[((x) & _BLK_REG_MASK) >> \ - _BLK_REG_SHFT] + ((x) & 0xff)) - -#define BXR2(isp, off) bus_read_2((isp)->isp_regs, (off)) - -static void -isp_sbus_run_isr(ispsoftc_t *isp) -{ - uint16_t isr, sema, info; - - isr = BXR2(isp, IspVirt2Off(isp, BIU_ISR)); - sema = BXR2(isp, IspVirt2Off(isp, BIU_SEMA)); - isp_prt(isp, ISP_LOGDEBUG3, "ISR 0x%x SEMA 0x%x", isr, sema); - isr &= INT_PENDING_MASK(isp); - sema &= BIU_SEMA_LOCK; - if (isr == 0 && sema == 0) - return; - if (sema != 0) { - info = BXR2(isp, IspVirt2Off(isp, OUTMAILBOX0)); - if (info & MBOX_COMMAND_COMPLETE) - isp_intr_mbox(isp, info); - else - isp_intr_async(isp, info); - if (isp->isp_state == ISP_RUNSTATE) - isp_intr_respq(isp); - } else - isp_intr_respq(isp); - ISP_WRITE(isp, HCCR, HCCR_CMD_CLEAR_RISC_INT); - if (sema) - ISP_WRITE(isp, BIU_SEMA, 0); -} - -static uint32_t -isp_sbus_rd_reg(ispsoftc_t *isp, int regoff) -{ - uint16_t rval; - struct isp_sbussoftc *sbs = (struct isp_sbussoftc *) isp; - int offset = sbs->sbus_poff[(regoff & _BLK_REG_MASK) >> _BLK_REG_SHFT]; - offset += (regoff & 0xff); - rval = BXR2(isp, offset); - isp_prt(isp, ISP_LOGDEBUG3, - "isp_sbus_rd_reg(off %x) = %x", regoff, rval); - return (rval); -} - -static void -isp_sbus_wr_reg(ispsoftc_t *isp, int regoff, uint32_t val) -{ - struct isp_sbussoftc *sbs = (struct isp_sbussoftc *) isp; - int offset = sbs->sbus_poff[(regoff & _BLK_REG_MASK) >> _BLK_REG_SHFT]; - offset += (regoff & 0xff); - isp_prt(isp, ISP_LOGDEBUG3, - "isp_sbus_wr_reg(off %x) = %x", regoff, val); - bus_write_2(isp->isp_regs, offset, val); - MEMORYBARRIER(isp, SYNC_REG, offset, 2, -1); -} - -struct imush { - bus_addr_t maddr; - int error; -}; - -static void imc(void *, bus_dma_segment_t *, int, int); - -static void -imc(void *arg, bus_dma_segment_t *segs, int nseg, int error) -{ - struct imush *imushp = (struct imush *) arg; - - if (!(imushp->error = error)) - imushp->maddr = segs[0].ds_addr; -} - -static int -isp_sbus_mbxdma(ispsoftc_t *isp) -{ - caddr_t base; - uint32_t len; - int i, error; - struct imush im; - - /* Already been here? If so, leave... */ - if (isp->isp_xflist != NULL) - return (0); - if (isp->isp_rquest != NULL && isp->isp_maxcmds == 0) - return (0); - ISP_UNLOCK(isp); - if (isp->isp_rquest != NULL) - goto gotmaxcmds; - - if (bus_dma_tag_create(bus_get_dma_tag(ISP_SBD(isp)), 1, - BUS_SPACE_MAXADDR_24BIT+1, BUS_SPACE_MAXADDR_32BIT, - BUS_SPACE_MAXADDR_32BIT, NULL, NULL, BUS_SPACE_MAXSIZE_32BIT, - ISP_NSEG_MAX, BUS_SPACE_MAXADDR_24BIT, 0, - busdma_lock_mutex, &isp->isp_lock, &isp->isp_osinfo.dmat)) { - isp_prt(isp, ISP_LOGERR, "could not create master dma tag"); - goto bad; - } - - /* - * Allocate and map the request queue. - */ - len = ISP_QUEUE_SIZE(RQUEST_QUEUE_LEN(isp)); - if (bus_dma_tag_create(isp->isp_osinfo.dmat, QENTRY_LEN, BUS_SPACE_MAXADDR_24BIT+1, - BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL, - len, 1, len, 0, busdma_lock_mutex, &isp->isp_lock, - &isp->isp_osinfo.reqdmat)) { - isp_prt(isp, ISP_LOGERR, "cannot create request DMA tag"); - goto bad; - } - if (bus_dmamem_alloc(isp->isp_osinfo.reqdmat, (void **)&base, - BUS_DMA_COHERENT, &isp->isp_osinfo.reqmap) != 0) { - isp_prt(isp, ISP_LOGERR, "cannot allocate request DMA memory"); - bus_dma_tag_destroy(isp->isp_osinfo.reqdmat); - goto bad; - } - isp->isp_rquest = base; - im.error = 0; - if (bus_dmamap_load(isp->isp_osinfo.reqdmat, isp->isp_osinfo.reqmap, - base, len, imc, &im, 0) || im.error) { - isp_prt(isp, ISP_LOGERR, "error loading request DMA map %d", im.error); - goto bad; - } - isp_prt(isp, ISP_LOGDEBUG0, "request area @ 0x%jx/0x%jx", - (uintmax_t)im.maddr, (uintmax_t)len); - isp->isp_rquest_dma = im.maddr; - - /* - * Allocate and map the result queue. - */ - len = ISP_QUEUE_SIZE(RESULT_QUEUE_LEN(isp)); - if (bus_dma_tag_create(isp->isp_osinfo.dmat, QENTRY_LEN, BUS_SPACE_MAXADDR_24BIT+1, - BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL, - len, 1, len, 0, busdma_lock_mutex, &isp->isp_lock, - &isp->isp_osinfo.respdmat)) { - isp_prt(isp, ISP_LOGERR, "cannot create response DMA tag"); - goto bad; - } - if (bus_dmamem_alloc(isp->isp_osinfo.respdmat, (void **)&base, - BUS_DMA_COHERENT, &isp->isp_osinfo.respmap) != 0) { - isp_prt(isp, ISP_LOGERR, "cannot allocate response DMA memory"); - bus_dma_tag_destroy(isp->isp_osinfo.respdmat); - goto bad; - } - isp->isp_result = base; - im.error = 0; - if (bus_dmamap_load(isp->isp_osinfo.respdmat, isp->isp_osinfo.respmap, - base, len, imc, &im, 0) || im.error) { - isp_prt(isp, ISP_LOGERR, "error loading response DMA map %d", im.error); - goto bad; - } - isp_prt(isp, ISP_LOGDEBUG0, "response area @ 0x%jx/0x%jx", - (uintmax_t)im.maddr, (uintmax_t)len); - isp->isp_result_dma = im.maddr; - - if (isp->isp_maxcmds == 0) { - ISP_LOCK(isp); - return (0); - } - -gotmaxcmds: - len = sizeof (struct isp_pcmd) * isp->isp_maxcmds; - isp->isp_osinfo.pcmd_pool = (struct isp_pcmd *) - malloc(len, M_DEVBUF, M_WAITOK | M_ZERO); - for (i = 0; i < isp->isp_maxcmds; i++) { - struct isp_pcmd *pcmd = &isp->isp_osinfo.pcmd_pool[i]; - error = bus_dmamap_create(isp->isp_osinfo.dmat, 0, &pcmd->dmap); - if (error) { - isp_prt(isp, ISP_LOGERR, - "error %d creating per-cmd DMA maps", error); - while (--i >= 0) { - bus_dmamap_destroy(isp->isp_osinfo.dmat, - isp->isp_osinfo.pcmd_pool[i].dmap); - } - goto bad; - } - callout_init_mtx(&pcmd->wdog, &isp->isp_lock, 0); - if (i == isp->isp_maxcmds-1) { - pcmd->next = NULL; - } else { - pcmd->next = &isp->isp_osinfo.pcmd_pool[i+1]; - } - } - isp->isp_osinfo.pcmd_free = &isp->isp_osinfo.pcmd_pool[0]; - - len = sizeof (isp_hdl_t *) * isp->isp_maxcmds; - isp->isp_xflist = (isp_hdl_t *) malloc(len, M_DEVBUF, M_WAITOK | M_ZERO); - for (len = 0; len < isp->isp_maxcmds - 1; len++) - isp->isp_xflist[len].cmd = &isp->isp_xflist[len+1]; - isp->isp_xffree = isp->isp_xflist; - - ISP_LOCK(isp); - return (0); - -bad: - isp_sbus_mbxdmafree(isp); - ISP_LOCK(isp); - return (1); -} - -static void -isp_sbus_mbxdmafree(ispsoftc_t *isp) -{ - int i; - - if (isp->isp_xflist != NULL) { - free(isp->isp_xflist, M_DEVBUF); - isp->isp_xflist = NULL; - } - if (isp->isp_osinfo.pcmd_pool != NULL) { - for (i = 0; i < isp->isp_maxcmds; i++) { - bus_dmamap_destroy(isp->isp_osinfo.dmat, - isp->isp_osinfo.pcmd_pool[i].dmap); - } - free(isp->isp_osinfo.pcmd_pool, M_DEVBUF); - isp->isp_osinfo.pcmd_pool = NULL; - } - if (isp->isp_result_dma != 0) { - bus_dmamap_unload(isp->isp_osinfo.respdmat, - isp->isp_osinfo.respmap); - isp->isp_result_dma = 0; - } - if (isp->isp_result != NULL) { - bus_dmamem_free(isp->isp_osinfo.respdmat, isp->isp_result, - isp->isp_osinfo.respmap); - bus_dma_tag_destroy(isp->isp_osinfo.respdmat); - isp->isp_result = NULL; - } - if (isp->isp_rquest_dma != 0) { - bus_dmamap_unload(isp->isp_osinfo.reqdmat, - isp->isp_osinfo.reqmap); - isp->isp_rquest_dma = 0; - } - if (isp->isp_rquest != NULL) { - bus_dmamem_free(isp->isp_osinfo.reqdmat, isp->isp_rquest, - isp->isp_osinfo.reqmap); - bus_dma_tag_destroy(isp->isp_osinfo.reqdmat); - isp->isp_rquest = NULL; - } -} - -typedef struct { - ispsoftc_t *isp; - void *cmd_token; - void *rq; /* original request */ - int error; -} mush_t; - -#define MUSHERR_NOQENTRIES -2 - -static void -dma2(void *arg, bus_dma_segment_t *dm_segs, int nseg, int error) -{ - mush_t *mp = (mush_t *) arg; - ispsoftc_t *isp = mp->isp; - struct ccb_scsiio *csio = mp->cmd_token; - isp_ddir_t ddir; - int sdir; - - if (error) { - mp->error = error; - return; - } - if (nseg == 0) { - ddir = ISP_NOXFR; - } else { - if ((csio->ccb_h.flags & CAM_DIR_MASK) == CAM_DIR_IN) { - ddir = ISP_FROM_DEVICE; - } else { - ddir = ISP_TO_DEVICE; - } - if ((csio->ccb_h.func_code == XPT_CONT_TARGET_IO) ^ - ((csio->ccb_h.flags & CAM_DIR_MASK) == CAM_DIR_IN)) { - sdir = BUS_DMASYNC_PREREAD; - } else { - sdir = BUS_DMASYNC_PREWRITE; - } - bus_dmamap_sync(isp->isp_osinfo.dmat, PISP_PCMD(csio)->dmap, - sdir); - } - - if (isp_send_cmd(isp, mp->rq, dm_segs, nseg, XS_XFRLEN(csio), - ddir, NULL) != CMD_QUEUED) { - mp->error = MUSHERR_NOQENTRIES; - } -} - -static int -isp_sbus_dmasetup(ispsoftc_t *isp, struct ccb_scsiio *csio, void *ff) -{ - mush_t mush, *mp; - int error; - - mp = &mush; - mp->isp = isp; - mp->cmd_token = csio; - mp->rq = ff; - mp->error = 0; - - error = bus_dmamap_load_ccb(isp->isp_osinfo.dmat, - PISP_PCMD(csio)->dmap, (union ccb *)csio, dma2, mp, 0); - if (error == EINPROGRESS) { - bus_dmamap_unload(isp->isp_osinfo.dmat, PISP_PCMD(csio)->dmap); - mp->error = EINVAL; - isp_prt(isp, ISP_LOGERR, - "deferred dma allocation not supported"); - } else if (error && mp->error == 0) { -#ifdef DIAGNOSTIC - isp_prt(isp, ISP_LOGERR, "error %d in dma mapping code", error); -#endif - mp->error = error; - } - if (mp->error) { - int retval = CMD_COMPLETE; - if (mp->error == MUSHERR_NOQENTRIES) { - retval = CMD_EAGAIN; - } else if (mp->error == EFBIG) { - XS_SETERR(csio, CAM_REQ_TOO_BIG); - } else if (mp->error == EINVAL) { - XS_SETERR(csio, CAM_REQ_INVALID); - } else { - XS_SETERR(csio, CAM_UNREC_HBA_ERROR); - } - return (retval); - } - return (CMD_QUEUED); -} - -static void -isp_sbus_dumpregs(ispsoftc_t *isp, const char *msg) -{ - if (msg) - printf("%s: %s\n", device_get_nameunit(isp->isp_dev), msg); - else - printf("%s:\n", device_get_nameunit(isp->isp_dev)); - printf(" biu_conf1=%x", ISP_READ(isp, BIU_CONF1)); - printf(" biu_icr=%x biu_isr=%x biu_sema=%x ", ISP_READ(isp, BIU_ICR), - ISP_READ(isp, BIU_ISR), ISP_READ(isp, BIU_SEMA)); - printf("risc_hccr=%x\n", ISP_READ(isp, HCCR)); - - - ISP_WRITE(isp, HCCR, HCCR_CMD_PAUSE); - printf(" cdma_conf=%x cdma_sts=%x cdma_fifostat=%x\n", - ISP_READ(isp, CDMA_CONF), ISP_READ(isp, CDMA_STATUS), - ISP_READ(isp, CDMA_FIFO_STS)); - printf(" ddma_conf=%x ddma_sts=%x ddma_fifostat=%x\n", - ISP_READ(isp, DDMA_CONF), ISP_READ(isp, DDMA_STATUS), - ISP_READ(isp, DDMA_FIFO_STS)); - printf(" sxp_int=%x sxp_gross=%x sxp(scsi_ctrl)=%x\n", - ISP_READ(isp, SXP_INTERRUPT), - ISP_READ(isp, SXP_GROSS_ERR), - ISP_READ(isp, SXP_PINS_CTRL)); - ISP_WRITE(isp, HCCR, HCCR_CMD_RELEASE); - printf(" mbox regs: %x %x %x %x %x\n", - ISP_READ(isp, OUTMAILBOX0), ISP_READ(isp, OUTMAILBOX1), - ISP_READ(isp, OUTMAILBOX2), ISP_READ(isp, OUTMAILBOX3), - ISP_READ(isp, OUTMAILBOX4)); -} diff --git a/sys/dev/ispfw/asm_1000.h b/sys/dev/ispfw/asm_1000.h deleted file mode 100644 index 69193fac602d..000000000000 --- a/sys/dev/ispfw/asm_1000.h +++ /dev/null @@ -1,1293 +0,0 @@ -/* $FreeBSD$ */ -/*- - * SPDX-License-Identifier: BSD-3-Clause - * - * Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000 Qlogic, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms are permitted provided - * that the following conditions are met: - * 1. Redistribution of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistribution 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. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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. - */ - -/* - * Firmware Version 1.37.00 (11:28 Aug 28, 2000) - */ -static const u_int16_t isp_1000_risc_code[] = { - 0x0078, 0x1041, 0x0000, 0x2757, 0x0000, 0x12ff, 0x2043, 0x4f50, - 0x5952, 0x4947, 0x4854, 0x2031, 0x3939, 0x312c, 0x3139, 0x3932, - 0x2c31, 0x3939, 0x332c, 0x3139, 0x3934, 0x2051, 0x4c4f, 0x4749, - 0x4320, 0x434f, 0x5250, 0x4f52, 0x4154, 0x494f, 0x4e00, 0x2049, - 0x5350, 0x3130, 0x3030, 0x2046, 0x6972, 0x6d77, 0x6172, 0x6520, - 0x2056, 0x6572, 0x7369, 0x6f6e, 0x2030, 0x312e, 0x3337, 0x2020, - 0x2043, 0x7573, 0x746f, 0x6d65, 0x7220, 0x4e6f, 0x2e20, 0x3135, - 0x2050, 0x726f, 0x6475, 0x6374, 0x204e, 0x6f2e, 0x2000, 0x3030, - 0x2024, 0x20b9, 0x1212, 0x20c1, 0x0008, 0x2071, 0x0010, 0x70c3, - 0x0004, 0x20c9, 0x5cff, 0x2089, 0x10ee, 0x70c7, 0x4953, 0x70cb, - 0x5020, 0x70cf, 0x2020, 0x70d3, 0x0001, 0x3f00, 0x70d6, 0x2031, - 0x0030, 0x2079, 0x3800, 0x7863, 0x0000, 0x2fa0, 0x2009, 0x031b, - 0x2011, 0x0000, 0x20a9, 0x0040, 0x42a4, 0x8109, 0x00c0, 0x1062, - 0x789b, 0x0101, 0x780b, 0x0002, 0x780f, 0x0002, 0x784f, 0x0bb8, - 0x2009, 0x3835, 0x200b, 0x0003, 0x78bb, 0x0000, 0x78bf, 0x0000, - 0x78c3, 0x0000, 0x2069, 0x3840, 0x00a8, 0x1085, 0x681b, 0x003c, - 0x2009, 0x1313, 0x21b8, 0x0078, 0x1087, 0x681b, 0x0028, 0x6807, - 0x0007, 0x680b, 0x00fa, 0x680f, 0x0008, 0x6813, 0x0005, 0x681f, - 0x0000, 0x6823, 0x0006, 0x6817, 0x0008, 0x6827, 0x0000, 0x2069, - 0x3a80, 0x2011, 0x0020, 0x2009, 0x0010, 0x680b, 0x0c19, 0x680f, - 0x0019, 0x6803, 0xdd00, 0x6807, 0x001a, 0x6a1a, 0x2d00, 0xa0e8, - 0x0008, 0xa290, 0x0004, 0x8109, 0x00c0, 0x109d, 0x2069, 0x3b00, - 0x2009, 0x0002, 0x20a9, 0x0100, 0x683f, 0x0000, 0x2001, 0x0008, - 0x8007, 0x6832, 0x6837, 0x000a, 0x680b, 0x0040, 0x6817, 0x0100, - 0x681f, 0x0064, 0xade8, 0x0010, 0x0070, 0x10c8, 0x0078, 0x10b4, - 0x8109, 0x00c0, 0x10b2, 0x1078, 0x1b64, 0x1078, 0x31c0, 0x1078, - 0x1747, 0x1078, 0x368b, 0x3200, 0xa085, 0x000d, 0x2090, 0x70c3, - 0x0000, 0x0090, 0x10e2, 0x70c0, 0xa086, 0x0002, 0x00c0, 0x10e2, - 0x1078, 0x11e0, 0x1078, 0x1112, 0x1078, 0x18f2, 0x1078, 0x1aaf, - 0x1078, 0x34fd, 0x1078, 0x184d, 0x0078, 0x10e2, 0x10f6, 0x10f8, - 0x1d05, 0x1d05, 0x321e, 0x321e, 0x1d05, 0x1d05, 0x0078, 0x10f6, - 0x0078, 0x10f8, 0x0078, 0x10fa, 0x0078, 0x10fc, 0x7008, 0x800c, - 0x00c8, 0x110d, 0x7007, 0x0002, 0xa08c, 0x000c, 0x00c0, 0x110e, - 0x8004, 0x8004, 0x00c8, 0x110d, 0x087a, 0x097a, 0x70c3, 0x4002, - 0x0078, 0x11e3, 0x7814, 0xa005, 0x00c0, 0x111a, 0x0010, 0x1156, - 0x0078, 0x1155, 0x2009, 0x3868, 0x2104, 0xa005, 0x00c0, 0x1155, - 0x7814, 0xa086, 0x0001, 0x00c0, 0x1127, 0x1078, 0x15ae, 0x7817, - 0x0000, 0x2009, 0x386f, 0x2104, 0xa065, 0x0040, 0x1143, 0x2009, - 0x386a, 0x211c, 0x8108, 0x2114, 0x8108, 0x2104, 0xa210, 0xa399, - 0x0000, 0x2009, 0x0018, 0x6083, 0x0103, 0x1078, 0x16d7, 0x00c0, - 0x114f, 0x1078, 0x173e, 0x2009, 0x386f, 0x200b, 0x0000, 0x2009, - 0x3869, 0x2104, 0x200b, 0x0000, 0xa005, 0x0040, 0x1153, 0x2001, - 0x4005, 0x0078, 0x11e2, 0x0078, 0x11e0, 0x007c, 0x2061, 0x0000, - 0x6018, 0xa084, 0x0001, 0x0040, 0x115e, 0x007c, 0x70c3, 0x0000, - 0x70c7, 0x0000, 0x70cb, 0x0000, 0x70cf, 0x0000, 0x70c0, 0xa0bc, - 0xffc0, 0x00c0, 0x11ae, 0x2038, 0x0079, 0x116e, 0x11e0, 0x122e, - 0x11fc, 0x122e, 0x127f, 0x127f, 0x11f3, 0x1608, 0x128a, 0x11ef, - 0x1200, 0x1202, 0x1204, 0x1206, 0x160d, 0x11ef, 0x1292, 0x12ba, - 0x15bc, 0x1602, 0x1208, 0x14e3, 0x1505, 0x151f, 0x1548, 0x149c, - 0x14aa, 0x14be, 0x14d2, 0x1357, 0x1332, 0x12e2, 0x12e9, 0x12ee, - 0x12f3, 0x12f9, 0x12fe, 0x1303, 0x1308, 0x130d, 0x1311, 0x1326, - 0x11ef, 0x11ef, 0x11ef, 0x11ef, 0x11ef, 0x1363, 0x136c, 0x137b, - 0x13a1, 0x13ab, 0x13b2, 0x13d8, 0x13e7, 0x13f6, 0x1408, 0x147a, - 0x11ef, 0x148a, 0x11ef, 0x11ef, 0x11ef, 0x1491, 0xa0bc, 0xffa0, - 0x00c0, 0x11ef, 0x2038, 0xa084, 0x001f, 0x0079, 0x11b7, 0x11ef, - 0x11ef, 0x11ef, 0x11ef, 0x11ef, 0x11ef, 0x11ef, 0x11ef, 0x11ef, - 0x11ef, 0x11ef, 0x11ef, 0x11ef, 0x11ef, 0x1665, 0x1674, 0x11ef, - 0x11ef, 0x11ef, 0x11ef, 0x11ef, 0x11ef, 0x11ef, 0x11ef, 0x11ef, - 0x11ef, 0x16b3, 0x16bd, 0x16c1, 0x16cf, 0x167f, 0x169c, 0x72ca, - 0x71c6, 0x2001, 0x4006, 0x0078, 0x11e2, 0x73ce, 0x72ca, 0x71c6, - 0x2001, 0x4000, 0x70c2, 0x2061, 0x0000, 0x601b, 0x0001, 0x2091, - 0x5000, 0x2091, 0x4080, 0x007c, 0x71c6, 0x0078, 0x11e2, 0x70c3, - 0x4001, 0x0078, 0x11e3, 0x2099, 0x0041, 0x20a1, 0x0041, 0x20a9, - 0x0005, 0x53a3, 0x0078, 0x11e0, 0x70c4, 0x70c3, 0x0004, 0x007a, - 0x0078, 0x11e0, 0x0078, 0x11e0, 0x0078, 0x11e0, 0x0078, 0x11e0, - 0x2091, 0x8000, 0x70c3, 0x0000, 0x70c7, 0x4953, 0x70cb, 0x5020, - 0x70cf, 0x2020, 0x70d3, 0x0001, 0x3f00, 0x70d6, 0x2079, 0x0000, - 0x781b, 0x0001, 0x2031, 0x0030, 0x2059, 0x1000, 0x2029, 0x0457, - 0x2051, 0x0470, 0x2061, 0x0472, 0x20b9, 0xffff, 0x20c1, 0x0000, - 0x2091, 0x5000, 0x2091, 0x4080, 0x0078, 0x0455, 0x71d0, 0x72c8, - 0x73cc, 0x70c4, 0x20a0, 0x2098, 0x2031, 0x0030, 0x81ff, 0x0040, - 0x11e0, 0x7007, 0x0004, 0x731a, 0x721e, 0x2051, 0x0012, 0x2049, - 0x125d, 0x2041, 0x11e0, 0x7003, 0x0002, 0xa786, 0x0001, 0x00c0, - 0x124f, 0x2049, 0x126b, 0x2041, 0x1277, 0x7003, 0x0003, 0x7017, - 0x0000, 0x810b, 0x7112, 0x00c8, 0x1257, 0x7017, 0x0001, 0x7007, - 0x0001, 0xa786, 0x0001, 0x0040, 0x126b, 0x700c, 0xa084, 0x007f, - 0x8004, 0x2009, 0x0020, 0xa102, 0x0942, 0x094a, 0x20a8, 0x26a0, - 0x53a6, 0x0078, 0x10fe, 0x700c, 0xa084, 0x007f, 0x0040, 0x126b, - 0x80ac, 0x0048, 0x126b, 0x2698, 0x53a5, 0x0078, 0x10fe, 0x700c, - 0xa084, 0x007f, 0x80ac, 0x2698, 0x53a5, 0x0078, 0x11e0, 0x71c4, - 0x70c8, 0x2114, 0xa79e, 0x0004, 0x00c0, 0x1287, 0x200a, 0x72ca, - 0x0078, 0x11df, 0x70c7, 0x0125, 0x70cb, 0x0000, 0x70cf, 0x0f00, - 0x0078, 0x11e0, 0x70c4, 0x72c8, 0x73cc, 0x74d0, 0x70c6, 0x72ca, - 0x73ce, 0x74d2, 0xa005, 0x0040, 0x12b4, 0x8001, 0x7872, 0xa084, - 0xfc00, 0x0040, 0x12ab, 0x7898, 0xa085, 0x0001, 0x789a, 0x2001, - 0x4005, 0x0078, 0x11e2, 0x7a7a, 0x7b7e, 0x7c76, 0x7898, 0xa084, - 0xfffc, 0x789a, 0x0078, 0x12b8, 0x7898, 0xa085, 0x0001, 0x789a, - 0x0078, 0x11e0, 0x70c4, 0x72c8, 0x73cc, 0x74d4, 0x70c6, 0x72ca, - 0x73ce, 0x74d6, 0xa005, 0x0040, 0x12dc, 0x8001, 0x7886, 0xa084, - 0xfc00, 0x0040, 0x12d3, 0x7898, 0xa085, 0x0100, 0x789a, 0x2001, - 0x4005, 0x0078, 0x11e2, 0x7a8e, 0x7b92, 0x7c8a, 0x7898, 0xa084, - 0xfcff, 0x789a, 0x0078, 0x12e0, 0x7898, 0xa085, 0x0100, 0x789a, - 0x0078, 0x11e0, 0x2009, 0x3859, 0x210c, 0x2011, 0x0372, 0x0078, - 0x11de, 0x2009, 0x3841, 0x210c, 0x0078, 0x11df, 0x2009, 0x3842, - 0x210c, 0x0078, 0x11df, 0x2061, 0x3840, 0x610c, 0x6210, 0x0078, - 0x11de, 0x2009, 0x3845, 0x210c, 0x0078, 0x11df, 0x2009, 0x3846, - 0x210c, 0x0078, 0x11df, 0x2009, 0x3847, 0x210c, 0x0078, 0x11df, - 0x2009, 0x3848, 0x210c, 0x0078, 0x11df, 0x7908, 0x7a0c, 0x0078, - 0x11de, 0x71c4, 0x8107, 0xa084, 0x000f, 0x8003, 0x8003, 0x8003, - 0xa0e8, 0x3a80, 0x6a00, 0x6804, 0xa084, 0x0008, 0x0040, 0x1323, - 0x6b08, 0x0078, 0x1324, 0x6b0c, 0x0078, 0x11dd, 0x77c4, 0x1078, - 0x1758, 0x2091, 0x8000, 0x6b1c, 0x6a14, 0x2091, 0x8001, 0x2708, - 0x0078, 0x11dd, 0x2091, 0x8000, 0x7848, 0xa005, 0x00c0, 0x1346, - 0x2061, 0x3b00, 0x20a9, 0x0100, 0x603c, 0xa005, 0x00c0, 0x1346, - 0xace0, 0x0010, 0x00f0, 0x133c, 0x0078, 0x134e, 0x2019, 0x0000, - 0x2011, 0x0000, 0x2009, 0x0000, 0x0078, 0x1353, 0x7bb8, 0x7abc, - 0x79c0, 0x78c3, 0x0000, 0x2091, 0x8001, 0x0078, 0x11dd, 0x77c4, - 0x1078, 0x1758, 0x2091, 0x8000, 0x6908, 0x6a18, 0x6b10, 0x2091, - 0x8001, 0x0078, 0x11dd, 0x71c4, 0xa182, 0x0010, 0x00c8, 0x11d8, - 0x1078, 0x1be8, 0x0078, 0x11dd, 0x71c4, 0xa182, 0x0010, 0x00c8, - 0x11d8, 0x2011, 0x3841, 0x2204, 0x007e, 0x2112, 0x1078, 0x1ba1, - 0x017f, 0x0078, 0x11df, 0x71c4, 0x2011, 0x1399, 0x20a9, 0x0008, - 0x2204, 0xa106, 0x0040, 0x138b, 0x8210, 0x0070, 0x1389, 0x0078, - 0x1380, 0x0078, 0x11d8, 0xa292, 0x1399, 0x027e, 0x2011, 0x3842, - 0x2204, 0x2112, 0x017f, 0x007e, 0x1078, 0x1bad, 0x017f, 0x0078, - 0x11df, 0x03e8, 0x00fa, 0x01f4, 0x02ee, 0x0064, 0x0019, 0x0032, - 0x004b, 0x2061, 0x3840, 0x610c, 0x6210, 0x70c4, 0x600e, 0x70c8, - 0x6012, 0x0078, 0x11de, 0x2061, 0x3840, 0x6114, 0x70c4, 0x6016, - 0x0078, 0x11df, 0x71c4, 0x2011, 0x0004, 0x2019, 0x1212, 0xa186, - 0x0028, 0x0040, 0x13cb, 0x2011, 0x0005, 0x2019, 0x1212, 0xa186, - 0x0032, 0x0040, 0x13cb, 0x2011, 0x0006, 0x2019, 0x1313, 0xa186, - 0x003c, 0x00c0, 0x11d8, 0x2061, 0x3840, 0x6018, 0x007e, 0x611a, - 0x23b8, 0x1078, 0x1bbe, 0x1078, 0x368b, 0x017f, 0x0078, 0x11df, - 0x71c4, 0xa184, 0xffcf, 0x00c0, 0x11d8, 0x2011, 0x3847, 0x2204, - 0x2112, 0x007e, 0x1078, 0x1be0, 0x017f, 0x0078, 0x11df, 0x71c4, - 0xa182, 0x0010, 0x00c8, 0x11d8, 0x2011, 0x3848, 0x2204, 0x007e, - 0x2112, 0x1078, 0x1bcf, 0x017f, 0x0078, 0x11df, 0x71c4, 0x72c8, - 0xa184, 0xfffd, 0x00c0, 0x11d7, 0xa284, 0xfffd, 0x00c0, 0x11d7, - 0x2100, 0x7908, 0x780a, 0x2200, 0x7a0c, 0x780e, 0x0078, 0x11de, - 0x71c4, 0x8107, 0xa084, 0x000f, 0x8003, 0x8003, 0x8003, 0xa0e8, - 0x3a80, 0x2019, 0x0000, 0x72c8, 0x6800, 0x007e, 0xa226, 0x0040, - 0x1440, 0xa284, 0x0001, 0x0040, 0x1422, 0x2220, 0xa39d, 0x0002, - 0xa294, 0xfffe, 0x6a02, 0xa484, 0x2000, 0x0040, 0x1429, 0xa39d, - 0x0010, 0xa484, 0x1000, 0x0040, 0x142f, 0xa39d, 0x0008, 0xa484, - 0x4000, 0x0040, 0x1440, 0x810f, 0xa284, 0x4000, 0x0040, 0x143c, - 0x1078, 0x1c02, 0x0078, 0x1440, 0x1078, 0x1bf4, 0x0078, 0x1440, - 0x72cc, 0x82ff, 0x0040, 0x1472, 0x6808, 0xa206, 0x0040, 0x1472, - 0xa2a4, 0x00ff, 0x2061, 0x3840, 0x6118, 0xa186, 0x0028, 0x0040, - 0x1459, 0xa186, 0x0032, 0x0040, 0x145f, 0xa186, 0x003c, 0x0040, - 0x1465, 0xa482, 0x0064, 0x0048, 0x146f, 0x0078, 0x1469, 0xa482, - 0x0050, 0x0048, 0x146f, 0x0078, 0x1469, 0xa482, 0x0043, 0x0048, - 0x146f, 0x71c4, 0x71c6, 0x027f, 0x72ca, 0x0078, 0x11d9, 0x6a0a, - 0xa39d, 0x000a, 0x6804, 0xa305, 0x6806, 0x027f, 0x6b0c, 0x71c4, - 0x0078, 0x11dd, 0x77c4, 0x1078, 0x1758, 0x2091, 0x8000, 0x6a14, - 0x6b1c, 0x2091, 0x8001, 0x70c8, 0x6816, 0x70cc, 0x681e, 0x2708, - 0x0078, 0x11dd, 0x2011, 0x3835, 0x220c, 0x70c4, 0x2012, 0x0078, - 0x11df, 0x71c4, 0x72c8, 0x73cc, 0xa182, 0x0010, 0x00c8, 0x11d8, - 0x1078, 0x1c10, 0x0078, 0x11dd, 0x77c4, 0x1078, 0x1758, 0x2091, - 0x8000, 0x6a08, 0xa295, 0x0002, 0x6a0a, 0x2091, 0x8001, 0x2708, - 0x0078, 0x11de, 0x77c4, 0x1078, 0x1758, 0x2091, 0x8000, 0x6a08, - 0xa294, 0xfff9, 0x6a0a, 0x6804, 0xa005, 0x0040, 0x14b9, 0x1078, - 0x1b49, 0x2091, 0x8001, 0x2708, 0x0078, 0x11de, 0x77c4, 0x1078, - 0x1758, 0x2091, 0x8000, 0x6a08, 0xa295, 0x0004, 0x6a0a, 0x6804, - 0xa005, 0x0040, 0x14cd, 0x1078, 0x1b49, 0x2091, 0x8001, 0x2708, - 0x0078, 0x11de, 0x77c4, 0x2041, 0x0001, 0x2049, 0x0005, 0x2051, - 0x0020, 0x2091, 0x8000, 0x1078, 0x1765, 0x2091, 0x8001, 0x2708, - 0x6a08, 0x0078, 0x11de, 0x77c4, 0x72c8, 0x73cc, 0x77c6, 0x72ca, - 0x73ce, 0x1078, 0x17e6, 0x00c0, 0x1501, 0x6818, 0xa005, 0x0040, - 0x14fb, 0x2708, 0x1078, 0x1c20, 0x00c0, 0x14fb, 0x7817, 0xffff, - 0x2091, 0x8001, 0x007c, 0x2091, 0x8001, 0x2001, 0x4005, 0x0078, - 0x11e2, 0x2091, 0x8001, 0x0078, 0x11e0, 0x77c4, 0x77c6, 0x2041, - 0x0021, 0x2049, 0x0005, 0x2051, 0x0020, 0x2091, 0x8000, 0x1078, - 0x1765, 0x2061, 0x3840, 0x60a3, 0x0003, 0x67b6, 0x60a7, 0x0000, - 0x7817, 0xffff, 0x1078, 0x1b49, 0x2091, 0x8001, 0x007c, 0x77c8, - 0x77ca, 0x77c4, 0x77c6, 0xa7bc, 0xff00, 0x2091, 0x8000, 0x2061, - 0x3840, 0x60a3, 0x0002, 0x60a7, 0x0000, 0x67b6, 0x7817, 0xffff, - 0x1078, 0x1b49, 0x2091, 0x8001, 0x2041, 0x0021, 0x2049, 0x0004, - 0x2051, 0x0010, 0x2091, 0x8000, 0x1078, 0x1765, 0x70c8, 0x683e, - 0x8738, 0xa784, 0x001f, 0x00c0, 0x153c, 0x2091, 0x8001, 0x007c, - 0x7898, 0xa084, 0x0003, 0x00c0, 0x156c, 0x2039, 0x0000, 0x2041, - 0x0021, 0x2049, 0x0004, 0x2051, 0x0008, 0x1078, 0x1758, 0x2091, - 0x8000, 0x6808, 0xa80d, 0x690a, 0x2091, 0x8001, 0x8738, 0xa784, - 0x001f, 0x00c0, 0x1555, 0xa7bc, 0xff00, 0x873f, 0x8738, 0x873f, - 0xa784, 0x0f00, 0x00c0, 0x1555, 0x2091, 0x8000, 0x2069, 0x0100, - 0x6830, 0xa084, 0x0040, 0x0040, 0x1595, 0x684b, 0x0004, 0x20a9, - 0x0014, 0x6848, 0xa084, 0x0004, 0x0040, 0x1582, 0x0070, 0x1582, - 0x0078, 0x1579, 0x684b, 0x0009, 0x20a9, 0x0014, 0x6848, 0xa084, - 0x0001, 0x0040, 0x158f, 0x0070, 0x158f, 0x0078, 0x1586, 0x20a9, - 0x00fa, 0x0070, 0x1595, 0x0078, 0x1591, 0x2079, 0x3800, 0x7817, - 0x0001, 0x2061, 0x3840, 0x60a3, 0x0001, 0x60a7, 0x0000, 0x60c3, - 0x000f, 0x7898, 0xa085, 0x0002, 0x789a, 0x6808, 0xa084, 0xfffd, - 0x680a, 0x681b, 0x0046, 0x2091, 0x8001, 0x007c, 0x7898, 0xa084, - 0xfffd, 0x789a, 0xa084, 0x0001, 0x00c0, 0x15b8, 0x1078, 0x1830, - 0x71c4, 0x71c6, 0x794a, 0x007c, 0x74c4, 0x73c8, 0x72cc, 0x74c6, - 0x73ca, 0x72ce, 0x2079, 0x3800, 0x2009, 0x0040, 0x1078, 0x1735, - 0x0040, 0x15fe, 0x1078, 0x1705, 0x0040, 0x15d2, 0x1078, 0x173e, - 0x0078, 0x15fe, 0x6010, 0x2091, 0x8000, 0x7817, 0xffff, 0x2009, - 0x3868, 0x200b, 0x0005, 0x8108, 0x200b, 0x0000, 0x8108, 0x230a, - 0x8108, 0x220a, 0x8108, 0x240a, 0x8108, 0x200a, 0x8108, 0x200b, - 0x0000, 0x8108, 0x2c0a, 0xa02e, 0x2530, 0x0e7e, 0x1078, 0x3199, - 0x0e7f, 0x6592, 0x65a2, 0x6696, 0x66a6, 0x60ab, 0x0000, 0x60af, - 0x0000, 0x1078, 0x1b49, 0x2091, 0x8001, 0x007c, 0x70c3, 0x4005, - 0x0078, 0x11e3, 0x71c4, 0x70c7, 0x0000, 0x7906, 0x0078, 0x11e0, - 0x71c4, 0x71c6, 0x2168, 0x0078, 0x160f, 0x2069, 0x1000, 0x690c, - 0xa016, 0x2d04, 0xa210, 0x8d68, 0x8109, 0x00c0, 0x1611, 0xa285, - 0x0000, 0x00c0, 0x161f, 0x70c3, 0x4000, 0x0078, 0x1621, 0x70c3, - 0x4003, 0x70ca, 0x0078, 0x11e3, 0x71c4, 0x72c8, 0x73cc, 0x2100, - 0xa184, 0xfffc, 0x00c0, 0x11ef, 0x2100, 0x0079, 0x162f, 0x1646, - 0x165b, 0x165d, 0x165f, 0x70c3, 0x4003, 0x71ce, 0x72d2, 0x73d6, - 0x0078, 0x1642, 0x70c3, 0x4000, 0x70cf, 0x0000, 0x70d3, 0x0000, - 0x70d7, 0x0000, 0x77c6, 0x71ca, 0x0078, 0x11e0, 0x2031, 0x1661, - 0x2624, 0x8630, 0x2412, 0x2204, 0xa446, 0x00c0, 0x1633, 0xa484, - 0xffff, 0x00c0, 0x1648, 0x2031, 0x1661, 0x8210, 0x8319, 0xa384, - 0xffff, 0x00c0, 0x1648, 0x0078, 0x163a, 0x0078, 0x163a, 0x0078, - 0x163a, 0x5555, 0xaaaa, 0xffff, 0x0000, 0x77c4, 0x1078, 0x1758, - 0x2091, 0x8000, 0x6830, 0xa084, 0xff00, 0x8007, 0x2010, 0x2091, - 0x8001, 0x2708, 0x0078, 0x11de, 0x77c4, 0x1078, 0x1758, 0x2091, - 0x8000, 0x6a34, 0x2091, 0x8001, 0x2708, 0x0078, 0x11de, 0x77c4, - 0x077e, 0xa7bc, 0xff00, 0x20a9, 0x0020, 0x72c8, 0x8217, 0xa294, - 0xff00, 0x1078, 0x1758, 0x2091, 0x8000, 0x6c30, 0x6a32, 0x2091, - 0x8001, 0x8738, 0x00f0, 0x1689, 0x077f, 0x2708, 0x8427, 0xa4a4, - 0x00ff, 0x2410, 0x0078, 0x11de, 0x77c4, 0x077e, 0xa7bc, 0xff00, - 0x20a9, 0x0020, 0x72c8, 0x1078, 0x1758, 0x2091, 0x8000, 0x6c34, - 0x6a36, 0x2091, 0x8001, 0x8738, 0x00f0, 0x16a3, 0x077f, 0x2708, - 0x2410, 0x0078, 0x11de, 0x7960, 0x71c6, 0x71c4, 0xa182, 0x0003, - 0x00c8, 0x11d8, 0x7962, 0x0078, 0x11e0, 0x7960, 0x71c6, 0x0078, - 0x11e0, 0x7954, 0x71c6, 0x71c4, 0x7956, 0x7958, 0x71ca, 0x71c8, - 0x795a, 0x795c, 0x71ce, 0x71cc, 0x795e, 0x0078, 0x11e0, 0x7954, - 0x71c6, 0x7958, 0x71ca, 0x795c, 0x71ce, 0x0078, 0x11e0, 0x700c, - 0xa084, 0x007f, 0x0040, 0x16e3, 0x7007, 0x0004, 0x7004, 0xa084, - 0x0004, 0x00c0, 0x16de, 0x7017, 0x0000, 0x7112, 0x721a, 0x731e, - 0x8108, 0x810c, 0x81a9, 0x8c98, 0x20a1, 0x0030, 0x6080, 0x20a2, - 0x53a6, 0x780c, 0xa085, 0x0000, 0x7002, 0x7007, 0x0001, 0x7108, - 0x8104, 0x00c8, 0x16f7, 0x7007, 0x0002, 0xa184, 0x000c, 0x710c, - 0xa184, 0x0300, 0x7003, 0x0000, 0x007c, 0x700c, 0xa084, 0x007f, - 0x0040, 0x1711, 0x7007, 0x0004, 0x7004, 0xa084, 0x0004, 0x00c0, - 0x170c, 0x7017, 0x0000, 0x7112, 0x721a, 0x731e, 0x2099, 0x0030, - 0x8108, 0x81ac, 0x780c, 0xa085, 0x0001, 0x7002, 0x7007, 0x0001, - 0x7008, 0x800c, 0x00c8, 0x1720, 0x7007, 0x0002, 0xa08c, 0x000c, - 0x00c0, 0x1732, 0x710c, 0xa184, 0x0300, 0x00c0, 0x1732, 0x2ca0, - 0x53a5, 0xa006, 0x7003, 0x0000, 0x007c, 0x7850, 0xa065, 0x0040, - 0x173d, 0x2c04, 0x7852, 0x2063, 0x0000, 0x007c, 0x0f7e, 0x2079, - 0x3800, 0x7850, 0x2062, 0x2c00, 0x7852, 0x0f7f, 0x007c, 0x2011, - 0x5d00, 0x7a52, 0x2019, 0x0372, 0x8319, 0x0040, 0x1755, 0xa280, - 0x002f, 0x2012, 0x2010, 0x0078, 0x174c, 0x2013, 0x0000, 0x007c, - 0xa784, 0x0f00, 0x800b, 0xa784, 0x001f, 0x8003, 0x8003, 0x8003, - 0x8003, 0xa105, 0xa0e8, 0x3b00, 0x007c, 0x1078, 0x1758, 0x2900, - 0x682a, 0x2a00, 0x682e, 0x6808, 0xa084, 0xffef, 0xa80d, 0x690a, - 0x2091, 0x8000, 0x2009, 0x384f, 0x210c, 0x6804, 0xa005, 0x0040, - 0x1784, 0xa116, 0x00c0, 0x1784, 0x2060, 0x6000, 0x6806, 0x017e, - 0x200b, 0x0000, 0x0078, 0x1787, 0x2009, 0x0000, 0x017e, 0x6804, - 0xa065, 0x0040, 0x1798, 0x6000, 0x6806, 0x1078, 0x17ad, 0x1078, - 0x18a4, 0x1078, 0x2b27, 0x6810, 0x8001, 0x6812, 0x00c0, 0x1787, - 0x1078, 0x2b27, 0x017f, 0x6902, 0x6906, 0x2091, 0x8001, 0x007c, - 0xa065, 0x0040, 0x17ac, 0x6098, 0x609b, 0x0000, 0x2008, 0x1078, - 0x173e, 0x2100, 0x0078, 0x17a0, 0x007c, 0x6003, 0x0103, 0x20a9, - 0x001c, 0xac80, 0x0004, 0x20a0, 0x2001, 0x0000, 0x40a4, 0x6828, - 0x6016, 0x682c, 0x601e, 0x007c, 0x0e7e, 0x2071, 0x3840, 0x7040, - 0xa08c, 0x0200, 0x00c0, 0x17ca, 0xa088, 0x3880, 0x2d0a, 0x8000, - 0x7042, 0xa006, 0x0e7f, 0x007c, 0x0e7e, 0x2071, 0x3840, 0x2009, - 0x3880, 0x7240, 0x8221, 0x8211, 0x0048, 0x17e4, 0x2104, 0x8108, - 0xad06, 0x00c0, 0x17d3, 0x8119, 0x211e, 0x8108, 0x8318, 0x8211, - 0x00c8, 0x17dc, 0x7442, 0xa006, 0x0e7f, 0x007c, 0x1078, 0x1758, - 0x2091, 0x8000, 0x6804, 0x781e, 0xa065, 0x0040, 0x182f, 0x0078, - 0x17f7, 0x2c00, 0x781e, 0x6000, 0xa065, 0x0040, 0x182f, 0x600c, - 0xa306, 0x00c0, 0x17f1, 0x6008, 0xa206, 0x00c0, 0x17f1, 0x2c28, - 0x2001, 0x384f, 0x2004, 0xac06, 0x0040, 0x182f, 0x6804, 0xac06, - 0x00c0, 0x1814, 0x6000, 0x2060, 0x6806, 0xa005, 0x00c0, 0x1814, - 0x6803, 0x0000, 0x0078, 0x181e, 0x6400, 0x781c, 0x2060, 0x6402, - 0xa486, 0x0000, 0x00c0, 0x181e, 0x2c00, 0x6802, 0x2560, 0x1078, - 0x17ad, 0x6017, 0x0005, 0x601f, 0x0020, 0x1078, 0x18a4, 0x1078, - 0x2b27, 0x6810, 0x8001, 0x6812, 0x2001, 0xffff, 0xa005, 0x007c, - 0x2039, 0x0000, 0x2041, 0x0021, 0x2049, 0x0004, 0x2051, 0x0008, - 0x2091, 0x8000, 0x1078, 0x1765, 0x8738, 0xa784, 0x001f, 0x00c0, - 0x183a, 0xa7bc, 0xff00, 0x873f, 0x8738, 0x873f, 0xa784, 0x0f00, - 0x00c0, 0x183a, 0x2091, 0x8001, 0x007c, 0x0068, 0x185c, 0x2061, - 0x0000, 0x6018, 0xa084, 0x0001, 0x00c0, 0x185c, 0x78ac, 0x78af, - 0x0000, 0xa005, 0x00c0, 0x185d, 0x007c, 0xa08c, 0xfff0, 0x0040, - 0x1863, 0x1078, 0x1ce7, 0x0079, 0x1865, 0x1875, 0x1877, 0x187d, - 0x1881, 0x1875, 0x1885, 0x1875, 0x1875, 0x188b, 0x1875, 0x1892, - 0x1896, 0x1875, 0x1875, 0x1875, 0x1875, 0x1078, 0x1ce7, 0x1078, - 0x1830, 0x2001, 0x8001, 0x0078, 0x189c, 0x2001, 0x8003, 0x0078, - 0x189c, 0x2001, 0x8004, 0x0078, 0x189c, 0x1078, 0x1830, 0x2001, - 0x8006, 0x0078, 0x189c, 0x2001, 0x8009, 0x2011, 0x382c, 0x220c, - 0x0078, 0x11ec, 0x2001, 0x800c, 0x0078, 0x189c, 0x1078, 0x1830, - 0x2001, 0x800d, 0x0078, 0x189c, 0x70c2, 0x2061, 0x0000, 0x601b, - 0x0001, 0x2091, 0x4080, 0x007c, 0x2c04, 0x6082, 0x2c08, 0x2063, - 0x0000, 0x7864, 0x8000, 0x7866, 0x7868, 0xa005, 0x796a, 0x0040, - 0x18b4, 0x2c02, 0x0078, 0x18b5, 0x796e, 0x007c, 0x0c7e, 0x2061, - 0x3800, 0x6883, 0x0103, 0x2d08, 0x206b, 0x0000, 0x6064, 0x8000, - 0x6066, 0x6068, 0xa005, 0x616a, 0x0040, 0x18c9, 0x2d02, 0x0078, - 0x18cc, 0x616e, 0x1078, 0x2b41, 0x0c7f, 0x007c, 0x1078, 0x18df, - 0x0040, 0x18de, 0x0c7e, 0x6098, 0xa065, 0x0040, 0x18d9, 0x1078, - 0x17a0, 0x0c7f, 0x609b, 0x0000, 0x1078, 0x173e, 0x007c, 0x786c, - 0xa065, 0x0040, 0x18f1, 0x2091, 0x8000, 0x7864, 0x8001, 0x7866, - 0x2c04, 0x786e, 0xa005, 0x00c0, 0x18ef, 0x786a, 0x8000, 0x2091, - 0x8001, 0x007c, 0x7898, 0xa005, 0x00c0, 0x194d, 0x7974, 0x70d0, - 0x0005, 0x0005, 0x72d0, 0xa206, 0x00c0, 0x18f7, 0x2200, 0xa106, - 0x00c0, 0x190e, 0x7804, 0xa005, 0x0040, 0x194d, 0x7807, 0x0000, - 0x0068, 0x194d, 0x2091, 0x4080, 0x0078, 0x194d, 0x1078, 0x1735, - 0x0040, 0x194d, 0x7a7c, 0x7b78, 0xa184, 0xff00, 0x0040, 0x1921, - 0x810f, 0x810c, 0x810c, 0x8004, 0x8004, 0x8007, 0xa100, 0x0078, - 0x1924, 0x8107, 0x8004, 0x8004, 0xa210, 0xa399, 0x0000, 0x2009, - 0x0040, 0x1078, 0x1705, 0x0040, 0x1944, 0x1078, 0x173e, 0x7880, - 0x8000, 0x7882, 0xa086, 0x0002, 0x00c0, 0x194d, 0x2091, 0x8000, - 0x78af, 0x0002, 0x7883, 0x0000, 0x7898, 0xa085, 0x0003, 0x789a, - 0x2091, 0x8001, 0x0078, 0x194d, 0x7883, 0x0000, 0x1078, 0x1a99, - 0x6000, 0xa084, 0x0007, 0x0079, 0x194e, 0x007c, 0x1956, 0x1965, - 0x1985, 0x1956, 0x1997, 0x1956, 0x1956, 0x1956, 0x2039, 0x0400, - 0x78a8, 0xa705, 0x78aa, 0x6004, 0xa705, 0x6006, 0x1078, 0x19e2, - 0x6018, 0x78a6, 0x1078, 0x1a81, 0x007c, 0x78a8, 0xa084, 0x0100, - 0x0040, 0x196c, 0x0078, 0x1956, 0x78ab, 0x0000, 0x6000, 0x8007, - 0xa084, 0x00ff, 0x789e, 0x8001, 0x609b, 0x0000, 0x0040, 0x1982, - 0x1078, 0x19e2, 0x0040, 0x1982, 0x78a8, 0xa085, 0x0100, 0x78aa, - 0x0078, 0x1984, 0x1078, 0x1a06, 0x007c, 0x78a8, 0xa08c, 0x0e00, - 0x00c0, 0x198e, 0xa084, 0x0100, 0x00c0, 0x1990, 0x0078, 0x1956, - 0x1078, 0x19e2, 0x00c0, 0x1996, 0x1078, 0x1a06, 0x007c, 0x78a8, - 0xa084, 0x0100, 0x0040, 0x199e, 0x0078, 0x1956, 0x78ab, 0x0000, - 0x6710, 0x2011, 0x0001, 0x20a9, 0x0001, 0x6014, 0xa084, 0x00ff, - 0xa005, 0x0040, 0x19c1, 0x2011, 0x0001, 0xa7bc, 0xff00, 0x20a9, - 0x0020, 0xa08e, 0x0001, 0x0040, 0x19c1, 0x2039, 0x0000, 0x2011, - 0x0002, 0x20a9, 0x0100, 0xa08e, 0x0002, 0x0040, 0x19c1, 0x0078, - 0x19df, 0x1078, 0x1758, 0x2d00, 0x2091, 0x8000, 0x682b, 0x0000, - 0x682f, 0x0000, 0x6808, 0xa084, 0xffde, 0x680a, 0x2d00, 0xa080, - 0x0010, 0x2068, 0x2091, 0x8001, 0x0070, 0x19d8, 0x0078, 0x19c4, - 0x8211, 0x0040, 0x19df, 0x20a9, 0x0100, 0x0078, 0x19c4, 0x1078, - 0x173e, 0x007c, 0x78a0, 0xa06d, 0x00c0, 0x19ed, 0x2c00, 0x78a2, - 0x78a6, 0x609b, 0x0000, 0x0078, 0x19f9, 0x2c00, 0x689a, 0x609b, - 0x0000, 0x78a2, 0x2d00, 0x6002, 0x78a4, 0xad06, 0x00c0, 0x19f9, - 0x6002, 0x789c, 0x8001, 0x789e, 0x00c0, 0x1a05, 0x78a8, 0xa084, - 0x0000, 0x78aa, 0x78a4, 0x2060, 0xa006, 0x007c, 0xa02e, 0x2530, - 0x6118, 0xa184, 0x0060, 0x619e, 0x0040, 0x1a12, 0x0e7e, 0x1078, - 0x3199, 0x0e7f, 0x6592, 0x65a2, 0x6696, 0x66a6, 0x60ab, 0x0000, - 0x60af, 0x0000, 0x6710, 0x1078, 0x1758, 0x2091, 0x8000, 0x6808, - 0xa084, 0x0001, 0x0040, 0x1a34, 0x2091, 0x8001, 0x1078, 0x17ad, - 0x2091, 0x8000, 0x1078, 0x18a4, 0x2091, 0x8001, 0x78a3, 0x0000, - 0x78a7, 0x0000, 0x0078, 0x1a80, 0x6020, 0xa096, 0x0001, 0x00c0, - 0x1a3b, 0x8000, 0x6022, 0x6a10, 0x6814, 0x2091, 0x8001, 0xa202, - 0x0048, 0x1a4a, 0x0040, 0x1a4a, 0x2039, 0x0200, 0x1078, 0x1a81, - 0x0078, 0x1a80, 0x2c08, 0x2091, 0x8000, 0x6800, 0xa065, 0x0040, - 0x1a52, 0x6102, 0x6902, 0x00c0, 0x1a56, 0x6906, 0x2160, 0x6003, - 0x0000, 0x6810, 0x8000, 0x6812, 0x78b8, 0x8000, 0x78ba, 0x2091, - 0x8001, 0x6808, 0xa08c, 0x0040, 0x0040, 0x1a76, 0xa086, 0x0040, - 0x680a, 0x1078, 0x17bc, 0x017e, 0x007e, 0x6930, 0x2100, 0x810f, - 0xa105, 0x6832, 0x6934, 0x693a, 0x007f, 0x017f, 0x2091, 0x8000, - 0x1078, 0x1b49, 0x2091, 0x8001, 0x78a7, 0x0000, 0x78a3, 0x0000, - 0x007c, 0x6004, 0xa705, 0x6006, 0x2091, 0x8000, 0x1078, 0x18a4, - 0x2091, 0x8001, 0x78a4, 0xa065, 0x0040, 0x1a94, 0x6098, 0x78a6, - 0x609b, 0x0000, 0x0078, 0x1a84, 0x78a3, 0x0000, 0x78a7, 0x0000, - 0x007c, 0x7970, 0x7874, 0x8000, 0xa10a, 0x00c8, 0x1aa0, 0xa006, - 0x7876, 0x70d2, 0x7804, 0xa005, 0x0040, 0x1aae, 0x8001, 0x7806, - 0x00c0, 0x1aae, 0x0068, 0x1aae, 0x2091, 0x4080, 0x007c, 0x0068, - 0x1ac9, 0x2029, 0x0000, 0x786c, 0xa065, 0x0040, 0x1ac4, 0x1078, - 0x1aca, 0x0040, 0x1ac4, 0x057e, 0x1078, 0x1ae8, 0x057f, 0x00c0, - 0x1ac4, 0x8528, 0x0078, 0x1ab3, 0x85ff, 0x0040, 0x1ac9, 0x2091, - 0x4080, 0x007c, 0x2091, 0x8000, 0x7b84, 0x7988, 0x72d4, 0x0005, - 0x0005, 0x70d4, 0xa206, 0x00c0, 0x1ace, 0x2200, 0xa102, 0x00c0, - 0x1ade, 0x2300, 0x2091, 0x8001, 0xa005, 0x007c, 0x0048, 0x1ae4, - 0xa302, 0x2091, 0x8001, 0x007c, 0x8002, 0x2091, 0x8001, 0x007c, - 0x2091, 0x8000, 0x2071, 0x0020, 0x7004, 0xa005, 0x00c0, 0x1b3f, - 0x7008, 0x7208, 0xa206, 0x00c0, 0x1b3f, 0xa286, 0x0002, 0x00c0, - 0x1b3f, 0x2071, 0x0010, 0xa184, 0xff00, 0x0040, 0x1b08, 0x810f, - 0x810c, 0x810c, 0x8004, 0x8004, 0x8007, 0xa100, 0x0078, 0x1b0b, - 0x8107, 0x8004, 0x8004, 0x7a90, 0x7b8c, 0xa210, 0xa399, 0x0000, - 0x2009, 0x0018, 0x6024, 0xa005, 0x0040, 0x1b18, 0x2009, 0x0040, - 0x1078, 0x16d7, 0x0040, 0x1b31, 0x7894, 0x8000, 0x7896, 0xa086, - 0x0002, 0x00c0, 0x1b3f, 0x2091, 0x8000, 0x78af, 0x0003, 0x7897, - 0x0000, 0x7898, 0xa085, 0x0300, 0x789a, 0x2091, 0x8001, 0x0078, - 0x1b3f, 0x7897, 0x0000, 0x1078, 0x18ce, 0x7984, 0x7888, 0x8000, - 0xa10a, 0x00c8, 0x1b3c, 0xa006, 0x788a, 0x70d6, 0xa006, 0x2071, - 0x0010, 0x2091, 0x8001, 0x007c, 0x2009, 0x3868, 0x2091, 0x8000, - 0x200a, 0x0f7e, 0x2079, 0x0100, 0x2009, 0x3840, 0x2104, 0xa086, - 0x0000, 0x00c0, 0x1b62, 0x2009, 0x3812, 0x2104, 0xa005, 0x00c0, - 0x1b62, 0x7830, 0xa084, 0x00c0, 0x00c0, 0x1b62, 0x0018, 0x1b62, - 0x781b, 0x0044, 0x0f7f, 0x007c, 0x127e, 0x2091, 0x2300, 0x2071, - 0x3840, 0x2079, 0x0100, 0x2019, 0x305e, 0x20a1, 0x012b, 0x2304, - 0xa005, 0x0040, 0x1b7c, 0x789a, 0x8318, 0x23ac, 0x8318, 0x2398, - 0x53a6, 0x3318, 0x0078, 0x1b6f, 0x789b, 0x0020, 0x20a9, 0x0010, - 0x78af, 0x0000, 0x78af, 0x0220, 0x0070, 0x1b88, 0x0078, 0x1b80, - 0x7003, 0x0000, 0x1078, 0x1c87, 0x7004, 0xa084, 0x000f, 0xa085, - 0x6280, 0x7806, 0x780f, 0x9200, 0x7843, 0x00d8, 0x7853, 0x0080, - 0x780b, 0x0008, 0x7047, 0x387f, 0x7043, 0x0000, 0x127f, 0x2000, - 0x007c, 0xa18c, 0x000f, 0x2011, 0x0101, 0x2204, 0xa084, 0xfff0, - 0xa105, 0x2012, 0x1078, 0x1c87, 0x007c, 0x2011, 0x0101, 0x20a9, - 0x0009, 0x810b, 0x0070, 0x1bb6, 0x0078, 0x1bb1, 0xa18c, 0x0e00, - 0x2204, 0xa084, 0xf1ff, 0xa105, 0x2012, 0x007c, 0x2009, 0x0101, - 0x20a9, 0x0005, 0x8213, 0x0070, 0x1bc7, 0x0078, 0x1bc2, 0xa294, - 0x00e0, 0x2104, 0xa084, 0xff1f, 0xa205, 0x200a, 0x007c, 0x2011, - 0x0101, 0x20a9, 0x000c, 0x810b, 0x0070, 0x1bd8, 0x0078, 0x1bd3, - 0xa18c, 0xf000, 0x2204, 0xa084, 0x0fff, 0xa105, 0x2012, 0x007c, - 0x2011, 0x0102, 0x2204, 0xa084, 0xffcf, 0xa105, 0x2012, 0x007c, - 0x8103, 0x8003, 0xa080, 0x0020, 0x0c7e, 0x2061, 0x0100, 0x609a, - 0x62ac, 0x63ac, 0x0c7f, 0x007c, 0x8103, 0x8003, 0xa080, 0x0022, - 0x0c7e, 0x2061, 0x0100, 0x609a, 0x60a4, 0xa084, 0xffdf, 0x60ae, - 0x0c7f, 0x007c, 0x8103, 0x8003, 0xa080, 0x0022, 0x0c7e, 0x2061, - 0x0100, 0x609a, 0x60a4, 0xa085, 0x0020, 0x60ae, 0x0c7f, 0x007c, - 0x8103, 0x8003, 0xa080, 0x0020, 0x0c7e, 0x2061, 0x0100, 0x609a, - 0x60a4, 0x62ae, 0x2010, 0x60a4, 0x63ae, 0x2018, 0x0c7f, 0x007c, - 0x2091, 0x8000, 0x0c7e, 0x0e7e, 0x6818, 0xa005, 0x0040, 0x1c65, - 0x2061, 0x5c00, 0x1078, 0x1c6d, 0x0040, 0x1c53, 0x20a9, 0x0000, - 0x2061, 0x5b00, 0x0c7e, 0x1078, 0x1c6d, 0x0040, 0x1c3f, 0x0c7f, - 0x8c60, 0x0070, 0x1c3d, 0x0078, 0x1c32, 0x0078, 0x1c65, 0x007f, - 0xa082, 0x5b00, 0x2071, 0x3840, 0x70ba, 0x601c, 0xa085, 0x0800, - 0x601e, 0x71b6, 0x60a7, 0x0000, 0x2001, 0x0004, 0x70a2, 0x1078, - 0x1b44, 0x0078, 0x1c61, 0x2071, 0x3840, 0x601c, 0xa085, 0x0800, - 0x601e, 0x71b6, 0x60a7, 0x0000, 0x2001, 0x0006, 0x70a2, 0x1078, - 0x1b44, 0x2001, 0x0000, 0x0078, 0x1c67, 0x2001, 0x0001, 0x2091, - 0x8001, 0xa005, 0x0e7f, 0x0c7f, 0x007c, 0x2c04, 0xa005, 0x0040, - 0x1c84, 0x2060, 0x600c, 0xa306, 0x00c0, 0x1c81, 0x6008, 0xa206, - 0x00c0, 0x1c81, 0x6010, 0xa106, 0x00c0, 0x1c81, 0xa006, 0x0078, - 0x1c86, 0x6000, 0x0078, 0x1c6e, 0xa085, 0x0001, 0x007c, 0x2011, - 0x3841, 0x220c, 0xa18c, 0x000f, 0x2011, 0x013b, 0x2204, 0xa084, - 0x0100, 0x0040, 0x1c96, 0x2021, 0xff00, 0x2122, 0x007c, 0x0e7e, - 0x68e4, 0xa08c, 0x0020, 0x0040, 0x1ce5, 0xa084, 0x0006, 0x00c0, - 0x1ce5, 0x6010, 0x8007, 0xa084, 0x000f, 0x8003, 0x8003, 0x8003, - 0xa0f0, 0x3a80, 0x7004, 0xa084, 0x000a, 0x00c0, 0x1ce5, 0x7108, - 0xa194, 0xff00, 0x0040, 0x1ce5, 0xa18c, 0x00ff, 0x7104, 0xa084, - 0x0014, 0x00c0, 0x1cd2, 0x017e, 0x611c, 0xa18d, 0x0002, 0x611e, - 0x017f, 0xa085, 0x0014, 0x7006, 0x2001, 0x000c, 0xa106, 0x0040, - 0x1cce, 0x2100, 0x8003, 0x2008, 0x0078, 0x1ce2, 0x2009, 0x0019, - 0x0078, 0x1ce2, 0x2011, 0x0000, 0x7000, 0xa084, 0xdfff, 0x7002, - 0x7004, 0xa084, 0xffef, 0x7006, 0x017e, 0x611c, 0xa18d, 0x0002, - 0x611e, 0x017f, 0x2100, 0xa205, 0x700a, 0x0e7f, 0x007c, 0x0068, - 0x1ce7, 0x007e, 0x2071, 0x0000, 0x7018, 0xa084, 0x0001, 0x00c0, - 0x1cec, 0x007f, 0x2e08, 0x2071, 0x0010, 0x70ca, 0x007f, 0x70c6, - 0x70c3, 0x8002, 0x2071, 0x0000, 0x701b, 0x0001, 0x2091, 0x4080, - 0x007f, 0x2070, 0x007f, 0x0078, 0x1d03, 0x107e, 0x007e, 0x127e, - 0x2091, 0x2300, 0x7f3c, 0x7e58, 0x7c30, 0x7d38, 0xa594, 0x003f, - 0xa484, 0x4000, 0x0040, 0x1d1a, 0xa784, 0x007c, 0x00c0, 0x3022, - 0x1078, 0x1ce7, 0xa49c, 0x000f, 0xa382, 0x0004, 0x0050, 0x1d22, - 0x1078, 0x1ce7, 0x8507, 0xa084, 0x000f, 0x0079, 0x1d27, 0x21a1, - 0x2251, 0x2277, 0x24cf, 0x2787, 0x27cf, 0x2808, 0x2883, 0x28dd, - 0x2962, 0x1d4d, 0x1d37, 0x1fb8, 0x208d, 0x2766, 0x1d37, 0x1078, - 0x1ce7, 0x0018, 0x1d0a, 0x127f, 0x2091, 0x8001, 0x007f, 0x107f, - 0x007c, 0x7003, 0x0000, 0x703f, 0x0000, 0x7030, 0xa005, 0x0040, - 0x1d4b, 0x7033, 0x0000, 0x0018, 0x1d0a, 0x705c, 0xa005, 0x00c0, - 0x1df8, 0x70a0, 0xa084, 0x001f, 0x0079, 0x1d56, 0x1e18, 0x1d5e, - 0x1d6c, 0x1d8d, 0x1db3, 0x1ddf, 0x1ddd, 0x1d5e, 0x7808, 0xa084, - 0xfffd, 0x780a, 0x2009, 0x0046, 0x1078, 0x260f, 0x00c0, 0x1d6a, - 0x7003, 0x0004, 0x0078, 0x1d39, 0x1078, 0x2fe4, 0x00c0, 0x1d8b, - 0x70b4, 0x8007, 0x789b, 0x007e, 0x78aa, 0x789b, 0x0010, 0x78ab, - 0x000c, 0x789b, 0x0060, 0x78ab, 0x0001, 0x785b, 0x0004, 0x2009, - 0x00f7, 0x1078, 0x260d, 0x00c0, 0x1d8b, 0x7003, 0x0004, 0x70c3, - 0x000f, 0x7033, 0x3870, 0x0078, 0x1d39, 0x1078, 0x2fe4, 0x00c0, - 0x1db1, 0x71b4, 0x8107, 0x789b, 0x007e, 0x78aa, 0x789b, 0x0010, - 0xa18c, 0x0007, 0xa18d, 0x00c0, 0x79aa, 0x78ab, 0x0006, 0x789b, - 0x0060, 0x78ab, 0x0002, 0x785b, 0x0004, 0x2009, 0x00f7, 0x1078, - 0x260d, 0x00c0, 0x1db1, 0x7003, 0x0004, 0x70c3, 0x000f, 0x7033, - 0x3870, 0x0078, 0x1d39, 0x1078, 0x2fe4, 0x00c0, 0x1ddb, 0x71b4, - 0x8107, 0x789b, 0x007e, 0x78aa, 0x789b, 0x0010, 0xa18c, 0x0007, - 0xa18d, 0x00c0, 0x79aa, 0x78ab, 0x0020, 0x71b8, 0x79aa, 0x78ab, - 0x000d, 0x789b, 0x0060, 0x78ab, 0x0004, 0x785b, 0x0004, 0x2009, - 0x00f7, 0x1078, 0x260d, 0x00c0, 0x1ddb, 0x7003, 0x0004, 0x70c3, - 0x000f, 0x7033, 0x3870, 0x0078, 0x1d39, 0x0078, 0x1d8d, 0x1078, - 0x2fe4, 0x00c0, 0x1d39, 0x70bc, 0x2068, 0x789b, 0x0010, 0x6f10, - 0x1078, 0x2f11, 0x2c50, 0x6810, 0xa084, 0x001f, 0xa085, 0x0080, - 0x78aa, 0x6e18, 0x2041, 0x0001, 0x2001, 0x0004, 0x0078, 0x1f41, - 0x1078, 0x2fe4, 0x00c0, 0x1d39, 0x789b, 0x0010, 0x705c, 0x2068, - 0x6f10, 0x1078, 0x2f11, 0x2c50, 0x6008, 0xa085, 0x0010, 0x600a, - 0x6810, 0xa084, 0x001f, 0xa085, 0x0080, 0x78aa, 0x2031, 0x0020, - 0x2041, 0x0001, 0x1078, 0x304b, 0x2001, 0x0003, 0x0078, 0x1f2c, - 0x0018, 0x1d0a, 0x7440, 0xa485, 0x0000, 0x0040, 0x1e32, 0xa080, - 0x3880, 0x2030, 0x7144, 0x8108, 0xa12a, 0x0048, 0x1e29, 0x2009, - 0x3880, 0x2164, 0x6504, 0x85ff, 0x00c0, 0x1e3f, 0x8421, 0x00c0, - 0x1e23, 0x7146, 0x7003, 0x0000, 0x703f, 0x0000, 0x0078, 0x1d39, - 0x7640, 0xa6b0, 0x3880, 0x7144, 0x2600, 0x0078, 0x1e2e, 0x7146, - 0x2568, 0x2558, 0x753e, 0x2c50, 0x603c, 0xa085, 0x0000, 0x00c0, - 0x1e3c, 0x6708, 0x7736, 0xa784, 0x033f, 0x0040, 0x1e75, 0xa784, - 0x0021, 0x00c0, 0x1e3c, 0xa784, 0x0002, 0x0040, 0x1e5e, 0xa784, - 0x0004, 0x0040, 0x1e3c, 0xa7bc, 0xfffb, 0x670a, 0xa784, 0x0008, - 0x00c0, 0x1e3c, 0xa784, 0x0010, 0x00c0, 0x1e3c, 0xa184, 0x0200, - 0x00c0, 0x1e3c, 0xa784, 0x0100, 0x0040, 0x1e75, 0x6018, 0xa005, - 0x00c0, 0x1e3c, 0xa7bc, 0xfeff, 0x670a, 0x681f, 0x0000, 0x6e18, - 0xa684, 0x000e, 0x6118, 0x0040, 0x1e85, 0x601c, 0xa102, 0x0048, - 0x1e92, 0x0040, 0x1e92, 0x0078, 0x1e38, 0x81ff, 0x0040, 0x1e92, - 0x6828, 0x8007, 0xa084, 0x00ff, 0xa082, 0x0003, 0x0040, 0x1e92, - 0x00c0, 0x1e38, 0xa184, 0x0400, 0x00c0, 0x1ea1, 0x6130, 0xa18c, - 0xff00, 0x810f, 0x6030, 0xa084, 0xff00, 0xa105, 0x6032, 0x0078, - 0x1ea5, 0x6034, 0x603a, 0xa7bc, 0xfbff, 0xa784, 0x0080, 0x00c0, - 0x1eab, 0x700c, 0x6022, 0xa7bc, 0xff7f, 0x670a, 0x6b10, 0x8307, - 0xa084, 0x000f, 0x8003, 0x8003, 0x8003, 0xa080, 0x3a80, 0x2060, - 0x2048, 0x704a, 0x6000, 0x704e, 0x6004, 0x7052, 0x2a60, 0x0018, - 0x1d0a, 0x789b, 0x0010, 0xa046, 0x1078, 0x2fe4, 0x00c0, 0x1d39, - 0x6b10, 0xa39c, 0x001f, 0xa39d, 0x00c0, 0x704c, 0xa084, 0x8000, - 0x0040, 0x1ed6, 0xa684, 0x0001, 0x0040, 0x1ed8, 0xa39c, 0xffbf, - 0xa684, 0x0010, 0x0040, 0x1ede, 0xa39d, 0x0020, 0x7baa, 0x8840, - 0xa684, 0x000e, 0x00c0, 0x1ee9, 0xa7bd, 0x0010, 0x670a, 0x0078, - 0x1f2a, 0x714c, 0xa18c, 0x0800, 0x0040, 0x2b74, 0x2011, 0x0021, - 0x8004, 0x8004, 0x0048, 0x1f00, 0x2011, 0x0022, 0x8004, 0x0048, - 0x1f00, 0x2011, 0x0020, 0x8004, 0x0048, 0x1f00, 0x0040, 0x1f2a, - 0x7aaa, 0x8840, 0x1078, 0x2ffd, 0x6a10, 0x610c, 0x8108, 0xa18c, - 0x00ff, 0xa1e0, 0x5b00, 0x2c64, 0x8cff, 0x0040, 0x1f21, 0x6010, - 0xa206, 0x00c0, 0x1f0b, 0x60b4, 0x8001, 0x60b6, 0x00c0, 0x1f06, - 0x0c7e, 0x2a60, 0x6008, 0xa085, 0x0100, 0x600a, 0x0c7f, 0x0078, - 0x1e18, 0x1078, 0x2fe4, 0x00c0, 0x1d39, 0x2a60, 0x610e, 0x79aa, - 0x8840, 0x712e, 0x2001, 0x0001, 0x007e, 0x7150, 0xa184, 0x0018, - 0x0040, 0x1f40, 0xa184, 0x0010, 0x0040, 0x1f3a, 0x1078, 0x2d3d, - 0x00c0, 0x1f40, 0xa184, 0x0008, 0x0040, 0x1f40, 0x1078, 0x2c58, - 0x007f, 0x7002, 0xa68c, 0x0060, 0x88ff, 0x0040, 0x1f49, 0xa18d, - 0x0004, 0x795a, 0x69b2, 0x789b, 0x0060, 0x2800, 0x78aa, 0x789b, - 0x0061, 0x6814, 0xa085, 0x8000, 0x6816, 0x78aa, 0x157e, 0x137e, - 0x147e, 0x20a1, 0x012c, 0x789b, 0x0000, 0x8000, 0x80ac, 0xad80, - 0x000a, 0x2098, 0x53a6, 0x147f, 0x137f, 0x157f, 0x6810, 0x8007, - 0x789b, 0x007e, 0x78aa, 0x6d90, 0x7dd6, 0x7dde, 0x6e94, 0x7ed2, - 0x7eda, 0x7830, 0xa084, 0x00c0, 0x00c0, 0x1f78, 0x0098, 0x1f80, - 0x6008, 0xa084, 0xffef, 0x600a, 0x1078, 0x2ffd, 0x0078, 0x1d41, - 0x7200, 0xa284, 0x0007, 0xa086, 0x0001, 0x00c0, 0x1f8d, 0x781b, - 0x0049, 0x1078, 0x2ffd, 0x0078, 0x1f9e, 0x6ab0, 0xa295, 0x2000, - 0x7a5a, 0x781b, 0x0049, 0x1078, 0x2ffd, 0x7200, 0x2500, 0xa605, - 0x0040, 0x1f9e, 0xa284, 0x0007, 0x1079, 0x1fae, 0xad80, 0x0008, - 0x7032, 0xa284, 0x0007, 0xa086, 0x0001, 0x00c0, 0x1fac, 0x6018, - 0x8000, 0x601a, 0x1078, 0x2b4b, 0x0078, 0x1d39, 0x1fb6, 0x3376, - 0x3376, 0x3365, 0x3376, 0x1fb6, 0x1fb6, 0x1fb6, 0x1078, 0x1ce7, - 0x7808, 0xa084, 0xfffd, 0x780a, 0x0f7e, 0x2079, 0x3800, 0x7898, - 0x0f7f, 0xa084, 0x0001, 0x0040, 0x1fde, 0x70a0, 0xa086, 0x0001, - 0x00c0, 0x1fcd, 0x70a2, 0x0078, 0x2071, 0x70a0, 0xa086, 0x0005, - 0x00c0, 0x1fdc, 0x70bc, 0x2068, 0x6817, 0x0004, 0x6813, 0x0000, - 0x681c, 0xa085, 0x0008, 0x681e, 0x70a3, 0x0000, 0x157e, 0x2011, - 0x0004, 0x71a0, 0xa186, 0x0001, 0x0040, 0x2000, 0xa186, 0x0007, - 0x00c0, 0x1ff0, 0x2009, 0x382b, 0x200b, 0x0005, 0x0078, 0x2000, - 0x2009, 0x3813, 0x2104, 0x2009, 0x3812, 0x200a, 0x2009, 0x382b, - 0x200b, 0x0001, 0x70a3, 0x0000, 0x70a7, 0x0001, 0x0078, 0x2002, - 0x70a3, 0x0000, 0x1078, 0x314d, 0x20a9, 0x0010, 0x2039, 0x0000, - 0x1078, 0x2e16, 0xa7b8, 0x0100, 0x0070, 0x2010, 0x0078, 0x2008, - 0x7000, 0x2020, 0x0079, 0x2014, 0x2042, 0x202b, 0x202b, 0x201e, - 0x2042, 0x2042, 0x201c, 0x201c, 0x1078, 0x1ce7, 0x2021, 0x3857, - 0x2404, 0xa005, 0x0040, 0x202b, 0xad06, 0x00c0, 0x202b, 0x6800, - 0x2022, 0x0078, 0x203b, 0x681c, 0xa084, 0x0001, 0x00c0, 0x2037, - 0x6f10, 0x1078, 0x2f11, 0x1078, 0x2b06, 0x0078, 0x203b, 0x7054, - 0x2060, 0x6800, 0x6002, 0x6a16, 0x681c, 0xa085, 0x0008, 0x681e, - 0x1078, 0x18b6, 0x2021, 0x5c00, 0x1078, 0x2077, 0x2021, 0x3857, - 0x1078, 0x2077, 0x20a9, 0x0000, 0x2021, 0x5b00, 0x1078, 0x2077, - 0x8420, 0x0070, 0x2055, 0x0078, 0x204e, 0x1078, 0x2b55, 0x2061, - 0x3b00, 0x2021, 0x0002, 0x20a9, 0x0100, 0x6018, 0x6110, 0xa102, - 0x6012, 0x601b, 0x0000, 0xace0, 0x0010, 0x0070, 0x2069, 0x0078, - 0x205d, 0x2009, 0x382f, 0x200b, 0x0000, 0x8421, 0x00c0, 0x205b, - 0x157f, 0x7003, 0x0000, 0x703f, 0x0000, 0x0078, 0x1d39, 0x047e, - 0x2404, 0xa005, 0x0040, 0x2089, 0x2068, 0x6800, 0x007e, 0x6a16, - 0x681c, 0xa085, 0x0008, 0x681e, 0x1078, 0x18b6, 0x007f, 0x0078, - 0x2079, 0x047f, 0x2023, 0x0000, 0x007c, 0xa282, 0x0003, 0x0050, - 0x2093, 0x1078, 0x1ce7, 0x2300, 0x0079, 0x2096, 0x2099, 0x210c, - 0x211a, 0xa282, 0x0002, 0x0040, 0x209f, 0x1078, 0x1ce7, 0x70a0, - 0x70a3, 0x0000, 0x70c3, 0x0000, 0x0079, 0x20a6, 0x20ae, 0x20ae, - 0x20b0, 0x20e4, 0x2b7a, 0x20ae, 0x20e4, 0x20ae, 0x1078, 0x1ce7, - 0x77b4, 0x1078, 0x2e16, 0x77b4, 0xa7bc, 0x0f00, 0x1078, 0x2f11, - 0x6018, 0xa005, 0x0040, 0x20db, 0x2021, 0x5c00, 0x2009, 0x0004, - 0x2011, 0x0010, 0x1078, 0x216a, 0x0040, 0x20db, 0x157e, 0x20a9, - 0x0000, 0x2021, 0x5b00, 0x047e, 0x2009, 0x0004, 0x2011, 0x0010, - 0x1078, 0x216a, 0x047f, 0x0040, 0x20da, 0x8420, 0x0070, 0x20da, - 0x0078, 0x20cb, 0x157f, 0x8738, 0xa784, 0x001f, 0x00c0, 0x20b6, - 0x0078, 0x1d41, 0x0078, 0x1d41, 0x77b4, 0x1078, 0x2f11, 0x6018, - 0xa005, 0x0040, 0x210a, 0x2021, 0x5c00, 0x2009, 0x0005, 0x2011, - 0x0020, 0x1078, 0x216a, 0x0040, 0x210a, 0x157e, 0x20a9, 0x0000, - 0x2021, 0x5b00, 0x047e, 0x2009, 0x0005, 0x2011, 0x0020, 0x1078, - 0x216a, 0x047f, 0x0040, 0x2109, 0x8420, 0x0070, 0x2109, 0x0078, - 0x20fa, 0x157f, 0x0078, 0x1d41, 0x2200, 0x0079, 0x210f, 0x2112, - 0x2114, 0x2114, 0x1078, 0x1ce7, 0x70a3, 0x0000, 0x70a7, 0x0001, - 0x0078, 0x1d39, 0x2200, 0x0079, 0x211d, 0x2122, 0x2114, 0x2120, - 0x1078, 0x1ce7, 0x1078, 0x261c, 0x70a0, 0xa086, 0x0002, 0x00c0, - 0x2159, 0x77b4, 0x1078, 0x2e16, 0x77b4, 0xa7bc, 0x0f00, 0x1078, - 0x2f11, 0x6018, 0xa005, 0x0040, 0x2154, 0x2021, 0x5c00, 0x2009, - 0x0005, 0x2011, 0x0020, 0x1078, 0x216a, 0x0040, 0x2154, 0x157e, - 0x20a9, 0x0000, 0x2021, 0x5b00, 0x047e, 0x2009, 0x0005, 0x2011, - 0x0020, 0x1078, 0x216a, 0x047f, 0x0040, 0x2153, 0x8420, 0x0070, - 0x2153, 0x0078, 0x2144, 0x157f, 0x8738, 0xa784, 0x001f, 0x00c0, - 0x212f, 0x7000, 0xa086, 0x0001, 0x00c0, 0x2acd, 0x1078, 0x2b1e, - 0x6008, 0xa084, 0xffef, 0x600a, 0x1078, 0x2ac0, 0x0040, 0x2acd, - 0x0078, 0x1e18, 0x2404, 0xa005, 0x0040, 0x219d, 0x2068, 0x2d04, - 0x007e, 0x6810, 0xa706, 0x0040, 0x2179, 0x2d20, 0x007f, 0x0078, - 0x216b, 0x007f, 0x2022, 0x6916, 0x6814, 0xa086, 0x0050, 0x00c0, - 0x218c, 0x6817, 0x0006, 0x2200, 0xa086, 0x0010, 0x00c0, 0x218c, - 0x681c, 0xa084, 0xffef, 0x681e, 0x681c, 0xa205, 0x681e, 0x1078, - 0x18b6, 0x1078, 0x2b27, 0x6010, 0x8001, 0x6012, 0x6008, 0xa084, - 0xffef, 0x600a, 0x1078, 0x2b1e, 0x007c, 0xa085, 0x0001, 0x0078, - 0x219c, 0x2300, 0x0079, 0x21a4, 0x21a9, 0x21a7, 0x21ec, 0x1078, - 0x1ce7, 0x78e4, 0xa005, 0x00d0, 0x21cc, 0x0018, 0x21cc, 0x2008, - 0xa084, 0x0030, 0x00c0, 0x21b8, 0x781b, 0x0049, 0x0078, 0x1d39, - 0x78ec, 0xa084, 0x0003, 0x0040, 0x21b4, 0x2100, 0xa084, 0x0007, - 0x0079, 0x21c2, 0x21da, 0x21e0, 0x21d4, 0x21ca, 0x2fde, 0x2fde, - 0x21ca, 0x21e6, 0x1078, 0x1ce7, 0x7000, 0xa005, 0x0040, 0x1d41, - 0x2001, 0x0003, 0x0078, 0x24e3, 0x1078, 0x2df9, 0x781b, 0x0055, - 0x0078, 0x1d39, 0x1078, 0x2df9, 0x781b, 0x00dc, 0x0078, 0x1d39, - 0x1078, 0x2df9, 0x781b, 0x00e3, 0x0078, 0x1d39, 0x1078, 0x2df9, - 0x781b, 0x009d, 0x0078, 0x1d39, 0xa584, 0x000f, 0x00c0, 0x2216, - 0x1078, 0x261c, 0x7000, 0x0079, 0x21f5, 0x21fd, 0x220a, 0x21fd, - 0x2acd, 0x21ff, 0x2acd, 0x21fd, 0x21fd, 0x1078, 0x1ce7, 0x71a0, - 0x70a3, 0x0000, 0xa186, 0x0004, 0x00c0, 0x2208, 0x0078, 0x2b7a, - 0x0078, 0x2acd, 0x1078, 0x2b1e, 0x6008, 0xa084, 0xffef, 0x600a, - 0x1078, 0x2ac0, 0x0040, 0x2acd, 0x0078, 0x1e18, 0x78e4, 0xa005, - 0x00d0, 0x21cc, 0x0018, 0x21cc, 0x2008, 0xa084, 0x0030, 0x00c0, - 0x2225, 0x781b, 0x0049, 0x0078, 0x1d39, 0x78ec, 0xa084, 0x0003, - 0x0040, 0x2221, 0x2100, 0xa184, 0x0007, 0x0079, 0x222f, 0x223f, - 0x2245, 0x2239, 0x2237, 0x2fde, 0x2fde, 0x2237, 0x2fd6, 0x1078, - 0x1ce7, 0x1078, 0x2e01, 0x781b, 0x0055, 0x0078, 0x1d39, 0x1078, - 0x2e01, 0x781b, 0x00dc, 0x0078, 0x1d39, 0x1078, 0x2e01, 0x781b, - 0x00e3, 0x0078, 0x1d39, 0x1078, 0x2e01, 0x781b, 0x009d, 0x0078, - 0x1d39, 0x2300, 0x0079, 0x2254, 0x2259, 0x2257, 0x225b, 0x1078, - 0x1ce7, 0x0078, 0x2883, 0x6817, 0x0008, 0x78a3, 0x0000, 0x79e4, - 0xa184, 0x0030, 0x0040, 0x2883, 0x78ec, 0xa084, 0x0003, 0x0040, - 0x2883, 0xa184, 0x0007, 0x0079, 0x226d, 0x21da, 0x21e0, 0x21d4, - 0x2fb6, 0x2fde, 0x2fde, 0x2275, 0x2fd6, 0x1078, 0x1ce7, 0xa282, - 0x0005, 0x0050, 0x227d, 0x1078, 0x1ce7, 0x2300, 0x0079, 0x2280, - 0x2283, 0x24b7, 0x24c3, 0x2200, 0x0079, 0x2286, 0x228b, 0x228d, - 0x22a0, 0x228b, 0x249c, 0x1078, 0x1ce7, 0x789b, 0x0018, 0x78a8, - 0xa084, 0x00ff, 0xa082, 0x0020, 0x0048, 0x2dda, 0xa08a, 0x0004, - 0x00c8, 0x2dda, 0x0079, 0x229c, 0x2dda, 0x2dda, 0x2dda, 0x2d7c, - 0x789b, 0x0018, 0x79a8, 0xa184, 0x0080, 0x0040, 0x22b5, 0xa184, - 0x0018, 0x0040, 0x22b1, 0x0078, 0x2dda, 0x7000, 0xa005, 0x00c0, - 0x22ab, 0x2011, 0x0003, 0x0078, 0x2970, 0xa184, 0x00ff, 0xa08c, - 0x0080, 0x0040, 0x22e9, 0x7000, 0xa086, 0x0001, 0x00c0, 0x22c8, - 0x1078, 0x2b1e, 0x1078, 0x314d, 0x7034, 0x600a, 0x0078, 0x22cd, - 0x7000, 0xa086, 0x0003, 0x0040, 0x22c2, 0x7003, 0x0005, 0x2001, - 0x5c10, 0x2068, 0x703e, 0x7032, 0x157e, 0x20a9, 0x002f, 0x2003, - 0x0000, 0x8000, 0x0070, 0x22de, 0x0078, 0x22d7, 0x157f, 0x6813, - 0x0000, 0x68b3, 0x0700, 0x681f, 0x0800, 0x6823, 0x0003, 0x0078, - 0x2dda, 0xa08a, 0x0010, 0x00c8, 0x2dda, 0x0079, 0x22ef, 0x2301, - 0x22ff, 0x2317, 0x2319, 0x23ab, 0x2dda, 0x2dda, 0x23ad, 0x2dda, - 0x2dda, 0x2498, 0x2498, 0x2dda, 0x2dda, 0x2dda, 0x249a, 0x1078, - 0x1ce7, 0xa684, 0x1000, 0x0040, 0x230e, 0x2001, 0x0300, 0x8000, - 0x8000, 0x783a, 0x781b, 0x009a, 0x0078, 0x1d39, 0x6814, 0xa084, - 0x8000, 0x0040, 0x2315, 0x6817, 0x0003, 0x0078, 0x2fb6, 0x1078, - 0x1ce7, 0x691c, 0x691e, 0xa684, 0x1800, 0x00c0, 0x2333, 0x681c, - 0xa084, 0x0001, 0x00c0, 0x233b, 0x6814, 0xa086, 0x0008, 0x00c0, - 0x232b, 0x6817, 0x0000, 0xa684, 0x0400, 0x0040, 0x23a7, 0x781b, - 0x0058, 0x0078, 0x1d39, 0xa684, 0x1000, 0x0040, 0x233b, 0x781b, - 0x0058, 0x0078, 0x1d39, 0xa684, 0x0060, 0x0040, 0x23a3, 0xa684, - 0x0800, 0x0040, 0x23a3, 0xa684, 0x8000, 0x00c0, 0x2349, 0x0078, - 0x2363, 0xa6b4, 0x7fff, 0x7e5a, 0x6eb2, 0x789b, 0x0074, 0x7aac, - 0x79ac, 0x78ac, 0x801b, 0x00c8, 0x2356, 0x8000, 0xa084, 0x003f, - 0xa108, 0xa291, 0x0000, 0x6b94, 0x2100, 0xa302, 0x68ae, 0x6b90, - 0x2200, 0xa303, 0x68aa, 0xa684, 0x4000, 0x0040, 0x236b, 0xa6b4, - 0xbfff, 0x7e5a, 0x6eb2, 0x7000, 0xa086, 0x0003, 0x00c0, 0x2378, - 0x1078, 0x31c0, 0x1078, 0x3365, 0x781b, 0x0067, 0x0078, 0x1d39, - 0xa006, 0x1078, 0x3414, 0x6aac, 0x69a8, 0x6c94, 0x6b90, 0x2200, - 0xa105, 0x0040, 0x2387, 0x2200, 0xa422, 0x2100, 0xa31b, 0x7cd2, - 0x7bd6, 0x2300, 0xa405, 0x00c0, 0x2395, 0xa6b5, 0x4000, 0x7e5a, - 0x6eb2, 0x781b, 0x0067, 0x0078, 0x1d39, 0x781b, 0x0067, 0x2200, - 0xa115, 0x00c0, 0x239f, 0x1078, 0x3376, 0x0078, 0x1d39, 0x1078, - 0x339d, 0x0078, 0x1d39, 0x781b, 0x006a, 0x0078, 0x1d39, 0x781b, - 0x0058, 0x0078, 0x1d39, 0x1078, 0x1ce7, 0x0078, 0x240a, 0x691c, - 0xa184, 0x0100, 0x0040, 0x23c5, 0xa18c, 0xfeff, 0x691e, 0x0c7e, - 0x7048, 0x2060, 0x6000, 0xa084, 0xefff, 0x6002, 0x6004, 0xa084, - 0xfff5, 0x6006, 0x0c7f, 0x0078, 0x23f9, 0xa184, 0x0200, 0x0040, - 0x23f9, 0xa18c, 0xfdff, 0x691e, 0x0c7e, 0x7048, 0x2060, 0x6000, - 0xa084, 0xdfff, 0x6002, 0x6004, 0xa084, 0xffef, 0x6006, 0x2008, - 0x2c48, 0x0c7f, 0xa184, 0x0008, 0x0040, 0x23f9, 0x1078, 0x2f0d, - 0x1078, 0x2c58, 0x88ff, 0x0040, 0x23f9, 0x789b, 0x0060, 0x2800, - 0x78aa, 0x7e58, 0xa6b5, 0x0004, 0x7e5a, 0xa684, 0x0400, 0x00c0, - 0x23f5, 0x781b, 0x0055, 0x0078, 0x1d39, 0x781b, 0x0069, 0x0078, - 0x1d39, 0x7e58, 0xa684, 0x0400, 0x00c0, 0x2402, 0x781b, 0x0058, - 0x0078, 0x1d39, 0x781b, 0x006a, 0x0078, 0x1d39, 0x0078, 0x2de0, - 0x0078, 0x2de0, 0x2019, 0x0000, 0x7990, 0xa18c, 0x0007, 0x0040, - 0x2408, 0x789b, 0x0010, 0x78a8, 0xa094, 0x00ff, 0xa286, 0x0001, - 0x00c0, 0x242d, 0x2300, 0x7ca8, 0xa400, 0x2018, 0xa102, 0x0040, - 0x2425, 0x0048, 0x2425, 0x0078, 0x2427, 0x0078, 0x23af, 0x24a8, - 0x7aa8, 0x00f0, 0x2427, 0x0078, 0x2413, 0xa284, 0x00f0, 0xa086, - 0x0020, 0x00c0, 0x2489, 0x8318, 0x8318, 0x2300, 0xa102, 0x0040, - 0x243d, 0x0048, 0x243d, 0x0078, 0x2486, 0xa286, 0x0023, 0x0040, - 0x2408, 0x6818, 0xa084, 0xfff1, 0x681a, 0x7e58, 0xa684, 0xfff1, - 0xa085, 0x0010, 0x2030, 0x7e5a, 0x6008, 0xa085, 0x0010, 0x600a, - 0x0c7e, 0x7048, 0x2060, 0x6004, 0x2008, 0x2c48, 0x0c7f, 0xa184, - 0x0010, 0x0040, 0x2461, 0x1078, 0x2f0d, 0x1078, 0x2d3d, 0x0078, - 0x2470, 0x0c7e, 0x7048, 0x2060, 0x6004, 0x2008, 0x2c48, 0x0c7f, - 0xa184, 0x0008, 0x0040, 0x23f9, 0x1078, 0x2f0d, 0x1078, 0x2c58, - 0x88ff, 0x0040, 0x23f9, 0x789b, 0x0060, 0x2800, 0x78aa, 0xa6b5, - 0x0004, 0x7e5a, 0xa684, 0x0400, 0x00c0, 0x2482, 0x781b, 0x0055, - 0x0078, 0x1d39, 0x781b, 0x0069, 0x0078, 0x1d39, 0x7aa8, 0x0078, - 0x2413, 0x8318, 0x2300, 0xa102, 0x0040, 0x2492, 0x0048, 0x2492, - 0x0078, 0x2413, 0xa284, 0x0080, 0x00c0, 0x2de6, 0x0078, 0x2de0, - 0x0078, 0x2de6, 0x0078, 0x2dda, 0x789b, 0x0018, 0x78a8, 0xa084, - 0x00ff, 0xa08e, 0x0001, 0x0040, 0x24a7, 0x1078, 0x1ce7, 0x7aa8, - 0xa294, 0x00ff, 0x78a8, 0xa084, 0x00ff, 0xa08a, 0x0004, 0x00c8, - 0x2dda, 0x0079, 0x24b3, 0x2dda, 0x2bab, 0x2dda, 0x2cd8, 0xa282, - 0x0000, 0x00c0, 0x24bd, 0x1078, 0x1ce7, 0x1078, 0x2df9, 0x781b, - 0x0069, 0x0078, 0x1d39, 0xa282, 0x0003, 0x00c0, 0x24c9, 0x1078, - 0x1ce7, 0x1078, 0x2e09, 0x781b, 0x0069, 0x0078, 0x1d39, 0xa282, - 0x0004, 0x0050, 0x24d5, 0x1078, 0x1ce7, 0x2300, 0x0079, 0x24d8, - 0x24db, 0x25c6, 0x25f7, 0xa286, 0x0003, 0x0040, 0x24e1, 0x1078, - 0x1ce7, 0x2001, 0x0000, 0x703a, 0x7000, 0xa084, 0x0007, 0x0079, - 0x24e9, 0x24f1, 0x24f3, 0x24f3, 0x2703, 0x274c, 0x26cd, 0x24f1, - 0x24f1, 0x1078, 0x1ce7, 0xa684, 0x1000, 0x00c0, 0x24fb, 0x1078, - 0x314d, 0x0040, 0x25a0, 0x7868, 0xa08c, 0x00ff, 0x0040, 0x2557, - 0xa186, 0x0008, 0x00c0, 0x2512, 0x6008, 0xa084, 0xffef, 0x600a, - 0x1078, 0x2ac0, 0x0040, 0x2557, 0x1078, 0x2b1e, 0x1078, 0x314d, - 0x0078, 0x253e, 0xa186, 0x0028, 0x00c0, 0x2557, 0x1078, 0x314d, - 0x6008, 0xa084, 0xffef, 0x600a, 0x1078, 0x2b34, 0x6018, 0xa005, - 0x0040, 0x253e, 0x8001, 0x601a, 0xa005, 0x0040, 0x2534, 0x8001, - 0xa005, 0x0040, 0x2534, 0x601e, 0x0078, 0x253e, 0x6813, 0x0028, - 0x6817, 0x0000, 0x0078, 0x25b5, 0x6030, 0xa084, 0x00ff, 0xa005, - 0x0040, 0x252e, 0x6008, 0xa085, 0x0200, 0x600a, 0x681c, 0xa084, - 0x0001, 0x0040, 0x1d41, 0x681c, 0xa084, 0xfffe, 0x681e, 0x7054, - 0x0c7e, 0x2060, 0x6800, 0x6002, 0x0c7f, 0x6004, 0x6802, 0xa005, - 0x2d00, 0x00c0, 0x2554, 0x6002, 0x6006, 0x0078, 0x1d41, 0x017e, - 0x1078, 0x261c, 0x017f, 0xa684, 0xdf00, 0x681a, 0x6827, 0x0000, - 0x6f10, 0x81ff, 0x0040, 0x25a0, 0xa186, 0x0002, 0x00c0, 0x2598, - 0xa684, 0x0800, 0x00c0, 0x2574, 0xa684, 0x0060, 0x0040, 0x2574, - 0x78d8, 0x7adc, 0x682e, 0x6a2a, 0x8717, 0xa294, 0x000f, 0x8213, - 0x8213, 0x8213, 0xa290, 0x3a80, 0xa290, 0x0000, 0x221c, 0xa384, - 0x0100, 0x00c0, 0x2585, 0x0078, 0x258b, 0x8210, 0x2204, 0xa085, - 0x0018, 0x2012, 0x8211, 0xa384, 0x0400, 0x0040, 0x2598, 0x689c, - 0xa084, 0x0100, 0x00c0, 0x2598, 0x1078, 0x268c, 0x0078, 0x1d41, - 0xa186, 0x0018, 0x0040, 0x25a0, 0xa186, 0x0014, 0x0040, 0x1d41, - 0x6912, 0x6814, 0xa084, 0x8000, 0x0040, 0x25a8, 0x7038, 0x6816, - 0xa68c, 0xdf00, 0x691a, 0x1078, 0x2b0d, 0x1078, 0x2b1e, 0x00c0, - 0x25b5, 0x6008, 0xa084, 0xffef, 0x600a, 0x681c, 0xa084, 0x0001, - 0x00c0, 0x25be, 0x1078, 0x2b06, 0x0078, 0x25c2, 0x7054, 0x2060, - 0x6800, 0x6002, 0x1078, 0x18b6, 0x0078, 0x1d41, 0xa282, 0x0004, - 0x0048, 0x25cc, 0x1078, 0x1ce7, 0x2200, 0x0079, 0x25cf, 0x25d3, - 0x25d5, 0x25e2, 0x25d5, 0x1078, 0x1ce7, 0x7000, 0xa086, 0x0005, - 0x0040, 0x25de, 0x1078, 0x2df9, 0x781b, 0x0069, 0x781b, 0x006a, - 0x0078, 0x1d39, 0x7890, 0x8007, 0x8001, 0xa084, 0x0007, 0xa080, - 0x0018, 0x789a, 0x79a8, 0xa18c, 0x00ff, 0xa186, 0x0003, 0x0040, - 0x25f3, 0x0078, 0x2dda, 0x781b, 0x006a, 0x0078, 0x1d39, 0x681c, - 0xa085, 0x0004, 0x681e, 0x82ff, 0x00c0, 0x2602, 0x1078, 0x2df9, - 0x0078, 0x2609, 0x8211, 0x0040, 0x2607, 0x1078, 0x1ce7, 0x1078, - 0x2e09, 0x781b, 0x0069, 0x0078, 0x1d39, 0x1078, 0x2ffd, 0x7830, - 0xa084, 0x00c0, 0x00c0, 0x2619, 0x0018, 0x2619, 0x791a, 0xa006, - 0x007c, 0xa085, 0x0001, 0x007c, 0xa684, 0x0060, 0x00c0, 0x2626, - 0x682f, 0x0000, 0x682b, 0x0000, 0x0078, 0x268b, 0xa684, 0x0800, - 0x00c0, 0x2635, 0x68b0, 0xa084, 0x4800, 0xa635, 0xa684, 0x0800, - 0x00c0, 0x2635, 0x1078, 0x314d, 0x007c, 0xa684, 0x0020, 0x0040, - 0x265f, 0x78d0, 0x8003, 0x00c8, 0x2643, 0xa006, 0x1078, 0x3414, - 0x78d4, 0x1078, 0x3479, 0xa684, 0x4000, 0x0040, 0x264d, 0x682f, - 0x0000, 0x682b, 0x0000, 0x0078, 0x2632, 0x68b0, 0xa084, 0x4800, - 0xa635, 0xa684, 0x4000, 0x00c0, 0x2647, 0x7038, 0xa005, 0x00c0, - 0x2659, 0x79d8, 0x7adc, 0x692e, 0x6a2a, 0x0078, 0x2632, 0xa684, - 0x4000, 0x0040, 0x2669, 0x682f, 0x0000, 0x682b, 0x0000, 0x0078, - 0x2632, 0x68b0, 0xa084, 0x4800, 0xa635, 0xa684, 0x4000, 0x00c0, - 0x2663, 0x7038, 0xa005, 0x00c0, 0x2675, 0x79d8, 0x7adc, 0x78d0, - 0x80f3, 0x00c8, 0x267c, 0x8000, 0xa084, 0x003f, 0xa108, 0xa291, - 0x0000, 0x692e, 0x6a2a, 0x2100, 0xa205, 0x00c0, 0x2689, 0x0078, - 0x2632, 0x1078, 0x3414, 0x007c, 0xa384, 0x0200, 0x0040, 0x2694, - 0x6008, 0xa085, 0x0002, 0x600a, 0x6817, 0x0006, 0x6a28, 0x692c, - 0x6a3a, 0x693e, 0x682b, 0x0300, 0x682f, 0x0000, 0x6833, 0x2000, - 0x6893, 0x0000, 0x6897, 0x0020, 0x7000, 0x0079, 0x26a7, 0x26af, - 0x26b1, 0x26ba, 0x26af, 0x26af, 0x26af, 0x26af, 0x26af, 0x1078, - 0x1ce7, 0x681c, 0xa084, 0x0001, 0x00c0, 0x26ba, 0x1078, 0x2b06, - 0x0078, 0x26c0, 0x7054, 0x2c50, 0x2060, 0x6800, 0x6002, 0x2a60, - 0x2021, 0x3857, 0x2404, 0xa005, 0x0040, 0x26c9, 0x2020, 0x0078, - 0x26c2, 0x2d22, 0x206b, 0x0000, 0x007c, 0x77b4, 0x1078, 0x2e16, - 0xa7bc, 0x0f00, 0x1078, 0x2f11, 0x6018, 0xa005, 0x0040, 0x26fc, - 0x0d7e, 0x2001, 0x5c10, 0x2068, 0x0d7f, 0x2021, 0x5c00, 0x2009, - 0x0004, 0x2011, 0x0010, 0x1078, 0x216a, 0x0040, 0x26fc, 0x157e, - 0x20a9, 0x0000, 0x2021, 0x5b00, 0x047e, 0x2009, 0x0004, 0x2011, - 0x0010, 0x1078, 0x216a, 0x047f, 0x0040, 0x26fb, 0x8420, 0x0070, - 0x26fb, 0x0078, 0x26ec, 0x157f, 0x8738, 0xa784, 0x001f, 0x00c0, - 0x26d2, 0x0078, 0x1d41, 0x1078, 0x2b0d, 0x1078, 0x2b1e, 0x6827, - 0x0000, 0x789b, 0x000e, 0x6f10, 0x1078, 0x344a, 0x017e, 0xad88, - 0x0010, 0xa188, 0x0006, 0x2104, 0x017f, 0x8007, 0xa084, 0x00ff, - 0xa082, 0x0047, 0x0040, 0x271e, 0x0078, 0x272f, 0x0c7e, 0x6810, - 0x8007, 0xa084, 0x000f, 0x8003, 0x8003, 0x8003, 0xa0e0, 0x3a80, - 0x6004, 0xa084, 0xfff5, 0x6006, 0x0c7f, 0x1078, 0x2f6b, 0x6813, - 0x0002, 0xa684, 0x0800, 0x0040, 0x2739, 0x6918, 0xa18d, 0x2000, - 0x691a, 0x6814, 0xa084, 0x8000, 0x0040, 0x2740, 0x6817, 0x0000, - 0x2021, 0x3857, 0x6800, 0x2022, 0x6a38, 0x693c, 0x6a2a, 0x692e, - 0x1078, 0x18b6, 0x0078, 0x1d41, 0x1078, 0x261c, 0x6827, 0x0000, - 0x789b, 0x000e, 0x6f10, 0x1078, 0x3002, 0xa08c, 0x00ff, 0x6912, - 0x6814, 0xa084, 0x8000, 0x0040, 0x275f, 0x7038, 0x6816, 0xa68c, - 0xdf00, 0x691a, 0x70a3, 0x0000, 0x0078, 0x1d41, 0xa006, 0x1078, - 0x314d, 0x6813, 0x0000, 0x6817, 0x0001, 0xa68c, 0xdf00, 0x691a, - 0x6827, 0x0000, 0x7000, 0x0079, 0x2775, 0x277d, 0x277f, 0x277f, - 0x2781, 0x2781, 0x2781, 0x277d, 0x277d, 0x1078, 0x1ce7, 0x1078, - 0x2b1e, 0x6008, 0xa084, 0xffef, 0x600a, 0x0078, 0x2ad8, 0x2300, - 0x0079, 0x278a, 0x278d, 0x278f, 0x27cd, 0x1078, 0x1ce7, 0x7000, - 0x0079, 0x2792, 0x279a, 0x279c, 0x279c, 0x27a7, 0x279c, 0x27ae, - 0x279a, 0x279a, 0x1078, 0x1ce7, 0xa684, 0x2000, 0x00c0, 0x27a7, - 0xa6b5, 0x2000, 0x7e5a, 0x1078, 0x3376, 0x0078, 0x2fb6, 0x6814, - 0xa084, 0x8000, 0x0040, 0x27ae, 0x6817, 0x0007, 0x2009, 0x3818, - 0x210c, 0xa186, 0x0000, 0x0040, 0x27c3, 0xa186, 0x0001, 0x0040, - 0x27c7, 0x2009, 0x382b, 0x200b, 0x000b, 0x70a3, 0x0001, 0x781b, - 0x0046, 0x0078, 0x1d39, 0x781b, 0x00dd, 0x0078, 0x1d39, 0x2009, - 0x382b, 0x200b, 0x000a, 0x0078, 0x1d39, 0x1078, 0x1ce7, 0x2300, - 0x0079, 0x27d2, 0x27d5, 0x27d7, 0x27fa, 0x1078, 0x1ce7, 0x7000, - 0x0079, 0x27da, 0x27e2, 0x27e4, 0x27e4, 0x27ef, 0x27e4, 0x27f6, - 0x27e2, 0x27e2, 0x1078, 0x1ce7, 0xa684, 0x2000, 0x00c0, 0x27ef, - 0xa6b5, 0x2000, 0x7e5a, 0x1078, 0x3376, 0x0078, 0x2fb6, 0x6814, - 0xa084, 0x8000, 0x0040, 0x27f6, 0x6817, 0x0007, 0x781b, 0x00e4, - 0x0078, 0x1d39, 0x681c, 0xa085, 0x0004, 0x681e, 0x1078, 0x2f6b, - 0xa6b5, 0x0800, 0x1078, 0x2df9, 0x781b, 0x0069, 0x0078, 0x1d39, - 0x2300, 0x0079, 0x280b, 0x280e, 0x2810, 0x2812, 0x1078, 0x1ce7, - 0x1078, 0x1ce7, 0xa684, 0x0400, 0x00c0, 0x2831, 0x782b, 0x3009, - 0x789b, 0x0060, 0x78ab, 0x0000, 0xa684, 0xfffb, 0x785a, 0x79e4, - 0xa184, 0x0020, 0x0040, 0x2829, 0x78ec, 0xa084, 0x0003, 0x00c0, - 0x282d, 0x2001, 0x0014, 0x0078, 0x24e3, 0xa184, 0x0007, 0x0079, - 0x2869, 0x7a90, 0xa294, 0x0007, 0x789b, 0x0060, 0x79a8, 0x81ff, - 0x0040, 0x2867, 0x789b, 0x0010, 0x7ba8, 0xa384, 0x0001, 0x00c0, - 0x2858, 0x7ba8, 0x7ba8, 0xa386, 0x0001, 0x00c0, 0x284b, 0x2009, - 0xfff7, 0x0078, 0x2851, 0xa386, 0x0003, 0x00c0, 0x2858, 0x2009, - 0xffef, 0x0c7e, 0x7048, 0x2060, 0x6004, 0xa104, 0x6006, 0x0c7f, - 0x789b, 0x0060, 0x78ab, 0x0000, 0xa684, 0xfffb, 0x785a, 0x782b, - 0x3009, 0x691c, 0xa18c, 0xfdff, 0xa18c, 0xfeff, 0x691e, 0x0078, - 0x2fb6, 0x21da, 0x21e0, 0x2873, 0x287b, 0x2871, 0x2871, 0x2871, - 0x2fb6, 0x1078, 0x1ce7, 0x691c, 0xa18c, 0xfdff, 0xa18c, 0xfeff, - 0x691e, 0x0078, 0x2fbe, 0x691c, 0xa18c, 0xfdff, 0xa18c, 0xfeff, - 0x691e, 0x0078, 0x2fb6, 0x79e4, 0xa184, 0x0030, 0x0040, 0x288d, - 0x78ec, 0xa084, 0x0003, 0x00c0, 0x2895, 0x6814, 0xa085, 0x8000, - 0x6816, 0x2001, 0x0014, 0x0078, 0x24e3, 0xa184, 0x0007, 0x0079, - 0x2899, 0x2fb6, 0x2fb6, 0x28a1, 0x2fb6, 0x2fde, 0x2fde, 0x2fb6, - 0x2fb6, 0xa684, 0x0400, 0x00c0, 0x28d2, 0x681c, 0xa084, 0x0001, - 0x0040, 0x2fbe, 0xa68c, 0x2060, 0xa18c, 0xfffb, 0x795a, 0x69b2, - 0x789b, 0x0060, 0x78ab, 0x0000, 0x789b, 0x0061, 0x6814, 0xa085, - 0x8000, 0x6816, 0x78aa, 0x157e, 0x137e, 0x147e, 0x20a1, 0x012c, - 0x789b, 0x0000, 0x8000, 0x80ac, 0xad80, 0x000a, 0x2098, 0x53a6, - 0x147f, 0x137f, 0x157f, 0x6810, 0x8007, 0x789b, 0x007e, 0x78aa, - 0x0078, 0x2fbe, 0x6814, 0xa084, 0x8000, 0x0040, 0x28d9, 0x6817, - 0x0008, 0x781b, 0x00d8, 0x0078, 0x1d39, 0x2300, 0x0079, 0x28e0, - 0x28e5, 0x2960, 0x28e3, 0x1078, 0x1ce7, 0x7000, 0xa084, 0x0007, - 0x0079, 0x28ea, 0x28f2, 0x28f4, 0x2910, 0x28f2, 0x28f2, 0x26cd, - 0x28f2, 0x28f2, 0x1078, 0x1ce7, 0x691c, 0xa18d, 0x0001, 0x691e, - 0x6800, 0x6006, 0xa005, 0x00c0, 0x28fe, 0x6002, 0x6818, 0xa084, - 0x000e, 0x0040, 0x290a, 0x7014, 0x68b6, 0x712c, 0xa188, 0x5b00, - 0x0078, 0x290c, 0x2009, 0x5c00, 0x2104, 0x6802, 0x2d0a, 0x7156, - 0x6eb2, 0xa684, 0x0060, 0x0040, 0x295e, 0xa684, 0x0800, 0x00c0, - 0x2922, 0xa684, 0x7fff, 0x68b2, 0x6890, 0x6894, 0x1078, 0x314d, - 0x0078, 0x295e, 0xa684, 0x0020, 0x0040, 0x2934, 0xa006, 0x1078, - 0x3414, 0x78d0, 0x8003, 0x00c8, 0x2930, 0x78d4, 0x1078, 0x3479, - 0x79d8, 0x7adc, 0x0078, 0x2938, 0x1078, 0x2f1e, 0x1078, 0x3414, - 0xa684, 0x8000, 0x0040, 0x295e, 0xa684, 0x7fff, 0x68b2, 0x789b, - 0x0074, 0x1078, 0x3002, 0x2010, 0x1078, 0x3002, 0x2008, 0xa684, - 0x0020, 0x00c0, 0x2956, 0x1078, 0x3002, 0x801b, 0x00c8, 0x2951, - 0x8000, 0xa084, 0x003f, 0xa108, 0xa291, 0x0000, 0x6b94, 0x2100, - 0xa302, 0x68ae, 0x6b90, 0x2200, 0xa303, 0x68aa, 0x0078, 0x1d41, - 0x0078, 0x2de6, 0x7033, 0x0000, 0xa282, 0x0005, 0x0050, 0x296a, - 0x1078, 0x1ce7, 0x2300, 0x0079, 0x296d, 0x2970, 0x297a, 0x299d, - 0x2200, 0x0079, 0x2973, 0x2978, 0x2de6, 0x2978, 0x29c6, 0x2a17, - 0x1078, 0x1ce7, 0x7000, 0xa086, 0x0001, 0x00c0, 0x2987, 0x1078, - 0x2b1e, 0x1078, 0x314d, 0x7034, 0x600a, 0x0078, 0x298c, 0x7000, - 0xa086, 0x0003, 0x0040, 0x2981, 0x7003, 0x0005, 0x2001, 0x5c10, - 0x2068, 0x703e, 0x7032, 0x2200, 0x0079, 0x2996, 0x2de6, 0x299b, - 0x29c6, 0x299b, 0x2de6, 0x1078, 0x1ce7, 0x7000, 0xa086, 0x0001, - 0x00c0, 0x29aa, 0x1078, 0x2b1e, 0x1078, 0x314d, 0x7034, 0x600a, - 0x0078, 0x29af, 0x7000, 0xa086, 0x0003, 0x0040, 0x29a4, 0x7003, - 0x0005, 0x2001, 0x5c10, 0x2068, 0x703e, 0x7032, 0x2200, 0x0079, - 0x29b9, 0x29c0, 0x29be, 0x29c0, 0x29be, 0x29c0, 0x1078, 0x1ce7, - 0x1078, 0x2e09, 0x781b, 0x0069, 0x0078, 0x1d39, 0x7000, 0xa086, - 0x0001, 0x00c0, 0x29d3, 0x1078, 0x2b1e, 0x1078, 0x314d, 0x7034, - 0x600a, 0x0078, 0x29d8, 0x7000, 0xa086, 0x0003, 0x0040, 0x29cd, - 0x7003, 0x0002, 0x7a80, 0xa294, 0x0f00, 0x789b, 0x0018, 0x7ca8, - 0xa484, 0x001f, 0xa215, 0x2069, 0x5c00, 0x2d04, 0x2d08, 0x7156, - 0x2068, 0xa005, 0x0040, 0x29f3, 0x6810, 0xa206, 0x0040, 0x2a0c, - 0x6800, 0x0078, 0x29e6, 0x7003, 0x0005, 0x2001, 0x5c10, 0x2068, - 0x703e, 0x7032, 0x157e, 0x20a9, 0x002f, 0x2003, 0x0000, 0x8000, - 0x0070, 0x2a04, 0x0078, 0x29fd, 0x157f, 0x6a12, 0x68b3, 0x0700, - 0x681f, 0x0800, 0x6823, 0x0003, 0x6eb0, 0x7e5a, 0x681c, 0xa084, - 0x0c00, 0x0040, 0x2a6d, 0x1078, 0x2e01, 0x0078, 0x2a6d, 0x7000, - 0xa086, 0x0001, 0x00c0, 0x2a24, 0x1078, 0x2b1e, 0x1078, 0x314d, - 0x7034, 0x600a, 0x0078, 0x2a29, 0x7000, 0xa086, 0x0003, 0x0040, - 0x2a1e, 0x7003, 0x0002, 0x7a80, 0xa294, 0x0f00, 0x789b, 0x0018, - 0x7ca8, 0xa484, 0x001f, 0xa215, 0x79a8, 0x79a8, 0xa18c, 0x00ff, - 0xa1e8, 0x5b00, 0x2d04, 0x2d08, 0x7156, 0x2068, 0xa005, 0x0040, - 0x2a48, 0x6810, 0xa206, 0x0040, 0x2a61, 0x6800, 0x0078, 0x2a3b, - 0x7003, 0x0005, 0x2001, 0x5c10, 0x2068, 0x703e, 0x7032, 0x157e, - 0x20a9, 0x002f, 0x2003, 0x0000, 0x8000, 0x0070, 0x2a59, 0x0078, - 0x2a52, 0x157f, 0x6a12, 0x68b3, 0x0700, 0x681f, 0x0800, 0x6823, - 0x0003, 0x6eb0, 0x7e5a, 0x681c, 0xa084, 0x0c00, 0x0040, 0x2a6d, - 0x1078, 0x2dfd, 0x7e58, 0x0078, 0x2a6d, 0x027e, 0x8207, 0xa084, - 0x000f, 0x8003, 0x8003, 0x8003, 0xa080, 0x3a80, 0x2060, 0x704a, - 0x6000, 0x704e, 0x6004, 0x7052, 0xa684, 0x0060, 0x0040, 0x2aa4, - 0x6b94, 0x6c90, 0x69a8, 0x68ac, 0xa105, 0x00c0, 0x2a92, 0x7bd2, - 0x7bda, 0x7cd6, 0x7cde, 0xa6b4, 0xb7ff, 0x7e5a, 0x1078, 0x3376, - 0x0078, 0x2aa4, 0x68ac, 0xa31a, 0x2100, 0xa423, 0x2400, 0xa305, - 0x0040, 0x2aa4, 0x7bd2, 0x7bda, 0x7cd6, 0x7cde, 0x68ac, 0xa6b4, - 0xbfff, 0x7e5a, 0x1078, 0x339d, 0x077f, 0x1078, 0x2f11, 0x2009, - 0x006a, 0xa684, 0x0008, 0x0040, 0x2aaf, 0x2009, 0x0069, 0xa6b5, - 0x2000, 0x7e5a, 0x791a, 0x2d00, 0x703e, 0x8207, 0xa084, 0x000f, - 0x8003, 0x8003, 0x8003, 0xa080, 0x3a80, 0x2048, 0x0078, 0x1d39, - 0x6020, 0xa005, 0x0040, 0x2acc, 0x8001, 0x6022, 0x6008, 0xa085, - 0x0008, 0x600a, 0x7010, 0x6026, 0x007c, 0xa006, 0x1078, 0x314d, - 0x6813, 0x0000, 0x6817, 0x0001, 0x681f, 0x0040, 0x681b, 0x0100, - 0x7000, 0xa084, 0x0007, 0x0079, 0x2add, 0x2ae5, 0x2ae7, 0x2ae7, - 0x2b02, 0x2aef, 0x2ae5, 0x2ae5, 0x2ae5, 0x1078, 0x1ce7, 0x1078, - 0x2b0d, 0x1078, 0x2b06, 0x1078, 0x18b6, 0x0078, 0x1d41, 0x70a0, - 0x70a3, 0x0000, 0x0079, 0x2af4, 0x2afe, 0x2afe, 0x2afc, 0x2afc, - 0x2afc, 0x2afe, 0x2afc, 0x2afe, 0x0079, 0x20a6, 0x70a3, 0x0000, - 0x0078, 0x1d41, 0x6817, 0x0000, 0x0078, 0x2703, 0x6800, 0xa005, - 0x00c0, 0x2b0b, 0x6002, 0x6006, 0x007c, 0x1078, 0x2b27, 0x6010, - 0xa005, 0x0040, 0x2b18, 0x8001, 0x00d0, 0x2b18, 0x1078, 0x1ce7, - 0x6012, 0x6008, 0xa084, 0xffef, 0x600a, 0x007c, 0x1078, 0x2b34, - 0x6018, 0xa005, 0x0040, 0x2b26, 0x8001, 0x601a, 0x007c, 0x017e, - 0x007e, 0x2009, 0x382e, 0x2104, 0xa005, 0x0040, 0x2b31, 0x8001, - 0x200a, 0x007f, 0x017f, 0x007c, 0x017e, 0x007e, 0x2009, 0x382f, - 0x2104, 0xa005, 0x0040, 0x2b3e, 0x8001, 0x200a, 0x007f, 0x017f, - 0x007c, 0x017e, 0x007e, 0x2009, 0x3830, 0x2104, 0x8000, 0x200a, - 0x007f, 0x017f, 0x007c, 0x017e, 0x007e, 0x2009, 0x382f, 0x2104, - 0x8000, 0x200a, 0x007f, 0x017f, 0x007c, 0x027e, 0x037e, 0x007e, - 0x2009, 0x382e, 0x2114, 0x2019, 0x382f, 0x2304, 0xa202, 0x200a, - 0x201b, 0x0000, 0x2009, 0x3830, 0x007f, 0x037f, 0x027f, 0x007c, - 0x1078, 0x2ffd, 0x6817, 0x0018, 0x0078, 0x2b98, 0x1078, 0x2ffd, - 0x6817, 0x0019, 0x0078, 0x2b98, 0x1078, 0x2ffd, 0x6817, 0x001a, - 0x0078, 0x2b98, 0x77b4, 0x1078, 0x2f11, 0x71b8, 0xa18c, 0x00ff, - 0xa1e8, 0x5b00, 0x2d04, 0x2d08, 0x2068, 0xa005, 0x00c0, 0x2b8a, - 0x0078, 0x1d41, 0x6810, 0x72b4, 0xa206, 0x0040, 0x2b92, 0x6800, - 0x0078, 0x2b83, 0x6800, 0x200a, 0x6817, 0x0005, 0x70bf, 0x0000, - 0x1078, 0x2b0d, 0x681c, 0xa084, 0x0001, 0x00c0, 0x2ba1, 0x1078, - 0x2b06, 0x1078, 0x2b1e, 0x681b, 0x0000, 0x681f, 0x0020, 0x1078, - 0x18b6, 0x0078, 0x1d41, 0xa282, 0x0003, 0x00c0, 0x2dda, 0x7da8, - 0xa5ac, 0x00ff, 0x7ea8, 0xa6b4, 0x00ff, 0x691c, 0xa18d, 0x0080, - 0x691e, 0xa184, 0x0100, 0x0040, 0x2c0b, 0xa18c, 0xfeff, 0x691e, - 0xa6b4, 0x00ff, 0x0040, 0x2bf5, 0xa682, 0x000f, 0x0048, 0x2bcc, - 0x0040, 0x2bcc, 0x2031, 0x000f, 0x852b, 0x852b, 0x1078, 0x2e94, - 0x0040, 0x2bd6, 0x1078, 0x2ca4, 0x0078, 0x2bfe, 0x1078, 0x2e4f, - 0x0c7e, 0x2960, 0x6004, 0xa084, 0xfff5, 0x6006, 0x1078, 0x2cc8, - 0x0c7f, 0x691c, 0xa18d, 0x0100, 0x691e, 0x7e58, 0xa6b5, 0x0004, - 0x7e5a, 0xa684, 0x0400, 0x00c0, 0x2bf1, 0x781b, 0x0055, 0x0078, - 0x1d39, 0x781b, 0x0069, 0x0078, 0x1d39, 0x0c7e, 0x2960, 0x6004, - 0xa084, 0xfff5, 0x6006, 0x1078, 0x2cc8, 0x0c7f, 0x7e58, 0xa684, - 0x0400, 0x00c0, 0x2c07, 0x781b, 0x0058, 0x0078, 0x1d39, 0x781b, - 0x006a, 0x0078, 0x1d39, 0x0c7e, 0x7048, 0x2060, 0x6100, 0xa18c, - 0x1000, 0x0040, 0x2c4b, 0x6208, 0x8217, 0xa294, 0x00ff, 0xa282, - 0x000f, 0x0048, 0x2c1f, 0x0040, 0x2c1f, 0x2011, 0x000f, 0x2600, - 0xa202, 0x00c8, 0x2c24, 0x2230, 0x6208, 0xa294, 0x00ff, 0x7018, - 0xa086, 0x0028, 0x00c0, 0x2c34, 0xa282, 0x0019, 0x00c8, 0x2c3a, - 0x2011, 0x0019, 0x0078, 0x2c3a, 0xa282, 0x000c, 0x00c8, 0x2c3a, - 0x2011, 0x000c, 0x2200, 0xa502, 0x00c8, 0x2c3f, 0x2228, 0x1078, - 0x2e53, 0x852b, 0x852b, 0x1078, 0x2e94, 0x0040, 0x2c4b, 0x1078, - 0x2ca4, 0x0078, 0x2c4f, 0x1078, 0x2e4f, 0x1078, 0x2cc8, 0x7858, - 0xa085, 0x0004, 0x785a, 0x0c7f, 0x781b, 0x0069, 0x0078, 0x1d39, - 0x0c7e, 0x2960, 0x6000, 0xa084, 0x1000, 0x00c0, 0x2c72, 0xa084, - 0x0040, 0x00c0, 0x2c6c, 0xa18c, 0x0002, 0x00c0, 0x2c6c, 0xa18c, - 0xfff5, 0x6106, 0x0c7f, 0x007c, 0x2011, 0x0032, 0x2019, 0x0000, - 0x0078, 0x2c94, 0x6208, 0xa294, 0x00ff, 0x7018, 0xa086, 0x0028, - 0x00c0, 0x2c82, 0xa282, 0x0019, 0x00c8, 0x2c88, 0x2011, 0x0019, - 0x0078, 0x2c88, 0xa282, 0x000c, 0x00c8, 0x2c88, 0x2011, 0x000c, - 0x6308, 0x831f, 0xa39c, 0x00ff, 0xa382, 0x000f, 0x0048, 0x2c94, - 0x0040, 0x2c94, 0x2019, 0x000f, 0x78ab, 0x0001, 0x78ab, 0x0003, - 0x78ab, 0x0001, 0x7aaa, 0x7baa, 0xa8c0, 0x0005, 0x681c, 0xa085, - 0x0100, 0x681e, 0x0c7f, 0x007c, 0x0c7e, 0x7148, 0x2160, 0x2008, - 0xa084, 0xfff0, 0xa635, 0x7e86, 0x6018, 0x789a, 0x7eae, 0x6612, - 0x78a4, 0xa084, 0xfff8, 0xa18c, 0x0007, 0xa105, 0x78a6, 0x6016, - 0x788a, 0xa6b4, 0x000f, 0x8637, 0x8204, 0x8004, 0xa084, 0x00ff, - 0xa605, 0x600e, 0x6004, 0xa084, 0xfff5, 0x6006, 0x0c7f, 0x007c, - 0x0c7e, 0x7048, 0x2060, 0x6018, 0x789a, 0x78a4, 0xa084, 0xfff0, - 0x78a6, 0x6012, 0x7884, 0xa084, 0xfff0, 0x7886, 0x0c7f, 0x007c, - 0xa282, 0x0002, 0x00c0, 0x2dda, 0x7aa8, 0x691c, 0xa18d, 0x0080, - 0x691e, 0xa184, 0x0200, 0x0040, 0x2d1d, 0xa18c, 0xfdff, 0x691e, - 0xa294, 0x00ff, 0xa282, 0x0002, 0x00c8, 0x2dda, 0x1078, 0x2d63, - 0x1078, 0x2cc8, 0xa980, 0x0001, 0x200c, 0x1078, 0x2f0d, 0x1078, - 0x2c58, 0x88ff, 0x0040, 0x2d10, 0x789b, 0x0060, 0x2800, 0x78aa, - 0x7e58, 0xa6b5, 0x0004, 0x7e5a, 0xa684, 0x0400, 0x00c0, 0x2d0c, - 0x781b, 0x0055, 0x0078, 0x1d39, 0x781b, 0x0069, 0x0078, 0x1d39, - 0x7e58, 0xa684, 0x0400, 0x00c0, 0x2d19, 0x781b, 0x0058, 0x0078, - 0x1d39, 0x781b, 0x006a, 0x0078, 0x1d39, 0xa282, 0x0002, 0x00c8, - 0x2d25, 0xa284, 0x0001, 0x0040, 0x2d2f, 0x7148, 0xa188, 0x0000, - 0x210c, 0xa18c, 0x2000, 0x00c0, 0x2d2f, 0x2011, 0x0000, 0x1078, - 0x2e41, 0x1078, 0x2d63, 0x1078, 0x2cc8, 0x7858, 0xa085, 0x0004, - 0x785a, 0x781b, 0x0069, 0x0078, 0x1d39, 0x0c7e, 0x027e, 0x2960, - 0x6000, 0x2011, 0x0001, 0xa084, 0x2000, 0x00c0, 0x2d53, 0xa084, - 0x0080, 0x00c0, 0x2d51, 0xa18c, 0xffef, 0x6106, 0xa006, 0x0078, - 0x2d60, 0x2011, 0x0000, 0x78ab, 0x0001, 0x78ab, 0x0002, 0x78ab, - 0x0003, 0x7aaa, 0xa8c0, 0x0004, 0x681c, 0xa085, 0x0200, 0x681e, - 0x027f, 0x0c7f, 0x007c, 0x0c7e, 0x7048, 0x2060, 0x82ff, 0x0040, - 0x2d6b, 0x2011, 0x0040, 0x6018, 0xa080, 0x0002, 0x789a, 0x78a4, - 0xa084, 0xffbf, 0xa205, 0x78a6, 0x6016, 0x788a, 0x6004, 0xa084, - 0xffef, 0x6006, 0x0c7f, 0x007c, 0x007e, 0x7000, 0xa086, 0x0003, - 0x0040, 0x2d85, 0x007f, 0x0078, 0x2d88, 0x007f, 0x0078, 0x2dd6, - 0xa684, 0x0020, 0x0040, 0x2dd6, 0x7888, 0xa084, 0x0040, 0x0040, - 0x2dd6, 0x78a8, 0x8001, 0x0040, 0x2d95, 0x7bb8, 0xa384, 0x003f, - 0x831b, 0x00c8, 0x2d9c, 0x8000, 0xa005, 0x0040, 0x2dbd, 0x831b, - 0x00c8, 0x2da5, 0x8001, 0x0040, 0x2dd2, 0xa006, 0x1078, 0x3414, - 0x78b4, 0x1078, 0x3479, 0x0078, 0x2dd6, 0xa684, 0x4000, 0x0040, - 0x2dbd, 0x78b8, 0x801b, 0x00c8, 0x2db6, 0x8000, 0xa084, 0x003f, - 0x00c0, 0x2dd2, 0xa6b4, 0xbfff, 0x7e5a, 0x79d8, 0x7adc, 0x2001, - 0x0001, 0xa108, 0x00c8, 0x2dc6, 0xa291, 0x0000, 0x79d2, 0x79da, - 0x7ad6, 0x7ade, 0x1078, 0x3414, 0x781b, 0x0067, 0x1078, 0x32e4, - 0x0078, 0x1d39, 0x781b, 0x0067, 0x0078, 0x1d39, 0x781b, 0x006a, - 0x0078, 0x1d39, 0x1078, 0x2e0d, 0x781b, 0x0069, 0x0078, 0x1d39, - 0x1078, 0x2df9, 0x781b, 0x0069, 0x0078, 0x1d39, 0x6823, 0x0002, - 0x1078, 0x2e01, 0x691c, 0xa18d, 0x0020, 0x691e, 0x6814, 0xa084, - 0x8000, 0x0040, 0x2df5, 0x6817, 0x0005, 0x781b, 0x0069, 0x0078, - 0x1d39, 0x2001, 0x0005, 0x0078, 0x2e0f, 0x2001, 0x000c, 0x0078, - 0x2e0f, 0x2001, 0x0006, 0x0078, 0x2e0f, 0x2001, 0x000d, 0x0078, - 0x2e0f, 0x2001, 0x0009, 0x0078, 0x2e0f, 0x2001, 0x0007, 0x789b, - 0x007f, 0x78aa, 0xa6b5, 0x0008, 0x7e5a, 0x007c, 0x077e, 0x873f, - 0xa7bc, 0x000f, 0x873b, 0x873b, 0x8703, 0xa0e0, 0x3a80, 0xa7b8, - 0x0020, 0x7f9a, 0x79a4, 0xa184, 0x000f, 0x0040, 0x2e2f, 0xa184, - 0xfff0, 0x78a6, 0x6012, 0x6004, 0xa085, 0x0008, 0x6006, 0x8738, - 0x8738, 0x7f9a, 0x79a4, 0xa184, 0x0040, 0x0040, 0x2e3f, 0xa184, - 0xffbf, 0x78a6, 0x6016, 0x6004, 0xa085, 0x0010, 0x6006, 0x077f, - 0x007c, 0x789b, 0x0010, 0x78ab, 0x0001, 0x78ab, 0x0002, 0x78ab, - 0x0003, 0x7aaa, 0x789b, 0x0060, 0x78ab, 0x0004, 0x007c, 0x2031, - 0x0000, 0x2029, 0x0032, 0x789b, 0x0010, 0x78ab, 0x0001, 0x78ab, - 0x0003, 0x78ab, 0x0001, 0x7daa, 0x7eaa, 0x789b, 0x0060, 0x78ab, - 0x0005, 0x007c, 0x157e, 0x8007, 0xa084, 0x00ff, 0x8003, 0x8003, - 0xa080, 0x0020, 0x789a, 0x79a4, 0xa18c, 0xfff0, 0x2001, 0x3846, - 0x2004, 0xa082, 0x0028, 0x0040, 0x2e7d, 0x2021, 0x2ef4, 0x2019, - 0x0014, 0x20a9, 0x000c, 0x0078, 0x2e83, 0x2021, 0x2f00, 0x2019, - 0x0019, 0x20a9, 0x000d, 0x2011, 0x0064, 0x2404, 0xa084, 0xfff0, - 0xa106, 0x0040, 0x2e92, 0x8420, 0x2300, 0xa210, 0x0070, 0x2e92, - 0x0078, 0x2e85, 0x157f, 0x007c, 0x157e, 0x2011, 0x3846, 0x2214, - 0xa282, 0x0032, 0x0048, 0x2ea8, 0x0040, 0x2eac, 0x2021, 0x2ee6, - 0x2019, 0x0011, 0x20a9, 0x000e, 0x2011, 0x0032, 0x0078, 0x2ebc, - 0xa282, 0x0028, 0x0040, 0x2eb4, 0x2021, 0x2ef4, 0x2019, 0x0014, - 0x20a9, 0x000c, 0x0078, 0x2eba, 0x2021, 0x2f00, 0x2019, 0x0019, - 0x20a9, 0x000d, 0x2011, 0x0064, 0x2200, 0xa502, 0x0040, 0x2ecc, - 0x0048, 0x2ecc, 0x8420, 0x2300, 0xa210, 0x0070, 0x2ec9, 0x0078, - 0x2ebc, 0x157f, 0xa006, 0x007c, 0x157f, 0xa582, 0x0064, 0x00c8, - 0x2ed5, 0x7808, 0xa085, 0x0070, 0x780a, 0x78ec, 0xa084, 0x0300, - 0x0040, 0x2ee3, 0x2404, 0xa09e, 0x1201, 0x00c0, 0x2ee3, 0x2001, - 0x2101, 0x0078, 0x2ee4, 0x2404, 0xa005, 0x007c, 0x1201, 0x3002, - 0x3202, 0x4203, 0x4403, 0x5404, 0x5604, 0x6605, 0x6805, 0x7806, - 0x7a06, 0x0a07, 0x0c07, 0x0e07, 0x3202, 0x4202, 0x5202, 0x6202, - 0x7202, 0x6605, 0x7605, 0x7805, 0x7a05, 0x7c05, 0x7e05, 0x7f05, - 0x2202, 0x3202, 0x4202, 0x5202, 0x5404, 0x6404, 0x7404, 0x7604, - 0x7804, 0x7a04, 0x7c04, 0x7e04, 0x7f04, 0x789b, 0x0010, 0xa046, - 0x007c, 0xa784, 0x0f00, 0x800b, 0xa784, 0x001f, 0x8003, 0x8003, - 0x8003, 0x8003, 0xa105, 0xa0e0, 0x3b00, 0x007c, 0x79d8, 0x7adc, - 0x78d0, 0x801b, 0x00c8, 0x2f25, 0x8000, 0xa084, 0x003f, 0xa108, - 0xa291, 0x0000, 0x007c, 0x0f7e, 0x2079, 0x0100, 0x2009, 0x3840, - 0x2091, 0x8000, 0x2104, 0x0079, 0x2f35, 0x2f67, 0x2f3f, 0x2f3f, - 0x2f3f, 0x2f3f, 0x2f3f, 0x2f3d, 0x2f3d, 0x1078, 0x1ce7, 0x784b, - 0x0004, 0x7848, 0xa084, 0x0004, 0x00c0, 0x2f41, 0x784b, 0x0008, - 0x7848, 0xa084, 0x0008, 0x00c0, 0x2f48, 0x68b0, 0xa085, 0x4000, - 0x68b2, 0x7858, 0xa085, 0x4000, 0x785a, 0x7830, 0xa084, 0x0080, - 0x00c0, 0x2f67, 0x0018, 0x2f67, 0x6818, 0xa084, 0x0020, 0x00c0, - 0x2f65, 0x781b, 0x00dd, 0x0078, 0x2f67, 0x781b, 0x00e4, 0x2091, - 0x8001, 0x0f7f, 0x007c, 0x0c7e, 0x6810, 0x8007, 0xa084, 0x000f, - 0x8003, 0x8003, 0x8003, 0xa0e0, 0x3a80, 0x6004, 0xa084, 0x000a, - 0x00c0, 0x2fb4, 0x6108, 0xa194, 0xff00, 0x0040, 0x2fb4, 0xa18c, - 0x00ff, 0x6004, 0xa084, 0x0014, 0x00c0, 0x2f9d, 0xa085, 0x0014, - 0x6006, 0x017e, 0x691c, 0xa18d, 0x0002, 0x691e, 0x017f, 0x2001, - 0x000c, 0xa106, 0x0040, 0x2f99, 0x2100, 0x8003, 0x2008, 0x0078, - 0x2fad, 0x2009, 0x0019, 0x0078, 0x2fad, 0x2011, 0x0000, 0x6000, - 0xa084, 0xdfff, 0x6002, 0x6004, 0xa084, 0xffef, 0x6006, 0x017e, - 0x691c, 0xa18d, 0x0002, 0x691e, 0x017f, 0x2100, 0xa205, 0x600a, - 0x6004, 0xa085, 0x000a, 0x6006, 0x0c7f, 0x007c, 0x781b, 0x006a, - 0x0078, 0x1d39, 0x781b, 0x0069, 0x0078, 0x1d39, 0x781b, 0x0058, - 0x0078, 0x1d39, 0x781b, 0x0055, 0x0078, 0x1d39, 0x781b, 0x00dd, - 0x0078, 0x1d39, 0x781b, 0x00dc, 0x0078, 0x1d39, 0x781b, 0x00e4, - 0x0078, 0x1d39, 0x781b, 0x00e3, 0x0078, 0x1d39, 0x781b, 0x009e, - 0x0078, 0x1d39, 0x781b, 0x009d, 0x0078, 0x1d39, 0x70a3, 0x0001, - 0x781b, 0x0046, 0x0078, 0x1d39, 0x007e, 0x7830, 0xa084, 0x00c0, - 0x00c0, 0x2ffb, 0x7808, 0xa084, 0xfffd, 0x780a, 0x0005, 0x0005, - 0x0005, 0x0005, 0x78ec, 0xa084, 0x0021, 0x0040, 0x2ffb, 0x7808, - 0xa085, 0x0002, 0x780a, 0x007f, 0x007c, 0x7808, 0xa085, 0x0002, - 0x780a, 0x007c, 0x7830, 0xa084, 0x0040, 0x00c0, 0x3002, 0x0098, - 0x300b, 0x78ac, 0x007c, 0x7808, 0xa084, 0xfffd, 0x780a, 0x0005, - 0x0005, 0x0005, 0x0005, 0x78ec, 0xa084, 0x0021, 0x0040, 0x301a, - 0x0098, 0x3018, 0x78ac, 0x007e, 0x7808, 0xa085, 0x0002, 0x780a, - 0x007f, 0x007c, 0xa784, 0x0070, 0x0040, 0x302e, 0x0c7e, 0x2d60, - 0x2f68, 0x1078, 0x1c97, 0x2d78, 0x2c68, 0x0c7f, 0x6817, 0x0003, - 0x7858, 0xa084, 0x3f00, 0x681a, 0x682f, 0x0000, 0x682b, 0x0000, - 0x784b, 0x0008, 0x78e4, 0xa005, 0x00d0, 0x21cc, 0xa084, 0x0020, - 0x0040, 0x21cc, 0x78ec, 0xa084, 0x0003, 0x0040, 0x21cc, 0x0018, - 0x21cc, 0x0078, 0x2de0, 0x0c7e, 0x6810, 0x8007, 0xa084, 0x000f, - 0x8003, 0x8003, 0x8003, 0xa080, 0x3a80, 0x2060, 0x2048, 0x704a, - 0x6000, 0x704e, 0x6004, 0x7052, 0x0c7f, 0x007c, 0x0020, 0x0020, - 0x0000, 0x0020, 0x0000, 0x0020, 0x0000, 0x0020, 0x0000, 0x0020, - 0x0000, 0x0020, 0x0000, 0x0020, 0x0000, 0x0020, 0x0000, 0x0020, - 0x0000, 0x0020, 0x0000, 0x0020, 0x0000, 0x0020, 0x0000, 0x0020, - 0x0000, 0x0020, 0x0000, 0x0020, 0x0000, 0x0020, 0x0000, 0x0020, - 0x0062, 0x0009, 0x0014, 0x0014, 0x9847, 0x0014, 0x0014, 0x98f5, - 0x98e7, 0x0014, 0x0014, 0x0080, 0x00bf, 0x0100, 0x0402, 0x2008, - 0xf880, 0xa20a, 0x0014, 0x300b, 0xa20c, 0x0014, 0xa200, 0x8838, - 0x817e, 0x842a, 0x84a0, 0x3806, 0x8839, 0x28c2, 0x9cc3, 0xa805, - 0x0864, 0xa83b, 0x3008, 0x28c1, 0x9cc3, 0xa201, 0x300c, 0x2847, - 0x8161, 0x846a, 0x8000, 0x84a4, 0x1856, 0x883a, 0xa808, 0x28e2, - 0x9ca0, 0xa8f3, 0x0864, 0xa829, 0x300c, 0xa801, 0x3008, 0x28e1, - 0x9ca0, 0x280d, 0xa204, 0x64c0, 0x67a0, 0x6fc0, 0x1814, 0x883b, - 0x7023, 0x8576, 0x8677, 0xa80f, 0x786e, 0x883e, 0xa80c, 0x282b, - 0xa205, 0x64a0, 0x67a0, 0x6fc0, 0x1814, 0x883b, 0x7023, 0x8576, - 0x8677, 0xa801, 0x883e, 0x2069, 0x28c1, 0x9cc3, 0x2044, 0x2103, - 0x20a2, 0x2081, 0xa8dc, 0xa207, 0x0014, 0xa203, 0x8000, 0x84a8, - 0x85a4, 0x1872, 0x849a, 0x883c, 0x1fe2, 0xf601, 0xa208, 0x856e, - 0x866f, 0x0704, 0x3008, 0x9ca0, 0x0014, 0xa202, 0x8000, 0x85a4, - 0x3009, 0x84a8, 0x19e2, 0xf848, 0x8174, 0x86eb, 0x85eb, 0x872e, - 0x87a9, 0x883f, 0x08e6, 0xa8f1, 0xf861, 0xa8e8, 0xf801, 0x0014, - 0xf881, 0x0016, 0x85b2, 0x80f0, 0x9532, 0xfaa2, 0x1de2, 0x0014, - 0x8532, 0xf221, 0x0014, 0x1de2, 0x84a8, 0xd6e0, 0x1fe6, 0x0014, - 0xa206, 0x6865, 0x817f, 0x842a, 0x1dc1, 0x8823, 0x0016, 0x6042, - 0x8008, 0xa8fa, 0x8000, 0x84a4, 0x8160, 0x842a, 0xf021, 0x3008, - 0x84a8, 0x1dc6, 0x20d7, 0x8822, 0x0016, 0x8000, 0x2848, 0x1011, - 0xa8fc, 0x3008, 0x8000, 0xa000, 0x2802, 0x1011, 0xa8fd, 0xa887, - 0x3008, 0x283d, 0x1011, 0xa8fd, 0xa209, 0x0017, 0x300c, 0x8000, - 0x85a4, 0x1de2, 0xdac1, 0x0014, 0x26e0, 0x873a, 0xfaa2, 0x19f2, - 0x1fe2, 0x0014, 0xa20b, 0x0014, 0xa20d, 0x817e, 0x842a, 0x84a0, - 0x3806, 0x0210, 0x9ccd, 0x0704, 0x0000, 0x127e, 0x2091, 0x2200, - 0x2049, 0x314d, 0x7000, 0x7204, 0xa205, 0x720c, 0xa215, 0x7008, - 0xa084, 0xfffd, 0xa205, 0x0040, 0x315f, 0x0078, 0x3164, 0x7003, - 0x0000, 0x127f, 0x2000, 0x007c, 0x7000, 0xa084, 0x0001, 0x00c0, - 0x3192, 0x7108, 0x8104, 0x00c8, 0x3171, 0x1078, 0x322e, 0x0078, - 0x3169, 0x700c, 0xa08c, 0x007f, 0x0040, 0x3192, 0x7004, 0x8004, - 0x00c8, 0x3189, 0x7014, 0xa005, 0x00c0, 0x3185, 0x7010, 0xa005, - 0x0040, 0x3189, 0xa102, 0x00c8, 0x3169, 0x7007, 0x0010, 0x0078, - 0x3192, 0x8aff, 0x0040, 0x3192, 0x1078, 0x33eb, 0x00c0, 0x318c, - 0x0040, 0x3169, 0x1078, 0x31dc, 0x7003, 0x0000, 0x127f, 0x2000, - 0x007c, 0x6424, 0x84ff, 0x0040, 0x31b6, 0x2c70, 0x2039, 0x31bb, - 0x2704, 0xae68, 0x680c, 0xa630, 0x6808, 0xa529, 0x8421, 0x0040, - 0x31b6, 0x8738, 0x2704, 0xa005, 0x00c0, 0x31a1, 0x7098, 0xa075, - 0x0040, 0x31b6, 0x2039, 0x31b8, 0x0078, 0x31a0, 0x007c, 0x0000, - 0x0004, 0x0008, 0x000c, 0x0010, 0x0014, 0x0018, 0x001c, 0x0000, - 0x127e, 0x2091, 0x2200, 0x2079, 0x3800, 0x2071, 0x0010, 0x7007, - 0x000a, 0x7007, 0x0002, 0x7003, 0x0000, 0x2071, 0x0020, 0x7007, - 0x000a, 0x7007, 0x0002, 0x7003, 0x0000, 0x2049, 0x0000, 0x78b7, - 0x0000, 0x127f, 0x2000, 0x007c, 0x2049, 0x31dc, 0x7004, 0x8004, - 0x00c8, 0x3208, 0x7007, 0x0012, 0x7108, 0x7008, 0xa106, 0x00c0, - 0x31e4, 0xa184, 0x0030, 0x0040, 0x31f1, 0xa086, 0x0030, 0x00c0, - 0x31e4, 0x7000, 0xa084, 0x0001, 0x00c0, 0x3208, 0x7008, 0xa084, - 0x000c, 0x00c0, 0x3206, 0x710c, 0xa184, 0x0300, 0x00c0, 0x3206, - 0xa184, 0x007f, 0x00c0, 0x31dc, 0x0078, 0x3208, 0x6817, 0x0003, - 0x7007, 0x0012, 0x7007, 0x0008, 0x7004, 0xa084, 0x0008, 0x00c0, - 0x320c, 0x7007, 0x0012, 0x7108, 0x8104, 0x0048, 0x3211, 0x78b7, - 0x0000, 0x7003, 0x0000, 0x2049, 0x0000, 0x007c, 0x107e, 0x007e, - 0x127e, 0x157e, 0x2091, 0x2200, 0x7108, 0x1078, 0x322e, 0x157f, - 0x127f, 0x2091, 0x8001, 0x007f, 0x107f, 0x007c, 0x7204, 0x2118, - 0x7108, 0x700c, 0xa084, 0x0300, 0x00c0, 0x3270, 0xa184, 0x000c, - 0x00c0, 0x3270, 0x8213, 0x8213, 0x8213, 0x8213, 0xa284, 0x0100, - 0xa10d, 0x810b, 0x810b, 0x810f, 0xa184, 0x0007, 0x0079, 0x3248, - 0x3252, 0x3262, 0x3270, 0x3262, 0x3284, 0x3284, 0x3270, 0x3282, - 0x1078, 0x1ce7, 0x7007, 0x0002, 0x8aff, 0x00c0, 0x325b, 0x2049, - 0x0000, 0x0078, 0x325f, 0x1078, 0x33eb, 0x00c0, 0x325b, 0x78b7, - 0x0000, 0x007c, 0x7007, 0x0002, 0x8aff, 0x00c0, 0x3269, 0x0078, - 0x326d, 0x1078, 0x33eb, 0x00c0, 0x3269, 0x78b7, 0x0000, 0x007c, - 0x7007, 0x0002, 0x1078, 0x31dc, 0x1078, 0x2f2b, 0x6814, 0xa084, - 0x8000, 0x0040, 0x327d, 0x6817, 0x0002, 0x007c, 0x1078, 0x1ce7, - 0x1078, 0x1ce7, 0x1078, 0x32d6, 0x7210, 0x7114, 0x700c, 0xa09c, - 0x007f, 0x2800, 0xa300, 0xa211, 0xa189, 0x0000, 0x78b4, 0xa005, - 0x0040, 0x3296, 0x78b7, 0x0000, 0x0078, 0x32b9, 0x1078, 0x32d6, - 0x2704, 0x2c58, 0xac60, 0x630c, 0x2200, 0xa322, 0x6308, 0x2100, - 0xa31b, 0x2400, 0xa305, 0x0040, 0x32af, 0x00c8, 0x32af, 0x8412, - 0x8210, 0x830a, 0xa189, 0x0000, 0x2b60, 0x0078, 0x3296, 0x2b60, - 0x8a07, 0xa7ba, 0x31b8, 0xa73d, 0x2c00, 0x6882, 0x6f86, 0x6c8e, - 0x6b8a, 0x7007, 0x0012, 0x1078, 0x31dc, 0x007c, 0x8738, 0x2704, - 0xa005, 0x00c0, 0x32ca, 0x6098, 0xa005, 0x0040, 0x32d3, 0x2060, - 0x2039, 0x31b8, 0x8a51, 0x0040, 0x32d2, 0x7008, 0xa084, 0x00c0, - 0xa086, 0x00c0, 0x007c, 0x2051, 0x0000, 0x007c, 0x8a50, 0x8739, - 0x2704, 0xa004, 0x00c0, 0x32e3, 0x2039, 0x31be, 0x6000, 0xa064, - 0x00c0, 0x32e3, 0x2d60, 0x007c, 0x127e, 0x0d7e, 0x2091, 0x2200, - 0x0d7f, 0x6880, 0x2060, 0x6884, 0x6b88, 0x6c8c, 0x8057, 0xaad4, - 0x00ff, 0xa084, 0x00ff, 0xa0b8, 0x31b8, 0x7e08, 0xa6b5, 0x000c, - 0x6818, 0xa084, 0x0040, 0x0040, 0x32ff, 0xa6b5, 0x0001, 0x0f7e, - 0x2079, 0x0100, 0x7858, 0x0f7f, 0xa084, 0x0040, 0x0040, 0x330e, - 0xa684, 0x0001, 0x00c0, 0x330e, 0xa6b5, 0x0001, 0x7007, 0x0004, - 0x7004, 0xa084, 0x0004, 0x00c0, 0x3310, 0x7000, 0xa005, 0x0040, - 0x331b, 0x1078, 0x1ce7, 0x2400, 0xa305, 0x00c0, 0x3321, 0x0078, - 0x335e, 0x2c58, 0x2704, 0xac60, 0x6004, 0xa400, 0x007e, 0x701a, - 0x6000, 0xa301, 0x701e, 0x2009, 0x04fd, 0x2104, 0xa086, 0x04fd, - 0x007f, 0x00c0, 0x334e, 0xa084, 0x0001, 0x0040, 0x334e, 0xa684, - 0x0001, 0x00c0, 0x334e, 0x7013, 0x0001, 0x7017, 0x0000, 0x7602, - 0x7007, 0x0001, 0x78b7, 0x0001, 0xa4a0, 0x0001, 0xa399, 0x0000, - 0x6004, 0xa400, 0x701a, 0x6000, 0xa301, 0x701e, 0x620c, 0x2400, - 0xa202, 0x7012, 0x6208, 0x2300, 0xa203, 0x7016, 0x7602, 0x7007, - 0x0001, 0x2b60, 0x1078, 0x32be, 0x0078, 0x3360, 0x1078, 0x33eb, - 0x00c0, 0x335e, 0x127f, 0x2000, 0x007c, 0x127e, 0x0d7e, 0x2091, - 0x2200, 0x0d7f, 0x7007, 0x0004, 0x7004, 0xa084, 0x0004, 0x00c0, - 0x336c, 0x7003, 0x0008, 0x127f, 0x2000, 0x007c, 0x127e, 0x0d7e, - 0x2091, 0x2200, 0x0d7f, 0x2049, 0x3376, 0x7007, 0x0004, 0x7004, - 0xa084, 0x0004, 0x00c0, 0x337f, 0x7e08, 0xa6b5, 0x000c, 0x6818, - 0xa084, 0x0040, 0x0040, 0x338e, 0xa6b5, 0x0001, 0x6824, 0xa005, - 0x0040, 0x339a, 0x2050, 0x2039, 0x31bb, 0x2d60, 0x1078, 0x33eb, - 0x00c0, 0x3396, 0x127f, 0x2000, 0x007c, 0x127e, 0x007e, 0x017e, - 0x0d7e, 0x2091, 0x2200, 0x0d7f, 0x037f, 0x047f, 0x7e08, 0xa6b5, - 0x000c, 0x6818, 0xa084, 0x0040, 0x0040, 0x33b0, 0xa6b5, 0x0001, - 0x2049, 0x339d, 0x6824, 0xa055, 0x0040, 0x33e8, 0x2d70, 0x2e60, - 0x2039, 0x31bb, 0x2704, 0xae68, 0x680c, 0xa422, 0x6808, 0xa31b, - 0x0048, 0x33d5, 0x8a51, 0x00c0, 0x33c7, 0x1078, 0x1ce7, 0x8738, - 0x2704, 0xa005, 0x00c0, 0x33bb, 0x7098, 0xa075, 0x2060, 0x0040, - 0x33e8, 0x2039, 0x31b8, 0x0078, 0x33ba, 0x8422, 0x8420, 0x831a, - 0xa399, 0x0000, 0x690c, 0x2400, 0xa122, 0x6908, 0x2300, 0xa11b, - 0x00c8, 0x33e4, 0x1078, 0x1ce7, 0x2071, 0x0020, 0x0078, 0x330e, - 0x127f, 0x2000, 0x007c, 0x7008, 0xa084, 0x00c0, 0xa086, 0x00c0, - 0x0040, 0x3413, 0x2704, 0xac08, 0x2104, 0x701e, 0x8108, 0x2104, - 0x701a, 0x8108, 0x2104, 0x7016, 0x8108, 0x2104, 0x7012, 0x0f7e, - 0x2079, 0x0100, 0x7858, 0x0f7f, 0xa084, 0x0040, 0x0040, 0x340e, - 0xa684, 0x0001, 0x00c0, 0x340e, 0xa6b5, 0x0001, 0x7602, 0x7007, - 0x0001, 0x1078, 0x32be, 0x007c, 0x127e, 0x007e, 0x0d7e, 0x2091, - 0x2200, 0x2049, 0x3414, 0x0d7f, 0x087f, 0x7108, 0xa184, 0x00c0, - 0x00c0, 0x342a, 0x6824, 0xa005, 0x0040, 0x343a, 0x0078, 0x3164, - 0x0078, 0x343a, 0x7108, 0x8104, 0x00c8, 0x3432, 0x1078, 0x322e, - 0x0078, 0x341d, 0x7007, 0x0010, 0x7108, 0x8104, 0x00c8, 0x3434, - 0x1078, 0x322e, 0x7008, 0xa086, 0x0002, 0x00c0, 0x341d, 0x7000, - 0xa005, 0x00c0, 0x341d, 0x7003, 0x0000, 0x2049, 0x0000, 0x127f, - 0x2000, 0x007c, 0x127e, 0x147e, 0x137e, 0x157e, 0x0d7e, 0x2091, - 0x2200, 0x0d7f, 0x2049, 0x344a, 0xad80, 0x0010, 0x20a0, 0x2099, - 0x0031, 0x700c, 0xa084, 0x007f, 0x6826, 0x7007, 0x0008, 0x7007, - 0x0002, 0x7003, 0x0001, 0x0040, 0x3468, 0x8000, 0x80ac, 0x53a5, - 0x7007, 0x0004, 0x7004, 0xa084, 0x0004, 0x00c0, 0x346a, 0x2049, - 0x0000, 0x7003, 0x0000, 0x157f, 0x137f, 0x147f, 0x127f, 0x2000, - 0x007c, 0x127e, 0x007e, 0x0d7e, 0x2091, 0x2200, 0x0d7f, 0x2049, - 0x3479, 0x6880, 0x2060, 0x6884, 0x6b88, 0x6c8c, 0x8057, 0xaad4, - 0x00ff, 0xa084, 0x00ff, 0xa0b8, 0x31b8, 0x7e08, 0xa6b5, 0x0004, - 0x7007, 0x0004, 0x7004, 0xa084, 0x0004, 0x00c0, 0x3492, 0x2c58, - 0x2704, 0xac60, 0x6004, 0xa400, 0x701a, 0x6000, 0xa301, 0x701e, - 0x7013, 0x0001, 0x7017, 0x0000, 0x7602, 0x7007, 0x0001, 0x007f, - 0x8007, 0x2009, 0x0031, 0x200a, 0x00a0, 0x34ac, 0x7108, 0x7007, - 0x0002, 0x810c, 0x00c8, 0x34ac, 0x810c, 0x0048, 0x34b9, 0x0078, - 0x3270, 0xa4a0, 0x0001, 0xa399, 0x0000, 0x6b8a, 0x6c8e, 0x7007, - 0x0004, 0x2049, 0x0000, 0x7003, 0x0000, 0x127f, 0x2000, 0x007c, - 0x20a9, 0x0010, 0xa006, 0x8004, 0x8086, 0x818e, 0x00c8, 0x34d1, - 0xa200, 0x00f0, 0x34cc, 0x8086, 0x818e, 0x007c, 0x157e, 0x20a9, - 0x0010, 0xa005, 0x0040, 0x34f7, 0xa11a, 0x00c8, 0x34f7, 0x8213, - 0x818d, 0x0048, 0x34ea, 0xa11a, 0x00c8, 0x34eb, 0x00f0, 0x34df, - 0x0078, 0x34ef, 0xa11a, 0x2308, 0x8210, 0x00f0, 0x34df, 0x007e, - 0x3200, 0xa084, 0xf7ff, 0x2080, 0x007f, 0x157f, 0x007c, 0x007e, - 0x3200, 0xa085, 0x0800, 0x0078, 0x34f3, 0x00e0, 0x3563, 0x2091, - 0x6000, 0x7820, 0x8001, 0x7822, 0x00c0, 0x355b, 0x7824, 0x7822, - 0x2009, 0x3834, 0x2104, 0xa005, 0x00c0, 0x3510, 0x2001, 0x0010, - 0x8001, 0x200a, 0x077e, 0x803f, 0x1078, 0x2f11, 0x077f, 0x20a9, - 0x0020, 0x601f, 0x0064, 0xace0, 0x0010, 0x00f0, 0x3519, 0x2091, - 0x8000, 0x2069, 0x3840, 0x6800, 0xa084, 0x0007, 0x0040, 0x3538, - 0xa086, 0x0002, 0x0040, 0x3538, 0x6830, 0xa00d, 0x0040, 0x3538, - 0x2104, 0xa005, 0x0040, 0x3538, 0x8001, 0x200a, 0x0040, 0x3640, - 0x2061, 0x3b00, 0x2009, 0x0002, 0x20a9, 0x0100, 0x603c, 0xa005, - 0x0040, 0x354e, 0x8001, 0x603e, 0x00c0, 0x354e, 0x6010, 0xa005, - 0x0040, 0x354e, 0x017e, 0x1078, 0x1b49, 0x017f, 0xace0, 0x0010, - 0x0070, 0x3554, 0x0078, 0x353e, 0x8109, 0x0040, 0x355b, 0x20a9, - 0x0100, 0x0078, 0x353e, 0x1078, 0x3578, 0x1078, 0x3566, 0x1078, - 0x359d, 0x1078, 0x3707, 0x2091, 0x8001, 0x007c, 0x783c, 0x8001, - 0x783e, 0x00c0, 0x3577, 0x7840, 0x783e, 0x7848, 0xa005, 0x0040, - 0x3577, 0x8001, 0x784a, 0x00c0, 0x3577, 0x1078, 0x1b49, 0x007c, - 0x7834, 0x8001, 0x7836, 0x00c0, 0x359c, 0x7838, 0x7836, 0x2091, - 0x8000, 0x7844, 0xa005, 0x00c0, 0x3587, 0x2001, 0x0101, 0x8001, - 0x7846, 0xa080, 0x5b00, 0x2040, 0x2004, 0xa065, 0x0040, 0x359c, - 0x6020, 0xa005, 0x0040, 0x3598, 0x8001, 0x6022, 0x0040, 0x35cc, - 0x6000, 0x2c40, 0x0078, 0x358d, 0x007c, 0x7828, 0x8001, 0x782a, - 0x00c0, 0x35cb, 0x782c, 0x782a, 0x7830, 0xa005, 0x00c0, 0x35aa, - 0x2001, 0x0200, 0x8001, 0x7832, 0x8003, 0x8003, 0x8003, 0x8003, - 0xa090, 0x3b00, 0xa298, 0x0002, 0x2304, 0xa084, 0x0008, 0x0040, - 0x35cb, 0xa290, 0x0009, 0x2204, 0xa005, 0x0040, 0x35c3, 0x8001, - 0x2012, 0x00c0, 0x35cb, 0x2304, 0xa084, 0xfff7, 0xa085, 0x0080, - 0x201a, 0x1078, 0x1b49, 0x007c, 0x2069, 0x3840, 0x6800, 0xa005, - 0x0040, 0x35d6, 0x683c, 0xac06, 0x0040, 0x3640, 0x6710, 0x6fb6, - 0x1078, 0x1758, 0x6808, 0xa084, 0x0020, 0x00c0, 0x363d, 0x2009, - 0x382b, 0x2104, 0xa005, 0x0040, 0x35e9, 0x6023, 0x0001, 0x0078, - 0x363d, 0x6808, 0xa084, 0xffef, 0xa085, 0x0021, 0x6017, 0x0006, - 0x60b0, 0xa084, 0x3f00, 0x601a, 0x601c, 0xa084, 0x00ff, 0xa085, - 0x0060, 0x601e, 0x6000, 0x2042, 0x6710, 0x6fb6, 0x1078, 0x1758, - 0x6818, 0xa005, 0x0040, 0x3606, 0x8001, 0x681a, 0x6808, 0xa084, - 0xffef, 0x680a, 0x6810, 0x8001, 0x00d0, 0x3610, 0x1078, 0x1ce7, - 0x6812, 0x602f, 0x0000, 0x602b, 0x0000, 0x2c68, 0x1078, 0x18b6, - 0x2069, 0x3840, 0x6710, 0xa784, 0x0f00, 0x68b6, 0x2001, 0x0002, - 0x1078, 0x1b44, 0x2041, 0x0021, 0x2049, 0x0005, 0x2051, 0x0030, - 0x1078, 0x1765, 0x2011, 0x3835, 0x2214, 0x6a3e, 0x8738, 0xa784, - 0x001f, 0x00c0, 0x3622, 0x2009, 0x382b, 0x200b, 0x0008, 0x2009, - 0x382c, 0x2069, 0x3840, 0x68b4, 0x200a, 0x2091, 0x8001, 0x007c, - 0x2009, 0x384f, 0x2164, 0x2069, 0x0100, 0x1078, 0x1c97, 0x6017, - 0x0006, 0x6858, 0xa084, 0x3f00, 0x601a, 0x601c, 0xa084, 0x00ff, - 0xa085, 0x0048, 0x601e, 0x602f, 0x0000, 0x602b, 0x0000, 0x6830, - 0xa084, 0x0040, 0x0040, 0x367c, 0x684b, 0x0004, 0x20a9, 0x0014, - 0x6848, 0xa084, 0x0004, 0x0040, 0x3669, 0x0070, 0x3669, 0x0078, - 0x3660, 0x684b, 0x0009, 0x20a9, 0x0014, 0x6848, 0xa084, 0x0001, - 0x0040, 0x3676, 0x0070, 0x3676, 0x0078, 0x366d, 0x20a9, 0x00fa, - 0x0070, 0x367c, 0x0078, 0x3678, 0x6808, 0xa084, 0xfffd, 0x680a, - 0x681b, 0x0046, 0x2009, 0x3868, 0x200b, 0x0007, 0x784c, 0x784a, - 0x2091, 0x8001, 0x007c, 0x2079, 0x3800, 0x1078, 0x36de, 0x1078, - 0x36a6, 0x1078, 0x36b4, 0x1078, 0x36c9, 0x1078, 0x36f3, 0x2009, - 0x3833, 0x200b, 0x0000, 0x2009, 0x3834, 0x200b, 0x0000, 0x7833, - 0x0000, 0x7847, 0x0000, 0x784b, 0x0000, 0x007c, 0x2019, 0x0003, - 0x2011, 0x3846, 0x2204, 0xa086, 0x003c, 0x0040, 0x36b1, 0x2019, - 0x0002, 0x7b2a, 0x7b2e, 0x007c, 0x2019, 0x0030, 0x2011, 0x3846, - 0x2204, 0xa086, 0x0032, 0x0040, 0x36c6, 0x2019, 0x0039, 0x2204, - 0xa086, 0x003c, 0x0040, 0x36c6, 0x2019, 0x0027, 0x7b36, 0x7b3a, - 0x007c, 0x2019, 0x000f, 0x2011, 0x3846, 0x2204, 0xa086, 0x003c, - 0x0040, 0x36db, 0x2019, 0x000d, 0x2204, 0xa086, 0x0032, 0x0040, - 0x36db, 0x2019, 0x000a, 0x7b3e, 0x7b42, 0x007c, 0x2019, 0x2faf, - 0x2011, 0x3846, 0x2204, 0xa086, 0x0032, 0x0040, 0x36f0, 0x2019, - 0x3971, 0x2204, 0xa086, 0x003c, 0x0040, 0x36f0, 0x2019, 0x2626, - 0x7b22, 0x7b26, 0x007c, 0x2019, 0x0001, 0x2011, 0x3846, 0x2204, - 0xa086, 0x003c, 0x0040, 0x36fe, 0x2019, 0x0001, 0x017e, 0x2009, - 0x3831, 0x230a, 0x2009, 0x3832, 0x230a, 0x017f, 0x007c, 0x2009, - 0x3831, 0x2104, 0x8001, 0x200a, 0xa005, 0x00c0, 0x3755, 0x2009, - 0x3832, 0x2104, 0x2009, 0x3831, 0x200a, 0x2009, 0x3833, 0x2104, - 0xa005, 0x00c0, 0x371d, 0x2001, 0x0200, 0x8001, 0x200a, 0x8003, - 0x8003, 0x8003, 0x8003, 0xa090, 0x3b00, 0x2208, 0xa298, 0x0002, - 0x2304, 0xa084, 0x0200, 0x0040, 0x3755, 0xa290, 0x000e, 0x2204, - 0xa005, 0x0040, 0x3740, 0x8001, 0x0040, 0x3740, 0x8001, 0x0040, - 0x3740, 0x8001, 0x0040, 0x3740, 0x8001, 0x2012, 0x00c0, 0x3755, - 0x2012, 0x2304, 0xa084, 0xfdff, 0xa085, 0x0400, 0x201a, 0xa188, - 0x000c, 0x2104, 0x007e, 0xa084, 0x00ff, 0x8001, 0x027f, 0xa294, - 0xff00, 0xa205, 0x200a, 0x1078, 0x1b49, 0x007c, 0x6ed0 -}; diff --git a/sys/dev/ispfw/ispfw.c b/sys/dev/ispfw/ispfw.c index 3c963663939d..2fface805a63 100644 --- a/sys/dev/ispfw/ispfw.c +++ b/sys/dev/ispfw/ispfw.c @@ -39,9 +39,6 @@ __FBSDID("$FreeBSD$"); #include #if defined(ISP_ALL) || !defined(KLD_MODULE) -#ifdef __sparc64__ -#define ISP_1000 1 -#endif #define ISP_1040 1 #define ISP_1040_IT 1 #define ISP_1080 1 @@ -60,13 +57,6 @@ __FBSDID("$FreeBSD$"); #define MODULE_NAME "ispfw" #endif -#if defined(ISP_1000) -#ifdef __sparc64__ -#include -#else -#error "firmware not compatible with this platform" -#endif -#endif #if defined(ISP_1040) || defined(ISP_1040_IT) #include #endif @@ -95,9 +85,6 @@ __FBSDID("$FreeBSD$"); #include #endif -#if defined(ISP_1000) -static int isp_1000_loaded; -#endif #if defined(ISP_1040) static int isp_1040_loaded; #endif @@ -152,9 +139,6 @@ static int do_load_fw(void) { -#if defined(ISP_1000) - RMACRO(isp_1000); -#endif #if defined(ISP_1040) RMACRO(isp_1040); #endif @@ -190,9 +174,6 @@ do_unload_fw(void) { int error = 0; -#if defined(ISP_1000) - UMACRO(isp_1000); -#endif #if defined(ISP_1040) UMACRO(isp_1040); #endif @@ -240,8 +221,6 @@ static moduledata_t ispfw_mod = { }; #if defined(ISP_ALL) || !defined(KLD_MODULE) DECLARE_MODULE(ispfw, ispfw_mod, SI_SUB_DRIVERS, SI_ORDER_THIRD); -#elif defined(ISP_1000) -DECLARE_MODULE(isp_1000, ispfw_mod, SI_SUB_DRIVERS, SI_ORDER_THIRD); #elif defined(ISP_1040) DECLARE_MODULE(isp_1040, ispfw_mod, SI_SUB_DRIVERS, SI_ORDER_THIRD); #elif defined(ISP_1080) diff --git a/sys/dev/le/if_le_lebuffer.c b/sys/dev/le/if_le_lebuffer.c deleted file mode 100644 index 630a47a921fb..000000000000 --- a/sys/dev/le/if_le_lebuffer.c +++ /dev/null @@ -1,393 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause-NetBSD - * - * Copyright (c) 2006 Marius Strobl - * 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 -__FBSDID("$FreeBSD$"); - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include -#include -#include - -#include -#include -#include - -#include -#include -#include -#include - -/* - * LANCE registers - */ -#define LEREG1_RDP 0 /* Register Data port */ -#define LEREG1_RAP 2 /* Register Address port */ - -struct le_lebuffer_softc { - struct am7990_softc sc_am7990; /* glue to MI code */ - - struct resource *sc_bres; - - struct resource *sc_rres; - - struct resource *sc_ires; - void *sc_ih; -}; - -static devclass_t le_lebuffer_devclass; - -static device_probe_t le_lebuffer_probe; -static device_attach_t le_lebuffer_attach; -static device_detach_t le_lebuffer_detach; -static device_resume_t le_buffer_resume; -static device_suspend_t le_buffer_suspend; - -static device_method_t le_lebuffer_methods[] = { - /* Device interface */ - DEVMETHOD(device_probe, le_lebuffer_probe), - DEVMETHOD(device_attach, le_lebuffer_attach), - DEVMETHOD(device_detach, le_lebuffer_detach), - /* We can just use the suspend method here. */ - DEVMETHOD(device_shutdown, le_buffer_suspend), - DEVMETHOD(device_suspend, le_buffer_suspend), - DEVMETHOD(device_resume, le_buffer_resume), - - { 0, 0 } -}; - -DEFINE_CLASS_0(le, le_lebuffer_driver, le_lebuffer_methods, - sizeof(struct le_lebuffer_softc)); -DRIVER_MODULE(le, lebuffer, le_lebuffer_driver, le_lebuffer_devclass, 0, 0); -MODULE_DEPEND(le, ether, 1, 1, 1); -MODULE_DEPEND(le, lebuffer, 1, 1, 1); - -/* - * Media types supported - */ -static const int le_lebuffer_media[] = { - IFM_MAKEWORD(IFM_ETHER, IFM_10_T, 0, 0) -}; -#define NLEMEDIA nitems(le_lebuffer_media) - -static void le_lebuffer_wrcsr(struct lance_softc *, uint16_t, uint16_t); -static uint16_t le_lebuffer_rdcsr(struct lance_softc *, uint16_t); -static void le_lebuffer_copytodesc(struct lance_softc *, void *, int, int); -static void le_lebuffer_copyfromdesc(struct lance_softc *, void *, int, int); -static void le_lebuffer_copytobuf(struct lance_softc *, void *, int, int); -static void le_lebuffer_copyfrombuf(struct lance_softc *, void *, int, int); -static void le_lebuffer_zerobuf(struct lance_softc *, int, int); - -static void -le_lebuffer_wrcsr(struct lance_softc *sc, uint16_t port, uint16_t val) -{ - struct le_lebuffer_softc *lesc = (struct le_lebuffer_softc *)sc; - - bus_write_2(lesc->sc_rres, LEREG1_RAP, port); - bus_barrier(lesc->sc_rres, LEREG1_RAP, 2, BUS_SPACE_BARRIER_WRITE); - bus_write_2(lesc->sc_rres, LEREG1_RDP, val); -} - -static uint16_t -le_lebuffer_rdcsr(struct lance_softc *sc, uint16_t port) -{ - struct le_lebuffer_softc *lesc = (struct le_lebuffer_softc *)sc; - - bus_write_2(lesc->sc_rres, LEREG1_RAP, port); - bus_barrier(lesc->sc_rres, LEREG1_RAP, 2, BUS_SPACE_BARRIER_WRITE); - return (bus_read_2(lesc->sc_rres, LEREG1_RDP)); -} - -/* - * It turns out that using bus_space(9) to access the buffers and the - * descriptors yields way more throughput than accessing them via the - * KVA returned by rman_get_virtual(9). The descriptor rings can be - * accessed using 8-bit up to 64-bit operations while the buffers can - * be only accessed using 8-bit and 16-bit operations. - * NB: For whatever reason setting LE_C3_BSWP has no effect with at - * least the 501-2981 (although their 'busmaster-regval' property - * indicates to set LE_C3_BSWP also for these cards), so we need - * to manually byte swap access to the buffers, i.e. the accesses - * going through the RX/TX FIFOs. - */ - -static void -le_lebuffer_copytodesc(struct lance_softc *sc, void *fromv, int off, int len) -{ - struct le_lebuffer_softc *lesc = (struct le_lebuffer_softc *)sc; - caddr_t from = fromv; - - for (; len >= 8; len -= 8, off += 8, from += 8) - bus_write_8(lesc->sc_bres, off, be64dec(from)); - for (; len >= 4; len -= 4, off += 4, from += 4) - bus_write_4(lesc->sc_bres, off, be32dec(from)); - for (; len >= 2; len -= 2, off += 2, from += 2) - bus_write_2(lesc->sc_bres, off, be16dec(from)); - if (len == 1) - bus_write_1(lesc->sc_bres, off, *from); -} - -static void -le_lebuffer_copyfromdesc(struct lance_softc *sc, void *tov, int off, int len) -{ - struct le_lebuffer_softc *lesc = (struct le_lebuffer_softc *)sc; - caddr_t to = tov; - - for (; len >= 8; len -= 8, off += 8, to += 8) - be64enc(to, - bus_read_8(lesc->sc_bres, off)); - for (; len >= 4; len -= 4, off += 4, to += 4) - be32enc(to, - bus_read_4(lesc->sc_bres, off)); - for (; len >= 2; len -= 2, off += 2, to += 2) - be16enc(to, - bus_read_2(lesc->sc_bres, off)); - if (len == 1) - *to = bus_read_1(lesc->sc_bres, off); -} - -static void -le_lebuffer_copytobuf(struct lance_softc *sc, void *fromv, int off, int len) -{ - struct le_lebuffer_softc *lesc = (struct le_lebuffer_softc *)sc; - caddr_t from = fromv; - - for (; len >= 2; len -= 2, off += 2, from += 2) - bus_write_2(lesc->sc_bres, off, le16dec(from)); - if (len == 1) - bus_write_1(lesc->sc_bres, off + 1, *from); -} - -static void -le_lebuffer_copyfrombuf(struct lance_softc *sc, void *tov, int off, int len) -{ - struct le_lebuffer_softc *lesc = (struct le_lebuffer_softc *)sc; - caddr_t to = tov; - - for (; len >= 2; len -= 2, off += 2, to += 2) - le16enc(to, - bus_read_2(lesc->sc_bres, off)); - if (len == 1) - *to = bus_read_1(lesc->sc_bres, off + 1); -} - -static void -le_lebuffer_zerobuf(struct lance_softc *sc, int off, int len) -{ - struct le_lebuffer_softc *lesc = (struct le_lebuffer_softc *)sc; - - for (; len >= 2; len -= 2, off += 2) - bus_write_2(lesc->sc_bres, off, 0); - if (len == 1) - bus_write_1(lesc->sc_bres, off + 1, 0); -} - -static int -le_lebuffer_probe(device_t dev) -{ - - if (strcmp(ofw_bus_get_name(dev), "le") == 0) { - device_set_desc(dev, "LANCE Ethernet"); - return (BUS_PROBE_DEFAULT); - } - return (ENXIO); -} - -static int -le_lebuffer_attach(device_t dev) -{ - struct le_lebuffer_softc *lesc; - struct lance_softc *sc; - int error, i; - - lesc = device_get_softc(dev); - sc = &lesc->sc_am7990.lsc; - - LE_LOCK_INIT(sc, device_get_nameunit(dev)); - - /* - * The "register space" of the parent is just a buffer where the - * the LANCE descriptor rings and the RX/TX buffers can be stored. - */ - i = 0; - lesc->sc_bres = bus_alloc_resource_any(device_get_parent(dev), - SYS_RES_MEMORY, &i, RF_ACTIVE); - if (lesc->sc_bres == NULL) { - device_printf(dev, "cannot allocate LANCE buffer\n"); - error = ENXIO; - goto fail_mtx; - } - - /* Allocate LANCE registers. */ - i = 0; - lesc->sc_rres = bus_alloc_resource_any(dev, SYS_RES_MEMORY, - &i, RF_ACTIVE); - if (lesc->sc_rres == NULL) { - device_printf(dev, "cannot allocate LANCE registers\n"); - error = ENXIO; - goto fail_bres; - } - - /* Allocate LANCE interrupt. */ - i = 0; - if ((lesc->sc_ires = bus_alloc_resource_any(dev, SYS_RES_IRQ, - &i, RF_SHAREABLE | RF_ACTIVE)) == NULL) { - device_printf(dev, "cannot allocate interrupt\n"); - error = ENXIO; - goto fail_rres; - } - - /* - * LANCE view is offset by buffer location. - * Note that we don't use sc->sc_mem. - */ - sc->sc_addr = 0; - sc->sc_memsize = rman_get_size(lesc->sc_bres); - sc->sc_flags = 0; - - /* That old black magic... */ - if (OF_getprop(ofw_bus_get_node(dev), "busmaster-regval", - &sc->sc_conf3, sizeof(sc->sc_conf3)) == -1) - sc->sc_conf3 = LE_C3_ACON | LE_C3_BCON; - /* - * Make sure LE_C3_BSWP is cleared so that for cards where - * that flag actually works le_lebuffer_copy{from,to}buf() - * don't fail... - */ - sc->sc_conf3 &= ~LE_C3_BSWP; - - OF_getetheraddr(dev, sc->sc_enaddr); - - sc->sc_copytodesc = le_lebuffer_copytodesc; - sc->sc_copyfromdesc = le_lebuffer_copyfromdesc; - sc->sc_copytobuf = le_lebuffer_copytobuf; - sc->sc_copyfrombuf = le_lebuffer_copyfrombuf; - sc->sc_zerobuf = le_lebuffer_zerobuf; - - sc->sc_rdcsr = le_lebuffer_rdcsr; - sc->sc_wrcsr = le_lebuffer_wrcsr; - sc->sc_hwreset = NULL; - sc->sc_hwinit = NULL; - sc->sc_hwintr = NULL; - sc->sc_nocarrier = NULL; - sc->sc_mediachange = NULL; - sc->sc_mediastatus = NULL; - sc->sc_supmedia = le_lebuffer_media; - sc->sc_nsupmedia = NLEMEDIA; - sc->sc_defaultmedia = le_lebuffer_media[0]; - - error = am7990_config(&lesc->sc_am7990, device_get_name(dev), - device_get_unit(dev)); - if (error != 0) { - device_printf(dev, "cannot attach Am7990\n"); - goto fail_ires; - } - - error = bus_setup_intr(dev, lesc->sc_ires, INTR_TYPE_NET | INTR_MPSAFE, - NULL, am7990_intr, sc, &lesc->sc_ih); - if (error != 0) { - device_printf(dev, "cannot set up interrupt\n"); - goto fail_am7990; - } - - return (0); - - fail_am7990: - am7990_detach(&lesc->sc_am7990); - fail_ires: - bus_release_resource(dev, SYS_RES_IRQ, - rman_get_rid(lesc->sc_ires), lesc->sc_ires); - fail_rres: - bus_release_resource(dev, SYS_RES_MEMORY, - rman_get_rid(lesc->sc_rres), lesc->sc_rres); - fail_bres: - bus_release_resource(device_get_parent(dev), SYS_RES_MEMORY, - rman_get_rid(lesc->sc_bres), lesc->sc_bres); - fail_mtx: - LE_LOCK_DESTROY(sc); - return (error); -} - -static int -le_lebuffer_detach(device_t dev) -{ - struct le_lebuffer_softc *lesc; - struct lance_softc *sc; - - lesc = device_get_softc(dev); - sc = &lesc->sc_am7990.lsc; - - bus_teardown_intr(dev, lesc->sc_ires, lesc->sc_ih); - am7990_detach(&lesc->sc_am7990); - bus_release_resource(dev, SYS_RES_IRQ, - rman_get_rid(lesc->sc_ires), lesc->sc_ires); - bus_release_resource(dev, SYS_RES_MEMORY, - rman_get_rid(lesc->sc_rres), lesc->sc_rres); - bus_release_resource(device_get_parent(dev), SYS_RES_MEMORY, - rman_get_rid(lesc->sc_bres), lesc->sc_bres); - LE_LOCK_DESTROY(sc); - - return (0); -} - -static int -le_buffer_suspend(device_t dev) -{ - struct le_lebuffer_softc *lesc; - - lesc = device_get_softc(dev); - - lance_suspend(&lesc->sc_am7990.lsc); - - return (0); -} - -static int -le_buffer_resume(device_t dev) -{ - struct le_lebuffer_softc *lesc; - - lesc = device_get_softc(dev); - - lance_resume(&lesc->sc_am7990.lsc); - - return (0); -} diff --git a/sys/dev/le/if_le_ledma.c b/sys/dev/le/if_le_ledma.c deleted file mode 100644 index 482c2341038c..000000000000 --- a/sys/dev/le/if_le_ledma.c +++ /dev/null @@ -1,496 +0,0 @@ -/* $NetBSD: if_le_ledma.c,v 1.26 2005/12/11 12:23:44 christos Exp $ */ - -/*- - * SPDX-License-Identifier: BSD-2-Clause-NetBSD - * - * Copyright (c) 1997, 1998 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Charles M. Hannum; Jason R. Thorpe of the Numerical Aerospace - * Simulation Facility, NASA Ames Research Center; Paul Kranenburg. - * - * 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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 -__FBSDID("$FreeBSD$"); - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include -#include -#include - -#include -#include -#include -#include - -#include -#include - -#include -#include -#include - -#define LEDMA_ALIGNMENT 8 /* ring desc. alignmet for NCR92C990 */ -#define LEDMA_BOUNDARY (16*1024*1024) /* must not cross 16MB boundary */ -#define LEDMA_MEMSIZE (16*1024) /* LANCE memory size */ -#define LEREG1_RDP 0 /* Register Data Port */ -#define LEREG1_RAP 2 /* Register Address Port */ - -struct le_dma_softc { - struct am7990_softc sc_am7990; /* glue to MI code */ - - struct resource *sc_rres; - - struct resource *sc_ires; - void *sc_ih; - - bus_dma_tag_t sc_dmat; - bus_dmamap_t sc_dmam; - bus_addr_t sc_laddr; /* LANCE DMA address */ - - struct lsi64854_softc *sc_dma; /* pointer to DMA engine */ -}; - -static device_probe_t le_dma_probe; -static device_attach_t le_dma_attach; -static device_detach_t le_dma_detach; -static device_resume_t le_dma_resume; -static device_suspend_t le_dma_suspend; - -static device_method_t le_dma_methods[] = { - /* Device interface */ - DEVMETHOD(device_probe, le_dma_probe), - DEVMETHOD(device_attach, le_dma_attach), - DEVMETHOD(device_detach, le_dma_detach), - /* We can just use the suspend method here. */ - DEVMETHOD(device_shutdown, le_dma_suspend), - DEVMETHOD(device_suspend, le_dma_suspend), - DEVMETHOD(device_resume, le_dma_resume), - - { 0, 0 } -}; - -DEFINE_CLASS_0(le, le_dma_driver, le_dma_methods, sizeof(struct le_dma_softc)); -DRIVER_MODULE(le, dma, le_dma_driver, le_devclass, 0, 0); -MODULE_DEPEND(le, dma, 1, 1, 1); -MODULE_DEPEND(le, ether, 1, 1, 1); - -/* - * Media types supported - */ -static const int le_dma_supmedia[] = { - IFM_MAKEWORD(IFM_ETHER, IFM_AUTO, 0, 0), - IFM_MAKEWORD(IFM_ETHER, IFM_10_T, 0, 0), - IFM_MAKEWORD(IFM_ETHER, IFM_10_5, 0, 0) -}; - -static void le_dma_wrcsr(struct lance_softc *, uint16_t, uint16_t); -static uint16_t le_dma_rdcsr(struct lance_softc *, uint16_t); -static void le_dma_setutp(struct lance_softc *); -static void le_dma_setaui(struct lance_softc *); -static int le_dma_supmediachange(struct lance_softc *); -static void le_dma_supmediastatus(struct lance_softc *, struct ifmediareq *); -static void le_dma_hwreset(struct lance_softc *); -static int le_dma_hwintr(struct lance_softc *); -static void le_dma_nocarrier(struct lance_softc *); -static bus_dmamap_callback_t le_dma_dma_callback; - -static void -le_dma_wrcsr(struct lance_softc *sc, uint16_t port, uint16_t val) -{ - struct le_dma_softc *lesc = (struct le_dma_softc *)sc; - - bus_write_2(lesc->sc_rres, LEREG1_RAP, port); - bus_barrier(lesc->sc_rres, LEREG1_RAP, 2, BUS_SPACE_BARRIER_WRITE); - bus_write_2(lesc->sc_rres, LEREG1_RDP, val); -} - -static uint16_t -le_dma_rdcsr(struct lance_softc *sc, uint16_t port) -{ - struct le_dma_softc *lesc = (struct le_dma_softc *)sc; - - bus_write_2(lesc->sc_rres, LEREG1_RAP, port); - bus_barrier(lesc->sc_rres, LEREG1_RAP, 2, BUS_SPACE_BARRIER_WRITE); - return (bus_read_2(lesc->sc_rres, LEREG1_RDP)); -} - -static void -le_dma_setutp(struct lance_softc *sc) -{ - struct lsi64854_softc *dma = ((struct le_dma_softc *)sc)->sc_dma; - - L64854_SCSR(dma, L64854_GCSR(dma) | E_TP_AUI); - DELAY(20000); /* We must not touch the LANCE chip for 20ms. */ -} - -static void -le_dma_setaui(struct lance_softc *sc) -{ - struct lsi64854_softc *dma = ((struct le_dma_softc *)sc)->sc_dma; - - L64854_SCSR(dma, L64854_GCSR(dma) & ~E_TP_AUI); - DELAY(20000); /* We must not touch the LANCE chip for 20ms. */ -} - -static int -le_dma_supmediachange(struct lance_softc *sc) -{ - struct ifmedia *ifm = &sc->sc_media; - - if (IFM_TYPE(ifm->ifm_media) != IFM_ETHER) - return (EINVAL); - - /* - * Switch to the selected media. If autoselect is set, we don't - * really have to do anything. We'll switch to the other media - * when we detect loss of carrier. - */ - switch (IFM_SUBTYPE(ifm->ifm_media)) { - case IFM_10_T: - le_dma_setutp(sc); - break; - - case IFM_10_5: - le_dma_setaui(sc); - break; - - case IFM_AUTO: - break; - - default: - return (EINVAL); - } - - return (0); -} - -static void -le_dma_supmediastatus(struct lance_softc *sc, struct ifmediareq *ifmr) -{ - struct lsi64854_softc *dma = ((struct le_dma_softc *)sc)->sc_dma; - - /* - * Notify the world which media we're currently using. - */ - if (L64854_GCSR(dma) & E_TP_AUI) - ifmr->ifm_active = IFM_MAKEWORD(IFM_ETHER, IFM_10_T, 0, 0); - else - ifmr->ifm_active = IFM_MAKEWORD(IFM_ETHER, IFM_10_5, 0, 0); -} - -static void -le_dma_hwreset(struct lance_softc *sc) -{ - struct le_dma_softc *lesc = (struct le_dma_softc *)sc; - struct lsi64854_softc *dma = lesc->sc_dma; - uint32_t aui_bit, csr; - - /* - * Reset DMA channel. - */ - csr = L64854_GCSR(dma); - aui_bit = csr & E_TP_AUI; - DMA_RESET(dma); - - /* Write bits 24-31 of Lance address. */ - bus_write_4(dma->sc_res, L64854_REG_ENBAR, - lesc->sc_laddr & 0xff000000); - - DMA_ENINTR(dma); - - /* - * Disable E-cache invalidates on chip writes. - * Retain previous cable selection bit. - */ - csr = L64854_GCSR(dma); - csr |= (E_DSBL_WR_INVAL | aui_bit); - L64854_SCSR(dma, csr); - DELAY(20000); /* We must not touch the LANCE chip for 20ms. */ -} - -static int -le_dma_hwintr(struct lance_softc *sc) -{ - struct le_dma_softc *lesc = (struct le_dma_softc *)sc; - struct lsi64854_softc *dma = lesc->sc_dma; - - return (DMA_INTR(dma)); -} - -static void -le_dma_nocarrier(struct lance_softc *sc) -{ - struct le_dma_softc *lesc = (struct le_dma_softc *)sc; - - /* - * Check if the user has requested a certain cable type, and - * if so, honor that request. - */ - - if (L64854_GCSR(lesc->sc_dma) & E_TP_AUI) { - switch (IFM_SUBTYPE(sc->sc_media.ifm_media)) { - case IFM_10_5: - case IFM_AUTO: - if_printf(sc->sc_ifp, "lost carrier on UTP port, " - "switching to AUI port\n"); - le_dma_setaui(sc); - } - } else { - switch (IFM_SUBTYPE(sc->sc_media.ifm_media)) { - case IFM_10_T: - case IFM_AUTO: - if_printf(sc->sc_ifp, "lost carrier on AUI port, " - "switching to UTP port\n"); - le_dma_setutp(sc); - } - } -} - -static void -le_dma_dma_callback(void *xsc, bus_dma_segment_t *segs, int nsegs, int error) -{ - struct le_dma_softc *lesc = (struct le_dma_softc *)xsc; - - if (error != 0) - return; - KASSERT(nsegs == 1, ("%s: bad DMA segment count", __func__)); - lesc->sc_laddr = segs[0].ds_addr; -} - -static int -le_dma_probe(device_t dev) -{ - - if (strcmp(ofw_bus_get_name(dev), "le") == 0) { - device_set_desc(dev, "LANCE Ethernet"); - return (BUS_PROBE_DEFAULT); - } - return (ENXIO); -} - -static int -le_dma_attach(device_t dev) -{ - struct le_dma_softc *lesc; - struct lsi64854_softc *dma; - struct lance_softc *sc; - int error, i; - - lesc = device_get_softc(dev); - sc = &lesc->sc_am7990.lsc; - - LE_LOCK_INIT(sc, device_get_nameunit(dev)); - - /* - * Establish link to `ledma' device. - * XXX hackery. - */ - dma = (struct lsi64854_softc *)device_get_softc(device_get_parent(dev)); - lesc->sc_dma = dma; - lesc->sc_dma->sc_client = lesc; - - i = 0; - lesc->sc_rres = bus_alloc_resource_any(dev, SYS_RES_MEMORY, - &i, RF_ACTIVE); - if (lesc->sc_rres == NULL) { - device_printf(dev, "cannot allocate registers\n"); - error = ENXIO; - goto fail_mtx; - } - - i = 0; - if ((lesc->sc_ires = bus_alloc_resource_any(dev, SYS_RES_IRQ, - &i, RF_SHAREABLE | RF_ACTIVE)) == NULL) { - device_printf(dev, "cannot allocate interrupt\n"); - error = ENXIO; - goto fail_rres; - } - - /* Attach the DMA engine. */ - error = lsi64854_attach(dma); - if (error != 0) { - device_printf(dev, "lsi64854_attach failed\n"); - goto fail_ires; - } - - sc->sc_memsize = LEDMA_MEMSIZE; - error = bus_dma_tag_create( - dma->sc_parent_dmat, /* parent */ - LEDMA_ALIGNMENT, /* alignment */ - LEDMA_BOUNDARY, /* boundary */ - BUS_SPACE_MAXADDR_32BIT, /* lowaddr */ - BUS_SPACE_MAXADDR, /* highaddr */ - NULL, NULL, /* filter, filterarg */ - sc->sc_memsize, /* maxsize */ - 1, /* nsegments */ - sc->sc_memsize, /* maxsegsize */ - 0, /* flags */ - NULL, NULL, /* lockfunc, lockarg */ - &lesc->sc_dmat); - if (error != 0) { - device_printf(dev, "cannot allocate buffer DMA tag\n"); - goto fail_lsi; - } - - error = bus_dmamem_alloc(lesc->sc_dmat, (void **)&sc->sc_mem, - BUS_DMA_WAITOK | BUS_DMA_COHERENT, &lesc->sc_dmam); - if (error != 0) { - device_printf(dev, "cannot allocate DMA buffer memory\n"); - goto fail_dtag; - } - - lesc->sc_laddr = 0; - error = bus_dmamap_load(lesc->sc_dmat, lesc->sc_dmam, sc->sc_mem, - sc->sc_memsize, le_dma_dma_callback, lesc, 0); - if (error != 0 || lesc->sc_laddr == 0) { - device_printf(dev, "cannot load DMA buffer map\n"); - goto fail_dmem; - } - - sc->sc_addr = lesc->sc_laddr & 0xffffff; - sc->sc_flags = 0; - sc->sc_conf3 = LE_C3_BSWP | LE_C3_ACON | LE_C3_BCON; - - sc->sc_mediachange = le_dma_supmediachange; - sc->sc_mediastatus = le_dma_supmediastatus; - sc->sc_supmedia = le_dma_supmedia; - sc->sc_nsupmedia = nitems(le_dma_supmedia); - sc->sc_defaultmedia = le_dma_supmedia[0]; - - OF_getetheraddr(dev, sc->sc_enaddr); - - sc->sc_copytodesc = lance_copytobuf_contig; - sc->sc_copyfromdesc = lance_copyfrombuf_contig; - sc->sc_copytobuf = lance_copytobuf_contig; - sc->sc_copyfrombuf = lance_copyfrombuf_contig; - sc->sc_zerobuf = lance_zerobuf_contig; - - sc->sc_rdcsr = le_dma_rdcsr; - sc->sc_wrcsr = le_dma_wrcsr; - sc->sc_hwreset = le_dma_hwreset; - sc->sc_hwintr = le_dma_hwintr; - sc->sc_nocarrier = le_dma_nocarrier; - - error = am7990_config(&lesc->sc_am7990, device_get_name(dev), - device_get_unit(dev)); - if (error != 0) { - device_printf(dev, "cannot attach Am7990\n"); - goto fail_dmap; - } - - error = bus_setup_intr(dev, lesc->sc_ires, INTR_TYPE_NET | INTR_MPSAFE, - NULL, am7990_intr, sc, &lesc->sc_ih); - if (error != 0) { - device_printf(dev, "cannot set up interrupt\n"); - goto fail_am7990; - } - - return (0); - - fail_am7990: - am7990_detach(&lesc->sc_am7990); - fail_dmap: - bus_dmamap_unload(lesc->sc_dmat, lesc->sc_dmam); - fail_dmem: - bus_dmamem_free(lesc->sc_dmat, sc->sc_mem, lesc->sc_dmam); - fail_dtag: - bus_dma_tag_destroy(lesc->sc_dmat); - fail_lsi: - lsi64854_detach(dma); - fail_ires: - bus_release_resource(dev, SYS_RES_IRQ, rman_get_rid(lesc->sc_ires), - lesc->sc_ires); - fail_rres: - bus_release_resource(dev, SYS_RES_MEMORY, rman_get_rid(lesc->sc_rres), - lesc->sc_rres); - fail_mtx: - LE_LOCK_DESTROY(sc); - return (error); -} - -static int -le_dma_detach(device_t dev) -{ - struct le_dma_softc *lesc; - struct lance_softc *sc; - int error; - - lesc = device_get_softc(dev); - sc = &lesc->sc_am7990.lsc; - - bus_teardown_intr(dev, lesc->sc_ires, lesc->sc_ih); - am7990_detach(&lesc->sc_am7990); - bus_dmamap_unload(lesc->sc_dmat, lesc->sc_dmam); - bus_dmamem_free(lesc->sc_dmat, sc->sc_mem, lesc->sc_dmam); - bus_dma_tag_destroy(lesc->sc_dmat); - error = lsi64854_detach(lesc->sc_dma); - if (error != 0) - return (error); - bus_release_resource(dev, SYS_RES_IRQ, rman_get_rid(lesc->sc_ires), - lesc->sc_ires); - bus_release_resource(dev, SYS_RES_MEMORY, rman_get_rid(lesc->sc_rres), - lesc->sc_rres); - LE_LOCK_DESTROY(sc); - - return (0); -} - -static int -le_dma_suspend(device_t dev) -{ - struct le_dma_softc *lesc; - - lesc = device_get_softc(dev); - - lance_suspend(&lesc->sc_am7990.lsc); - - return (0); -} - -static int -le_dma_resume(device_t dev) -{ - struct le_dma_softc *lesc; - - lesc = device_get_softc(dev); - - lance_resume(&lesc->sc_am7990.lsc); - - return (0); -} diff --git a/sys/dev/le/lebuffer_sbus.c b/sys/dev/le/lebuffer_sbus.c deleted file mode 100644 index f40aca1b6830..000000000000 --- a/sys/dev/le/lebuffer_sbus.c +++ /dev/null @@ -1,305 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD - * - * Copyright (c) 2006 Marius Strobl - * 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 -__FBSDID("$FreeBSD$"); - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include -#include -#include - -#include -#include -#include - -struct lebuffer_devinfo { - struct ofw_bus_devinfo ldi_obdinfo; - struct resource_list ldi_rl; -}; - -static devclass_t lebuffer_devclass; - -static device_probe_t lebuffer_probe; -static device_attach_t lebuffer_attach; -static device_detach_t lebuffer_detach; -static bus_print_child_t lebuffer_print_child; -static bus_probe_nomatch_t lebuffer_probe_nomatch; -static bus_get_resource_list_t lebuffer_get_resource_list; -static ofw_bus_get_devinfo_t lebuffer_get_devinfo; - -static struct lebuffer_devinfo *lebuffer_setup_dinfo(device_t, phandle_t); -static void lebuffer_destroy_dinfo(struct lebuffer_devinfo *); -static int lebuffer_print_res(struct lebuffer_devinfo *); - -static device_method_t lebuffer_methods[] = { - /* Device interface */ - DEVMETHOD(device_probe, lebuffer_probe), - DEVMETHOD(device_attach, lebuffer_attach), - DEVMETHOD(device_detach, lebuffer_detach), - DEVMETHOD(device_shutdown, bus_generic_shutdown), - DEVMETHOD(device_suspend, bus_generic_suspend), - DEVMETHOD(device_resume, bus_generic_resume), - - /* Bus interface */ - DEVMETHOD(bus_print_child, lebuffer_print_child), - DEVMETHOD(bus_probe_nomatch, lebuffer_probe_nomatch), - DEVMETHOD(bus_setup_intr, bus_generic_setup_intr), - DEVMETHOD(bus_teardown_intr, bus_generic_teardown_intr), - DEVMETHOD(bus_alloc_resource, bus_generic_rl_alloc_resource), - DEVMETHOD(bus_adjust_resource, bus_generic_adjust_resource), - DEVMETHOD(bus_release_resource, bus_generic_rl_release_resource), - DEVMETHOD(bus_activate_resource, bus_generic_activate_resource), - DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource), - DEVMETHOD(bus_get_resource_list, lebuffer_get_resource_list), - DEVMETHOD(bus_get_resource, bus_generic_rl_get_resource), - - /* ofw_bus interface */ - DEVMETHOD(ofw_bus_get_devinfo, lebuffer_get_devinfo), - DEVMETHOD(ofw_bus_get_compat, ofw_bus_gen_get_compat), - DEVMETHOD(ofw_bus_get_model, ofw_bus_gen_get_model), - DEVMETHOD(ofw_bus_get_name, ofw_bus_gen_get_name), - DEVMETHOD(ofw_bus_get_node, ofw_bus_gen_get_node), - DEVMETHOD(ofw_bus_get_type, ofw_bus_gen_get_type), - - { 0, 0 } -}; - -DEFINE_CLASS_0(lebuffer, lebuffer_driver, lebuffer_methods, 1); -DRIVER_MODULE(lebuffer, sbus, lebuffer_driver, lebuffer_devclass, 0, 0); -MODULE_DEPEND(lebuffer, sbus, 1, 1, 1); -MODULE_VERSION(lebuffer, 1); - -static int -lebuffer_probe(device_t dev) -{ - const char *name; - - name = ofw_bus_get_name(dev); - if (strcmp(name, "lebuffer") == 0) { - device_set_desc_copy(dev, name); - return (0); - } - return (ENXIO); -} - -static int -lebuffer_attach(device_t dev) -{ - struct lebuffer_devinfo *ldi; - device_t cdev; - phandle_t child; - int children; - - children = 0; - for (child = OF_child(ofw_bus_get_node(dev)); child != 0; - child = OF_peer(child)) { - if ((ldi = lebuffer_setup_dinfo(dev, child)) == NULL) - continue; - if (children != 0) { - device_printf(dev, - "<%s>: only one child per buffer supported\n", - ldi->ldi_obdinfo.obd_name); - lebuffer_destroy_dinfo(ldi); - continue; - } - if ((cdev = device_add_child(dev, NULL, -1)) == NULL) { - device_printf(dev, "<%s>: device_add_child failed\n", - ldi->ldi_obdinfo.obd_name); - lebuffer_destroy_dinfo(ldi); - continue; - } - device_set_ivars(cdev, ldi); - children++; - } - return (bus_generic_attach(dev)); -} - -static int -lebuffer_detach(device_t dev) -{ - device_t *children; - int i, nchildren; - - bus_generic_detach(dev); - if (device_get_children(dev, &children, &nchildren) == 0) { - for (i = 0; i < nchildren; i++) { - lebuffer_destroy_dinfo(device_get_ivars(children[i])); - device_delete_child(dev, children[i]); - } - free(children, M_TEMP); - } - return (0); -} - -static struct lebuffer_devinfo * -lebuffer_setup_dinfo(device_t dev, phandle_t node) -{ - struct lebuffer_devinfo *ldi; - struct sbus_regs *reg; - uint32_t base, iv, *intr; - int i, nreg, nintr, slot, rslot; - - ldi = malloc(sizeof(*ldi), M_DEVBUF, M_WAITOK | M_ZERO); - if (ofw_bus_gen_setup_devinfo(&ldi->ldi_obdinfo, node) != 0) { - free(ldi, M_DEVBUF); - return (NULL); - } - resource_list_init(&ldi->ldi_rl); - slot = -1; - nreg = OF_getprop_alloc_multi(node, "reg", sizeof(*reg), (void **)®); - if (nreg == -1) { - device_printf(dev, "<%s>: incomplete\n", - ldi->ldi_obdinfo.obd_name); - goto fail; - } - for (i = 0; i < nreg; i++) { - base = reg[i].sbr_offset; - if (SBUS_ABS(base)) { - rslot = SBUS_ABS_TO_SLOT(base); - base = SBUS_ABS_TO_OFFSET(base); - } else - rslot = reg[i].sbr_slot; - if (slot != -1 && slot != rslot) { - device_printf(dev, "<%s>: multiple slots\n", - ldi->ldi_obdinfo.obd_name); - OF_prop_free(reg); - goto fail; - } - slot = rslot; - - resource_list_add(&ldi->ldi_rl, SYS_RES_MEMORY, i, base, - base + reg[i].sbr_size, reg[i].sbr_size); - } - OF_prop_free(reg); - if (slot != sbus_get_slot(dev)) { - device_printf(dev, "<%s>: parent and child slot do not match\n", - ldi->ldi_obdinfo.obd_name); - goto fail; - } - - /* - * The `interrupts' property contains the SBus interrupt level. - */ - nintr = OF_getprop_alloc_multi(node, "interrupts", sizeof(*intr), - (void **)&intr); - if (nintr != -1) { - for (i = 0; i < nintr; i++) { - iv = intr[i]; - /* - * SBus card devices need the slot number encoded into - * the vector as this is generally not done. - */ - if ((iv & INTMAP_OBIO_MASK) == 0) - iv |= slot << 3; - /* Set the IGN as appropriate. */ - iv |= sbus_get_ign(dev) << INTMAP_IGN_SHIFT; - resource_list_add(&ldi->ldi_rl, SYS_RES_IRQ, i, - iv, iv, 1); - } - OF_prop_free(intr); - } - return (ldi); - - fail: - lebuffer_destroy_dinfo(ldi); - return (NULL); -} - -static void -lebuffer_destroy_dinfo(struct lebuffer_devinfo *dinfo) -{ - - resource_list_free(&dinfo->ldi_rl); - ofw_bus_gen_destroy_devinfo(&dinfo->ldi_obdinfo); - free(dinfo, M_DEVBUF); -} - -static int -lebuffer_print_child(device_t dev, device_t child) -{ - int rv; - - rv = bus_print_child_header(dev, child); - rv += lebuffer_print_res(device_get_ivars(child)); - rv += bus_print_child_footer(dev, child); - return (rv); -} - -static void -lebuffer_probe_nomatch(device_t dev, device_t child) -{ - const char *type; - - device_printf(dev, "<%s>", ofw_bus_get_name(child)); - lebuffer_print_res(device_get_ivars(child)); - type = ofw_bus_get_type(child); - printf(" type %s (no driver attached)\n", - type != NULL ? type : "unknown"); -} - -static struct resource_list * -lebuffer_get_resource_list(device_t dev, device_t child) -{ - struct lebuffer_devinfo *ldi; - - ldi = device_get_ivars(child); - return (&ldi->ldi_rl); -} - -static const struct ofw_bus_devinfo * -lebuffer_get_devinfo(device_t bus, device_t child) -{ - struct lebuffer_devinfo *ldi; - - ldi = device_get_ivars(child); - return (&ldi->ldi_obdinfo); -} - -static int -lebuffer_print_res(struct lebuffer_devinfo *ldi) -{ - int rv; - - rv = 0; - rv += resource_list_print_type(&ldi->ldi_rl, "mem", SYS_RES_MEMORY, - "%#jx"); - rv += resource_list_print_type(&ldi->ldi_rl, "irq", SYS_RES_IRQ, "%jd"); - return (rv); -} diff --git a/sys/dev/mfi/mfi.c b/sys/dev/mfi/mfi.c index 96c63fa3eb61..46fe586e0b5f 100644 --- a/sys/dev/mfi/mfi.c +++ b/sys/dev/mfi/mfi.c @@ -2152,7 +2152,9 @@ mfi_build_syspdio(struct mfi_softc *sc, struct bio *bio) break; default: /* TODO: what about BIO_DELETE??? */ - panic("Unsupported bio command %x\n", bio->bio_cmd); + biofinish(bio, NULL, EOPNOTSUPP); + mfi_enqueue_free(cm); + return (NULL); } /* Cheat with the sector length to avoid a non-constant division */ @@ -2211,7 +2213,9 @@ mfi_build_ldio(struct mfi_softc *sc, struct bio *bio) break; default: /* TODO: what about BIO_DELETE??? */ - panic("Unsupported bio command %x\n", bio->bio_cmd); + biofinish(bio, NULL, EOPNOTSUPP); + mfi_enqueue_free(cm); + return (NULL); } /* Cheat with the sector length to avoid a non-constant division */ diff --git a/sys/dev/mlx/mlx_disk.c b/sys/dev/mlx/mlx_disk.c index 1fb0a27c9da7..bc487d1330a0 100644 --- a/sys/dev/mlx/mlx_disk.c +++ b/sys/dev/mlx/mlx_disk.c @@ -157,6 +157,11 @@ mlxd_strategy(struct bio *bp) goto bad; } + if ((bp->bio_cmd != BIO_READ) && (bp->bio_cmd != BIO_WRITE)) { + bp->bio_error = EOPNOTSUPP; + goto bad; + } + /* XXX may only be temporarily offline - sleep? */ MLX_IO_LOCK(sc->mlxd_controller); if (sc->mlxd_drive->ms_state == MLX_SYSD_OFFLINE) { diff --git a/sys/dev/mmc/mmcsd.c b/sys/dev/mmc/mmcsd.c index dcb8290b821e..f9637ac4427f 100644 --- a/sys/dev/mmc/mmcsd.c +++ b/sys/dev/mmc/mmcsd.c @@ -1431,7 +1431,7 @@ mmcsd_task(void *arg) struct mmcsd_softc *sc; struct bio *bp; device_t dev, mmcbus; - int err, sz; + int bio_error, err, sz; part = arg; sc = part->sc; @@ -1482,11 +1482,14 @@ mmcsd_task(void *arg) block = mmcsd_rw(part, bp); } else if (bp->bio_cmd == BIO_DELETE) { block = mmcsd_delete(part, bp); + } else { + bio_error = EOPNOTSUPP; + goto release; } release: MMCBUS_RELEASE_BUS(mmcbus, dev); if (block < end) { - bp->bio_error = EIO; + bp->bio_error = (bio_error == 0) ? EIO : bio_error; bp->bio_resid = (end - block) * sz; bp->bio_flags |= BIO_ERROR; } else { diff --git a/sys/dev/mpr/mpr.c b/sys/dev/mpr/mpr.c index 4ef502d8c760..c5b1a9c01811 100644 --- a/sys/dev/mpr/mpr.c +++ b/sys/dev/mpr/mpr.c @@ -520,6 +520,12 @@ mpr_iocfacts_allocate(struct mpr_softc *sc, uint8_t attaching) sc->facts->FWVersion.Struct.Unit, sc->facts->FWVersion.Struct.Dev); + snprintf(sc->msg_version, sizeof(sc->msg_version), "%d.%d", + (sc->facts->MsgVersion & MPI2_IOCFACTS_MSGVERSION_MAJOR_MASK) >> + MPI2_IOCFACTS_MSGVERSION_MAJOR_SHIFT, + (sc->facts->MsgVersion & MPI2_IOCFACTS_MSGVERSION_MINOR_MASK) >> + MPI2_IOCFACTS_MSGVERSION_MINOR_SHIFT); + mpr_dprint(sc, MPR_INFO, "Firmware: %s, Driver: %s\n", sc->fw_version, MPR_DRIVER_VERSION); mpr_dprint(sc, MPR_INFO, @@ -1833,13 +1839,17 @@ mpr_setup_sysctl(struct mpr_softc *sc) "Total number of event frames allocated"); SYSCTL_ADD_STRING(sysctl_ctx, SYSCTL_CHILDREN(sysctl_tree), - OID_AUTO, "firmware_version", CTLFLAG_RW, sc->fw_version, + OID_AUTO, "firmware_version", CTLFLAG_RD, sc->fw_version, strlen(sc->fw_version), "firmware version"); SYSCTL_ADD_STRING(sysctl_ctx, SYSCTL_CHILDREN(sysctl_tree), - OID_AUTO, "driver_version", CTLFLAG_RW, MPR_DRIVER_VERSION, + OID_AUTO, "driver_version", CTLFLAG_RD, MPR_DRIVER_VERSION, strlen(MPR_DRIVER_VERSION), "driver version"); + SYSCTL_ADD_STRING(sysctl_ctx, SYSCTL_CHILDREN(sysctl_tree), + OID_AUTO, "msg_version", CTLFLAG_RD, sc->msg_version, + strlen(sc->msg_version), "message interface version"); + SYSCTL_ADD_INT(sysctl_ctx, SYSCTL_CHILDREN(sysctl_tree), OID_AUTO, "io_cmds_active", CTLFLAG_RD, &sc->io_cmds_active, 0, "number of currently active commands"); diff --git a/sys/dev/mpr/mprvar.h b/sys/dev/mpr/mprvar.h index 8f1f7a385c72..c18460085f56 100644 --- a/sys/dev/mpr/mprvar.h +++ b/sys/dev/mpr/mprvar.h @@ -372,6 +372,7 @@ struct mpr_softc { struct sysctl_ctx_list sysctl_ctx; struct sysctl_oid *sysctl_tree; char fw_version[16]; + char msg_version[8]; struct mpr_command *commands; struct mpr_chain *chains; struct mpr_prp_page *prps; diff --git a/sys/dev/mps/mps.c b/sys/dev/mps/mps.c index 046beda137fc..cff2e2aa080d 100644 --- a/sys/dev/mps/mps.c +++ b/sys/dev/mps/mps.c @@ -498,6 +498,12 @@ mps_iocfacts_allocate(struct mps_softc *sc, uint8_t attaching) sc->facts->FWVersion.Struct.Unit, sc->facts->FWVersion.Struct.Dev); + snprintf(sc->msg_version, sizeof(sc->msg_version), "%d.%d", + (sc->facts->MsgVersion & MPI2_IOCFACTS_MSGVERSION_MAJOR_MASK) >> + MPI2_IOCFACTS_MSGVERSION_MAJOR_SHIFT, + (sc->facts->MsgVersion & MPI2_IOCFACTS_MSGVERSION_MINOR_MASK) >> + MPI2_IOCFACTS_MSGVERSION_MINOR_SHIFT); + mps_dprint(sc, MPS_INFO, "Firmware: %s, Driver: %s\n", sc->fw_version, MPS_DRIVER_VERSION); mps_dprint(sc, MPS_INFO, "IOCCapabilities: %b\n", @@ -1742,13 +1748,17 @@ mps_setup_sysctl(struct mps_softc *sc) "Total number of event frames allocated"); SYSCTL_ADD_STRING(sysctl_ctx, SYSCTL_CHILDREN(sysctl_tree), - OID_AUTO, "firmware_version", CTLFLAG_RW, sc->fw_version, + OID_AUTO, "firmware_version", CTLFLAG_RD, sc->fw_version, strlen(sc->fw_version), "firmware version"); SYSCTL_ADD_STRING(sysctl_ctx, SYSCTL_CHILDREN(sysctl_tree), - OID_AUTO, "driver_version", CTLFLAG_RW, MPS_DRIVER_VERSION, + OID_AUTO, "driver_version", CTLFLAG_RD, MPS_DRIVER_VERSION, strlen(MPS_DRIVER_VERSION), "driver version"); + SYSCTL_ADD_STRING(sysctl_ctx, SYSCTL_CHILDREN(sysctl_tree), + OID_AUTO, "msg_version", CTLFLAG_RD, sc->msg_version, + strlen(sc->msg_version), "message interface version"); + SYSCTL_ADD_INT(sysctl_ctx, SYSCTL_CHILDREN(sysctl_tree), OID_AUTO, "io_cmds_active", CTLFLAG_RD, &sc->io_cmds_active, 0, "number of currently active commands"); diff --git a/sys/dev/mps/mpsvar.h b/sys/dev/mps/mpsvar.h index 3193198c6cbd..442ada4221bf 100644 --- a/sys/dev/mps/mpsvar.h +++ b/sys/dev/mps/mpsvar.h @@ -330,6 +330,7 @@ struct mps_softc { struct sysctl_ctx_list sysctl_ctx; struct sysctl_oid *sysctl_tree; char fw_version[16]; + char msg_version[8]; struct mps_command *commands; struct mps_chain *chains; struct callout periodic; diff --git a/sys/dev/mpt/mpt.h b/sys/dev/mpt/mpt.h index 1bff77e3758c..8c9000a03e68 100644 --- a/sys/dev/mpt/mpt.h +++ b/sys/dev/mpt/mpt.h @@ -122,11 +122,6 @@ #include #include -#ifdef __sparc64__ -#include -#include -#endif - #include #include diff --git a/sys/dev/mpt/mpt_pci.c b/sys/dev/mpt/mpt_pci.c index 2adaa95df32a..94c568c4c205 100644 --- a/sys/dev/mpt/mpt_pci.c +++ b/sys/dev/mpt/mpt_pci.c @@ -372,10 +372,6 @@ mpt_pci_attach(device_t dev) mpt->verbose = MPT_PRT_NONE; mpt->role = MPT_ROLE_NONE; mpt->mpt_ini_id = MPT_INI_ID_NONE; -#ifdef __sparc64__ - if (mpt->is_spi) - mpt->mpt_ini_id = OF_getscsinitid(dev); -#endif mpt_set_options(mpt); if (mpt->verbose == MPT_PRT_NONE) { mpt->verbose = MPT_PRT_WARN; diff --git a/sys/dev/mthca/mthca_srq.c b/sys/dev/mthca/mthca_srq.c index d22f970480c0..579c23a73654 100644 --- a/sys/dev/mthca/mthca_srq.c +++ b/sys/dev/mthca/mthca_srq.c @@ -115,16 +115,10 @@ static void mthca_arbel_init_srq_context(struct mthca_dev *dev, struct mthca_srq *srq, struct mthca_arbel_srq_context *context) { - int logsize, max; + int logsize; memset(context, 0, sizeof *context); - - /* - * Put max in a temporary variable to work around gcc bug - * triggered by ilog2() on sparc64. - */ - max = srq->max; - logsize = ilog2(max); + logsize = ilog2(srq->max); context->state_logsize_srqn = cpu_to_be32(logsize << 24 | srq->srqn); context->lkey = cpu_to_be32(srq->mr.ibmr.lkey); context->db_index = cpu_to_be32(srq->db_index); diff --git a/sys/dev/mxge/if_mxge_var.h b/sys/dev/mxge/if_mxge_var.h index dd9ec3ff2612..0c3950b5e005 100644 --- a/sys/dev/mxge/if_mxge_var.h +++ b/sys/dev/mxge/if_mxge_var.h @@ -325,27 +325,6 @@ struct mxge_pkt_info { }; -/* implement our own memory barriers, since bus_space_barrier - cannot handle write-combining regions */ - -#if __FreeBSD_version < 800053 - -#if defined (__GNUC__) - #if #cpu(i386) || defined __i386 || defined i386 || defined __i386__ || #cpu(x86_64) || defined __x86_64__ - #define wmb() __asm__ __volatile__ ("sfence;": : :"memory") - #elif #cpu(sparc64) || defined sparc64 || defined __sparcv9 - #define wmb() __asm__ __volatile__ ("membar #MemIssue": : :"memory") - #elif #cpu(sparc) || defined sparc || defined __sparc__ - #define wmb() __asm__ __volatile__ ("stbar;": : :"memory") - #else - #define wmb() /* XXX just to make this compile */ - #endif -#else - #error "unknown compiler" -#endif - -#endif - static inline void mxge_pio_copy(volatile void *to_v, void *from_v, size_t size) { diff --git a/sys/dev/nvme/nvme_ns.c b/sys/dev/nvme/nvme_ns.c index 006d059257c4..dd5465f9377f 100644 --- a/sys/dev/nvme/nvme_ns.c +++ b/sys/dev/nvme/nvme_ns.c @@ -488,7 +488,7 @@ nvme_ns_bio_process(struct nvme_namespace *ns, struct bio *bp, free(dsm_range, M_NVME); break; default: - err = EIO; + err = EOPNOTSUPP; break; } diff --git a/sys/dev/ofw/openfirm.h b/sys/dev/ofw/openfirm.h index 1f3f4bd0b255..53c8cdf88df8 100644 --- a/sys/dev/ofw/openfirm.h +++ b/sys/dev/ofw/openfirm.h @@ -178,13 +178,10 @@ int OF_interpret(const char *cmd, int nreturns, ...); /* * Decode the Nth register property of the given device node and create a bus * space tag and handle for accessing it. This is for use in setting up things - * like early console output before newbus is available. The implementation is - * machine-dependent, and sparc uses a different function signature as well. + * like early console output before newbus is available. */ -#ifndef __sparc64__ int OF_decode_addr(phandle_t dev, int regno, bus_space_tag_t *ptag, bus_space_handle_t *phandle, bus_size_t *sz); -#endif #endif /* _KERNEL */ #endif /* _DEV_OPENFIRM_H_ */ diff --git a/sys/dev/pcf/envctrl.c b/sys/dev/pcf/envctrl.c deleted file mode 100644 index 1d57b36e000e..000000000000 --- a/sys/dev/pcf/envctrl.c +++ /dev/null @@ -1,194 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD - * - * Copyright (c) 2004 Joerg Wunsch - * - * derived from sys/i386/isa/pcf.c which is: - * - * Copyright (c) 1998 Nicolas Souchu, Marc Bouget - * 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 -__FBSDID("$FreeBSD$"); - -/* - * Device specific driver for the SUNW,envctrl device found on some - * UltraSPARC Sun systems. This device is a Philips PCF8584 sitting - * on the Ebus2. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include -#include - -#include - -#include -#include -#include -#include "iicbus_if.h" - -#undef PCF_DEFAULT_ADDR -#define PCF_DEFAULT_ADDR 0x55 /* SUNW,pcf default */ - -static int envctrl_probe(device_t); -static int envctrl_attach(device_t); -static int envctrl_detach(device_t); - -static device_method_t envctrl_methods[] = { - /* device interface */ - DEVMETHOD(device_probe, envctrl_probe), - DEVMETHOD(device_attach, envctrl_attach), - DEVMETHOD(device_detach, envctrl_detach), - - /* iicbus interface */ - DEVMETHOD(iicbus_callback, iicbus_null_callback), - DEVMETHOD(iicbus_repeated_start, pcf_repeated_start), - DEVMETHOD(iicbus_start, pcf_start), - DEVMETHOD(iicbus_stop, pcf_stop), - DEVMETHOD(iicbus_write, pcf_write), - DEVMETHOD(iicbus_read, pcf_read), - DEVMETHOD(iicbus_reset, pcf_rst_card), - { 0, 0 } -}; - -static devclass_t envctrl_devclass; - -static driver_t envctrl_driver = { - "envctrl", - envctrl_methods, - sizeof(struct pcf_softc), -}; - -static int -envctrl_probe(device_t dev) -{ - - if (strcmp("SUNW,envctrl", ofw_bus_get_name(dev)) == 0) { - device_set_desc(dev, "EBus SUNW,envctrl"); - return (0); - } - return (ENXIO); -} - -static int -envctrl_attach(device_t dev) -{ - struct pcf_softc *sc; - int rv = ENXIO; - - sc = DEVTOSOFTC(dev); - mtx_init(&sc->pcf_lock, device_get_nameunit(dev), "pcf", MTX_DEF); - - /* IO port is mandatory */ - sc->res_ioport = bus_alloc_resource_any(dev, SYS_RES_MEMORY, - &sc->rid_ioport, RF_ACTIVE); - if (sc->res_ioport == 0) { - device_printf(dev, "cannot reserve I/O port range\n"); - goto error; - } - - sc->pcf_flags = device_get_flags(dev); - - if (!(sc->pcf_flags & IIC_POLLED)) { - sc->res_irq = bus_alloc_resource_any(dev, SYS_RES_IRQ, &sc->rid_irq, - RF_ACTIVE); - if (sc->res_irq == 0) { - device_printf(dev, "can't reserve irq, polled mode.\n"); - sc->pcf_flags |= IIC_POLLED; - } - } - - /* reset the chip */ - pcf_rst_card(dev, IIC_FASTEST, PCF_DEFAULT_ADDR, NULL); - - rv = bus_setup_intr(dev, sc->res_irq, - INTR_TYPE_NET | INTR_MPSAFE /* | INTR_ENTROPY */, - NULL, pcf_intr, sc, &sc->intr_cookie); - if (rv) { - device_printf(dev, "could not setup IRQ\n"); - goto error; - } - - if ((sc->iicbus = device_add_child(dev, "iicbus", -1)) == NULL) - device_printf(dev, "could not allocate iicbus instance\n"); - - /* probe and attach the iicbus */ - bus_generic_attach(dev); - - return (0); - -error: - if (sc->res_irq != 0) { - bus_release_resource(dev, SYS_RES_IRQ, sc->rid_irq, - sc->res_irq); - } - if (sc->res_ioport != 0) { - bus_release_resource(dev, SYS_RES_MEMORY, sc->rid_ioport, - sc->res_ioport); - } - mtx_destroy(&sc->pcf_lock); - return (rv); -} - -static int -envctrl_detach(device_t dev) -{ - struct pcf_softc *sc; - int rv; - - sc = DEVTOSOFTC(dev); - - if ((rv = bus_generic_detach(dev)) != 0) - return (rv); - - if ((rv = device_delete_child(dev, sc->iicbus)) != 0) - return (rv); - - if (sc->res_irq != 0) { - bus_teardown_intr(dev, sc->res_irq, sc->intr_cookie); - bus_release_resource(dev, SYS_RES_IRQ, sc->rid_irq, sc->res_irq); - } - - bus_release_resource(dev, SYS_RES_MEMORY, sc->rid_ioport, sc->res_ioport); - mtx_destroy(&sc->pcf_lock); - - return (0); -} - -DRIVER_MODULE(envctrl, ebus, envctrl_driver, envctrl_devclass, 0, 0); -DRIVER_MODULE(iicbus, envctrl, iicbus_driver, iicbus_devclass, 0, 0); diff --git a/sys/dev/pcf/pcf_ebus.c b/sys/dev/pcf/pcf_ebus.c deleted file mode 100644 index 3fa0be6b26cc..000000000000 --- a/sys/dev/pcf/pcf_ebus.c +++ /dev/null @@ -1,256 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD - * - * Copyright (c) 2004 Marius Strobl, Joerg Wunsch - * - * derived from sys/i386/isa/pcf.c which is: - * - * Copyright (c) 1998 Nicolas Souchu, Marc Bouget - * 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 -__FBSDID("$FreeBSD$"); - -/* - * Device specific driver for the EBus i2c devices found on some sun4u - * systems. On systems not having a boot-bus controller the i2c devices - * are PCF8584. - * - * Known onboard slave devices on the primary bus are: - * - * AXe: - * 0x40 PCF8574 I/O fan status (CPU fans 1+2) - * 0x9e PCF8591 A/D temperature (CPU + hotspot) - * - * AXmp: - * 0x70 PCF8574 I/O fan status (fans 1-4) - * 0x78 PCF8574 I/O fan fail interrupt - * 0x9a PCF8591 A/D voltage (CPU core) - * 0x9c PCF8591 A/D temperature (hotspots 1+2, aux. analog 1+2) - * 0x9e PCF8591 A/D temperature (CPUs 1-4) - * - * CP1400: - * 0x70 PCF8574 I/O reserved for factory use - * 0x9e PCF8591 A/D temperature (CPU) - * - * CP1500: - * 0x70 PCF8574 I/O reserved for factory use - * 0x72 PCF8574 I/O geographic address + power supply status lines - * 0x9e PCF8591 A/D temperature (CPU) - * 0xa0 AT24C01A hostid - * - * For AXmp, CP1400 and CP1500 these are described in more detail in: - * http://www.sun.com/oem/products/manuals/805-7581-04.pdf - * - */ - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include -#include - -#include - -#include -#include -#include "iicbus_if.h" - -#define PCF_NAME "pcf" - -static int pcf_ebus_probe(device_t); -static int pcf_ebus_attach(device_t); -static int pcf_ebus_detach(device_t); - -static device_method_t pcf_ebus_methods[] = { - /* device interface */ - DEVMETHOD(device_probe, pcf_ebus_probe), - DEVMETHOD(device_attach, pcf_ebus_attach), - DEVMETHOD(device_detach, pcf_ebus_detach), - - /* iicbus interface */ - DEVMETHOD(iicbus_callback, iicbus_null_callback), - DEVMETHOD(iicbus_repeated_start, pcf_repeated_start), - DEVMETHOD(iicbus_start, pcf_start), - DEVMETHOD(iicbus_stop, pcf_stop), - DEVMETHOD(iicbus_write, pcf_write), - DEVMETHOD(iicbus_read, pcf_read), - DEVMETHOD(iicbus_reset, pcf_rst_card), - { 0, 0 } -}; - -static devclass_t pcf_ebus_devclass; - -static driver_t pcf_ebus_driver = { - PCF_NAME, - pcf_ebus_methods, - sizeof(struct pcf_softc), -}; - -static int -pcf_ebus_probe(device_t dev) -{ - const char *compat; - - /* - * We must not attach to this i2c device if this is a system with - * a boot-bus controller. Additionally testing the compatibility - * property will hopefully take care of this. - */ - if (strcmp("i2c", ofw_bus_get_name(dev)) == 0) { - compat = ofw_bus_get_compat(dev); - if (compat != NULL && strcmp("i2cpcf,8584", compat) == 0) { - device_set_desc(dev, "PCF8584 I2C bus controller"); - return (0); - } - } - return (ENXIO); -} - -static int -pcf_ebus_attach(device_t dev) -{ - struct pcf_softc *sc; - int rv = ENXIO; - phandle_t node; - uint64_t own_addr; - - sc = DEVTOSOFTC(dev); - mtx_init(&sc->pcf_lock, device_get_nameunit(dev), "pcf", MTX_DEF); - - /* get OFW node of the pcf */ - if ((node = ofw_bus_get_node(dev)) == -1) { - device_printf(dev, "cannot get OFW node\n"); - goto error; - } - - /* IO port is mandatory */ - sc->res_ioport = bus_alloc_resource_any(dev, SYS_RES_MEMORY, - &sc->rid_ioport, RF_ACTIVE); - if (sc->res_ioport == 0) { - device_printf(dev, "cannot reserve I/O port range\n"); - goto error; - } - - sc->pcf_flags = device_get_flags(dev); - - /* - * XXX use poll-mode property? - */ - if (!(sc->pcf_flags & IIC_POLLED)) { - sc->res_irq = bus_alloc_resource_any(dev, SYS_RES_IRQ, - &sc->rid_irq, RF_ACTIVE); - if (sc->res_irq == 0) { - device_printf(dev, "can't reserve irq, polled mode.\n"); - sc->pcf_flags |= IIC_POLLED; - } - } - - /* - * XXX on AXmp there's probably a second IRQ which is the fan fail - * interrupt genererated by the PCF8574 at 0x78. - */ - - /* get address of the pcf */ - if (OF_getprop(node, "own-address", &own_addr, sizeof(own_addr)) == - -1) { - device_printf(dev, "cannot get own address\n"); - goto error; - } - if (bootverbose) - device_printf(dev, "PCF8584 address: 0x%08llx\n", (unsigned - long long)own_addr); - - /* reset the chip */ - pcf_rst_card(dev, IIC_FASTEST, own_addr, NULL); - - if (sc->res_irq) { - rv = bus_setup_intr(dev, sc->res_irq, - INTR_TYPE_NET /* | INTR_ENTROPY */, NULL, pcf_intr, sc, - &sc->intr_cookie); - if (rv) { - device_printf(dev, "could not setup IRQ\n"); - goto error; - } - } - - if ((sc->iicbus = device_add_child(dev, "iicbus", -1)) == NULL) - device_printf(dev, "could not allocate iicbus instance\n"); - - /* probe and attach the iicbus */ - bus_generic_attach(dev); - - return (0); - -error: - if (sc->res_irq != 0) { - bus_release_resource(dev, SYS_RES_IRQ, sc->rid_irq, - sc->res_irq); - } - if (sc->res_ioport != 0) { - bus_release_resource(dev, SYS_RES_MEMORY, sc->rid_ioport, - sc->res_ioport); - } - mtx_destroy(&sc->pcf_lock); - return (rv); -} - -static int -pcf_ebus_detach(device_t dev) -{ - struct pcf_softc *sc; - int rv; - - sc = DEVTOSOFTC(dev); - - if ((rv = bus_generic_detach(dev)) != 0) - return (rv); - - if ((rv = device_delete_child(dev, sc->iicbus)) != 0) - return (rv); - - if (sc->res_irq != 0) { - bus_teardown_intr(dev, sc->res_irq, - sc->intr_cookie); - bus_release_resource(dev, SYS_RES_IRQ, sc->rid_irq, - sc->res_irq); - } - - bus_release_resource(dev, SYS_RES_MEMORY, sc->rid_ioport, - sc->res_ioport); - mtx_destroy(&sc->pcf_lock); - - return (0); -} - -DRIVER_MODULE(pcf_ebus, ebus, pcf_ebus_driver, pcf_ebus_devclass, 0, 0); diff --git a/sys/dev/proto/proto_core.c b/sys/dev/proto/proto_core.c index 404ba498f09d..44199bdd7b8f 100644 --- a/sys/dev/proto/proto_core.c +++ b/sys/dev/proto/proto_core.c @@ -507,9 +507,7 @@ proto_mmap(struct cdev *cdev, vm_ooffset_t offset, vm_paddr_t *paddr, if (offset >= r->r_size) return (EINVAL); *paddr = rman_get_start(r->r_d.res) + offset; -#ifndef __sparc64__ *memattr = VM_MEMATTR_UNCACHEABLE; -#endif break; case PROTO_RES_BUSDMA: if (!proto_busdma_mmap_allowed(r->r_d.busdma, offset)) diff --git a/sys/dev/pst/pst-raid.c b/sys/dev/pst/pst-raid.c index 2c16064981ab..eda4dd4022f6 100644 --- a/sys/dev/pst/pst-raid.c +++ b/sys/dev/pst/pst-raid.c @@ -214,6 +214,7 @@ pst_start(struct pst_softc *psc) struct pst_request *request; struct bio *bp; u_int32_t mfa; + int error; if (psc->iop->outstanding < (I2O_IOP_OUTBOUND_FRAME_COUNT - 1) && (bp = bioq_first(&psc->queue))) { @@ -231,8 +232,8 @@ pst_start(struct pst_softc *psc) request->psc = psc; request->mfa = mfa; request->bp = bp; - if (pst_rw(request)) { - biofinish(request->bp, NULL, EIO); + if ((error = pst_rw(request)) != 0) { + biofinish(request->bp, NULL, error); iop_free_mfa(request->psc->iop, request->mfa); psc->iop->outstanding--; free(request, M_PSTRAID); @@ -286,7 +287,7 @@ pst_rw(struct pst_request *request) break; default: printf("pst: unknown command type 0x%02x\n", request->bp->bio_cmd); - return -1; + return EOPNOTSUPP; } msg->initiator_context = (u_int32_t)pst_done; msg->transaction_context = (u_int32_t)request; @@ -296,7 +297,7 @@ pst_rw(struct pst_request *request) if (!iop_create_sgl((struct i2o_basic_message *)msg, request->bp->bio_data, request->bp->bio_bcount, sgl_flag)) - return -1; + return EIO; request->psc->iop->reg->iqueue = request->mfa; @@ -309,6 +310,7 @@ static void pst_timeout(void *arg) { struct pst_request *request; + int error; request = arg; printf("pst: timeout mfa=0x%08x cmd=0x%02x\n", @@ -321,9 +323,9 @@ pst_timeout(void *arg) request->psc->iop->outstanding--; return; } - if (pst_rw(request)) { + if ((error = pst_rw(request)) != 0) { iop_free_mfa(request->psc->iop, request->mfa); - biofinish(request->bp, NULL, EIO); + biofinish(request->bp, NULL, error); request->psc->iop->outstanding--; } } diff --git a/sys/dev/scc/scc_bfe_ebus.c b/sys/dev/scc/scc_bfe_ebus.c deleted file mode 100644 index 365eb28444ee..000000000000 --- a/sys/dev/scc/scc_bfe_ebus.c +++ /dev/null @@ -1,99 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD - * - * Copyright (c) 2004-2006 Marcel Moolenaar - * 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 ``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 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 -__FBSDID("$FreeBSD$"); - -#include -#include -#include -#include -#include -#include - -#include - -#include -#include -#include - -#include - -#define EBUS_REGSHFT 0 -#define EBUS_RCLK 29491200 - -static int -scc_ebus_probe(device_t dev) -{ - struct scc_softc *sc; - const char *cmpt, *nm; - - sc = device_get_softc(dev); - nm = ofw_bus_get_name(dev); - cmpt = ofw_bus_get_compat(dev); - if (cmpt == NULL) - cmpt = ""; - if (!strcmp(nm, "se") || !strcmp(nm, "FJSV,se") || - !strcmp(cmpt, "sab82532")) { - device_set_desc(dev, "Siemens SAB 82532 dual channel SCC"); - sc->sc_class = &scc_sab82532_class; - return (scc_bfe_probe(dev, EBUS_REGSHFT, EBUS_RCLK, 0)); - } - return (ENXIO); -} - -static int -scc_ebus_attach(device_t dev) -{ - - return (scc_bfe_attach(dev, 0)); -} - -static device_method_t scc_ebus_methods[] = { - /* Device interface */ - DEVMETHOD(device_probe, scc_ebus_probe), - DEVMETHOD(device_attach, scc_ebus_attach), - DEVMETHOD(device_detach, scc_bfe_detach), - - DEVMETHOD(bus_alloc_resource, scc_bus_alloc_resource), - DEVMETHOD(bus_release_resource, scc_bus_release_resource), - DEVMETHOD(bus_get_resource, scc_bus_get_resource), - DEVMETHOD(bus_read_ivar, scc_bus_read_ivar), - DEVMETHOD(bus_setup_intr, scc_bus_setup_intr), - DEVMETHOD(bus_teardown_intr, scc_bus_teardown_intr), - - DEVMETHOD_END -}; - -static driver_t scc_ebus_driver = { - scc_driver_name, - scc_ebus_methods, - sizeof(struct scc_softc), -}; - -DRIVER_MODULE(scc, ebus, scc_ebus_driver, scc_devclass, NULL, NULL); diff --git a/sys/dev/scc/scc_bfe_sbus.c b/sys/dev/scc/scc_bfe_sbus.c deleted file mode 100644 index b6f0f1a0e8b8..000000000000 --- a/sys/dev/scc/scc_bfe_sbus.c +++ /dev/null @@ -1,96 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD - * - * Copyright (c) 2004-2006 Marcel Moolenaar - * 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 ``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 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 -__FBSDID("$FreeBSD$"); - -#include -#include -#include -#include -#include -#include - -#include - -#include -#include -#include - -#include - -#define SBUS_REGSHFT 1 -#define SBUS_RCLK 307200 - -static int -scc_sbus_probe(device_t dev) -{ - struct scc_softc *sc; - const char *nm; - - sc = device_get_softc(dev); - nm = ofw_bus_get_name(dev); - if (!strcmp(nm, "zs")) { - device_set_desc(dev, "Zilog Z8530 dual channel SCC"); - sc->sc_class = &scc_z8530_class; - return (scc_bfe_probe(dev, SBUS_REGSHFT, SBUS_RCLK, 0)); - } - return (ENXIO); -} - -static int -scc_sbus_attach(device_t dev) -{ - - return (scc_bfe_attach(dev, 0)); -} - -static device_method_t scc_sbus_methods[] = { - /* Device interface */ - DEVMETHOD(device_probe, scc_sbus_probe), - DEVMETHOD(device_attach, scc_sbus_attach), - DEVMETHOD(device_detach, scc_bfe_detach), - - DEVMETHOD(bus_alloc_resource, scc_bus_alloc_resource), - DEVMETHOD(bus_release_resource, scc_bus_release_resource), - DEVMETHOD(bus_get_resource, scc_bus_get_resource), - DEVMETHOD(bus_read_ivar, scc_bus_read_ivar), - DEVMETHOD(bus_setup_intr, scc_bus_setup_intr), - DEVMETHOD(bus_teardown_intr, scc_bus_teardown_intr), - - DEVMETHOD_END -}; - -static driver_t scc_sbus_driver = { - scc_driver_name, - scc_sbus_methods, - sizeof(struct scc_softc), -}; - -DRIVER_MODULE(scc, fhc, scc_sbus_driver, scc_devclass, NULL, NULL); -DRIVER_MODULE(scc, sbus, scc_sbus_driver, scc_devclass, NULL, NULL); diff --git a/sys/dev/sfxge/common/efsys.h b/sys/dev/sfxge/common/efsys.h index 1d9ec6a0f228..09825cd23565 100644 --- a/sys/dev/sfxge/common/efsys.h +++ b/sys/dev/sfxge/common/efsys.h @@ -130,26 +130,6 @@ prefetch_read_once(void *addr) : : "r" (addr)); } -#elif defined(__sparc64__) -static __inline void -prefetch_read_many(void *addr) -{ - - __asm__( - "prefetch [%0], 0" - : - : "r" (addr)); -} - -static __inline void -prefetch_read_once(void *addr) -{ - - __asm__( - "prefetch [%0], 1" - : - : "r" (addr)); -} #else static __inline void prefetch_read_many(void *addr) diff --git a/sys/dev/sound/pci/t4dwave.c b/sys/dev/sound/pci/t4dwave.c index a7c5cd2be6b9..f046b8a47e21 100644 --- a/sys/dev/sound/pci/t4dwave.c +++ b/sys/dev/sound/pci/t4dwave.c @@ -829,11 +829,6 @@ tr_pci_attach(device_t dev) bus_addr_t lowaddr; int i, dacn; char status[SND_STATUSLEN]; -#ifdef __sparc64__ - device_t *children; - int nchildren; - u_int32_t data; -#endif tr = malloc(sizeof(*tr), M_DEVBUF, M_WAITOK | M_ZERO); tr->type = pci_get_devid(dev); @@ -900,34 +895,9 @@ tr_pci_attach(device_t dev) * using a low address of BUS_SPACE_MAXADDR_32BIT for both * we might end up with the play buffer being in the 32-bit * range while the record buffer isn't or vice versa. So we - * limit enabling the 31st bit to sparc64, where the IOMMU - * guarantees that we're using a 32-bit address (and in turn - * requires it). + * don't enabling the 31st bit. */ lowaddr = ALI_MAXADDR; -#ifdef __sparc64__ - if (device_get_children(device_get_parent(dev), &children, - &nchildren) == 0) { - for (i = 0; i < nchildren; i++) { - if (pci_get_devid(children[i]) == 0x153310b9) { - lowaddr = BUS_SPACE_MAXADDR_32BIT; - data = pci_read_config(children[i], - 0x7e, 1); - if (bootverbose) - device_printf(dev, - "M1533 0x7e: 0x%x -> ", - data); - data |= 0x1; - if (bootverbose) - printf("0x%x\n", data); - pci_write_config(children[i], 0x7e, - data, 1); - break; - } - } - } - free(children, M_TEMP); -#endif tr->hwchns = ALI_MAXHWCH; tr->bufsz = ALI_BUFSZ; } else { diff --git a/sys/dev/sound/sbus/apcdmareg.h b/sys/dev/sound/sbus/apcdmareg.h deleted file mode 100644 index 719da7d09d12..000000000000 --- a/sys/dev/sound/sbus/apcdmareg.h +++ /dev/null @@ -1,116 +0,0 @@ -/* $FreeBSD$ */ -/* $OpenBSD: apcdmareg.h,v 1.2 2003/06/02 18:53:18 jason Exp $ */ - -/*- - * SPDX-License-Identifier: BSD-2-Clause - * - * Copyright (c) 2001 Jason L. Wright (jason@thought.net) - * 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 ``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 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. - */ - -/* - * Definitions for Sun APC DMA controller. - */ - -/* APC DMA registers */ -#define APC_CSR 0x0010 /* control/status */ -#define APC_CVA 0x0020 /* capture virtual address */ -#define APC_CC 0x0024 /* capture count */ -#define APC_CNVA 0x0028 /* capture next virtual address */ -#define APC_CNC 0x002c /* capture next count */ -#define APC_PVA 0x0030 /* playback virtual address */ -#define APC_PC 0x0034 /* playback count */ -#define APC_PNVA 0x0038 /* playback next virtual address */ -#define APC_PNC 0x003c /* playback next count */ - -/* - * APC DMA Register definitions - */ -#define APC_CSR_RESET 0x00000001 /* reset */ -#define APC_CSR_CDMA_GO 0x00000004 /* capture dma go */ -#define APC_CSR_PDMA_GO 0x00000008 /* playback dma go */ -#define APC_CSR_CODEC_RESET 0x00000020 /* codec reset */ -#define APC_CSR_CPAUSE 0x00000040 /* capture dma pause */ -#define APC_CSR_PPAUSE 0x00000080 /* playback dma pause */ -#define APC_CSR_CMIE 0x00000100 /* capture pipe empty enb */ -#define APC_CSR_CMI 0x00000200 /* capture pipe empty intr */ -#define APC_CSR_CD 0x00000400 /* capture nva dirty */ -#define APC_CSR_CM 0x00000800 /* capture data lost */ -#define APC_CSR_PMIE 0x00001000 /* pb pipe empty intr enable */ -#define APC_CSR_PD 0x00002000 /* pb nva dirty */ -#define APC_CSR_PM 0x00004000 /* pb pipe empty */ -#define APC_CSR_PMI 0x00008000 /* pb pipe empty interrupt */ -#define APC_CSR_EIE 0x00010000 /* error interrupt enable */ -#define APC_CSR_CIE 0x00020000 /* capture intr enable */ -#define APC_CSR_PIE 0x00040000 /* playback intr enable */ -#define APC_CSR_GIE 0x00080000 /* general intr enable */ -#define APC_CSR_EI 0x00100000 /* error interrupt */ -#define APC_CSR_CI 0x00200000 /* capture interrupt */ -#define APC_CSR_PI 0x00400000 /* playback interrupt */ -#define APC_CSR_GI 0x00800000 /* general interrupt */ - -#define APC_CSR_PLAY ( \ - APC_CSR_EI | \ - APC_CSR_GIE | \ - APC_CSR_PIE | \ - APC_CSR_EIE | \ - APC_CSR_PDMA_GO | \ - APC_CSR_PMIE ) - -#define APC_CSR_CAPTURE ( \ - APC_CSR_EI | \ - APC_CSR_GIE | \ - APC_CSR_CIE | \ - APC_CSR_EIE | \ - APC_CSR_CDMA_GO ) - -#define APC_CSR_PLAY_PAUSE (~( \ - APC_CSR_PPAUSE | \ - APC_CSR_GI | \ - APC_CSR_PI | \ - APC_CSR_CI | \ - APC_CSR_EI | \ - APC_CSR_PMI | \ - APC_CSR_PMIE | \ - APC_CSR_CMI | \ - APC_CSR_CMIE ) ) - -#define APC_CSR_CAPTURE_PAUSE (~( \ - APC_CSR_PPAUSE | \ - APC_CSR_GI | \ - APC_CSR_PI | \ - APC_CSR_CI | \ - APC_CSR_EI | \ - APC_CSR_PMI | \ - APC_CSR_PMIE | \ - APC_CSR_CMI | \ - APC_CSR_CMIE ) ) - -#define APC_CSR_INTR_MASK ( \ - APC_CSR_GI | \ - APC_CSR_PI | \ - APC_CSR_CI | \ - APC_CSR_EI | \ - APC_CSR_PMI | \ - APC_CSR_CMI ) diff --git a/sys/dev/sound/sbus/cs4231.c b/sys/dev/sound/sbus/cs4231.c deleted file mode 100644 index 0fb7164d0f51..000000000000 --- a/sys/dev/sound/sbus/cs4231.c +++ /dev/null @@ -1,1566 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD - * - * Copyright (c) 1999 Jason L. Wright (jason@thought.net) - * Copyright (c) 2004 Pyun YongHyeon - * 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 ``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 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. - * - * Effort sponsored in part by the Defense Advanced Research Projects - * Agency (DARPA) and Air Force Research Laboratory, Air Force - * Materiel Command, USAF, under agreement number F30602-01-2-0537. - * - * from: OpenBSD: cs4231.c,v 1.21 2003/07/03 20:36:07 jason Exp - */ - -/* - * Driver for CS4231 based audio found in some sun4m systems (cs4231) - * based on ideas from the S/Linux project and the NetBSD project. - */ - -#include -__FBSDID("$FreeBSD$"); - -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#ifdef HAVE_KERNEL_OPTION_HEADERS -#include "opt_snd.h" -#endif - -#include -#include -#include - -#include -#include - -#include "mixer_if.h" - -/* - * The driver supports CS4231A audio chips found on Sbus/Ebus based - * UltraSPARCs. Though, CS4231A says it supports full-duplex mode, I - * doubt it due to the lack of independent sampling frequency register - * for playback/capture. - * Since I couldn't find any documentation for APCDMA programming - * information, I guessed the usage of APCDMA from that of OpenBSD's - * driver. The EBDMA information of PCIO can be obtained from - * http://solutions.sun.com/embedded/databook/web/microprocessors/pcio.html - * And CS4231A datasheet can also be obtained from - * ftp://ftp.alsa-project.org/pub/manuals/cirrus/4231a.pdf - * - * Audio capture(recording) was not tested at all and may have bugs. - * Sorry, I don't have microphone. Don't try to use full-duplex mode. - * It wouldn't work. - */ -#define CS_TIMEOUT 90000 - -#define CS4231_MIN_BUF_SZ (16*1024) -#define CS4231_DEFAULT_BUF_SZ (32*1024) -#define CS4231_MAX_BUF_SZ (64*1024) -#define CS4231_MAX_BLK_SZ (8*1024) -#define CS4231_MAX_APC_DMA_SZ (8*1024) - - -#undef CS4231_DEBUG -#ifdef CS4231_DEBUG -#define DPRINTF(x) printf x -#else -#define DPRINTF(x) -#endif -#define CS4231_AUTO_CALIBRATION - -struct cs4231_softc; - -struct cs4231_channel { - struct cs4231_softc *parent; - struct pcm_channel *channel; - struct snd_dbuf *buffer; - u_int32_t format; - u_int32_t speed; - u_int32_t nextaddr; - u_int32_t togo; - int dir; - int locked; -}; - -#define CS4231_RES_MEM_MAX 4 -#define CS4231_RES_IRQ_MAX 2 -struct cs4231_softc { - device_t sc_dev; - int sc_rid[CS4231_RES_MEM_MAX]; - struct resource *sc_res[CS4231_RES_MEM_MAX]; - bus_space_handle_t sc_regh[CS4231_RES_MEM_MAX]; - bus_space_tag_t sc_regt[CS4231_RES_MEM_MAX]; - - int sc_irqrid[CS4231_RES_IRQ_MAX]; - struct resource *sc_irqres[CS4231_RES_IRQ_MAX]; - void *sc_ih[CS4231_RES_IRQ_MAX]; - bus_dma_tag_t sc_dmat[CS4231_RES_IRQ_MAX]; - int sc_burst; - - u_int32_t sc_bufsz; - struct cs4231_channel sc_pch; - struct cs4231_channel sc_rch; - int sc_enabled; - int sc_nmres; - int sc_nires; - int sc_codecv; - int sc_chipvid; - int sc_flags; -#define CS4231_SBUS 0x01 -#define CS4231_EBUS 0x02 - - struct mtx *sc_lock; -}; - -struct mix_table { - u_int32_t reg:8; - u_int32_t bits:8; - u_int32_t mute:8; - u_int32_t shift:4; - u_int32_t neg:1; - u_int32_t avail:1; - u_int32_t recdev:1; -}; - -static int cs4231_bus_probe(device_t); -static int cs4231_sbus_attach(device_t); -static int cs4231_ebus_attach(device_t); -static int cs4231_attach_common(struct cs4231_softc *); -static int cs4231_bus_detach(device_t); -static int cs4231_bus_suspend(device_t); -static int cs4231_bus_resume(device_t); -static void cs4231_getversion(struct cs4231_softc *); -static void cs4231_free_resource(struct cs4231_softc *); -static void cs4231_ebdma_reset(struct cs4231_softc *); -static void cs4231_power_reset(struct cs4231_softc *, int); -static int cs4231_enable(struct cs4231_softc *, int); -static void cs4231_disable(struct cs4231_softc *); -static void cs4231_write(struct cs4231_softc *, u_int8_t, u_int8_t); -static u_int8_t cs4231_read(struct cs4231_softc *, u_int8_t); -static void cs4231_sbus_intr(void *); -static void cs4231_ebus_pintr(void *arg); -static void cs4231_ebus_cintr(void *arg); -static int cs4231_mixer_init(struct snd_mixer *); -static void cs4231_mixer_set_value(struct cs4231_softc *, - const struct mix_table *, u_int8_t); -static int cs4231_mixer_set(struct snd_mixer *, u_int32_t, u_int32_t, - u_int32_t); -static u_int32_t cs4231_mixer_setrecsrc(struct snd_mixer *, u_int32_t); -static void *cs4231_chan_init(kobj_t, void *, struct snd_dbuf *, - struct pcm_channel *, int); -static int cs4231_chan_setformat(kobj_t, void *, u_int32_t); -static u_int32_t cs4231_chan_setspeed(kobj_t, void *, u_int32_t); -static void cs4231_chan_fs(struct cs4231_softc *, int, u_int8_t); -static u_int32_t cs4231_chan_setblocksize(kobj_t, void *, u_int32_t); -static int cs4231_chan_trigger(kobj_t, void *, int); -static u_int32_t cs4231_chan_getptr(kobj_t, void *); -static struct pcmchan_caps * - cs4231_chan_getcaps(kobj_t, void *); -static void cs4231_trigger(struct cs4231_channel *); -static void cs4231_apcdma_trigger(struct cs4231_softc *, - struct cs4231_channel *); -static void cs4231_ebdma_trigger(struct cs4231_softc *, - struct cs4231_channel *); -static void cs4231_halt(struct cs4231_channel *); - -#define CS4231_LOCK(sc) snd_mtxlock(sc->sc_lock) -#define CS4231_UNLOCK(sc) snd_mtxunlock(sc->sc_lock) -#define CS4231_LOCK_ASSERT(sc) snd_mtxassert(sc->sc_lock) - -#define CS_WRITE(sc,r,v) \ - bus_space_write_1((sc)->sc_regt[0], (sc)->sc_regh[0], (r) << 2, (v)) -#define CS_READ(sc,r) \ - bus_space_read_1((sc)->sc_regt[0], (sc)->sc_regh[0], (r) << 2) - -#define APC_WRITE(sc,r,v) \ - bus_space_write_4(sc->sc_regt[0], sc->sc_regh[0], r, v) -#define APC_READ(sc,r) \ - bus_space_read_4(sc->sc_regt[0], sc->sc_regh[0], r) - -#define EBDMA_P_WRITE(sc,r,v) \ - bus_space_write_4((sc)->sc_regt[1], (sc)->sc_regh[1], (r), (v)) -#define EBDMA_P_READ(sc,r) \ - bus_space_read_4((sc)->sc_regt[1], (sc)->sc_regh[1], (r)) - -#define EBDMA_C_WRITE(sc,r,v) \ - bus_space_write_4((sc)->sc_regt[2], (sc)->sc_regh[2], (r), (v)) -#define EBDMA_C_READ(sc,r) \ - bus_space_read_4((sc)->sc_regt[2], (sc)->sc_regh[2], (r)) - -#define AUXIO_CODEC 0x00 -#define AUXIO_WRITE(sc,r,v) \ - bus_space_write_4((sc)->sc_regt[3], (sc)->sc_regh[3], (r), (v)) -#define AUXIO_READ(sc,r) \ - bus_space_read_4((sc)->sc_regt[3], (sc)->sc_regh[3], (r)) - -#define CODEC_WARM_RESET 0 -#define CODEC_COLD_RESET 1 - -/* SBus */ -static device_method_t cs4231_sbus_methods[] = { - DEVMETHOD(device_probe, cs4231_bus_probe), - DEVMETHOD(device_attach, cs4231_sbus_attach), - DEVMETHOD(device_detach, cs4231_bus_detach), - DEVMETHOD(device_suspend, cs4231_bus_suspend), - DEVMETHOD(device_resume, cs4231_bus_resume), - - DEVMETHOD_END -}; - -static driver_t cs4231_sbus_driver = { - "pcm", - cs4231_sbus_methods, - PCM_SOFTC_SIZE -}; - -DRIVER_MODULE(snd_audiocs, sbus, cs4231_sbus_driver, pcm_devclass, 0, 0); - -/* EBus */ -static device_method_t cs4231_ebus_methods[] = { - DEVMETHOD(device_probe, cs4231_bus_probe), - DEVMETHOD(device_attach, cs4231_ebus_attach), - DEVMETHOD(device_detach, cs4231_bus_detach), - DEVMETHOD(device_suspend, cs4231_bus_suspend), - DEVMETHOD(device_resume, cs4231_bus_resume), - - DEVMETHOD_END -}; - -static driver_t cs4231_ebus_driver = { - "pcm", - cs4231_ebus_methods, - PCM_SOFTC_SIZE -}; - -DRIVER_MODULE(snd_audiocs, ebus, cs4231_ebus_driver, pcm_devclass, 0, 0); -MODULE_DEPEND(snd_audiocs, sound, SOUND_MINVER, SOUND_PREFVER, SOUND_MAXVER); -MODULE_VERSION(snd_audiocs, 1); - - -static u_int32_t cs4231_fmt[] = { - SND_FORMAT(AFMT_U8, 1, 0), - SND_FORMAT(AFMT_U8, 2, 0), - SND_FORMAT(AFMT_MU_LAW, 1, 0), - SND_FORMAT(AFMT_MU_LAW, 2, 0), - SND_FORMAT(AFMT_A_LAW, 1, 0), - SND_FORMAT(AFMT_A_LAW, 2, 0), - SND_FORMAT(AFMT_IMA_ADPCM, 1, 0), - SND_FORMAT(AFMT_IMA_ADPCM, 2, 0), - SND_FORMAT(AFMT_S16_LE, 1, 0), - SND_FORMAT(AFMT_S16_LE, 2, 0), - SND_FORMAT(AFMT_S16_BE, 1, 0), - SND_FORMAT(AFMT_S16_BE, 2, 0), - 0 -}; - -static struct pcmchan_caps cs4231_caps = {5510, 48000, cs4231_fmt, 0}; - -/* - * sound(4) channel interface - */ -static kobj_method_t cs4231_chan_methods[] = { - KOBJMETHOD(channel_init, cs4231_chan_init), - KOBJMETHOD(channel_setformat, cs4231_chan_setformat), - KOBJMETHOD(channel_setspeed, cs4231_chan_setspeed), - KOBJMETHOD(channel_setblocksize, cs4231_chan_setblocksize), - KOBJMETHOD(channel_trigger, cs4231_chan_trigger), - KOBJMETHOD(channel_getptr, cs4231_chan_getptr), - KOBJMETHOD(channel_getcaps, cs4231_chan_getcaps), - KOBJMETHOD_END -}; -CHANNEL_DECLARE(cs4231_chan); - -/* - * sound(4) mixer interface - */ -static kobj_method_t cs4231_mixer_methods[] = { - KOBJMETHOD(mixer_init, cs4231_mixer_init), - KOBJMETHOD(mixer_set, cs4231_mixer_set), - KOBJMETHOD(mixer_setrecsrc, cs4231_mixer_setrecsrc), - KOBJMETHOD_END -}; -MIXER_DECLARE(cs4231_mixer); - -static int -cs4231_bus_probe(device_t dev) -{ - const char *compat, *name; - - compat = ofw_bus_get_compat(dev); - name = ofw_bus_get_name(dev); - if (strcmp("SUNW,CS4231", name) == 0 || - (compat != NULL && strcmp("SUNW,CS4231", compat) == 0)) { - device_set_desc(dev, "Sun Audiocs"); - return (BUS_PROBE_DEFAULT); - } - return (ENXIO); -} - -static int -cs4231_sbus_attach(device_t dev) -{ - struct cs4231_softc *sc; - int burst; - - sc = malloc(sizeof(*sc), M_DEVBUF, M_WAITOK | M_ZERO); - sc->sc_dev = dev; - /* - * XXX - * No public documentation exists on programming burst size of APCDMA. - */ - burst = sbus_get_burstsz(sc->sc_dev); - if ((burst & SBUS_BURST_64)) - sc->sc_burst = 64; - else if ((burst & SBUS_BURST_32)) - sc->sc_burst = 32; - else if ((burst & SBUS_BURST_16)) - sc->sc_burst = 16; - else - sc->sc_burst = 0; - sc->sc_flags = CS4231_SBUS; - sc->sc_nmres = 1; - sc->sc_nires = 1; - return cs4231_attach_common(sc); -} - -static int -cs4231_ebus_attach(device_t dev) -{ - struct cs4231_softc *sc; - - sc = malloc(sizeof(struct cs4231_softc), M_DEVBUF, M_NOWAIT | M_ZERO); - if (sc == NULL) { - device_printf(dev, "cannot allocate softc\n"); - return (ENOMEM); - } - sc->sc_dev = dev; - sc->sc_burst = EBDCSR_BURST_1; - sc->sc_nmres = CS4231_RES_MEM_MAX; - sc->sc_nires = CS4231_RES_IRQ_MAX; - sc->sc_flags = CS4231_EBUS; - return cs4231_attach_common(sc); -} - -static int -cs4231_attach_common(struct cs4231_softc *sc) -{ - char status[SND_STATUSLEN]; - driver_intr_t *ihandler; - int i; - - sc->sc_lock = snd_mtxcreate(device_get_nameunit(sc->sc_dev), - "snd_cs4231 softc"); - - for (i = 0; i < sc->sc_nmres; i++) { - sc->sc_rid[i] = i; - if ((sc->sc_res[i] = bus_alloc_resource_any(sc->sc_dev, - SYS_RES_MEMORY, &sc->sc_rid[i], RF_ACTIVE)) == NULL) { - device_printf(sc->sc_dev, - "cannot map register %d\n", i); - goto fail; - } - sc->sc_regt[i] = rman_get_bustag(sc->sc_res[i]); - sc->sc_regh[i] = rman_get_bushandle(sc->sc_res[i]); - } - for (i = 0; i < sc->sc_nires; i++) { - sc->sc_irqrid[i] = i; - if ((sc->sc_irqres[i] = bus_alloc_resource_any(sc->sc_dev, - SYS_RES_IRQ, &sc->sc_irqrid[i], RF_SHAREABLE | RF_ACTIVE)) - == NULL) { - if ((sc->sc_flags & CS4231_SBUS) != 0) - device_printf(sc->sc_dev, - "cannot allocate interrupt\n"); - else - device_printf(sc->sc_dev, "cannot allocate %s " - "interrupt\n", i == 0 ? "capture" : - "playback"); - goto fail; - } - } - - ihandler = cs4231_sbus_intr; - for (i = 0; i < sc->sc_nires; i++) { - if ((sc->sc_flags & CS4231_EBUS) != 0) { - if (i == 0) - ihandler = cs4231_ebus_cintr; - else - ihandler = cs4231_ebus_pintr; - } - if (snd_setup_intr(sc->sc_dev, sc->sc_irqres[i], INTR_MPSAFE, - ihandler, sc, &sc->sc_ih[i])) { - if ((sc->sc_flags & CS4231_SBUS) != 0) - device_printf(sc->sc_dev, - "cannot set up interrupt\n"); - else - device_printf(sc->sc_dev, "cannot set up %s " - " interrupt\n", i == 0 ? "capture" : - "playback"); - goto fail; - } - } - - sc->sc_bufsz = pcm_getbuffersize(sc->sc_dev, CS4231_MIN_BUF_SZ, - CS4231_DEFAULT_BUF_SZ, CS4231_MAX_BUF_SZ); - for (i = 0; i < sc->sc_nires; i++) { - if (bus_dma_tag_create( - bus_get_dma_tag(sc->sc_dev),/* parent */ - 64, 0, /* alignment, boundary */ - BUS_SPACE_MAXADDR_32BIT, /* lowaddr */ - BUS_SPACE_MAXADDR, /* highaddr */ - NULL, NULL, /* filtfunc, filtfuncarg */ - sc->sc_bufsz, /* maxsize */ - 1, /* nsegments */ - sc->sc_bufsz, /* maxsegsz */ - BUS_DMA_ALLOCNOW, /* flags */ - NULL, /* lockfunc */ - NULL, /* lockfuncarg */ - &sc->sc_dmat[i])) { - if ((sc->sc_flags & CS4231_SBUS) != 0) - device_printf(sc->sc_dev, - "cannot allocate DMA tag\n"); - else - device_printf(sc->sc_dev, "cannot allocate %s " - "DMA tag\n", i == 0 ? "capture" : - "playback"); - goto fail; - } - } - cs4231_enable(sc, CODEC_WARM_RESET); - cs4231_getversion(sc); - if (mixer_init(sc->sc_dev, &cs4231_mixer_class, sc) != 0) - goto fail; - if (pcm_register(sc->sc_dev, sc, 1, 1)) { - device_printf(sc->sc_dev, "cannot register to pcm\n"); - goto fail; - } - if (pcm_addchan(sc->sc_dev, PCMDIR_REC, &cs4231_chan_class, sc) != 0) - goto chan_fail; - if (pcm_addchan(sc->sc_dev, PCMDIR_PLAY, &cs4231_chan_class, sc) != 0) - goto chan_fail; - if ((sc->sc_flags & CS4231_SBUS) != 0) - snprintf(status, SND_STATUSLEN, "at mem 0x%lx irq %ld bufsz %u", - rman_get_start(sc->sc_res[0]), - rman_get_start(sc->sc_irqres[0]), sc->sc_bufsz); - else - snprintf(status, SND_STATUSLEN, "at io 0x%lx 0x%lx 0x%lx 0x%lx " - "irq %ld %ld bufsz %u", rman_get_start(sc->sc_res[0]), - rman_get_start(sc->sc_res[1]), - rman_get_start(sc->sc_res[2]), - rman_get_start(sc->sc_res[3]), - rman_get_start(sc->sc_irqres[0]), - rman_get_start(sc->sc_irqres[1]), sc->sc_bufsz); - pcm_setstatus(sc->sc_dev, status); - return (0); - -chan_fail: - pcm_unregister(sc->sc_dev); -fail: - cs4231_free_resource(sc); - return (ENXIO); -} - -static int -cs4231_bus_detach(device_t dev) -{ - struct cs4231_softc *sc; - struct cs4231_channel *pch, *rch; - int error; - - sc = pcm_getdevinfo(dev); - CS4231_LOCK(sc); - pch = &sc->sc_pch; - rch = &sc->sc_pch; - if (pch->locked || rch->locked) { - CS4231_UNLOCK(sc); - return (EBUSY); - } - /* - * Since EBDMA requires valid DMA buffer to drain its FIFO, we need - * real DMA buffer for draining. - */ - if ((sc->sc_flags & CS4231_EBUS) != 0) - cs4231_ebdma_reset(sc); - CS4231_UNLOCK(sc); - error = pcm_unregister(dev); - if (error) - return (error); - cs4231_free_resource(sc); - return (0); -} - -static int -cs4231_bus_suspend(device_t dev) -{ - - return (ENXIO); -} - -static int -cs4231_bus_resume(device_t dev) -{ - - return (ENXIO); -} - -static void -cs4231_getversion(struct cs4231_softc *sc) -{ - u_int8_t v; - - v = cs4231_read(sc, CS_MISC_INFO); - sc->sc_codecv = v & CS_CODEC_ID_MASK; - v = cs4231_read(sc, CS_VERSION_ID); - v &= (CS_VERSION_NUMBER | CS_VERSION_CHIPID); - sc->sc_chipvid = v; - switch(v) { - case 0x80: - device_printf(sc->sc_dev, "\n", - sc->sc_codecv); - break; - case 0xa0: - device_printf(sc->sc_dev, "\n", - sc->sc_codecv); - break; - case 0x82: - device_printf(sc->sc_dev, "\n", - sc->sc_codecv); - break; - default: - device_printf(sc->sc_dev, - "sc_codecv); - break; - } -} - -static void -cs4231_ebdma_reset(struct cs4231_softc *sc) -{ - int i; - - /* playback */ - EBDMA_P_WRITE(sc, EBDMA_DCSR, - EBDMA_P_READ(sc, EBDMA_DCSR) & ~(EBDCSR_INTEN | EBDCSR_NEXTEN)); - EBDMA_P_WRITE(sc, EBDMA_DCSR, EBDCSR_RESET); - for (i = CS_TIMEOUT; - i && EBDMA_P_READ(sc, EBDMA_DCSR) & EBDCSR_DRAIN; i--) - DELAY(1); - if (i == 0) - device_printf(sc->sc_dev, - "timeout waiting for playback DMA reset\n"); - EBDMA_P_WRITE(sc, EBDMA_DCSR, sc->sc_burst); - /* capture */ - EBDMA_C_WRITE(sc, EBDMA_DCSR, - EBDMA_C_READ(sc, EBDMA_DCSR) & ~(EBDCSR_INTEN | EBDCSR_NEXTEN)); - EBDMA_C_WRITE(sc, EBDMA_DCSR, EBDCSR_RESET); - for (i = CS_TIMEOUT; - i && EBDMA_C_READ(sc, EBDMA_DCSR) & EBDCSR_DRAIN; i--) - DELAY(1); - if (i == 0) - device_printf(sc->sc_dev, - "timeout waiting for capture DMA reset\n"); - EBDMA_C_WRITE(sc, EBDMA_DCSR, sc->sc_burst); -} - -static void -cs4231_power_reset(struct cs4231_softc *sc, int how) -{ - u_int32_t v; - int i; - - if ((sc->sc_flags & CS4231_SBUS) != 0) { - APC_WRITE(sc, APC_CSR, APC_CSR_RESET); - DELAY(10); - APC_WRITE(sc, APC_CSR, 0); - DELAY(10); - APC_WRITE(sc, - APC_CSR, APC_READ(sc, APC_CSR) | APC_CSR_CODEC_RESET); - DELAY(20); - APC_WRITE(sc, - APC_CSR, APC_READ(sc, APC_CSR) & (~APC_CSR_CODEC_RESET)); - } else { - v = AUXIO_READ(sc, AUXIO_CODEC); - if (how == CODEC_WARM_RESET && v != 0) { - AUXIO_WRITE(sc, AUXIO_CODEC, 0); - DELAY(20); - } else if (how == CODEC_COLD_RESET){ - AUXIO_WRITE(sc, AUXIO_CODEC, 1); - DELAY(20); - AUXIO_WRITE(sc, AUXIO_CODEC, 0); - DELAY(20); - } - cs4231_ebdma_reset(sc); - } - - for (i = CS_TIMEOUT; - i && CS_READ(sc, CS4231_IADDR) == CS_IN_INIT; i--) - DELAY(10); - if (i == 0) - device_printf(sc->sc_dev, "timeout waiting for reset\n"); - - /* turn on cs4231 mode */ - cs4231_write(sc, CS_MISC_INFO, - cs4231_read(sc, CS_MISC_INFO) | CS_MODE2); - /* enable interrupts & clear CSR */ - cs4231_write(sc, CS_PIN_CONTROL, - cs4231_read(sc, CS_PIN_CONTROL) | INTERRUPT_ENABLE); - CS_WRITE(sc, CS4231_STATUS, 0); - /* enable DAC output */ - cs4231_write(sc, CS_LEFT_OUTPUT_CONTROL, - cs4231_read(sc, CS_LEFT_OUTPUT_CONTROL) & ~OUTPUT_MUTE); - cs4231_write(sc, CS_RIGHT_OUTPUT_CONTROL, - cs4231_read(sc, CS_RIGHT_OUTPUT_CONTROL) & ~OUTPUT_MUTE); - /* mute AUX1 since it generates noises */ - cs4231_write(sc, CS_LEFT_AUX1_CONTROL, - cs4231_read(sc, CS_LEFT_AUX1_CONTROL) | AUX_INPUT_MUTE); - cs4231_write(sc, CS_RIGHT_AUX1_CONTROL, - cs4231_read(sc, CS_RIGHT_AUX1_CONTROL) | AUX_INPUT_MUTE); - /* protect buffer underrun and set output level to 0dB */ - cs4231_write(sc, CS_ALT_FEATURE1, - cs4231_read(sc, CS_ALT_FEATURE1) | CS_DAC_ZERO | CS_OUTPUT_LVL); - /* enable high pass filter, dual xtal was disabled due to noises */ - cs4231_write(sc, CS_ALT_FEATURE2, - cs4231_read(sc, CS_ALT_FEATURE2) | CS_HPF_ENABLE); -} - -static int -cs4231_enable(struct cs4231_softc *sc, int how) -{ - cs4231_power_reset(sc, how); - sc->sc_enabled = 1; - return (0); -} - -static void -cs4231_disable(struct cs4231_softc *sc) -{ - u_int8_t v; - - CS4231_LOCK_ASSERT(sc); - - if (sc->sc_enabled == 0) - return; - sc->sc_enabled = 0; - CS4231_UNLOCK(sc); - cs4231_halt(&sc->sc_pch); - cs4231_halt(&sc->sc_rch); - CS4231_LOCK(sc); - v = cs4231_read(sc, CS_PIN_CONTROL) & ~INTERRUPT_ENABLE; - cs4231_write(sc, CS_PIN_CONTROL, v); - - if ((sc->sc_flags & CS4231_SBUS) != 0) { - APC_WRITE(sc, APC_CSR, APC_CSR_RESET); - DELAY(10); - APC_WRITE(sc, APC_CSR, 0); - DELAY(10); - } else - cs4231_ebdma_reset(sc); -} - -static void -cs4231_free_resource(struct cs4231_softc *sc) -{ - int i; - - CS4231_LOCK(sc); - cs4231_disable(sc); - CS4231_UNLOCK(sc); - for (i = 0; i < sc->sc_nires; i++) { - if (sc->sc_irqres[i]) { - if (sc->sc_ih[i]) { - bus_teardown_intr(sc->sc_dev, sc->sc_irqres[i], - sc->sc_ih[i]); - sc->sc_ih[i] = NULL; - } - bus_release_resource(sc->sc_dev, SYS_RES_IRQ, - sc->sc_irqrid[i], sc->sc_irqres[i]); - sc->sc_irqres[i] = NULL; - } - } - for (i = 0; i < sc->sc_nires; i++) { - if (sc->sc_dmat[i]) - bus_dma_tag_destroy(sc->sc_dmat[i]); - } - for (i = 0; i < sc->sc_nmres; i++) { - if (sc->sc_res[i]) - bus_release_resource(sc->sc_dev, SYS_RES_MEMORY, - sc->sc_rid[i], sc->sc_res[i]); - } - snd_mtxfree(sc->sc_lock); - free(sc, M_DEVBUF); -} - -static void -cs4231_write(struct cs4231_softc *sc, u_int8_t r, u_int8_t v) -{ - CS_WRITE(sc, CS4231_IADDR, r); - CS_WRITE(sc, CS4231_IDATA, v); -} - -static u_int8_t -cs4231_read(struct cs4231_softc *sc, u_int8_t r) -{ - CS_WRITE(sc, CS4231_IADDR, r); - return (CS_READ(sc, CS4231_IDATA)); -} - -static void -cs4231_sbus_intr(void *arg) -{ - struct cs4231_softc *sc; - struct cs4231_channel *pch, *rch; - u_int32_t csr; - u_int8_t status; - - sc = arg; - CS4231_LOCK(sc); - - csr = APC_READ(sc, APC_CSR); - if ((csr & APC_CSR_GI) == 0) { - CS4231_UNLOCK(sc); - return; - } - APC_WRITE(sc, APC_CSR, csr); - - if ((csr & APC_CSR_EIE) && (csr & APC_CSR_EI)) { - status = cs4231_read(sc, CS_TEST_AND_INIT); - device_printf(sc->sc_dev, - "apc error interrupt : stat = 0x%x\n", status); - } - - pch = rch = NULL; - if ((csr & APC_CSR_PMIE) && (csr & APC_CSR_PMI)) { - u_long nextaddr, saddr; - u_int32_t togo; - - pch = &sc->sc_pch; - togo = pch->togo; - saddr = sndbuf_getbufaddr(pch->buffer); - nextaddr = pch->nextaddr + togo; - if (nextaddr >= saddr + sndbuf_getsize(pch->buffer)) - nextaddr = saddr; - APC_WRITE(sc, APC_PNVA, nextaddr); - APC_WRITE(sc, APC_PNC, togo); - pch->nextaddr = nextaddr; - } - - if ((csr & APC_CSR_CIE) && (csr & APC_CSR_CI) && (csr & APC_CSR_CD)) { - u_long nextaddr, saddr; - u_int32_t togo; - - rch = &sc->sc_rch; - togo = rch->togo; - saddr = sndbuf_getbufaddr(rch->buffer); - nextaddr = rch->nextaddr + togo; - if (nextaddr >= saddr + sndbuf_getsize(rch->buffer)) - nextaddr = saddr; - APC_WRITE(sc, APC_CNVA, nextaddr); - APC_WRITE(sc, APC_CNC, togo); - rch->nextaddr = nextaddr; - } - CS4231_UNLOCK(sc); - if (pch) - chn_intr(pch->channel); - if (rch) - chn_intr(rch->channel); -} - -/* playback interrupt handler */ -static void -cs4231_ebus_pintr(void *arg) -{ - struct cs4231_softc *sc; - struct cs4231_channel *ch; - u_int32_t csr; - u_int8_t status; - - sc = arg; - CS4231_LOCK(sc); - - csr = EBDMA_P_READ(sc, EBDMA_DCSR); - if ((csr & EBDCSR_INT) == 0) { - CS4231_UNLOCK(sc); - return; - } - - if ((csr & EBDCSR_ERR)) { - status = cs4231_read(sc, CS_TEST_AND_INIT); - device_printf(sc->sc_dev, - "ebdma error interrupt : stat = 0x%x\n", status); - } - EBDMA_P_WRITE(sc, EBDMA_DCSR, csr | EBDCSR_TC); - - ch = NULL; - if (csr & EBDCSR_TC) { - u_long nextaddr, saddr; - u_int32_t togo; - - ch = &sc->sc_pch; - togo = ch->togo; - saddr = sndbuf_getbufaddr(ch->buffer); - nextaddr = ch->nextaddr + togo; - if (nextaddr >= saddr + sndbuf_getsize(ch->buffer)) - nextaddr = saddr; - /* - * EBDMA_DCNT is loaded automatically - * EBDMA_P_WRITE(sc, EBDMA_DCNT, togo); - */ - EBDMA_P_WRITE(sc, EBDMA_DADDR, nextaddr); - ch->nextaddr = nextaddr; - } - CS4231_UNLOCK(sc); - if (ch) - chn_intr(ch->channel); -} - -/* capture interrupt handler */ -static void -cs4231_ebus_cintr(void *arg) -{ - struct cs4231_softc *sc; - struct cs4231_channel *ch; - u_int32_t csr; - u_int8_t status; - - sc = arg; - CS4231_LOCK(sc); - - csr = EBDMA_C_READ(sc, EBDMA_DCSR); - if ((csr & EBDCSR_INT) == 0) { - CS4231_UNLOCK(sc); - return; - } - if ((csr & EBDCSR_ERR)) { - status = cs4231_read(sc, CS_TEST_AND_INIT); - device_printf(sc->sc_dev, - "dma error interrupt : stat = 0x%x\n", status); - } - EBDMA_C_WRITE(sc, EBDMA_DCSR, csr | EBDCSR_TC); - - ch = NULL; - if (csr & EBDCSR_TC) { - u_long nextaddr, saddr; - u_int32_t togo; - - ch = &sc->sc_rch; - togo = ch->togo; - saddr = sndbuf_getbufaddr(ch->buffer); - nextaddr = ch->nextaddr + togo; - if (nextaddr >= saddr + sndbuf_getblksz(ch->buffer)) - nextaddr = saddr; - /* - * EBDMA_DCNT is loaded automatically - * EBDMA_C_WRITE(sc, EBDMA_DCNT, togo); - */ - EBDMA_C_WRITE(sc, EBDMA_DADDR, nextaddr); - ch->nextaddr = nextaddr; - } - CS4231_UNLOCK(sc); - if (ch) - chn_intr(ch->channel); -} - -static const struct mix_table cs4231_mix_table[SOUND_MIXER_NRDEVICES][2] = { - [SOUND_MIXER_PCM] = { - { CS_LEFT_OUTPUT_CONTROL, 6, OUTPUT_MUTE, 0, 1, 1, 0 }, - { CS_RIGHT_OUTPUT_CONTROL, 6, OUTPUT_MUTE, 0, 1, 1, 0 } - }, - [SOUND_MIXER_SPEAKER] = { - { CS_MONO_IO_CONTROL, 4, MONO_OUTPUT_MUTE, 0, 1, 1, 0 }, - { CS_REG_NONE, 0, 0, 0, 0, 1, 0 } - }, - [SOUND_MIXER_LINE] = { - { CS_LEFT_LINE_CONTROL, 5, LINE_INPUT_MUTE, 0, 1, 1, 1 }, - { CS_RIGHT_LINE_CONTROL, 5, LINE_INPUT_MUTE, 0, 1, 1, 1 } - }, - /* - * AUX1 : removed intentionally since it generates noises - * AUX2 : Ultra1/Ultra2 has no internal CD-ROM audio in - */ - [SOUND_MIXER_CD] = { - { CS_LEFT_AUX2_CONTROL, 5, LINE_INPUT_MUTE, 0, 1, 1, 1 }, - { CS_RIGHT_AUX2_CONTROL, 5, LINE_INPUT_MUTE, 0, 1, 1, 1 } - }, - [SOUND_MIXER_MIC] = { - { CS_LEFT_INPUT_CONTROL, 4, 0, 0, 0, 1, 1 }, - { CS_RIGHT_INPUT_CONTROL, 4, 0, 0, 0, 1, 1 } - }, - [SOUND_MIXER_IGAIN] = { - { CS_LEFT_INPUT_CONTROL, 4, 0, 0, 1, 0 }, - { CS_RIGHT_INPUT_CONTROL, 4, 0, 0, 1, 0 } - } -}; - -static int -cs4231_mixer_init(struct snd_mixer *m) -{ - u_int32_t v; - int i; - - v = 0; - for (i = 0; i < SOUND_MIXER_NRDEVICES; i++) - if (cs4231_mix_table[i][0].avail != 0) - v |= (1 << i); - mix_setdevs(m, v); - v = 0; - for (i = 0; i < SOUND_MIXER_NRDEVICES; i++) - if (cs4231_mix_table[i][0].recdev != 0) - v |= (1 << i); - mix_setrecdevs(m, v); - return (0); -} - -static void -cs4231_mixer_set_value(struct cs4231_softc *sc, const struct mix_table *mt, - u_int8_t v) -{ - u_int8_t mask, reg; - u_int8_t old, shift, val; - - if (mt->avail == 0 || mt->reg == CS_REG_NONE) - return; - reg = mt->reg; - if (mt->neg != 0) - val = 100 - v; - else - val = v; - mask = (1 << mt->bits) - 1; - val = ((val * mask) + 50) / 100; - shift = mt->shift; - val <<= shift; - if (v == 0) - val |= mt->mute; - old = cs4231_read(sc, reg); - old &= ~(mt->mute | (mask << shift)); - val |= old; - if (reg == CS_LEFT_INPUT_CONTROL || reg == CS_RIGHT_INPUT_CONTROL) { - if ((val & (mask << shift)) != 0) - val |= ADC_INPUT_GAIN_ENABLE; - else - val &= ~ADC_INPUT_GAIN_ENABLE; - } - cs4231_write(sc, reg, val); -} - -static int -cs4231_mixer_set(struct snd_mixer *m, u_int32_t dev, u_int32_t left, - u_int32_t right) -{ - struct cs4231_softc *sc; - - sc = mix_getdevinfo(m); - CS4231_LOCK(sc); - cs4231_mixer_set_value(sc, &cs4231_mix_table[dev][0], left); - cs4231_mixer_set_value(sc, &cs4231_mix_table[dev][1], right); - CS4231_UNLOCK(sc); - - return (left | (right << 8)); -} - -static u_int32_t -cs4231_mixer_setrecsrc(struct snd_mixer *m, u_int32_t src) -{ - struct cs4231_softc *sc; - u_int8_t v; - - sc = mix_getdevinfo(m); - switch (src) { - case SOUND_MASK_LINE: - v = CS_IN_LINE; - break; - - case SOUND_MASK_CD: - v = CS_IN_DAC; - break; - - case SOUND_MASK_MIC: - default: - v = CS_IN_MIC; - src = SOUND_MASK_MIC; - break; - } - CS4231_LOCK(sc); - cs4231_write(sc, CS_LEFT_INPUT_CONTROL, - (cs4231_read(sc, CS_LEFT_INPUT_CONTROL) & CS_IN_MASK) | v); - cs4231_write(sc, CS_RIGHT_INPUT_CONTROL, - (cs4231_read(sc, CS_RIGHT_INPUT_CONTROL) & CS_IN_MASK) | v); - CS4231_UNLOCK(sc); - - return (src); -} - -static void * -cs4231_chan_init(kobj_t obj, void *dev, struct snd_dbuf *b, - struct pcm_channel *c, int dir) -{ - struct cs4231_softc *sc; - struct cs4231_channel *ch; - bus_dma_tag_t dmat; - - sc = dev; - ch = (dir == PCMDIR_PLAY) ? &sc->sc_pch : &sc->sc_rch; - ch->parent = sc; - ch->channel = c; - ch->dir = dir; - ch->buffer = b; - if ((sc->sc_flags & CS4231_SBUS) != 0) - dmat = sc->sc_dmat[0]; - else { - if (dir == PCMDIR_PLAY) - dmat = sc->sc_dmat[1]; - else - dmat = sc->sc_dmat[0]; - } - if (sndbuf_alloc(ch->buffer, dmat, 0, sc->sc_bufsz) != 0) - return (NULL); - DPRINTF(("%s channel addr: 0x%lx\n", dir == PCMDIR_PLAY ? "playback" : - "capture", sndbuf_getbufaddr(ch->buffer))); - - return (ch); -} - -static int -cs4231_chan_setformat(kobj_t obj, void *data, u_int32_t format) -{ - struct cs4231_softc *sc; - struct cs4231_channel *ch; - u_int32_t encoding; - u_int8_t fs, v; - - ch = data; - sc = ch->parent; - - CS4231_LOCK(sc); - if (ch->format == format) { - CS4231_UNLOCK(sc); - return (0); - } - - encoding = AFMT_ENCODING(format); - fs = 0; - switch (encoding) { - case AFMT_U8: - fs = CS_AFMT_U8; - break; - case AFMT_MU_LAW: - fs = CS_AFMT_MU_LAW; - break; - case AFMT_S16_LE: - fs = CS_AFMT_S16_LE; - break; - case AFMT_A_LAW: - fs = CS_AFMT_A_LAW; - break; - case AFMT_IMA_ADPCM: - fs = CS_AFMT_IMA_ADPCM; - break; - case AFMT_S16_BE: - fs = CS_AFMT_S16_BE; - break; - default: - fs = CS_AFMT_U8; - format = AFMT_U8; - break; - } - - if (AFMT_CHANNEL(format) > 1) - fs |= CS_AFMT_STEREO; - - DPRINTF(("FORMAT: %s : 0x%x\n", ch->dir == PCMDIR_PLAY ? "playback" : - "capture", format)); - v = cs4231_read(sc, CS_CLOCK_DATA_FORMAT); - v &= CS_CLOCK_DATA_FORMAT_MASK; - fs |= v; - cs4231_chan_fs(sc, ch->dir, fs); - ch->format = format; - CS4231_UNLOCK(sc); - - return (0); -} - -static u_int32_t -cs4231_chan_setspeed(kobj_t obj, void *data, u_int32_t speed) -{ - typedef struct { - u_int32_t speed; - u_int8_t bits; - } speed_struct; - - const static speed_struct speed_table[] = { - {5510, (0 << 1) | CLOCK_XTAL2}, - {5510, (0 << 1) | CLOCK_XTAL2}, - {6620, (7 << 1) | CLOCK_XTAL2}, - {8000, (0 << 1) | CLOCK_XTAL1}, - {9600, (7 << 1) | CLOCK_XTAL1}, - {11025, (1 << 1) | CLOCK_XTAL2}, - {16000, (1 << 1) | CLOCK_XTAL1}, - {18900, (2 << 1) | CLOCK_XTAL2}, - {22050, (3 << 1) | CLOCK_XTAL2}, - {27420, (2 << 1) | CLOCK_XTAL1}, - {32000, (3 << 1) | CLOCK_XTAL1}, - {33075, (6 << 1) | CLOCK_XTAL2}, - {33075, (4 << 1) | CLOCK_XTAL2}, - {44100, (5 << 1) | CLOCK_XTAL2}, - {48000, (6 << 1) | CLOCK_XTAL1}, - }; - - struct cs4231_softc *sc; - struct cs4231_channel *ch; - int i, n, sel; - u_int8_t fs; - - ch = data; - sc = ch->parent; - CS4231_LOCK(sc); - if (ch->speed == speed) { - CS4231_UNLOCK(sc); - return (speed); - } - n = sizeof(speed_table) / sizeof(speed_struct); - - for (i = 1, sel =0; i < n - 1; i++) - if (abs(speed - speed_table[i].speed) < - abs(speed - speed_table[sel].speed)) - sel = i; - DPRINTF(("SPEED: %s : %dHz -> %dHz\n", ch->dir == PCMDIR_PLAY ? - "playback" : "capture", speed, speed_table[sel].speed)); - speed = speed_table[sel].speed; - - fs = cs4231_read(sc, CS_CLOCK_DATA_FORMAT); - fs &= ~CS_CLOCK_DATA_FORMAT_MASK; - fs |= speed_table[sel].bits; - cs4231_chan_fs(sc, ch->dir, fs); - ch->speed = speed; - CS4231_UNLOCK(sc); - - return (speed); -} - -static void -cs4231_chan_fs(struct cs4231_softc *sc, int dir, u_int8_t fs) -{ - int i, doreset; -#ifdef CS4231_AUTO_CALIBRATION - u_int8_t v; -#endif - - CS4231_LOCK_ASSERT(sc); - - /* set autocalibration */ - doreset = 0; -#ifdef CS4231_AUTO_CALIBRATION - v = cs4231_read(sc, CS_INTERFACE_CONFIG) | AUTO_CAL_ENABLE; - CS_WRITE(sc, CS4231_IADDR, MODE_CHANGE_ENABLE); - CS_WRITE(sc, CS4231_IADDR, MODE_CHANGE_ENABLE | CS_INTERFACE_CONFIG); - CS_WRITE(sc, CS4231_IDATA, v); -#endif - - /* - * We always need to write CS_CLOCK_DATA_FORMAT register since - * the clock frequency is shared with playback/capture. - */ - CS_WRITE(sc, CS4231_IADDR, MODE_CHANGE_ENABLE | CS_CLOCK_DATA_FORMAT); - CS_WRITE(sc, CS4231_IDATA, fs); - CS_READ(sc, CS4231_IDATA); - CS_READ(sc, CS4231_IDATA); - for (i = CS_TIMEOUT; - i && CS_READ(sc, CS4231_IADDR) == CS_IN_INIT; i--) - DELAY(10); - if (i == 0) { - device_printf(sc->sc_dev, "timeout setting playback speed\n"); - doreset++; - } - - /* - * capture channel - * cs4231 doesn't allow separate fs setup for playback/capture. - * I believe this will break full-duplex operation. - */ - if (dir == PCMDIR_REC) { - CS_WRITE(sc, CS4231_IADDR, MODE_CHANGE_ENABLE | CS_REC_FORMAT); - CS_WRITE(sc, CS4231_IDATA, fs); - CS_READ(sc, CS4231_IDATA); - CS_READ(sc, CS4231_IDATA); - for (i = CS_TIMEOUT; - i && CS_READ(sc, CS4231_IADDR) == CS_IN_INIT; i--) - DELAY(10); - if (i == 0) { - device_printf(sc->sc_dev, - "timeout setting capture format\n"); - doreset++; - } - } - - CS_WRITE(sc, CS4231_IADDR, 0); - for (i = CS_TIMEOUT; - i && CS_READ(sc, CS4231_IADDR) == CS_IN_INIT; i--) - DELAY(10); - if (i == 0) { - device_printf(sc->sc_dev, "timeout waiting for !MCE\n"); - doreset++; - } - -#ifdef CS4231_AUTO_CALIBRATION - CS_WRITE(sc, CS4231_IADDR, CS_TEST_AND_INIT); - for (i = CS_TIMEOUT; - i && CS_READ(sc, CS4231_IDATA) & AUTO_CAL_IN_PROG; i--) - DELAY(10); - if (i == 0) { - device_printf(sc->sc_dev, - "timeout waiting for autocalibration\n"); - doreset++; - } -#endif - if (doreset) { - /* - * Maybe the last resort to avoid a dreadful message like - * "pcm0:play:0: play interrupt timeout, channel dead" would - * be hardware reset. - */ - device_printf(sc->sc_dev, "trying to hardware reset\n"); - cs4231_disable(sc); - cs4231_enable(sc, CODEC_COLD_RESET); - CS4231_UNLOCK(sc); /* XXX */ - if (mixer_reinit(sc->sc_dev) != 0) - device_printf(sc->sc_dev, - "unable to reinitialize the mixer\n"); - CS4231_LOCK(sc); - } -} - -static u_int32_t -cs4231_chan_setblocksize(kobj_t obj, void *data, u_int32_t blocksize) -{ - struct cs4231_softc *sc; - struct cs4231_channel *ch; - int nblks, error; - - ch = data; - sc = ch->parent; - - if (blocksize > CS4231_MAX_BLK_SZ) - blocksize = CS4231_MAX_BLK_SZ; - nblks = sc->sc_bufsz / blocksize; - error = sndbuf_resize(ch->buffer, nblks, blocksize); - if (error != 0) - device_printf(sc->sc_dev, - "unable to block size, blksz = %d, error = %d\n", - blocksize, error); - - return (blocksize); -} - -static int -cs4231_chan_trigger(kobj_t obj, void *data, int go) -{ - struct cs4231_channel *ch; - - ch = data; - switch (go) { - case PCMTRIG_EMLDMAWR: - case PCMTRIG_EMLDMARD: - break; - case PCMTRIG_START: - cs4231_trigger(ch); - break; - case PCMTRIG_ABORT: - case PCMTRIG_STOP: - cs4231_halt(ch); - break; - default: - break; - } - - return (0); -} - -static u_int32_t -cs4231_chan_getptr(kobj_t obj, void *data) -{ - struct cs4231_softc *sc; - struct cs4231_channel *ch; - u_int32_t cur, ptr, sz; - - ch = data; - sc = ch->parent; - - CS4231_LOCK(sc); - if ((sc->sc_flags & CS4231_SBUS) != 0) - cur = (ch->dir == PCMDIR_PLAY) ? APC_READ(sc, APC_PVA) : - APC_READ(sc, APC_CVA); - else - cur = (ch->dir == PCMDIR_PLAY) ? EBDMA_P_READ(sc, EBDMA_DADDR) : - EBDMA_C_READ(sc, EBDMA_DADDR); - sz = sndbuf_getsize(ch->buffer); - ptr = cur - sndbuf_getbufaddr(ch->buffer) + sz; - CS4231_UNLOCK(sc); - - ptr %= sz; - return (ptr); -} - -static struct pcmchan_caps * -cs4231_chan_getcaps(kobj_t obj, void *data) -{ - - return (&cs4231_caps); -} - -static void -cs4231_trigger(struct cs4231_channel *ch) -{ - struct cs4231_softc *sc; - - sc = ch->parent; - if ((sc->sc_flags & CS4231_SBUS) != 0) - cs4231_apcdma_trigger(sc, ch); - else - cs4231_ebdma_trigger(sc, ch); -} - -static void -cs4231_apcdma_trigger(struct cs4231_softc *sc, struct cs4231_channel *ch) -{ - u_int32_t csr, togo; - u_int32_t nextaddr; - - CS4231_LOCK(sc); - if (ch->locked) { - device_printf(sc->sc_dev, "%s channel already triggered\n", - ch->dir == PCMDIR_PLAY ? "playback" : "capture"); - CS4231_UNLOCK(sc); - return; - } - - nextaddr = sndbuf_getbufaddr(ch->buffer); - togo = sndbuf_getsize(ch->buffer) / 2; - if (togo > CS4231_MAX_APC_DMA_SZ) - togo = CS4231_MAX_APC_DMA_SZ; - ch->togo = togo; - if (ch->dir == PCMDIR_PLAY) { - DPRINTF(("TRG: PNVA = 0x%x, togo = 0x%x\n", nextaddr, togo)); - - cs4231_read(sc, CS_TEST_AND_INIT); /* clear pending error */ - csr = APC_READ(sc, APC_CSR); - APC_WRITE(sc, APC_PNVA, nextaddr); - APC_WRITE(sc, APC_PNC, togo); - - if ((csr & APC_CSR_PDMA_GO) == 0 || - (csr & APC_CSR_PPAUSE) != 0) { - APC_WRITE(sc, APC_CSR, APC_READ(sc, APC_CSR) & - ~(APC_CSR_PIE | APC_CSR_PPAUSE)); - APC_WRITE(sc, APC_CSR, APC_READ(sc, APC_CSR) | - APC_CSR_GIE | APC_CSR_PIE | APC_CSR_EIE | - APC_CSR_EI | APC_CSR_PMIE | APC_CSR_PDMA_GO); - cs4231_write(sc, CS_INTERFACE_CONFIG, - cs4231_read(sc, CS_INTERFACE_CONFIG) | - PLAYBACK_ENABLE); - } - /* load next address */ - if (APC_READ(sc, APC_CSR) & APC_CSR_PD) { - nextaddr += togo; - APC_WRITE(sc, APC_PNVA, nextaddr); - APC_WRITE(sc, APC_PNC, togo); - } - } else { - DPRINTF(("TRG: CNVA = 0x%x, togo = 0x%x\n", nextaddr, togo)); - - cs4231_read(sc, CS_TEST_AND_INIT); /* clear pending error */ - APC_WRITE(sc, APC_CNVA, nextaddr); - APC_WRITE(sc, APC_CNC, togo); - csr = APC_READ(sc, APC_CSR); - if ((csr & APC_CSR_CDMA_GO) == 0 || - (csr & APC_CSR_CPAUSE) != 0) { - csr &= APC_CSR_CPAUSE; - csr |= APC_CSR_GIE | APC_CSR_CMIE | APC_CSR_CIE | - APC_CSR_EI | APC_CSR_CDMA_GO; - APC_WRITE(sc, APC_CSR, csr); - cs4231_write(sc, CS_INTERFACE_CONFIG, - cs4231_read(sc, CS_INTERFACE_CONFIG) | - CAPTURE_ENABLE); - } - /* load next address */ - if (APC_READ(sc, APC_CSR) & APC_CSR_CD) { - nextaddr += togo; - APC_WRITE(sc, APC_CNVA, nextaddr); - APC_WRITE(sc, APC_CNC, togo); - } - } - ch->nextaddr = nextaddr; - ch->locked = 1; - CS4231_UNLOCK(sc); -} - -static void -cs4231_ebdma_trigger(struct cs4231_softc *sc, struct cs4231_channel *ch) -{ - u_int32_t csr, togo; - u_int32_t nextaddr; - - CS4231_LOCK(sc); - if (ch->locked) { - device_printf(sc->sc_dev, "%s channel already triggered\n", - ch->dir == PCMDIR_PLAY ? "playback" : "capture"); - CS4231_UNLOCK(sc); - return; - } - - nextaddr = sndbuf_getbufaddr(ch->buffer); - togo = sndbuf_getsize(ch->buffer) / 2; - if (togo % 64 == 0) - sc->sc_burst = EBDCSR_BURST_16; - else if (togo % 32 == 0) - sc->sc_burst = EBDCSR_BURST_8; - else if (togo % 16 == 0) - sc->sc_burst = EBDCSR_BURST_4; - else - sc->sc_burst = EBDCSR_BURST_1; - ch->togo = togo; - DPRINTF(("TRG: DNAR = 0x%x, togo = 0x%x\n", nextaddr, togo)); - if (ch->dir == PCMDIR_PLAY) { - cs4231_read(sc, CS_TEST_AND_INIT); /* clear pending error */ - csr = EBDMA_P_READ(sc, EBDMA_DCSR); - - if (csr & EBDCSR_DMAEN) { - EBDMA_P_WRITE(sc, EBDMA_DCNT, togo); - EBDMA_P_WRITE(sc, EBDMA_DADDR, nextaddr); - } else { - EBDMA_P_WRITE(sc, EBDMA_DCSR, EBDCSR_RESET); - EBDMA_P_WRITE(sc, EBDMA_DCSR, sc->sc_burst); - EBDMA_P_WRITE(sc, EBDMA_DCNT, togo); - EBDMA_P_WRITE(sc, EBDMA_DADDR, nextaddr); - - EBDMA_P_WRITE(sc, EBDMA_DCSR, sc->sc_burst | - EBDCSR_DMAEN | EBDCSR_INTEN | EBDCSR_CNTEN | - EBDCSR_NEXTEN); - cs4231_write(sc, CS_INTERFACE_CONFIG, - cs4231_read(sc, CS_INTERFACE_CONFIG) | - PLAYBACK_ENABLE); - } - /* load next address */ - if (EBDMA_P_READ(sc, EBDMA_DCSR) & EBDCSR_A_LOADED) { - nextaddr += togo; - EBDMA_P_WRITE(sc, EBDMA_DCNT, togo); - EBDMA_P_WRITE(sc, EBDMA_DADDR, nextaddr); - } - } else { - cs4231_read(sc, CS_TEST_AND_INIT); /* clear pending error */ - csr = EBDMA_C_READ(sc, EBDMA_DCSR); - - if (csr & EBDCSR_DMAEN) { - EBDMA_C_WRITE(sc, EBDMA_DCNT, togo); - EBDMA_C_WRITE(sc, EBDMA_DADDR, nextaddr); - } else { - EBDMA_C_WRITE(sc, EBDMA_DCSR, EBDCSR_RESET); - EBDMA_C_WRITE(sc, EBDMA_DCSR, sc->sc_burst); - EBDMA_C_WRITE(sc, EBDMA_DCNT, togo); - EBDMA_C_WRITE(sc, EBDMA_DADDR, nextaddr); - - EBDMA_C_WRITE(sc, EBDMA_DCSR, sc->sc_burst | - EBDCSR_WRITE | EBDCSR_DMAEN | EBDCSR_INTEN | - EBDCSR_CNTEN | EBDCSR_NEXTEN); - cs4231_write(sc, CS_INTERFACE_CONFIG, - cs4231_read(sc, CS_INTERFACE_CONFIG) | - CAPTURE_ENABLE); - } - /* load next address */ - if (EBDMA_C_READ(sc, EBDMA_DCSR) & EBDCSR_A_LOADED) { - nextaddr += togo; - EBDMA_C_WRITE(sc, EBDMA_DCNT, togo); - EBDMA_C_WRITE(sc, EBDMA_DADDR, nextaddr); - } - } - ch->nextaddr = nextaddr; - ch->locked = 1; - CS4231_UNLOCK(sc); -} - -static void -cs4231_halt(struct cs4231_channel *ch) -{ - struct cs4231_softc *sc; - u_int8_t status; - int i; - - sc = ch->parent; - CS4231_LOCK(sc); - if (ch->locked == 0) { - CS4231_UNLOCK(sc); - return; - } - - if (ch->dir == PCMDIR_PLAY ) { - if ((sc->sc_flags & CS4231_SBUS) != 0) { - /* XXX Kills some capture bits */ - APC_WRITE(sc, APC_CSR, APC_READ(sc, APC_CSR) & - ~(APC_CSR_EI | APC_CSR_GIE | APC_CSR_PIE | - APC_CSR_EIE | APC_CSR_PDMA_GO | APC_CSR_PMIE)); - } else { - EBDMA_P_WRITE(sc, EBDMA_DCSR, - EBDMA_P_READ(sc, EBDMA_DCSR) & ~EBDCSR_DMAEN); - } - /* Waiting for playback FIFO to empty */ - status = cs4231_read(sc, CS_TEST_AND_INIT); - for (i = CS_TIMEOUT; - i && (status & PLAYBACK_UNDERRUN) == 0; i--) { - DELAY(5); - status = cs4231_read(sc, CS_TEST_AND_INIT); - } - if (i == 0) - device_printf(sc->sc_dev, "timeout waiting for " - "playback FIFO drain\n"); - cs4231_write(sc, CS_INTERFACE_CONFIG, - cs4231_read(sc, CS_INTERFACE_CONFIG) & (~PLAYBACK_ENABLE)); - } else { - if ((sc->sc_flags & CS4231_SBUS) != 0) { - /* XXX Kills some playback bits */ - APC_WRITE(sc, APC_CSR, APC_CSR_CAPTURE_PAUSE); - } else { - EBDMA_C_WRITE(sc, EBDMA_DCSR, - EBDMA_C_READ(sc, EBDMA_DCSR) & ~EBDCSR_DMAEN); - } - /* Waiting for capture FIFO to empty */ - status = cs4231_read(sc, CS_TEST_AND_INIT); - for (i = CS_TIMEOUT; - i && (status & CAPTURE_OVERRUN) == 0; i--) { - DELAY(5); - status = cs4231_read(sc, CS_TEST_AND_INIT); - } - if (i == 0) - device_printf(sc->sc_dev, "timeout waiting for " - "capture FIFO drain\n"); - cs4231_write(sc, CS_INTERFACE_CONFIG, - cs4231_read(sc, CS_INTERFACE_CONFIG) & (~CAPTURE_ENABLE)); - } - ch->locked = 0; - CS4231_UNLOCK(sc); -} diff --git a/sys/dev/sound/sbus/cs4231.h b/sys/dev/sound/sbus/cs4231.h deleted file mode 100644 index 717e7792712e..000000000000 --- a/sys/dev/sound/sbus/cs4231.h +++ /dev/null @@ -1,243 +0,0 @@ -/* $FreeBSD$ */ -/*- - * SPDX-License-Identifier: BSD-2-Clause-NetBSD - * - * Copyright (c) 1996 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Ken Hornstein and John Kohl. - * - * 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 NETBSD FOUNDATION, INC. 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. - */ - -/** - * Register defs for Crystal Semiconductor CS4231 Audio Codec/mixer - * chip, used on Gravis UltraSound MAX cards. - * - * Block diagram: - * +----------------------------------------------------+ - * | | - * | +----------------------------------------------+ | - * | |mixed in +-+ | | - * | +------------>--| | | | - * | mic in | | | | - * Mic --+-->| --------- GAIN ->-| | | | - * | | AUX 1 in |M| | | - * GF1 --)-->| -------------+-->-|U| | | - * | | Line in | |X|---- GAIN ----------+ | | - * Line --)-->| ---------+---)-->-| | | | | - * | | | | | | | | | - * | | | | +-+ ADC | | - * | | | | | | | - * | | | | | | | - * | | | +--- L/M --\ | | | AMP--> - * | | | \ | | | | - * | | | \ | | | | - * | | +---- L/M -------O-->--+--------)-------+-|--+-> line - * | | mono in /| | | | - * +---|-->------------ L/M -----/ | | | | - * | AUX 2 in | | | | - * CD --------|-->------------ L/M -------+ L/M | | - * | | v | - * | | | | - * | DAC | | - * | | | | - * +----------------------------------------------------+ - * | | - * | | - * v v - * Pc BUS (DISK) ??? - * - * Documentation for this chip can be found at: - * http://www.cirrus.com/products/overviews/cs4231.html - */ - -/* - * This file was merged from two header files.(ad1848reg.h and cs4231reg.h) - * And the suffix AD1848 and SP was changed to CS4231 and CS respectively. - */ -/* CS4231 direct registers */ -#define CS4231_IADDR 0x00 -#define CS4231_IDATA 0x01 -#define CS4231_STATUS 0x02 -#define CS4231_PIO 0x03 - -/* Index address register */ -#define CS_IN_INIT 0x80 -#define MODE_CHANGE_ENABLE 0x40 -#define TRANSFER_DISABLE 0x20 -#define ADDRESS_MASK 0xe0 - -/* Status bits */ -#define INTERRUPT_STATUS 0x01 -#define PLAYBACK_READY 0x02 -#define PLAYBACK_LEFT 0x04 -/* pbright is not left */ -#define PLAYBACK_UPPER 0x08 -/* bplower is not upper */ -#define SAMPLE_ERROR 0x10 -#define CAPTURE_READY 0x20 -#define CAPTURE_LEFT 0x40 -/* cpright is not left */ -#define CAPTURE_UPPER 0x80 -/* cplower is not upper */ - -/* CS4231 indirect mapped registers */ -#define CS_LEFT_INPUT_CONTROL 0x00 -#define CS_RIGHT_INPUT_CONTROL 0x01 -#define CS_LEFT_AUX1_CONTROL 0x02 -#define CS_RIGHT_AUX1_CONTROL 0x03 -#define CS_LEFT_AUX2_CONTROL 0x04 -#define CS_RIGHT_AUX2_CONTROL 0x05 -#define CS_LEFT_OUTPUT_CONTROL 0x06 -#define CS_RIGHT_OUTPUT_CONTROL 0x07 -#define CS_CLOCK_DATA_FORMAT 0x08 -#define CS_INTERFACE_CONFIG 0x09 -#define CS_PIN_CONTROL 0x0a -#define CS_TEST_AND_INIT 0x0b -#define CS_MISC_INFO 0x0c -#define CS_DIGITAL_MIX 0x0d -#define CS_UPPER_BASE_COUNT 0x0e -#define CS_LOWER_BASE_COUNT 0x0f -/* CS4231/AD1845 mode2 registers; added to AD1848 registers */ -#define CS_ALT_FEATURE1 0x10 -#define CS_ALT_FEATURE2 0x11 -#define CS_LEFT_LINE_CONTROL 0x12 -#define CS_RIGHT_LINE_CONTROL 0x13 -#define CS_TIMER_LOW 0x14 -#define CS_TIMER_HIGH 0x15 -#define CS_UPPER_FREQUENCY_SEL 0x16 -#define CS_LOWER_FREQUENCY_SEL 0x17 -#define CS_IRQ_STATUS 0x18 -#define CS_VERSION_ID 0x19 -#define CS_MONO_IO_CONTROL 0x1a -#define CS_POWERDOWN_CONTROL 0x1b -#define CS_REC_FORMAT 0x1c -#define CS_XTAL_SELECT 0x1d -#define CS_UPPER_REC_CNT 0x1e -#define CS_LOWER_REC_CNT 0x1f -#define CS_REG_NONE 0xff - -#define CS_IN_MASK 0x2f -#define CS_IN_LINE 0x00 -#define CS_IN_AUX1 0x40 -#define CS_IN_MIC 0x80 -#define CS_IN_DAC 0xc0 -#define CS_MIC_GAIN_ENABLE 0x20 -#define CS_IN_GAIN_MASK 0xf0 - -/* ADC input control - registers I0 (channel 1,left); I1 (channel 1,right) */ -#define ADC_INPUT_ATTEN_BITS 0x0f -#define ADC_INPUT_GAIN_ENABLE 0x20 - -/* Aux input control - registers I2 (channel 1,left); I3 (channel 1,right) - I4 (channel 2,left); I5 (channel 2,right) */ -#define AUX_INPUT_ATTEN_BITS 0x1f -#define AUX_INPUT_ATTEN_MASK 0xe0 -#define AUX_INPUT_MUTE 0x80 - -/* Output bits - registers I6,I7*/ -#define OUTPUT_MUTE 0x80 -#define OUTPUT_ATTEN_BITS 0x3f -#define OUTPUT_ATTEN_MASK (~OUTPUT_ATTEN_BITS & 0xff) - -/* Clock and Data format reg bits (some also Capture Data format) - reg I8 */ -#define CS_CLOCK_DATA_FORMAT_MASK 0x0f -#define CLOCK_XTAL1 0x00 -#define CLOCK_XTAL2 0x01 -#define CLOCK_FREQ_MASK 0xf1 -#define CS_AFMT_STEREO 0x10 -#define CS_AFMT_U8 0x00 -#define CS_AFMT_MU_LAW 0x20 -#define CS_AFMT_S16_LE 0x40 -#define CS_AFMT_A_LAW 0x60 -#define CS_AFMT_IMA_ADPCM 0xa0 -#define CS_AFMT_S16_BE 0xc0 - -/* Interface Configuration reg bits - register I9 */ -#define PLAYBACK_ENABLE 0x01 -#define CAPTURE_ENABLE 0x02 -#define DUAL_DMA 0x00 -#define SINGLE_DMA 0x04 -#define AUTO_CAL_ENABLE 0x08 -#define PLAYBACK_PIO_ENABLE 0x40 -#define CAPTURE_PIO_ENABLE 0x80 - -/* Pin control bits - register I10 */ -#define INTERRUPT_ENABLE 0x02 -#define XCTL0_ENABLE 0x40 -#define XCTL1_ENABLE 0x80 - -/* Test and init reg bits - register I11 (read-only) */ -#define OVERRANGE_LEFT_MASK 0xfc -#define OVERRANGE_RIGHT_MASK 0xf3 -#define DATA_REQUEST_STATUS 0x10 -#define AUTO_CAL_IN_PROG 0x20 -#define PLAYBACK_UNDERRUN 0x40 -#define CAPTURE_OVERRUN 0x80 - -/* Miscellaneous Control reg bits - register I12 */ -#define CS_ID_MASK 0x70 -#define CS_MODE2 0x40 -#define CS_CODEC_ID_MASK 0x0f - -/* Digital Mix Control reg bits - register I13 */ -#define DIGITAL_MIX1_ENABLE 0x01 -#define MIX_ATTEN_MASK 0x03 - -/* Alternate Feature Enable I - register I16 */ -#define CS_DAC_ZERO 0x01 -#define CS_PMC_ENABLE 0x10 -#define CS_CMC_ENABLE 0x20 -#define CS_OUTPUT_LVL 0x80 - -/* Alternate Feature Enable II - register I17 */ -#define CS_HPF_ENABLE 0x01 -#define DUAL_XTAL_ENABLE 0x02 - -/* alternate feature status(I24) */ -#define CS_AFS_TI 0x40 /* timer interrupt */ -#define CS_AFS_CI 0x20 /* capture interrupt */ -#define CS_AFS_PI 0x10 /* playback interrupt */ -#define CS_AFS_CU 0x08 /* capture underrun */ -#define CS_AFS_CO 0x04 /* capture overrun */ -#define CS_AFS_PO 0x02 /* playback overrun */ -#define CS_AFS_PU 0x01 /* playback underrun */ - -/* Version - register I25 */ -#define CS_VERSION_NUMBER 0xe0 -#define CS_VERSION_CHIPID 0x07 - -/* Miscellaneous Control reg bits */ -#define CS_MODE2 0x40 - -#define MONO_INPUT_ATTEN_BITS 0x0f -#define MONO_INPUT_ATTEN_MASK 0xf0 -#define MONO_OUTPUT_MUTE 0x40 -#define MONO_INPUT_MUTE 0x80 -#define MONO_INPUT_MUTE_MASK 0x7f - -#define LINE_INPUT_ATTEN_BITS 0x1f -#define LINE_INPUT_ATTEN_MASK 0xe0 -#define LINE_INPUT_MUTE 0x80 -#define LINE_INPUT_MUTE_MASK 0x7f diff --git a/sys/dev/sym/sym_hipd.c b/sys/dev/sym/sym_hipd.c index c338053ad6fa..9b9798d8c57d 100644 --- a/sys/dev/sym/sym_hipd.c +++ b/sys/dev/sym/sym_hipd.c @@ -90,11 +90,6 @@ __FBSDID("$FreeBSD$"); #include #include -#ifdef __sparc64__ -#include -#include -#endif - #include #include @@ -134,8 +129,6 @@ typedef u_int32_t u32; #define MEMORY_BARRIER() do { ; } while(0) #elif defined __powerpc__ #define MEMORY_BARRIER() __asm__ volatile("eieio; sync" : : : "memory") -#elif defined __sparc64__ -#define MEMORY_BARRIER() __asm__ volatile("membar #Sync" : : : "memory") #elif defined __arm__ #define MEMORY_BARRIER() dmb() #elif defined __aarch64__ @@ -2652,9 +2645,6 @@ static int sym_prepare_setting(hcb_p np, struct sym_nvram *nvram) */ np->myaddr = 255; sym_nvram_setup_host (np, nvram); -#ifdef __sparc64__ - np->myaddr = OF_getscsinitid(np->device); -#endif /* * Get SCSI addr of host adapter (set by bios?). diff --git a/sys/dev/syscons/scgfbrndr.c b/sys/dev/syscons/scgfbrndr.c index 190da5254546..2dc4f503854e 100644 --- a/sys/dev/syscons/scgfbrndr.c +++ b/sys/dev/syscons/scgfbrndr.c @@ -107,38 +107,11 @@ sc_rndr_sw_t grrndrsw = { #endif /* SC_NO_MODE_CHANGE */ #ifndef SC_NO_CUTPASTE -#ifdef __sparc64__ -static u_char mouse_pointer[22 * 2] = { - 0x00, 0x00, /* ............ */ - 0x80, 0x00, /* *........... */ - 0xc0, 0x00, /* **.......... */ - 0xe0, 0x00, /* ***......... */ - 0xf0, 0x00, /* ****........ */ - 0xf8, 0x00, /* *****....... */ - 0xfc, 0x00, /* ******...... */ - 0xfe, 0x00, /* *******..... */ - 0xff, 0x00, /* ********.... */ - 0xff, 0x80, /* *********... */ - 0xfc, 0xc0, /* ******..**.. */ - 0xdc, 0x00, /* **.***...... */ - 0x8e, 0x00, /* *...***..... */ - 0x0e, 0x00, /* ....***..... */ - 0x07, 0x00, /* .....***.... */ - 0x04, 0x00, /* .....*...... */ - 0x00, 0x00, /* ............ */ - 0x00, 0x00, /* ............ */ - 0x00, 0x00, /* ............ */ - 0x00, 0x00, /* ............ */ - 0x00, 0x00, /* ............ */ - 0x00, 0x00 /* ............ */ -}; -#else static u_char mouse_pointer[16] = { 0x00, 0x40, 0x60, 0x70, 0x78, 0x7c, 0x7e, 0x68, 0x0c, 0x0c, 0x06, 0x06, 0x00, 0x00, 0x00, 0x00 }; #endif -#endif static void gfb_nop(scr_stat *scp) @@ -241,7 +214,7 @@ gfb_cursor_shape(scr_stat *scp, int base, int height, int blink) static int pxlblinkrate = 0; -#if defined(__sparc64__) || defined(SC_OFWFB) +#if defined(SC_OFWFB) static void gfb_cursor(scr_stat *scp, int at, int blink, int on, int flip) { @@ -336,17 +309,12 @@ gfb_blink(scr_stat *scp, int at, int flip) static void gfb_mouse(scr_stat *scp, int x, int y, int on) { -#ifdef __sparc64__ - vidd_putm(scp->sc->adp, x, y, mouse_pointer, - on ? 0xffffffff : 0x0, 22, 12); -#else if (on) { vidd_putm(scp->sc->adp, x, y, mouse_pointer, 0xffffffff, 16, 8); } else { /* XXX: removal is incomplete for h/w cursors and borders. */ } -#endif } #endif /* SC_NO_CUTPASTE */ diff --git a/sys/dev/syscons/schistory.c b/sys/dev/syscons/schistory.c index 8da242c8a9f8..64f662b5a7f4 100644 --- a/sys/dev/syscons/schistory.c +++ b/sys/dev/syscons/schistory.c @@ -44,8 +44,7 @@ __FBSDID("$FreeBSD$"); #include #include -#if defined(__arm__) || defined(__mips__) || \ - defined(__powerpc__) || defined(__sparc64__) +#if defined(__arm__) || defined(__mips__) || defined(__powerpc__) #include #else #include diff --git a/sys/dev/syscons/scterm-dumb.c b/sys/dev/syscons/scterm-dumb.c index b888897d5437..3011b0de8f52 100644 --- a/sys/dev/syscons/scterm-dumb.c +++ b/sys/dev/syscons/scterm-dumb.c @@ -35,8 +35,7 @@ __FBSDID("$FreeBSD$"); #include #include -#if defined(__arm__) || defined(__mips__) || \ - defined(__powerpc__) || defined(__sparc64__) +#if defined(__arm__) || defined(__mips__) || defined(__powerpc__) #include #else #include diff --git a/sys/dev/syscons/scterm-sc.c b/sys/dev/syscons/scterm-sc.c index 52ba50714f9d..de46827b5837 100644 --- a/sys/dev/syscons/scterm-sc.c +++ b/sys/dev/syscons/scterm-sc.c @@ -36,8 +36,7 @@ __FBSDID("$FreeBSD$"); #include #include -#if defined(__arm__) || defined(__mips__) || \ - defined(__powerpc__) || defined(__sparc64__) +#if defined(__arm__) || defined(__mips__) || defined(__powerpc__) #include #else #include diff --git a/sys/dev/syscons/scterm-teken.c b/sys/dev/syscons/scterm-teken.c index ae231f01d294..b575b4ec3119 100644 --- a/sys/dev/syscons/scterm-teken.c +++ b/sys/dev/syscons/scterm-teken.c @@ -42,8 +42,7 @@ __FBSDID("$FreeBSD$"); #include #include -#if defined(__arm__) || defined(__mips__) || \ - defined(__powerpc__) || defined(__sparc64__) +#if defined(__arm__) || defined(__mips__) || defined(__powerpc__) #include #else #include diff --git a/sys/dev/syscons/scvtb.c b/sys/dev/syscons/scvtb.c index 44b667b8ab82..28ea4b41666c 100644 --- a/sys/dev/syscons/scvtb.c +++ b/sys/dev/syscons/scvtb.c @@ -76,12 +76,10 @@ sc_vtb_init(sc_vtb_t *vtb, int type, int cols, int rows, void *buf, int wait) } vtb->vtb_flags |= VTB_VALID; break; -#ifndef __sparc64__ case VTB_FRAMEBUFFER: vtb->vtb_buffer = (vm_offset_t)buf; vtb->vtb_flags |= VTB_VALID; break; -#endif default: break; } @@ -121,44 +119,36 @@ sc_vtb_size(int cols, int rows) int sc_vtb_getc(sc_vtb_t *vtb, int at) { -#ifndef __sparc64__ if (vtb->vtb_type == VTB_FRAMEBUFFER) return (readw(sc_vtb_pointer(vtb, at)) & 0x00ff); else -#endif return (*(u_int16_t *)sc_vtb_pointer(vtb, at) & 0x00ff); } int sc_vtb_geta(sc_vtb_t *vtb, int at) { -#ifndef __sparc64__ if (vtb->vtb_type == VTB_FRAMEBUFFER) return (readw(sc_vtb_pointer(vtb, at)) & 0xff00); else -#endif return (*(u_int16_t *)sc_vtb_pointer(vtb, at) & 0xff00); } void sc_vtb_putc(sc_vtb_t *vtb, int at, int c, int a) { -#ifndef __sparc64__ if (vtb->vtb_type == VTB_FRAMEBUFFER) writew(sc_vtb_pointer(vtb, at), a | c); else -#endif *(u_int16_t *)sc_vtb_pointer(vtb, at) = a | c; } vm_offset_t sc_vtb_putchar(sc_vtb_t *vtb, vm_offset_t p, int c, int a) { -#ifndef __sparc64__ if (vtb->vtb_type == VTB_FRAMEBUFFER) writew(p, a | c); else -#endif *(u_int16_t *)p = a | c; return (p + sizeof(u_int16_t)); } @@ -178,18 +168,15 @@ sc_vtb_pos(sc_vtb_t *vtb, int pos, int offset) void sc_vtb_clear(sc_vtb_t *vtb, int c, int attr) { -#ifndef __sparc64__ if (vtb->vtb_type == VTB_FRAMEBUFFER) fillw_io(attr | c, sc_vtb_pointer(vtb, 0), vtb->vtb_size); else -#endif fillw(attr | c, (void *)sc_vtb_pointer(vtb, 0), vtb->vtb_size); } void sc_vtb_copy(sc_vtb_t *vtb1, int from, sc_vtb_t *vtb2, int to, int count) { -#ifndef __sparc64__ /* XXX if both are VTB_VRAMEBUFFER... */ if (vtb2->vtb_type == VTB_FRAMEBUFFER) bcopy_toio(sc_vtb_pointer(vtb1, from), @@ -200,7 +187,6 @@ sc_vtb_copy(sc_vtb_t *vtb1, int from, sc_vtb_t *vtb2, int to, int count) sc_vtb_pointer(vtb2, to), count*sizeof(u_int16_t)); else -#endif bcopy((void *)sc_vtb_pointer(vtb1, from), (void *)sc_vtb_pointer(vtb2, to), count*sizeof(u_int16_t)); @@ -216,13 +202,11 @@ sc_vtb_append(sc_vtb_t *vtb1, int from, sc_vtb_t *vtb2, int count) while (count > 0) { len = imin(count, vtb2->vtb_size - vtb2->vtb_tail); -#ifndef __sparc64__ if (vtb1->vtb_type == VTB_FRAMEBUFFER) bcopy_fromio(sc_vtb_pointer(vtb1, from), sc_vtb_pointer(vtb2, vtb2->vtb_tail), len*sizeof(u_int16_t)); else -#endif bcopy((void *)sc_vtb_pointer(vtb1, from), (void *)sc_vtb_pointer(vtb2, vtb2->vtb_tail), len*sizeof(u_int16_t)); @@ -243,11 +227,9 @@ sc_vtb_erase(sc_vtb_t *vtb, int at, int count, int c, int attr) { if (at + count > vtb->vtb_size) count = vtb->vtb_size - at; -#ifndef __sparc64__ if (vtb->vtb_type == VTB_FRAMEBUFFER) fillw_io(attr | c, sc_vtb_pointer(vtb, at), count); else -#endif fillw(attr | c, (void *)sc_vtb_pointer(vtb, at), count); } @@ -260,12 +242,10 @@ sc_vtb_move(sc_vtb_t *vtb, int from, int to, int count) count = vtb->vtb_size - to; if (count <= 0) return; -#ifndef __sparc64__ if (vtb->vtb_type == VTB_FRAMEBUFFER) bcopy_io(sc_vtb_pointer(vtb, from), sc_vtb_pointer(vtb, to), count*sizeof(u_int16_t)); else -#endif bcopy((void *)sc_vtb_pointer(vtb, from), (void *)sc_vtb_pointer(vtb, to), count*sizeof(u_int16_t)); } @@ -279,23 +259,19 @@ sc_vtb_delete(sc_vtb_t *vtb, int at, int count, int c, int attr) count = vtb->vtb_size - at; len = vtb->vtb_size - at - count; if (len > 0) { -#ifndef __sparc64__ if (vtb->vtb_type == VTB_FRAMEBUFFER) bcopy_io(sc_vtb_pointer(vtb, at + count), sc_vtb_pointer(vtb, at), len*sizeof(u_int16_t)); else -#endif bcopy((void *)sc_vtb_pointer(vtb, at + count), (void *)sc_vtb_pointer(vtb, at), len*sizeof(u_int16_t)); } -#ifndef __sparc64__ if (vtb->vtb_type == VTB_FRAMEBUFFER) fillw_io(attr | c, sc_vtb_pointer(vtb, at + len), vtb->vtb_size - at - len); else -#endif fillw(attr | c, (void *)sc_vtb_pointer(vtb, at + len), vtb->vtb_size - at - len); } @@ -306,21 +282,17 @@ sc_vtb_ins(sc_vtb_t *vtb, int at, int count, int c, int attr) if (at + count > vtb->vtb_size) count = vtb->vtb_size - at; else { -#ifndef __sparc64__ if (vtb->vtb_type == VTB_FRAMEBUFFER) bcopy_io(sc_vtb_pointer(vtb, at), sc_vtb_pointer(vtb, at + count), (vtb->vtb_size - at - count)*sizeof(u_int16_t)); else -#endif bcopy((void *)sc_vtb_pointer(vtb, at), (void *)sc_vtb_pointer(vtb, at + count), (vtb->vtb_size - at - count)*sizeof(u_int16_t)); } -#ifndef __sparc64__ if (vtb->vtb_type == VTB_FRAMEBUFFER) fillw_io(attr | c, sc_vtb_pointer(vtb, at), count); else -#endif fillw(attr | c, (void *)sc_vtb_pointer(vtb, at), count); } diff --git a/sys/dev/syscons/syscons.c b/sys/dev/syscons/syscons.c index 06d4e525e834..d822820e13a0 100644 --- a/sys/dev/syscons/syscons.c +++ b/sys/dev/syscons/syscons.c @@ -65,8 +65,7 @@ __FBSDID("$FreeBSD$"); #include #include -#if defined(__arm__) || defined(__mips__) || defined(__powerpc__) || \ - defined(__sparc64__) +#if defined(__arm__) || defined(__mips__) || defined(__powerpc__) #include #else #include @@ -536,10 +535,8 @@ sc_set_vesa_mode(scr_stat *scp, sc_softc_t *sc, int unit) scp->end = 0; scp->cursor_pos = scp->cursor_oldpos = scp->xsize * scp->xsize; scp->mode = sc->initial_mode = vmode; -#ifndef __sparc64__ sc_vtb_init(&scp->scr, VTB_FRAMEBUFFER, scp->xsize, scp->ysize, (void *)sc->adp->va_window, FALSE); -#endif sc_alloc_scr_buffer(scp, FALSE, FALSE); sc_init_emulator(scp, NULL); #ifndef SC_NO_CUTPASTE @@ -725,9 +722,7 @@ sctty_open(struct tty *tp) int unit = scdevtounit(tp); sc_softc_t *sc; scr_stat *scp; -#ifndef __sparc64__ keyarg_t key; -#endif DPRINTF(5, ("scopen: dev:%s, unit:%d, vty:%d\n", devtoname(tp->t_dev), unit, @@ -741,13 +736,11 @@ sctty_open(struct tty *tp) if (!tty_opened(tp)) { /* Use the current setting of the <-- key as default VERASE. */ /* If the Delete key is preferable, an stty is necessary */ -#ifndef __sparc64__ if (sc->kbd != NULL) { key.keynum = KEYCODE_BS; (void)kbdd_ioctl(sc->kbd, GIO_KEYMAPENT, (caddr_t)&key); tp->t_termios.c_cc[VERASE] = key.key.map[0]; } -#endif } scp = sc_get_stat(tp); @@ -789,9 +782,7 @@ sctty_close(struct tty *tp) scp->smode.mode = VT_AUTO; } else { sc_vtb_destroy(&scp->vtb); -#ifndef __sparc64__ sc_vtb_destroy(&scp->scr); -#endif sc_free_history_buffer(scp, scp->ysize); SC_STAT(tp) = NULL; free(scp, M_DEVBUF); @@ -3003,11 +2994,9 @@ exchange_scr(sc_softc_t *sc) scp = sc->cur_scp = sc->new_scp; if (sc->old_scp->mode != scp->mode || ISUNKNOWNSC(sc->old_scp)) set_mode(scp); -#ifndef __sparc64__ else sc_vtb_init(&scp->scr, VTB_FRAMEBUFFER, scp->xsize, scp->ysize, (void *)sc->adp->va_window, FALSE); -#endif scp->status |= MOUSE_HIDDEN; sc_move_cursor(scp, scp->xpos, scp->ypos); if (!ISGRAPHSC(scp)) @@ -3334,14 +3323,12 @@ scinit(int unit, int flags) } sc->cur_scp = scp; -#ifndef __sparc64__ /* copy screen to temporary buffer */ sc_vtb_init(&scp->scr, VTB_FRAMEBUFFER, scp->xsize, scp->ysize, (void *)scp->sc->adp->va_window, FALSE); if (ISTEXTSC(scp)) sc_vtb_copy(&scp->scr, 0, &scp->vtb, 0, scp->xsize * scp->ysize); -#endif /* Sync h/w cursor position to s/w (sc and teken). */ if (col >= scp->xsize) @@ -3666,9 +3653,7 @@ init_scp(sc_softc_t *sc, int vty, scr_stat *scp) #endif sc_vtb_init(&scp->vtb, VTB_MEMORY, 0, 0, NULL, FALSE); -#ifndef __sparc64__ sc_vtb_init(&scp->scr, VTB_FRAMEBUFFER, 0, 0, NULL, FALSE); -#endif scp->xoff = scp->yoff = 0; scp->xpos = scp->ypos = 0; scp->start = scp->xsize * scp->ysize - 1; @@ -4192,10 +4177,8 @@ set_mode(scr_stat *scp) /* setup video hardware for the given mode */ vidd_set_mode(scp->sc->adp, scp->mode); scp->rndr->init(scp); -#ifndef __sparc64__ sc_vtb_init(&scp->scr, VTB_FRAMEBUFFER, scp->xsize, scp->ysize, (void *)scp->sc->adp->va_window, FALSE); -#endif update_font(scp); diff --git a/sys/dev/syscons/syscons.h b/sys/dev/syscons/syscons.h index 405e5ba42932..21060352f767 100644 --- a/sys/dev/syscons/syscons.h +++ b/sys/dev/syscons/syscons.h @@ -88,15 +88,7 @@ #define DPRINTF(l, p) if (SC_DEBUG_LEVEL >= (l)) printf p -#ifndef __sparc64__ #define SC_DRIVER_NAME "sc" -#else -/* - * Use a different driver name on sparc64 so it does not get confused - * with the system controller devices which are also termed 'sc' in OFW. - */ -#define SC_DRIVER_NAME "syscons" -#endif #define SC_VTY(dev) (((sc_ttysoftc *)tty_softc(tp))->st_index) #define SC_DEV(sc, vty) ((sc)->dev[(vty) - (sc)->first_vty]) #define SC_STAT(tp) (*((scr_stat **)&((sc_ttysoftc *)tty_softc(tp))->st_stat)) @@ -287,9 +279,7 @@ typedef struct scr_stat { int index; /* index of this vty */ struct sc_softc *sc; /* pointer to softc */ struct sc_rndr_sw *rndr; /* renderer */ -#ifndef __sparc64__ sc_vtb_t scr; -#endif sc_vtb_t vtb; int xpos; /* current X position */ diff --git a/sys/dev/twe/twe.c b/sys/dev/twe/twe.c index 1419d4ffa836..97778ad839b8 100644 --- a/sys/dev/twe/twe.c +++ b/sys/dev/twe/twe.c @@ -439,9 +439,13 @@ twe_startio(struct twe_softc *sc) if (bp->bio_cmd == BIO_READ) { tr->tr_flags |= TWE_CMD_DATAIN; cmd->io.opcode = TWE_OP_READ; - } else { + } else if (bp->bio_cmd == BIO_WRITE) { tr->tr_flags |= TWE_CMD_DATAOUT; cmd->io.opcode = TWE_OP_WRITE; + } else { + twe_release_request(tr); + biofinish(bp, NULL, EOPNOTSUPP); + break; } /* build a suitable I/O command (assumes 512-byte rounded transfers) */ diff --git a/sys/dev/uart/uart_bus_ebus.c b/sys/dev/uart/uart_bus_ebus.c deleted file mode 100644 index dd50ff83596f..000000000000 --- a/sys/dev/uart/uart_bus_ebus.c +++ /dev/null @@ -1,108 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD - * - * Copyright (c) 2001 by Thomas Moestl . - * 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 ``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 -__FBSDID("$FreeBSD$"); - -#include -#include -#include -#include -#include - -#include - -#include -#include -#include -#include - -#include -#include -#include - -static int uart_ebus_probe(device_t dev); - -static device_method_t uart_ebus_methods[] = { - /* Device interface */ - DEVMETHOD(device_probe, uart_ebus_probe), - DEVMETHOD(device_attach, uart_bus_attach), - DEVMETHOD(device_detach, uart_bus_detach), - { 0, 0 } -}; - -static driver_t uart_ebus_driver = { - uart_driver_name, - uart_ebus_methods, - sizeof(struct uart_softc), -}; - -static int -uart_ebus_probe(device_t dev) -{ - const char *nm, *cmpt; - struct uart_softc *sc; - struct uart_devinfo dummy; - - sc = device_get_softc(dev); - sc->sc_class = NULL; - - nm = ofw_bus_get_name(dev); - cmpt = ofw_bus_get_compat(dev); - if (cmpt == NULL) - cmpt = ""; - if (!strcmp(nm, "lom-console") || !strcmp(nm, "su") || - !strcmp(nm, "su_pnp") || !strcmp(cmpt, "rsc-console") || - !strcmp(cmpt, "rsc-control") || !strcmp(cmpt, "su") || - !strcmp(cmpt, "su16550") || !strcmp(cmpt, "su16552")) { - /* - * On AXi and AXmp boards the NS16550 (used to connect - * keyboard/mouse) share their IRQ lines with the i8042. - * Any IRQ activity (typically during attach) of the - * NS16550 used to connect the keyboard when actually the - * PS/2 keyboard is selected in OFW causes interaction - * with the OBP i8042 driver resulting in a hang and vice - * versa. As RS232 keyboards and mice obviously aren't - * meant to be used in parallel with PS/2 ones on these - * boards don't attach to the NS16550 in case the RS232 - * keyboard isn't selected in order to prevent such hangs. - */ - if ((!strcmp(sparc64_model, "SUNW,UltraAX-MP") || - !strcmp(sparc64_model, "SUNW,UltraSPARC-IIi-Engine")) && - uart_cpu_getdev(UART_DEV_KEYBOARD, &dummy)) { - device_disable(dev); - return (ENXIO); - } - sc->sc_class = &uart_ns8250_class; - return (uart_bus_probe(dev, 0, 0, 0, 0, 0, 0)); - } - - return (ENXIO); -} - -DRIVER_MODULE(uart, ebus, uart_ebus_driver, uart_devclass, 0, 0); diff --git a/sys/dev/uart/uart_cpu_sparc64.c b/sys/dev/uart/uart_cpu_sparc64.c deleted file mode 100644 index 17a2ca84bb6c..000000000000 --- a/sys/dev/uart/uart_cpu_sparc64.c +++ /dev/null @@ -1,307 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD - * - * Copyright (c) 2003, 2004 Marcel Moolenaar - * Copyright (c) 2004 - 2006 Marius Strobl - * 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 ``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 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 -__FBSDID("$FreeBSD$"); - -#include -#include - -#include -#include - -#include -#include - -#include -#include - -bus_space_tag_t uart_bus_space_io; -bus_space_tag_t uart_bus_space_mem; - -static struct bus_space_tag bst_store[3]; - -/* - * Determine which channel of a SCC a device referenced by a full device - * path or as an alias is (in the latter case we try to look up the device - * path via the /aliases node). - * Only the device paths of devices which are used for TTYs really allow - * to do this as they look like these (taken from /aliases nodes): - * ttya: '/central/fhc/zs@0,902000:a' - * ttyc: '/pci@1f,0/pci@1,1/ebus@1/se@14,400000:a' - * Additionally, for device paths of SCCs which are connected to a RSC - * (Remote System Control) device we can hardcode the appropriate channel. - * Such device paths look like these: - * rsc: '/pci@1f,4000/ebus@1/se@14,200000:ssp' - * ttyc: '/pci@1f,4000/ebus@1/se@14,200000:ssp' - */ -static int -uart_cpu_channel(char *dev) -{ - char alias[64]; - phandle_t aliases; - int len; - const char *p; - - strcpy(alias, dev); - if ((aliases = OF_finddevice("/aliases")) != -1) - (void)OF_getprop(aliases, dev, alias, sizeof(alias)); - len = strlen(alias); - if ((p = strrchr(alias, ':')) == NULL) - return (0); - p++; - if (p - alias == len - 1 && (*p == 'a' || *p == 'b')) - return (*p - 'a' + 1); - if (strcmp(p, "ssp") == 0) - return (1); - return (0); -} - -int -uart_cpu_eqres(struct uart_bas *b1, struct uart_bas *b2) -{ - - return ((b1->bsh == b2->bsh) ? 1 : 0); -} - -/* - * Get the package handle of the UART that is selected as the console, if - * the console is an UART of course. Note that we enforce that both input - * and output are selected. - * Note that the currently active console (i.e. /chosen/stdout and - * /chosen/stdin) may not be the same as the device selected in the - * environment (ie /options/output-device and /options/input-device) because - * keyboard and screen were selected but the keyboard was unplugged or the - * user has changed the environment. In the latter case I would assume that - * the user expects that FreeBSD uses the new console setting. - * For weirder configurations, use ofw_console(4). - */ -static phandle_t -uart_cpu_getdev_console(phandle_t options, char *dev, size_t devsz) -{ - char buf[sizeof("serial")]; - ihandle_t inst; - phandle_t chosen, input, output; - - if (OF_getprop(options, "input-device", dev, devsz) == -1) - return (-1); - input = OF_finddevice(dev); - if (OF_getprop(options, "output-device", dev, devsz) == -1) - return (-1); - output = OF_finddevice(dev); - if (input == -1 || output == -1 || - OF_getproplen(input, "keyboard") >= 0) { - if ((chosen = OF_finddevice("/chosen")) == -1) - return (-1); - if (OF_getprop(chosen, "stdin", &inst, sizeof(inst)) == -1) - return (-1); - if ((input = OF_instance_to_package(inst)) == -1) - return (-1); - if (OF_getprop(chosen, "stdout", &inst, sizeof(inst)) == -1) - return (-1); - if ((output = OF_instance_to_package(inst)) == -1) - return (-1); - snprintf(dev, devsz, "ttya"); - } - if (input != output) - return (-1); - if (OF_getprop(input, "device_type", buf, sizeof(buf)) == -1) - return (-1); - if (strcmp(buf, "serial") != 0) - return (-1); - /* For a Serengeti console device point to the bootbus controller. */ - if (OF_getprop(input, "name", buf, sizeof(buf)) > 0 && - !strcmp(buf, "sgcn")) { - if ((chosen = OF_finddevice("/chosen")) == -1) - return (-1); - if (OF_getprop(chosen, "iosram", &input, sizeof(input)) == -1) - return (-1); - } - return (input); -} - -/* - * Get the package handle of the UART that's selected as the debug port. - * Since there's no place for this in the OF, we use the kernel environment - * variable "hw.uart.dbgport". Note however that the variable is not a - * list of attributes. It's single device name or alias, as known by - * the OF. - */ -static phandle_t -uart_cpu_getdev_dbgport(char *dev, size_t devsz) -{ - char buf[sizeof("serial")]; - phandle_t input; - - if (!getenv_string("hw.uart.dbgport", dev, devsz)) - return (-1); - if ((input = OF_finddevice(dev)) == -1) - return (-1); - if (OF_getprop(input, "device_type", buf, sizeof(buf)) == -1) - return (-1); - if (strcmp(buf, "serial") != 0) - return (-1); - return (input); -} - -/* - * Get the package handle of the UART that is selected as the keyboard port, - * if it's actually used to connect the keyboard according to the OF. I.e. - * this will return the UART used to connect the keyboard regardless whether - * it's stdin or not, however not in case the user or the OF gave preference - * to e.g. a PS/2 keyboard by setting /aliases/keyboard accordingly. - */ -static phandle_t -uart_cpu_getdev_keyboard(char *dev, size_t devsz) -{ - char buf[sizeof("serial")]; - phandle_t input; - - if ((input = OF_finddevice("keyboard")) == -1) - return (-1); - if (OF_getprop(input, "device_type", buf, sizeof(buf)) == -1) - return (-1); - if (strcmp(buf, "serial") != 0) - return (-1); - if (OF_getprop(input, "name", dev, devsz) == -1) - return (-1); - /* - * So far this also matched PS/2 keyboard nodes so make sure it's - * one of the SCCs/UARTs known to be used to connect keyboards. - */ - if (strcmp(dev, "su") && strcmp(dev, "su_pnp") && strcmp(dev, "zs")) - return (-1); - return (input); -} - -int -uart_cpu_getdev(int devtype, struct uart_devinfo *di) -{ - char buf[32], compat[32], dev[64]; - struct uart_class *class; - phandle_t input, options; - bus_addr_t addr; - int baud, bits, error, range, space, stop; - char flag, par; - - if ((options = OF_finddevice("/options")) == -1) - return (ENXIO); - switch (devtype) { - case UART_DEV_CONSOLE: - input = uart_cpu_getdev_console(options, dev, sizeof(dev)); - break; - case UART_DEV_DBGPORT: - input = uart_cpu_getdev_dbgport(dev, sizeof(dev)); - break; - case UART_DEV_KEYBOARD: - input = uart_cpu_getdev_keyboard(dev, sizeof(dev)); - break; - default: - input = -1; - break; - } - if (input == -1) - return (ENXIO); - error = OF_decode_addr(input, 0, &space, &addr); - if (error) - return (error); - - /* Get the device class. */ - if (OF_getprop(input, "name", buf, sizeof(buf)) == -1) - return (ENXIO); - if (OF_getprop(input, "compatible", compat, sizeof(compat)) == -1) - compat[0] = '\0'; - di->bas.regshft = 0; - di->bas.rclk = 0; - class = NULL; - if (!strcmp(buf, "se") || !strcmp(buf, "FJSV,se") || - !strcmp(compat, "sab82532")) { - class = &uart_sab82532_class; - /* SAB82532 are only known to be used for TTYs. */ - if ((di->bas.chan = uart_cpu_channel(dev)) == 0) - return (ENXIO); - addr += uart_getrange(class) * (di->bas.chan - 1); - } else if (!strcmp(buf, "zs")) { - class = &uart_z8530_class; - if ((di->bas.chan = uart_cpu_channel(dev)) == 0) { - /* - * There's no way to determine from OF which - * channel has the keyboard. Should always be - * on channel 1 however. - */ - if (devtype == UART_DEV_KEYBOARD) - di->bas.chan = 1; - else - return (ENXIO); - } - di->bas.regshft = 1; - range = uart_getrange(class) << di->bas.regshft; - addr += range - range * (di->bas.chan - 1); - } else if (!strcmp(buf, "lom-console") || !strcmp(buf, "su") || - !strcmp(buf, "su_pnp") || !strcmp(compat, "rsc-console") || - !strcmp(compat, "su") || !strcmp(compat, "su16550") || - !strcmp(compat, "su16552")) { - class = &uart_ns8250_class; - di->bas.chan = 0; - } else if (!strcmp(compat, "sgsbbc")) { - class = &uart_sbbc_class; - di->bas.chan = 0; - } - if (class == NULL) - return (ENXIO); - - /* Fill in the device info. */ - di->ops = uart_getops(class); - di->bas.bst = &bst_store[devtype]; - di->bas.bsh = sparc64_fake_bustag(space, addr, di->bas.bst); - - /* Get the line settings. */ - if (devtype == UART_DEV_KEYBOARD) - di->baudrate = 1200; - else if (!strcmp(compat, "rsc-console")) - di->baudrate = 115200; - else - di->baudrate = 9600; - di->databits = 8; - di->stopbits = 1; - di->parity = UART_PARITY_NONE; - snprintf(buf, sizeof(buf), "%s-mode", dev); - if (OF_getprop(options, buf, buf, sizeof(buf)) == -1 && - OF_getprop(input, "ssp-console-modes", buf, sizeof(buf)) == -1) - return (0); - if (sscanf(buf, "%d,%d,%c,%d,%c", &baud, &bits, &par, &stop, &flag) - != 5) - return (0); - di->baudrate = baud; - di->databits = bits; - di->stopbits = stop; - di->parity = (par == 'n') ? UART_PARITY_NONE : - (par == 'o') ? UART_PARITY_ODD : UART_PARITY_EVEN; - return (0); -} diff --git a/sys/dev/uart/uart_kbd_sun.c b/sys/dev/uart/uart_kbd_sun.c deleted file mode 100644 index 5c9d7555f186..000000000000 --- a/sys/dev/uart/uart_kbd_sun.c +++ /dev/null @@ -1,869 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD - * - * Copyright (c) 2003 Jake Burkholder. - * 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 -__FBSDID("$FreeBSD$"); - -#include "opt_kbd.h" -#include "opt_sunkbd.h" - -#if (defined(SUNKBD_EMULATE_ATKBD) && defined(SUNKBD_DFLT_KEYMAP)) || \ - !defined(SUNKBD_EMULATE_ATKBD) -#define KBD_DFLT_KEYMAP -#endif - -#include -#include -#include -#include -#include -#include -#include - -#include - -#include -#include - -#include -#include -#include - -#include -#if !defined(SUNKBD_EMULATE_ATKBD) -#include -#endif - -#if defined(SUNKBD_EMULATE_ATKBD) && defined(SUNKBD_DFLT_KEYMAP) -#include "sunkbdmap.h" -#endif -#include "uart_if.h" - -#define SUNKBD_DRIVER_NAME "sunkbd" - -#define TODO printf("%s: unimplemented", __func__) - -struct sunkbd_softc { - keyboard_t sc_kbd; - struct uart_softc *sc_uart; - struct uart_devinfo *sc_sysdev; - - struct callout sc_repeat_callout; - int sc_repeat_key; - - int sc_accents; - int sc_composed_char; - int sc_flags; -#define KPCOMPOSE (1 << 0) - int sc_mode; - int sc_polling; - int sc_repeating; - int sc_state; - -#if defined(SUNKBD_EMULATE_ATKBD) - int sc_buffered_char[2]; -#endif -}; - -static int sunkbd_configure(int flags); -static int sunkbd_probe_keyboard(struct uart_devinfo *di); - -static int sunkbd_probe(int unit, void *arg, int flags); -static int sunkbd_init(int unit, keyboard_t **kbdp, void *arg, int flags); -static int sunkbd_term(keyboard_t *kbd); -static int sunkbd_intr(keyboard_t *kbd, void *arg); -static int sunkbd_test_if(keyboard_t *kbd); -static int sunkbd_enable(keyboard_t *kbd); -static int sunkbd_disable(keyboard_t *kbd); -static int sunkbd_read(keyboard_t *kbd, int wait); -static int sunkbd_check(keyboard_t *kbd); -static u_int sunkbd_read_char(keyboard_t *kbd, int wait); -static int sunkbd_check_char(keyboard_t *kbd); -static int sunkbd_ioctl(keyboard_t *kbd, u_long cmd, caddr_t data); -static int sunkbd_lock(keyboard_t *kbd, int lock); -static void sunkbd_clear_state(keyboard_t *kbd); -static int sunkbd_get_state(keyboard_t *kbd, void *buf, size_t len); -static int sunkbd_set_state(keyboard_t *kbd, void *buf, size_t len); -static int sunkbd_poll_mode(keyboard_t *kbd, int on); -static void sunkbd_diag(keyboard_t *kbd, int level); - -static void sunkbd_repeat(void *v); -#if defined(SUNKBD_EMULATE_ATKBD) -static int keycode2scancode(int keycode, int shift, int up); -#endif - -static keyboard_switch_t sunkbdsw = { - .probe = sunkbd_probe, - .init = sunkbd_init, - .term = sunkbd_term, - .intr = sunkbd_intr, - .test_if = sunkbd_test_if, - .enable = sunkbd_enable, - .disable = sunkbd_disable, - .read = sunkbd_read, - .check = sunkbd_check, - .read_char = sunkbd_read_char, - .check_char = sunkbd_check_char, - .ioctl = sunkbd_ioctl, - .lock = sunkbd_lock, - .clear_state = sunkbd_clear_state, - .get_state = sunkbd_get_state, - .set_state = sunkbd_set_state, - .poll = sunkbd_poll_mode, - .diag = sunkbd_diag -}; - -KEYBOARD_DRIVER(sunkbd, sunkbdsw, sunkbd_configure); - -static struct sunkbd_softc sunkbd_softc; -static struct uart_devinfo uart_keyboard; - -#if defined(SUNKBD_EMULATE_ATKBD) - -#define SCAN_PRESS 0x000 -#define SCAN_RELEASE 0x080 -#define SCAN_PREFIX_E0 0x100 -#define SCAN_PREFIX_E1 0x200 -#define SCAN_PREFIX_CTL 0x400 -#define SCAN_PREFIX_SHIFT 0x800 -#define SCAN_PREFIX (SCAN_PREFIX_E0 | SCAN_PREFIX_E1 | \ - SCAN_PREFIX_CTL | SCAN_PREFIX_SHIFT) - -#define NOTR 0x0 /* no translation */ - -static const uint8_t sunkbd_trtab[] = { - NOTR, 0x6d, 0x78, 0x6e, 0x79, 0x3b, 0x3c, 0x44, /* 0x00 - 0x07 */ - 0x3d, 0x57, 0x3e, 0x58, 0x3f, 0x5d, 0x40, NOTR, /* 0x08 - 0x0f */ - 0x41, 0x42, 0x43, 0x38, 0x5f, 0x68, 0x5c, 0x46, /* 0x10 - 0x17 */ - 0x61, 0x6f, 0x70, 0x64, 0x62, 0x01, 0x02, 0x03, /* 0x18 - 0x1f */ - 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, /* 0x20 - 0x27 */ - 0x0c, 0x0d, 0x29, 0x0e, 0x66, 0x77, 0x5b, 0x37, /* 0x28 - 0x2f */ - 0x7a, 0x71, 0x53, 0x74, 0x5e, 0x0f, 0x10, 0x11, /* 0x30 - 0x37 */ - 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, /* 0x38 - 0x3f */ - 0x1a, 0x1b, 0x67, 0x6b, 0x47, 0x48, 0x49, 0x4a, /* 0x40 - 0x47 */ - 0x73, 0x72, 0x63, NOTR, 0x1d, 0x1e, 0x1f, 0x20, /* 0x48 - 0x4f */ - 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, /* 0x50 - 0x57 */ - 0x2b, 0x1c, 0x59, 0x4b, 0x4c, 0x4d, 0x52, 0x75, /* 0x58 - 0x5f */ - 0x60, 0x76, 0x45, 0x2a, 0x2c, 0x2d, 0x2e, 0x2f, /* 0x60 - 0x67 */ - 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, NOTR, /* 0x68 - 0x6f */ - 0x4f, 0x50, 0x51, NOTR, NOTR, NOTR, 0x6c, 0x3a, /* 0x70 - 0x77 */ - 0x69, 0x39, 0x6a, 0x65, 0x56, 0x4e, NOTR, NOTR /* 0x78 - 0x7f */ -}; - -#endif - -static int -sunkbd_probe_keyboard(struct uart_devinfo *di) -{ - int c, id, ltries, tries; - - for (tries = 5; tries != 0; tries--) { - uart_putc(di, SKBD_CMD_RESET); - for (ltries = 1000; ltries != 0; ltries--) { - if (uart_poll(di) == SKBD_RSP_RESET) - break; - DELAY(1000); - } - if (ltries == 0) - continue; - id = -1; - for (ltries = 1000; ltries != 0; ltries--) { - switch (c = uart_poll(di)) { - case -1: - break; - case SKBD_RSP_IDLE: - return (id); - default: - id = c; - } - DELAY(1000); - } - } - return (-1); -} - -static int sunkbd_attach(struct uart_softc *sc); -static void sunkbd_uart_intr(void *arg); - -static int -sunkbd_configure(int flags) -{ - struct sunkbd_softc *sc; - - /* - * We are only prepared to be used for the high-level console - * when the keyboard is both configured and attached. - */ - if (!(flags & KB_CONF_PROBE_ONLY)) { - if (KBD_IS_INITIALIZED(&sunkbd_softc.sc_kbd)) - goto found; - else - return (0); - } - - if (uart_cpu_getdev(UART_DEV_KEYBOARD, &uart_keyboard)) - return (0); - if (uart_probe(&uart_keyboard)) - return (0); - uart_init(&uart_keyboard); - - uart_keyboard.type = UART_DEV_KEYBOARD; - uart_keyboard.attach = sunkbd_attach; - uart_add_sysdev(&uart_keyboard); - - if (sunkbd_probe_keyboard(&uart_keyboard) != KB_SUN4) - return (0); - - sc = &sunkbd_softc; - callout_init(&sc->sc_repeat_callout, 0); - sunkbd_clear_state(&sc->sc_kbd); - -#if defined(SUNKBD_EMULATE_ATKBD) - kbd_init_struct(&sc->sc_kbd, SUNKBD_DRIVER_NAME, KB_101, 0, 0, 0, 0); - kbd_set_maps(&sc->sc_kbd, &key_map, &accent_map, fkey_tab, - sizeof(fkey_tab) / sizeof(fkey_tab[0])); -#else - kbd_init_struct(&sc->sc_kbd, SUNKBD_DRIVER_NAME, KB_OTHER, 0, 0, 0, 0); - kbd_set_maps(&sc->sc_kbd, &keymap_sun_us_unix_kbd, - &accentmap_sun_us_unix_kbd, fkey_tab, - sizeof(fkey_tab) / sizeof(fkey_tab[0])); -#endif - sc->sc_mode = K_XLATE; - kbd_register(&sc->sc_kbd); - - sc->sc_sysdev = &uart_keyboard; - - found: - /* Return number of found keyboards. */ - return (1); -} - -static int -sunkbd_attach(struct uart_softc *sc) -{ - - /* - * Don't attach if we didn't probe the keyboard. Note that - * the UART is still marked as a system device in that case. - */ - if (sunkbd_softc.sc_sysdev == NULL) { - device_printf(sc->sc_dev, "keyboard not present\n"); - return (0); - } - - if (sc->sc_sysdev != NULL) { - sunkbd_softc.sc_uart = sc; - -#ifdef KBD_INSTALL_CDEV - kbd_attach(&sunkbd_softc.sc_kbd); -#endif - sunkbd_enable(&sunkbd_softc.sc_kbd); - - swi_add(&tty_intr_event, uart_driver_name, sunkbd_uart_intr, - &sunkbd_softc, SWI_TTY, INTR_TYPE_TTY, &sc->sc_softih); - - sc->sc_opened = 1; - KBD_INIT_DONE(&sunkbd_softc.sc_kbd); - } - - return (0); -} - -static void -sunkbd_uart_intr(void *arg) -{ - struct sunkbd_softc *sc = arg; - int pend; - - if (sc->sc_uart->sc_leaving) - return; - - pend = atomic_readandclear_32(&sc->sc_uart->sc_ttypend); - if (!(pend & SER_INT_MASK)) - return; - - if (pend & SER_INT_RXREADY) { - if (KBD_IS_ACTIVE(&sc->sc_kbd) && KBD_IS_BUSY(&sc->sc_kbd)) { - sc->sc_kbd.kb_callback.kc_func(&sc->sc_kbd, - KBDIO_KEYINPUT, sc->sc_kbd.kb_callback.kc_arg); - } - } -} - -static int -sunkbd_probe(int unit, void *arg, int flags) -{ - - TODO; - return (0); -} - -static int -sunkbd_init(int unit, keyboard_t **kbdp, void *arg, int flags) -{ - - TODO; - return (0); -} - -static int -sunkbd_term(keyboard_t *kbd) -{ - - TODO; - return (0); -} - -static int -sunkbd_intr(keyboard_t *kbd, void *arg) -{ - - TODO; - return (0); -} - -static int -sunkbd_test_if(keyboard_t *kbd) -{ - - TODO; - return (0); -} - -static int -sunkbd_enable(keyboard_t *kbd) -{ - - KBD_ACTIVATE(kbd); - return (0); -} - -static int -sunkbd_disable(keyboard_t *kbd) -{ - - KBD_DEACTIVATE(kbd); - return (0); -} - -static int -sunkbd_read(keyboard_t *kbd, int wait) -{ - - TODO; - return (0); -} - -static int -sunkbd_check(keyboard_t *kbd) -{ - struct sunkbd_softc *sc; - - if (!KBD_IS_ACTIVE(kbd)) - return (FALSE); - - sc = (struct sunkbd_softc *)kbd; - -#if defined(SUNKBD_EMULATE_ATKBD) - if (sc->sc_buffered_char[0]) - return (TRUE); -#endif - - if (sc->sc_repeating) - return (TRUE); - - if (sc->sc_uart != NULL && !uart_rx_empty(sc->sc_uart)) - return (TRUE); - - if (sc->sc_polling != 0 && sc->sc_sysdev != NULL && - uart_rxready(sc->sc_sysdev)) - return (TRUE); - - return (FALSE); -} - -static u_int -sunkbd_read_char(keyboard_t *kbd, int wait) -{ - struct sunkbd_softc *sc; - int key, release, repeated, suncode; - - sc = (struct sunkbd_softc *)kbd; - -#if defined(SUNKBD_EMULATE_ATKBD) - if (sc->sc_mode == K_RAW && sc->sc_buffered_char[0]) { - key = sc->sc_buffered_char[0]; - if (key & SCAN_PREFIX) { - sc->sc_buffered_char[0] = key & ~SCAN_PREFIX; - return ((key & SCAN_PREFIX_E0) ? 0xe0 : 0xe1); - } else { - sc->sc_buffered_char[0] = sc->sc_buffered_char[1]; - sc->sc_buffered_char[1] = 0; - return (key); - } - } -#endif - - repeated = 0; - if (sc->sc_repeating) { - repeated = 1; - sc->sc_repeating = 0; - callout_reset(&sc->sc_repeat_callout, hz / 10, - sunkbd_repeat, sc); - suncode = sc->sc_repeat_key; - goto process_code; - } - - for (;;) { - next_code: - if (!(sc->sc_flags & KPCOMPOSE) && (sc->sc_composed_char > 0)) { - key = sc->sc_composed_char; - sc->sc_composed_char = 0; - if (key > UCHAR_MAX) - return (ERRKEY); - return (key); - } - - if (sc->sc_uart != NULL && !uart_rx_empty(sc->sc_uart)) { - suncode = uart_rx_get(sc->sc_uart); - } else if (sc->sc_polling != 0 && sc->sc_sysdev != NULL) { - if (wait) - suncode = uart_getc(sc->sc_sysdev); - else if ((suncode = uart_poll(sc->sc_sysdev)) == -1) - return (NOKEY); - } else { - return (NOKEY); - } - - switch (suncode) { - case SKBD_RSP_IDLE: - break; - default: - process_code: - ++kbd->kb_count; - key = SKBD_KEY_CHAR(suncode); - release = suncode & SKBD_KEY_RELEASE; - if (!repeated) { - if (release == 0) { - callout_reset(&sc->sc_repeat_callout, - hz / 2, sunkbd_repeat, sc); - sc->sc_repeat_key = suncode; - } else if (sc->sc_repeat_key == key) { - callout_stop(&sc->sc_repeat_callout); - sc->sc_repeat_key = -1; - } - } - -#if defined(SUNKBD_EMULATE_ATKBD) - key = sunkbd_trtab[key]; - if (key == NOTR) - return (NOKEY); - - if (!repeated) { - switch (key) { - case 0x1d: /* ctrl */ - if (release != 0) - sc->sc_flags &= ~CTLS; - else - sc->sc_flags |= CTLS; - break; - case 0x2a: /* left shift */ - case 0x36: /* right shift */ - if (release != 0) - sc->sc_flags &= ~SHIFTS; - else - sc->sc_flags |= SHIFTS; - break; - case 0x38: /* alt */ - case 0x5d: /* altgr */ - if (release != 0) - sc->sc_flags &= ~ALTS; - else - sc->sc_flags |= ALTS; - break; - } - } - if (sc->sc_mode == K_RAW) { - key = keycode2scancode(key, sc->sc_flags, - release); - if (key & SCAN_PREFIX) { - if (key & SCAN_PREFIX_CTL) { - sc->sc_buffered_char[0] = - 0x1d | (key & SCAN_RELEASE); - sc->sc_buffered_char[1] = - key & ~SCAN_PREFIX; - } else if (key & SCAN_PREFIX_SHIFT) { - sc->sc_buffered_char[0] = - 0x2a | (key & SCAN_RELEASE); - sc->sc_buffered_char[1] = - key & ~SCAN_PREFIX_SHIFT; - } else { - sc->sc_buffered_char[0] = - key & ~SCAN_PREFIX; - sc->sc_buffered_char[1] = 0; - } - return ((key & SCAN_PREFIX_E0) ? - 0xe0 : 0xe1); - } - return (key); - } - switch (key) { - case 0x5c: /* print screen */ - if (sc->sc_flags & ALTS) - key = 0x54; /* sysrq */ - break; - case 0x68: /* pause/break */ - if (sc->sc_flags & CTLS) - key = 0x6c; /* break */ - break; - } - - if (sc->sc_mode == K_CODE) - return (key | release); -#else - if (sc->sc_mode == K_RAW || sc->sc_mode == K_CODE) - return (suncode); -#endif - -#if defined(SUNKBD_EMULATE_ATKBD) - if (key == 0x38) { /* left alt (KP compose key) */ -#else - if (key == 0x13) { /* left alt (KP compose key) */ -#endif - if (release != 0) { - if (sc->sc_flags & KPCOMPOSE) { - sc->sc_flags &= ~KPCOMPOSE; - if (sc->sc_composed_char > - UCHAR_MAX) - sc->sc_composed_char = - 0; - } - } else { - if (!(sc->sc_flags & KPCOMPOSE)) { - sc->sc_flags |= KPCOMPOSE; - sc->sc_composed_char = 0; - } - } - } - if (sc->sc_flags & KPCOMPOSE) { - switch (suncode) { - case 0x44: /* KP 7 */ - case 0x45: /* KP 8 */ - case 0x46: /* KP 9 */ - sc->sc_composed_char *= 10; - sc->sc_composed_char += suncode - 0x3d; - if (sc->sc_composed_char > UCHAR_MAX) - return (ERRKEY); - goto next_code; - case 0x5b: /* KP 4 */ - case 0x5c: /* KP 5 */ - case 0x5d: /* KP 6 */ - sc->sc_composed_char *= 10; - sc->sc_composed_char += suncode - 0x58; - if (sc->sc_composed_char > UCHAR_MAX) - return (ERRKEY); - goto next_code; - case 0x70: /* KP 1 */ - case 0x71: /* KP 2 */ - case 0x72: /* KP 3 */ - sc->sc_composed_char *= 10; - sc->sc_composed_char += suncode - 0x6f; - if (sc->sc_composed_char > UCHAR_MAX) - return (ERRKEY); - goto next_code; - case 0x5e: /* KP 0 */ - sc->sc_composed_char *= 10; - if (sc->sc_composed_char > UCHAR_MAX) - return (ERRKEY); - goto next_code; - - case 0x44 | SKBD_KEY_RELEASE: /* KP 7 */ - case 0x45 | SKBD_KEY_RELEASE: /* KP 8 */ - case 0x46 | SKBD_KEY_RELEASE: /* KP 9 */ - case 0x5b | SKBD_KEY_RELEASE: /* KP 4 */ - case 0x5c | SKBD_KEY_RELEASE: /* KP 5 */ - case 0x5d | SKBD_KEY_RELEASE: /* KP 6 */ - case 0x70 | SKBD_KEY_RELEASE: /* KP 1 */ - case 0x71 | SKBD_KEY_RELEASE: /* KP 2 */ - case 0x72 | SKBD_KEY_RELEASE: /* KP 3 */ - case 0x5e | SKBD_KEY_RELEASE: /* KP 0 */ - goto next_code; - default: - if (sc->sc_composed_char > 0) { - sc->sc_flags &= ~KPCOMPOSE; - sc->sc_composed_char = 0; - return (ERRKEY); - } - } - } - - key = genkbd_keyaction(kbd, key, release, - &sc->sc_state, &sc->sc_accents); - if (key != NOKEY || repeated) - return (key); - } - } - return (0); -} - -static int -sunkbd_check_char(keyboard_t *kbd) -{ - struct sunkbd_softc *sc; - - if (!KBD_IS_ACTIVE(kbd)) - return (FALSE); - - sc = (struct sunkbd_softc *)kbd; - if (!(sc->sc_flags & KPCOMPOSE) && (sc->sc_composed_char > 0)) - return (TRUE); - - return (sunkbd_check(kbd)); -} - -static int -sunkbd_ioctl(keyboard_t *kbd, u_long cmd, caddr_t data) -{ - struct sunkbd_softc *sc; - int c, error; -#if defined(COMPAT_FREEBSD6) || defined(COMPAT_FREEBSD5) - int ival; -#endif - - sc = (struct sunkbd_softc *)kbd; - error = 0; - switch (cmd) { - case KDGKBMODE: - *(int *)data = sc->sc_mode; - break; -#if defined(COMPAT_FREEBSD6) || defined(COMPAT_FREEBSD5) - case _IO('K', 7): - ival = IOCPARM_IVAL(data); - data = (caddr_t)&ival; - /* FALLTHROUGH */ -#endif - case KDSKBMODE: - switch (*(int *)data) { - case K_XLATE: - if (sc->sc_mode != K_XLATE) { - /* make lock key state and LED state match */ - sc->sc_state &= ~LOCK_MASK; - sc->sc_state |= KBD_LED_VAL(kbd); - } - /* FALLTHROUGH */ - case K_RAW: - case K_CODE: - if (sc->sc_mode != *(int *)data) { - sunkbd_clear_state(kbd); - sc->sc_mode = *(int *)data; - } - break; - default: - error = EINVAL; - break; - } - break; - case KDGETLED: - *(int *)data = KBD_LED_VAL(kbd); - break; -#if defined(COMPAT_FREEBSD6) || defined(COMPAT_FREEBSD5) - case _IO('K', 66): - ival = IOCPARM_IVAL(data); - data = (caddr_t)&ival; - /* FALLTHROUGH */ -#endif - case KDSETLED: - if (*(int *)data & ~LOCK_MASK) { - error = EINVAL; - break; - } - if (sc->sc_sysdev == NULL) - break; - c = 0; - if (*(int *)data & CLKED) - c |= SKBD_LED_CAPSLOCK; - if (*(int *)data & NLKED) - c |= SKBD_LED_NUMLOCK; - if (*(int *)data & SLKED) - c |= SKBD_LED_SCROLLLOCK; - uart_lock(sc->sc_sysdev->hwmtx); - sc->sc_sysdev->ops->putc(&sc->sc_sysdev->bas, SKBD_CMD_SETLED); - sc->sc_sysdev->ops->putc(&sc->sc_sysdev->bas, c); - uart_unlock(sc->sc_sysdev->hwmtx); - KBD_LED_VAL(kbd) = *(int *)data; - break; - case KDGKBSTATE: - *(int *)data = sc->sc_state & LOCK_MASK; - break; -#if defined(COMPAT_FREEBSD6) || defined(COMPAT_FREEBSD5) - case _IO('K', 20): - ival = IOCPARM_IVAL(data); - data = (caddr_t)&ival; - /* FALLTHROUGH */ -#endif - case KDSKBSTATE: - if (*(int *)data & ~LOCK_MASK) { - error = EINVAL; - break; - } - sc->sc_state &= ~LOCK_MASK; - sc->sc_state |= *(int *)data; - /* set LEDs and quit */ - return (sunkbd_ioctl(kbd, KDSETLED, data)); - case KDSETREPEAT: - case KDSETRAD: - break; - case PIO_KEYMAP: - case OPIO_KEYMAP: - case PIO_KEYMAPENT: - case PIO_DEADKEYMAP: - default: - return (genkbd_commonioctl(kbd, cmd, data)); - } - return (error); -} - -static int -sunkbd_lock(keyboard_t *kbd, int lock) -{ - - TODO; - return (0); -} - -static void -sunkbd_clear_state(keyboard_t *kbd) -{ - struct sunkbd_softc *sc; - - sc = (struct sunkbd_softc *)kbd; - sc->sc_repeat_key = -1; - sc->sc_accents = 0; - sc->sc_composed_char = 0; - sc->sc_flags = 0; - sc->sc_polling = 0; - sc->sc_repeating = 0; - sc->sc_state &= LOCK_MASK; /* Preserve locking key state. */ - -#if defined(SUNKBD_EMULATE_ATKBD) - sc->sc_buffered_char[0] = 0; - sc->sc_buffered_char[1] = 0; -#endif -} - -static int -sunkbd_get_state(keyboard_t *kbd, void *buf, size_t len) -{ - - TODO; - return (0); -} - -static int -sunkbd_set_state(keyboard_t *kbd, void *buf, size_t len) -{ - - TODO; - return (0); -} - -static int -sunkbd_poll_mode(keyboard_t *kbd, int on) -{ - struct sunkbd_softc *sc; - - sc = (struct sunkbd_softc *)kbd; - if (on) - sc->sc_polling++; - else - sc->sc_polling--; - return (0); -} - -static void -sunkbd_diag(keyboard_t *kbd, int level) -{ - - TODO; -} - -static void -sunkbd_repeat(void *v) -{ - struct sunkbd_softc *sc = v; - - if (KBD_IS_ACTIVE(&sc->sc_kbd) && KBD_IS_BUSY(&sc->sc_kbd)) { - if (sc->sc_repeat_key != -1) { - sc->sc_repeating = 1; - sc->sc_kbd.kb_callback.kc_func(&sc->sc_kbd, - KBDIO_KEYINPUT, sc->sc_kbd.kb_callback.kc_arg); - } - } -} - -#if defined(SUNKBD_EMULATE_ATKBD) -static int -keycode2scancode(int keycode, int shift, int up) -{ - static const int scan[] = { - /* KP enter, right ctrl, KP divide */ - 0x1c , 0x1d , 0x35 , - /* print screen */ - 0x37 | SCAN_PREFIX_SHIFT, - /* right alt, home, up, page up, left, right, end */ - 0x38, 0x47, 0x48, 0x49, 0x4b, 0x4d, 0x4f, - /* down, page down, insert, delete */ - 0x50, 0x51, 0x52, 0x53, - /* pause/break (see also below) */ - 0x46, - /* - * MS: left window, right window, menu - * also Sun: left meta, right meta, compose - */ - 0x5b, 0x5c, 0x5d, - /* Sun type 6 USB */ - /* help, stop, again, props, undo, front, copy */ - 0x68, 0x5e, 0x5f, 0x60, 0x61, 0x62, 0x63, - /* open, paste, find, cut, audiomute, audiolower, audioraise */ - 0x64, 0x65, 0x66, 0x67, 0x25, 0x1f, 0x1e, - /* power */ - 0x20 - }; - int scancode; - - scancode = keycode; - if ((keycode >= 89) && (keycode < 89 + nitems(scan))) - scancode = scan[keycode - 89] | SCAN_PREFIX_E0; - /* pause/break */ - if ((keycode == 104) && !(shift & CTLS)) - scancode = 0x45 | SCAN_PREFIX_E1 | SCAN_PREFIX_CTL; - if (shift & SHIFTS) - scancode &= ~SCAN_PREFIX_SHIFT; - return (scancode | (up ? SCAN_RELEASE : SCAN_PRESS)); -} -#endif diff --git a/sys/dev/uart/uart_kbd_sun.h b/sys/dev/uart/uart_kbd_sun.h deleted file mode 100644 index 05a4597930f9..000000000000 --- a/sys/dev/uart/uart_kbd_sun.h +++ /dev/null @@ -1,70 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-4-Clause - * - * Copyright (c) 2002 Jason L. Wright (jason@thought.net) - * 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. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Jason L. Wright - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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. - * - * Effort sponsored in part by the Defense Advanced Research Projects - * Agency (DARPA) and Air Force Research Laboratory, Air Force - * Materiel Command, USAF, under agreement number F30602-01-2-0537. - * - * $FreeBSD$ - */ - -/* keyboard commands (host->kbd) */ -#define SKBD_CMD_RESET 0x01 -#define SKBD_CMD_BELLON 0x02 -#define SKBD_CMD_BELLOFF 0x03 -#define SKBD_CMD_CLICKON 0x0a -#define SKBD_CMD_CLICKOFF 0x0b -#define SKBD_CMD_SETLED 0x0e -#define SKBD_CMD_LAYOUT 0x0f - -/* keyboard responses (kbd->host) */ -#define SKBD_RSP_RESET_OK 0x04 /* normal reset status for type 4/5/6 */ -#define SKBD_RSP_IDLE 0x7f /* no keys down */ -#define SKBD_RSP_LAYOUT 0xfe /* layout follows */ -#define SKBD_RSP_RESET 0xff /* reset status follows */ - -#define SKBD_LED_NUMLOCK 0x01 -#define SKBD_LED_COMPOSE 0x02 -#define SKBD_LED_SCROLLLOCK 0x04 -#define SKBD_LED_CAPSLOCK 0x08 - -#define SKBD_STATE_RESET 0 -#define SKBD_STATE_LAYOUT 1 -#define SKBD_STATE_GETKEY 2 - -/* keyboard types */ -#define KB_SUN2 2 /* type 2 keyboard */ -#define KB_SUN3 3 /* type 3 keyboard */ -#define KB_SUN4 4 /* type 4/5/6 keyboard */ - -#define SKBD_KEY_RELEASE 0x80 -#define SKBD_KEY_CHAR(c) ((c) & 0x7f) diff --git a/sys/dev/uart/uart_kbd_sun_tables.h b/sys/dev/uart/uart_kbd_sun_tables.h deleted file mode 100644 index e7dc61205104..000000000000 --- a/sys/dev/uart/uart_kbd_sun_tables.h +++ /dev/null @@ -1,144 +0,0 @@ -/* - * Automatically generated from sun.us.unix.kbd. - * DO NOT EDIT! - * - * $FreeBSD$ - */ -static keymap_t keymap_sun_us_unix_kbd = { 0x80, { -/* alt - * scan cntrl alt alt cntrl - * code base shift cntrl shift alt shift cntrl shift spcl flgs - * --------------------------------------------------------------------------- - */ -/*00*/{{ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, }, 0xFF,0x00 }, -/*01*/{{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }, 0x00,0x00 }, -/*02*/{{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }, 0x00,0x00 }, -/*03*/{{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }, 0x00,0x00 }, -/*04*/{{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }, 0x00,0x00 }, -/*05*/{{ F( 1), F(13), F(25), F(37), S( 1), S(11), S( 1), S(11),}, 0xFF,0x00 }, -/*06*/{{ F( 2), F(14), F(26), F(38), S( 2), S(12), S( 2), S(12),}, 0xFF,0x00 }, -/*07*/{{ F(10), F(22), F(34), F(46), S(10), S(10), S(10), S(10),}, 0xFF,0x00 }, -/*08*/{{ F( 3), F(15), F(27), F(39), S( 3), S(13), S( 3), S(13),}, 0xFF,0x00 }, -/*09*/{{ F(11), F(23), F(35), F(47), S(11), S(11), S(11), S(11),}, 0xFF,0x00 }, -/*0a*/{{ F( 4), F(16), F(28), F(40), S( 4), S(14), S( 4), S(14),}, 0xFF,0x00 }, -/*0b*/{{ F(12), F(24), F(36), F(48), S(12), S(12), S(12), S(12),}, 0xFF,0x00 }, -/*0c*/{{ F( 5), F(17), F(29), F(41), S( 5), S(15), S( 5), S(15),}, 0xFF,0x00 }, -/*0d*/{{ RALT, RALT, RALT, RALT, RALT, RALT, RALT, RALT, }, 0xFF,0x00 }, -/*0e*/{{ F( 6), F(18), F(30), F(42), S( 6), S(16), S( 6), S(16),}, 0xFF,0x00 }, -/*0f*/{{ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, }, 0xFF,0x00 }, -/*10*/{{ F( 7), F(19), F(31), F(43), S( 7), S( 7), S( 7), S( 7),}, 0xFF,0x00 }, -/*11*/{{ F( 8), F(20), F(32), F(44), S( 8), S( 8), S( 8), S( 8),}, 0xFF,0x00 }, -/*12*/{{ F( 9), F(21), F(33), F(45), S( 9), S( 9), S( 9), S( 9),}, 0xFF,0x00 }, -/*13*/{{ LALT, LALT, LALT, LALT, LALT, LALT, LALT, LALT, }, 0xFF,0x00 }, -/*14*/{{ F(50), F(50), F(50), F(50), F(50), F(50), F(50), F(50),}, 0xFF,0x00 }, -/*15*/{{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }, 0x00,0x00 }, -/*16*/{{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }, 0x00,0x00 }, -/*17*/{{ SLK, SPSC, SLK, SPSC, SUSP, NOP, SUSP, NOP, }, 0xFF,0x00 }, -/*18*/{{ F(53), F(53), F(53), F(53), F(53), F(53), F(53), F(53),}, 0xFF,0x00 }, -/*19*/{{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }, 0x00,0x00 }, -/*1a*/{{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }, 0x00,0x00 }, -/*1b*/{{ F(58), F(58), F(58), F(58), F(58), F(58), F(58), F(58),}, 0xFF,0x00 }, -/*1c*/{{ F(55), F(55), F(55), F(55), F(55), F(55), F(55), F(55),}, 0xFF,0x00 }, -/*1d*/{{ 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, DBG, 0x1B, }, 0x02,0x00 }, -/*1e*/{{ '1', '!', NOP, NOP, '1', '!', NOP, NOP, }, 0x33,0x00 }, -/*1f*/{{ '2', '@', 0x00, 0x00, '2', '@', 0x00, 0x00, }, 0x00,0x00 }, -/*20*/{{ '3', '#', NOP, NOP, '3', '#', NOP, NOP, }, 0x33,0x00 }, -/*21*/{{ '4', '$', NOP, NOP, '4', '$', NOP, NOP, }, 0x33,0x00 }, -/*22*/{{ '5', '%', NOP, NOP, '5', '%', NOP, NOP, }, 0x33,0x00 }, -/*23*/{{ '6', '^', 0x1E, 0x1E, '6', '^', 0x1E, 0x1E, }, 0x00,0x00 }, -/*24*/{{ '7', '&', NOP, NOP, '7', '&', NOP, NOP, }, 0x33,0x00 }, -/*25*/{{ '8', '*', NOP, NOP, '8', '*', NOP, NOP, }, 0x33,0x00 }, -/*26*/{{ '9', '(', NOP, NOP, '9', '(', NOP, NOP, }, 0x33,0x00 }, -/*27*/{{ '0', ')', NOP, NOP, '0', ')', NOP, NOP, }, 0x33,0x00 }, -/*28*/{{ '-', '_', 0x1F, 0x1F, '-', '_', 0x1F, 0x1F, }, 0x00,0x00 }, -/*29*/{{ '=', '+', NOP, NOP, '=', '+', NOP, NOP, }, 0x33,0x00 }, -/*2a*/{{ '`', '~', NOP, NOP, '`', '~', DBG, NOP, }, 0x33,0x00 }, -/*2b*/{{ 0x7F, 0x7F, 0x08, 0x08, 0x7F, 0x7F, 0x08, 0x08, }, 0x00,0x00 }, -/*2c*/{{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }, 0x00,0x00 }, -/*2d*/{{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }, 0x00,0x00 }, -/*2e*/{{ '/', '/', '/', '/', '/', '/', '/', '/', }, 0x00,0x02 }, -/*2f*/{{ '*', '*', '*', '*', '*', '*', '*', '*', }, 0x00,0x00 }, -/*30*/{{ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, }, 0xFF,0x00 }, -/*31*/{{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }, 0x00,0x00 }, -/*32*/{{ 0x08, '.', '.', '.', '.', '.', RBT, RBT, }, 0x03,0x02 }, -/*33*/{{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }, 0x00,0x00 }, -/*34*/{{ F(49), F(49), F(49), F(49), F(49), F(49), F(49), F(49),}, 0xFF,0x00 }, -/*35*/{{ 0x09, BTAB, NOP, NOP, 0x09, BTAB, NOP, NOP, }, 0x77,0x00 }, -/*36*/{{ 'q', 'Q', 0x11, 0x11, 'q', 'Q', 0x11, 0x11, }, 0x00,0x01 }, -/*37*/{{ 'w', 'W', 0x17, 0x17, 'w', 'W', 0x17, 0x17, }, 0x00,0x01 }, -/*38*/{{ 'e', 'E', 0x05, 0x05, 'e', 'E', 0x05, 0x05, }, 0x00,0x01 }, -/*39*/{{ 'r', 'R', 0x12, 0x12, 'r', 'R', 0x12, 0x12, }, 0x00,0x01 }, -/*3a*/{{ 't', 'T', 0x14, 0x14, 't', 'T', 0x14, 0x14, }, 0x00,0x01 }, -/*3b*/{{ 'y', 'Y', 0x19, 0x19, 'y', 'Y', 0x19, 0x19, }, 0x00,0x01 }, -/*3c*/{{ 'u', 'U', 0x15, 0x15, 'u', 'U', 0x15, 0x15, }, 0x00,0x01 }, -/*3d*/{{ 'i', 'I', 0x09, 0x09, 'i', 'I', 0x09, 0x09, }, 0x00,0x01 }, -/*3e*/{{ 'o', 'O', 0x0F, 0x0F, 'o', 'O', 0x0F, 0x0F, }, 0x00,0x01 }, -/*3f*/{{ 'p', 'P', 0x10, 0x10, 'p', 'P', 0x10, 0x10, }, 0x00,0x01 }, -/*40*/{{ '[', '{', 0x1B, 0x1B, '[', '{', 0x1B, 0x1B, }, 0x00,0x00 }, -/*41*/{{ ']', '}', 0x1D, 0x1D, ']', '}', 0x1D, 0x1D, }, 0x00,0x00 }, -/*42*/{{ 0x7F, 0x7F, 0x08, 0x08, 0x7F, 0x7F, 0x08, 0x08, }, 0x00,0x00 }, -/*43*/{{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }, 0x00,0x00 }, -/*44*/{{ F(49), '7', '7', '7', '7', '7', '7', '7', }, 0x80,0x02 }, -/*45*/{{ F(50), '8', '8', '8', '8', '8', '8', '8', }, 0x80,0x02 }, -/*46*/{{ F(51), '9', '9', '9', '9', '9', '9', '9', }, 0x80,0x02 }, -/*47*/{{ F(52), '-', '-', '-', '-', '-', '-', '-', }, 0x80,0x02 }, -/*48*/{{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }, 0x00,0x00 }, -/*49*/{{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }, 0x00,0x00 }, -/*4a*/{{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }, 0x00,0x00 }, -/*4b*/{{ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, }, 0xFF,0x00 }, -/*4c*/{{ LCTR, LCTR, LCTR, LCTR, LCTR, LCTR, LCTR, LCTR, }, 0xFF,0x00 }, -/*4d*/{{ 'a', 'A', 0x01, 0x01, 'a', 'A', 0x01, 0x01, }, 0x00,0x01 }, -/*4e*/{{ 's', 'S', 0x13, 0x13, 's', 'S', 0x13, 0x13, }, 0x00,0x01 }, -/*4f*/{{ 'd', 'D', 0x04, 0x04, 'd', 'D', 0x04, 0x04, }, 0x00,0x01 }, -/*50*/{{ 'f', 'F', 0x06, 0x06, 'f', 'F', 0x06, 0x06, }, 0x00,0x01 }, -/*51*/{{ 'g', 'G', 0x07, 0x07, 'g', 'G', 0x07, 0x07, }, 0x00,0x01 }, -/*52*/{{ 'h', 'H', 0x08, 0x08, 'h', 'H', 0x08, 0x08, }, 0x00,0x01 }, -/*53*/{{ 'j', 'J', 0x0A, 0x0A, 'j', 'J', 0x0A, 0x0A, }, 0x00,0x01 }, -/*54*/{{ 'k', 'K', 0x0B, 0x0B, 'k', 'K', 0x0B, 0x0B, }, 0x00,0x01 }, -/*55*/{{ 'l', 'L', 0x0C, 0x0C, 'l', 'L', 0x0C, 0x0C, }, 0x00,0x01 }, -/*56*/{{ ';', ':', NOP, NOP, ';', ':', NOP, NOP, }, 0x33,0x00 }, -/*57*/{{ '\'', '"', NOP, NOP, '\'', '"', NOP, NOP, }, 0x33,0x00 }, -/*58*/{{ '\\', '|', 0x1C, 0x1C, '\\', '|', 0x1C, 0x1C, }, 0x00,0x00 }, -/*59*/{{ 0x0D, 0x0D, 0x0A, 0x0A, 0x0D, 0x0D, 0x0A, 0x0A, }, 0x00,0x00 }, -/*5a*/{{ 0x0D, 0x0D, 0x0A, 0x0A, 0x0D, 0x0D, 0x0A, 0x0A, }, 0x00,0x00 }, -/*5b*/{{ F(53), '4', '4', '4', '4', '4', '4', '4', }, 0x80,0x02 }, -/*5c*/{{ F(54), '5', '5', '5', '5', '5', '5', '5', }, 0x80,0x02 }, -/*5d*/{{ F(55), '6', '6', '6', '6', '6', '6', '6', }, 0x80,0x02 }, -/*5e*/{{ F(60), '0', '0', '0', '0', '0', '0', '0', }, 0x80,0x02 }, -/*5f*/{{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }, 0x00,0x00 }, -/*60*/{{ F(51), F(51), F(51), F(51), F(51), F(51), F(51), F(51),}, 0xFF,0x00 }, -/*61*/{{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }, 0x00,0x00 }, -/*62*/{{ NLK, NLK, NLK, NLK, NLK, NLK, NLK, NLK, }, 0xFF,0x00 }, -/*63*/{{ LSH, LSH, LSH, LSH, LSH, LSH, LSH, LSH, }, 0xFF,0x00 }, -/*64*/{{ 'z', 'Z', 0x1A, 0x1A, 'z', 'Z', 0x1A, 0x1A, }, 0x00,0x01 }, -/*65*/{{ 'x', 'X', 0x18, 0x18, 'x', 'X', 0x18, 0x18, }, 0x00,0x01 }, -/*66*/{{ 'c', 'C', 0x03, 0x03, 'c', 'C', 0x03, 0x03, }, 0x00,0x01 }, -/*67*/{{ 'v', 'V', 0x16, 0x16, 'v', 'V', 0x16, 0x16, }, 0x00,0x01 }, -/*68*/{{ 'b', 'B', 0x02, 0x02, 'b', 'B', 0x02, 0x02, }, 0x00,0x01 }, -/*69*/{{ 'n', 'N', 0x0E, 0x0E, 'n', 'N', 0x0E, 0x0E, }, 0x00,0x01 }, -/*6a*/{{ 'm', 'M', 0x0D, 0x0D, 'm', 'M', 0x0D, 0x0D, }, 0x00,0x01 }, -/*6b*/{{ ',', '<', NOP, NOP, ',', '<', NOP, NOP, }, 0x33,0x00 }, -/*6c*/{{ '.', '>', NOP, NOP, '.', '>', NOP, NOP, }, 0x33,0x00 }, -/*6d*/{{ '/', '?', NOP, NOP, '/', '?', NOP, NOP, }, 0x33,0x00 }, -/*6e*/{{ RSH, RSH, RSH, RSH, RSH, RSH, RSH, RSH, }, 0xFF,0x00 }, -/*6f*/{{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }, 0x00,0x00 }, -/*70*/{{ F(57), '1', '1', '1', '1', '1', '1', '1', }, 0x80,0x02 }, -/*71*/{{ F(58), '2', '2', '2', '2', '2', '2', '2', }, 0x80,0x02 }, -/*72*/{{ F(59), '3', '3', '3', '3', '3', '3', '3', }, 0x80,0x02 }, -/*73*/{{ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, }, 0xFF,0x00 }, -/*74*/{{ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, }, 0xFF,0x00 }, -/*75*/{{ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, }, 0xFF,0x00 }, -/*76*/{{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }, 0x00,0x00 }, -/*77*/{{ CLK, CLK, CLK, CLK, CLK, CLK, CLK, CLK, }, 0xFF,0x00 }, -/*78*/{{ META, META, META, META, META, META, META, META, }, 0xFF,0x00 }, -/*79*/{{ ' ', ' ', 0x00, ' ', ' ', ' ', SUSP, ' ', }, 0x02,0x00 }, -/*7a*/{{ META, META, META, META, META, META, META, META, }, 0xFF,0x00 }, -/*7b*/{{ F(59), F(59), F(59), F(59), F(59), F(59), F(59), F(59),}, 0xFF,0x00 }, -/*7c*/{{ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, }, 0xFF,0x00 }, -/*7d*/{{ F(56), '+', '+', '+', '+', '+', '+', '+', }, 0x80,0x02 }, -/*7e*/{{ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, }, 0xFF,0x00 }, -/*7f*/{{ NOP, NOP, NOP, NOP, NOP, NOP, NOP, NOP, }, 0xFF,0x00 }, -} }; - -static accentmap_t accentmap_sun_us_unix_kbd = { 0 }; - diff --git a/sys/dev/virtio/block/virtio_blk.c b/sys/dev/virtio/block/virtio_blk.c index c36271d47f97..94ad4196155f 100644 --- a/sys/dev/virtio/block/virtio_blk.c +++ b/sys/dev/virtio/block/virtio_blk.c @@ -549,6 +549,12 @@ vtblk_strategy(struct bio *bp) return; } + if ((bp->bio_cmd != BIO_READ) && (bp->bio_cmd != BIO_WRITE) && + (bp->bio_cmd != BIO_FLUSH)) { + vtblk_bio_done(sc, bp, EOPNOTSUPP); + return; + } + VTBLK_LOCK(sc); if (sc->vtblk_flags & VTBLK_FLAG_DETACH) { diff --git a/sys/dev/virtio/pci/virtio_pci.c b/sys/dev/virtio/pci/virtio_pci.c index d63a3ddedb66..aba35eb38ff5 100644 --- a/sys/dev/virtio/pci/virtio_pci.c +++ b/sys/dev/virtio/pci/virtio_pci.c @@ -37,6 +37,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include @@ -184,6 +185,17 @@ static void vtpci_config_intr(void *); #define vtpci_write_config_2(sc, o, v) bus_write_2((sc)->vtpci_res, (o), (v)) #define vtpci_write_config_4(sc, o, v) bus_write_4((sc)->vtpci_res, (o), (v)) +/* + * Legacy VirtIO header is always PCI endianness (little), so if we + * are in a BE machine we need to swap bytes from LE to BE when reading + * and from BE to LE when writing. + * If we are in a LE machine, there will be no swaps. + */ +#define vtpci_read_header_2(sc, o) le16toh(vtpci_read_config_2(sc, o)) +#define vtpci_read_header_4(sc, o) le32toh(vtpci_read_config_4(sc, o)) +#define vtpci_write_header_2(sc, o, v) vtpci_write_config_2(sc, o, (htole16(v))) +#define vtpci_write_header_4(sc, o, v) vtpci_write_config_4(sc, o, (htole32(v))) + /* Tunables. */ static int vtpci_disable_msix = 0; TUNABLE_INT("hw.virtio.pci.disable_msix", &vtpci_disable_msix); @@ -278,6 +290,17 @@ vtpci_attach(device_t dev) return (ENXIO); } +/* + * For legacy VirtIO, the device-specific configuration is guest + * endian, while the common configuration header is always + * PCI (little) endian and will be handled specifically in + * other parts of this file via functions + * 'vtpci_[read|write]_header_[2|4]' + */ +#if _BYTE_ORDER == _BIG_ENDIAN + rman_set_bustag(sc->vtpci_res, &bs_be_tag); +#endif + if (pci_find_cap(dev, PCIY_MSI, NULL) != 0) sc->vtpci_flags |= VTPCI_FLAG_NO_MSI; @@ -447,7 +470,7 @@ vtpci_negotiate_features(device_t dev, uint64_t child_features) sc = device_get_softc(dev); - host_features = vtpci_read_config_4(sc, VIRTIO_PCI_HOST_FEATURES); + host_features = vtpci_read_header_4(sc, VIRTIO_PCI_HOST_FEATURES); vtpci_describe_features(sc, "host", host_features); /* @@ -459,7 +482,7 @@ vtpci_negotiate_features(device_t dev, uint64_t child_features) sc->vtpci_features = features; vtpci_describe_features(sc, "negotiated", features); - vtpci_write_config_4(sc, VIRTIO_PCI_GUEST_FEATURES, features); + vtpci_write_header_4(sc, VIRTIO_PCI_GUEST_FEATURES, features); return (features); } @@ -502,7 +525,7 @@ vtpci_alloc_virtqueues(device_t dev, int flags, int nvqs, info = &vq_info[idx]; vtpci_select_virtqueue(sc, idx); - size = vtpci_read_config_2(sc, VIRTIO_PCI_QUEUE_NUM); + size = vtpci_read_header_2(sc, VIRTIO_PCI_QUEUE_NUM); error = virtqueue_alloc(dev, idx, size, VIRTIO_PCI_VRING_ALIGN, ~(vm_paddr_t)0, info, &vq); @@ -512,7 +535,7 @@ vtpci_alloc_virtqueues(device_t dev, int flags, int nvqs, break; } - vtpci_write_config_4(sc, VIRTIO_PCI_QUEUE_PFN, + vtpci_write_header_4(sc, VIRTIO_PCI_QUEUE_PFN, virtqueue_paddr(vq) >> VIRTIO_PCI_QUEUE_ADDR_SHIFT); vqx->vtv_vq = *info->vqai_vq = vq; @@ -646,7 +669,7 @@ vtpci_notify_virtqueue(device_t dev, uint16_t queue) sc = device_get_softc(dev); - vtpci_write_config_2(sc, VIRTIO_PCI_QUEUE_NOTIFY, queue); + vtpci_write_header_2(sc, VIRTIO_PCI_QUEUE_NOTIFY, queue); } static uint8_t @@ -1046,10 +1069,10 @@ vtpci_register_msix_vector(struct vtpci_softc *sc, int offset, } else vector = VIRTIO_MSI_NO_VECTOR; - vtpci_write_config_2(sc, offset, vector); + vtpci_write_header_2(sc, offset, vector); /* Read vector to determine if the host had sufficient resources. */ - if (vtpci_read_config_2(sc, offset) != vector) { + if (vtpci_read_header_2(sc, offset) != vector) { device_printf(dev, "insufficient host resources for MSIX interrupts\n"); return (ENODEV); @@ -1112,13 +1135,13 @@ vtpci_reinit_virtqueue(struct vtpci_softc *sc, int idx) KASSERT(vq != NULL, ("%s: vq %d not allocated", __func__, idx)); vtpci_select_virtqueue(sc, idx); - size = vtpci_read_config_2(sc, VIRTIO_PCI_QUEUE_NUM); + size = vtpci_read_header_2(sc, VIRTIO_PCI_QUEUE_NUM); error = virtqueue_reinit(vq, size); if (error) return (error); - vtpci_write_config_4(sc, VIRTIO_PCI_QUEUE_PFN, + vtpci_write_header_4(sc, VIRTIO_PCI_QUEUE_PFN, virtqueue_paddr(vq) >> VIRTIO_PCI_QUEUE_ADDR_SHIFT); return (0); @@ -1182,7 +1205,7 @@ vtpci_free_virtqueues(struct vtpci_softc *sc) vqx = &sc->vtpci_vqs[idx]; vtpci_select_virtqueue(sc, idx); - vtpci_write_config_4(sc, VIRTIO_PCI_QUEUE_PFN, 0); + vtpci_write_header_4(sc, VIRTIO_PCI_QUEUE_PFN, 0); virtqueue_free(vqx->vtv_vq); vqx->vtv_vq = NULL; @@ -1207,12 +1230,12 @@ vtpci_cleanup_setup_intr_attempt(struct vtpci_softc *sc) int idx; if (sc->vtpci_flags & VTPCI_FLAG_MSIX) { - vtpci_write_config_2(sc, VIRTIO_MSI_CONFIG_VECTOR, + vtpci_write_header_2(sc, VIRTIO_MSI_CONFIG_VECTOR, VIRTIO_MSI_NO_VECTOR); for (idx = 0; idx < sc->vtpci_nvqs; idx++) { vtpci_select_virtqueue(sc, idx); - vtpci_write_config_2(sc, VIRTIO_MSI_QUEUE_VECTOR, + vtpci_write_header_2(sc, VIRTIO_MSI_QUEUE_VECTOR, VIRTIO_MSI_NO_VECTOR); } } @@ -1235,7 +1258,7 @@ static void vtpci_select_virtqueue(struct vtpci_softc *sc, int idx) { - vtpci_write_config_2(sc, VIRTIO_PCI_QUEUE_SEL, idx); + vtpci_write_header_2(sc, VIRTIO_PCI_QUEUE_SEL, idx); } static void diff --git a/sys/dev/vt/hw/fb/vt_early_fb.c b/sys/dev/vt/hw/fb/vt_early_fb.c index e538ace2c052..12db4368d919 100644 --- a/sys/dev/vt/hw/fb/vt_early_fb.c +++ b/sys/dev/vt/hw/fb/vt_early_fb.c @@ -233,10 +233,6 @@ vt_efb_init(struct vt_device *vd) sc->sc_memt = &bs_be_tag; bus_space_map(sc->sc_memt, info->fb_pbase, info->fb_size, BUS_SPACE_MAP_PREFETCHABLE, &info->fb_vbase); - #elif defined(__sparc64__) - OF_decode_addr(node, 0, &space, &phys); - sc->sc_memt = &vt_efb_memt[0]; - info->addr = sparc64_fake_bustag(space, fb_phys, sc->sc_memt); #else bus_space_map(fdtbus_bs_tag, info->fb_pbase, info->fb_size, BUS_SPACE_MAP_PREFETCHABLE, @@ -274,11 +270,6 @@ vt_efb_init(struct vt_device *vd) #if defined(__powerpc__) OF_decode_addr(node, info->fb_pbase, &sc->sc_memt, &info->fb_vbase); - #elif defined(__sparc64__) - OF_decode_addr(node, info->fb_pbase, &space, &info->fb_pbase); - sc->sc_memt = &vt_efb_memt[0]; - info->fb_vbase = sparc64_fake_bustag(space, info->fb_pbase, - sc->sc_memt); #else bus_space_map(fdtbus_bs_tag, info->fb_pbase, info->fb_size, BUS_SPACE_MAP_PREFETCHABLE, diff --git a/sys/dev/vt/hw/ofwfb/ofwfb.c b/sys/dev/vt/hw/ofwfb/ofwfb.c index 77e1ac687314..01f5339fe212 100644 --- a/sys/dev/vt/hw/ofwfb/ofwfb.c +++ b/sys/dev/vt/hw/ofwfb/ofwfb.c @@ -42,9 +42,6 @@ __FBSDID("$FreeBSD$"); #include #include -#ifdef __sparc64__ -#include -#endif #include #include @@ -366,11 +363,6 @@ ofwfb_init(struct vt_device *vd) uint32_t depth, height, width, stride; uint32_t fb_phys; int i, len; -#ifdef __sparc64__ - static struct bus_space_tag ofwfb_memt[1]; - bus_addr_t phys; - int space; -#endif /* Initialize softc */ vd->vd_softc = sc = &ofwfb_conssoftc; @@ -445,11 +437,6 @@ ofwfb_init(struct vt_device *vd) sc->sc_memt = &bs_be_tag; bus_space_map(sc->sc_memt, fb_phys, sc->fb.fb_size, BUS_SPACE_MAP_PREFETCHABLE, &sc->fb.fb_vbase); - #elif defined(__sparc64__) - OF_decode_addr(node, 0, &space, &phys); - sc->sc_memt = &ofwfb_memt[0]; - sc->fb.fb_vbase = - sparc64_fake_bustag(space, fb_phys, sc->sc_memt); #elif defined(__arm__) sc->sc_memt = fdtbus_bs_tag; bus_space_map(sc->sc_memt, sc->fb.fb_pbase, sc->fb.fb_size, diff --git a/sys/dev/xdma/xdma.c b/sys/dev/xdma/xdma.c index d88cb1306536..aa6e6497a34c 100644 --- a/sys/dev/xdma/xdma.c +++ b/sys/dev/xdma/xdma.c @@ -510,6 +510,24 @@ xdma_ofw_get(device_t dev, const char *prop) } #endif +/* + * Allocate xdma controller. + */ +xdma_controller_t * +xdma_get(device_t dev, device_t dma_dev) +{ + xdma_controller_t *xdma; + + xdma = malloc(sizeof(struct xdma_controller), + M_XDMA, M_WAITOK | M_ZERO); + xdma->dev = dev; + xdma->dma_dev = dma_dev; + + TAILQ_INIT(&xdma->channels); + + return (xdma); +} + /* * Free xDMA controller object. */ diff --git a/sys/dev/xdma/xdma.h b/sys/dev/xdma/xdma.h index 48a03c125b3a..b9a8dd2c37c3 100644 --- a/sys/dev/xdma/xdma.h +++ b/sys/dev/xdma/xdma.h @@ -231,6 +231,7 @@ static MALLOC_DEFINE(M_XDMA, "xdma", "xDMA framework"); /* xDMA controller ops */ xdma_controller_t *xdma_ofw_get(device_t dev, const char *prop); +xdma_controller_t *xdma_get(device_t dev, device_t dma_dev); int xdma_put(xdma_controller_t *xdma); vmem_t * xdma_get_memory(device_t dev); void xdma_put_memory(vmem_t *vmem); diff --git a/sys/dev/xen/blkfront/blkfront.c b/sys/dev/xen/blkfront/blkfront.c index ae82f0cd022b..d20fc32e66b6 100644 --- a/sys/dev/xen/blkfront/blkfront.c +++ b/sys/dev/xen/blkfront/blkfront.c @@ -399,7 +399,9 @@ xbd_bio_command(struct xbd_softc *sc) panic("flush request, but no flush support available"); break; default: - panic("unknown bio command %d", bp->bio_cmd); + biofinish(bp, NULL, EOPNOTSUPP); + xbd_enqueue_cm(cm, XBD_Q_FREE); + return (NULL); } return (cm); diff --git a/sys/dev/xen/console/xen_console.c b/sys/dev/xen/console/xen_console.c index d7ffb591768e..7d10c1871e98 100644 --- a/sys/dev/xen/console/xen_console.c +++ b/sys/dev/xen/console/xen_console.c @@ -44,6 +44,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include @@ -590,7 +591,7 @@ xencons_cnprobe(struct consdev *cp) if (!xen_domain()) return; - cp->cn_pri = CN_REMOTE; + cp->cn_pri = (boothowto & RB_SERIAL) ? CN_REMOTE : CN_NORMAL; sprintf(cp->cn_name, "%s0", driver_name); } diff --git a/sys/dev/xilinx/axidma.c b/sys/dev/xilinx/axidma.c index 3c9b1b5c6dc7..32683de787d3 100644 --- a/sys/dev/xilinx/axidma.c +++ b/sys/dev/xilinx/axidma.c @@ -61,6 +61,15 @@ __FBSDID("$FreeBSD$"); #include "xdma_if.h" +#define READ4(_sc, _reg) \ + bus_space_read_4(_sc->bst, _sc->bsh, _reg) +#define WRITE4(_sc, _reg, _val) \ + bus_space_write_4(_sc->bst, _sc->bsh, _reg, _val) +#define READ8(_sc, _reg) \ + bus_space_read_8(_sc->bst, _sc->bsh, _reg) +#define WRITE8(_sc, _reg, _val) \ + bus_space_write_8(_sc->bst, _sc->bsh, _reg, _val) + #define AXIDMA_DEBUG #undef AXIDMA_DEBUG @@ -70,17 +79,8 @@ __FBSDID("$FreeBSD$"); #define dprintf(fmt, ...) #endif -#define AXIDMA_NCHANNELS 2 -#define AXIDMA_DESCS_NUM 512 -#define AXIDMA_TX_CHAN 0 -#define AXIDMA_RX_CHAN 1 - extern struct bus_space memmap_bus; -struct axidma_fdt_data { - int id; -}; - struct axidma_channel { struct axidma_softc *sc; xdma_channel_t *xchan; diff --git a/sys/dev/xilinx/axidma.h b/sys/dev/xilinx/axidma.h index 8e5d83874eee..addacb463d2a 100644 --- a/sys/dev/xilinx/axidma.h +++ b/sys/dev/xilinx/axidma.h @@ -60,14 +60,10 @@ #define AXI_TAILDESC_MSB(n) (0x14 + 0x30 * (n)) /* Tail Descriptor Pointer. Upper 32 bits of address. */ #define AXI_SG_CTL 0x2C /* Scatter/Gather User and Cache */ -#define READ4(_sc, _reg) \ - bus_space_read_4(_sc->bst, _sc->bsh, _reg) -#define WRITE4(_sc, _reg, _val) \ - bus_space_write_4(_sc->bst, _sc->bsh, _reg, _val) -#define READ8(_sc, _reg) \ - bus_space_read_8(_sc->bst, _sc->bsh, _reg) -#define WRITE8(_sc, _reg, _val) \ - bus_space_write_8(_sc->bst, _sc->bsh, _reg, _val) +#define AXIDMA_NCHANNELS 2 +#define AXIDMA_DESCS_NUM 512 +#define AXIDMA_TX_CHAN 0 +#define AXIDMA_RX_CHAN 1 struct axidma_desc { uint32_t next; @@ -93,4 +89,8 @@ struct axidma_desc { uint32_t reserved[3]; }; +struct axidma_fdt_data { + int id; +}; + #endif /* !_DEV_XILINX_AXIDMA_H_ */ diff --git a/sys/dev/xilinx/if_xae.c b/sys/dev/xilinx/if_xae.c index bde6470c4376..e6dbb15de75e 100644 --- a/sys/dev/xilinx/if_xae.c +++ b/sys/dev/xilinx/if_xae.c @@ -64,6 +64,8 @@ __FBSDID("$FreeBSD$"); #include #include +#include + #include "miibus_if.h" #define READ4(_sc, _reg) \ @@ -774,6 +776,68 @@ xae_phy_fixup(struct xae_softc *sc) } while ((PHY1_RD(sc, MII_BMSR) & BMSR_ACOMP) == 0); } +static int +get_xdma_std(struct xae_softc *sc) +{ + + sc->xdma_tx = xdma_ofw_get(sc->dev, "tx"); + if (sc->xdma_tx == NULL) + return (ENXIO); + + sc->xdma_rx = xdma_ofw_get(sc->dev, "rx"); + if (sc->xdma_rx == NULL) { + xdma_put(sc->xdma_tx); + return (ENXIO); + } + + return (0); +} + +static int +get_xdma_axistream(struct xae_softc *sc) +{ + struct axidma_fdt_data *data; + device_t dma_dev; + phandle_t node; + pcell_t prop; + size_t len; + + node = ofw_bus_get_node(sc->dev); + len = OF_getencprop(node, "axistream-connected", &prop, sizeof(prop)); + if (len != sizeof(prop)) { + device_printf(sc->dev, + "%s: Couldn't get axistream-connected prop.\n", __func__); + return (ENXIO); + } + dma_dev = OF_device_from_xref(prop); + if (dma_dev == NULL) { + device_printf(sc->dev, "Could not get DMA device by xref.\n"); + return (ENXIO); + } + + sc->xdma_tx = xdma_get(sc->dev, dma_dev); + if (sc->xdma_tx == NULL) { + device_printf(sc->dev, "Could not find DMA controller.\n"); + return (ENXIO); + } + data = malloc(sizeof(struct axidma_fdt_data), + M_DEVBUF, (M_WAITOK | M_ZERO)); + data->id = AXIDMA_TX_CHAN; + sc->xdma_tx->data = data; + + sc->xdma_rx = xdma_get(sc->dev, dma_dev); + if (sc->xdma_rx == NULL) { + device_printf(sc->dev, "Could not find DMA controller.\n"); + return (ENXIO); + } + data = malloc(sizeof(struct axidma_fdt_data), + M_DEVBUF, (M_WAITOK | M_ZERO)); + data->id = AXIDMA_RX_CHAN; + sc->xdma_rx->data = data; + + return (0); +} + static int setup_xdma(struct xae_softc *sc) { @@ -784,15 +848,16 @@ setup_xdma(struct xae_softc *sc) dev = sc->dev; /* Get xDMA controller */ - sc->xdma_tx = xdma_ofw_get(sc->dev, "tx"); - if (sc->xdma_tx == NULL) { - device_printf(dev, "Could not find DMA controller.\n"); - return (ENXIO); + error = get_xdma_std(sc); + + if (error) { + device_printf(sc->dev, + "Fallback to axistream-connected property\n"); + error = get_xdma_axistream(sc); } - sc->xdma_rx = xdma_ofw_get(sc->dev, "rx"); - if (sc->xdma_rx == NULL) { - device_printf(dev, "Could not find DMA controller.\n"); + if (error) { + device_printf(dev, "Could not find xDMA controllers.\n"); return (ENXIO); } diff --git a/sys/fs/devfs/devfs_vnops.c b/sys/fs/devfs/devfs_vnops.c index 8f60bfc414c3..f038f74e67a0 100644 --- a/sys/fs/devfs/devfs_vnops.c +++ b/sys/fs/devfs/devfs_vnops.c @@ -479,8 +479,7 @@ devfs_allocv(struct devfs_dirent *de, struct mount *mp, int lockmode, dev_refl(dev); /* XXX: v_rdev should be protect by vnode lock */ vp->v_rdev = dev; - KASSERT(vp->v_usecount == 1, - ("%s %d (%d)\n", __func__, __LINE__, vp->v_usecount)); + VNPASS(vp->v_usecount == 1, vp); dev->si_usecount++; /* Special casing of ttys for deadfs. Probably redundant. */ dsw = dev->si_devsw; @@ -946,8 +945,8 @@ devfs_lookupx(struct vop_lookup_args *ap, int *dm_unlock) if ((flags & ISDOTDOT) && (dvp->v_vflag & VV_ROOT)) return (EIO); - error = VOP_ACCESS(dvp, VEXEC, cnp->cn_cred, td); - if (error) + error = vn_dir_check_exec(dvp, cnp); + if (error != 0) return (error); if (cnp->cn_namelen == 1 && *pname == '.') { diff --git a/sys/fs/fuse/fuse_vnops.c b/sys/fs/fuse/fuse_vnops.c index f1b0fcbe7bdf..05431a770657 100644 --- a/sys/fs/fuse/fuse_vnops.c +++ b/sys/fs/fuse/fuse_vnops.c @@ -1006,7 +1006,9 @@ fuse_vnop_lookup(struct vop_lookup_args *ap) if (islastcn && vfs_isrdonly(mp) && (nameiop != LOOKUP)) return EROFS; - if ((err = fuse_internal_access(dvp, VEXEC, td, cred))) + if ((cnp->cn_flags & NOEXECCHECK) != 0) + cnp->cn_flags &= ~NOEXECCHECK; + else if ((err = fuse_internal_access(dvp, VEXEC, td, cred))) return err; if (flags & ISDOTDOT) { diff --git a/sys/fs/nfsclient/nfs_clvnops.c b/sys/fs/nfsclient/nfs_clvnops.c index 63b1ab76975b..9c929e9af3b5 100644 --- a/sys/fs/nfsclient/nfs_clvnops.c +++ b/sys/fs/nfsclient/nfs_clvnops.c @@ -1195,7 +1195,8 @@ nfs_lookup(struct vop_lookup_args *ap) } NFSUNLOCKNODE(np); - if ((error = VOP_ACCESS(dvp, VEXEC, cnp->cn_cred, td)) != 0) + error = vn_dir_check_exec(dvp, cnp); + if (error != 0) return (error); error = cache_lookup(dvp, vpp, cnp, &nctime, &ncticks); if (error > 0 && error != ENOENT) diff --git a/sys/fs/nullfs/null_subr.c b/sys/fs/nullfs/null_subr.c index e0de5c8cc058..125b623cb638 100644 --- a/sys/fs/nullfs/null_subr.c +++ b/sys/fs/nullfs/null_subr.c @@ -209,7 +209,7 @@ null_nodeget(mp, lowervp, vpp) int error; ASSERT_VOP_LOCKED(lowervp, "lowervp"); - KASSERT(lowervp->v_usecount >= 1, ("Unreferenced vnode %p", lowervp)); + VNPASS(lowervp->v_usecount > 0, lowervp); /* Lookup the hash firstly. */ *vpp = null_hashget(mp, lowervp); diff --git a/sys/fs/pseudofs/pseudofs_vnops.c b/sys/fs/pseudofs/pseudofs_vnops.c index e019c7fd95cb..f4a0c3371088 100644 --- a/sys/fs/pseudofs/pseudofs_vnops.c +++ b/sys/fs/pseudofs/pseudofs_vnops.c @@ -466,10 +466,6 @@ pfs_lookup(struct vop_cachedlookup_args *va) PFS_RETURN (ENOTDIR); KASSERT_PN_IS_DIR(pd); - error = VOP_ACCESS(vn, VEXEC, cnp->cn_cred, cnp->cn_thread); - if (error) - PFS_RETURN (error); - /* * Don't support DELETE or RENAME. CREATE is supported so * that O_CREAT will work, but the lookup will still fail if diff --git a/sys/fs/smbfs/smbfs_vnops.c b/sys/fs/smbfs/smbfs_vnops.c index 3a0c207f685c..026fab8d000c 100644 --- a/sys/fs/smbfs/smbfs_vnops.c +++ b/sys/fs/smbfs/smbfs_vnops.c @@ -1199,7 +1199,8 @@ smbfs_lookup(ap) islastcn = flags & ISLASTCN; if (islastcn && (mp->mnt_flag & MNT_RDONLY) && (nameiop != LOOKUP)) return EROFS; - if ((error = VOP_ACCESS(dvp, VEXEC, cnp->cn_cred, td)) != 0) + error = vn_dir_check_exec(dvp, cnp); + if (error != 0) return error; smp = VFSTOSMBFS(mp); dnp = VTOSMB(dvp); diff --git a/sys/fs/tmpfs/tmpfs.h b/sys/fs/tmpfs/tmpfs.h index 4916be6c5f19..8b6ea0789b43 100644 --- a/sys/fs/tmpfs/tmpfs.h +++ b/sys/fs/tmpfs/tmpfs.h @@ -382,6 +382,8 @@ struct tmpfs_mount { bool tm_ronly; /* Do not use namecache. */ bool tm_nonc; + /* Do not update mtime on writes through mmaped areas. */ + bool tm_nomtime; }; #define TMPFS_LOCK(tm) mtx_lock(&(tm)->tm_allnode_lock) #define TMPFS_UNLOCK(tm) mtx_unlock(&(tm)->tm_allnode_lock) @@ -450,12 +452,17 @@ void tmpfs_itimes(struct vnode *, const struct timespec *, void tmpfs_set_status(struct tmpfs_mount *tm, struct tmpfs_node *node, int status); -void tmpfs_update(struct vnode *); int tmpfs_truncate(struct vnode *, off_t); struct tmpfs_dirent *tmpfs_dir_first(struct tmpfs_node *dnode, struct tmpfs_dir_cursor *dc); struct tmpfs_dirent *tmpfs_dir_next(struct tmpfs_node *dnode, struct tmpfs_dir_cursor *dc); +static __inline void +tmpfs_update(struct vnode *vp) +{ + + tmpfs_itimes(vp, NULL, NULL); +} /* * Convenience macros to simplify some logical expressions. @@ -534,6 +541,20 @@ tmpfs_use_nc(struct vnode *vp) return (!(VFS_TO_TMPFS(vp->v_mount)->tm_nonc)); } + +static inline void +tmpfs_update_getattr(struct vnode *vp) +{ + struct tmpfs_node *node; + int update_flags; + + update_flags = TMPFS_NODE_ACCESSED | TMPFS_NODE_MODIFIED | TMPFS_NODE_CHANGED; + + node = VP_TO_TMPFS_NODE(vp); + if (__predict_false(node->tn_status & update_flags) != 0) + tmpfs_update(vp); +} + #endif /* _KERNEL */ #endif /* _FS_TMPFS_TMPFS_H_ */ diff --git a/sys/fs/tmpfs/tmpfs_subr.c b/sys/fs/tmpfs/tmpfs_subr.c index e93c8f2192ed..e2440a405749 100644 --- a/sys/fs/tmpfs/tmpfs_subr.c +++ b/sys/fs/tmpfs/tmpfs_subr.c @@ -1889,13 +1889,6 @@ tmpfs_itimes(struct vnode *vp, const struct timespec *acc, random_harvest_queue(node, sizeof(*node), RANDOM_FS_ATIME); } -void -tmpfs_update(struct vnode *vp) -{ - - tmpfs_itimes(vp, NULL, NULL); -} - int tmpfs_truncate(struct vnode *vp, off_t length) { diff --git a/sys/fs/tmpfs/tmpfs_vfsops.c b/sys/fs/tmpfs/tmpfs_vfsops.c index d09a0ce81d31..2ce471d9917d 100644 --- a/sys/fs/tmpfs/tmpfs_vfsops.c +++ b/sys/fs/tmpfs/tmpfs_vfsops.c @@ -92,20 +92,19 @@ static void tmpfs_susp_clean(struct mount *); static const char *tmpfs_opts[] = { "from", "size", "maxfilesize", "inodes", "uid", "gid", "mode", "export", - "union", "nonc", NULL + "union", "nonc", "nomtime", NULL }; static const char *tmpfs_updateopts[] = { - "from", "export", "size", NULL + "from", "export", "nomtime", "size", NULL }; /* - * Handle updates of time from writes to mmaped regions. Use - * MNT_VNODE_FOREACH_ALL instead of MNT_VNODE_FOREACH_LAZY, since + * Handle updates of time from writes to mmaped regions, if allowed. + * Use MNT_VNODE_FOREACH_ALL instead of MNT_VNODE_FOREACH_LAZY, since * unmap of the tmpfs-backed vnode does not call vinactive(), due to - * vm object type is OBJT_SWAP. - * If lazy, only handle delayed update of mtime due to the writes to - * mapped files. + * vm object type is OBJT_SWAP. If lazy, only handle delayed update + * of mtime due to the writes to mapped files. */ static void tmpfs_update_mtime(struct mount *mp, bool lazy) @@ -113,6 +112,8 @@ tmpfs_update_mtime(struct mount *mp, bool lazy) struct vnode *vp, *mvp; struct vm_object *obj; + if (VFS_TO_TMPFS(mp)->tm_nomtime) + return; MNT_VNODE_FOREACH_ALL(vp, mp, mvp) { if (vp->v_type != VREG) { VI_UNLOCK(vp); @@ -327,7 +328,7 @@ tmpfs_mount(struct mount *mp) struct tmpfs_mount *tmp; struct tmpfs_node *root; int error; - bool nonc; + bool nomtime, nonc; /* Size counters. */ u_quad_t pages; off_t nodes_max, size_max, maxfilesize; @@ -346,6 +347,7 @@ tmpfs_mount(struct mount *mp) /* Only support update mounts for certain options. */ if (vfs_filteropt(mp->mnt_optnew, tmpfs_updateopts) != 0) return (EOPNOTSUPP); + tmp = VFS_TO_TMPFS(mp); if (vfs_getopt_size(mp->mnt_optnew, "size", &size_max) == 0) { /* * On-the-fly resizing is not supported (yet). We still @@ -354,21 +356,23 @@ tmpfs_mount(struct mount *mp) * parameter, say trying to change rw to ro or vice * versa, would cause vfs_filteropt() to bail. */ - if (size_max != VFS_TO_TMPFS(mp)->tm_size_max) + if (size_max != tmp->tm_size_max) return (EOPNOTSUPP); } if (vfs_flagopt(mp->mnt_optnew, "ro", NULL, 0) && - !(VFS_TO_TMPFS(mp)->tm_ronly)) { + !tmp->tm_ronly) { /* RW -> RO */ return (tmpfs_rw_to_ro(mp)); } else if (!vfs_flagopt(mp->mnt_optnew, "ro", NULL, 0) && - VFS_TO_TMPFS(mp)->tm_ronly) { + tmp->tm_ronly) { /* RO -> RW */ - VFS_TO_TMPFS(mp)->tm_ronly = 0; + tmp->tm_ronly = 0; MNT_ILOCK(mp); mp->mnt_flag &= ~MNT_RDONLY; MNT_IUNLOCK(mp); } + tmp->tm_nomtime = vfs_getopt(mp->mnt_optnew, "nomtime", NULL, + 0) == 0; return (0); } @@ -394,6 +398,7 @@ tmpfs_mount(struct mount *mp) if (vfs_getopt_size(mp->mnt_optnew, "maxfilesize", &maxfilesize) != 0) maxfilesize = 0; nonc = vfs_getopt(mp->mnt_optnew, "nonc", NULL, NULL) == 0; + nomtime = vfs_getopt(mp->mnt_optnew, "nomtime", NULL, NULL) == 0; /* Do not allow mounts if we do not have enough memory to preserve * the minimum reserved pages. */ @@ -440,6 +445,7 @@ tmpfs_mount(struct mount *mp) new_unrhdr64(&tmp->tm_ino_unr, 2); tmp->tm_ronly = (mp->mnt_flag & MNT_RDONLY) != 0; tmp->tm_nonc = nonc; + tmp->tm_nomtime = nomtime; /* Allocate the root node. */ error = tmpfs_alloc_node(mp, tmp, VDIR, root_uid, root_gid, diff --git a/sys/fs/tmpfs/tmpfs_vnops.c b/sys/fs/tmpfs/tmpfs_vnops.c index 570c33c33491..f881407c6485 100644 --- a/sys/fs/tmpfs/tmpfs_vnops.c +++ b/sys/fs/tmpfs/tmpfs_vnops.c @@ -90,7 +90,7 @@ tmpfs_lookup1(struct vnode *dvp, struct vnode **vpp, struct componentname *cnp) *vpp = NULLVP; /* Check accessibility of requested node as a first step. */ - error = VOP_ACCESS(dvp, VEXEC, cnp->cn_cred, cnp->cn_thread); + error = vn_dir_check_exec(dvp, cnp); if (error != 0) goto out; @@ -387,7 +387,7 @@ tmpfs_getattr(struct vop_getattr_args *v) node = VP_TO_TMPFS_NODE(vp); - tmpfs_update(vp); + tmpfs_update_getattr(vp); vap->va_type = vp->v_type; vap->va_mode = node->tn_mode; diff --git a/sys/geom/geom_vfs.c b/sys/geom/geom_vfs.c index b2ca996aa4a3..2136beb6573e 100644 --- a/sys/geom/geom_vfs.c +++ b/sys/geom/geom_vfs.c @@ -139,7 +139,7 @@ g_vfs_done(struct bio *bip) cp = bip->bio_from; sc = cp->geom->softc; - if (bip->bio_error) + if (bip->bio_error && bip->bio_error != EOPNOTSUPP) g_print_bio("g_vfs_done():", bip, "error = %d", bip->bio_error); bp->b_error = bip->bio_error; diff --git a/sys/i386/i386/pmap.c b/sys/i386/i386/pmap.c index 91d85943a2d1..a8e46c2967e9 100644 --- a/sys/i386/i386/pmap.c +++ b/sys/i386/i386/pmap.c @@ -1064,7 +1064,7 @@ __CONCAT(PMTYPE, init)(void) #ifdef PMAP_PAE_COMP pdptzone = uma_zcreate("PDPT", NPGPTD * sizeof(pdpt_entry_t), NULL, NULL, NULL, NULL, (NPGPTD * sizeof(pdpt_entry_t)) - 1, - UMA_ZONE_VM | UMA_ZONE_NOFREE); + UMA_ZONE_CONTIG | UMA_ZONE_VM | UMA_ZONE_NOFREE); uma_zone_set_allocf(pdptzone, pmap_pdpt_allocf); #endif diff --git a/sys/i386/include/param.h b/sys/i386/include/param.h index 7b1d05eebf15..260ef14c9431 100644 --- a/sys/i386/include/param.h +++ b/sys/i386/include/param.h @@ -58,13 +58,13 @@ #endif #define MID_MACHINE MID_I386 -#if defined(SMP) || defined(KLD_MODULE) +#ifdef SMP #ifndef MAXCPU #define MAXCPU 32 #endif #else #define MAXCPU 1 -#endif /* SMP || KLD_MODULE */ +#endif #ifndef MAXMEMDOM #define MAXMEMDOM 1 diff --git a/sys/i386/linux/linux_dummy.c b/sys/i386/linux/linux_dummy.c index 4951e5c414c0..6ce97bd16f55 100644 --- a/sys/i386/linux/linux_dummy.c +++ b/sys/i386/linux/linux_dummy.c @@ -75,7 +75,6 @@ DUMMY(quotactl); DUMMY(bdflush); DUMMY(sysfs); DUMMY(vm86); -DUMMY(sendfile); /* different semantics */ DUMMY(setfsuid); DUMMY(setfsgid); DUMMY(pivot_root); diff --git a/sys/i386/linux/linux_proto.h b/sys/i386/linux/linux_proto.h index 8c0e0348ccbd..180cc6791267 100644 --- a/sys/i386/linux/linux_proto.h +++ b/sys/i386/linux/linux_proto.h @@ -605,7 +605,10 @@ struct linux_sigaltstack_args { char uoss_l_[PADL_(l_stack_t *)]; l_stack_t * uoss; char uoss_r_[PADR_(l_stack_t *)]; }; struct linux_sendfile_args { - register_t dummy; + char out_l_[PADL_(l_int)]; l_int out; char out_r_[PADR_(l_int)]; + char in_l_[PADL_(l_int)]; l_int in; char in_r_[PADR_(l_int)]; + char offset_l_[PADL_(l_long *)]; l_long * offset; char offset_r_[PADR_(l_long *)]; + char count_l_[PADL_(l_size_t)]; l_size_t count; char count_r_[PADR_(l_size_t)]; }; struct linux_vfork_args { register_t dummy; @@ -734,6 +737,12 @@ struct linux_tkill_args { char tid_l_[PADL_(int)]; int tid; char tid_r_[PADR_(int)]; char sig_l_[PADL_(int)]; int sig; char sig_r_[PADR_(int)]; }; +struct linux_sendfile64_args { + char out_l_[PADL_(l_int)]; l_int out; char out_r_[PADR_(l_int)]; + char in_l_[PADL_(l_int)]; l_int in; char in_r_[PADR_(l_int)]; + char offset_l_[PADL_(l_loff_t *)]; l_loff_t * offset; char offset_r_[PADR_(l_loff_t *)]; + char count_l_[PADL_(l_size_t)]; l_size_t count; char count_r_[PADR_(l_size_t)]; +}; struct linux_sys_futex_args { char uaddr_l_[PADL_(void *)]; void * uaddr; char uaddr_r_[PADR_(void *)]; char op_l_[PADL_(int)]; int op; char op_r_[PADR_(int)]; @@ -1706,6 +1715,7 @@ int linux_removexattr(struct thread *, struct linux_removexattr_args *); int linux_lremovexattr(struct thread *, struct linux_lremovexattr_args *); int linux_fremovexattr(struct thread *, struct linux_fremovexattr_args *); int linux_tkill(struct thread *, struct linux_tkill_args *); +int linux_sendfile64(struct thread *, struct linux_sendfile64_args *); int linux_sys_futex(struct thread *, struct linux_sys_futex_args *); int linux_sched_setaffinity(struct thread *, struct linux_sched_setaffinity_args *); int linux_sched_getaffinity(struct thread *, struct linux_sched_getaffinity_args *); @@ -2102,6 +2112,7 @@ int linux_io_uring_register(struct thread *, struct linux_io_uring_register_args #define LINUX_SYS_AUE_linux_lremovexattr AUE_NULL #define LINUX_SYS_AUE_linux_fremovexattr AUE_NULL #define LINUX_SYS_AUE_linux_tkill AUE_NULL +#define LINUX_SYS_AUE_linux_sendfile64 AUE_SENDFILE #define LINUX_SYS_AUE_linux_sys_futex AUE_NULL #define LINUX_SYS_AUE_linux_sched_setaffinity AUE_NULL #define LINUX_SYS_AUE_linux_sched_getaffinity AUE_NULL diff --git a/sys/i386/linux/linux_syscall.h b/sys/i386/linux/linux_syscall.h index 0207a6bcee91..0b3a480e68aa 100644 --- a/sys/i386/linux/linux_syscall.h +++ b/sys/i386/linux/linux_syscall.h @@ -222,6 +222,7 @@ #define LINUX_SYS_linux_lremovexattr 236 #define LINUX_SYS_linux_fremovexattr 237 #define LINUX_SYS_linux_tkill 238 +#define LINUX_SYS_linux_sendfile64 239 #define LINUX_SYS_linux_sys_futex 240 #define LINUX_SYS_linux_sched_setaffinity 241 #define LINUX_SYS_linux_sched_getaffinity 242 diff --git a/sys/i386/linux/linux_syscalls.c b/sys/i386/linux/linux_syscalls.c index 6e1708a30363..8ccc0f57ea03 100644 --- a/sys/i386/linux/linux_syscalls.c +++ b/sys/i386/linux/linux_syscalls.c @@ -246,7 +246,7 @@ const char *linux_syscallnames[] = { "linux_lremovexattr", /* 236 = linux_lremovexattr */ "linux_fremovexattr", /* 237 = linux_fremovexattr */ "linux_tkill", /* 238 = linux_tkill */ - "#239", /* 239 = linux_sendfile64 */ + "linux_sendfile64", /* 239 = linux_sendfile64 */ "linux_sys_futex", /* 240 = linux_sys_futex */ "linux_sched_setaffinity", /* 241 = linux_sched_setaffinity */ "linux_sched_getaffinity", /* 242 = linux_sched_getaffinity */ diff --git a/sys/i386/linux/linux_sysent.c b/sys/i386/linux/linux_sysent.c index ffb55d322d02..7e5a5278eaec 100644 --- a/sys/i386/linux/linux_sysent.c +++ b/sys/i386/linux/linux_sysent.c @@ -204,7 +204,7 @@ struct sysent linux_sysent[] = { { AS(linux_capget_args), (sy_call_t *)linux_capget, AUE_CAPGET, NULL, 0, 0, 0, SY_THR_STATIC }, /* 184 = linux_capget */ { AS(linux_capset_args), (sy_call_t *)linux_capset, AUE_CAPSET, NULL, 0, 0, 0, SY_THR_STATIC }, /* 185 = linux_capset */ { AS(linux_sigaltstack_args), (sy_call_t *)linux_sigaltstack, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 186 = linux_sigaltstack */ - { 0, (sy_call_t *)linux_sendfile, AUE_SENDFILE, NULL, 0, 0, 0, SY_THR_STATIC }, /* 187 = linux_sendfile */ + { AS(linux_sendfile_args), (sy_call_t *)linux_sendfile, AUE_SENDFILE, NULL, 0, 0, 0, SY_THR_STATIC }, /* 187 = linux_sendfile */ { 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0, 0, SY_THR_ABSENT }, /* 188 = getpmsg */ { 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0, 0, SY_THR_ABSENT }, /* 189 = putpmsg */ { 0, (sy_call_t *)linux_vfork, AUE_VFORK, NULL, 0, 0, 0, SY_THR_STATIC }, /* 190 = linux_vfork */ @@ -256,7 +256,7 @@ struct sysent linux_sysent[] = { { 0, (sy_call_t *)linux_lremovexattr, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 236 = linux_lremovexattr */ { 0, (sy_call_t *)linux_fremovexattr, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 237 = linux_fremovexattr */ { AS(linux_tkill_args), (sy_call_t *)linux_tkill, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 238 = linux_tkill */ - { 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0, 0, SY_THR_ABSENT }, /* 239 = linux_sendfile64 */ + { AS(linux_sendfile64_args), (sy_call_t *)linux_sendfile64, AUE_SENDFILE, NULL, 0, 0, 0, SY_THR_STATIC }, /* 239 = linux_sendfile64 */ { AS(linux_sys_futex_args), (sy_call_t *)linux_sys_futex, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 240 = linux_sys_futex */ { AS(linux_sched_setaffinity_args), (sy_call_t *)linux_sched_setaffinity, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 241 = linux_sched_setaffinity */ { AS(linux_sched_getaffinity_args), (sy_call_t *)linux_sched_getaffinity, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 242 = linux_sched_getaffinity */ diff --git a/sys/i386/linux/linux_systrace_args.c b/sys/i386/linux/linux_systrace_args.c index 11a7041cc484..6b78bc1ff511 100644 --- a/sys/i386/linux/linux_systrace_args.c +++ b/sys/i386/linux/linux_systrace_args.c @@ -1335,7 +1335,12 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args) } /* linux_sendfile */ case 187: { - *n_args = 0; + struct linux_sendfile_args *p = params; + iarg[0] = p->out; /* l_int */ + iarg[1] = p->in; /* l_int */ + uarg[2] = (intptr_t) p->offset; /* l_long * */ + iarg[3] = p->count; /* l_size_t */ + *n_args = 4; break; } /* linux_vfork */ @@ -1659,6 +1664,16 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args) *n_args = 2; break; } + /* linux_sendfile64 */ + case 239: { + struct linux_sendfile64_args *p = params; + iarg[0] = p->out; /* l_int */ + iarg[1] = p->in; /* l_int */ + uarg[2] = (intptr_t) p->offset; /* l_loff_t * */ + iarg[3] = p->count; /* l_size_t */ + *n_args = 4; + break; + } /* linux_sys_futex */ case 240: { struct linux_sys_futex_args *p = params; @@ -5107,6 +5122,22 @@ systrace_entry_setargdesc(int sysnum, int ndx, char *desc, size_t descsz) break; /* linux_sendfile */ case 187: + switch(ndx) { + case 0: + p = "l_int"; + break; + case 1: + p = "l_int"; + break; + case 2: + p = "userland l_long *"; + break; + case 3: + p = "l_size_t"; + break; + default: + break; + }; break; /* linux_vfork */ case 190: @@ -5546,6 +5577,25 @@ systrace_entry_setargdesc(int sysnum, int ndx, char *desc, size_t descsz) break; }; break; + /* linux_sendfile64 */ + case 239: + switch(ndx) { + case 0: + p = "l_int"; + break; + case 1: + p = "l_int"; + break; + case 2: + p = "userland l_loff_t *"; + break; + case 3: + p = "l_size_t"; + break; + default: + break; + }; + break; /* linux_sys_futex */ case 240: switch(ndx) { @@ -8516,6 +8566,9 @@ systrace_return_setargdesc(int sysnum, int ndx, char *desc, size_t descsz) break; /* linux_sendfile */ case 187: + if (ndx == 0 || ndx == 1) + p = "int"; + break; /* linux_vfork */ case 190: /* linux_getrlimit */ @@ -8689,6 +8742,11 @@ systrace_return_setargdesc(int sysnum, int ndx, char *desc, size_t descsz) if (ndx == 0 || ndx == 1) p = "int"; break; + /* linux_sendfile64 */ + case 239: + if (ndx == 0 || ndx == 1) + p = "int"; + break; /* linux_sys_futex */ case 240: if (ndx == 0 || ndx == 1) diff --git a/sys/i386/linux/syscalls.master b/sys/i386/linux/syscalls.master index f2596c56ad64..6e86c1b88d74 100644 --- a/sys/i386/linux/syscalls.master +++ b/sys/i386/linux/syscalls.master @@ -341,7 +341,8 @@ struct l_user_cap_data *datap); } 186 AUE_NULL STD { int linux_sigaltstack(l_stack_t *uss, \ l_stack_t *uoss); } -187 AUE_SENDFILE STD { int linux_sendfile(void); } +187 AUE_SENDFILE STD { int linux_sendfile(l_int out, l_int in, \ + l_long *offset, l_size_t count); } 188 AUE_GETPMSG UNIMPL getpmsg 189 AUE_PUTPMSG UNIMPL putpmsg 190 AUE_VFORK STD { int linux_vfork(void); } @@ -415,7 +416,8 @@ 236 AUE_NULL STD { int linux_lremovexattr(void); } 237 AUE_NULL STD { int linux_fremovexattr(void); } 238 AUE_NULL STD { int linux_tkill(int tid, int sig); } -239 AUE_SENDFILE UNIMPL linux_sendfile64 +239 AUE_SENDFILE STD { int linux_sendfile64(l_int out, l_int in, \ + l_loff_t *offset, l_size_t count); } 240 AUE_NULL STD { int linux_sys_futex(void *uaddr, int op, uint32_t val, \ struct l_timespec *timeout, uint32_t *uaddr2, uint32_t val3); } 241 AUE_NULL STD { int linux_sched_setaffinity(l_pid_t pid, l_uint len, \ diff --git a/sys/kern/kern_descrip.c b/sys/kern/kern_descrip.c index b81f7b0eef5d..e8d2ee296a8f 100644 --- a/sys/kern/kern_descrip.c +++ b/sys/kern/kern_descrip.c @@ -619,7 +619,7 @@ kern_fcntl(struct thread *td, int fd, int cmd, intptr_t arg) break; } - error = fget_unlocked(fdp, fd, &cap_flock_rights, &fp, NULL); + error = fget_unlocked(fdp, fd, &cap_flock_rights, &fp); if (error != 0) break; if (fp->f_type != DTYPE_VNODE) { @@ -706,7 +706,7 @@ kern_fcntl(struct thread *td, int fd, int cmd, intptr_t arg) * that the closing thread was a bit slower and that the * advisory lock succeeded before the close. */ - error = fget_unlocked(fdp, fd, &cap_no_rights, &fp2, NULL); + error = fget_unlocked(fdp, fd, &cap_no_rights, &fp2); if (error != 0) { fdrop(fp, td); break; @@ -724,7 +724,7 @@ kern_fcntl(struct thread *td, int fd, int cmd, intptr_t arg) break; case F_GETLK: - error = fget_unlocked(fdp, fd, &cap_flock_rights, &fp, NULL); + error = fget_unlocked(fdp, fd, &cap_flock_rights, &fp); if (error != 0) break; if (fp->f_type != DTYPE_VNODE) { @@ -758,7 +758,7 @@ kern_fcntl(struct thread *td, int fd, int cmd, intptr_t arg) break; case F_ADD_SEALS: - error = fget_unlocked(fdp, fd, &cap_no_rights, &fp, NULL); + error = fget_unlocked(fdp, fd, &cap_no_rights, &fp); if (error != 0) break; error = fo_add_seals(fp, arg); @@ -766,7 +766,7 @@ kern_fcntl(struct thread *td, int fd, int cmd, intptr_t arg) break; case F_GET_SEALS: - error = fget_unlocked(fdp, fd, &cap_no_rights, &fp, NULL); + error = fget_unlocked(fdp, fd, &cap_no_rights, &fp); if (error != 0) break; if (fo_get_seals(fp, &seals) == 0) @@ -780,7 +780,7 @@ kern_fcntl(struct thread *td, int fd, int cmd, intptr_t arg) arg = arg ? 128 * 1024: 0; /* FALLTHROUGH */ case F_READAHEAD: - error = fget_unlocked(fdp, fd, &cap_no_rights, &fp, NULL); + error = fget_unlocked(fdp, fd, &cap_no_rights, &fp); if (error != 0) break; if (fp->f_type != DTYPE_VNODE) { @@ -831,7 +831,7 @@ kern_fcntl(struct thread *td, int fd, int cmd, intptr_t arg) * horrible kludge facilitates the current behavior in a much * cheaper manner until someone(tm) sorts this out. */ - error = fget_unlocked(fdp, fd, &cap_no_rights, &fp, NULL); + error = fget_unlocked(fdp, fd, &cap_no_rights, &fp); if (error != 0) break; if (fp->f_type != DTYPE_VNODE) { @@ -1445,16 +1445,14 @@ kern_fstat(struct thread *td, int fd, struct stat *sbp) error = fo_stat(fp, sbp, td->td_ucred, td); fdrop(fp, td); #ifdef __STAT_TIME_T_EXT - if (error == 0) { - sbp->st_atim_ext = 0; - sbp->st_mtim_ext = 0; - sbp->st_ctim_ext = 0; - sbp->st_btim_ext = 0; - } + sbp->st_atim_ext = 0; + sbp->st_mtim_ext = 0; + sbp->st_ctim_ext = 0; + sbp->st_btim_ext = 0; #endif #ifdef KTRACE - if (error == 0 && KTRPOINT(td, KTR_STRUCT)) - ktrstat(sbp); + if (KTRPOINT(td, KTR_STRUCT)) + ktrstat_error(sbp, error); #endif return (error); } @@ -2646,15 +2644,16 @@ fget_cap(struct thread *td, int fd, cap_rights_t *needrightsp, struct filedesc *fdp = td->td_proc->p_fd; int error; #ifndef CAPABILITIES - error = fget_unlocked(fdp, fd, needrightsp, fpp, NULL); - if (error == 0 && havecapsp != NULL) + error = fget_unlocked(fdp, fd, needrightsp, fpp); + if (havecapsp != NULL && error == 0) filecaps_fill(havecapsp); #else struct file *fp; seqc_t seq; + *fpp = NULL; for (;;) { - error = fget_unlocked(fdp, fd, needrightsp, &fp, &seq); + error = fget_unlocked_seq(fdp, fd, needrightsp, &fp, &seq); if (error != 0) return (error); @@ -2685,7 +2684,7 @@ fget_cap(struct thread *td, int fd, cap_rights_t *needrightsp, } int -fget_unlocked(struct filedesc *fdp, int fd, cap_rights_t *needrightsp, +fget_unlocked_seq(struct filedesc *fdp, int fd, cap_rights_t *needrightsp, struct file **fpp, seqc_t *seqp) { #ifdef CAPABILITIES @@ -2693,7 +2692,6 @@ fget_unlocked(struct filedesc *fdp, int fd, cap_rights_t *needrightsp, #endif const struct fdescenttbl *fdt; struct file *fp; - u_int count; #ifdef CAPABILITIES seqc_t seq; cap_rights_t haverights; @@ -2725,31 +2723,31 @@ fget_unlocked(struct filedesc *fdp, int fd, cap_rights_t *needrightsp, if (fp == NULL) return (EBADF); #ifdef CAPABILITIES - error = cap_check(&haverights, needrightsp); + error = cap_check_inline(&haverights, needrightsp); if (error != 0) return (error); #endif - count = fp->f_count; - retry: - if (count == 0) { + if (__predict_false(!refcount_acquire_if_not_zero(&fp->f_count))) { + /* + * The count was found either saturated or zero. + * This re-read is not any more racy than using the + * return value from fcmpset. + */ + if (fp->f_count != 0) + return (EBADF); /* * Force a reload. Other thread could reallocate the - * table before this fd was closed, so it possible that - * there is a stale fp pointer in cached version. + * table before this fd was closed, so it is possible + * that there is a stale fp pointer in cached version. */ fdt = (struct fdescenttbl *)atomic_load_ptr(&fdp->fd_files); continue; } - if (__predict_false(count + 1 < count)) - return (EBADF); - /* * Use an acquire barrier to force re-reading of fdt so it is * refreshed for verification. */ - if (__predict_false(atomic_fcmpset_acq_int(&fp->f_count, - &count, count + 1) == 0)) - goto retry; + atomic_thread_fence_acq(); fdt = fdp->fd_files; #ifdef CAPABILITIES if (seqc_consistent_nomb(fd_seqc(fdt, fd), seq)) @@ -2768,6 +2766,69 @@ fget_unlocked(struct filedesc *fdp, int fd, cap_rights_t *needrightsp, return (0); } +/* + * See the comments in fget_unlocked_seq for an explanation of how this works. + * + * This is a simplified variant which bails out to the aforementioned routine + * if anything goes wrong. In practice this only happens when userspace is + * racing with itself. + */ +int +fget_unlocked(struct filedesc *fdp, int fd, cap_rights_t *needrightsp, + struct file **fpp) +{ +#ifdef CAPABILITIES + const struct filedescent *fde; +#endif + const struct fdescenttbl *fdt; + struct file *fp; +#ifdef CAPABILITIES + seqc_t seq; + const cap_rights_t *haverights; +#endif + + fdt = fdp->fd_files; + if (__predict_false((u_int)fd >= fdt->fdt_nfiles)) + return (EBADF); +#ifdef CAPABILITIES + seq = seqc_read_any(fd_seqc(fdt, fd)); + if (__predict_false(seqc_in_modify(seq))) + goto out_fallback; + fde = &fdt->fdt_ofiles[fd]; + haverights = cap_rights_fde_inline(fde); + fp = fde->fde_file; +#else + fp = fdt->fdt_ofiles[fd].fde_file; +#endif + if (__predict_false(fp == NULL)) + goto out_fallback; +#ifdef CAPABILITIES + if (__predict_false(cap_check_inline_transient(haverights, needrightsp))) + goto out_fallback; +#endif + if (__predict_false(!refcount_acquire_if_not_zero(&fp->f_count))) + goto out_fallback; + + /* + * Use an acquire barrier to force re-reading of fdt so it is + * refreshed for verification. + */ + atomic_thread_fence_acq(); + fdt = fdp->fd_files; +#ifdef CAPABILITIES + if (__predict_false(!seqc_consistent_nomb(fd_seqc(fdt, fd), seq))) +#else + if (__predict_false(fp != fdt->fdt_ofiles[fd].fde_file)) +#endif + goto out_fdrop; + *fpp = fp; + return (0); +out_fdrop: + fdrop(fp, curthread); +out_fallback: + return (fget_unlocked_seq(fdp, fd, needrightsp, fpp, NULL)); +} + /* * Extract the file pointer associated with the specified descriptor for the * current user process. @@ -2783,7 +2844,7 @@ fget_unlocked(struct filedesc *fdp, int fd, cap_rights_t *needrightsp, */ static __inline int _fget(struct thread *td, int fd, struct file **fpp, int flags, - cap_rights_t *needrightsp, seqc_t *seqp) + cap_rights_t *needrightsp) { struct filedesc *fdp; struct file *fp; @@ -2791,7 +2852,7 @@ _fget(struct thread *td, int fd, struct file **fpp, int flags, *fpp = NULL; fdp = td->td_proc->p_fd; - error = fget_unlocked(fdp, fd, needrightsp, &fp, seqp); + error = fget_unlocked(fdp, fd, needrightsp, &fp); if (__predict_false(error != 0)) return (error); if (__predict_false(fp->f_ops == &badfileops)) { @@ -2833,7 +2894,7 @@ int fget(struct thread *td, int fd, cap_rights_t *rightsp, struct file **fpp) { - return (_fget(td, fd, fpp, 0, rightsp, NULL)); + return (_fget(td, fd, fpp, 0, rightsp)); } int @@ -2842,24 +2903,32 @@ fget_mmap(struct thread *td, int fd, cap_rights_t *rightsp, u_char *maxprotp, { int error; #ifndef CAPABILITIES - error = _fget(td, fd, fpp, 0, rightsp, NULL); + error = _fget(td, fd, fpp, 0, rightsp); if (maxprotp != NULL) *maxprotp = VM_PROT_ALL; + return (error); #else cap_rights_t fdrights; - struct filedesc *fdp = td->td_proc->p_fd; + struct filedesc *fdp; + struct file *fp; seqc_t seq; + *fpp = NULL; + fdp = td->td_proc->p_fd; MPASS(cap_rights_is_set(rightsp, CAP_MMAP)); for (;;) { - error = _fget(td, fd, fpp, 0, rightsp, &seq); - if (error != 0) + error = fget_unlocked_seq(fdp, fd, rightsp, &fp, &seq); + if (__predict_false(error != 0)) return (error); + if (__predict_false(fp->f_ops == &badfileops)) { + fdrop(fp, td); + return (EBADF); + } if (maxprotp != NULL) fdrights = *cap_rights(fdp, fd); if (!fd_modified(fdp, fd, seq)) break; - fdrop(*fpp, td); + fdrop(fp, td); } /* @@ -2867,22 +2936,23 @@ fget_mmap(struct thread *td, int fd, cap_rights_t *rightsp, u_char *maxprotp, */ if (maxprotp != NULL) *maxprotp = cap_rights_to_vmprot(&fdrights); + *fpp = fp; + return (0); #endif - return (error); } int fget_read(struct thread *td, int fd, cap_rights_t *rightsp, struct file **fpp) { - return (_fget(td, fd, fpp, FREAD, rightsp, NULL)); + return (_fget(td, fd, fpp, FREAD, rightsp)); } int fget_write(struct thread *td, int fd, cap_rights_t *rightsp, struct file **fpp) { - return (_fget(td, fd, fpp, FWRITE, rightsp, NULL)); + return (_fget(td, fd, fpp, FWRITE, rightsp)); } int @@ -2891,26 +2961,29 @@ fget_fcntl(struct thread *td, int fd, cap_rights_t *rightsp, int needfcntl, { struct filedesc *fdp = td->td_proc->p_fd; #ifndef CAPABILITIES - return (fget_unlocked(fdp, fd, rightsp, fpp, NULL)); + return (fget_unlocked(fdp, fd, rightsp, fpp)); #else + struct file *fp; int error; seqc_t seq; + *fpp = NULL; MPASS(cap_rights_is_set(rightsp, CAP_FCNTL)); for (;;) { - error = fget_unlocked(fdp, fd, rightsp, fpp, &seq); + error = fget_unlocked_seq(fdp, fd, rightsp, &fp, &seq); if (error != 0) return (error); error = cap_fcntl_check(fdp, fd, needfcntl); if (!fd_modified(fdp, fd, seq)) break; - fdrop(*fpp, td); + fdrop(fp, td); } if (error != 0) { - fdrop(*fpp, td); - *fpp = NULL; + fdrop(fp, td); + return (error); } - return (error); + *fpp = fp; + return (0); #endif } @@ -2929,7 +3002,7 @@ _fgetvp(struct thread *td, int fd, int flags, cap_rights_t *needrightsp, int error; *vpp = NULL; - error = _fget(td, fd, &fp, flags, needrightsp, NULL); + error = _fget(td, fd, &fp, flags, needrightsp); if (error != 0) return (error); if (fp->f_vnode == NULL) { diff --git a/sys/kern/kern_exit.c b/sys/kern/kern_exit.c index 54584a10cddf..d3adc9604ab4 100644 --- a/sys/kern/kern_exit.c +++ b/sys/kern/kern_exit.c @@ -217,6 +217,7 @@ exit1(struct thread *td, int rval, int signo) * XXX in case we're rebooting we just let init die in order to * work around an unsolved stack overflow seen very late during * shutdown on sparc64 when the gmirror worker process exists. + * XXX what to do now that sparc64 is gone... remove if? */ if (p == initproc && rebooting == 0) { printf("init died (signal %d, exit %d)\n", signo, rval); diff --git a/sys/kern/kern_ktrace.c b/sys/kern/kern_ktrace.c index a6788afad3b8..b4df404afe0c 100644 --- a/sys/kern/kern_ktrace.c +++ b/sys/kern/kern_ktrace.c @@ -778,6 +778,14 @@ ktrstruct(const char *name, const void *data, size_t datalen) ktr_submitrequest(curthread, req); } +void +ktrstruct_error(const char *name, const void *data, size_t datalen, int error) +{ + + if (error == 0) + ktrstruct(name, data, datalen); +} + void ktrstructarray(const char *name, enum uio_seg seg, const void *data, int num_items, size_t struct_size) diff --git a/sys/kern/kern_malloc.c b/sys/kern/kern_malloc.c index cf98ca8c2ff7..3ecac176ac02 100644 --- a/sys/kern/kern_malloc.c +++ b/sys/kern/kern_malloc.c @@ -930,9 +930,7 @@ reallocf(void *addr, size_t size, struct malloc_type *mtp, int flags) return (mem); } -#ifndef __sparc64__ CTASSERT(VM_KMEM_SIZE_SCALE >= 1); -#endif /* * Initialize the kernel memory (kmem) arena. diff --git a/sys/kern/kern_mbuf.c b/sys/kern/kern_mbuf.c index b5dcd808a9b1..71fce3ab4167 100644 --- a/sys/kern/kern_mbuf.c +++ b/sys/kern/kern_mbuf.c @@ -303,7 +303,6 @@ static void mb_dtor_pack(void *, int, void *); static int mb_zinit_pack(void *, int, int); static void mb_zfini_pack(void *, int); static void mb_reclaim(uma_zone_t, int); -static void *mbuf_jumbo_alloc(uma_zone_t, vm_size_t, int, uint8_t *, int); /* Ensure that MSIZE is a power of 2. */ CTASSERT((((MSIZE - 1) ^ MSIZE) + 1) >> 1 == MSIZE); @@ -323,7 +322,7 @@ mbuf_init(void *dummy) */ zone_mbuf = uma_zcreate(MBUF_MEM_NAME, MSIZE, mb_ctor_mbuf, mb_dtor_mbuf, NULL, NULL, - MSIZE - 1, UMA_ZONE_MAXBUCKET); + MSIZE - 1, UMA_ZONE_CONTIG | UMA_ZONE_MAXBUCKET); if (nmbufs > 0) nmbufs = uma_zone_set_max(zone_mbuf, nmbufs); uma_zone_set_warning(zone_mbuf, "kern.ipc.nmbufs limit reached"); @@ -331,7 +330,7 @@ mbuf_init(void *dummy) zone_clust = uma_zcreate(MBUF_CLUSTER_MEM_NAME, MCLBYTES, mb_ctor_clust, NULL, NULL, NULL, - UMA_ALIGN_PTR, 0); + UMA_ALIGN_PTR, UMA_ZONE_CONTIG); if (nmbclusters > 0) nmbclusters = uma_zone_set_max(zone_clust, nmbclusters); uma_zone_set_warning(zone_clust, "kern.ipc.nmbclusters limit reached"); @@ -343,7 +342,7 @@ mbuf_init(void *dummy) /* Make jumbo frame zone too. Page size, 9k and 16k. */ zone_jumbop = uma_zcreate(MBUF_JUMBOP_MEM_NAME, MJUMPAGESIZE, mb_ctor_clust, NULL, NULL, NULL, - UMA_ALIGN_PTR, 0); + UMA_ALIGN_PTR, UMA_ZONE_CONTIG); if (nmbjumbop > 0) nmbjumbop = uma_zone_set_max(zone_jumbop, nmbjumbop); uma_zone_set_warning(zone_jumbop, "kern.ipc.nmbjumbop limit reached"); @@ -351,8 +350,7 @@ mbuf_init(void *dummy) zone_jumbo9 = uma_zcreate(MBUF_JUMBO9_MEM_NAME, MJUM9BYTES, mb_ctor_clust, NULL, NULL, NULL, - UMA_ALIGN_PTR, 0); - uma_zone_set_allocf(zone_jumbo9, mbuf_jumbo_alloc); + UMA_ALIGN_PTR, UMA_ZONE_CONTIG); if (nmbjumbo9 > 0) nmbjumbo9 = uma_zone_set_max(zone_jumbo9, nmbjumbo9); uma_zone_set_warning(zone_jumbo9, "kern.ipc.nmbjumbo9 limit reached"); @@ -360,8 +358,7 @@ mbuf_init(void *dummy) zone_jumbo16 = uma_zcreate(MBUF_JUMBO16_MEM_NAME, MJUM16BYTES, mb_ctor_clust, NULL, NULL, NULL, - UMA_ALIGN_PTR, 0); - uma_zone_set_allocf(zone_jumbo16, mbuf_jumbo_alloc); + UMA_ALIGN_PTR, UMA_ZONE_CONTIG); if (nmbjumbo16 > 0) nmbjumbo16 = uma_zone_set_max(zone_jumbo16, nmbjumbo16); uma_zone_set_warning(zone_jumbo16, "kern.ipc.nmbjumbo16 limit reached"); @@ -614,24 +611,6 @@ debugnet_mbuf_reinit(int nmbuf, int nclust, int clsize) } #endif /* DEBUGNET */ -/* - * UMA backend page allocator for the jumbo frame zones. - * - * Allocates kernel virtual memory that is backed by contiguous physical - * pages. - */ -static void * -mbuf_jumbo_alloc(uma_zone_t zone, vm_size_t bytes, int domain, uint8_t *flags, - int wait) -{ - - /* Inform UMA that this allocator uses kernel_map/object. */ - *flags = UMA_SLAB_KERNEL; - return ((void *)kmem_alloc_contig_domainset(DOMAINSET_FIXED(domain), - bytes, wait, (vm_paddr_t)0, ~(vm_paddr_t)0, 1, 0, - VM_MEMATTR_DEFAULT)); -} - /* * Constructor for Mbuf master zone. * @@ -829,15 +808,18 @@ mb_ctor_pack(void *mem, int size, void *arg, int how) static void mb_reclaim(uma_zone_t zone __unused, int pending __unused) { + struct epoch_tracker et; struct domain *dp; struct protosw *pr; WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK | WARN_PANIC, NULL, __func__); + NET_EPOCH_ENTER(et); for (dp = domains; dp != NULL; dp = dp->dom_next) for (pr = dp->dom_protosw; pr < dp->dom_protoswNPROTOSW; pr++) if (pr->pr_drain != NULL) (*pr->pr_drain)(); + NET_EPOCH_EXIT(et); } /* diff --git a/sys/kern/kern_sendfile.c b/sys/kern/kern_sendfile.c index 5b3f15af0828..2eb973d5dc3c 100644 --- a/sys/kern/kern_sendfile.c +++ b/sys/kern/kern_sendfile.c @@ -1060,8 +1060,10 @@ vn_sendfile(struct file *fp, int sockfd, struct uio *hdr_uio, * we can send data right now without the * PRUS_NOTREADY flag. */ - vm_object_pip_wakeup(sfio->obj); - free(sfio, M_TEMP); + if (sfio != NULL) { + vm_object_pip_wakeup(sfio->obj); + free(sfio, M_TEMP); + } #ifdef KERN_TLS if (tls != NULL && tls->mode == TCP_TLS_MODE_SW) { error = (*so->so_proto->pr_usrreqs->pru_send) diff --git a/sys/kern/kern_sysctl.c b/sys/kern/kern_sysctl.c index 43bbe921314c..407254c68292 100644 --- a/sys/kern/kern_sysctl.c +++ b/sys/kern/kern_sysctl.c @@ -96,9 +96,13 @@ static MALLOC_DEFINE(M_SYSCTLTMP, "sysctltmp", "sysctl temp output buffer"); * The sysctlmemlock is used to limit the amount of user memory wired for * sysctl requests. This is implemented by serializing any userland * sysctl requests larger than a single page via an exclusive lock. + * + * The sysctlstringlock is used to protect concurrent access to writable + * string nodes in sysctl_handle_string(). */ static struct rmlock sysctllock; static struct sx __exclusive_cache_line sysctlmemlock; +static struct sx sysctlstringlock; #define SYSCTL_WLOCK() rm_wlock(&sysctllock) #define SYSCTL_WUNLOCK() rm_wunlock(&sysctllock) @@ -170,10 +174,16 @@ sysctl_root_handler_locked(struct sysctl_oid *oid, void *arg1, intmax_t arg2, else SYSCTL_WUNLOCK(); - if (!(oid->oid_kind & CTLFLAG_MPSAFE)) + /* + * Treat set CTLFLAG_NEEDGIANT and unset CTLFLAG_MPSAFE flags the same, + * untill we're ready to remove all traces of Giant from sysctl(9). + */ + if ((oid->oid_kind & CTLFLAG_NEEDGIANT) || + (!(oid->oid_kind & CTLFLAG_MPSAFE))) mtx_lock(&Giant); error = oid->oid_handler(oid, arg1, arg2, req); - if (!(oid->oid_kind & CTLFLAG_MPSAFE)) + if ((oid->oid_kind & CTLFLAG_NEEDGIANT) || + (!(oid->oid_kind & CTLFLAG_MPSAFE))) mtx_unlock(&Giant); KFAIL_POINT_ERROR(_debug_fail_point, sysctl_running, error); @@ -917,6 +927,7 @@ sysctl_register_all(void *arg) struct sysctl_oid **oidp; sx_init(&sysctlmemlock, "sysctl mem"); + sx_init(&sysctlstringlock, "sysctl string handler"); SYSCTL_INIT(); SYSCTL_WLOCK(); SET_FOREACH(oidp, sysctl_set) @@ -1632,48 +1643,69 @@ sysctl_handle_64(SYSCTL_HANDLER_ARGS) int sysctl_handle_string(SYSCTL_HANDLER_ARGS) { + char *tmparg; size_t outlen; int error = 0, ro_string = 0; /* + * If the sysctl isn't writable, microoptimise and treat it as a + * const string. * A zero-length buffer indicates a fixed size read-only * string. In ddb, don't worry about trying to make a malloced * snapshot. */ - if (arg2 == 0 || kdb_active) { + if (!(oidp->oid_kind & CTLFLAG_WR) || arg2 == 0 || kdb_active) { arg2 = strlen((char *)arg1) + 1; ro_string = 1; } if (req->oldptr != NULL) { - char *tmparg; - if (ro_string) { tmparg = arg1; + outlen = strlen(tmparg) + 1; } else { - /* try to make a coherent snapshot of the string */ tmparg = malloc(arg2, M_SYSCTLTMP, M_WAITOK); + sx_slock(&sysctlstringlock); memcpy(tmparg, arg1, arg2); + sx_sunlock(&sysctlstringlock); + outlen = strlen(tmparg) + 1; } - outlen = strnlen(tmparg, arg2 - 1) + 1; error = SYSCTL_OUT(req, tmparg, outlen); if (!ro_string) free(tmparg, M_SYSCTLTMP); } else { - outlen = strnlen((char *)arg1, arg2 - 1) + 1; + if (!ro_string) + sx_slock(&sysctlstringlock); + outlen = strlen((char *)arg1) + 1; + if (!ro_string) + sx_sunlock(&sysctlstringlock); error = SYSCTL_OUT(req, NULL, outlen); } if (error || !req->newptr) return (error); - if ((req->newlen - req->newidx) >= arg2) { + if (req->newlen - req->newidx >= arg2 || + req->newlen - req->newidx <= 0) { error = EINVAL; } else { - arg2 = (req->newlen - req->newidx); - error = SYSCTL_IN(req, arg1, arg2); + arg2 = req->newlen - req->newidx; + tmparg = malloc(arg2, M_SYSCTLTMP, M_WAITOK); + + error = copyin((const char *)req->newptr + req->newidx, + tmparg, arg2); + if (error) { + free(tmparg, M_SYSCTLTMP); + return (error); + } + + sx_xlock(&sysctlstringlock); + memcpy(arg1, tmparg, arg2); ((char *)arg1)[arg2] = '\0'; + sx_xunlock(&sysctlstringlock); + free(tmparg, M_SYSCTLTMP); + req->newidx += arg2; } return (error); } diff --git a/sys/kern/kern_thr.c b/sys/kern/kern_thr.c index da47cf9a517e..2f361fbdd25b 100644 --- a/sys/kern/kern_thr.c +++ b/sys/kern/kern_thr.c @@ -271,14 +271,12 @@ thread_create(struct thread *td, struct rtprio *rtp, tidhash_add(newtd); + /* ignore timesharing class */ + if (rtp != NULL && !(td->td_pri_class == PRI_TIMESHARE && + rtp->type == RTP_PRIO_NORMAL)) + rtp_to_pri(rtp, newtd); + thread_lock(newtd); - if (rtp != NULL) { - if (!(td->td_pri_class == PRI_TIMESHARE && - rtp->type == RTP_PRIO_NORMAL)) { - rtp_to_pri(rtp, newtd); - sched_prio(newtd, newtd->td_user_pri); - } /* ignore timesharing class */ - } TD_SET_CAN_RUN(newtd); sched_add(newtd, SRQ_BORING); diff --git a/sys/kern/kern_time.c b/sys/kern/kern_time.c index 98db5e7fb006..b743f2d2cce0 100644 --- a/sys/kern/kern_time.c +++ b/sys/kern/kern_time.c @@ -242,7 +242,7 @@ sys_clock_gettime(struct thread *td, struct clock_gettime_args *uap) return (error); } -static inline void +static inline void cputick2timespec(uint64_t runtime, struct timespec *ats) { runtime = cputick2usec(runtime); @@ -250,8 +250,8 @@ cputick2timespec(uint64_t runtime, struct timespec *ats) ats->tv_nsec = runtime % 1000000 * 1000; } -static void -get_thread_cputime(struct thread *targettd, struct timespec *ats) +void +kern_thread_cputime(struct thread *targettd, struct timespec *ats) { uint64_t runtime, curtime, switchtime; @@ -263,6 +263,7 @@ get_thread_cputime(struct thread *targettd, struct timespec *ats) critical_exit(); runtime += curtime - switchtime; } else { + PROC_LOCK_ASSERT(targettd->td_proc, MA_OWNED); thread_lock(targettd); runtime = targettd->td_runtime; thread_unlock(targettd); @@ -270,12 +271,13 @@ get_thread_cputime(struct thread *targettd, struct timespec *ats) cputick2timespec(runtime, ats); } -static void -get_process_cputime(struct proc *targetp, struct timespec *ats) +void +kern_process_cputime(struct proc *targetp, struct timespec *ats) { uint64_t runtime; struct rusage ru; + PROC_LOCK_ASSERT(targetp, MA_OWNED); PROC_STATLOCK(targetp); rufetch(targetp, &ru); runtime = targetp->p_rux.rux_runtime; @@ -300,14 +302,14 @@ get_cputime(struct thread *td, clockid_t clock_id, struct timespec *ats) td2 = tdfind(tid, p->p_pid); if (td2 == NULL) return (EINVAL); - get_thread_cputime(td2, ats); + kern_thread_cputime(td2, ats); PROC_UNLOCK(td2->td_proc); } else { pid = clock_id & CPUCLOCK_ID_MASK; error = pget(pid, PGET_CANSEE, &p2); if (error != 0) return (EINVAL); - get_process_cputime(p2, ats); + kern_process_cputime(p2, ats); PROC_UNLOCK(p2); } return (0); @@ -360,11 +362,11 @@ kern_clock_gettime(struct thread *td, clockid_t clock_id, struct timespec *ats) ats->tv_nsec = 0; break; case CLOCK_THREAD_CPUTIME_ID: - get_thread_cputime(NULL, ats); + kern_thread_cputime(NULL, ats); break; case CLOCK_PROCESS_CPUTIME_ID: PROC_LOCK(p); - get_process_cputime(p, ats); + kern_process_cputime(p, ats); PROC_UNLOCK(p); break; default: diff --git a/sys/kern/link_elf.c b/sys/kern/link_elf.c index 03f9ae63d9ac..266b9d0b06b6 100644 --- a/sys/kern/link_elf.c +++ b/sys/kern/link_elf.c @@ -51,6 +51,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include @@ -389,6 +390,13 @@ link_elf_link_common_finish(linker_file_t lf) extern vm_offset_t __startkernel, __endkernel; +static unsigned long kern_relbase = KERNBASE; + +SYSCTL_ULONG(_kern, OID_AUTO, base_address, CTLFLAG_RD, + SYSCTL_NULL_ULONG_PTR, KERNBASE, "Kernel base address"); +SYSCTL_ULONG(_kern, OID_AUTO, relbase_address, CTLFLAG_RD, + &kern_relbase, 0, "Kernel relocated base address"); + static void link_elf_init(void* arg) { @@ -431,6 +439,7 @@ link_elf_init(void* arg) #ifdef __powerpc__ linker_kernel_file->address = (caddr_t)__startkernel; linker_kernel_file->size = (intptr_t)(__endkernel - __startkernel); + kern_relbase = (unsigned long)__startkernel; #else linker_kernel_file->address += KERNBASE; linker_kernel_file->size = -(intptr_t)linker_kernel_file->address; diff --git a/sys/kern/sched_ule.c b/sys/kern/sched_ule.c index e2adf98ec6fd..62e19678c8f7 100644 --- a/sys/kern/sched_ule.c +++ b/sys/kern/sched_ule.c @@ -2605,15 +2605,17 @@ sched_add(struct thread *td, int flags) sched_setpreempt(td); #else tdq = TDQ_SELF(); - TDQ_LOCK(tdq); /* * Now that the thread is moving to the run-queue, set the lock * to the scheduler's lock. */ - if ((flags & SRQ_HOLD) != 0) - td->td_lock = TDQ_LOCKPTR(tdq); - else - thread_lock_set(td, TDQ_LOCKPTR(tdq)); + if (td->td_lock != TDQ_LOCKPTR(tdq)) { + TDQ_LOCK(tdq); + if ((flags & SRQ_HOLD) != 0) + td->td_lock = TDQ_LOCKPTR(tdq); + else + thread_lock_set(td, TDQ_LOCKPTR(tdq)); + } tdq_add(tdq, td, flags); if (!(flags & SRQ_YIELDING)) sched_setpreempt(td); diff --git a/sys/kern/subr_capability.c b/sys/kern/subr_capability.c index 677e3a498408..559dc8e52cc9 100644 --- a/sys/kern/subr_capability.c +++ b/sys/kern/subr_capability.c @@ -394,25 +394,3 @@ cap_rights_remove(cap_rights_t *dst, const cap_rights_t *src) return (dst); } - -bool -cap_rights_contains(const cap_rights_t *big, const cap_rights_t *little) -{ - unsigned int i, n; - - assert(CAPVER(big) == CAP_RIGHTS_VERSION_00); - assert(CAPVER(little) == CAP_RIGHTS_VERSION_00); - assert(CAPVER(big) == CAPVER(little)); - - n = CAPARSIZE(big); - assert(n >= CAPARSIZE_MIN && n <= CAPARSIZE_MAX); - - for (i = 0; i < n; i++) { - if ((big->cr_rights[i] & little->cr_rights[i]) != - little->cr_rights[i]) { - return (false); - } - } - - return (true); -} diff --git a/sys/kern/subr_param.c b/sys/kern/subr_param.c index 92d1066da383..61119dd2f34c 100644 --- a/sys/kern/subr_param.c +++ b/sys/kern/subr_param.c @@ -166,7 +166,7 @@ void init_param1(void) { -#if !defined(__mips__) && !defined(__arm64__) && !defined(__sparc64__) +#if !defined(__mips__) && !defined(__arm64__) TUNABLE_INT_FETCH("kern.kstack_pages", &kstack_pages); #endif hz = -1; diff --git a/sys/kern/subr_smr.c b/sys/kern/subr_smr.c index c344fdcb7f5f..bbbc5711c499 100644 --- a/sys/kern/subr_smr.c +++ b/sys/kern/subr_smr.c @@ -30,11 +30,13 @@ __FBSDID("$FreeBSD$"); #include #include -#include +#include #include +#include #include #include #include +#include #include @@ -158,10 +160,21 @@ static uma_zone_t smr_zone; #define SMR_SEQ_INCR (UINT_MAX / 10000) #define SMR_SEQ_INIT (UINT_MAX - 100000) /* Force extra polls to test the integer overflow detection. */ -#define SMR_SEQ_MAX_DELTA (1000) +#define SMR_SEQ_MAX_DELTA (SMR_SEQ_INCR * 32) #define SMR_SEQ_MAX_ADVANCE SMR_SEQ_MAX_DELTA / 2 #endif +static SYSCTL_NODE(_debug, OID_AUTO, smr, CTLFLAG_RW, NULL, "SMR Stats"); +static counter_u64_t advance = EARLY_COUNTER; +SYSCTL_COUNTER_U64(_debug_smr, OID_AUTO, advance, CTLFLAG_RD, &advance, ""); +static counter_u64_t advance_wait = EARLY_COUNTER; +SYSCTL_COUNTER_U64(_debug_smr, OID_AUTO, advance_wait, CTLFLAG_RD, &advance_wait, ""); +static counter_u64_t poll = EARLY_COUNTER; +SYSCTL_COUNTER_U64(_debug_smr, OID_AUTO, poll, CTLFLAG_RD, &poll, ""); +static counter_u64_t poll_scan = EARLY_COUNTER; +SYSCTL_COUNTER_U64(_debug_smr, OID_AUTO, poll_scan, CTLFLAG_RD, &poll_scan, ""); + + /* * Advance the write sequence and return the new value for use as the * wait goal. This guarantees that any changes made by the calling @@ -175,7 +188,7 @@ smr_seq_t smr_advance(smr_t smr) { smr_shared_t s; - smr_seq_t goal; + smr_seq_t goal, s_rd_seq; /* * It is illegal to enter while in an smr section. @@ -189,26 +202,55 @@ smr_advance(smr_t smr) */ atomic_thread_fence_rel(); + /* + * Load the current read seq before incrementing the goal so + * we are guaranteed it is always < goal. + */ + s = zpcpu_get(smr)->c_shared; + s_rd_seq = atomic_load_acq_int(&s->s_rd_seq); + /* * Increment the shared write sequence by 2. Since it is * initialized to 1 this means the only valid values are * odd and an observed value of 0 in a particular CPU means * it is not currently in a read section. */ - s = zpcpu_get(smr)->c_shared; goal = atomic_fetchadd_int(&s->s_wr_seq, SMR_SEQ_INCR) + SMR_SEQ_INCR; + counter_u64_add(advance, 1); /* * Force a synchronization here if the goal is getting too * far ahead of the read sequence number. This keeps the * wrap detecting arithmetic working in pathological cases. */ - if (goal - atomic_load_int(&s->s_rd_seq) >= SMR_SEQ_MAX_DELTA) + if (SMR_SEQ_DELTA(goal, s_rd_seq) >= SMR_SEQ_MAX_DELTA) { + counter_u64_add(advance_wait, 1); smr_wait(smr, goal - SMR_SEQ_MAX_ADVANCE); + } return (goal); } +smr_seq_t +smr_advance_deferred(smr_t smr, int limit) +{ + smr_seq_t goal; + smr_t csmr; + + critical_enter(); + csmr = zpcpu_get(smr); + if (++csmr->c_deferred >= limit) { + goal = SMR_SEQ_INVALID; + csmr->c_deferred = 0; + } else + goal = smr_shared_current(csmr->c_shared) + SMR_SEQ_INCR; + critical_exit(); + if (goal != SMR_SEQ_INVALID) + return (goal); + + return (smr_advance(smr)); +} + /* * Poll to determine whether all readers have observed the 'goal' write * sequence number. @@ -243,6 +285,7 @@ smr_poll(smr_t smr, smr_seq_t goal, bool wait) success = true; critical_enter(); s = zpcpu_get(smr)->c_shared; + counter_u64_add_protected(poll, 1); /* * Acquire barrier loads s_wr_seq after s_rd_seq so that we can not @@ -256,6 +299,17 @@ smr_poll(smr_t smr, smr_seq_t goal, bool wait) */ s_wr_seq = atomic_load_acq_int(&s->s_wr_seq); + /* + * This may have come from a deferred advance. Consider one + * increment past the current wr_seq valid and make sure we + * have advanced far enough to succeed. We simply add to avoid + * an additional fence. + */ + if (goal == s_wr_seq + SMR_SEQ_INCR) { + atomic_add_int(&s->s_wr_seq, SMR_SEQ_INCR); + s_wr_seq = goal; + } + /* * Detect whether the goal is valid and has already been observed. * @@ -275,6 +329,7 @@ smr_poll(smr_t smr, smr_seq_t goal, bool wait) * gone inactive. Keep track of the oldest sequence currently * active as rd_seq. */ + counter_u64_add_protected(poll_scan, 1); rd_seq = s_wr_seq; CPU_FOREACH(i) { c = zpcpu_get_cpu(smr, i); @@ -335,7 +390,7 @@ smr_poll(smr_t smr, smr_seq_t goal, bool wait) s_rd_seq = atomic_load_int(&s->s_rd_seq); do { if (SMR_SEQ_LEQ(rd_seq, s_rd_seq)) - break; + goto out; } while (atomic_fcmpset_int(&s->s_rd_seq, &s_rd_seq, rd_seq) == 0); out: @@ -395,3 +450,14 @@ smr_init(void) smr_zone = uma_zcreate("SMR CPU", sizeof(struct smr), NULL, NULL, NULL, NULL, (CACHE_LINE_SIZE * 2) - 1, UMA_ZONE_PCPU); } + +static void +smr_init_counters(void *unused) +{ + + advance = counter_u64_alloc(M_WAITOK); + advance_wait = counter_u64_alloc(M_WAITOK); + poll = counter_u64_alloc(M_WAITOK); + poll_scan = counter_u64_alloc(M_WAITOK); +} +SYSINIT(smr_counters, SI_SUB_CPU, SI_ORDER_ANY, smr_init_counters, NULL); diff --git a/sys/kern/subr_uio.c b/sys/kern/subr_uio.c index 5d98e8fbc69f..04c5fb162405 100644 --- a/sys/kern/subr_uio.c +++ b/sys/kern/subr_uio.c @@ -501,77 +501,6 @@ copyout_unmap(struct thread *td, vm_offset_t addr, size_t sz) return (0); } -#ifdef NO_FUEWORD -/* - * XXXKIB The temporal implementation of fue*() functions which do not - * handle usermode -1 properly, mixing it with the fault code. Keep - * this until MD code is written. Currently sparc64 does not have a - * proper implementation. - */ - -int -fueword(volatile const void *base, long *val) -{ - long res; - - res = fuword(base); - if (res == -1) - return (-1); - *val = res; - return (0); -} - -int -fueword32(volatile const void *base, int32_t *val) -{ - int32_t res; - - res = fuword32(base); - if (res == -1) - return (-1); - *val = res; - return (0); -} - -#ifdef _LP64 -int -fueword64(volatile const void *base, int64_t *val) -{ - int64_t res; - - res = fuword64(base); - if (res == -1) - return (-1); - *val = res; - return (0); -} -#endif - -int -casueword32(volatile uint32_t *base, uint32_t oldval, uint32_t *oldvalp, - uint32_t newval) -{ - int32_t ov; - - ov = casuword32(base, oldval, newval); - if (ov == -1) - return (-1); - *oldvalp = ov; - return (0); -} - -int -casueword(volatile u_long *p, u_long oldval, u_long *oldvalp, u_long newval) -{ - u_long ov; - - ov = casuword(p, oldval, newval); - if (ov == -1) - return (-1); - *oldvalp = ov; - return (0); -} -#else /* NO_FUEWORD */ int32_t fuword32(volatile const void *addr) { @@ -623,5 +552,3 @@ casuword(volatile u_long *addr, u_long old, u_long new) rv = casueword(addr, old, &val, new); return (rv == -1 ? -1 : val); } - -#endif /* NO_FUEWORD */ diff --git a/sys/kern/subr_witness.c b/sys/kern/subr_witness.c index bf87e908ed8f..f48095fc22ea 100644 --- a/sys/kern/subr_witness.c +++ b/sys/kern/subr_witness.c @@ -656,10 +656,6 @@ static struct witness_order_list_entry order_lists[] = { { "sio", &lock_class_mtx_spin }, #ifdef __i386__ { "cy", &lock_class_mtx_spin }, -#endif -#ifdef __sparc64__ - { "pcib_mtx", &lock_class_mtx_spin }, - { "rtc_mtx", &lock_class_mtx_spin }, #endif { "scc_hwmtx", &lock_class_mtx_spin }, { "uart_hwmtx", &lock_class_mtx_spin }, @@ -692,9 +688,6 @@ static struct witness_order_list_entry order_lists[] = { */ { "intrcnt", &lock_class_mtx_spin }, { "icu", &lock_class_mtx_spin }, -#if defined(SMP) && defined(__sparc64__) - { "ipi", &lock_class_mtx_spin }, -#endif #ifdef __i386__ { "allpmaps", &lock_class_mtx_spin }, { "descriptor tables", &lock_class_mtx_spin }, diff --git a/sys/kern/sys_capability.c b/sys/kern/sys_capability.c index 807521f55f3f..8ad0eabd4278 100644 --- a/sys/kern/sys_capability.c +++ b/sys/kern/sys_capability.c @@ -179,6 +179,17 @@ cap_check(const cap_rights_t *havep, const cap_rights_t *needp) return (_cap_check(havep, needp, CAPFAIL_NOTCAPABLE)); } +int +cap_check_failed_notcapable(const cap_rights_t *havep, const cap_rights_t *needp) +{ + +#ifdef KTRACE + if (KTRPOINT(curthread, KTR_CAPFAIL)) + ktrcapfail(CAPFAIL_NOTCAPABLE, needp, havep); +#endif + return (ENOTCAPABLE); +} + /* * Convert capability rights into VM access flags. */ diff --git a/sys/kern/sys_generic.c b/sys/kern/sys_generic.c index c013e6832b71..9cbf7138b006 100644 --- a/sys/kern/sys_generic.c +++ b/sys/kern/sys_generic.c @@ -1245,7 +1245,7 @@ static __inline int getselfd_cap(struct filedesc *fdp, int fd, struct file **fpp) { - return (fget_unlocked(fdp, fd, &cap_event_rights, fpp, NULL)); + return (fget_unlocked(fdp, fd, &cap_event_rights, fpp)); } /* diff --git a/sys/kern/sysv_sem.c b/sys/kern/sysv_sem.c index 8578c311bb82..9d0ef67a3081 100644 --- a/sys/kern/sysv_sem.c +++ b/sys/kern/sysv_sem.c @@ -1142,7 +1142,7 @@ sys_semop(struct thread *td, struct semop_args *uap) DPRINTF(("error = %d from copyin(%p, %p, %d)\n", error, uap->sops, sops, nsops * sizeof(sops[0]))); if (sops != small_sops) - free(sops, M_SEM); + free(sops, M_TEMP); return (error); } @@ -1393,7 +1393,7 @@ sys_semop(struct thread *td, struct semop_args *uap) done2: mtx_unlock(sema_mtxp); if (sops != small_sops) - free(sops, M_SEM); + free(sops, M_TEMP); return (error); } diff --git a/sys/kern/tty.c b/sys/kern/tty.c index d8e893db4b29..77e268c451a7 100644 --- a/sys/kern/tty.c +++ b/sys/kern/tty.c @@ -2059,7 +2059,7 @@ ttyhook_register(struct tty **rtp, struct proc *p, int fd, struct ttyhook *th, /* Validate the file descriptor. */ fdp = p->p_fd; error = fget_unlocked(fdp, fd, cap_rights_init(&rights, CAP_TTYHOOK), - &fp, NULL); + &fp); if (error != 0) return (error); if (fp->f_ops == &badfileops) { diff --git a/sys/kern/vfs_bio.c b/sys/kern/vfs_bio.c index eee492ade431..0d95776676c5 100644 --- a/sys/kern/vfs_bio.c +++ b/sys/kern/vfs_bio.c @@ -2859,10 +2859,8 @@ vfs_vmio_iodone(struct buf *bp) REFCOUNT_COUNT(obj->paging_in_progress), bp->b_npages)); vp = bp->b_vp; - KASSERT(vp->v_holdcnt > 0, - ("vfs_vmio_iodone: vnode %p has zero hold count", vp)); - KASSERT(vp->v_object != NULL, - ("vfs_vmio_iodone: vnode %p has no vm_object", vp)); + VNPASS(vp->v_holdcnt > 0, vp); + VNPASS(vp->v_object != NULL, vp); foff = bp->b_offset; KASSERT(bp->b_offset != NOOFFSET, diff --git a/sys/kern/vfs_cache.c b/sys/kern/vfs_cache.c index fecf749578e3..f0026e1be18e 100644 --- a/sys/kern/vfs_cache.c +++ b/sys/kern/vfs_cache.c @@ -2141,9 +2141,7 @@ vfs_cache_lookup(struct vop_lookup_args *ap) int error; struct vnode **vpp = ap->a_vpp; struct componentname *cnp = ap->a_cnp; - struct ucred *cred = cnp->cn_cred; int flags = cnp->cn_flags; - struct thread *td = cnp->cn_thread; *vpp = NULL; dvp = ap->a_dvp; @@ -2155,8 +2153,8 @@ vfs_cache_lookup(struct vop_lookup_args *ap) (cnp->cn_nameiop == DELETE || cnp->cn_nameiop == RENAME)) return (EROFS); - error = VOP_ACCESS(dvp, VEXEC, cred, td); - if (error) + error = vn_dir_check_exec(dvp, cnp); + if (error != 0) return (error); error = cache_lookup(dvp, vpp, cnp, NULL, NULL); diff --git a/sys/kern/vfs_lookup.c b/sys/kern/vfs_lookup.c index 265fd724d0f9..c8c303347010 100644 --- a/sys/kern/vfs_lookup.c +++ b/sys/kern/vfs_lookup.c @@ -308,6 +308,7 @@ namei(struct nameidata *ndp) struct vnode *dp; /* the directory we are searching */ struct iovec aiov; /* uio for reading symbolic links */ struct componentname *cnp; + struct file *dfp; struct thread *td; struct proc *p; cap_rights_t rights; @@ -445,10 +446,29 @@ namei(struct nameidata *ndp) AUDIT_ARG_ATFD1(ndp->ni_dirfd); if (cnp->cn_flags & AUDITVNODE2) AUDIT_ARG_ATFD2(ndp->ni_dirfd); - error = fgetvp_rights(td, ndp->ni_dirfd, - &rights, &ndp->ni_filecaps, &dp); - if (error == EINVAL) + /* + * Effectively inlined fgetvp_rights, because we need to + * inspect the file as well as grabbing the vnode. + */ + error = fget_cap_locked(fdp, ndp->ni_dirfd, &rights, + &dfp, &ndp->ni_filecaps); + if (error != 0) { + /* + * Preserve the error; it should either be EBADF + * or capability-related, both of which can be + * safely returned to the caller. + */ + } else if (dfp->f_ops == &badfileops) { + error = EBADF; + } else if (dfp->f_vnode == NULL) { error = ENOTDIR; + } else { + dp = dfp->f_vnode; + vrefact(dp); + + if ((dfp->f_flag & FSEARCH) != 0) + cnp->cn_flags |= NOEXECCHECK; + } #ifdef CAPABILITIES /* * If file descriptor doesn't have all rights, diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c index 6f9d37d03ccd..f9f1f0a541c6 100644 --- a/sys/kern/vfs_subr.c +++ b/sys/kern/vfs_subr.c @@ -6377,3 +6377,15 @@ __mnt_vnode_markerfree_lazy(struct vnode **mvp, struct mount *mp) mtx_unlock(&mp->mnt_listmtx); mnt_vnode_markerfree_lazy(mvp, mp); } + +int +vn_dir_check_exec(struct vnode *vp, struct componentname *cnp) +{ + + if ((cnp->cn_flags & NOEXECCHECK) != 0) { + cnp->cn_flags &= ~NOEXECCHECK; + return (0); + } + + return (VOP_ACCESS(vp, VEXEC, cnp->cn_cred, cnp->cn_thread)); +} diff --git a/sys/kern/vfs_syscalls.c b/sys/kern/vfs_syscalls.c index 20ed0dc8f39d..a77018a778aa 100644 --- a/sys/kern/vfs_syscalls.c +++ b/sys/kern/vfs_syscalls.c @@ -2349,8 +2349,6 @@ kern_statat(struct thread *td, int flag, int fd, const char *path, } NDFREE(&nd, NDF_ONLY_PNBUF); vput(nd.ni_vp); - if (error != 0) - return (error); #ifdef __STAT_TIME_T_EXT sbp->st_atim_ext = 0; sbp->st_mtim_ext = 0; @@ -2359,9 +2357,9 @@ kern_statat(struct thread *td, int flag, int fd, const char *path, #endif #ifdef KTRACE if (KTRPOINT(td, KTR_STRUCT)) - ktrstat(sbp); + ktrstat_error(sbp, error); #endif - return (0); + return (error); } #if defined(COMPAT_FREEBSD11) @@ -4175,7 +4173,7 @@ getvnode(struct thread *td, int fd, cap_rights_t *rightsp, struct file **fpp) struct file *fp; int error; - error = fget_unlocked(td->td_proc->p_fd, fd, rightsp, &fp, NULL); + error = fget_unlocked(td->td_proc->p_fd, fd, rightsp, &fp); if (error != 0) return (error); diff --git a/sys/mips/beri/beri_mp.c b/sys/mips/beri/beri_mp.c index 5279d5287983..8f8ab9a86a05 100644 --- a/sys/mips/beri/beri_mp.c +++ b/sys/mips/beri/beri_mp.c @@ -132,7 +132,7 @@ platform_cpu_mask(cpuset_t *mask) continue; } if (se->entry_addr != 1) { - printf("%s: CPU %d has uninitalized spin " + printf("%s: CPU %d has uninitialized spin " "entry\n", __func__, reg); continue; } diff --git a/sys/modules/Makefile b/sys/modules/Makefile index 932a79b7b2a2..6055587fa0c6 100644 --- a/sys/modules/Makefile +++ b/sys/modules/Makefile @@ -57,7 +57,6 @@ SUBDIR= \ ath_rate \ ath_pci \ ${_autofs} \ - ${_auxio} \ ${_bce} \ ${_bcm283x_clkman} \ ${_bcm283x_pwm} \ @@ -110,7 +109,6 @@ SUBDIR= \ ${_efirt} \ ${_em} \ ${_ena} \ - ${_epic} \ esp \ ${_et} \ evdev \ @@ -397,8 +395,7 @@ _autofs= autofs .if ${MK_CDDL} != "no" || defined(ALL_MODULES) .if (${MACHINE_CPUARCH} != "arm" || ${MACHINE_ARCH:Marmv[67]*} != "") && \ - ${MACHINE_CPUARCH} != "mips" && \ - ${MACHINE_CPUARCH} != "sparc64" + ${MACHINE_CPUARCH} != "mips" SUBDIR+= dtrace .endif SUBDIR+= opensolaris @@ -725,7 +722,7 @@ _vmm= vmm _3dfx= 3dfx _3dfx_linux= 3dfx_linux _apm= apm -.if ${MK_SOURCELESS_UCODE} != "no" +.if ${MK_SOURCELESS_HOST} != "no" _ce= ce .endif .if ${MK_SOURCELESS_UCODE} != "no" @@ -771,12 +768,6 @@ _nvram= opal_nvram _nvram+= powermac_nvram .endif -.if ${MACHINE_CPUARCH} == "sparc64" -_auxio= auxio -_em= em -_epic= epic -.endif - .if (${MACHINE_CPUARCH} == "aarch64" || ${MACHINE_CPUARCH} == "amd64" || \ ${MACHINE_ARCH:Marmv[67]*} != "" || ${MACHINE_CPUARCH} == "i386") _cloudabi32= cloudabi32 diff --git a/sys/modules/auxio/Makefile b/sys/modules/auxio/Makefile deleted file mode 100644 index f46f438accc5..000000000000 --- a/sys/modules/auxio/Makefile +++ /dev/null @@ -1,10 +0,0 @@ -# $FreeBSD$ - -.PATH: ${SRCTOP}/sys/dev/auxio - -KMOD= auxio - -SRCS= auxio.c -SRCS+= device_if.h bus_if.h ofw_bus_if.h - -.include diff --git a/sys/modules/bge/Makefile b/sys/modules/bge/Makefile index 53e3364f0e3a..9a197e8fab3f 100644 --- a/sys/modules/bge/Makefile +++ b/sys/modules/bge/Makefile @@ -5,8 +5,4 @@ KMOD= if_bge SRCS= if_bge.c miibus_if.h miidevs.h device_if.h bus_if.h pci_if.h -.if ${MACHINE_CPUARCH} == sparc64 -SRCS+= ofw_bus_if.h -.endif - .include diff --git a/sys/modules/cas/Makefile b/sys/modules/cas/Makefile index 2e6fcfb4cb45..ef53564f9356 100644 --- a/sys/modules/cas/Makefile +++ b/sys/modules/cas/Makefile @@ -5,7 +5,7 @@ KMOD= if_cas SRCS= bus_if.h device_if.h if_cas.c miibus_if.h pci_if.h ${ofw_bus_if} -.if ${MACHINE_CPUARCH} == "powerpc" || ${MACHINE_ARCH} == "sparc64" +.if ${MACHINE_CPUARCH} == "powerpc" ofw_bus_if= ofw_bus_if.h .endif diff --git a/sys/modules/dtrace/dtrace/Makefile b/sys/modules/dtrace/dtrace/Makefile index 2cfb84c43150..84960728aaac 100644 --- a/sys/modules/dtrace/dtrace/Makefile +++ b/sys/modules/dtrace/dtrace/Makefile @@ -47,8 +47,6 @@ CFLAGS+= -I${SYSDIR}/cddl/compat/opensolaris \ -I${SYSDIR}/cddl/contrib/opensolaris/common/util \ -I${SYSDIR} -DDIS_MEM -CFLAGS+= -DSMP - EXPORT_SYMS= dtrace_register \ dtrace_unregister \ dtrace_probe_lookup diff --git a/sys/modules/dtrace/fasttrap/Makefile b/sys/modules/dtrace/fasttrap/Makefile index d1d303cb8856..4f1ecc4839be 100644 --- a/sys/modules/dtrace/fasttrap/Makefile +++ b/sys/modules/dtrace/fasttrap/Makefile @@ -24,8 +24,6 @@ CFLAGS+= -I${SYSDIR}/cddl/contrib/opensolaris/uts/powerpc .PATH: ${SYSDIR}/cddl/contrib/opensolaris/common/unicode SRCS+= u8_textprep.c -CFLAGS+= -DSMP - .include CFLAGS+= -include ${SYSDIR}/cddl/compat/opensolaris/sys/debug_compat.h diff --git a/sys/modules/epic/Makefile b/sys/modules/epic/Makefile deleted file mode 100644 index b791d340b844..000000000000 --- a/sys/modules/epic/Makefile +++ /dev/null @@ -1,8 +0,0 @@ -# $FreeBSD$ - -.PATH: ${SRCTOP}/sys/sparc64/ebus - -KMOD= epic -SRCS= device_if.h epic.c bus_if.h ofw_bus_if.h - -.include diff --git a/sys/modules/esp/Makefile b/sys/modules/esp/Makefile index d582a2da5dbe..1880d385dfb8 100644 --- a/sys/modules/esp/Makefile +++ b/sys/modules/esp/Makefile @@ -6,9 +6,4 @@ KMOD= esp SRCS= device_if.h esp_pci.c ${esp_sbus} bus_if.h ncr53c9x.c ${ofw_bus_if} SRCS+= opt_cam.h pci_if.h -.if ${MACHINE} == "sparc64" -ofw_bus_if= ofw_bus_if.h -esp_sbus= esp_sbus.c -.endif - .include diff --git a/sys/modules/gem/Makefile b/sys/modules/gem/Makefile index 54083b0de6cb..13c9003dc38c 100644 --- a/sys/modules/gem/Makefile +++ b/sys/modules/gem/Makefile @@ -3,14 +3,10 @@ .PATH: ${SRCTOP}/sys/dev/gem KMOD= if_gem -SRCS= bus_if.h device_if.h if_gem.c if_gem_pci.c ${if_gem_sbus} miibus_if.h +SRCS= bus_if.h device_if.h if_gem.c if_gem_pci.c miibus_if.h SRCS+= ${ofw_bus_if} pci_if.h -.if ${MACHINE} == "sparc64" -if_gem_sbus= if_gem_sbus.c -.endif - -.if ${MACHINE_CPUARCH} == "powerpc" || ${MACHINE_CPUARCH} == "sparc64" +.if ${MACHINE_CPUARCH} == "powerpc" ofw_bus_if= ofw_bus_if.h .endif diff --git a/sys/modules/hme/Makefile b/sys/modules/hme/Makefile index 74633717bbd3..ab7fd5be64ee 100644 --- a/sys/modules/hme/Makefile +++ b/sys/modules/hme/Makefile @@ -3,12 +3,7 @@ .PATH: ${SRCTOP}/sys/dev/hme KMOD= if_hme -SRCS= bus_if.h device_if.h if_hme.c if_hme_pci.c ${if_hme_sbus} miibus_if.h -SRCS+= ${ofw_bus_if} pci_if.h - -.if ${MACHINE} == "sparc64" -if_hme_sbus= if_hme_sbus.c -ofw_bus_if= ofw_bus_if.h -.endif +SRCS= bus_if.h device_if.h if_hme.c if_hme_pci.c miibus_if.h +SRCS+= pci_if.h .include diff --git a/sys/modules/hwpmc/Makefile b/sys/modules/hwpmc/Makefile index 23bd648be229..c4500fb4a174 100644 --- a/sys/modules/hwpmc/Makefile +++ b/sys/modules/hwpmc/Makefile @@ -35,8 +35,4 @@ SRCS+= hwpmc_tsc.c hwpmc_x86.c hwpmc_uncore.c SRCS+= hwpmc_powerpc.c hwpmc_e500.c hwpmc_mpc7xxx.c hwpmc_ppc970.c .endif -.if ${MACHINE_CPUARCH} == "sparc64" -SRCS+= hwpmc_sparc64.c -.endif - .include diff --git a/sys/modules/i2c/controllers/pcf/Makefile b/sys/modules/i2c/controllers/pcf/Makefile index 94b4b0c22fc7..f213b0b3168e 100644 --- a/sys/modules/i2c/controllers/pcf/Makefile +++ b/sys/modules/i2c/controllers/pcf/Makefile @@ -3,18 +3,12 @@ .PATH: ${SRCTOP}/sys/dev/pcf KMOD= pcf -SRCS= ${envctrl} pcf.c ${pcf_ebus} ${pcf_isa} -SRCS+= bus_if.h device_if.h iicbus_if.h ${isa_if} ${ofw_bus_if} +SRCS= pcf.c ${pcf_isa} +SRCS+= bus_if.h device_if.h iicbus_if.h ${isa_if} .if ${MACHINE_CPUARCH} == "i386" isa_if= isa_if.h pcf_isa= pcf_isa.c .endif -.if ${MACHINE_CPUARCH} == "sparc64" -envctrl= envctrl.c -ofw_bus_if= ofw_bus_if.h -pcf_ebus= pcf_ebus.c -.endif - .include diff --git a/sys/modules/isp/Makefile b/sys/modules/isp/Makefile index d59d54036be6..89f612f35b55 100644 --- a/sys/modules/isp/Makefile +++ b/sys/modules/isp/Makefile @@ -7,8 +7,4 @@ SRCS= bus_if.h device_if.h pci_if.h \ opt_cam.h opt_ddb.h opt_isp.h \ isp.c isp_library.c isp_target.c isp_freebsd.c isp_pci.c -.if ${MACHINE} == sparc64 -SRCS+= isp_sbus.c ofw_bus_if.h -.endif - .include diff --git a/sys/modules/ispfw/Makefile b/sys/modules/ispfw/Makefile index fa61f172d80b..05de489c3412 100644 --- a/sys/modules/ispfw/Makefile +++ b/sys/modules/ispfw/Makefile @@ -37,8 +37,5 @@ SUBDIR += isp_2300 SUBDIR += isp_2322 SUBDIR += isp_2400 SUBDIR += isp_2500 -.if ${MACHINE} == "sparc64" -SUBDIR += isp_1000 -.endif .include diff --git a/sys/modules/ix/Makefile b/sys/modules/ix/Makefile index 421ca104a2e4..1affdeb1d024 100644 --- a/sys/modules/ix/Makefile +++ b/sys/modules/ix/Makefile @@ -10,6 +10,6 @@ SRCS += if_ix.c if_bypass.c if_fdir.c if_sriov.c ix_txrx.c ixgbe_osdep.c SRCS += ixgbe_common.c ixgbe_api.c ixgbe_phy.c ixgbe_mbx.c ixgbe_vf.c SRCS += ixgbe_dcb.c ixgbe_dcb_82598.c ixgbe_dcb_82599.c SRCS += ixgbe_82598.c ixgbe_82599.c ixgbe_x540.c ixgbe_x550.c -CFLAGS+= -I${SRCTOP}/sys/dev/ixgbe -DSMP +CFLAGS+= -I${SRCTOP}/sys/dev/ixgbe .include diff --git a/sys/modules/ixv/Makefile b/sys/modules/ixv/Makefile index 573af9189516..db0bb9fe9b4f 100644 --- a/sys/modules/ixv/Makefile +++ b/sys/modules/ixv/Makefile @@ -10,6 +10,6 @@ SRCS += if_ixv.c if_fdir.c ix_txrx.c ixgbe_osdep.c SRCS += ixgbe_common.c ixgbe_api.c ixgbe_phy.c ixgbe_mbx.c ixgbe_vf.c SRCS += ixgbe_dcb.c ixgbe_dcb_82598.c ixgbe_dcb_82599.c SRCS += ixgbe_82598.c ixgbe_82599.c ixgbe_x540.c ixgbe_x550.c -CFLAGS+= -I${SRCTOP}/sys/dev/ixgbe -DSMP +CFLAGS+= -I${SRCTOP}/sys/dev/ixgbe .include diff --git a/sys/modules/le/Makefile b/sys/modules/le/Makefile index 96a157c50ac9..b77a2e69f161 100644 --- a/sys/modules/le/Makefile +++ b/sys/modules/le/Makefile @@ -3,20 +3,12 @@ .PATH: ${SRCTOP}/sys/dev/le KMOD= if_le -SRCS= am7990.c am79900.c ${if_le_isa} ${if_le_lebuffer} -SRCS+= ${if_le_ledma} if_le_pci.c lance.c ${lebuffer_sbus} -SRCS+= bus_if.h device_if.h ${isa_if} ${ofw_bus_if} pci_if.h +SRCS= am7990.c am79900.c ${if_le_isa} if_le_pci.c lance.c +SRCS+= bus_if.h device_if.h ${isa_if} pci_if.h .if ${MACHINE_CPUARCH} == "i386" if_le_isa= if_le_isa.c isa_if= isa_if.h .endif -.if ${MACHINE} == "sparc64" -if_le_lebuffer= if_le_lebuffer.c -if_le_ledma= if_le_ledma.c -lebuffer_sbus= lebuffer_sbus.c -ofw_bus_if= ofw_bus_if.h -.endif - .include diff --git a/sys/modules/lio/Makefile b/sys/modules/lio/Makefile index e3b48cc81a1c..1484e3029d6e 100644 --- a/sys/modules/lio/Makefile +++ b/sys/modules/lio/Makefile @@ -7,7 +7,6 @@ KMOD = if_lio CFLAGS += -I${.CURDIR}/../../dev/liquidio CFLAGS += -I${.CURDIR}/../../dev/liquidio/base -CFLAGS += -DSMP SRCS = device_if.h bus_if.h pci_if.h vnode_if.h opt_inet.h opt_inet6.h SRCS += vnode_if_newproto.h vnode_if_typedef.h diff --git a/sys/modules/oce/Makefile b/sys/modules/oce/Makefile index 5565d2dec31a..f5ea74b979ea 100644 --- a/sys/modules/oce/Makefile +++ b/sys/modules/oce/Makefile @@ -7,7 +7,7 @@ KMOD = if_oce SRCS = oce_if.c oce_hw.c oce_mbox.c oce_util.c oce_queue.c oce_sysctl.c SRCS += bus_if.h device_if.h pci_if.h opt_inet.h opt_inet6.h -CFLAGS+= -I${SRCTOP}/sys/dev/oce -DSMP +CFLAGS+= -I${SRCTOP}/sys/dev/oce # uncomment for lock profiling statistics #CFLAGS += -DLOCK_PROFILING diff --git a/sys/modules/scc/Makefile b/sys/modules/scc/Makefile index 05a67b2db85d..d138bcd3c8f2 100644 --- a/sys/modules/scc/Makefile +++ b/sys/modules/scc/Makefile @@ -2,9 +2,6 @@ .PATH: ${SRCTOP}/sys/dev/scc -.if ${MACHINE} == "sparc64" -scc_bfe= scc_bfe_ebus.c scc_bfe_sbus.c -.endif .if ${MACHINE_CPUARCH} == "powerpc" scc_bfe= scc_bfe_macio.c scc_bfe_quicc.c scc_dev_quicc.c .endif diff --git a/sys/modules/sound/driver/Makefile b/sys/modules/sound/driver/Makefile index d00ccaa10286..8c21a719966a 100644 --- a/sys/modules/sound/driver/Makefile +++ b/sys/modules/sound/driver/Makefile @@ -21,12 +21,6 @@ _maestro3= maestro3 SUBDIR+= cmi mss .endif -.if ${MACHINE_CPUARCH} == "sparc64" -.if ${MACHINE} == "sparc64" -SUBDIR+= audiocs -.endif -.endif - .if ${MACHINE_CPUARCH} == "powerpc" SUBDIR+= ai2s davbus .endif diff --git a/sys/modules/sound/driver/audiocs/Makefile b/sys/modules/sound/driver/audiocs/Makefile deleted file mode 100644 index 0cd516cc8bc0..000000000000 --- a/sys/modules/sound/driver/audiocs/Makefile +++ /dev/null @@ -1,10 +0,0 @@ -# $FreeBSD$ - -.PATH: ${SRCTOP}/sys/dev/sound/sbus - -KMOD= snd_audiocs -SRCS= device_if.h bus_if.h ofw_bus_if.h -SRCS+= channel_if.h feeder_if.h mixer_if.h -SRCS+= cs4231.c - -.include diff --git a/sys/modules/syscons/Makefile b/sys/modules/syscons/Makefile index 85e513d5f898..256cfe3ac744 100644 --- a/sys/modules/syscons/Makefile +++ b/sys/modules/syscons/Makefile @@ -1,36 +1,22 @@ # $FreeBSD$ SUBDIR= ${_apm} \ - ${_beastie} \ + beastie \ blank \ - ${_daemon} \ - ${_dragon} \ + daemon \ + dragon \ fade \ - ${_fire} \ + fire \ green \ - ${_logo} \ - ${_plasma} \ - ${_rain} \ - ${_snake} \ - ${_star} \ - ${_warp} + logo \ + plasma \ + rain \ + snake \ + star \ + warp .if ${MACHINE_CPUARCH} == "i386" _apm= apm .endif -.if ${MACHINE_CPUARCH} != "sparc64" -_beastie= beastie -_beastie= beastie -_daemon= daemon -_dragon= dragon -_fire= fire -_logo= logo -_plasma= plasma -_rain= rain -_snake= snake -_star= star -_warp= warp -.endif - .include diff --git a/sys/modules/uart/Makefile b/sys/modules/uart/Makefile index 199440ae78db..b6bba88da9ca 100644 --- a/sys/modules/uart/Makefile +++ b/sys/modules/uart/Makefile @@ -8,13 +8,8 @@ uart_bus_acpi=uart_bus_acpi.c uart_cpu_acpi=uart_cpu_acpi.c .endif -.if ${MACHINE_CPUARCH} == "sparc64" -uart_bus_ebus= uart_bus_ebus.c -.endif - .if ${MACHINE_CPUARCH} == "aarch64" || ${MACHINE_CPUARCH} == "arm" || \ - ${MACHINE_CPUARCH} == "powerpc" || ${MACHINE_CPUARCH} == "riscv" || \ - ${MACHINE_CPUARCH} == "sparc64" + ${MACHINE_CPUARCH} == "powerpc" || ${MACHINE_CPUARCH} == "riscv" ofw_bus_if= ofw_bus_if.h .endif diff --git a/sys/modules/vmm/Makefile b/sys/modules/vmm/Makefile index fa016a97192a..4e430acf93ab 100644 --- a/sys/modules/vmm/Makefile +++ b/sys/modules/vmm/Makefile @@ -6,7 +6,7 @@ SRCS= opt_acpi.h opt_ddb.h device_if.h bus_if.h pci_if.h pcib_if.h acpi_if.h DPSRCS+= vmx_assym.h svm_assym.h DPSRCS+= vmx_genassym.c svm_genassym.c offset.inc -CFLAGS+= -DVMM_KEEP_STATS -DSMP +CFLAGS+= -DVMM_KEEP_STATS CFLAGS+= -I${SRCTOP}/sys/amd64/vmm CFLAGS+= -I${SRCTOP}/sys/amd64/vmm/io CFLAGS+= -I${SRCTOP}/sys/amd64/vmm/intel diff --git a/sys/net/ethernet.h b/sys/net/ethernet.h index 77773eee04a7..346887b41e95 100644 --- a/sys/net/ethernet.h +++ b/sys/net/ethernet.h @@ -6,7 +6,7 @@ */ #ifndef _NET_ETHERNET_H_ -#define _NET_ETHERNET_H_ +#define _NET_ETHERNET_H_ /* * Some basic Ethernet constants. @@ -98,6 +98,11 @@ struct ether_vlan_header { ((((((pri) & 7) << 1) | ((cfi) & 1)) << 12) | ((vlid) & EVL_VLID_MASK)) /* + * Ethernet protocol types. + * + * A public list is available from the IEEE Registration Authority: + * https://standards.ieee.org/products-services/regauth/ + * * NOTE: 0x0000-0x05DC (0..1500) are generally IEEE 802.3 length fields. * However, there are some conflicts. */ @@ -266,7 +271,7 @@ struct ether_vlan_header { #define ETHERTYPE_AARP 0x80F3 /* AppleTalk AARP */ /* 0x80F4 - 0x80F5 Kinetics */ #define ETHERTYPE_APOLLO 0x80F7 /* Apollo Computer */ -#define ETHERTYPE_VLAN 0x8100 /* IEEE 802.1Q VLAN tagging (XXX conflicts) */ +#define ETHERTYPE_VLAN 0x8100 /* IEEE 802.1Q VLAN tagging (XXX conflicts) */ /* 0x80FF - 0x8101 Wellfleet Communications (XXX conflicts) */ #define ETHERTYPE_BOFL 0x8102 /* Wellfleet; BOFL (Breath OF Life) pkts [every 5-10 secs.] */ #define ETHERTYPE_WELLFLEET 0x8103 /* Wellfleet Communications */ @@ -339,15 +344,24 @@ struct ether_vlan_header { #define ETHERTYPE_SLOW 0x8809 /* 802.3ad link aggregation (LACP) */ #define ETHERTYPE_PPP 0x880B /* PPP (obsolete by PPPoE) */ #define ETHERTYPE_HITACHI 0x8820 /* Hitachi Cable (Optoelectronic Systems Laboratory) */ -#define ETHERTYPE_TEST 0x8822 /* Network Conformance Testing */ +#define ETHERTYPE_TEST 0x8822 /* Network Conformance Testing */ #define ETHERTYPE_MPLS 0x8847 /* MPLS Unicast */ #define ETHERTYPE_MPLS_MCAST 0x8848 /* MPLS Multicast */ #define ETHERTYPE_AXIS 0x8856 /* Axis Communications AB proprietary bootstrap/config */ #define ETHERTYPE_PPPOEDISC 0x8863 /* PPP Over Ethernet Discovery Stage */ #define ETHERTYPE_PPPOE 0x8864 /* PPP Over Ethernet Session Stage */ #define ETHERTYPE_LANPROBE 0x8888 /* HP LanProbe test? */ -#define ETHERTYPE_PAE 0x888e /* EAPOL PAE/802.1x */ +#define ETHERTYPE_PAE 0x888E /* EAPOL PAE/802.1x */ +#define ETHERTYPE_PROFINET 0x8892 /* PROFINET RT Protocol */ +#define ETHERTYPE_AOE 0x88A2 /* ATA Protocol */ +#define ETHERTYPE_ETHERCAT 0x88A4 /* EtherCat Protocol */ #define ETHERTYPE_QINQ 0x88A8 /* 802.1ad VLAN stacking */ +#define ETHERTYPE_POWERLINK 0x88AB /* Ethernet Powerlink (EPL) */ +#define ETHERTYPE_LLDP 0x88CC /* Link Layer Discovery Protocol */ +#define ETHERTYPE_SERCOS 0x88CD /* SERCOS III Protocol */ +#define ETHERTYPE_MACSEC 0x88E5 /* 802.1AE MAC Security */ +#define ETHERTYPE_PBB 0x88E7 /* 802.1Q Provider Backbone Bridges */ +#define ETHERTYPE_FCOE 0x8906 /* Fibre Channel over Ethernet */ #define ETHERTYPE_LOOPBACK 0x9000 /* Loopback: used to test interfaces */ #define ETHERTYPE_8021Q9100 0x9100 /* IEEE 802.1Q stacking (proprietary) */ #define ETHERTYPE_LBACK ETHERTYPE_LOOPBACK /* DEC MOP loopback */ @@ -381,7 +395,7 @@ struct ether_vlan_header { * ether_vlan_mtap. This function will re-insert VLAN tags for the duration * of the tap, so they show up properly for network analyzers. */ -#define ETHER_BPF_MTAP(_ifp, _m) do { \ +#define ETHER_BPF_MTAP(_ifp, _m) do { \ if (bpf_peers_present((_ifp)->if_bpf)) { \ M_ASSERTVALID(_m); \ if (((_m)->m_flags & M_VLANTAG) != 0) \ diff --git a/sys/net/if.c b/sys/net/if.c index 8214a1bd7a18..738d73616c58 100644 --- a/sys/net/if.c +++ b/sys/net/if.c @@ -546,6 +546,8 @@ if_alloc_domain(u_char type, int numa_domain) #ifdef VIMAGE ifp->if_vnet = curvnet; #endif + /* XXX */ + ifp->if_flags |= IFF_NEEDSEPOCH; if (if_com_alloc[type] != NULL) { ifp->if_l2com = if_com_alloc[type](type, ifp); if (ifp->if_l2com == NULL) { @@ -4152,7 +4154,8 @@ if_setdrvflags(if_t ifp, int flags) int if_setflags(if_t ifp, int flags) { - ((struct ifnet *)ifp)->if_flags = flags; + /* XXX Temporary */ + ((struct ifnet *)ifp)->if_flags = flags | IFF_NEEDSEPOCH; return (0); } diff --git a/sys/netgraph/ng_base.c b/sys/netgraph/ng_base.c index 698696f13404..a009c33d09cd 100644 --- a/sys/netgraph/ng_base.c +++ b/sys/netgraph/ng_base.c @@ -3772,11 +3772,14 @@ ng_send_fn2(node_p node, hook_p hook, item_p pitem, ng_item_fn2 *fn, void *arg1, static void ng_callout_trampoline(void *arg) { + struct epoch_tracker et; item_p item = arg; + NET_EPOCH_ENTER(et); CURVNET_SET(NGI_NODE(item)->nd_vnet); ng_snd_item(item, 0); CURVNET_RESTORE(); + NET_EPOCH_EXIT(et); } int diff --git a/sys/netgraph/ng_device.c b/sys/netgraph/ng_device.c index b239982df28c..248572b6fd49 100644 --- a/sys/netgraph/ng_device.c +++ b/sys/netgraph/ng_device.c @@ -46,6 +46,8 @@ #include #include #include +#include +#include #include #include #include @@ -454,6 +456,7 @@ ngdread(struct cdev *dev, struct uio *uio, int flag) static int ngdwrite(struct cdev *dev, struct uio *uio, int flag) { + struct epoch_tracker et; priv_p priv = (priv_p )dev->si_drv1; struct mbuf *m; int error = 0; @@ -469,7 +472,9 @@ ngdwrite(struct cdev *dev, struct uio *uio, int flag) if ((m = m_uiotombuf(uio, M_NOWAIT, 0, 0, M_PKTHDR)) == NULL) return (ENOBUFS); + NET_EPOCH_ENTER(et); NG_SEND_DATA_ONLY(error, priv->hook, m); + NET_EPOCH_EXIT(et); return (error); } diff --git a/sys/netgraph/ng_socket.c b/sys/netgraph/ng_socket.c index 08ee76300ae8..6339ce0e2ccf 100644 --- a/sys/netgraph/ng_socket.c +++ b/sys/netgraph/ng_socket.c @@ -58,6 +58,8 @@ #include #include #include +#include +#include #include #include #include @@ -217,6 +219,7 @@ static int ngc_send(struct socket *so, int flags, struct mbuf *m, struct sockaddr *addr, struct mbuf *control, struct thread *td) { + struct epoch_tracker et; struct ngpcb *const pcbp = sotongpcb(so); struct ngsock *const priv = NG_NODE_PRIVATE(pcbp->sockdata->node); struct sockaddr_ng *const sap = (struct sockaddr_ng *) addr; @@ -335,7 +338,9 @@ ngc_send(struct socket *so, int flags, struct mbuf *m, struct sockaddr *addr, item->apply = &apply; priv->error = -1; + NET_EPOCH_ENTER(et); error = ng_snd_item(item, 0); + NET_EPOCH_EXIT(et); mtx_lock(&priv->mtx); if (priv->error == -1) @@ -403,6 +408,7 @@ static int ngd_send(struct socket *so, int flags, struct mbuf *m, struct sockaddr *addr, struct mbuf *control, struct thread *td) { + struct epoch_tracker et; struct ngpcb *const pcbp = sotongpcb(so); struct sockaddr_ng *const sap = (struct sockaddr_ng *) addr; int len, error; @@ -459,7 +465,9 @@ ngd_send(struct socket *so, int flags, struct mbuf *m, struct sockaddr *addr, } /* Send data. */ + NET_EPOCH_ENTER(et); NG_SEND_DATA_FLAGS(error, hook, m, NG_WAITOK); + NET_EPOCH_EXIT(et); release: if (control != NULL) diff --git a/sys/netinet/libalias/alias_db.c b/sys/netinet/libalias/alias_db.c index cf85f40161e7..b5ae64a7e33b 100644 --- a/sys/netinet/libalias/alias_db.c +++ b/sys/netinet/libalias/alias_db.c @@ -664,7 +664,7 @@ GetNewPort(struct libalias *la, struct alias_link *lnk, int alias_port_param) } #ifdef LIBALIAS_DEBUG - fprintf(stderr, "PacketAlias/GetnewPort(): "); + fprintf(stderr, "PacketAlias/GetNewPort(): "); fprintf(stderr, "could not find free port\n"); #endif diff --git a/sys/netinet/sctp_constants.h b/sys/netinet/sctp_constants.h index 7ee7e3117946..9da2ccaa9847 100644 --- a/sys/netinet/sctp_constants.h +++ b/sys/netinet/sctp_constants.h @@ -807,7 +807,7 @@ __FBSDID("$FreeBSD$"); #define SCTP_LOC_33 0x00000021 #define SCTP_LOC_34 0x00000022 #define SCTP_LOC_35 0x00000023 - +#define SCTP_LOC_36 0x00000024 /* Free assoc codes */ #define SCTP_NORMAL_PROC 0 diff --git a/sys/netinet/sctp_indata.c b/sys/netinet/sctp_indata.c index 830b5b4371c9..9229c8037edc 100644 --- a/sys/netinet/sctp_indata.c +++ b/sys/netinet/sctp_indata.c @@ -1754,7 +1754,7 @@ sctp_process_a_data_chunk(struct sctp_tcb *stcb, struct sctp_association *asoc, * Need to send an abort since we had a empty data chunk. */ op_err = sctp_generate_no_user_data_cause(tsn); - stcb->sctp_ep->last_abort_code = SCTP_FROM_SCTP_INDATA + SCTP_LOC_14; + stcb->sctp_ep->last_abort_code = SCTP_FROM_SCTP_INDATA + SCTP_LOC_15; sctp_abort_an_association(stcb->sctp_ep, stcb, op_err, SCTP_SO_NOT_LOCKED); *abort_flag = 1; return (0); @@ -1892,7 +1892,7 @@ sctp_process_a_data_chunk(struct sctp_tcb *stcb, struct sctp_association *asoc, snprintf(msg, sizeof(msg), "Reassembly problem (MID=%8.8x)", mid); err_out: op_err = sctp_generate_cause(SCTP_CAUSE_PROTOCOL_VIOLATION, msg); - stcb->sctp_ep->last_abort_code = SCTP_FROM_SCTP_INDATA + SCTP_LOC_15; + stcb->sctp_ep->last_abort_code = SCTP_FROM_SCTP_INDATA + SCTP_LOC_16; sctp_abort_an_association(stcb->sctp_ep, stcb, op_err, SCTP_SO_NOT_LOCKED); *abort_flag = 1; return (0); @@ -2041,7 +2041,7 @@ sctp_process_a_data_chunk(struct sctp_tcb *stcb, struct sctp_association *asoc, (uint16_t)mid); } op_err = sctp_generate_cause(SCTP_CAUSE_PROTOCOL_VIOLATION, msg); - stcb->sctp_ep->last_abort_code = SCTP_FROM_SCTP_INDATA + SCTP_LOC_16; + stcb->sctp_ep->last_abort_code = SCTP_FROM_SCTP_INDATA + SCTP_LOC_17; sctp_abort_an_association(stcb->sctp_ep, stcb, op_err, SCTP_SO_NOT_LOCKED); *abort_flag = 1; return (0); @@ -2613,7 +2613,7 @@ sctp_sack_check(struct sctp_tcb *stcb, int was_a_gap) if (SCTP_OS_TIMER_PENDING(&stcb->asoc.dack_timer.timer)) { sctp_timer_stop(SCTP_TIMER_TYPE_RECV, stcb->sctp_ep, stcb, NULL, - SCTP_FROM_SCTP_INDATA + SCTP_LOC_17); + SCTP_FROM_SCTP_INDATA + SCTP_LOC_18); } sctp_send_shutdown(stcb, ((stcb->asoc.alternate) ? stcb->asoc.alternate : stcb->asoc.primary_destination)); @@ -2766,7 +2766,7 @@ sctp_process_data(struct mbuf **mm, int iphlen, int *offset, int length, snprintf(msg, sizeof(msg), "%s", "I-DATA chunk received when DATA was negotiated"); op_err = sctp_generate_cause(SCTP_CAUSE_PROTOCOL_VIOLATION, msg); - stcb->sctp_ep->last_abort_code = SCTP_FROM_SCTP_INDATA + SCTP_LOC_18; + stcb->sctp_ep->last_abort_code = SCTP_FROM_SCTP_INDATA + SCTP_LOC_20; sctp_abort_an_association(inp, stcb, op_err, SCTP_SO_NOT_LOCKED); return (2); } @@ -2777,7 +2777,7 @@ sctp_process_data(struct mbuf **mm, int iphlen, int *offset, int length, snprintf(msg, sizeof(msg), "%s", "DATA chunk received when I-DATA was negotiated"); op_err = sctp_generate_cause(SCTP_CAUSE_PROTOCOL_VIOLATION, msg); - stcb->sctp_ep->last_abort_code = SCTP_FROM_SCTP_INDATA + SCTP_LOC_19; + stcb->sctp_ep->last_abort_code = SCTP_FROM_SCTP_INDATA + SCTP_LOC_21; sctp_abort_an_association(inp, stcb, op_err, SCTP_SO_NOT_LOCKED); return (2); } @@ -2802,7 +2802,7 @@ sctp_process_data(struct mbuf **mm, int iphlen, int *offset, int length, ch->chunk_type == SCTP_DATA ? "DATA" : "I-DATA", chk_length); op_err = sctp_generate_cause(SCTP_CAUSE_PROTOCOL_VIOLATION, msg); - stcb->sctp_ep->last_abort_code = SCTP_FROM_SCTP_INDATA + SCTP_LOC_20; + stcb->sctp_ep->last_abort_code = SCTP_FROM_SCTP_INDATA + SCTP_LOC_22; sctp_abort_an_association(inp, stcb, op_err, SCTP_SO_NOT_LOCKED); return (2); } @@ -2891,7 +2891,7 @@ sctp_process_data(struct mbuf **mm, int iphlen, int *offset, int length, snprintf(msg, sizeof(msg), "Chunk of length %u", chk_length); op_err = sctp_generate_cause(SCTP_CAUSE_PROTOCOL_VIOLATION, msg); - stcb->sctp_ep->last_abort_code = SCTP_FROM_SCTP_INDATA + SCTP_LOC_20; + stcb->sctp_ep->last_abort_code = SCTP_FROM_SCTP_INDATA + SCTP_LOC_23; sctp_abort_an_association(inp, stcb, op_err, SCTP_SO_NOT_LOCKED); return (2); } @@ -4041,7 +4041,7 @@ sctp_express_handle_sack(struct sctp_tcb *stcb, uint32_t cumack, snprintf(msg, sizeof(msg), "Cum ack %8.8x greater or equal than TSN %8.8x", cumack, send_s); op_err = sctp_generate_cause(SCTP_CAUSE_PROTOCOL_VIOLATION, msg); - stcb->sctp_ep->last_abort_code = SCTP_FROM_SCTP_INDATA + SCTP_LOC_21; + stcb->sctp_ep->last_abort_code = SCTP_FROM_SCTP_INDATA + SCTP_LOC_24; sctp_abort_an_association(stcb->sctp_ep, stcb, op_err, SCTP_SO_NOT_LOCKED); return; } @@ -4237,7 +4237,7 @@ sctp_express_handle_sack(struct sctp_tcb *stcb, uint32_t cumack, net->dest_state &= ~SCTP_ADDR_PF; sctp_timer_stop(SCTP_TIMER_TYPE_HEARTBEAT, stcb->sctp_ep, stcb, net, - SCTP_FROM_SCTP_INDATA + SCTP_LOC_22); + SCTP_FROM_SCTP_INDATA + SCTP_LOC_25); sctp_timer_start(SCTP_TIMER_TYPE_HEARTBEAT, stcb->sctp_ep, stcb, net); asoc->cc_functions.sctp_cwnd_update_exit_pf(stcb, net); /* Done with this net */ @@ -4315,7 +4315,7 @@ sctp_express_handle_sack(struct sctp_tcb *stcb, uint32_t cumack, } else if (SCTP_OS_TIMER_PENDING(&net->rxt_timer.timer)) { sctp_timer_stop(SCTP_TIMER_TYPE_SEND, stcb->sctp_ep, stcb, net, - SCTP_FROM_SCTP_INDATA + SCTP_LOC_23); + SCTP_FROM_SCTP_INDATA + SCTP_LOC_26); } } } @@ -4368,7 +4368,7 @@ sctp_express_handle_sack(struct sctp_tcb *stcb, uint32_t cumack, *abort_now = 1; /* XXX */ op_err = sctp_generate_cause(SCTP_CAUSE_USER_INITIATED_ABT, ""); - stcb->sctp_ep->last_abort_code = SCTP_FROM_SCTP_INDATA + SCTP_LOC_24; + stcb->sctp_ep->last_abort_code = SCTP_FROM_SCTP_INDATA + SCTP_LOC_27; sctp_abort_an_association(stcb->sctp_ep, stcb, op_err, SCTP_SO_NOT_LOCKED); return; } @@ -4578,7 +4578,7 @@ sctp_handle_sack(struct mbuf *m, int offset_seg, int offset_dup, snprintf(msg, sizeof(msg), "Cum ack %8.8x greater or equal than TSN %8.8x", cum_ack, send_s); op_err = sctp_generate_cause(SCTP_CAUSE_PROTOCOL_VIOLATION, msg); - stcb->sctp_ep->last_abort_code = SCTP_FROM_SCTP_INDATA + SCTP_LOC_25; + stcb->sctp_ep->last_abort_code = SCTP_FROM_SCTP_INDATA + SCTP_LOC_28; sctp_abort_an_association(stcb->sctp_ep, stcb, op_err, SCTP_SO_NOT_LOCKED); return; } @@ -4610,7 +4610,7 @@ sctp_handle_sack(struct mbuf *m, int offset_seg, int offset_dup, /* stop any timers */ TAILQ_FOREACH(net, &asoc->nets, sctp_next) { sctp_timer_stop(SCTP_TIMER_TYPE_SEND, stcb->sctp_ep, - stcb, net, SCTP_FROM_SCTP_INDATA + SCTP_LOC_26); + stcb, net, SCTP_FROM_SCTP_INDATA + SCTP_LOC_29); net->partial_bytes_acked = 0; net->flight_size = 0; } @@ -4810,14 +4810,14 @@ sctp_handle_sack(struct mbuf *m, int offset_seg, int offset_dup, if (net->new_pseudo_cumack) sctp_timer_stop(SCTP_TIMER_TYPE_SEND, stcb->sctp_ep, stcb, net, - SCTP_FROM_SCTP_INDATA + SCTP_LOC_27); + SCTP_FROM_SCTP_INDATA + SCTP_LOC_30); } } else { if (accum_moved) { TAILQ_FOREACH(net, &asoc->nets, sctp_next) { sctp_timer_stop(SCTP_TIMER_TYPE_SEND, stcb->sctp_ep, - stcb, net, SCTP_FROM_SCTP_INDATA + SCTP_LOC_28); + stcb, net, SCTP_FROM_SCTP_INDATA + SCTP_LOC_31); } } } @@ -5000,7 +5000,7 @@ sctp_handle_sack(struct mbuf *m, int offset_seg, int offset_dup, net->dest_state &= ~SCTP_ADDR_PF; sctp_timer_stop(SCTP_TIMER_TYPE_HEARTBEAT, stcb->sctp_ep, stcb, net, - SCTP_FROM_SCTP_INDATA + SCTP_LOC_29); + SCTP_FROM_SCTP_INDATA + SCTP_LOC_32); sctp_timer_start(SCTP_TIMER_TYPE_HEARTBEAT, stcb->sctp_ep, stcb, net); asoc->cc_functions.sctp_cwnd_update_exit_pf(stcb, net); /* Done with this net */ @@ -5025,7 +5025,7 @@ sctp_handle_sack(struct mbuf *m, int offset_seg, int offset_dup, /* stop all timers */ sctp_timer_stop(SCTP_TIMER_TYPE_SEND, stcb->sctp_ep, stcb, net, - SCTP_FROM_SCTP_INDATA + SCTP_LOC_30); + SCTP_FROM_SCTP_INDATA + SCTP_LOC_33); net->flight_size = 0; net->partial_bytes_acked = 0; } @@ -5063,7 +5063,7 @@ sctp_handle_sack(struct mbuf *m, int offset_seg, int offset_dup, *abort_now = 1; /* XXX */ op_err = sctp_generate_cause(SCTP_CAUSE_USER_INITIATED_ABT, ""); - stcb->sctp_ep->last_abort_code = SCTP_FROM_SCTP_INDATA + SCTP_LOC_24; + stcb->sctp_ep->last_abort_code = SCTP_FROM_SCTP_INDATA + SCTP_LOC_34; sctp_abort_an_association(stcb->sctp_ep, stcb, op_err, SCTP_SO_NOT_LOCKED); return; } @@ -5212,7 +5212,7 @@ sctp_handle_sack(struct mbuf *m, int offset_seg, int offset_dup, } else if (SCTP_OS_TIMER_PENDING(&net->rxt_timer.timer)) { sctp_timer_stop(SCTP_TIMER_TYPE_SEND, stcb->sctp_ep, stcb, net, - SCTP_FROM_SCTP_INDATA + SCTP_LOC_32); + SCTP_FROM_SCTP_INDATA + SCTP_LOC_35); } } } @@ -5618,7 +5618,7 @@ sctp_handle_forward_tsn(struct sctp_tcb *stcb, "New cum ack %8.8x too high, highest TSN %8.8x", new_cum_tsn, asoc->highest_tsn_inside_map); op_err = sctp_generate_cause(SCTP_CAUSE_PROTOCOL_VIOLATION, msg); - stcb->sctp_ep->last_abort_code = SCTP_FROM_SCTP_INDATA + SCTP_LOC_33; + stcb->sctp_ep->last_abort_code = SCTP_FROM_SCTP_INDATA + SCTP_LOC_36; sctp_abort_an_association(stcb->sctp_ep, stcb, op_err, SCTP_SO_NOT_LOCKED); return; } diff --git a/sys/netinet/sctp_pcb.c b/sys/netinet/sctp_pcb.c index 509b34956366..d07b89933dec 100644 --- a/sys/netinet/sctp_pcb.c +++ b/sys/netinet/sctp_pcb.c @@ -2746,7 +2746,6 @@ sctp_move_pcb_and_assoc(struct sctp_inpcb *old_inp, struct sctp_inpcb *new_inp, stcb->asoc.strreset_timer.ep = (void *)new_inp; stcb->asoc.shut_guard_timer.ep = (void *)new_inp; stcb->asoc.autoclose_timer.ep = (void *)new_inp; - stcb->asoc.delayed_event_timer.ep = (void *)new_inp; stcb->asoc.delete_prim_timer.ep = (void *)new_inp; /* now what about the nets? */ TAILQ_FOREACH(net, &stcb->asoc.nets, sctp_next) { @@ -4407,7 +4406,6 @@ sctp_aloc_assoc(struct sctp_inpcb *inp, struct sockaddr *firstaddr, SCTP_OS_TIMER_INIT(&asoc->asconf_timer.timer); SCTP_OS_TIMER_INIT(&asoc->shut_guard_timer.timer); SCTP_OS_TIMER_INIT(&asoc->autoclose_timer.timer); - SCTP_OS_TIMER_INIT(&asoc->delayed_event_timer.timer); SCTP_OS_TIMER_INIT(&asoc->delete_prim_timer.timer); LIST_INSERT_HEAD(&inp->sctp_asoc_list, stcb, sctp_tcblist); @@ -4781,8 +4779,6 @@ sctp_free_assoc(struct sctp_inpcb *inp, struct sctp_tcb *stcb, int from_inpcbfre asoc->autoclose_timer.self = NULL; (void)SCTP_OS_TIMER_STOP(&asoc->shut_guard_timer.timer); asoc->shut_guard_timer.self = NULL; - (void)SCTP_OS_TIMER_STOP(&asoc->delayed_event_timer.timer); - asoc->delayed_event_timer.self = NULL; /* Mobility adaptation */ (void)SCTP_OS_TIMER_STOP(&asoc->delete_prim_timer.timer); asoc->delete_prim_timer.self = NULL; @@ -4967,7 +4963,6 @@ sctp_free_assoc(struct sctp_inpcb *inp, struct sctp_tcb *stcb, int from_inpcbfre (void)SCTP_OS_TIMER_STOP(&asoc->asconf_timer.timer); (void)SCTP_OS_TIMER_STOP(&asoc->shut_guard_timer.timer); (void)SCTP_OS_TIMER_STOP(&asoc->autoclose_timer.timer); - (void)SCTP_OS_TIMER_STOP(&asoc->delayed_event_timer.timer); TAILQ_FOREACH(net, &asoc->nets, sctp_next) { (void)SCTP_OS_TIMER_STOP(&net->rxt_timer.timer); (void)SCTP_OS_TIMER_STOP(&net->pmtu_timer.timer); diff --git a/sys/netinet/sctp_structs.h b/sys/netinet/sctp_structs.h index 451ae72bce34..f7e2a2c41732 100644 --- a/sys/netinet/sctp_structs.h +++ b/sys/netinet/sctp_structs.h @@ -806,7 +806,6 @@ struct sctp_association { struct sctp_timer strreset_timer; /* stream reset */ struct sctp_timer shut_guard_timer; /* shutdown guard */ struct sctp_timer autoclose_timer; /* automatic close timer */ - struct sctp_timer delayed_event_timer; /* timer for delayed events */ struct sctp_timer delete_prim_timer; /* deleting primary dst */ /* list of restricted local addresses */ diff --git a/sys/netinet/sctputil.c b/sys/netinet/sctputil.c index cbda6e2c4948..2804a59dac6a 100644 --- a/sys/netinet/sctputil.c +++ b/sys/netinet/sctputil.c @@ -789,7 +789,6 @@ sctp_stop_timers_for_shutdown(struct sctp_tcb *stcb) (void)SCTP_OS_TIMER_STOP(&asoc->strreset_timer.timer); (void)SCTP_OS_TIMER_STOP(&asoc->asconf_timer.timer); (void)SCTP_OS_TIMER_STOP(&asoc->autoclose_timer.timer); - (void)SCTP_OS_TIMER_STOP(&asoc->delayed_event_timer.timer); TAILQ_FOREACH(net, &asoc->nets, sctp_next) { (void)SCTP_OS_TIMER_STOP(&net->pmtu_timer.timer); (void)SCTP_OS_TIMER_STOP(&net->hb_timer.timer); diff --git a/sys/powerpc/aim/aim_machdep.c b/sys/powerpc/aim/aim_machdep.c index 22704dff29ac..a5939c8db127 100644 --- a/sys/powerpc/aim/aim_machdep.c +++ b/sys/powerpc/aim/aim_machdep.c @@ -251,8 +251,25 @@ aim_cpu_init(vm_offset_t toc) psl_userset32 = psl_userset & ~PSL_SF; #endif - /* Bits that users aren't allowed to change */ - psl_userstatic = ~(PSL_VEC | PSL_FP | PSL_FE0 | PSL_FE1); + /* + * Zeroed bits in this variable signify that the value of the bit + * in its position is allowed to vary between userspace contexts. + * + * All other bits are required to be identical for every userspace + * context. The actual *value* of the bit is determined by + * psl_userset and/or psl_userset32, and is not allowed to change. + * + * Remember to update this set when implementing support for + * *conditionally* enabling a processor facility. Failing to do + * this will cause swapcontext() in userspace to break when a + * process uses a conditionally-enabled facility. + * + * When *unconditionally* implementing support for a processor + * facility, update psl_userset / psl_userset32 instead. + * + * See the access control check in set_mcontext(). + */ + psl_userstatic = ~(PSL_VSX | PSL_VEC | PSL_FP | PSL_FE0 | PSL_FE1); /* * Mask bits from the SRR1 that aren't really the MSR: * Bits 1-4, 10-15 (ppc32), 33-36, 42-47 (ppc64) diff --git a/sys/powerpc/aim/slb.c b/sys/powerpc/aim/slb.c index fad4c04c69a6..ab9dde4ee69b 100644 --- a/sys/powerpc/aim/slb.c +++ b/sys/powerpc/aim/slb.c @@ -523,12 +523,18 @@ slb_uma_real_alloc(uma_zone_t zone, vm_size_t bytes, int domain, static void slb_zone_init(void *dummy) { + uint32_t allocf_flags; + + allocf_flags = 0; + if (platform_real_maxaddr() != VM_MAX_ADDRESS) + allocf_flags = UMA_ZONE_CONTIG; slbt_zone = uma_zcreate("SLB tree node", sizeof(struct slbtnode), - NULL, NULL, NULL, NULL, UMA_ALIGN_PTR, UMA_ZONE_VM); + NULL, NULL, NULL, NULL, UMA_ALIGN_PTR, + allocf_flags | UMA_ZONE_VM); slb_cache_zone = uma_zcreate("SLB cache", (n_slbs + 1)*sizeof(struct slb *), NULL, NULL, NULL, NULL, - UMA_ALIGN_PTR, UMA_ZONE_VM); + UMA_ALIGN_PTR, allocf_flags | UMA_ZONE_VM); if (platform_real_maxaddr() != VM_MAX_ADDRESS) { uma_zone_set_allocf(slb_cache_zone, slb_uma_real_alloc); diff --git a/sys/powerpc/booke/booke_machdep.c b/sys/powerpc/booke/booke_machdep.c index e95d1c886f8e..6def6c6d681b 100644 --- a/sys/powerpc/booke/booke_machdep.c +++ b/sys/powerpc/booke/booke_machdep.c @@ -222,6 +222,24 @@ booke_cpu_init(void) #ifdef __powerpc64__ psl_userset32 = psl_userset & ~PSL_CM; #endif + /* + * Zeroed bits in this variable signify that the value of the bit + * in its position is allowed to vary between userspace contexts. + * + * All other bits are required to be identical for every userspace + * context. The actual *value* of the bit is determined by + * psl_userset and/or psl_userset32, and is not allowed to change. + * + * Remember to update this set when implementing support for + * *conditionally* enabling a processor facility. Failing to do + * this will cause swapcontext() in userspace to break when a + * process uses a conditionally-enabled facility. + * + * When *unconditionally* implementing support for a processor + * facility, update psl_userset / psl_userset32 instead. + * + * See the access control check in set_mcontext(). + */ psl_userstatic = ~(PSL_VEC | PSL_FP | PSL_FE0 | PSL_FE1); pmap_mmu_install(MMU_TYPE_BOOKE, BUS_PROBE_GENERIC); diff --git a/sys/powerpc/include/param.h b/sys/powerpc/include/param.h index 8c43f5a8faae..c7726049fc1a 100644 --- a/sys/powerpc/include/param.h +++ b/sys/powerpc/include/param.h @@ -73,13 +73,13 @@ #endif #endif -#if defined(SMP) || defined(KLD_MODULE) +#ifdef SMP #ifndef MAXCPU #define MAXCPU 256 #endif #else #define MAXCPU 1 -#endif /* SMP || KLD_MODULE */ +#endif #ifndef MAXMEMDOM #define MAXMEMDOM 8 diff --git a/sys/powerpc/powerpc/exec_machdep.c b/sys/powerpc/powerpc/exec_machdep.c index 8bbb7b38d7f0..e67a6a3349ff 100644 --- a/sys/powerpc/powerpc/exec_machdep.c +++ b/sys/powerpc/powerpc/exec_machdep.c @@ -463,7 +463,17 @@ set_mcontext(struct thread *td, mcontext_t *mcp) return (EINVAL); /* - * Don't let the user set privileged MSR bits + * Don't let the user change privileged MSR bits. + * + * psl_userstatic is used here to mask off any bits that can + * legitimately vary between user contexts (Floating point + * exception control and any facilities that we are using the + * "enable on first use" pattern with.) + * + * All other bits are required to match psl_userset(32). + * + * Remember to update the platform cpu_init code when implementing + * support for a new conditional facility! */ if ((mcp->mc_srr1 & psl_userstatic) != (tf->srr1 & psl_userstatic)) { return (EINVAL); @@ -480,9 +490,19 @@ set_mcontext(struct thread *td, mcontext_t *mcp) else tf->fixreg[2] = tls; - /* Disable FPU */ - tf->srr1 &= ~PSL_FP; - pcb->pcb_flags &= ~PCB_FPU; + /* + * Force the FPU back off to ensure the new context will not bypass + * the enable_fpu() setup code accidentally. + * + * This prevents an issue where a process that uses floating point + * inside a signal handler could end up in a state where the MSR + * did not match pcb_flags. + * + * Additionally, ensure VSX is disabled as well, as it is illegal + * to leave it turned on when FP or VEC are off. + */ + tf->srr1 &= ~(PSL_FP | PSL_VSX); + pcb->pcb_flags &= ~(PCB_FPU | PCB_VSX); if (mcp->mc_flags & _MC_FP_VALID) { /* enable_fpu() will happen lazily on a fault */ @@ -506,6 +526,9 @@ set_mcontext(struct thread *td, mcontext_t *mcp) pcb->pcb_vec.vscr = mcp->mc_vscr; pcb->pcb_vec.vrsave = mcp->mc_vrsave; memcpy(pcb->pcb_vec.vr, mcp->mc_avec, sizeof(mcp->mc_avec)); + } else { + tf->srr1 &= ~PSL_VEC; + pcb->pcb_flags &= ~PCB_VEC; } return (0); diff --git a/sys/riscv/include/db_machdep.h b/sys/riscv/include/db_machdep.h index 9271a2757cb8..d32e3bc53419 100644 --- a/sys/riscv/include/db_machdep.h +++ b/sys/riscv/include/db_machdep.h @@ -53,8 +53,14 @@ typedef long db_expr_t; #define BKPT_SIZE (INSN_SIZE) #define BKPT_SET(inst) (BKPT_INST) -#define BKPT_SKIP do { \ - kdb_frame->tf_sepc += BKPT_SIZE; \ +#define BKPT_SKIP do { \ + uint32_t _instr; \ + \ + _instr = db_get_value(PC_REGS(), sizeof(uint32_t), FALSE); \ + if ((_instr & 0x3) == 0x3) \ + kdb_frame->tf_sepc += 4; /* ebreak */ \ + else \ + kdb_frame->tf_sepc += 2; /* c.ebreak */ \ } while (0) #define db_clear_single_step kdb_cpu_clear_singlestep diff --git a/sys/riscv/include/param.h b/sys/riscv/include/param.h index 4b4610bea8d1..94e18c580417 100644 --- a/sys/riscv/include/param.h +++ b/sys/riscv/include/param.h @@ -49,13 +49,13 @@ #define MACHINE_ARCH "riscv64" #endif -#if defined(SMP) || defined(KLD_MODULE) +#ifdef SMP #ifndef MAXCPU #define MAXCPU 16 #endif #else #define MAXCPU 1 -#endif /* SMP || KLD_MODULE */ +#endif #ifndef MAXMEMDOM #define MAXMEMDOM 1 diff --git a/sys/riscv/include/riscvreg.h b/sys/riscv/include/riscvreg.h index b0a6518933d1..55606e70adf2 100644 --- a/sys/riscv/include/riscvreg.h +++ b/sys/riscv/include/riscvreg.h @@ -37,8 +37,7 @@ #ifndef _MACHINE_RISCVREG_H_ #define _MACHINE_RISCVREG_H_ -#define EXCP_SHIFT 0 -#define EXCP_MASK (0xf << EXCP_SHIFT) +#define EXCP_MASK (~EXCP_INTR) #define EXCP_MISALIGNED_FETCH 0 #define EXCP_FAULT_FETCH 1 #define EXCP_ILLEGAL_INSTRUCTION 2 diff --git a/sys/riscv/riscv/db_trace.c b/sys/riscv/riscv/db_trace.c index 6c45e070a981..2a783b2ed0f0 100644 --- a/sys/riscv/riscv/db_trace.c +++ b/sys/riscv/riscv/db_trace.c @@ -2,6 +2,7 @@ * Copyright (c) 2015 The FreeBSD Foundation * Copyright (c) 2016 Ruslan Bukin * All rights reserved. + * Copyright (c) 2020 John Baldwin * * Portions of this software were developed by Semihalf under * the sponsorship of the FreeBSD Foundation. @@ -38,15 +39,18 @@ #include __FBSDID("$FreeBSD$"); + #include -#include #include -#include +#include + #include #include +#include #include #include +#include void db_md_list_watchpoints() @@ -80,9 +84,6 @@ db_stack_trace_cmd(struct unwind_state *frame) while (1) { pc = frame->pc; - if (unwind_frame(frame) < 0) - break; - sym = db_search_symbol(pc, DB_STGY_ANY, &offset); if (sym == C_DB_SYM_NULL) { value = 0; @@ -94,11 +95,32 @@ db_stack_trace_cmd(struct unwind_state *frame) db_printsym(frame->pc, DB_STGY_PROC); db_printf("\n"); - db_printf("\t pc = 0x%016lx ra = 0x%016lx\n", - pc, frame->pc); - db_printf("\t sp = 0x%016lx fp = 0x%016lx\n", - frame->sp, frame->fp); - db_printf("\n"); + if (strcmp(name, "cpu_exception_handler_supervisor") == 0 || + strcmp(name, "cpu_exception_handler_user") == 0) { + struct trapframe *tf; + + tf = (struct trapframe *)(uintptr_t)frame->sp; + + if (tf->tf_scause & EXCP_INTR) + db_printf("--- interrupt %ld\n", + tf->tf_scause & EXCP_MASK); + else + db_printf("--- exception %ld, tval = %#lx\n", + tf->tf_scause & EXCP_MASK, + tf->tf_stval); + frame->sp = (uint64_t)tf->tf_sp; + frame->fp = (uint64_t)tf->tf_s[0]; + frame->pc = (uint64_t)tf->tf_sepc; + if (!INKERNEL(frame->fp)) + break; + continue; + } + + if (strcmp(name, "fork_trampoline") == 0) + break; + + if (unwind_frame(frame) < 0) + break; } } @@ -108,15 +130,12 @@ db_trace_thread(struct thread *thr, int count) struct unwind_state frame; struct pcb *ctx; - if (thr != curthread) { - ctx = kdb_thr_ctx(thr); + ctx = kdb_thr_ctx(thr); - frame.sp = (uint64_t)ctx->pcb_sp; - frame.fp = (uint64_t)ctx->pcb_s[0]; - frame.pc = (uint64_t)ctx->pcb_ra; - db_stack_trace_cmd(&frame); - } else - db_trace_self(); + frame.sp = (uint64_t)ctx->pcb_sp; + frame.fp = (uint64_t)ctx->pcb_s[0]; + frame.pc = (uint64_t)ctx->pcb_ra; + db_stack_trace_cmd(&frame); return (0); } diff --git a/sys/riscv/riscv/machdep.c b/sys/riscv/riscv/machdep.c index 488d024d26d8..83e54e4fc49a 100644 --- a/sys/riscv/riscv/machdep.c +++ b/sys/riscv/riscv/machdep.c @@ -571,7 +571,7 @@ makectx(struct trapframe *tf, struct pcb *pcb) memcpy(pcb->pcb_s, tf->tf_s, sizeof(tf->tf_s)); - pcb->pcb_ra = tf->tf_ra; + pcb->pcb_ra = tf->tf_sepc; pcb->pcb_sp = tf->tf_sp; pcb->pcb_gp = tf->tf_gp; pcb->pcb_tp = tf->tf_tp; diff --git a/sys/riscv/riscv/riscv_console.c b/sys/riscv/riscv/riscv_console.c index df6aba155e11..abedf8fa8c55 100644 --- a/sys/riscv/riscv/riscv_console.c +++ b/sys/riscv/riscv/riscv_console.c @@ -206,20 +206,6 @@ riscv_cngetc(struct consdev *cp) { int ch; -#if defined(KDB) - /* - * RISCVTODO: BBL polls for console data on timer interrupt, - * but interrupts are turned off in KDB. - * So we currently do not have console in KDB. - */ - if (kdb_active) { - ch = sbi_console_getchar(); - while (ch) { - ch = sbi_console_getchar(); - } - } -#endif - ch = sbi_console_getchar(); if (ch > 0 && ch < 0xff) { #if defined(KDB) diff --git a/sys/riscv/riscv/trap.c b/sys/riscv/riscv/trap.c index 8a4b4e9f8631..f6d547fe5f3f 100644 --- a/sys/riscv/riscv/trap.c +++ b/sys/riscv/riscv/trap.c @@ -245,12 +245,10 @@ void do_trap_supervisor(struct trapframe *frame) { uint64_t exception; - uint64_t sstatus; /* Ensure we came from supervisor mode, interrupts disabled */ - __asm __volatile("csrr %0, sstatus" : "=&r" (sstatus)); - KASSERT((sstatus & (SSTATUS_SPP | SSTATUS_SIE)) == SSTATUS_SPP, - ("We must came from S mode with interrupts disabled")); + KASSERT((csr_read(sstatus) & (SSTATUS_SPP | SSTATUS_SIE)) == + SSTATUS_SPP, ("Came from S mode with interrupts enabled")); exception = (frame->tf_scause & EXCP_MASK); if (frame->tf_scause & EXCP_INTR) { @@ -305,7 +303,6 @@ do_trap_user(struct trapframe *frame) { uint64_t exception; struct thread *td; - uint64_t sstatus; struct pcb *pcb; td = curthread; @@ -313,9 +310,8 @@ do_trap_user(struct trapframe *frame) pcb = td->td_pcb; /* Ensure we came from usermode, interrupts disabled */ - __asm __volatile("csrr %0, sstatus" : "=&r" (sstatus)); - KASSERT((sstatus & (SSTATUS_SPP | SSTATUS_SIE)) == 0, - ("We must came from U mode with interrupts disabled")); + KASSERT((csr_read(sstatus) & (SSTATUS_SPP | SSTATUS_SIE)) == 0, + ("Came from U mode with interrupts enabled")); exception = (frame->tf_scause & EXCP_MASK); if (frame->tf_scause & EXCP_INTR) { diff --git a/sys/sparc64/central/central.c b/sys/sparc64/central/central.c deleted file mode 100644 index a376fd2bee20..000000000000 --- a/sys/sparc64/central/central.c +++ /dev/null @@ -1,301 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD - * - * Copyright (c) 2003 Jake Burkholder. - * 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 -__FBSDID("$FreeBSD$"); - -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include -#include - -#include - -#include - -struct central_devinfo { - struct ofw_bus_devinfo cdi_obdinfo; - struct resource_list cdi_rl; -}; - -struct central_softc { - int sc_nrange; - struct sbus_ranges *sc_ranges; -}; - -static device_probe_t central_probe; -static device_attach_t central_attach; -static bus_print_child_t central_print_child; -static bus_probe_nomatch_t central_probe_nomatch; -static bus_alloc_resource_t central_alloc_resource; -static bus_adjust_resource_t central_adjust_resource; -static bus_get_resource_list_t central_get_resource_list; -static ofw_bus_get_devinfo_t central_get_devinfo; - -static int central_print_res(struct central_devinfo *); - -static device_method_t central_methods[] = { - /* Device interface */ - DEVMETHOD(device_probe, central_probe), - DEVMETHOD(device_attach, central_attach), - DEVMETHOD(device_shutdown, bus_generic_shutdown), - DEVMETHOD(device_suspend, bus_generic_suspend), - DEVMETHOD(device_resume, bus_generic_resume), - - /* Bus interface */ - DEVMETHOD(bus_print_child, central_print_child), - DEVMETHOD(bus_probe_nomatch, central_probe_nomatch), - DEVMETHOD(bus_alloc_resource, central_alloc_resource), - DEVMETHOD(bus_activate_resource, bus_generic_activate_resource), - DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource), - DEVMETHOD(bus_adjust_resource, central_adjust_resource), - DEVMETHOD(bus_release_resource, bus_generic_rl_release_resource), - DEVMETHOD(bus_setup_intr, bus_generic_setup_intr), - DEVMETHOD(bus_teardown_intr, bus_generic_teardown_intr), - DEVMETHOD(bus_get_resource, bus_generic_rl_get_resource), - DEVMETHOD(bus_get_resource_list, central_get_resource_list), - DEVMETHOD(bus_child_pnpinfo_str, ofw_bus_gen_child_pnpinfo_str), - - /* ofw_bus interface */ - DEVMETHOD(ofw_bus_get_devinfo, central_get_devinfo), - DEVMETHOD(ofw_bus_get_compat, ofw_bus_gen_get_compat), - DEVMETHOD(ofw_bus_get_model, ofw_bus_gen_get_model), - DEVMETHOD(ofw_bus_get_name, ofw_bus_gen_get_name), - DEVMETHOD(ofw_bus_get_node, ofw_bus_gen_get_node), - DEVMETHOD(ofw_bus_get_type, ofw_bus_gen_get_type), - - DEVMETHOD_END -}; - -static driver_t central_driver = { - "central", - central_methods, - sizeof(struct central_softc), -}; - -static devclass_t central_devclass; - -EARLY_DRIVER_MODULE(central, nexus, central_driver, central_devclass, 0, 0, - BUS_PASS_BUS); -MODULE_DEPEND(fhc, nexus, 1, 1, 1); -MODULE_VERSION(central, 1); - -static int -central_probe(device_t dev) -{ - - if (strcmp(ofw_bus_get_name(dev), "central") == 0) { - device_set_desc(dev, "central"); - return (0); - } - return (ENXIO); -} - -static int -central_attach(device_t dev) -{ - struct central_devinfo *cdi; - struct sbus_regs *reg; - struct central_softc *sc; - phandle_t child; - phandle_t node; - device_t cdev; - int nreg; - int i; - - sc = device_get_softc(dev); - node = ofw_bus_get_node(dev); - - sc->sc_nrange = OF_getprop_alloc_multi(node, "ranges", - sizeof(*sc->sc_ranges), (void **)&sc->sc_ranges); - if (sc->sc_nrange == -1) { - device_printf(dev, "can't get ranges\n"); - return (ENXIO); - } - - for (child = OF_child(node); child != 0; child = OF_peer(child)) { - cdi = malloc(sizeof(*cdi), M_DEVBUF, M_WAITOK | M_ZERO); - if (ofw_bus_gen_setup_devinfo(&cdi->cdi_obdinfo, child) != 0) { - free(cdi, M_DEVBUF); - continue; - } - nreg = OF_getprop_alloc_multi(child, "reg", sizeof(*reg), - (void **)®); - if (nreg == -1) { - device_printf(dev, "<%s>: incomplete\n", - cdi->cdi_obdinfo.obd_name); - ofw_bus_gen_destroy_devinfo(&cdi->cdi_obdinfo); - free(cdi, M_DEVBUF); - continue; - } - resource_list_init(&cdi->cdi_rl); - for (i = 0; i < nreg; i++) - resource_list_add(&cdi->cdi_rl, SYS_RES_MEMORY, i, - reg[i].sbr_offset, reg[i].sbr_offset + - reg[i].sbr_size, reg[i].sbr_size); - OF_prop_free(reg); - cdev = device_add_child(dev, NULL, -1); - if (cdev == NULL) { - device_printf(dev, "<%s>: device_add_child failed\n", - cdi->cdi_obdinfo.obd_name); - resource_list_free(&cdi->cdi_rl); - ofw_bus_gen_destroy_devinfo(&cdi->cdi_obdinfo); - free(cdi, M_DEVBUF); - continue; - } - device_set_ivars(cdev, cdi); - } - - return (bus_generic_attach(dev)); -} - -static int -central_adjust_resource(device_t bus __unused, device_t child __unused, - int type __unused, struct resource *r __unused, rman_res_t start __unused, - rman_res_t end __unused) -{ - - return (ENXIO); -} - -static int -central_print_child(device_t dev, device_t child) -{ - int rv; - - rv = bus_print_child_header(dev, child); - rv += central_print_res(device_get_ivars(child)); - rv += bus_print_child_footer(dev, child); - return (rv); -} - -static void -central_probe_nomatch(device_t dev, device_t child) -{ - const char *type; - - device_printf(dev, "<%s>", ofw_bus_get_name(child)); - central_print_res(device_get_ivars(child)); - type = ofw_bus_get_type(child); - printf(" type %s (no driver attached)\n", - type != NULL ? type : "unknown"); -} - -static struct resource * -central_alloc_resource(device_t bus, device_t child, int type, int *rid, - rman_res_t start, rman_res_t end, rman_res_t count, u_int flags) -{ - struct resource_list *rl; - struct resource_list_entry *rle; - struct central_softc *sc; - struct resource *res; - bus_addr_t coffset; - bus_addr_t cend; - bus_addr_t phys; - int isdefault; - int passthrough; - int i; - - isdefault = RMAN_IS_DEFAULT_RANGE(start, end); - passthrough = (device_get_parent(child) != bus); - res = NULL; - rle = NULL; - rl = BUS_GET_RESOURCE_LIST(bus, child); - sc = device_get_softc(bus); - switch (type) { - case SYS_RES_IRQ: - return (resource_list_alloc(rl, bus, child, type, rid, start, - end, count, flags)); - case SYS_RES_MEMORY: - if (!passthrough) { - rle = resource_list_find(rl, type, *rid); - if (rle == NULL) - return (NULL); - if (rle->res != NULL) - panic("%s: resource entry is busy", __func__); - if (isdefault) { - start = rle->start; - count = ulmax(count, rle->count); - end = ulmax(rle->end, start + count - 1); - } - } - for (i = 0; i < sc->sc_nrange; i++) { - coffset = sc->sc_ranges[i].coffset; - cend = coffset + sc->sc_ranges[i].size - 1; - if (start >= coffset && end <= cend) { - start -= coffset; - end -= coffset; - phys = sc->sc_ranges[i].poffset | - ((bus_addr_t)sc->sc_ranges[i].pspace << 32); - res = bus_generic_alloc_resource(bus, child, - type, rid, phys + start, phys + end, - count, flags); - if (!passthrough) - rle->res = res; - break; - } - } - break; - } - return (res); -} - -static struct resource_list * -central_get_resource_list(device_t bus, device_t child) -{ - struct central_devinfo *cdi; - - cdi = device_get_ivars(child); - return (&cdi->cdi_rl); -} - -static const struct ofw_bus_devinfo * -central_get_devinfo(device_t bus, device_t child) -{ - struct central_devinfo *cdi; - - cdi = device_get_ivars(child); - return (&cdi->cdi_obdinfo); -} - -static int -central_print_res(struct central_devinfo *cdi) -{ - - return (resource_list_print_type(&cdi->cdi_rl, "mem", SYS_RES_MEMORY, - "%#jx")); -} diff --git a/sys/sparc64/conf/DEFAULTS b/sys/sparc64/conf/DEFAULTS deleted file mode 100644 index c99480c8f86f..000000000000 --- a/sys/sparc64/conf/DEFAULTS +++ /dev/null @@ -1,23 +0,0 @@ -# -# DEFAULTS -- Default kernel configuration file for FreeBSD/sparc64 -# -# $FreeBSD$ - -machine sparc64 - -# Pseudo devices. -device mem # Memory and kernel memory devices - -# UART chips on this platform -device uart_ns8250 -device uart_sab82532 -device uart_z8530 - -# Default partitioning schemes -options GEOM_PART_BSD -options GEOM_PART_VTOC8 - -# Let sunkbd emulate an AT keyboard by default. -options SUNKBD_EMULATE_ATKBD - -options NEW_PCIB diff --git a/sys/sparc64/conf/GENERIC b/sys/sparc64/conf/GENERIC deleted file mode 100644 index 4509269c19ff..000000000000 --- a/sys/sparc64/conf/GENERIC +++ /dev/null @@ -1,253 +0,0 @@ -# -# GENERIC -- Generic kernel configuration file for FreeBSD/sparc64 -# -# For more information on this file, please read the config(5) manual page, -# and/or the handbook section on Kernel Configuration Files: -# -# https://www.FreeBSD.org/doc/en_US.ISO8859-1/books/handbook/kernelconfig-config.html -# -# The handbook is also available locally in /usr/share/doc/handbook -# if you've installed the doc distribution, otherwise always see the -# FreeBSD World Wide Web server (https://www.FreeBSD.org/) for the -# latest information. -# -# An exhaustive list of options and more detailed explanations of the -# device lines is also present in the ../../conf/NOTES and NOTES files. -# If you are in doubt as to the purpose or necessity of a line, check first -# in NOTES. -# -# $FreeBSD$ - -cpu SUN4U -ident GENERIC - -makeoptions DEBUG=-g # Build kernel with gdb(1) debug symbols - -# Platforms supported -# At this time all platforms are supported, as-is. - -options SCHED_ULE # ULE scheduler -options PREEMPTION # Enable kernel thread preemption -options VIMAGE # Subsystem virtualization, e.g. VNET -options INET # InterNETworking -options INET6 # IPv6 communications protocols -options IPSEC_SUPPORT # Allow kldload of ipsec and tcpmd5 -options TCP_HHOOK # hhook(9) framework for TCP -options SCTP # Stream Control Transmission Protocol -options FFS # Berkeley Fast Filesystem -options SOFTUPDATES # Enable FFS soft updates support -options UFS_ACL # Support for access control lists -options UFS_DIRHASH # Improve performance on big directories -options UFS_GJOURNAL # Enable gjournal-based UFS journaling -options QUOTA # Enable disk quotas for UFS -options MD_ROOT # MD is a potential root device -options NFSCL # Network Filesystem Client -options NFSD # Network Filesystem Server -options NFSLOCKD # Network Lock Manager -options NFS_ROOT # NFS usable as /, requires NFSCL -#options MSDOSFS # MSDOS Filesystem -options CD9660 # ISO 9660 Filesystem -options PROCFS # Process filesystem (requires PSEUDOFS) -options PSEUDOFS # Pseudo-filesystem framework -options GEOM_PART_GPT # GUID Partition Tables. -options GEOM_LABEL # Provides labelization -options COMPAT_FREEBSD5 # Compatible with FreeBSD5 -options COMPAT_FREEBSD6 # Compatible with FreeBSD6 -options COMPAT_FREEBSD7 # Compatible with FreeBSD7 -options COMPAT_FREEBSD9 # Compatible with FreeBSD9 -options COMPAT_FREEBSD10 # Compatible with FreeBSD10 -options COMPAT_FREEBSD11 # Compatible with FreeBSD11 -options COMPAT_FREEBSD12 # Compatible with FreeBSD12 -options SCSI_DELAY=5000 # Delay (in ms) before probing SCSI -options KTRACE # ktrace(1) support -options STACK # stack(9) support -options SYSVSHM # SYSV-style shared memory -options SYSVMSG # SYSV-style message queues -options SYSVSEM # SYSV-style semaphores -options _KPOSIX_PRIORITY_SCHEDULING # POSIX P1003_1B real-time extensions -options PRINTF_BUFR_SIZE=128 # Prevent printf output being interspersed. -options HWPMC_HOOKS # Necessary kernel hooks for hwpmc(4) -options AUDIT # Security event auditing -options CAPABILITY_MODE # Capsicum capability mode -options CAPABILITIES # Capsicum capabilities -options MAC # TrustedBSD MAC Framework -options INCLUDE_CONFIG_FILE # Include this file in kernel -options RACCT # Resource accounting framework -options RACCT_DEFAULT_TO_DISABLED # Set kern.racct.enable=0 by default -options RCTL # Resource limits - -# Debugging support. Always need this: -options KDB # Enable kernel debugger support. -options KDB_TRACE # Print a stack trace for a panic. -# For full debugger support use (turn off in stable branch): -options DDB # Support DDB. -options GDB # Support remote GDB. -options DEADLKRES # Enable the deadlock resolver -options INVARIANTS # Enable calls of extra sanity checking -options INVARIANT_SUPPORT # Extra sanity checks of internal structures, required by INVARIANTS -options WITNESS # Enable checks to detect deadlocks and cycles -options WITNESS_SKIPSPIN # Don't run witness on spinlocks for speed -options MALLOC_DEBUG_MAXZONES=8 # Separate malloc(9) zones -options VERBOSE_SYSINIT=0 # Support debug.verbose_sysinit, off by default - -# Kernel dump features. -options EKCD # Support for encrypted kernel dumps -options GZIO # gzip-compressed kernel and user dumps -options ZSTDIO # zstd-compressed kernel and user dumps -options DEBUGNET # debugnet networking -options NETDUMP # netdump(4) client support - -# Make an SMP-capable kernel by default -options SMP # Symmetric MultiProcessor Kernel - -# Standard busses -device ebus -device isa -device pci -device sbus -device central -device fhc - -# Floppy drives -#device fdc - -# ATA controllers -device ahci # AHCI-compatible SATA controllers -device ata # Legacy ATA/SATA controllers -device mvs # Marvell 88SX50XX/88SX60XX/88SX70XX/SoC SATA -device siis # SiliconImage SiI3124/SiI3132/SiI3531 SATA - -# SCSI Controllers -device ahc # AHA2940 and onboard AIC7xxx devices -options AHC_ALLOW_MEMIO # Attempt to use memory mapped I/O -device esp # AMD Am53C974, Sun ESP and FAS families -device isp # Qlogic family -device ispfw # Firmware module for Qlogic host adapters -device mpt # LSI-Logic MPT-Fusion -device mps # LSI-Logic MPT-Fusion 2 -device mpr # LSI-Logic MPT-Fusion 3 -device sym # NCR/Symbios/LSI Logic 53C8XX/53C1010/53C1510D - -# ATA/SCSI peripherals -device scbus # SCSI bus (required for ATA/SCSI) -device ch # SCSI media changers -device da # Direct Access (disks) -device sa # Sequential Access (tape etc) -device cd # CD -device pass # Passthrough device (direct ATA/SCSI access) -device ses # Enclosure Services (SES and SAF-TE) -#device ctl # CAM Target Layer - -# RAID controllers -#device amr # AMI MegaRAID -#device mlx # Mylex DAC960 family - -# atkbdc0 controls both the keyboard and the PS/2 mouse -device atkbdc # AT keyboard controller -device atkbd # AT keyboard -device psm # PS/2 mouse - -device kbdmux # keyboard multiplexer - -# syscons is the default console driver, resembling an SCO console -device sc -device creator # Creator, Creator3D and Elite3D framebuffers -device machfb # ATI Mach64 framebuffers -device splash # Splash screen and screen saver support -options KBD_INSTALL_CDEV # install a CDEV entry in /dev - -# vt is the new video console driver -#device vt - -# Builtin hardware -device auxio # auxiliary I/O device -device eeprom # eeprom (really a front-end for the MK48Txx) -device mk48txx # Mostek MK48Txx clocks -device rtc # rtc (really a front-end for the MC146818) -device mc146818 # Motorola MC146818 and compatible clocks -device epic # Sun Fire V215/V245 LEDs -device sbbc # Sun BootBus controller (time-of-day clock for - # Serengeti and StarCat, console for Serengeti, - # requires device uart) - -# Serial (COM) ports -device puc # Multi-channel uarts -device scc # Serial communications controllers. -device uart # Multi-uart driver - -# Parallel port -#device ppc -#device ppbus # Parallel port bus (required) -#device lpt # Printer -#device ppi # Parallel port interface device -#device vpo # Requires scbus and da - -device iflib - -# PCI Ethernet NICs. -device em # Intel PRO/1000 adapter Gigabit Ethernet Card -device le # AMD Am7900 LANCE and Am79C9xx PCnet -device ti # Alteon Networks Tigon I/II gigabit Ethernet - -# PCI Ethernet NICs that use the common MII bus controller code. -# NOTE: Be sure to keep the 'device miibus' line in order to use these NICs! -device miibus # MII bus support -#device bfe # Broadcom BCM440x 10/100 Ethernet -device bge # Broadcom BCM570xx Gigabit Ethernet -device cas # Sun Cassini/Cassini+ and NS DP83065 Saturn -device dc # DEC/Intel 21143 and various workalikes -device fxp # Intel EtherExpress PRO/100B (82557, 82558) -device gem # Sun GEM/Sun ERI/Apple GMAC -device hme # Sun HME (Happy Meal Ethernet) -device nge # NatSemi DP83820 gigabit Ethernet -device re # RealTek 8139C+/8169/8169S/8110S -device rl # RealTek 8129/8139 -device sis # Silicon Integrated Systems SiS 900/SiS 7016 -device sk # SysKonnect SK-984x & SK-982x gigabit Ethernet -device ste # Sundance ST201 (D-Link DFE-550TX) -device stge # Sundance/Tamarack TC9021 gigabit Ethernet -device vr # VIA Rhine, Rhine II -device xl # 3Com 3c90x (``Boomerang'', ``Cyclone'') - -# Wireless NIC cards -device wlan # 802.11 support -options IEEE80211_DEBUG # enable debug msgs -options IEEE80211_SUPPORT_MESH # enable 802.11s D3.0 support -device wlan_wep # 802.11 WEP support -device wlan_ccmp # 802.11 CCMP support -device wlan_tkip # 802.11 TKIP support -device wlan_amrr # AMRR transmit rate control algorithm -device ath # Atheros NICs -device ath_pci # Atheros pci/cardbus glue -device ath_hal # Atheros HAL (Hardware Access Layer) -device ath_rate_sample # SampleRate tx rate control for ath - -# Pseudo devices. -device crypto # core crypto support -device loop # Network loopback -device ether # Ethernet support -device vlan # 802.1Q VLAN support -device tuntap # Packet tunnel. -device md # Memory "disks" -device gif # IPv6 and IPv4 tunneling -device firmware # firmware assist module - -# The `bpf' device enables the Berkeley Packet Filter. -# Be aware of the administrative consequences of enabling this! -# Note that 'bpf' is required for DHCP. -device bpf # Berkeley packet filter - -# USB support -options USB_DEBUG # enable debug msgs -device uhci # UHCI PCI->USB interface -device ohci # OHCI PCI->USB interface -device ehci # EHCI PCI->USB interface (USB 2.0) -device usb # USB Bus (required) -device ukbd # Keyboard -device umass # Disks/Mass storage - Requires scbus and da - -# Sound support -device sound # Generic sound driver (required) -device snd_audiocs # Crystal Semiconductor CS4231 -device snd_es137x # Ensoniq AudioPCI ES137x -device snd_t4dwave # Acer Labs M5451 diff --git a/sys/sparc64/conf/GENERIC-NODEBUG b/sys/sparc64/conf/GENERIC-NODEBUG deleted file mode 100644 index 863c2a79194e..000000000000 --- a/sys/sparc64/conf/GENERIC-NODEBUG +++ /dev/null @@ -1,38 +0,0 @@ -# -# GENERIC-NODEBUG -- WITNESS and INVARIANTS free kernel configuration file -# for FreeBSD/sparc64 -# -# This configuration file removes several debugging options, including -# WITNESS and INVARIANTS checking, which are known to have significant -# performance impact on running systems. When benchmarking new features -# this kernel should be used instead of the standard GENERIC. -# This kernel configuration should never appear outside of the HEAD -# of the FreeBSD tree. -# -# For more information on this file, please read the config(5) manual page, -# and/or the handbook section on Kernel Configuration Files: -# -# https://www.FreeBSD.org/doc/en_US.ISO8859-1/books/handbook/kernelconfig-config.html -# -# The handbook is also available locally in /usr/share/doc/handbook -# if you've installed the doc distribution, otherwise always see the -# FreeBSD World Wide Web server (https://www.FreeBSD.org/) for the -# latest information. -# -# An exhaustive list of options and more detailed explanations of the -# device lines is also present in the ../../conf/NOTES and NOTES files. -# If you are in doubt as to the purpose or necessity of a line, check first -# in NOTES. -# -# $FreeBSD$ - -include GENERIC - -ident GENERIC-NODEBUG - -nooptions INVARIANTS -nooptions INVARIANT_SUPPORT -nooptions WITNESS -nooptions WITNESS_SKIPSPIN -nooptions DEADLKRES -nooptions MALLOC_DEBUG_MAXZONES diff --git a/sys/sparc64/conf/GENERIC.hints b/sys/sparc64/conf/GENERIC.hints deleted file mode 100644 index e8c0da7a1d7e..000000000000 --- a/sys/sparc64/conf/GENERIC.hints +++ /dev/null @@ -1 +0,0 @@ -# $FreeBSD$ diff --git a/sys/sparc64/conf/Makefile b/sys/sparc64/conf/Makefile deleted file mode 100644 index b0b5857849c4..000000000000 --- a/sys/sparc64/conf/Makefile +++ /dev/null @@ -1,5 +0,0 @@ -# $FreeBSD$ - -TARGET=sparc64 - -.include "${.CURDIR}/../../conf/makeLINT.mk" diff --git a/sys/sparc64/conf/NOTES b/sys/sparc64/conf/NOTES deleted file mode 100644 index 28e2030df536..000000000000 --- a/sys/sparc64/conf/NOTES +++ /dev/null @@ -1,168 +0,0 @@ -# $FreeBSD$ -# -# This file contains machine dependent kernel configuration notes. For -# machine independent notes, look in /sys/conf/NOTES. - - -##################################################################### -# CPU OPTIONS - -# -# You must specify at least one CPU (the one you intend to run on); -# deleting the specification for CPUs you don't need to use may make -# parts of the system run faster. -# XXX: On the Sparc64, there is only one CPU type -cpu SUN4U - - -##################################################################### -# HARDWARE BUS CONFIGURATION - -device ebus -device isa -device sbus -device central -device fhc - - -##################################################################### -# HARDWARE DEVICE CONFIGURATION - -# -# Mandatory devices: -# - -device eeprom # eeprom (really a front-end for the MK48Txx) -device mk48txx # Mostek MK48Txx clocks -device rtc # rtc (really a front-end for the MC146818) -device mc146818 # Motorola MC146818 and compatible clocks -device sbbc # Sun BootBus controller - -# -# Optional devices: -# - -device auxio # auxiliary I/O device -device epic # Sun Fire V215/V245 LEDs -device creator # Creator, Creator3D and Elite3D framebuffers -device machfb # ATI Mach64 framebuffers - -device ofw_console # Open Firmware console device -option OFWCONS_POLL_HZ=4 # 20 or more works best on Ultra2 - -# PS/2 mouse -device psm - -# Options for psm: -options PSM_HOOKRESUME #hook the system resume event, useful - #for some laptops -options PSM_RESETAFTERSUSPEND #reset the device at the resume event - -# The keyboard controller; it controls the keyboard and the PS/2 mouse. -device atkbdc - -# The AT keyboard -device atkbd - -# Options for atkbd: -options ATKBD_DFLT_KEYMAP # specify the built-in keymap -makeoptions ATKBD_DFLT_KEYMAP=fr.dvorak - -# `flags' for atkbd: -# 0x01 Force detection of keyboard, else we always assume a keyboard -# 0x02 Don't reset keyboard, useful for some newer ThinkPads -# 0x03 Force detection and avoid reset, might help with certain -# dockingstations -# 0x04 Old-style (XT) keyboard support, useful for older ThinkPads - -# Sun type 4/5/6 RS-232@TTL keyboard -#device sunkbd - -# Options for sunkbd: -options SUNKBD_EMULATE_ATKBD # allows to use the AT keyboard maps - # in share/syscons/keymaps, required - # for SUNKBD_DFLT_KEYMAP and kbdmux -options SUNKBD_DFLT_KEYMAP # specify the built-in keymap -makeoptions SUNKBD_DFLT_KEYMAP=fr.dvorak - -# The syscons console driver (SCO color console compatible). -device sc -hint.sc.0.at="isa" -options MAXCONS=16 # number of virtual consoles -options SC_DFLT_TERM=\"sc\" # default terminal emulator -options SC_DISABLE_KDBKEY # disable `debug' key -options SC_DISABLE_REBOOT # disable reboot key sequence -options SC_HISTORY_SIZE=200 # number of history buffer lines -options SC_MOUSE_CHAR=0x3 # char code for text mode mouse cursor -options SC_PIXEL_MODE # add support for the raster text mode - -# The following options will let you change the default behavior of -# cut-n-paste feature -options SC_CUT_SPACES2TABS # convert leading spaces into tabs -options SC_CUT_SEPCHARS=\"x09\" # set of characters that delimit words - # (default is single space - \"x20\") - -# If you have a two button mouse, you may want to add the following option -# to use the right button of the mouse to paste text. -options SC_TWOBUTTON_MOUSE - -# You can selectively disable features in syscons. -options SC_NO_CUTPASTE -options SC_NO_HISTORY -options SC_NO_MODE_CHANGE -options SC_NO_SYSMOUSE -#!options SC_NO_TERM_DUMB -#!options SC_NO_TERM_SC -#!options SC_NO_TERM_SCTEKEN - -# `flags' for sc -# 0x80 Put the video card in the VESA 800x600 dots, 16 color mode -# 0x100 Probe for a keyboard device periodically if one is not present - - -##################################################################### -# Devices we don't want to deal with - -nodevice bktr -nodevice ppc -nodevice snd_ad1816 -nodevice snd_als4000 -nodevice snd_cmi -nodevice snd_cs4281 -nodevice snd_csa -nodevice snd_ds1 -nodevice snd_emu10k1 -nodevice snd_ess -nodevice snd_fm801 -nodevice snd_gusc -nodevice snd_ich -nodevice snd_maestro -nodevice snd_maestro3 -nodevice snd_mss -nodevice snd_neomagic -nodevice snd_sb16 -nodevice snd_sb8 -nodevice snd_sbc -nodevice snd_solo -nodevice snd_t4dwave -nodevice snd_via8233 -nodevice snd_via82c686 -nodevice snd_vibes -nodevice snd_uaudio - - -##################################################################### -# Options we don't want to deal with - -nooption COMPAT_FREEBSD4 -nooption SC_RENDER_DEBUG -nooption SC_DEBUG_LEVEL -nooption PPC_DEBUG -nooption PPC_PROBE_CHIPSET -nooption EXT2FS - - -##################################################################### -# Make options we don't want to deal with - -nomakeoption SC_DFLT_FONT diff --git a/sys/sparc64/ebus/ebus.c b/sys/sparc64/ebus/ebus.c deleted file mode 100644 index df9e3c29d17f..000000000000 --- a/sys/sparc64/ebus/ebus.c +++ /dev/null @@ -1,730 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause-NetBSD AND BSD-3-Clause - * - * Copyright (c) 1999, 2000 Matthew R. Green - * Copyright (c) 2009 by Marius Strobl - * 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. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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. - * - * from: NetBSD: ebus.c,v 1.52 2008/05/29 14:51:26 mrg Exp - */ -/*- - * Copyright (c) 2001 Thomas Moestl - * 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. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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 -__FBSDID("$FreeBSD$"); - -/* - * Driver for JBus to EBus and PCI to EBus bridges - */ - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include -#ifndef SUN4V -#include -#endif -#include -#include - -#include -#include - -#include - -/* - * The register, interrupt map and for the PCI variant also the ranges - * properties are identical to the ISA ones. - */ -#include - -struct ebus_nexus_ranges { - uint32_t child_hi; - uint32_t child_lo; - uint32_t phys_hi; - uint32_t phys_lo; - uint32_t size; -}; - -struct ebus_devinfo { - struct ofw_bus_devinfo edi_obdinfo; - struct resource_list edi_rl; -}; - -struct ebus_rinfo { - int eri_rtype; - struct rman eri_rman; - struct resource *eri_res; -}; - -struct ebus_softc { - void *sc_range; - struct ebus_rinfo *sc_rinfo; - - u_int sc_flags; -#define EBUS_PCI (1 << 0) - - int sc_nrange; - - struct ofw_bus_iinfo sc_iinfo; - -#ifndef SUN4V - uint32_t sc_ign; -#endif -}; - -static device_probe_t ebus_nexus_probe; -static device_attach_t ebus_nexus_attach; -static device_probe_t ebus_pci_probe; -static device_attach_t ebus_pci_attach; -static bus_print_child_t ebus_print_child; -static bus_probe_nomatch_t ebus_probe_nomatch; -static bus_alloc_resource_t ebus_alloc_resource; -static bus_activate_resource_t ebus_activate_resource; -static bus_adjust_resource_t ebus_adjust_resource; -static bus_release_resource_t ebus_release_resource; -static bus_setup_intr_t ebus_setup_intr; -static bus_get_resource_list_t ebus_get_resource_list; -static ofw_bus_get_devinfo_t ebus_get_devinfo; - -static int ebus_attach(device_t dev, struct ebus_softc *sc, phandle_t node); -static struct ebus_devinfo *ebus_setup_dinfo(device_t dev, - struct ebus_softc *sc, phandle_t node); -static void ebus_destroy_dinfo(struct ebus_devinfo *edi); -static int ebus_print_res(struct ebus_devinfo *edi); - -static devclass_t ebus_devclass; - -static device_method_t ebus_nexus_methods[] = { - /* Device interface */ - DEVMETHOD(device_probe, ebus_nexus_probe), - DEVMETHOD(device_attach, ebus_nexus_attach), - DEVMETHOD(device_shutdown, bus_generic_shutdown), - DEVMETHOD(device_suspend, bus_generic_suspend), - DEVMETHOD(device_resume, bus_generic_resume), - - /* Bus interface */ - DEVMETHOD(bus_print_child, ebus_print_child), - DEVMETHOD(bus_probe_nomatch, ebus_probe_nomatch), - DEVMETHOD(bus_alloc_resource, ebus_alloc_resource), - DEVMETHOD(bus_activate_resource, ebus_activate_resource), - DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource), - DEVMETHOD(bus_adjust_resource, ebus_adjust_resource), - DEVMETHOD(bus_release_resource, ebus_release_resource), - DEVMETHOD(bus_setup_intr, ebus_setup_intr), - DEVMETHOD(bus_teardown_intr, bus_generic_teardown_intr), - DEVMETHOD(bus_get_resource, bus_generic_rl_get_resource), - DEVMETHOD(bus_get_resource_list, ebus_get_resource_list), - DEVMETHOD(bus_child_pnpinfo_str, ofw_bus_gen_child_pnpinfo_str), - - /* ofw_bus interface */ - DEVMETHOD(ofw_bus_get_devinfo, ebus_get_devinfo), - DEVMETHOD(ofw_bus_get_compat, ofw_bus_gen_get_compat), - DEVMETHOD(ofw_bus_get_model, ofw_bus_gen_get_model), - DEVMETHOD(ofw_bus_get_name, ofw_bus_gen_get_name), - DEVMETHOD(ofw_bus_get_node, ofw_bus_gen_get_node), - DEVMETHOD(ofw_bus_get_type, ofw_bus_gen_get_type), - - DEVMETHOD_END -}; - -static driver_t ebus_nexus_driver = { - "ebus", - ebus_nexus_methods, - sizeof(struct ebus_softc), -}; - -/* - * NB: we rely on the interrupt controllers of the accompanying PCI-Express - * bridge to be registered as the nexus variant of the EBus bridges doesn't - * employ its own one. - */ -EARLY_DRIVER_MODULE(ebus, nexus, ebus_nexus_driver, ebus_devclass, 0, 0, - BUS_PASS_BUS + 1); -MODULE_DEPEND(ebus, nexus, 1, 1, 1); - -static device_method_t ebus_pci_methods[] = { - /* Device interface */ - DEVMETHOD(device_probe, ebus_pci_probe), - DEVMETHOD(device_attach, ebus_pci_attach), - DEVMETHOD(device_shutdown, bus_generic_shutdown), - DEVMETHOD(device_suspend, bus_generic_suspend), - DEVMETHOD(device_resume, bus_generic_resume), - - /* Bus interface */ - DEVMETHOD(bus_print_child, ebus_print_child), - DEVMETHOD(bus_probe_nomatch, ebus_probe_nomatch), - DEVMETHOD(bus_alloc_resource, ebus_alloc_resource), - DEVMETHOD(bus_activate_resource, bus_generic_activate_resource), - DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource), - DEVMETHOD(bus_release_resource, ebus_release_resource), - DEVMETHOD(bus_setup_intr, bus_generic_setup_intr), - DEVMETHOD(bus_teardown_intr, bus_generic_teardown_intr), - DEVMETHOD(bus_get_resource, bus_generic_rl_get_resource), - DEVMETHOD(bus_get_resource_list, ebus_get_resource_list), - DEVMETHOD(bus_child_pnpinfo_str, ofw_bus_gen_child_pnpinfo_str), - - /* ofw_bus interface */ - DEVMETHOD(ofw_bus_get_devinfo, ebus_get_devinfo), - DEVMETHOD(ofw_bus_get_compat, ofw_bus_gen_get_compat), - DEVMETHOD(ofw_bus_get_model, ofw_bus_gen_get_model), - DEVMETHOD(ofw_bus_get_name, ofw_bus_gen_get_name), - DEVMETHOD(ofw_bus_get_node, ofw_bus_gen_get_node), - DEVMETHOD(ofw_bus_get_type, ofw_bus_gen_get_type), - - DEVMETHOD_END -}; - -static driver_t ebus_pci_driver = { - "ebus", - ebus_pci_methods, - sizeof(struct ebus_softc), -}; - -EARLY_DRIVER_MODULE(ebus, pci, ebus_pci_driver, ebus_devclass, 0, 0, - BUS_PASS_BUS); -MODULE_DEPEND(ebus, pci, 1, 1, 1); -MODULE_VERSION(ebus, 1); - -static int -ebus_nexus_probe(device_t dev) -{ - const char* compat; - - compat = ofw_bus_get_compat(dev); - if (compat != NULL && strcmp(ofw_bus_get_name(dev), "ebus") == 0 && - strcmp(compat, "jbus-ebus") == 0) { - device_set_desc(dev, "JBus-EBus bridge"); - return (BUS_PROBE_GENERIC); - } - return (ENXIO); -} - -static int -ebus_pci_probe(device_t dev) -{ - - if (pci_get_class(dev) != PCIC_BRIDGE || - pci_get_vendor(dev) != 0x108e || - strcmp(ofw_bus_get_name(dev), "ebus") != 0) - return (ENXIO); - - if (pci_get_device(dev) == 0x1000) - device_set_desc(dev, "PCI-EBus2 bridge"); - else if (pci_get_device(dev) == 0x1100) - device_set_desc(dev, "PCI-EBus3 bridge"); - else - return (ENXIO); - return (BUS_PROBE_GENERIC); -} - -static int -ebus_nexus_attach(device_t dev) -{ - struct ebus_softc *sc; - phandle_t node; - - sc = device_get_softc(dev); - node = ofw_bus_get_node(dev); - -#ifndef SUN4V - if (OF_getprop(node, "portid", &sc->sc_ign, - sizeof(sc->sc_ign)) == -1) { - device_printf(dev, "could not determine IGN"); - return (ENXIO); - } -#endif - - sc->sc_nrange = OF_getprop_alloc_multi(node, "ranges", - sizeof(struct ebus_nexus_ranges), &sc->sc_range); - if (sc->sc_nrange == -1) { - device_printf(dev, "could not get ranges property\n"); - return (ENXIO); - } - return (ebus_attach(dev, sc, node)); -} - -static int -ebus_pci_attach(device_t dev) -{ - struct ebus_softc *sc; - struct ebus_rinfo *eri; - struct resource *res; - struct isa_ranges *range; - phandle_t node; - int i, rnum, rid; - - sc = device_get_softc(dev); - sc->sc_flags |= EBUS_PCI; - - pci_write_config(dev, PCIR_COMMAND, - pci_read_config(dev, PCIR_COMMAND, 2) | PCIM_CMD_SERRESPEN | - PCIM_CMD_PERRESPEN | PCIM_CMD_BUSMASTEREN | PCIM_CMD_MEMEN, 2); - pci_write_config(dev, PCIR_CACHELNSZ, 16 /* 64 bytes */, 1); - pci_write_config(dev, PCIR_LATTIMER, 64 /* 64 PCI cycles */, 1); - - node = ofw_bus_get_node(dev); - sc->sc_nrange = OF_getprop_alloc_multi(node, "ranges", - sizeof(struct isa_ranges), &sc->sc_range); - if (sc->sc_nrange == -1) { - device_printf(dev, "could not get ranges property\n"); - return (ENXIO); - } - - sc->sc_rinfo = malloc(sizeof(*sc->sc_rinfo) * sc->sc_nrange, M_DEVBUF, - M_WAITOK | M_ZERO); - - /* For every range, there must be a matching resource. */ - for (rnum = 0; rnum < sc->sc_nrange; rnum++) { - eri = &sc->sc_rinfo[rnum]; - range = &((struct isa_ranges *)sc->sc_range)[rnum]; - eri->eri_rtype = ofw_isa_range_restype(range); - rid = PCIR_BAR(rnum); - res = bus_alloc_resource_any(dev, eri->eri_rtype, &rid, - RF_ACTIVE); - if (res == NULL) { - device_printf(dev, - "could not allocate range resource %d\n", rnum); - goto fail; - } - if (rman_get_start(res) != ISA_RANGE_PHYS(range)) { - device_printf(dev, - "mismatch in start of range %d (0x%lx/0x%lx)\n", - rnum, rman_get_start(res), ISA_RANGE_PHYS(range)); - goto fail; - } - if (rman_get_size(res) != range->size) { - device_printf(dev, - "mismatch in size of range %d (0x%lx/0x%x)\n", - rnum, rman_get_size(res), range->size); - goto fail; - } - eri->eri_res = res; - eri->eri_rman.rm_type = RMAN_ARRAY; - eri->eri_rman.rm_descr = "EBus range"; - if (rman_init_from_resource(&eri->eri_rman, res) != 0) { - device_printf(dev, - "could not initialize rman for range %d", rnum); - goto fail; - } - } - return (ebus_attach(dev, sc, node)); - - fail: - for (i = rnum; i >= 0; i--) { - eri = &sc->sc_rinfo[i]; - if (i < rnum) - rman_fini(&eri->eri_rman); - if (eri->eri_res != NULL) { - bus_release_resource(dev, eri->eri_rtype, - PCIR_BAR(rnum), eri->eri_res); - } - } - free(sc->sc_rinfo, M_DEVBUF); - OF_prop_free(sc->sc_range); - return (ENXIO); -} - -static int -ebus_attach(device_t dev, struct ebus_softc *sc, phandle_t node) -{ - struct ebus_devinfo *edi; - device_t cdev; - - ofw_bus_setup_iinfo(node, &sc->sc_iinfo, sizeof(ofw_isa_intr_t)); - - /* - * Now attach our children. - */ - for (node = OF_child(node); node > 0; node = OF_peer(node)) { - if ((edi = ebus_setup_dinfo(dev, sc, node)) == NULL) - continue; - if ((cdev = device_add_child(dev, NULL, -1)) == NULL) { - device_printf(dev, "<%s>: device_add_child failed\n", - edi->edi_obdinfo.obd_name); - ebus_destroy_dinfo(edi); - continue; - } - device_set_ivars(cdev, edi); - } - return (bus_generic_attach(dev)); -} - -static int -ebus_print_child(device_t dev, device_t child) -{ - int retval; - - retval = bus_print_child_header(dev, child); - retval += ebus_print_res(device_get_ivars(child)); - retval += bus_print_child_footer(dev, child); - return (retval); -} - -static void -ebus_probe_nomatch(device_t dev, device_t child) -{ - - device_printf(dev, "<%s>", ofw_bus_get_name(child)); - ebus_print_res(device_get_ivars(child)); - printf(" (no driver attached)\n"); -} - -static struct resource * -ebus_alloc_resource(device_t bus, device_t child, int type, int *rid, - rman_res_t start, rman_res_t end, rman_res_t count, u_int flags) -{ - struct ebus_softc *sc; - struct resource_list *rl; - struct resource_list_entry *rle = NULL; - struct resource *res; - struct ebus_rinfo *eri; - struct ebus_nexus_ranges *enr; - uint64_t cend, cstart, offset; - int i, isdefault, passthrough, ridx; - - isdefault = RMAN_IS_DEFAULT_RANGE(start, end); - passthrough = (device_get_parent(child) != bus); - sc = device_get_softc(bus); - rl = BUS_GET_RESOURCE_LIST(bus, child); - switch (type) { - case SYS_RES_MEMORY: - KASSERT(!(isdefault && passthrough), - ("%s: passthrough of default allocation", __func__)); - if (!passthrough) { - rle = resource_list_find(rl, type, *rid); - if (rle == NULL) - return (NULL); - KASSERT(rle->res == NULL, - ("%s: resource entry is busy", __func__)); - if (isdefault) { - start = rle->start; - count = ulmax(count, rle->count); - end = ulmax(rle->end, start + count - 1); - } - } - - res = NULL; - if ((sc->sc_flags & EBUS_PCI) != 0) { - /* - * Map EBus ranges to PCI ranges. This may include - * changing the allocation type. - */ - type = ofw_isa_range_map(sc->sc_range, sc->sc_nrange, - &start, &end, &ridx); - eri = &sc->sc_rinfo[ridx]; - res = rman_reserve_resource(&eri->eri_rman, start, - end, count, flags & ~RF_ACTIVE, child); - if (res == NULL) - return (NULL); - rman_set_rid(res, *rid); - if ((flags & RF_ACTIVE) != 0 && bus_activate_resource( - child, type, *rid, res) != 0) { - rman_release_resource(res); - return (NULL); - } - } else { - /* Map EBus ranges to nexus ranges. */ - for (i = 0; i < sc->sc_nrange; i++) { - enr = &((struct ebus_nexus_ranges *) - sc->sc_range)[i]; - cstart = (((uint64_t)enr->child_hi) << 32) | - enr->child_lo; - cend = cstart + enr->size - 1; - if (start >= cstart && end <= cend) { - offset = - (((uint64_t)enr->phys_hi) << 32) | - enr->phys_lo; - start += offset - cstart; - end += offset - cstart; - res = bus_generic_alloc_resource(bus, - child, type, rid, start, end, - count, flags); - break; - } - } - } - if (!passthrough) - rle->res = res; - return (res); - case SYS_RES_IRQ: - return (resource_list_alloc(rl, bus, child, type, rid, start, - end, count, flags)); - } - return (NULL); -} - -static int -ebus_activate_resource(device_t bus, device_t child, int type, int rid, - struct resource *res) -{ - struct ebus_softc *sc; - struct ebus_rinfo *eri; - bus_space_tag_t bt; - bus_space_handle_t bh; - int i, rv; - - sc = device_get_softc(bus); - if ((sc->sc_flags & EBUS_PCI) != 0 && type != SYS_RES_IRQ) { - for (i = 0; i < sc->sc_nrange; i++) { - eri = &sc->sc_rinfo[i]; - if (rman_is_region_manager(res, &eri->eri_rman) != 0) { - bt = rman_get_bustag(eri->eri_res); - rv = bus_space_subregion(bt, - rman_get_bushandle(eri->eri_res), - rman_get_start(res) - - rman_get_start(eri->eri_res), - rman_get_size(res), &bh); - if (rv != 0) - return (rv); - rman_set_bustag(res, bt); - rman_set_bushandle(res, bh); - return (rman_activate_resource(res)); - } - } - return (EINVAL); - } - return (bus_generic_activate_resource(bus, child, type, rid, res)); -} - -static int -ebus_adjust_resource(device_t bus __unused, device_t child __unused, - int type __unused, struct resource *res __unused, rman_res_t start __unused, - rman_res_t end __unused) -{ - - return (ENXIO); -} - -static int -ebus_release_resource(device_t bus, device_t child, int type, int rid, - struct resource *res) -{ - struct ebus_softc *sc; - struct resource_list *rl; - struct resource_list_entry *rle; - int passthrough, rv; - - passthrough = (device_get_parent(child) != bus); - rl = BUS_GET_RESOURCE_LIST(bus, child); - sc = device_get_softc(bus); - if ((sc->sc_flags & EBUS_PCI) != 0 && type != SYS_RES_IRQ) { - if ((rman_get_flags(res) & RF_ACTIVE) != 0 ){ - rv = bus_deactivate_resource(child, type, rid, res); - if (rv != 0) - return (rv); - } - rv = rman_release_resource(res); - if (rv != 0) - return (rv); - if (!passthrough) { - rle = resource_list_find(rl, type, rid); - KASSERT(rle != NULL, - ("%s: resource entry not found!", __func__)); - KASSERT(rle->res != NULL, - ("%s: resource entry is not busy", __func__)); - rle->res = NULL; - } - return (0); - } - return (resource_list_release(rl, bus, child, type, rid, res)); -} - -static int -ebus_setup_intr(device_t dev, device_t child, struct resource *ires, - int flags, driver_filter_t *filt, driver_intr_t *intr, void *arg, - void **cookiep) -{ -#ifndef SUN4V - struct ebus_softc *sc; - u_long vec; - - sc = device_get_softc(dev); - if ((sc->sc_flags & EBUS_PCI) == 0) { - /* - * Make sure the vector is fully specified. This isn't - * necessarily the case with the PCI variant. - */ - vec = rman_get_start(ires); - if (INTIGN(vec) != sc->sc_ign) { - device_printf(dev, - "invalid interrupt vector 0x%lx\n", vec); - return (EINVAL); - } - - /* - * As we rely on the interrupt controllers of the - * accompanying PCI-Express bridge ensure at least - * something is registered for this vector. - */ - if (intr_vectors[vec].iv_ic == NULL) { - device_printf(dev, - "invalid interrupt controller for vector 0x%lx\n", - vec); - return (EINVAL); - } - } -#endif - return (bus_generic_setup_intr(dev, child, ires, flags, filt, intr, - arg, cookiep)); -} - -static struct resource_list * -ebus_get_resource_list(device_t dev, device_t child) -{ - struct ebus_devinfo *edi; - - edi = device_get_ivars(child); - return (&edi->edi_rl); -} - -static const struct ofw_bus_devinfo * -ebus_get_devinfo(device_t bus, device_t dev) -{ - struct ebus_devinfo *edi; - - edi = device_get_ivars(dev); - return (&edi->edi_obdinfo); -} - -static struct ebus_devinfo * -ebus_setup_dinfo(device_t dev, struct ebus_softc *sc, phandle_t node) -{ - struct isa_regs reg, *regs; - ofw_isa_intr_t intr, *intrs; - struct ebus_devinfo *edi; - uint64_t start; - uint32_t rintr; - int i, nintr, nreg, rv; - - edi = malloc(sizeof(*edi), M_DEVBUF, M_ZERO | M_WAITOK); - if (ofw_bus_gen_setup_devinfo(&edi->edi_obdinfo, node) != 0) { - free(edi, M_DEVBUF); - return (NULL); - } - resource_list_init(&edi->edi_rl); - nreg = OF_getprop_alloc_multi(node, "reg", sizeof(*regs), (void **)®s); - if (nreg == -1) { - device_printf(dev, "<%s>: incomplete\n", - edi->edi_obdinfo.obd_name); - ebus_destroy_dinfo(edi); - return (NULL); - } - for (i = 0; i < nreg; i++) { - start = ISA_REG_PHYS(regs + i); - (void)resource_list_add(&edi->edi_rl, SYS_RES_MEMORY, i, - start, start + regs[i].size - 1, regs[i].size); - } - OF_prop_free(regs); - - nintr = OF_getprop_alloc_multi(node, "interrupts", sizeof(*intrs), - (void **)&intrs); - if (nintr == -1) - return (edi); - for (i = 0; i < nintr; i++) { - rv = 0; - if ((sc->sc_flags & EBUS_PCI) != 0) { - rintr = ofw_isa_route_intr(dev, node, &sc->sc_iinfo, - intrs[i]); - } else { - intr = intrs[i]; - rv = ofw_bus_lookup_imap(node, &sc->sc_iinfo, ®, - sizeof(reg), &intr, sizeof(intr), &rintr, - sizeof(rintr), NULL); -#ifndef SUN4V - if (rv != 0) - rintr = INTMAP_VEC(sc->sc_ign, rintr); -#endif - } - if ((sc->sc_flags & EBUS_PCI) == 0 ? rv == 0 : - rintr == PCI_INVALID_IRQ) { - device_printf(dev, - "<%s>: could not map EBus interrupt %d\n", - edi->edi_obdinfo.obd_name, intrs[i]); - continue; - } - (void)resource_list_add(&edi->edi_rl, SYS_RES_IRQ, i, rintr, - rintr, 1); - } - OF_prop_free(intrs); - return (edi); -} - -static void -ebus_destroy_dinfo(struct ebus_devinfo *edi) -{ - - resource_list_free(&edi->edi_rl); - ofw_bus_gen_destroy_devinfo(&edi->edi_obdinfo); - free(edi, M_DEVBUF); -} - -static int -ebus_print_res(struct ebus_devinfo *edi) -{ - int retval; - - retval = 0; - retval += resource_list_print_type(&edi->edi_rl, "addr", SYS_RES_MEMORY, - "%#jx"); - retval += resource_list_print_type(&edi->edi_rl, "irq", SYS_RES_IRQ, - "%jd"); - return (retval); -} diff --git a/sys/sparc64/ebus/ebusreg.h b/sys/sparc64/ebus/ebusreg.h deleted file mode 100644 index 53a4cdd3dc11..000000000000 --- a/sys/sparc64/ebus/ebusreg.h +++ /dev/null @@ -1,91 +0,0 @@ -/* $FreeBSD$ */ -/* $OpenBSD: ebusreg.h,v 1.4 2001/10/01 18:08:04 jason Exp $ */ -/* $NetBSD: ebusreg.h,v 1.8 2008/05/29 14:51:27 mrg Exp $ */ - -/*- - * SPDX-License-Identifier: BSD-2-Clause-NetBSD - * - * Copyright (c) 1999 Matthew R. Green - * 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 ``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 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. - * - */ - -/* - * UltraSPARC `ebus' - * - * The `ebus' bus is designed to plug traditional PC-ISA devices into - * an SPARC system with as few costs as possible, without sacrificing - * to performance. Typically, it is implemented in the PCIO IC from - * SME, which also implements a `hme-compatible' PCI network device - * (`network'). The ebus has 4 DMA channels, similar to the DMA seen - * in the ESP SCSI DMA. - * - * Typical UltraSPARC systems have a NatSemi SuperIO IC to provide - * serial ports for the keyboard and mouse (`se'), floppy disk - * controller (`fdthree'), parallel port controller (`bpp') connected - * to the ebus, and a PCI-IDE controller (connected directly to the - * PCI bus, of course), as well as a Siemens Nixdorf SAB82532 dual - * channel serial controller (`su' providing ttya and ttyb), an MK48T59 - * EEPROM/clock controller (also where the idprom, including the - * ethernet address, is located), the audio system (`SUNW,CS4231', same - * as other UltraSPARC and some SPARC systems), and other various - * internal devices found on traditional SPARC systems such as the - * `power', `flashprom', etc., devices. - * - * The ebus uses an interrupt mapping scheme similar to PCI, though - * the actual structures are different. - */ - -/* EBUS dma registers */ -#define EBDMA_DCSR 0x0 /* control/status */ -#define EBDMA_DADDR 0x4 /* DMA address */ -#define EBDMA_DCNT 0x8 /* DMA count */ - -/* EBUS DMA control/status (EBDMA_DCSR) */ -#define EBDCSR_INT 0x00000001 /* interrupt pending */ -#define EBDCSR_ERR 0x00000002 /* error pending */ -#define EBDCSR_DRAIN 0x00000004 /* drain */ -#define EBDCSR_INTEN 0x00000010 /* interrupt enable */ -#define EBDCSR_RESET 0x00000080 /* reset */ -#define EBDCSR_WRITE 0x00000100 /* write */ -#define EBDCSR_DMAEN 0x00000200 /* dma enable */ -#define EBDCSR_CYC 0x00000400 /* cyc pending */ -#define EBDCSR_DIAGRD 0x00000800 /* diagnostic read done */ -#define EBDCSR_DIAGWR 0x00001000 /* diagnostic write done */ -#define EBDCSR_CNTEN 0x00002000 /* count enable */ -#define EBDCSR_TC 0x00004000 /* terminal count */ -#define EBDCSR_CSRDRNDIS 0x00010000 /* disable csr drain */ -#define EBDCSR_BURSTMASK 0x000c0000 /* burst size mask */ -#define EBDCSR_BURST_1 0x00080000 /* burst 1 */ -#define EBDCSR_BURST_4 0x00000000 /* burst 4 */ -#define EBDCSR_BURST_8 0x00040000 /* burst 8 */ -#define EBDCSR_BURST_16 0x000c0000 /* burst 16 */ -#define EBDCSR_DIAGEN 0x00100000 /* enable diagnostics */ -#define EBDCSR_ERRDIS 0x00400000 /* disable error pending */ -#define EBDCSR_TCIDIS 0x00800000 /* disable TCI */ -#define EBDCSR_NEXTEN 0x01000000 /* enable next */ -#define EBDCSR_DMAON 0x02000000 /* dma on */ -#define EBDCSR_A_LOADED 0x04000000 /* address loaded */ -#define EBDCSR_NA_LOADED 0x08000000 /* next address loaded */ -#define EBDCSR_DEVMASK 0xf0000000 /* device id mask */ diff --git a/sys/sparc64/ebus/epic.c b/sys/sparc64/ebus/epic.c deleted file mode 100644 index 68634a863f1b..000000000000 --- a/sys/sparc64/ebus/epic.c +++ /dev/null @@ -1,218 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD - * - * Copyright (c) 2009 Marius Strobl - * 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 -__FBSDID("$FreeBSD$"); - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include -#include - -#define EPIC_DELAY 10000 - -#define EPIC_NREG 1 -#define EPIC_FW_LED 0 - -#define EPIC_FW_LED_DATA 0x40 -#define EPIC_FW_LED_ADDR 0x41 -#define EPIC_FW_LED_WRITE_MASK 0x80 - -#define EPIC_FW_VERSION 0x05 -#define EPIC_LED_STATE0 0x06 - -#define EPIC_LED_ALERT_MASK 0x0c -#define EPIC_LED_ALERT_OFF 0x00 -#define EPIC_LED_ALERT_ON 0x04 - -#define EPIC_LED_POWER_MASK 0x30 -#define EPIC_LED_POWER_OFF 0x00 -#define EPIC_LED_POWER_ON 0x10 -#define EPIC_LED_POWER_SB_BLINK 0x20 -#define EPIC_LED_POWER_FAST_BLINK 0x30 - -static struct resource_spec epic_res_spec[] = { - { SYS_RES_MEMORY, EPIC_FW_LED, RF_ACTIVE }, - { -1, 0 } -}; - -struct epic_softc { - struct mtx sc_mtx; - struct resource *sc_res[EPIC_NREG]; - struct cdev *sc_led_dev_alert; - struct cdev *sc_led_dev_power; -}; - -#define EPIC_FW_LED_READ(sc, off) ({ \ - uint8_t __val; \ - bus_write_1((sc)->sc_res[EPIC_FW_LED], EPIC_FW_LED_ADDR, (off));\ - bus_barrier((sc)->sc_res[EPIC_FW_LED], EPIC_FW_LED_ADDR, 1, \ - BUS_SPACE_BARRIER_READ | BUS_SPACE_BARRIER_WRITE); \ - DELAY(EPIC_DELAY); \ - __val = bus_read_1((sc)->sc_res[EPIC_FW_LED], EPIC_FW_LED_DATA);\ - bus_barrier((sc)->sc_res[EPIC_FW_LED], EPIC_FW_LED_DATA, 1, \ - BUS_SPACE_BARRIER_READ); \ - DELAY(EPIC_DELAY); \ - __val; \ -}) - -#define EPIC_FW_LED_WRITE(sc, off, mask, val) do { \ - bus_write_1((sc)->sc_res[EPIC_FW_LED], EPIC_FW_LED_ADDR, (off));\ - bus_barrier((sc)->sc_res[EPIC_FW_LED], EPIC_FW_LED_ADDR, 1, \ - BUS_SPACE_BARRIER_READ | BUS_SPACE_BARRIER_WRITE); \ - DELAY(EPIC_DELAY); \ - bus_write_1((sc)->sc_res[EPIC_FW_LED], EPIC_FW_LED_WRITE_MASK, \ - (mask)); \ - bus_barrier((sc)->sc_res[EPIC_FW_LED], EPIC_FW_LED_WRITE_MASK, \ - 1, BUS_SPACE_BARRIER_READ | BUS_SPACE_BARRIER_WRITE); \ - DELAY(EPIC_DELAY); \ - bus_write_1((sc)->sc_res[EPIC_FW_LED], EPIC_FW_LED_DATA, (val));\ - bus_barrier((sc)->sc_res[EPIC_FW_LED], EPIC_FW_LED_DATA, 1, \ - BUS_SPACE_BARRIER_READ | BUS_SPACE_BARRIER_WRITE); \ - DELAY(EPIC_DELAY); \ -} while (0) - -#define EPIC_LOCK_INIT(sc) \ - mtx_init(&(sc)->sc_mtx, "epic mtx", NULL, MTX_DEF) -#define EPIC_LOCK_DESTROY(sc) mtx_destroy(&(sc)->sc_mtx) -#define EPIC_LOCK(sc) mtx_lock(&(sc)->sc_mtx) -#define EPIC_UNLOCK(sc) mtx_unlock(&(sc)->sc_mtx) - -static device_probe_t epic_probe; -static device_attach_t epic_attach; -static device_detach_t epic_detach; - -static void epic_led_alert(void *arg, int onoff); -static void epic_led_power(void *arg, int onoff); - -static device_method_t epic_methods[] = { - /* Device interface */ - DEVMETHOD(device_probe, epic_probe), - DEVMETHOD(device_attach, epic_attach), - DEVMETHOD(device_detach, epic_detach), - - DEVMETHOD_END -}; - -static devclass_t epic_devclass; - -DEFINE_CLASS_0(epic, epic_driver, epic_methods, - sizeof(struct epic_softc)); -DRIVER_MODULE(epic, ebus, epic_driver, epic_devclass, 0, 0); - -static int -epic_probe(device_t dev) -{ - const char* compat; - - compat = ofw_bus_get_compat(dev); - if (compat != NULL && strcmp(ofw_bus_get_name(dev), - "env-monitor") == 0 && strcmp(compat, "epic") == 0) { - device_set_desc(dev, "Sun Fire V215/V245 LEDs"); - return (BUS_PROBE_DEFAULT); - } - return (ENXIO); -} - -static int -epic_attach(device_t dev) -{ - struct epic_softc *sc; - - sc = device_get_softc(dev); - if (bus_alloc_resources(dev, epic_res_spec, sc->sc_res)) { - device_printf(dev, "failed to allocate resources\n"); - bus_release_resources(dev, epic_res_spec, sc->sc_res); - return (ENXIO); - } - - EPIC_LOCK_INIT(sc); - - if (bootverbose) - device_printf(dev, "version 0x%x\n", - EPIC_FW_LED_READ(sc, EPIC_FW_VERSION)); - - sc->sc_led_dev_alert = led_create(epic_led_alert, sc, "alert"); - sc->sc_led_dev_power = led_create(epic_led_power, sc, "power"); - - return (0); -} - -static int -epic_detach(device_t dev) -{ - struct epic_softc *sc; - - sc = device_get_softc(dev); - - led_destroy(sc->sc_led_dev_alert); - led_destroy(sc->sc_led_dev_power); - - bus_release_resources(dev, epic_res_spec, sc->sc_res); - - EPIC_LOCK_DESTROY(sc); - - return (0); -} - -static void -epic_led_alert(void *arg, int onoff) -{ - struct epic_softc *sc; - - sc = (struct epic_softc *)arg; - - EPIC_LOCK(sc); - EPIC_FW_LED_WRITE(sc, EPIC_LED_STATE0, EPIC_LED_ALERT_MASK, - onoff ? EPIC_LED_ALERT_ON : EPIC_LED_ALERT_OFF); - EPIC_UNLOCK(sc); -} - -static void -epic_led_power(void *arg, int onoff) -{ - struct epic_softc *sc; - - sc = (struct epic_softc *)arg; - - EPIC_LOCK(sc); - EPIC_FW_LED_WRITE(sc, EPIC_LED_STATE0, EPIC_LED_POWER_MASK, - onoff ? EPIC_LED_POWER_ON : EPIC_LED_POWER_OFF); - EPIC_UNLOCK(sc); -} diff --git a/sys/sparc64/fhc/clkbrd.c b/sys/sparc64/fhc/clkbrd.c deleted file mode 100644 index 002030f42508..000000000000 --- a/sys/sparc64/fhc/clkbrd.c +++ /dev/null @@ -1,214 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause - * - * Copyright (c) 2004 Jason L. Wright (jason@thought.net) - * Copyright (c) 2005 Marius Strobl - * 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 ``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 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. - * - * from: OpenBSD: clkbrd.c,v 1.5 2004/10/01 18:18:49 jason Exp - */ - -#include -__FBSDID("$FreeBSD$"); - -#include -#include -#include -#include -#include -#include - -#include -#include - -#include -#include - -#include - -#define CLKBRD_NREG 3 - -#define CLKBRD_CF 0 -#define CLKBRD_CLK 1 -#define CLKBRD_CLKVER 2 - -struct clkbrd_softc { - device_t sc_dev; - struct resource *sc_res[CLKBRD_NREG]; - int sc_rid[CLKBRD_NREG]; - bus_space_tag_t sc_bt[CLKBRD_NREG]; - bus_space_handle_t sc_bh[CLKBRD_NREG]; - uint8_t sc_clk_ctrl; - struct cdev *sc_led_dev; - int sc_flags; -#define CLKBRD_HAS_CLKVER (1 << 0) -}; - -static devclass_t clkbrd_devclass; - -static device_probe_t clkbrd_probe; -static device_attach_t clkbrd_attach; -static device_detach_t clkbrd_detach; - -static void clkbrd_free_resources(struct clkbrd_softc *); -static void clkbrd_led_func(void *, int); - -static device_method_t clkbrd_methods[] = { - /* Device interface */ - DEVMETHOD(device_probe, clkbrd_probe), - DEVMETHOD(device_attach, clkbrd_attach), - DEVMETHOD(device_detach, clkbrd_detach), - - { 0, 0 } -}; - -static driver_t clkbrd_driver = { - "clkbrd", - clkbrd_methods, - sizeof(struct clkbrd_softc), -}; - -DRIVER_MODULE(clkbrd, fhc, clkbrd_driver, clkbrd_devclass, 0, 0); - -static int -clkbrd_probe(device_t dev) -{ - - if (strcmp(ofw_bus_get_name(dev), "clock-board") == 0) { - device_set_desc(dev, "Clock Board"); - return (0); - } - return (ENXIO); -} - -static int -clkbrd_attach(device_t dev) -{ - struct clkbrd_softc *sc; - int i, slots; - uint8_t r; - - sc = device_get_softc(dev); - sc->sc_dev = dev; - - for (i = CLKBRD_CF; i <= CLKBRD_CLKVER; i++) { - sc->sc_rid[i] = i; - sc->sc_res[i] = bus_alloc_resource_any(sc->sc_dev, - SYS_RES_MEMORY, &sc->sc_rid[i], RF_ACTIVE); - if (sc->sc_res[i] == NULL) { - if (i != CLKBRD_CLKVER) { - device_printf(sc->sc_dev, - "could not allocate resource %d\n", i); - goto fail; - } - continue; - } - sc->sc_bt[i] = rman_get_bustag(sc->sc_res[i]); - sc->sc_bh[i] = rman_get_bushandle(sc->sc_res[i]); - if (i == CLKBRD_CLKVER) - sc->sc_flags |= CLKBRD_HAS_CLKVER; - } - - slots = 4; - r = bus_space_read_1(sc->sc_bt[CLKBRD_CLK], sc->sc_bh[CLKBRD_CLK], - CLK_STS1); - switch (r & CLK_STS1_SLOTS_MASK) { - case CLK_STS1_SLOTS_16: - slots = 16; - break; - case CLK_STS1_SLOTS_8: - slots = 8; - break; - case CLK_STS1_SLOTS_4: - if (sc->sc_flags & CLKBRD_HAS_CLKVER) { - r = bus_space_read_1(sc->sc_bt[CLKBRD_CLKVER], - sc->sc_bh[CLKBRD_CLKVER], CLKVER_SLOTS); - if (r != 0 && - (r & CLKVER_SLOTS_MASK) == CLKVER_SLOTS_PLUS) - slots = 5; - } - } - - device_printf(sc->sc_dev, "Sun Enterprise Exx00 machine: %d slots\n", - slots); - - sc->sc_clk_ctrl = bus_space_read_1(sc->sc_bt[CLKBRD_CLK], - sc->sc_bh[CLKBRD_CLK], CLK_CTRL); - sc->sc_led_dev = led_create(clkbrd_led_func, sc, "clockboard"); - - return (0); - - fail: - clkbrd_free_resources(sc); - - return (ENXIO); -} - -static int -clkbrd_detach(device_t dev) -{ - struct clkbrd_softc *sc; - - sc = device_get_softc(dev); - - led_destroy(sc->sc_led_dev); - bus_space_write_1(sc->sc_bt[CLKBRD_CLK], sc->sc_bh[CLKBRD_CLK], - CLK_CTRL, sc->sc_clk_ctrl); - bus_space_read_1(sc->sc_bt[CLKBRD_CLK], sc->sc_bh[CLKBRD_CLK], - CLK_CTRL); - clkbrd_free_resources(sc); - - return (0); -} - -static void -clkbrd_free_resources(struct clkbrd_softc *sc) -{ - int i; - - for (i = CLKBRD_CF; i <= CLKBRD_CLKVER; i++) - if (sc->sc_res[i] != NULL) - bus_release_resource(sc->sc_dev, SYS_RES_MEMORY, - sc->sc_rid[i], sc->sc_res[i]); -} - -static void -clkbrd_led_func(void *arg, int onoff) -{ - struct clkbrd_softc *sc; - uint8_t r; - - sc = (struct clkbrd_softc *)arg; - - r = bus_space_read_1(sc->sc_bt[CLKBRD_CLK], sc->sc_bh[CLKBRD_CLK], - CLK_CTRL); - if (onoff) - r |= CLK_CTRL_RLED; - else - r &= ~CLK_CTRL_RLED; - bus_space_write_1(sc->sc_bt[CLKBRD_CLK], sc->sc_bh[CLKBRD_CLK], - CLK_CTRL, r); - bus_space_read_1(sc->sc_bt[CLKBRD_CLK], sc->sc_bh[CLKBRD_CLK], - CLK_CTRL); -} diff --git a/sys/sparc64/fhc/clkbrdreg.h b/sys/sparc64/fhc/clkbrdreg.h deleted file mode 100644 index ec5baa79142e..000000000000 --- a/sys/sparc64/fhc/clkbrdreg.h +++ /dev/null @@ -1,99 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause - * - * Copyright (c) 2004 Jason L. Wright (jason@thought.net) - * Copyright (c) 2006 Marius Strobl - * 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 ``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 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. - * - * from: OpenBSD: clkbrdreg.h,v 1.2 2004/10/01 15:36:30 jason Exp - * - * $FreeBSD$ - */ - -#ifndef _SPARC64_FHC_CLKBRDREG_H_ -#define _SPARC64_FHC_CLKBRDREG_H_ - -/* register bank 0 */ -#define CLK_CF_REG2 0x20 /* clock frequency register 2 */ -#define CLK_CF_REG2_REN_RCONS 0x80 /* reset enable: remote console */ -#define CLK_CF_REG2_REN_GEN 0x40 /* reset enable: frequency change */ -#define CLK_CF_REG2_REN_WDOG 0x20 /* reset enable: watchdog */ -#define CLK_CF_REG2_DIV1 0x10 /* CPU module divisor bit 1 */ -#define CLK_CF_REG2_RANGE 0x0c /* clock range */ -#define CLK_CF_REG2_DIV0 0x02 /* CPU module divisor bit 0 */ -#define CLK_CF_REG2_FREQ8 0x01 /* frequency bit 8 */ - -/* register bank 1 */ -#define CLK_CTRL 0x00 /* system control register */ -#define CLK_CTRL_IEN_FAN 0x80 /* intr enable: fan failure */ -#define CLK_CTRL_IEN_DC 0x40 /* intr enable: power supply DC */ -#define CLK_CTRL_IEN_AC 0x20 /* intr enable: AC power */ -#define CLK_CTRL_IEN_BRD 0x10 /* intr enable: board insert */ -#define CLK_CTRL_POFF 0x08 /* turn off system power */ -#define CLK_CTRL_LLED 0x04 /* left led (reversed) */ -#define CLK_CTRL_MLED 0x02 /* middle led */ -#define CLK_CTRL_RLED 0x01 /* right led */ -#define CLK_STS1 0x10 /* system status register 1 */ -#define CLK_STS1_SLOTS_MASK 0xc0 /* system status 1 slots mask */ -#define CLK_STS1_SLOTS_16 0x40 /* 16 slots */ -#define CLK_STS1_SLOTS_8 0xc0 /* 8 slots */ -#define CLK_STS1_SLOTS_4 0x80 /* 4 slots */ -#define CLK_STS1_SLOTS_TESTBED 0x00 /* test machine */ -#define CLK_STS1_SECURE 0x20 /* key in position secure (reversed) */ -#define CLK_STS1_FAN 0x10 /* fan tray present (reversed) */ -#define CLK_STS1_BRD 0x08 /* board inserted (reversed) */ -#define CLK_STS1_PS0 0x04 /* power supply 0 present (reversed) */ -#define CLK_STS1_RST_WDOG 0x02 /* rst by: watchdog (reversed) */ -#define CLK_STS1_RST_GEN 0x01 /* rst by: freq change (reversed) */ -#define CLK_STS2 0x20 /* system status register 2 */ -#define CLK_STS2_RST_RCONS 0x80 /* rst by: remote console (reversed) */ -#define CLK_STS2_OK_PS0 0x40 /* ok: power supply 0 */ -#define CLK_STS2_OK_33V 0x20 /* ok: 3.3V on clock board */ -#define CLK_STS2_OK_50V 0x10 /* ok: 5.0V on clock board */ -#define CLK_STS2_FAIL_AC 0x08 /* failed: AC power */ -#define CLK_STS2_FAIL_FAN 0x04 /* failed: rack fans */ -#define CLK_STS2_OK_ACFAN 0x02 /* ok: 4 AC box fans */ -#define CLK_STS2_OK_KEYFAN 0x01 /* ok: keyswitch fans */ -#define CLK_PSTS1 0x30 /* power supply 1 status register */ -#define CLK_PSTS1_PS 0x80 /* power supply 1 present (reversed) */ -#define CLK_PPRES 0x40 /* power supply presence register */ -#define CLK_PPRES_CSHARE 0x80 /* current share backplane */ -#define CLK_PPRES_OK_MASK 0x7f /* precharge and peripheral pwr mask */ -#define CLK_PPRES_OK_P_5V 0x40 /* ok: peripheral 5V */ -#define CLK_PPRES_OK_P_12V 0x20 /* ok: peripheral 12V */ -#define CLK_PPRES_OK_AUX_5V 0x10 /* ok: auxiliary 5V */ -#define CLK_PPRES_OK_PP_5V 0x08 /* ok: peripheral 5V precharge */ -#define CLK_PPRES_OK_PP_12V 0x04 /* ok: peripheral 12V precharge */ -#define CLK_PPRES_OK_SP_3V 0x02 /* ok: system 3.3V precharge */ -#define CLK_PPRES_OK_SP_5V 0x01 /* ok: system 5V precharge */ -#define CLK_TEMP 0x50 /* temperature register */ -#define CLK_IDIAG 0x60 /* interrupt diagnostic register */ -#define CLK_PSTS2 0x70 /* power supply 2 status register */ - -/* register bank 2 */ -#define CLKVER_SLOTS 0x00 /* clock version slots register */ -#define CLKVER_SLOTS_MASK 0x80 /* clock version slots mask */ -#define CLKVER_SLOTS_PLUS 0x00 /* plus system (reversed) */ - -#endif /* !_SPARC64_FHC_CLKBRDREG_H_ */ diff --git a/sys/sparc64/fhc/fhc.c b/sys/sparc64/fhc/fhc.c deleted file mode 100644 index cc858cfc9544..000000000000 --- a/sys/sparc64/fhc/fhc.c +++ /dev/null @@ -1,537 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD - * - * Copyright (c) 2003 Jake Burkholder. - * Copyright (c) 2005 Marius Strobl - * 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 -__FBSDID("$FreeBSD$"); - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include -#include -#include - -#include - -#include -#include - -struct fhc_devinfo { - struct ofw_bus_devinfo fdi_obdinfo; - struct resource_list fdi_rl; -}; - -struct fhc_softc { - struct resource *sc_memres[FHC_NREG]; - int sc_nrange; - struct sbus_ranges *sc_ranges; - int sc_ign; - struct cdev *sc_led_dev; -}; - -static device_probe_t fhc_probe; -static device_attach_t fhc_attach; -static bus_print_child_t fhc_print_child; -static bus_probe_nomatch_t fhc_probe_nomatch; -static bus_setup_intr_t fhc_setup_intr; -static bus_alloc_resource_t fhc_alloc_resource; -static bus_adjust_resource_t fhc_adjust_resource; -static bus_get_resource_list_t fhc_get_resource_list; -static ofw_bus_get_devinfo_t fhc_get_devinfo; - -static void fhc_intr_enable(void *); -static void fhc_intr_disable(void *); -static void fhc_intr_assign(void *); -static void fhc_intr_clear(void *); -static void fhc_led_func(void *, int); -static int fhc_print_res(struct fhc_devinfo *); - -static device_method_t fhc_methods[] = { - /* Device interface */ - DEVMETHOD(device_probe, fhc_probe), - DEVMETHOD(device_attach, fhc_attach), - DEVMETHOD(device_shutdown, bus_generic_shutdown), - DEVMETHOD(device_suspend, bus_generic_suspend), - DEVMETHOD(device_resume, bus_generic_resume), - - /* Bus interface */ - DEVMETHOD(bus_print_child, fhc_print_child), - DEVMETHOD(bus_probe_nomatch, fhc_probe_nomatch), - DEVMETHOD(bus_alloc_resource, fhc_alloc_resource), - DEVMETHOD(bus_activate_resource, bus_generic_activate_resource), - DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource), - DEVMETHOD(bus_adjust_resource, fhc_adjust_resource), - DEVMETHOD(bus_release_resource, bus_generic_rl_release_resource), - DEVMETHOD(bus_setup_intr, fhc_setup_intr), - DEVMETHOD(bus_teardown_intr, bus_generic_teardown_intr), - DEVMETHOD(bus_get_resource, bus_generic_rl_get_resource), - DEVMETHOD(bus_get_resource_list, fhc_get_resource_list), - DEVMETHOD(bus_child_pnpinfo_str, ofw_bus_gen_child_pnpinfo_str), - - /* ofw_bus interface */ - DEVMETHOD(ofw_bus_get_devinfo, fhc_get_devinfo), - DEVMETHOD(ofw_bus_get_compat, ofw_bus_gen_get_compat), - DEVMETHOD(ofw_bus_get_model, ofw_bus_gen_get_model), - DEVMETHOD(ofw_bus_get_name, ofw_bus_gen_get_name), - DEVMETHOD(ofw_bus_get_node, ofw_bus_gen_get_node), - DEVMETHOD(ofw_bus_get_type, ofw_bus_gen_get_type), - - DEVMETHOD_END -}; - -static driver_t fhc_driver = { - "fhc", - fhc_methods, - sizeof(struct fhc_softc), -}; - -static devclass_t fhc_devclass; - -EARLY_DRIVER_MODULE(fhc, central, fhc_driver, fhc_devclass, 0, 0, - BUS_PASS_BUS); -MODULE_DEPEND(fhc, central, 1, 1, 1); -EARLY_DRIVER_MODULE(fhc, nexus, fhc_driver, fhc_devclass, 0, 0, - BUS_PASS_BUS); -MODULE_DEPEND(fhc, nexus, 1, 1, 1); -MODULE_VERSION(fhc, 1); - -static const struct intr_controller fhc_ic = { - fhc_intr_enable, - fhc_intr_disable, - fhc_intr_assign, - fhc_intr_clear -}; - -struct fhc_icarg { - struct fhc_softc *fica_sc; - struct resource *fica_memres; -}; - -static int -fhc_probe(device_t dev) -{ - - if (strcmp(ofw_bus_get_name(dev), "fhc") == 0) { - device_set_desc(dev, "fhc"); - return (0); - } - return (ENXIO); -} - -static int -fhc_attach(device_t dev) -{ - char ledname[sizeof("boardXX")]; - struct fhc_devinfo *fdi; - struct fhc_icarg *fica; - struct fhc_softc *sc; - struct sbus_regs *reg; - phandle_t child; - phandle_t node; - device_t cdev; - uint32_t board; - uint32_t ctrl; - uint32_t *intr; - uint32_t iv; - char *name; - int central; - int error; - int i; - int j; - - sc = device_get_softc(dev); - node = ofw_bus_get_node(dev); - - central = 0; - if (strcmp(device_get_name(device_get_parent(dev)), "central") == 0) - central = 1; - - for (i = 0; i < FHC_NREG; i++) { - j = i; - sc->sc_memres[i] = bus_alloc_resource_any(dev, SYS_RES_MEMORY, - &j, RF_ACTIVE); - if (sc->sc_memres[i] == NULL) { - device_printf(dev, "cannot allocate resource %d\n", i); - error = ENXIO; - goto fail_memres; - } - } - - if (central != 0) { - board = bus_read_4(sc->sc_memres[FHC_INTERNAL], FHC_BSR); - board = ((board >> 16) & 0x1) | ((board >> 12) & 0xe); - } else { - if (OF_getprop(node, "board#", &board, sizeof(board)) == -1) { - device_printf(dev, "cannot get board number\n"); - error = ENXIO; - goto fail_memres; - } - } - - device_printf(dev, "board %d, ", board); - if (OF_getprop_alloc(node, "board-model", (void **)&name) != -1) { - printf("model %s\n", name); - OF_prop_free(name); - } else - printf("model unknown\n"); - - for (i = FHC_FANFAIL; i <= FHC_TOD; i++) { - bus_write_4(sc->sc_memres[i], FHC_ICLR, INTCLR_IDLE); - (void)bus_read_4(sc->sc_memres[i], FHC_ICLR); - } - - sc->sc_ign = board << 1; - bus_write_4(sc->sc_memres[FHC_IGN], 0x0, sc->sc_ign); - sc->sc_ign = bus_read_4(sc->sc_memres[FHC_IGN], 0x0); - - ctrl = bus_read_4(sc->sc_memres[FHC_INTERNAL], FHC_CTRL); - if (central == 0) - ctrl |= FHC_CTRL_IXIST; - ctrl &= ~(FHC_CTRL_AOFF | FHC_CTRL_BOFF | FHC_CTRL_SLINE); - bus_write_4(sc->sc_memres[FHC_INTERNAL], FHC_CTRL, ctrl); - (void)bus_read_4(sc->sc_memres[FHC_INTERNAL], FHC_CTRL); - - sc->sc_nrange = OF_getprop_alloc_multi(node, "ranges", - sizeof(*sc->sc_ranges), (void **)&sc->sc_ranges); - if (sc->sc_nrange == -1) { - device_printf(dev, "cannot get ranges\n"); - error = ENXIO; - goto fail_memres; - } - - /* - * Apparently only the interrupt controller of boards hanging off - * of central(4) is indented to be used, otherwise we would have - * conflicts registering the interrupt controllers for all FHC - * boards as the board number and thus the IGN isn't unique. - */ - if (central == 1) { - /* - * Hunt through all the interrupt mapping regs and register - * our interrupt controller for the corresponding interrupt - * vectors. We do this early in order to be able to catch - * stray interrupts. - */ - for (i = FHC_FANFAIL; i <= FHC_TOD; i++) { - fica = malloc(sizeof(*fica), M_DEVBUF, M_NOWAIT); - if (fica == NULL) - panic("%s: could not allocate interrupt " - "controller argument", __func__); - fica->fica_sc = sc; - fica->fica_memres = sc->sc_memres[i]; -#ifdef FHC_DEBUG - device_printf(dev, "intr map %d: %#lx, clr: %#lx\n", i, - (u_long)bus_read_4(fica->fica_memres, FHC_IMAP), - (u_long)bus_read_4(fica->fica_memres, FHC_ICLR)); -#endif - /* - * XXX we only pick the INO rather than the INR - * from the IMR since the firmware may not provide - * the IGN and the IGN is constant for all devices - * on that FireHose controller. - */ - j = intr_controller_register(INTMAP_VEC(sc->sc_ign, - INTINO(bus_read_4(fica->fica_memres, FHC_IMAP))), - &fhc_ic, fica); - if (j != 0) - device_printf(dev, "could not register " - "interrupt controller for map %d (%d)\n", - i, j); - } - } else { - snprintf(ledname, sizeof(ledname), "board%d", board); - sc->sc_led_dev = led_create(fhc_led_func, sc, ledname); - } - - for (child = OF_child(node); child != 0; child = OF_peer(child)) { - fdi = malloc(sizeof(*fdi), M_DEVBUF, M_WAITOK | M_ZERO); - if (ofw_bus_gen_setup_devinfo(&fdi->fdi_obdinfo, child) != 0) { - free(fdi, M_DEVBUF); - continue; - } - i = OF_getprop_alloc_multi(child, "reg", sizeof(*reg), - (void **)®); - if (i == -1) { - device_printf(dev, "<%s>: incomplete\n", - fdi->fdi_obdinfo.obd_name); - ofw_bus_gen_destroy_devinfo(&fdi->fdi_obdinfo); - free(fdi, M_DEVBUF); - continue; - } - resource_list_init(&fdi->fdi_rl); - for (j = 0; j < i; j++) - resource_list_add(&fdi->fdi_rl, SYS_RES_MEMORY, j, - reg[j].sbr_offset, reg[j].sbr_offset + - reg[j].sbr_size, reg[j].sbr_size); - OF_prop_free(reg); - if (central == 1) { - i = OF_getprop_alloc_multi(child, "interrupts", - sizeof(*intr), (void **)&intr); - if (i != -1) { - for (j = 0; j < i; j++) { - iv = INTMAP_VEC(sc->sc_ign, intr[j]); - resource_list_add(&fdi->fdi_rl, - SYS_RES_IRQ, j, iv, iv, 1); - } - OF_prop_free(intr); - } - } - cdev = device_add_child(dev, NULL, -1); - if (cdev == NULL) { - device_printf(dev, "<%s>: device_add_child failed\n", - fdi->fdi_obdinfo.obd_name); - resource_list_free(&fdi->fdi_rl); - ofw_bus_gen_destroy_devinfo(&fdi->fdi_obdinfo); - free(fdi, M_DEVBUF); - continue; - } - device_set_ivars(cdev, fdi); - } - - return (bus_generic_attach(dev)); - - fail_memres: - for (i = 0; i < FHC_NREG; i++) - if (sc->sc_memres[i] != NULL) - bus_release_resource(dev, SYS_RES_MEMORY, - rman_get_rid(sc->sc_memres[i]), sc->sc_memres[i]); - return (error); -} - -static int -fhc_print_child(device_t dev, device_t child) -{ - int rv; - - rv = bus_print_child_header(dev, child); - rv += fhc_print_res(device_get_ivars(child)); - rv += bus_print_child_footer(dev, child); - return (rv); -} - -static void -fhc_probe_nomatch(device_t dev, device_t child) -{ - const char *type; - - device_printf(dev, "<%s>", ofw_bus_get_name(child)); - fhc_print_res(device_get_ivars(child)); - type = ofw_bus_get_type(child); - printf(" type %s (no driver attached)\n", - type != NULL ? type : "unknown"); -} - -static void -fhc_intr_enable(void *arg) -{ - struct intr_vector *iv = arg; - struct fhc_icarg *fica = iv->iv_icarg; - - bus_write_4(fica->fica_memres, FHC_IMAP, - INTMAP_ENABLE(iv->iv_vec, iv->iv_mid)); - (void)bus_read_4(fica->fica_memres, FHC_IMAP); -} - -static void -fhc_intr_disable(void *arg) -{ - struct intr_vector *iv = arg; - struct fhc_icarg *fica = iv->iv_icarg; - - bus_write_4(fica->fica_memres, FHC_IMAP, iv->iv_vec); - (void)bus_read_4(fica->fica_memres, FHC_IMAP); -} - -static void -fhc_intr_assign(void *arg) -{ - struct intr_vector *iv = arg; - struct fhc_icarg *fica = iv->iv_icarg; - - bus_write_4(fica->fica_memres, FHC_IMAP, INTMAP_TID( - bus_read_4(fica->fica_memres, FHC_IMAP), iv->iv_mid)); - (void)bus_read_4(fica->fica_memres, FHC_IMAP); -} - -static void -fhc_intr_clear(void *arg) -{ - struct intr_vector *iv = arg; - struct fhc_icarg *fica = iv->iv_icarg; - - bus_write_4(fica->fica_memres, FHC_ICLR, INTCLR_IDLE); - (void)bus_read_4(fica->fica_memres, FHC_ICLR); -} - -static int -fhc_setup_intr(device_t bus, device_t child, struct resource *r, int flags, - driver_filter_t *filt, driver_intr_t *func, void *arg, void **cookiep) -{ - struct fhc_softc *sc; - u_long vec; - - sc = device_get_softc(bus); - /* - * Make sure the vector is fully specified and we registered - * our interrupt controller for it. - */ - vec = rman_get_start(r); - if (INTIGN(vec) != sc->sc_ign || intr_vectors[vec].iv_ic != &fhc_ic) { - device_printf(bus, "invalid interrupt vector 0x%lx\n", vec); - return (EINVAL); - } - return (bus_generic_setup_intr(bus, child, r, flags, filt, func, - arg, cookiep)); -} - -static struct resource * -fhc_alloc_resource(device_t bus, device_t child, int type, int *rid, - rman_res_t start, rman_res_t end, rman_res_t count, u_int flags) -{ - struct resource_list *rl; - struct resource_list_entry *rle; - struct fhc_softc *sc; - struct resource *res; - bus_addr_t coffset; - bus_addr_t cend; - bus_addr_t phys; - int isdefault; - int passthrough; - int i; - - isdefault = RMAN_IS_DEFAULT_RANGE(start, end); - passthrough = (device_get_parent(child) != bus); - res = NULL; - rle = NULL; - rl = BUS_GET_RESOURCE_LIST(bus, child); - sc = device_get_softc(bus); - switch (type) { - case SYS_RES_IRQ: - return (resource_list_alloc(rl, bus, child, type, rid, start, - end, count, flags)); - case SYS_RES_MEMORY: - if (!passthrough) { - rle = resource_list_find(rl, type, *rid); - if (rle == NULL) - return (NULL); - if (rle->res != NULL) - panic("%s: resource entry is busy", __func__); - if (isdefault) { - start = rle->start; - count = ulmax(count, rle->count); - end = ulmax(rle->end, start + count - 1); - } - } - for (i = 0; i < sc->sc_nrange; i++) { - coffset = sc->sc_ranges[i].coffset; - cend = coffset + sc->sc_ranges[i].size - 1; - if (start >= coffset && end <= cend) { - start -= coffset; - end -= coffset; - phys = sc->sc_ranges[i].poffset | - ((bus_addr_t)sc->sc_ranges[i].pspace << 32); - res = bus_generic_alloc_resource(bus, child, - type, rid, phys + start, phys + end, - count, flags); - if (!passthrough) - rle->res = res; - break; - } - } - break; - } - return (res); -} - -static int -fhc_adjust_resource(device_t bus __unused, device_t child __unused, - int type __unused, struct resource *r __unused, rman_res_t start __unused, - rman_res_t end __unused) -{ - - return (ENXIO); -} - -static struct resource_list * -fhc_get_resource_list(device_t bus, device_t child) -{ - struct fhc_devinfo *fdi; - - fdi = device_get_ivars(child); - return (&fdi->fdi_rl); -} - -static const struct ofw_bus_devinfo * -fhc_get_devinfo(device_t bus, device_t child) -{ - struct fhc_devinfo *fdi; - - fdi = device_get_ivars(child); - return (&fdi->fdi_obdinfo); -} - -static void -fhc_led_func(void *arg, int onoff) -{ - struct fhc_softc *sc; - uint32_t ctrl; - - sc = (struct fhc_softc *)arg; - - ctrl = bus_read_4(sc->sc_memres[FHC_INTERNAL], FHC_CTRL); - if (onoff) - ctrl |= FHC_CTRL_RLED; - else - ctrl &= ~FHC_CTRL_RLED; - ctrl &= ~(FHC_CTRL_AOFF | FHC_CTRL_BOFF | FHC_CTRL_SLINE); - bus_write_4(sc->sc_memres[FHC_INTERNAL], FHC_CTRL, ctrl); - (void)bus_read_4(sc->sc_memres[FHC_INTERNAL], FHC_CTRL); -} - -static int -fhc_print_res(struct fhc_devinfo *fdi) -{ - int rv; - - rv = 0; - rv += resource_list_print_type(&fdi->fdi_rl, "mem", SYS_RES_MEMORY, - "%#jx"); - rv += resource_list_print_type(&fdi->fdi_rl, "irq", SYS_RES_IRQ, "%jd"); - return (rv); -} diff --git a/sys/sparc64/fhc/fhcreg.h b/sys/sparc64/fhc/fhcreg.h deleted file mode 100644 index e01afe7a7651..000000000000 --- a/sys/sparc64/fhc/fhcreg.h +++ /dev/null @@ -1,97 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD AND BSD-2-Clause - * - * Copyright (c) 2003 Jake Burkholder. - * 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. - */ -/*- - * Copyright (c) 2004 Jason L. Wright (jason@thought.net). - * 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 ``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 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. - * - * from: OpenBSD: fhcreg.h,v 1.3 2004/09/28 16:26:03 jason Exp - * - * $FreeBSD$ - */ - -#ifndef _SPARC64_FHC_FHCREG_H_ -#define _SPARC64_FHC_FHCREG_H_ - -#define FHC_NREG (6) - -#define FHC_INTERNAL (0) -#define FHC_IGN (1) -#define FHC_FANFAIL (2) -#define FHC_SYSTEM (3) -#define FHC_UART (4) -#define FHC_TOD (5) - -#define FHC_IMAP 0x0 -#define FHC_ICLR 0x10 - -#define FHC_ID 0x00000000 /* ID */ -#define FHC_RCS 0x00000010 /* reset ctrl/status */ -#define FHC_CTRL 0x00000020 /* control */ -#define FHC_BSR 0x00000030 /* board status */ -#define FHC_ECC 0x00000040 /* ECC control */ -#define FHC_JCTRL 0x000000f0 /* JTAG control */ - -#define FHC_CTRL_ICS 0x00100000 /* ignore centerplane sigs */ -#define FHC_CTRL_FRST 0x00080000 /* fatal error reset enable */ -#define FHC_CTRL_LFAT 0x00040000 /* AC/DC local error */ -#define FHC_CTRL_SLINE 0x00010000 /* firmware sync line */ -#define FHC_CTRL_DCD 0x00008000 /* DC/DC converter disable */ -#define FHC_CTRL_POFF 0x00004000 /* AC/DC ctlr PLL disable */ -#define FHC_CTRL_FOFF 0x00002000 /* FHC ctlr PLL disable */ -#define FHC_CTRL_AOFF 0x00001000 /* cpu a sram low pwr mode */ -#define FHC_CTRL_BOFF 0x00000800 /* cpu b sram low pwr mode */ -#define FHC_CTRL_PSOFF 0x00000400 /* disable fhc power supply */ -#define FHC_CTRL_IXIST 0x00000200 /* fhc notifies clock-board */ -#define FHC_CTRL_XMSTR 0x00000100 /* xir master enable */ -#define FHC_CTRL_LLED 0x00000040 /* left led (reversed) */ -#define FHC_CTRL_MLED 0x00000020 /* middle led */ -#define FHC_CTRL_RLED 0x00000010 /* right led */ -#define FHC_CTRL_BPINS 0x00000003 /* spare bidir pins */ - -#endif /* !_SPARC64_FHC_FHCREG_H_ */ diff --git a/sys/sparc64/include/_align.h b/sys/sparc64/include/_align.h deleted file mode 100644 index daf6de7c3524..000000000000 --- a/sys/sparc64/include/_align.h +++ /dev/null @@ -1,46 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD - * - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * 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 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. - * - * from: @(#)param.h 5.8 (Berkeley) 6/28/91 - * $FreeBSD$ - */ - -#ifndef _SPARC64_INCLUDE__ALIGN_H_ -#define _SPARC64_INCLUDE__ALIGN_H_ - -/* - * Round p (pointer or byte index) up to a correctly-aligned value - * for all data types (int, long, ...). The result is unsigned int - * and must be cast to any desired pointer type. - */ -#define _ALIGNBYTES 0xf -#define _ALIGN(p) (((u_long)(p) + _ALIGNBYTES) & ~_ALIGNBYTES) - -#endif /* !_SPARC64_INCLUDE__ALIGN_H_ */ diff --git a/sys/sparc64/include/_bus.h b/sys/sparc64/include/_bus.h deleted file mode 100644 index e6b6101b9c54..000000000000 --- a/sys/sparc64/include/_bus.h +++ /dev/null @@ -1,40 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD - * - * Copyright (c) 2005 M. Warner Losh - * - * 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, - * without modification, immediately at the beginning of the file. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD$ - */ - -#ifndef SPARC64_INCLUDE__BUS_H -#define SPARC64_INCLUDE__BUS_H - -typedef u_long bus_addr_t; -typedef u_long bus_size_t; -typedef u_long bus_space_handle_t; -typedef struct bus_space_tag *bus_space_tag_t; - -#endif /* SPARC64_INCLUDE__BUS_H */ diff --git a/sys/sparc64/include/_inttypes.h b/sys/sparc64/include/_inttypes.h deleted file mode 100644 index 46c13582d70a..000000000000 --- a/sys/sparc64/include/_inttypes.h +++ /dev/null @@ -1,215 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD - * - * Copyright (c) 2001 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Klaus Klein. - * - * 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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. - * - * From: $NetBSD: int_fmtio.h,v 1.4 2008/04/28 20:23:36 martin Exp $ - * $FreeBSD$ - */ - -#ifndef _MACHINE_INTTYPES_H_ -#define _MACHINE_INTTYPES_H_ - -/* - * Macros for format specifiers. - */ - -/* fprintf(3) macros for signed integers. */ - -#define PRId8 "d" /* int8_t */ -#define PRId16 "d" /* int16_t */ -#define PRId32 "d" /* int32_t */ -#define PRId64 "ld" /* int64_t */ -#define PRIdLEAST8 "d" /* int_least8_t */ -#define PRIdLEAST16 "d" /* int_least16_t */ -#define PRIdLEAST32 "d" /* int_least32_t */ -#define PRIdLEAST64 "ld" /* int_least64_t */ -#define PRIdFAST8 "d" /* int_fast8_t */ -#define PRIdFAST16 "d" /* int_fast16_t */ -#define PRIdFAST32 "d" /* int_fast32_t */ -#define PRIdFAST64 "ld" /* int_fast64_t */ -#define PRIdMAX "jd" /* intmax_t */ -#define PRIdPTR "ld" /* intptr_t */ - -#define PRIi8 "i" /* int8_t */ -#define PRIi16 "i" /* int16_t */ -#define PRIi32 "i" /* int32_t */ -#define PRIi64 "li" /* int64_t */ -#define PRIiLEAST8 "i" /* int_least8_t */ -#define PRIiLEAST16 "i" /* int_least16_t */ -#define PRIiLEAST32 "i" /* int_least32_t */ -#define PRIiLEAST64 "li" /* int_least64_t */ -#define PRIiFAST8 "i" /* int_fast8_t */ -#define PRIiFAST16 "i" /* int_fast16_t */ -#define PRIiFAST32 "i" /* int_fast32_t */ -#define PRIiFAST64 "li" /* int_fast64_t */ -#define PRIiMAX "ji" /* intmax_t */ -#define PRIiPTR "li" /* intptr_t */ - -/* fprintf(3) macros for unsigned integers. */ - -#define PRIo8 "o" /* uint8_t */ -#define PRIo16 "o" /* uint16_t */ -#define PRIo32 "o" /* uint32_t */ -#define PRIo64 "lo" /* uint64_t */ -#define PRIoLEAST8 "o" /* uint_least8_t */ -#define PRIoLEAST16 "o" /* uint_least16_t */ -#define PRIoLEAST32 "o" /* uint_least32_t */ -#define PRIoLEAST64 "lo" /* uint_least64_t */ -#define PRIoFAST8 "o" /* uint_fast8_t */ -#define PRIoFAST16 "o" /* uint_fast16_t */ -#define PRIoFAST32 "o" /* uint_fast32_t */ -#define PRIoFAST64 "lo" /* uint_fast64_t */ -#define PRIoMAX "jo" /* uintmax_t */ -#define PRIoPTR "lo" /* uintptr_t */ - -#define PRIu8 "u" /* uint8_t */ -#define PRIu16 "u" /* uint16_t */ -#define PRIu32 "u" /* uint32_t */ -#define PRIu64 "lu" /* uint64_t */ -#define PRIuLEAST8 "u" /* uint_least8_t */ -#define PRIuLEAST16 "u" /* uint_least16_t */ -#define PRIuLEAST32 "u" /* uint_least32_t */ -#define PRIuLEAST64 "lu" /* uint_least64_t */ -#define PRIuFAST8 "u" /* uint_fast8_t */ -#define PRIuFAST16 "u" /* uint_fast16_t */ -#define PRIuFAST32 "u" /* uint_fast32_t */ -#define PRIuFAST64 "lu" /* uint_fast64_t */ -#define PRIuMAX "ju" /* uintmax_t */ -#define PRIuPTR "lu" /* uintptr_t */ - -#define PRIx8 "x" /* uint8_t */ -#define PRIx16 "x" /* uint16_t */ -#define PRIx32 "x" /* uint32_t */ -#define PRIx64 "lx" /* uint64_t */ -#define PRIxLEAST8 "x" /* uint_least8_t */ -#define PRIxLEAST16 "x" /* uint_least16_t */ -#define PRIxLEAST32 "x" /* uint_least32_t */ -#define PRIxLEAST64 "lx" /* uint_least64_t */ -#define PRIxFAST8 "x" /* uint_fast8_t */ -#define PRIxFAST16 "x" /* uint_fast16_t */ -#define PRIxFAST32 "x" /* uint_fast32_t */ -#define PRIxFAST64 "lx" /* uint_fast64_t */ -#define PRIxMAX "jx" /* uintmax_t */ -#define PRIxPTR "lx" /* uintptr_t */ - -#define PRIX8 "X" /* uint8_t */ -#define PRIX16 "X" /* uint16_t */ -#define PRIX32 "X" /* uint32_t */ -#define PRIX64 "lX" /* uint64_t */ -#define PRIXLEAST8 "X" /* uint_least8_t */ -#define PRIXLEAST16 "X" /* uint_least16_t */ -#define PRIXLEAST32 "X" /* uint_least32_t */ -#define PRIXLEAST64 "lX" /* uint_least64_t */ -#define PRIXFAST8 "X" /* uint_fast8_t */ -#define PRIXFAST16 "X" /* uint_fast16_t */ -#define PRIXFAST32 "X" /* uint_fast32_t */ -#define PRIXFAST64 "lX" /* uint_fast64_t */ -#define PRIXMAX "jX" /* uintmax_t */ -#define PRIXPTR "lX" /* uintptr_t */ - -/* fscanf(3) macros for signed integers. */ - -#define SCNd8 "hhd" /* int8_t */ -#define SCNd16 "hd" /* int16_t */ -#define SCNd32 "d" /* int32_t */ -#define SCNd64 "ld" /* int64_t */ -#define SCNdLEAST8 "hhd" /* int_least8_t */ -#define SCNdLEAST16 "hd" /* int_least16_t */ -#define SCNdLEAST32 "d" /* int_least32_t */ -#define SCNdLEAST64 "ld" /* int_least64_t */ -#define SCNdFAST8 "d" /* int_fast8_t */ -#define SCNdFAST16 "d" /* int_fast16_t */ -#define SCNdFAST32 "d" /* int_fast32_t */ -#define SCNdFAST64 "ld" /* int_fast64_t */ -#define SCNdMAX "jd" /* intmax_t */ -#define SCNdPTR "ld" /* intptr_t */ - -#define SCNi8 "hhi" /* int8_t */ -#define SCNi16 "hi" /* int16_t */ -#define SCNi32 "i" /* int32_t */ -#define SCNi64 "li" /* int64_t */ -#define SCNiLEAST8 "hhi" /* int_least8_t */ -#define SCNiLEAST16 "hi" /* int_least16_t */ -#define SCNiLEAST32 "i" /* int_least32_t */ -#define SCNiLEAST64 "li" /* int_least64_t */ -#define SCNiFAST8 "i" /* int_fast8_t */ -#define SCNiFAST16 "i" /* int_fast16_t */ -#define SCNiFAST32 "i" /* int_fast32_t */ -#define SCNiFAST64 "li" /* int_fast64_t */ -#define SCNiMAX "ji" /* intmax_t */ -#define SCNiPTR "li" /* intptr_t */ - -/* fscanf(3) macros for unsigned integers. */ - -#define SCNo8 "hho" /* uint8_t */ -#define SCNo16 "ho" /* uint16_t */ -#define SCNo32 "o" /* uint32_t */ -#define SCNo64 "lo" /* uint64_t */ -#define SCNoLEAST8 "hho" /* uint_least8_t */ -#define SCNoLEAST16 "ho" /* uint_least16_t */ -#define SCNoLEAST32 "o" /* uint_least32_t */ -#define SCNoLEAST64 "lo" /* uint_least64_t */ -#define SCNoFAST8 "o" /* uint_fast8_t */ -#define SCNoFAST16 "o" /* uint_fast16_t */ -#define SCNoFAST32 "o" /* uint_fast32_t */ -#define SCNoFAST64 "lo" /* uint_fast64_t */ -#define SCNoMAX "jo" /* uintmax_t */ -#define SCNoPTR "lo" /* uintptr_t */ - -#define SCNu8 "hhu" /* uint8_t */ -#define SCNu16 "hu" /* uint16_t */ -#define SCNu32 "u" /* uint32_t */ -#define SCNu64 "lu" /* uint64_t */ -#define SCNuLEAST8 "hhu" /* uint_least8_t */ -#define SCNuLEAST16 "hu" /* uint_least16_t */ -#define SCNuLEAST32 "u" /* uint_least32_t */ -#define SCNuLEAST64 "lu" /* uint_least64_t */ -#define SCNuFAST8 "u" /* uint_fast8_t */ -#define SCNuFAST16 "u" /* uint_fast16_t */ -#define SCNuFAST32 "u" /* uint_fast32_t */ -#define SCNuFAST64 "lu" /* uint_fast64_t */ -#define SCNuMAX "ju" /* uintmax_t */ -#define SCNuPTR "lu" /* uintptr_t */ - -#define SCNx8 "hhx" /* uint8_t */ -#define SCNx16 "hx" /* uint16_t */ -#define SCNx32 "x" /* uint32_t */ -#define SCNx64 "lx" /* uint64_t */ -#define SCNxLEAST8 "hhx" /* uint_least8_t */ -#define SCNxLEAST16 "hx" /* uint_least16_t */ -#define SCNxLEAST32 "x" /* uint_least32_t */ -#define SCNxLEAST64 "lx" /* uint_least64_t */ -#define SCNxFAST8 "x" /* uint_fast8_t */ -#define SCNxFAST16 "x" /* uint_fast16_t */ -#define SCNxFAST32 "x" /* uint_fast32_t */ -#define SCNxFAST64 "lx" /* uint_fast64_t */ -#define SCNxMAX "jx" /* uintmax_t */ -#define SCNxPTR "lx" /* uintptr_t */ - -#endif /* !_MACHINE_INTTYPES_H_ */ diff --git a/sys/sparc64/include/_limits.h b/sys/sparc64/include/_limits.h deleted file mode 100644 index 62ee07db3f60..000000000000 --- a/sys/sparc64/include/_limits.h +++ /dev/null @@ -1,87 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD - * - * Copyright (c) 1988, 1993 - * The Regents of the University of California. 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 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. - * - * @(#)limits.h 8.3 (Berkeley) 1/4/94 - * $FreeBSD$ - */ - -#ifndef _MACHINE__LIMITS_H_ -#define _MACHINE__LIMITS_H_ - -/* - * According to ANSI (section 2.2.4.2), the values below must be usable by - * #if preprocessing directives. Additionally, the expression must have the - * same type as would an expression that is an object of the corresponding - * type converted according to the integral promotions. The subtraction for - * INT_MIN, etc., is so the value is not unsigned; e.g., 0x80000000 is an - * unsigned int for 32-bit two's complement ANSI compilers (section 3.1.3.2). - */ - -#define __CHAR_BIT 8 /* number of bits in a char */ - -#define __SCHAR_MAX 0x7f /* max value for a signed char */ -#define __SCHAR_MIN (-0x7f-1) /* min value for a signed char */ - -#define __UCHAR_MAX 0xff /* max value for an unsigned char */ - -#define __USHRT_MAX 0xffff /* max value for an unsigned short */ -#define __SHRT_MAX 0x7fff /* max value for a short */ -#define __SHRT_MIN (-0x7fff-1) /* min value for a short */ - -#define __UINT_MAX 0xffffffff /* max value for an unsigned int */ -#define __INT_MAX 0x7fffffff /* max value for an int */ -#define __INT_MIN (-0x7fffffff-1) /* min value for an int */ - -#define __ULONG_MAX 0xffffffffffffffff /* max for an unsigned long */ -#define __LONG_MAX 0x7fffffffffffffff /* max for a long */ -#define __LONG_MIN (-0x7fffffffffffffff-1) /* min for a long */ - -/* Long longs have the same size but not the same type as longs. */ - /* max for an unsigned long long */ -#define __ULLONG_MAX 0xffffffffffffffffULL -#define __LLONG_MAX 0x7fffffffffffffffLL /* max for a long long */ -#define __LLONG_MIN (-0x7fffffffffffffffLL-1) /* min for a long long */ - -#define __SSIZE_MAX __LONG_MAX /* max value for a ssize_t */ - -#define __SIZE_T_MAX __ULONG_MAX /* max value for a size_t */ - -#define __OFF_MAX __LONG_MAX /* max value for an off_t */ -#define __OFF_MIN __LONG_MIN /* min value for an off_t */ - -/* Quads and longs are the same size. Ensure they stay in sync. */ -#define __UQUAD_MAX (__ULONG_MAX) /* max value for a uquad_t */ -#define __QUAD_MAX (__LONG_MAX) /* max value for a quad_t */ -#define __QUAD_MIN (__LONG_MIN) /* min value for a quad_t */ - -#define __LONG_BIT 64 -#define __WORD_BIT 32 - -/* Minimum signal stack size. */ -#define __MINSIGSTKSZ (1024 * 4) - -#endif /* !_MACHINE__LIMITS_H_ */ diff --git a/sys/sparc64/include/_stdint.h b/sys/sparc64/include/_stdint.h deleted file mode 100644 index a21274ef1875..000000000000 --- a/sys/sparc64/include/_stdint.h +++ /dev/null @@ -1,160 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD - * - * Copyright (c) 2001, 2002 Mike Barcroft - * Copyright (c) 2001 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Klaus Klein. - * - * 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 NETBSD FOUNDATION, INC. 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 FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * $FreeBSD$ - */ - -#ifndef _MACHINE__STDINT_H_ -#define _MACHINE__STDINT_H_ - -#if !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS) - -#define INT8_C(c) (c) -#define INT16_C(c) (c) -#define INT32_C(c) (c) -#define INT64_C(c) (c ## L) - -#define UINT8_C(c) (c) -#define UINT16_C(c) (c) -#define UINT32_C(c) (c ## U) -#define UINT64_C(c) (c ## UL) - -#define INTMAX_C(c) INT64_C(c) -#define UINTMAX_C(c) UINT64_C(c) - -#endif /* !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS) */ - -#if !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS) - -/* - * ISO/IEC 9899:1999 - * 7.18.2.1 Limits of exact-width integer types - */ -/* Minimum values of exact-width signed integer types. */ -#define INT8_MIN (-0x7f-1) -#define INT16_MIN (-0x7fff-1) -#define INT32_MIN (-0x7fffffff-1) -#define INT64_MIN (-0x7fffffffffffffffL-1) - -/* Maximum values of exact-width signed integer types. */ -#define INT8_MAX 0x7f -#define INT16_MAX 0x7fff -#define INT32_MAX 0x7fffffff -#define INT64_MAX 0x7fffffffffffffffL - -/* Maximum values of exact-width unsigned integer types. */ -#define UINT8_MAX 0xff -#define UINT16_MAX 0xffff -#define UINT32_MAX 0xffffffffU -#define UINT64_MAX 0xffffffffffffffffUL - -/* - * ISO/IEC 9899:1999 - * 7.18.2.2 Limits of minimum-width integer types - */ -/* Minimum values of minimum-width signed integer types. */ -#define INT_LEAST8_MIN INT8_MIN -#define INT_LEAST16_MIN INT16_MIN -#define INT_LEAST32_MIN INT32_MIN -#define INT_LEAST64_MIN INT64_MIN - -/* Maximum values of minimum-width signed integer types. */ -#define INT_LEAST8_MAX INT8_MAX -#define INT_LEAST16_MAX INT16_MAX -#define INT_LEAST32_MAX INT32_MAX -#define INT_LEAST64_MAX INT64_MAX - -/* Maximum values of minimum-width unsigned integer types. */ -#define UINT_LEAST8_MAX UINT8_MAX -#define UINT_LEAST16_MAX UINT16_MAX -#define UINT_LEAST32_MAX UINT32_MAX -#define UINT_LEAST64_MAX UINT64_MAX - -/* - * ISO/IEC 9899:1999 - * 7.18.2.3 Limits of fastest minimum-width integer types - */ -/* Minimum values of fastest minimum-width signed integer types. */ -#define INT_FAST8_MIN INT32_MIN -#define INT_FAST16_MIN INT32_MIN -#define INT_FAST32_MIN INT32_MIN -#define INT_FAST64_MIN INT64_MIN - -/* Maximum values of fastest minimum-width signed integer types. */ -#define INT_FAST8_MAX INT32_MAX -#define INT_FAST16_MAX INT32_MAX -#define INT_FAST32_MAX INT32_MAX -#define INT_FAST64_MAX INT64_MAX - -/* Maximum values of fastest minimum-width unsigned integer types. */ -#define UINT_FAST8_MAX UINT32_MAX -#define UINT_FAST16_MAX UINT32_MAX -#define UINT_FAST32_MAX UINT32_MAX -#define UINT_FAST64_MAX UINT64_MAX - -/* - * ISO/IEC 9899:1999 - * 7.18.2.4 Limits of integer types capable of holding object pointers - */ -#define INTPTR_MIN INT64_MIN -#define INTPTR_MAX INT64_MAX -#define UINTPTR_MAX UINT64_MAX - -/* - * ISO/IEC 9899:1999 - * 7.18.2.5 Limits of greatest-width integer types - */ -#define INTMAX_MIN INT64_MIN -#define INTMAX_MAX INT64_MAX -#define UINTMAX_MAX UINT64_MAX - -/* - * ISO/IEC 9899:1999 - * 7.18.3 Limits of other integer types - */ -/* Limits of ptrdiff_t. */ -#define PTRDIFF_MIN INT64_MIN -#define PTRDIFF_MAX INT64_MAX - -/* Limits of sig_atomic_t. */ -#define SIG_ATOMIC_MIN INT32_MIN -#define SIG_ATOMIC_MAX INT32_MAX - -/* Limit of size_t. */ -#define SIZE_MAX UINT64_MAX - -/* Limits of wint_t. */ -#define WINT_MIN INT32_MIN -#define WINT_MAX INT32_MAX - -#endif /* !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS) */ - -#endif /* !_MACHINE__STDINT_H_ */ diff --git a/sys/sparc64/include/_types.h b/sys/sparc64/include/_types.h deleted file mode 100644 index 9d71fefc52eb..000000000000 --- a/sys/sparc64/include/_types.h +++ /dev/null @@ -1,102 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-3-Clause - * - * Copyright (c) 2002 Mike Barcroft - * Copyright (c) 1990, 1993 - * The Regents of the University of California. 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. - * 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. - * - * From: @(#)ansi.h 8.2 (Berkeley) 1/4/94 - * From: @(#)types.h 8.3 (Berkeley) 1/5/94 - * $FreeBSD$ - */ - -#ifndef _MACHINE__TYPES_H_ -#define _MACHINE__TYPES_H_ - -#ifndef _SYS_CDEFS_H_ -#error this file needs sys/cdefs.h as a prerequisite -#endif - -/* - * Basic types upon which most other types are built. - */ -typedef signed char __int8_t; -typedef unsigned char __uint8_t; -typedef short __int16_t; -typedef unsigned short __uint16_t; -typedef int __int32_t; -typedef unsigned int __uint32_t; -typedef long __int64_t; -typedef unsigned long __uint64_t; - -/* - * Standard type definitions. - */ -typedef __int32_t __clock_t; /* clock()... */ -typedef __int64_t __critical_t; -#ifndef _STANDALONE -typedef double __double_t; -typedef float __float_t; -#endif -typedef __int64_t __intfptr_t; -typedef __int64_t __intmax_t; -typedef __int64_t __intptr_t; -typedef __int32_t __int_fast8_t; -typedef __int32_t __int_fast16_t; -typedef __int32_t __int_fast32_t; -typedef __int64_t __int_fast64_t; -typedef __int8_t __int_least8_t; -typedef __int16_t __int_least16_t; -typedef __int32_t __int_least32_t; -typedef __int64_t __int_least64_t; -typedef __int64_t __ptrdiff_t; /* ptr1 - ptr2 */ -typedef __int64_t __register_t; -typedef __int64_t __segsz_t; /* segment size (in pages) */ -typedef __uint64_t __size_t; /* sizeof() */ -typedef __int64_t __ssize_t; /* byte count or error */ -typedef __int64_t __time_t; /* time()... */ -typedef __uint64_t __uintfptr_t; -typedef __uint64_t __uintmax_t; -typedef __uint64_t __uintptr_t; -typedef __uint32_t __uint_fast8_t; -typedef __uint32_t __uint_fast16_t; -typedef __uint32_t __uint_fast32_t; -typedef __uint64_t __uint_fast64_t; -typedef __uint8_t __uint_least8_t; -typedef __uint16_t __uint_least16_t; -typedef __uint32_t __uint_least32_t; -typedef __uint64_t __uint_least64_t; -typedef __uint64_t __u_register_t; -typedef __uint64_t __vm_offset_t; -typedef __uint64_t __vm_paddr_t; -typedef __uint64_t __vm_size_t; -typedef int ___wchar_t; - -#define __WCHAR_MIN __INT_MIN /* min value for a wchar_t */ -#define __WCHAR_MAX __INT_MAX /* max value for a wchar_t */ - -#endif /* !_MACHINE__TYPES_H_ */ diff --git a/sys/sparc64/include/asi.h b/sys/sparc64/include/asi.h deleted file mode 100644 index 2a40eb89c357..000000000000 --- a/sys/sparc64/include/asi.h +++ /dev/null @@ -1,262 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-3-Clause - * - * Copyright (c) 1997 Berkeley Software Design, Inc. 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. - * 3. Berkeley Software Design Inc's name may not be used to endorse or - * promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY BERKELEY SOFTWARE DESIGN INC ``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 BERKELEY SOFTWARE DESIGN INC 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. - * - * from: BSDI: asi.h,v 1.3 1997/08/08 14:31:42 torek - * $FreeBSD$ - */ - -#ifndef _MACHINE_ASI_H_ -#define _MACHINE_ASI_H_ - -/* - * Standard v9 ASIs - */ -#define ASI_N 0x4 -#define ASI_NL 0xc -#define ASI_AIUP 0x10 -#define ASI_AIUS 0x11 -#define ASI_AIUPL 0x18 -#define ASI_AIUSL 0x19 -#define ASI_P 0x80 -#define ASI_S 0x81 -#define ASI_PNF 0x82 -#define ASI_SNF 0x83 -#define ASI_PL 0x88 -#define ASI_SL 0x89 -#define ASI_PNFL 0x8a -#define ASI_SNFL 0x8b - -/* - * UltraSPARC extensions - ASIs limited to a certain family are annotated. - */ -#define ASI_PHYS_USE_EC 0x14 -#define ASI_PHYS_BYPASS_EC_WITH_EBIT 0x15 -#define ASI_PHYS_USE_EC_L 0x1c -#define ASI_PHYS_BYPASS_EC_WITH_EBIT_L 0x1d - -#define ASI_NUCLEUS_QUAD_LDD 0x24 -#define ASI_NUCLEUS_QUAD_LDD_L 0x2c - -#define ASI_PCACHE_STATUS_DATA 0x30 /* US-III Cu */ -#define ASI_PCACHE_DATA 0x31 /* US-III Cu */ -#define ASI_PCACHE_TAG 0x32 /* US-III Cu */ -#define ASI_PCACHE_SNOOP_TAG 0x33 /* US-III Cu */ - -#define ASI_ATOMIC_QUAD_LDD_PHYS 0x34 /* US-III Cu */ - -#define ASI_WCACHE_VALID_BITS 0x38 /* US-III Cu */ -#define ASI_WCACHE_DATA 0x39 /* US-III Cu */ -#define ASI_WCACHE_TAG 0x3a /* US-III Cu */ -#define ASI_WCACHE_SNOOP_TAG 0x3b /* US-III Cu */ - -#define ASI_ATOMIC_QUAD_LDD_PHYS_L 0x3c /* US-III Cu */ - -#define ASI_SRAM_FAST_INIT 0x40 /* US-III Cu */ - -#define ASI_DCACHE_INVALIDATE 0x42 /* US-III Cu */ -#define ASI_DCACHE_UTAG 0x43 /* US-III Cu */ -#define ASI_DCACHE_SNOOP_TAG 0x44 /* US-III Cu */ - -/* Named ASI_DCUCR on US-III, but is mostly identical except for added bits. */ -#define ASI_LSU_CTL_REG 0x45 /* US only */ - -#define ASI_MCNTL 0x45 /* SPARC64 only */ -#define AA_MCNTL 0x08 - -#define ASI_DCACHE_DATA 0x46 -#define ASI_DCACHE_TAG 0x47 - -#define ASI_INTR_DISPATCH_STATUS 0x48 -#define ASI_INTR_RECEIVE 0x49 -#define ASI_UPA_CONFIG_REG 0x4a /* US-I, II */ - -#define ASI_FIREPLANE_CONFIG_REG 0x4a /* US-III{,+}, IV{,+} */ -#define AA_FIREPLANE_CONFIG 0x0 /* US-III{,+}, IV{,+} */ -#define AA_FIREPLANE_ADDRESS 0x8 /* US-III{,+}, IV{,+} */ -#define AA_FIREPLANE_CONFIG_2 0x10 /* US-IV{,+} */ - -#define ASI_JBUS_CONFIG_REG 0x4a /* US-IIIi{,+} */ - -#define ASI_ESTATE_ERROR_EN_REG 0x4b -#define AA_ESTATE_CEEN 0x1 -#define AA_ESTATE_NCEEN 0x2 -#define AA_ESTATE_ISAPEN 0x4 - -#define ASI_AFSR 0x4c -#define ASI_AFAR 0x4d - -#define ASI_ECACHE_TAG_DATA 0x4e - -#define ASI_IMMU_TAG_TARGET_REG 0x50 -#define ASI_IMMU 0x50 -#define AA_IMMU_TTR 0x0 -#define AA_IMMU_SFSR 0x18 -#define AA_IMMU_TSB 0x28 -#define AA_IMMU_TAR 0x30 -#define AA_IMMU_TSB_PEXT_REG 0x48 /* US-III family */ -#define AA_IMMU_TSB_SEXT_REG 0x50 /* US-III family */ -#define AA_IMMU_TSB_NEXT_REG 0x58 /* US-III family */ - -#define ASI_IMMU_TSB_8KB_PTR_REG 0x51 -#define ASI_IMMU_TSB_64KB_PTR_REG 0x52 - -#define ASI_SERIAL_ID 0x53 /* US-III family */ - -#define ASI_ITLB_DATA_IN_REG 0x54 -/* US-III Cu: also ASI_ITLB_CAM_ADDRESS_REG */ -#define ASI_ITLB_DATA_ACCESS_REG 0x55 -#define ASI_ITLB_TAG_READ_REG 0x56 -#define ASI_IMMU_DEMAP 0x57 - -#define ASI_DMMU_TAG_TARGET_REG 0x58 -#define ASI_DMMU 0x58 -#define AA_DMMU_TTR 0x0 -#define AA_DMMU_PCXR 0x8 -#define AA_DMMU_SCXR 0x10 -#define AA_DMMU_SFSR 0x18 -#define AA_DMMU_SFAR 0x20 -#define AA_DMMU_TSB 0x28 -#define AA_DMMU_TAR 0x30 -#define AA_DMMU_VWPR 0x38 -#define AA_DMMU_PWPR 0x40 -#define AA_DMMU_TSB_PEXT_REG 0x48 -#define AA_DMMU_TSB_SEXT_REG 0x50 -#define AA_DMMU_TSB_NEXT_REG 0x58 -#define AA_DMMU_TAG_ACCESS_EXT 0x60 /* US-III family */ - -#define ASI_DMMU_TSB_8KB_PTR_REG 0x59 -#define ASI_DMMU_TSB_64KB_PTR_REG 0x5a -#define ASI_DMMU_TSB_DIRECT_PTR_REG 0x5b -#define ASI_DTLB_DATA_IN_REG 0x5c -/* US-III Cu: also ASI_DTLB_CAM_ADDRESS_REG */ -#define ASI_DTLB_DATA_ACCESS_REG 0x5d -#define ASI_DTLB_TAG_READ_REG 0x5e -#define ASI_DMMU_DEMAP 0x5f - -#define ASI_IIU_INST_TRAP 0x60 /* US-III family */ - -#define ASI_INTR_ID 0x63 /* US-IV{,+} */ -#define AA_INTR_ID 0x0 /* US-IV{,+} */ -#define AA_CORE_ID 0x10 /* US-IV{,+} */ -#define AA_CESR_ID 0x40 /* US-IV{,+} */ - -#define ASI_ICACHE_INSTR 0x66 -#define ASI_ICACHE_TAG 0x67 -#define ASI_ICACHE_SNOOP_TAG 0x68 /* US-III family */ -#define ASI_ICACHE_PRE_DECODE 0x6e /* US-I, II */ -#define ASI_ICACHE_PRE_NEXT_FIELD 0x6f /* US-I, II */ - -#define ASI_FLUSH_L1I 0x67 /* SPARC64 only */ - -#define ASI_BLK_AUIP 0x70 -#define ASI_BLK_AIUS 0x71 - -#define ASI_MCU_CONFIG_REG 0x72 /* US-III Cu */ -#define AA_MCU_TIMING1_REG 0x0 /* US-III Cu */ -#define AA_MCU_TIMING2_REG 0x8 /* US-III Cu */ -#define AA_MCU_TIMING3_REG 0x10 /* US-III Cu */ -#define AA_MCU_TIMING4_REG 0x18 /* US-III Cu */ -#define AA_MCU_DEC1_REG 0x20 /* US-III Cu */ -#define AA_MCU_DEC2_REG 0x28 /* US-III Cu */ -#define AA_MCU_DEC3_REG 0x30 /* US-III Cu */ -#define AA_MCU_DEC4_REG 0x38 /* US-III Cu */ -#define AA_MCU_ADDR_CNTL_REG 0x40 /* US-III Cu */ - -#define ASI_ECACHE_DATA 0x74 /* US-III Cu */ -#define ASI_ECACHE_CONTROL 0x75 /* US-III Cu */ -#define ASI_ECACHE_W 0x76 - -/* - * With the advent of the US-III, the numbering has changed, as additional - * registers were inserted in between. We retain the original ordering for - * now, and append an A to the inserted registers. - * Exceptions are AA_SDB_INTR_D6 and AA_SDB_INTR_D7, which were appended - * at the end. - */ -#define ASI_SDB_ERROR_W 0x77 -#define ASI_SDB_CONTROL_W 0x77 -#define ASI_SDB_INTR_W 0x77 -#define AA_SDB_ERR_HIGH 0x0 -#define AA_SDB_ERR_LOW 0x18 -#define AA_SDB_CNTL_HIGH 0x20 -#define AA_SDB_CNTL_LOW 0x38 -#define AA_SDB_INTR_D0 0x40 -#define AA_SDB_INTR_D0A 0x48 /* US-III family */ -#define AA_SDB_INTR_D1 0x50 -#define AA_SDB_INTR_D1A 0x5A /* US-III family */ -#define AA_SDB_INTR_D2 0x60 -#define AA_SDB_INTR_D2A 0x68 /* US-III family */ -#define AA_INTR_SEND 0x70 -#define AA_SDB_INTR_D6 0x80 /* US-III family */ -#define AA_SDB_INTR_D7 0x88 /* US-III family */ - -#define ASI_BLK_AIUPL 0x78 -#define ASI_BLK_AIUSL 0x79 - -#define ASI_ECACHE_R 0x7e - -/* - * These have the same registers as their corresponding write versions - * except for AA_INTR_SEND. - */ -#define ASI_SDB_ERROR_R 0x7f -#define ASI_SDB_CONTROL_R 0x7f -#define ASI_SDB_INTR_R 0x7f - -#define ASI_PST8_P 0xc0 -#define ASI_PST8_S 0xc1 -#define ASI_PST16_P 0xc2 -#define ASI_PST16_S 0xc3 -#define ASI_PST32_P 0xc4 -#define ASI_PST32_S 0xc5 - -#define ASI_PST8_PL 0xc8 -#define ASI_PST8_SL 0xc9 -#define ASI_PST16_PL 0xca -#define ASI_PST16_SL 0xcb -#define ASI_PST32_PL 0xcc -#define ASI_PST32_SL 0xcd - -#define ASI_FL8_P 0xd0 -#define ASI_FL8_S 0xd1 -#define ASI_FL16_P 0xd2 -#define ASI_FL16_S 0xd3 -#define ASI_FL8_PL 0xd8 -#define ASI_FL8_SL 0xd9 -#define ASI_FL16_PL 0xda -#define ASI_FL16_SL 0xdb - -#define ASI_BLK_COMMIT_P 0xe0 -#define ASI_BLK_COMMIT_S 0xe1 -#define ASI_BLK_P 0xf0 -#define ASI_BLK_S 0xf1 -#define ASI_BLK_PL 0xf8 -#define ASI_BLK_SL 0xf9 - -#endif /* !_MACHINE_ASI_H_ */ diff --git a/sys/sparc64/include/asm.h b/sys/sparc64/include/asm.h deleted file mode 100644 index e8ca4af257f1..000000000000 --- a/sys/sparc64/include/asm.h +++ /dev/null @@ -1,128 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-3-Clause - * - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * 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. - * - * from: @(#)DEFS.h 5.1 (Berkeley) 4/23/90 - * from: FreeBSD: src/sys/i386/include/asm.h,v 1.7 2000/01/25 - * $FreeBSD$ - */ - -#ifndef _MACHINE_ASM_H_ -#define _MACHINE_ASM_H_ - -#define __ASM__ - -#include - -#ifdef PIC -#define PIC_PROLOGUE(r1, r2) \ - sethi %hi(_GLOBAL_OFFSET_TABLE_-4), r1 ; \ - rd %pc, r2 ; \ - or r1, %lo(_GLOBAL_OFFSET_TABLE_+4), r1 ; \ - add r2, r1, r2 -#define SET(name, r1, r2) \ - set name, r2 ; \ - ldx [r1 + r2], r2 -#else -#define PIC_PROLOGUE(r1, r2) -#define SET(name, r1, r2) \ - set name, r2 -#endif - -/* - * CNAME and HIDENAME manage the relationship between symbol names in C - * and the equivalent assembly language names. CNAME is given a name as - * it would be used in a C program. It expands to the equivalent assembly - * language name. HIDENAME is given an assembly-language name, and expands - * to a possibly-modified form that will be invisible to C programs. - */ -#define CNAME(csym) csym -#define HIDENAME(asmsym) __CONCAT(.,asmsym) - -#define CCFSZ 192 -#define SPOFF 2047 - -#define _ALIGN_TEXT .align 32 - -#define _START_ENTRY \ - .text ; \ - _ALIGN_TEXT - -/* - * Define function entry and alternate entry points. - * - * The compiler produces #function for the .type pseudo-op, but the '#' - * character has special meaning in cpp macros, so we use @function like - * other architectures. The assembler seems to accept both. - * The assembler also accepts a .proc pseudo-op, which is used by the - * peep hole optimizer, whose argument is the type code of the return - * value. Since this is difficult to predict and its expected that - * assembler code is already optimized, we leave it out. - */ - -#define _ALTENTRY(x) \ - .globl CNAME(x) ; \ - .type CNAME(x),@function ; \ -CNAME(x): - -#define _ENTRY(x) \ - _START_ENTRY ; \ - .globl CNAME(x) ; \ - .type CNAME(x),@function ; \ -CNAME(x): - -#define ALTENTRY(x) _ALTENTRY(x) -#define ENTRY(x) _ENTRY(x) -#define END(x) .size x, . - x - -/* - * WEAK_REFERENCE(): create a weak reference alias from sym. - * The macro is not a general asm macro that takes arbitrary names, - * but one that takes only C names. It does the non-null name - * translation inside the macro. - */ -#define WEAK_REFERENCE(sym, alias) \ - .weak CNAME(alias); \ - .equ CNAME(alias),CNAME(sym) - -/* - * Kernel RCS ID tag and copyright macros - */ - -#undef __FBSDID -#if !defined(lint) && !defined(STRIP_FBSDID) -#define __FBSDID(s) .ident s -#else -#define __FBSDID(s) /* nothing */ -#endif /* not lint and not STRIP_FBSDID */ - -#endif /* !_MACHINE_ASM_H_ */ diff --git a/sys/sparc64/include/asmacros.h b/sys/sparc64/include/asmacros.h deleted file mode 100644 index cb39694387e4..000000000000 --- a/sys/sparc64/include/asmacros.h +++ /dev/null @@ -1,226 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD - * - * Copyright (c) 2001 Jake Burkholder. - * Copyright (c) 2011 Marius Strobl - * 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$ - */ - -#ifndef _MACHINE_ASMACROS_H_ -#define _MACHINE_ASMACROS_H_ - -#ifdef _KERNEL - -/* - * Normal and alternate %g6 point to the pcb of the current process. Normal, - * alternate and interrupt %g7 point to per-cpu data. - */ -#define PCB_REG %g6 -#define PCPU_REG %g7 - -/* - * Alternate %g5 points to a per-cpu panic stack, which is used as a last - * resort, and for temporarily saving alternate globals. - */ -#define ASP_REG %g5 - -#ifdef LOCORE - -/* - * Atomically decrement an integer in memory. - */ -#define ATOMIC_DEC_INT(r1, r2, r3) \ - lduw [r1], r2 ; \ -9: sub r2, 1, r3 ; \ - casa [r1] ASI_N, r2, r3 ; \ - cmp r2, r3 ; \ - bne,pn %icc, 9b ; \ - mov r3, r2 - -/* - * Atomically increment an integer in memory. - */ -#define ATOMIC_INC_INT(r1, r2, r3) \ - lduw [r1], r2 ; \ -9: add r2, 1, r3 ; \ - casa [r1] ASI_N, r2, r3 ; \ - cmp r2, r3 ; \ - bne,pn %icc, 9b ; \ - mov r3, r2 - -/* - * Atomically increment a long in memory. - */ -#define ATOMIC_INC_LONG(r1, r2, r3) \ - ldx [r1], r2 ; \ -9: add r2, 1, r3 ; \ - casxa [r1] ASI_N, r2, r3 ; \ - cmp r2, r3 ; \ - bne,pn %xcc, 9b ; \ - mov r3, r2 - -/* - * Atomically clear a number of bits of an integer in memory. - */ -#define ATOMIC_CLEAR_INT(r1, r2, r3, bits) \ - lduw [r1], r2 ; \ -9: andn r2, bits, r3 ; \ - casa [r1] ASI_N, r2, r3 ; \ - cmp r2, r3 ; \ - bne,pn %icc, 9b ; \ - mov r3, r2 - -/* - * Atomically clear a number of bits of a long in memory. - */ -#define ATOMIC_CLEAR_LONG(r1, r2, r3, bits) \ - ldx [r1], r2 ; \ -9: andn r2, bits, r3 ; \ - casxa [r1] ASI_N, r2, r3 ; \ - cmp r2, r3 ; \ - bne,pn %xcc, 9b ; \ - mov r3, r2 - -/* - * Atomically load an integer from memory. - */ -#define ATOMIC_LOAD_INT(r1, val) \ - clr val ; \ - casa [r1] ASI_N, %g0, val - -/* - * Atomically load a long from memory. - */ -#define ATOMIC_LOAD_LONG(r1, val) \ - clr val ; \ - casxa [r1] ASI_N, %g0, val - -/* - * Atomically set a number of bits of an integer in memory. - */ -#define ATOMIC_SET_INT(r1, r2, r3, bits) \ - lduw [r1], r2 ; \ -9: or r2, bits, r3 ; \ - casa [r1] ASI_N, r2, r3 ; \ - cmp r2, r3 ; \ - bne,pn %icc, 9b ; \ - mov r3, r2 - -/* - * Atomically set a number of bits of a long in memory. - */ -#define ATOMIC_SET_LONG(r1, r2, r3, bits) \ - ldx [r1], r2 ; \ -9: or r2, bits, r3 ; \ - casxa [r1] ASI_N, r2, r3 ; \ - cmp r2, r3 ; \ - bne,pn %xcc, 9b ; \ - mov r3, r2 - -/* - * Atomically store an integer in memory. - */ -#define ATOMIC_STORE_INT(r1, r2, r3, val) \ - lduw [r1], r2 ; \ -9: mov val, r3 ; \ - casa [r1] ASI_N, r2, r3 ; \ - cmp r2, r3 ; \ - bne,pn %icc, 9b ; \ - mov r3, r2 - -/* - * Atomically store a long in memory. - */ -#define ATOMIC_STORE_LONG(r1, r2, r3, val) \ - ldx [r1], r2 ; \ -9: mov val, r3 ; \ - casxa [r1] ASI_N, r2, r3 ; \ - cmp r2, r3 ; \ - bne,pn %xcc, 9b ; \ - mov r3, r2 - -#define PCPU(member) PCPU_REG + PC_ ## member -#define PCPU_ADDR(member, reg) \ - add PCPU_REG, PC_ ## member, reg - -#define DEBUGGER() \ - ta %xcc, 1 - -#define PANIC(msg, r1) \ - .sect .rodata ; \ -9: .asciz msg ; \ - .previous ; \ - SET(9b, r1, %o0) ; \ - call panic ; \ - nop - -#ifdef INVARIANTS -#define KASSERT(r1, msg) \ - brnz,pt r1, 8f ; \ - nop ; \ - PANIC(msg, r1) ; \ -8: -#else -#define KASSERT(r1, msg) -#endif - -#define PUTS(msg, r1) \ - .sect .rodata ; \ -9: .asciz msg ; \ - .previous ; \ - SET(9b, r1, %o0) ; \ - call printf ; \ - nop - -#define _ALIGN_DATA .align 8 - -#define DATA(name) \ - .data ; \ - _ALIGN_DATA ; \ - .globl name ; \ - .type name, @object ; \ -name: - -#define EMPTY - -/* - * Generate atomic compare and swap, load and store instructions for the - * corresponding width and ASI (or not). Note that we want to evaluate the - * macro args before concatenating, so that EMPTY really turns into nothing. - */ -#define _LD(w, a) ld ## w ## a -#define _ST(w, a) st ## w ## a -#define _CAS(w, a) cas ## w ## a - -#define LD(w, a) _LD(w, a) -#define ST(w, a) _ST(w, a) -#define CAS(w, a) _CAS(w, a) - -#endif /* LOCORE */ - -#endif /* _KERNEL */ - -#endif /* !_MACHINE_ASMACROS_H_ */ diff --git a/sys/sparc64/include/atomic.h b/sys/sparc64/include/atomic.h deleted file mode 100644 index e98da0f5e49c..000000000000 --- a/sys/sparc64/include/atomic.h +++ /dev/null @@ -1,446 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD - * - * Copyright (c) 1998 Doug Rabson. - * Copyright (c) 2001 Jake Burkholder. - * 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. - * - * from: FreeBSD: src/sys/i386/include/atomic.h,v 1.20 2001/02/11 - * $FreeBSD$ - */ - -#ifndef _MACHINE_ATOMIC_H_ -#define _MACHINE_ATOMIC_H_ - -#include - -#define mb() __asm__ __volatile__ ("membar #MemIssue": : :"memory") -#define wmb() mb() -#define rmb() mb() - -#include - -/* Userland needs different ASI's. */ -#ifdef _KERNEL -#define __ASI_ATOMIC ASI_N -#else -#define __ASI_ATOMIC ASI_P -#endif - -static __inline int atomic_cmpset_8(__volatile uint8_t *, uint8_t, uint8_t); -static __inline int atomic_fcmpset_8(__volatile uint8_t *, uint8_t *, uint8_t); -static __inline int atomic_cmpset_16(__volatile uint16_t *, uint16_t, uint16_t); -static __inline int atomic_fcmpset_16(__volatile uint16_t *, uint16_t *, uint16_t); - -/* - * Various simple arithmetic on memory which is atomic in the presence - * of interrupts and multiple processors. See atomic(9) for details. - * Note that efficient hardware support exists only for the 32 and 64 - * bit variants; the 8 and 16 bit versions are not provided and should - * not be used in MI code. - * - * This implementation takes advantage of the fact that the sparc64 - * cas instruction is both a load and a store. The loop is often coded - * as follows: - * - * do { - * expect = *p; - * new = expect + 1; - * } while (cas(p, expect, new) != expect); - * - * which performs an unnnecessary load on each iteration that the cas - * operation fails. Modified as follows: - * - * expect = *p; - * for (;;) { - * new = expect + 1; - * result = cas(p, expect, new); - * if (result == expect) - * break; - * expect = result; - * } - * - * the return value of cas is used to avoid the extra reload. - * - * We only include a memory barrier in the rel variants as in total store - * order which we use for running the kernel and all of the userland atomic - * loads and stores behave as if the were followed by a membar with a mask - * of #LoadLoad | #LoadStore | #StoreStore. In order to be also sufficient - * for use of relaxed memory ordering, the atomic_cas() in the acq variants - * additionally would have to be followed by a membar #LoadLoad | #LoadStore. - * Due to the suggested assembly syntax of the membar operands containing a - * # character, they cannot be used in macros. The cmask and mmask bits thus - * are hard coded in machine/cpufunc.h and used here through macros. - * Hopefully the bit numbers won't change in the future. - */ - -#define itype(sz) uint ## sz ## _t - -#define atomic_cas_32(p, e, s) casa((p), (e), (s), __ASI_ATOMIC) -#define atomic_cas_64(p, e, s) casxa((p), (e), (s), __ASI_ATOMIC) - -#define atomic_cas(p, e, s, sz) \ - atomic_cas_ ## sz((p), (e), (s)) - -#define atomic_cas_acq(p, e, s, sz) ({ \ - itype(sz) v; \ - v = atomic_cas((p), (e), (s), sz); \ - __compiler_membar(); \ - v; \ -}) - -#define atomic_cas_rel(p, e, s, sz) ({ \ - itype(sz) v; \ - membar(LoadStore | StoreStore); \ - v = atomic_cas((p), (e), (s), sz); \ - v; \ -}) - -#define atomic_op(p, op, v, sz) ({ \ - itype(sz) e, r, s; \ - for (e = *(volatile itype(sz) *)(p);; e = r) { \ - s = e op (v); \ - r = atomic_cas_ ## sz((p), e, s); \ - if (r == e) \ - break; \ - } \ - e; \ -}) - -#define atomic_op_acq(p, op, v, sz) ({ \ - itype(sz) t; \ - t = atomic_op((p), op, (v), sz); \ - __compiler_membar(); \ - t; \ -}) - -#define atomic_op_rel(p, op, v, sz) ({ \ - itype(sz) t; \ - membar(LoadStore | StoreStore); \ - t = atomic_op((p), op, (v), sz); \ - t; \ -}) - -#define atomic_ld_acq(p, sz) ({ \ - itype(sz) v; \ - v = atomic_cas((p), 0, 0, sz); \ - __compiler_membar(); \ - v; \ -}) - -#define atomic_ld_clear(p, sz) ({ \ - itype(sz) e, r; \ - for (e = *(volatile itype(sz) *)(p);; e = r) { \ - r = atomic_cas((p), e, 0, sz); \ - if (r == e) \ - break; \ - } \ - e; \ -}) - -#define atomic_st(p, v, sz) ({ \ - itype(sz) e, r; \ - for (e = *(volatile itype(sz) *)(p);; e = r) { \ - r = atomic_cas((p), e, (v), sz); \ - if (r == e) \ - break; \ - } \ - e; \ -}) - -#define atomic_st_acq(p, v, sz) do { \ - atomic_st((p), (v), sz); \ - __compiler_membar(); \ -} while (0) - -#define atomic_st_rel(p, v, sz) do { \ - membar(LoadStore | StoreStore); \ - atomic_st((p), (v), sz); \ -} while (0) - -#define ATOMIC_GEN(name, ptype, vtype, atype, sz) \ - \ -static __inline vtype \ -atomic_add_ ## name(volatile ptype p, atype v) \ -{ \ - return ((vtype)atomic_op((p), +, (v), sz)); \ -} \ -static __inline vtype \ -atomic_add_acq_ ## name(volatile ptype p, atype v) \ -{ \ - return ((vtype)atomic_op_acq((p), +, (v), sz)); \ -} \ -static __inline vtype \ -atomic_add_rel_ ## name(volatile ptype p, atype v) \ -{ \ - return ((vtype)atomic_op_rel((p), +, (v), sz)); \ -} \ - \ -static __inline vtype \ -atomic_clear_ ## name(volatile ptype p, atype v) \ -{ \ - return ((vtype)atomic_op((p), &, ~(v), sz)); \ -} \ -static __inline vtype \ -atomic_clear_acq_ ## name(volatile ptype p, atype v) \ -{ \ - return ((vtype)atomic_op_acq((p), &, ~(v), sz)); \ -} \ -static __inline vtype \ -atomic_clear_rel_ ## name(volatile ptype p, atype v) \ -{ \ - return ((vtype)atomic_op_rel((p), &, ~(v), sz)); \ -} \ - \ -static __inline int \ -atomic_cmpset_ ## name(volatile ptype p, vtype e, vtype s) \ -{ \ - return (((vtype)atomic_cas((p), (e), (s), sz)) == (e)); \ -} \ -static __inline int \ -atomic_cmpset_acq_ ## name(volatile ptype p, vtype e, vtype s) \ -{ \ - return (((vtype)atomic_cas_acq((p), (e), (s), sz)) == (e)); \ -} \ -static __inline int \ -atomic_cmpset_rel_ ## name(volatile ptype p, vtype e, vtype s) \ -{ \ - return (((vtype)atomic_cas_rel((p), (e), (s), sz)) == (e)); \ -} \ - \ -static __inline int \ -atomic_fcmpset_ ## name(volatile ptype p, vtype *ep, vtype s) \ -{ \ - vtype t; \ - \ - t = (vtype)atomic_cas((p), (*ep), (s), sz); \ - if (t == (*ep)) \ - return (1); \ - *ep = t; \ - return (0); \ -} \ -static __inline int \ -atomic_fcmpset_acq_ ## name(volatile ptype p, vtype *ep, vtype s) \ -{ \ - vtype t; \ - \ - t = (vtype)atomic_cas_acq((p), (*ep), (s), sz); \ - if (t == (*ep)) \ - return (1); \ - *ep = t; \ - return (0); \ -} \ -static __inline int \ -atomic_fcmpset_rel_ ## name(volatile ptype p, vtype *ep, vtype s) \ -{ \ - vtype t; \ - \ - t = (vtype)atomic_cas_rel((p), (*ep), (s), sz); \ - if (t == (*ep)) \ - return (1); \ - *ep = t; \ - return (0); \ -} \ - \ -static __inline vtype \ -atomic_load_acq_ ## name(volatile ptype p) \ -{ \ - return ((vtype)atomic_cas_acq((p), 0, 0, sz)); \ -} \ - \ -static __inline vtype \ -atomic_readandclear_ ## name(volatile ptype p) \ -{ \ - return ((vtype)atomic_ld_clear((p), sz)); \ -} \ - \ -static __inline vtype \ -atomic_set_ ## name(volatile ptype p, atype v) \ -{ \ - return ((vtype)atomic_op((p), |, (v), sz)); \ -} \ -static __inline vtype \ -atomic_set_acq_ ## name(volatile ptype p, atype v) \ -{ \ - return ((vtype)atomic_op_acq((p), |, (v), sz)); \ -} \ -static __inline vtype \ -atomic_set_rel_ ## name(volatile ptype p, atype v) \ -{ \ - return ((vtype)atomic_op_rel((p), |, (v), sz)); \ -} \ - \ -static __inline vtype \ -atomic_subtract_ ## name(volatile ptype p, atype v) \ -{ \ - return ((vtype)atomic_op((p), -, (v), sz)); \ -} \ -static __inline vtype \ -atomic_subtract_acq_ ## name(volatile ptype p, atype v) \ -{ \ - return ((vtype)atomic_op_acq((p), -, (v), sz)); \ -} \ -static __inline vtype \ -atomic_subtract_rel_ ## name(volatile ptype p, atype v) \ -{ \ - return ((vtype)atomic_op_rel((p), -, (v), sz)); \ -} \ - \ -static __inline void \ -atomic_store_acq_ ## name(volatile ptype p, vtype v) \ -{ \ - atomic_st_acq((p), (v), sz); \ -} \ -static __inline void \ -atomic_store_rel_ ## name(volatile ptype p, vtype v) \ -{ \ - atomic_st_rel((p), (v), sz); \ -} \ - \ -static __inline vtype \ -atomic_swap_ ## name(volatile ptype p, vtype v) \ -{ \ - return ((vtype)atomic_st((p), (v), sz)); \ -} - -static __inline void -atomic_thread_fence_acq(void) -{ - - __compiler_membar(); -} - -static __inline void -atomic_thread_fence_rel(void) -{ - - __compiler_membar(); -} - -static __inline void -atomic_thread_fence_acq_rel(void) -{ - - __compiler_membar(); -} - -static __inline void -atomic_thread_fence_seq_cst(void) -{ - - membar(LoadLoad | LoadStore | StoreStore | StoreLoad); -} - - -ATOMIC_GEN(int, u_int *, u_int, u_int, 32); -ATOMIC_GEN(32, uint32_t *, uint32_t, uint32_t, 32); - -ATOMIC_GEN(long, u_long *, u_long, u_long, 64); -ATOMIC_GEN(64, uint64_t *, uint64_t, uint64_t, 64); - -ATOMIC_GEN(ptr, uintptr_t *, uintptr_t, uintptr_t, 64); - -#define ATOMIC_CMPSET_ACQ_REL(WIDTH) \ -static __inline int \ -atomic_cmpset_acq_##WIDTH(__volatile uint##WIDTH##_t *p, \ - uint##WIDTH##_t cmpval, uint##WIDTH##_t newval) \ -{ \ - int retval; \ - \ - retval = atomic_cmpset_##WIDTH(p, cmpval, newval); \ - mb(); \ - return (retval); \ -} \ - \ -static __inline int \ -atomic_cmpset_rel_##WIDTH(__volatile uint##WIDTH##_t *p, \ - uint##WIDTH##_t cmpval, uint##WIDTH##_t newval) \ -{ \ - mb(); \ - return (atomic_cmpset_##WIDTH(p, cmpval, newval)); \ -} - -#define ATOMIC_FCMPSET_ACQ_REL(WIDTH) \ -static __inline int \ -atomic_fcmpset_acq_##WIDTH(__volatile uint##WIDTH##_t *p, \ - uint##WIDTH##_t *cmpval, uint##WIDTH##_t newval) \ -{ \ - int retval; \ - \ - retval = atomic_fcmpset_##WIDTH(p, cmpval, newval); \ - mb(); \ - return (retval); \ -} \ - \ -static __inline int \ -atomic_fcmpset_rel_##WIDTH(__volatile uint##WIDTH##_t *p, \ - uint##WIDTH##_t *cmpval, uint##WIDTH##_t newval) \ -{ \ - mb(); \ - return (atomic_fcmpset_##WIDTH(p, cmpval, newval)); \ -} - -/* - * Atomically compare the value stored at *p with cmpval and if the - * two values are equal, update the value of *p with newval. Returns - * zero if the compare failed, nonzero otherwise. - */ -ATOMIC_CMPSET_ACQ_REL(8); -ATOMIC_CMPSET_ACQ_REL(16); -ATOMIC_FCMPSET_ACQ_REL(8); -ATOMIC_FCMPSET_ACQ_REL(16); - -#define atomic_cmpset_char atomic_cmpset_8 -#define atomic_cmpset_acq_char atomic_cmpset_acq_8 -#define atomic_cmpset_rel_char atomic_cmpset_rel_8 -#define atomic_fcmpset_acq_char atomic_fcmpset_acq_8 -#define atomic_fcmpset_rel_char atomic_fcmpset_rel_8 - -#define atomic_cmpset_short atomic_cmpset_16 -#define atomic_cmpset_acq_short atomic_cmpset_acq_16 -#define atomic_cmpset_rel_short atomic_cmpset_rel_16 -#define atomic_fcmpset_acq_short atomic_fcmpset_acq_16 -#define atomic_fcmpset_rel_short atomic_fcmpset_rel_16 - -#define atomic_fetchadd_int atomic_add_int -#define atomic_fetchadd_32 atomic_add_32 -#define atomic_fetchadd_long atomic_add_long -#define atomic_fetchadd_64 atomic_add_64 - -#undef ATOMIC_GEN -#undef atomic_cas -#undef atomic_cas_acq -#undef atomic_cas_rel -#undef atomic_op -#undef atomic_op_acq -#undef atomic_op_rel -#undef atomic_ld_acq -#undef atomic_ld_clear -#undef atomic_st -#undef atomic_st_acq -#undef atomic_st_rel - -#include - -#endif /* !_MACHINE_ATOMIC_H_ */ diff --git a/sys/sparc64/include/bus.h b/sys/sparc64/include/bus.h deleted file mode 100644 index e36c6863f80a..000000000000 --- a/sys/sparc64/include/bus.h +++ /dev/null @@ -1,852 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause-NetBSD AND BSD-4-Clause - * - * Copyright (c) 1996, 1997, 1998, 2001 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, - * NASA Ames Research Center. - * - * 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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. - */ -/* - * Copyright (c) 1997-1999 Eduardo E. Horvath. All rights reserved. - * Copyright (c) 1996 Charles M. Hannum. All rights reserved. - * Copyright (c) 1996 Christopher G. Demetriou. 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. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Christopher G. Demetriou - * for the NetBSD Project. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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. - * - * from: NetBSD: bus.h,v 1.58 2008/04/28 20:23:36 martin Exp - * and - * from: FreeBSD: src/sys/alpha/include/bus.h,v 1.9 2001/01/09 - * - * $FreeBSD$ - */ - -#ifndef _MACHINE_BUS_H_ -#define _MACHINE_BUS_H_ - -#ifdef BUS_SPACE_DEBUG -#include -#endif - -#include -#include - -/* - * Nexus and SBus spaces are non-cached and big endian - * (except for RAM and PROM) - * - * PCI spaces are non-cached and little endian - */ -#define NEXUS_BUS_SPACE 0 -#define SBUS_BUS_SPACE 1 -#define PCI_CONFIG_BUS_SPACE 2 -#define PCI_IO_BUS_SPACE 3 -#define PCI_MEMORY_BUS_SPACE 4 -#define LAST_BUS_SPACE 5 - -extern const int bus_type_asi[]; -extern const int bus_stream_asi[]; - -#define __BUS_SPACE_HAS_STREAM_METHODS 1 - -#define BUS_SPACE_MAXSIZE_24BIT 0xFFFFFF -#define BUS_SPACE_MAXSIZE_32BIT 0xFFFFFFFF -#define BUS_SPACE_MAXSIZE 0xFFFFFFFFFFFFFFFF -#define BUS_SPACE_MAXADDR_24BIT 0xFFFFFF -#define BUS_SPACE_MAXADDR_32BIT 0xFFFFFFFF -#define BUS_SPACE_MAXADDR 0xFFFFFFFFFFFFFFFF - -#define BUS_SPACE_UNRESTRICTED (~0) - -struct bus_space_tag { - void *bst_cookie; - int bst_type; -}; - -/* - * Bus space function prototypes. - */ -static void bus_space_barrier(bus_space_tag_t, bus_space_handle_t, bus_size_t, - bus_size_t, int); -static int bus_space_subregion(bus_space_tag_t, bus_space_handle_t, - bus_size_t, bus_size_t, bus_space_handle_t *); - -/* - * Map a region of device bus space into CPU virtual address space. - */ -int bus_space_map(bus_space_tag_t tag, bus_addr_t address, bus_size_t size, - int flags, bus_space_handle_t *handlep); - -/* - * Unmap a region of device bus space. - */ -void bus_space_unmap(bus_space_tag_t tag, bus_space_handle_t handle, - bus_size_t size); - -static __inline void -bus_space_barrier(bus_space_tag_t t __unused, bus_space_handle_t h __unused, - bus_size_t o __unused, bus_size_t s __unused, int f __unused) -{ - - /* - * We have lots of alternatives depending on whether we're - * synchronizing loads with loads, loads with stores, stores - * with loads, or stores with stores. The only ones that seem - * generic are #Sync and #MemIssue. We use #Sync for safety. - */ - membar(Sync); -} - -static __inline int -bus_space_subregion(bus_space_tag_t t __unused, bus_space_handle_t h, - bus_size_t o __unused, bus_size_t s __unused, bus_space_handle_t *hp) -{ - - *hp = h + o; - return (0); -} - -/* flags for bus space map functions */ -#define BUS_SPACE_MAP_CACHEABLE 0x0001 -#define BUS_SPACE_MAP_LINEAR 0x0002 -#define BUS_SPACE_MAP_READONLY 0x0004 -#define BUS_SPACE_MAP_PREFETCHABLE 0x0008 -/* placeholders for bus functions... */ -#define BUS_SPACE_MAP_BUS1 0x0100 -#define BUS_SPACE_MAP_BUS2 0x0200 -#define BUS_SPACE_MAP_BUS3 0x0400 -#define BUS_SPACE_MAP_BUS4 0x0800 - -/* flags for bus_space_barrier() */ -#define BUS_SPACE_BARRIER_READ 0x01 /* force read barrier */ -#define BUS_SPACE_BARRIER_WRITE 0x02 /* force write barrier */ - -#ifdef BUS_SPACE_DEBUG -#define KTR_BUS KTR_SPARE2 -#define __BUS_DEBUG_ACCESS(h, o, desc, sz) do { \ - CTR4(KTR_BUS, "bus space: %s %d: handle %#lx, offset %#lx", \ - (desc), (sz), (h), (o)); \ -} while (0) -#else -#define __BUS_DEBUG_ACCESS(h, o, desc, sz) -#endif - -static __inline uint8_t -bus_space_read_1(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o) -{ - - __BUS_DEBUG_ACCESS(h, o, "read", 1); - return (lduba_nc((caddr_t)(h + o), bus_type_asi[t->bst_type])); -} - -static __inline uint16_t -bus_space_read_2(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o) -{ - - __BUS_DEBUG_ACCESS(h, o, "read", 2); - return (lduha_nc((caddr_t)(h + o), bus_type_asi[t->bst_type])); -} - -static __inline uint32_t -bus_space_read_4(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o) -{ - - __BUS_DEBUG_ACCESS(h, o, "read", 4); - return (lduwa_nc((caddr_t)(h + o), bus_type_asi[t->bst_type])); -} - -static __inline uint64_t -bus_space_read_8(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o) -{ - - __BUS_DEBUG_ACCESS(h, o, "read", 8); - return (ldxa_nc((caddr_t)(h + o), bus_type_asi[t->bst_type])); -} - -static __inline void -bus_space_read_multi_1(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, - uint8_t *a, size_t c) -{ - - while (c-- > 0) - *a++ = bus_space_read_1(t, h, o); -} - -static __inline void -bus_space_read_multi_2(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, - uint16_t *a, size_t c) -{ - - while (c-- > 0) - *a++ = bus_space_read_2(t, h, o); -} - -static __inline void -bus_space_read_multi_4(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, - uint32_t *a, size_t c) -{ - - while (c-- > 0) - *a++ = bus_space_read_4(t, h, o); -} - -static __inline void -bus_space_read_multi_8(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, - uint64_t *a, size_t c) -{ - - while (c-- > 0) - *a++ = bus_space_read_8(t, h, o); -} - -static __inline void -bus_space_write_1(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, - uint8_t v) -{ - - __BUS_DEBUG_ACCESS(h, o, "write", 1); - stba_nc((caddr_t)(h + o), bus_type_asi[t->bst_type], v); -} - -static __inline void -bus_space_write_2(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, - uint16_t v) -{ - - __BUS_DEBUG_ACCESS(h, o, "write", 2); - stha_nc((caddr_t)(h + o), bus_type_asi[t->bst_type], v); -} - -static __inline void -bus_space_write_4(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, - uint32_t v) -{ - - __BUS_DEBUG_ACCESS(h, o, "write", 4); - stwa_nc((caddr_t)(h + o), bus_type_asi[t->bst_type], v); -} - -static __inline void -bus_space_write_8(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, - uint64_t v) -{ - - __BUS_DEBUG_ACCESS(h, o, "write", 8); - stxa_nc((caddr_t)(h + o), bus_type_asi[t->bst_type], v); -} - -static __inline void -bus_space_write_multi_1(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, - const uint8_t *a, size_t c) -{ - - while (c-- > 0) - bus_space_write_1(t, h, o, *a++); -} - -static __inline void -bus_space_write_multi_2(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, - const uint16_t *a, size_t c) -{ - - while (c-- > 0) - bus_space_write_2(t, h, o, *a++); -} - -static __inline void -bus_space_write_multi_4(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, - const uint32_t *a, size_t c) -{ - - while (c-- > 0) - bus_space_write_4(t, h, o, *a++); -} - -static __inline void -bus_space_write_multi_8(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, - const uint64_t *a, size_t c) -{ - - while (c-- > 0) - bus_space_write_8(t, h, o, *a++); -} - -static __inline void -bus_space_set_multi_1(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, - uint8_t v, size_t c) -{ - - while (c-- > 0) - bus_space_write_1(t, h, o, v); -} - -static __inline void -bus_space_set_multi_2(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, - uint16_t v, size_t c) -{ - - while (c-- > 0) - bus_space_write_2(t, h, o, v); -} - -static __inline void -bus_space_set_multi_4(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, - uint32_t v, size_t c) -{ - - while (c-- > 0) - bus_space_write_4(t, h, o, v); -} - -static __inline void -bus_space_set_multi_8(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, - uint64_t v, size_t c) -{ - - while (c-- > 0) - bus_space_write_8(t, h, o, v); -} - -static __inline void -bus_space_read_region_1(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, - uint8_t *a, bus_size_t c) -{ - - for (; c; a++, c--, o++) - *a = bus_space_read_1(t, h, o); -} - -static __inline void -bus_space_read_region_2(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, - uint16_t *a, bus_size_t c) -{ - - for (; c; a++, c--, o += 2) - *a = bus_space_read_2(t, h, o); -} - -static __inline void -bus_space_read_region_4(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, - uint32_t *a, bus_size_t c) -{ - - for (; c; a++, c--, o += 4) - *a = bus_space_read_4(t, h, o); -} - -static __inline void -bus_space_read_region_8(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, - uint64_t *a, bus_size_t c) -{ - - for (; c; a++, c--, o += 8) - *a = bus_space_read_8(t, h, o); -} - -static __inline void -bus_space_write_region_1(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, - const uint8_t *a, bus_size_t c) -{ - - for (; c; a++, c--, o++) - bus_space_write_1(t, h, o, *a); -} - -static __inline void -bus_space_write_region_2(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, - const uint16_t *a, bus_size_t c) -{ - - for (; c; a++, c--, o += 2) - bus_space_write_2(t, h, o, *a); -} - -static __inline void -bus_space_write_region_4(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, - const uint32_t *a, bus_size_t c) -{ - - for (; c; a++, c--, o += 4) - bus_space_write_4(t, h, o, *a); -} - -static __inline void -bus_space_write_region_8(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, - const uint64_t *a, bus_size_t c) -{ - - for (; c; a++, c--, o += 8) - bus_space_write_8(t, h, o, *a); -} - -static __inline void -bus_space_set_region_1(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, - const uint8_t v, bus_size_t c) -{ - - for (; c; c--, o++) - bus_space_write_1(t, h, o, v); -} - -static __inline void -bus_space_set_region_2(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, - const uint16_t v, bus_size_t c) -{ - - for (; c; c--, o += 2) - bus_space_write_2(t, h, o, v); -} - -static __inline void -bus_space_set_region_4(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, - const uint32_t v, bus_size_t c) -{ - - for (; c; c--, o += 4) - bus_space_write_4(t, h, o, v); -} - -static __inline void -bus_space_set_region_8(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, - const uint64_t v, bus_size_t c) -{ - - for (; c; c--, o += 8) - bus_space_write_8(t, h, o, v); -} - -static __inline void -bus_space_copy_region_1(bus_space_tag_t t, bus_space_handle_t h1, - bus_size_t o1, bus_space_handle_t h2, bus_size_t o2, bus_size_t c) -{ - - for (; c; c--, o1++, o2++) - bus_space_write_1(t, h1, o1, bus_space_read_1(t, h2, o2)); -} - -static __inline void -bus_space_copy_region_2(bus_space_tag_t t, bus_space_handle_t h1, - bus_size_t o1, bus_space_handle_t h2, bus_size_t o2, bus_size_t c) -{ - - for (; c; c--, o1 += 2, o2 += 2) - bus_space_write_2(t, h1, o1, bus_space_read_2(t, h2, o2)); -} - -static __inline void -bus_space_copy_region_4(bus_space_tag_t t, bus_space_handle_t h1, - bus_size_t o1, bus_space_handle_t h2, bus_size_t o2, bus_size_t c) -{ - - for (; c; c--, o1 += 4, o2 += 4) - bus_space_write_4(t, h1, o1, bus_space_read_4(t, h2, o2)); -} - -static __inline void -bus_space_copy_region_8(bus_space_tag_t t, bus_space_handle_t h1, - bus_size_t o1, bus_space_handle_t h2, bus_size_t o2, bus_size_t c) -{ - - for (; c; c--, o1 += 8, o2 += 8) - bus_space_write_8(t, h1, o1, bus_space_read_8(t, h2, o2)); -} - -static __inline uint8_t -bus_space_read_stream_1(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o) -{ - - __BUS_DEBUG_ACCESS(h, o, "read stream", 1); - return (lduba_nc((caddr_t)(h + o), bus_stream_asi[t->bst_type])); -} - -static __inline uint16_t -bus_space_read_stream_2(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o) -{ - - __BUS_DEBUG_ACCESS(h, o, "read stream", 2); - return (lduha_nc((caddr_t)(h + o), bus_stream_asi[t->bst_type])); -} - -static __inline uint32_t -bus_space_read_stream_4(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o) -{ - - __BUS_DEBUG_ACCESS(h, o, "read stream", 4); - return (lduwa_nc((caddr_t)(h + o), bus_stream_asi[t->bst_type])); -} - -static __inline uint64_t -bus_space_read_stream_8(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o) -{ - - __BUS_DEBUG_ACCESS(h, o, "read stream", 8); - return (ldxa_nc((caddr_t)(h + o), bus_stream_asi[t->bst_type])); -} - -static __inline void -bus_space_read_multi_stream_1(bus_space_tag_t t, bus_space_handle_t h, - bus_size_t o, uint8_t *a, size_t c) -{ - - while (c-- > 0) - *a++ = bus_space_read_stream_1(t, h, o); -} - -static __inline void -bus_space_read_multi_stream_2(bus_space_tag_t t, bus_space_handle_t h, - bus_size_t o, uint16_t *a, size_t c) -{ - - while (c-- > 0) - *a++ = bus_space_read_stream_2(t, h, o); -} - -static __inline void -bus_space_read_multi_stream_4(bus_space_tag_t t, bus_space_handle_t h, - bus_size_t o, uint32_t *a, size_t c) -{ - - while (c-- > 0) - *a++ = bus_space_read_stream_4(t, h, o); -} - -static __inline void -bus_space_read_multi_stream_8(bus_space_tag_t t, bus_space_handle_t h, - bus_size_t o, uint64_t *a, size_t c) -{ - - while (c-- > 0) - *a++ = bus_space_read_stream_8(t, h, o); -} - -static __inline void -bus_space_write_stream_1(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, - uint8_t v) -{ - - __BUS_DEBUG_ACCESS(h, o, "write stream", 1); - stba_nc((caddr_t)(h + o), bus_stream_asi[t->bst_type], v); -} - -static __inline void -bus_space_write_stream_2(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, - uint16_t v) -{ - - __BUS_DEBUG_ACCESS(h, o, "write stream", 2); - stha_nc((caddr_t)(h + o), bus_stream_asi[t->bst_type], v); -} - -static __inline void -bus_space_write_stream_4(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, - uint32_t v) -{ - - __BUS_DEBUG_ACCESS(h, o, "write stream", 4); - stwa_nc((caddr_t)(h + o), bus_stream_asi[t->bst_type], v); -} - -static __inline void -bus_space_write_stream_8(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, - uint64_t v) -{ - - __BUS_DEBUG_ACCESS(h, o, "write stream", 8); - stxa_nc((caddr_t)(h + o), bus_stream_asi[t->bst_type], v); -} - -static __inline void -bus_space_write_multi_stream_1(bus_space_tag_t t, bus_space_handle_t h, - bus_size_t o, const uint8_t *a, size_t c) -{ - - while (c-- > 0) - bus_space_write_stream_1(t, h, o, *a++); -} - -static __inline void -bus_space_write_multi_stream_2(bus_space_tag_t t, bus_space_handle_t h, - bus_size_t o, const uint16_t *a, size_t c) -{ - - while (c-- > 0) - bus_space_write_stream_2(t, h, o, *a++); -} - -static __inline void -bus_space_write_multi_stream_4(bus_space_tag_t t, bus_space_handle_t h, - bus_size_t o, const uint32_t *a, size_t c) -{ - - while (c-- > 0) - bus_space_write_stream_4(t, h, o, *a++); -} - -static __inline void -bus_space_write_multi_stream_8(bus_space_tag_t t, bus_space_handle_t h, - bus_size_t o, const uint64_t *a, size_t c) -{ - - while (c-- > 0) - bus_space_write_stream_8(t, h, o, *a++); -} - -static __inline void -bus_space_set_multi_stream_1(bus_space_tag_t t, bus_space_handle_t h, - bus_size_t o, uint8_t v, size_t c) -{ - - while (c-- > 0) - bus_space_write_stream_1(t, h, o, v); -} - -static __inline void -bus_space_set_multi_stream_2(bus_space_tag_t t, bus_space_handle_t h, - bus_size_t o, uint16_t v, size_t c) -{ - - while (c-- > 0) - bus_space_write_stream_2(t, h, o, v); -} - -static __inline void -bus_space_set_multi_stream_4(bus_space_tag_t t, bus_space_handle_t h, - bus_size_t o, uint32_t v, size_t c) -{ - - while (c-- > 0) - bus_space_write_stream_4(t, h, o, v); -} - -static __inline void -bus_space_set_multi_stream_8(bus_space_tag_t t, bus_space_handle_t h, - bus_size_t o, uint64_t v, size_t c) -{ - - while (c-- > 0) - bus_space_write_stream_8(t, h, o, v); -} - -static __inline void -bus_space_read_region_stream_1(bus_space_tag_t t, bus_space_handle_t h, - bus_size_t o, uint8_t *a, bus_size_t c) -{ - - for (; c; a++, c--, o++) - *a = bus_space_read_stream_1(t, h, o); -} - -static __inline void -bus_space_read_region_stream_2(bus_space_tag_t t, bus_space_handle_t h, - bus_size_t o, uint16_t *a, bus_size_t c) -{ - - for (; c; a++, c--, o += 2) - *a = bus_space_read_stream_2(t, h, o); -} - -static __inline void -bus_space_read_region_stream_4(bus_space_tag_t t, bus_space_handle_t h, - bus_size_t o, uint32_t *a, bus_size_t c) -{ - - for (; c; a++, c--, o += 4) - *a = bus_space_read_stream_4(t, h, o); -} - -static __inline void -bus_space_read_region_stream_8(bus_space_tag_t t, bus_space_handle_t h, - bus_size_t o, uint64_t *a, bus_size_t c) -{ - - for (; c; a++, c--, o += 8) - *a = bus_space_read_stream_8(t, h, o); -} - -static __inline void -bus_space_write_region_stream_1(bus_space_tag_t t, bus_space_handle_t h, - bus_size_t o, const uint8_t *a, bus_size_t c) -{ - - for (; c; a++, c--, o++) - bus_space_write_stream_1(t, h, o, *a); -} - -static __inline void -bus_space_write_region_stream_2(bus_space_tag_t t, bus_space_handle_t h, - bus_size_t o, const uint16_t *a, bus_size_t c) -{ - - for (; c; a++, c--, o += 2) - bus_space_write_stream_2(t, h, o, *a); -} - -static __inline void -bus_space_write_region_stream_4(bus_space_tag_t t, bus_space_handle_t h, - bus_size_t o, const uint32_t *a, bus_size_t c) -{ - - for (; c; a++, c--, o += 4) - bus_space_write_stream_4(t, h, o, *a); -} - -static __inline void -bus_space_write_region_stream_8(bus_space_tag_t t, bus_space_handle_t h, - bus_size_t o, const uint64_t *a, bus_size_t c) -{ - - for (; c; a++, c--, o += 8) - bus_space_write_stream_8(t, h, o, *a); -} - -static __inline void -bus_space_set_region_stream_1(bus_space_tag_t t, bus_space_handle_t h, - bus_size_t o, const uint8_t v, bus_size_t c) -{ - - for (; c; c--, o++) - bus_space_write_stream_1(t, h, o, v); -} - -static __inline void -bus_space_set_region_stream_2(bus_space_tag_t t, bus_space_handle_t h, - bus_size_t o, const uint16_t v, bus_size_t c) -{ - - for (; c; c--, o += 2) - bus_space_write_stream_2(t, h, o, v); -} - -static __inline void -bus_space_set_region_stream_4(bus_space_tag_t t, bus_space_handle_t h, - bus_size_t o, const uint32_t v, bus_size_t c) -{ - - for (; c; c--, o += 4) - bus_space_write_stream_4(t, h, o, v); -} - -static __inline void -bus_space_set_region_stream_8(bus_space_tag_t t, bus_space_handle_t h, - bus_size_t o, const uint64_t v, bus_size_t c) -{ - - for (; c; c--, o += 8) - bus_space_write_stream_8(t, h, o, v); -} - -static __inline void -bus_space_copy_region_stream_1(bus_space_tag_t t, bus_space_handle_t h1, - bus_size_t o1, bus_space_handle_t h2, bus_size_t o2, bus_size_t c) -{ - - for (; c; c--, o1++, o2++) - bus_space_write_stream_1(t, h1, o1, bus_space_read_stream_1(t, h2, - o2)); -} - -static __inline void -bus_space_copy_region_stream_2(bus_space_tag_t t, bus_space_handle_t h1, - bus_size_t o1, bus_space_handle_t h2, bus_size_t o2, bus_size_t c) -{ - - for (; c; c--, o1 += 2, o2 += 2) - bus_space_write_stream_2(t, h1, o1, bus_space_read_stream_2(t, h2, - o2)); -} - -static __inline void -bus_space_copy_region_stream_4(bus_space_tag_t t, bus_space_handle_t h1, - bus_size_t o1, bus_space_handle_t h2, bus_size_t o2, bus_size_t c) -{ - - for (; c; c--, o1 += 4, o2 += 4) - bus_space_write_stream_4(t, h1, o1, bus_space_read_stream_4(t, h2, - o2)); -} - -static __inline void -bus_space_copy_region_stream_8(bus_space_tag_t t, bus_space_handle_t h1, - bus_size_t o1, bus_space_handle_t h2, bus_size_t o2, bus_size_t c) -{ - - for (; c; c--, o1 += 8, o2 += 8) - bus_space_write_stream_8(t, h1, o1, bus_space_read_8(t, h2, o2)); -} - -static __inline int -bus_space_peek_1(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, - uint8_t *a) -{ - - __BUS_DEBUG_ACCESS(h, o, "peek", 1); - return (fasword8(bus_type_asi[t->bst_type], (caddr_t)(h + o), a)); -} - -static __inline int -bus_space_peek_2(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, - uint16_t *a) -{ - - __BUS_DEBUG_ACCESS(h, o, "peek", 2); - return (fasword16(bus_type_asi[t->bst_type], (caddr_t)(h + o), a)); -} - -static __inline int -bus_space_peek_4(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, - uint32_t *a) -{ - - __BUS_DEBUG_ACCESS(h, o, "peek", 4); - return (fasword32(bus_type_asi[t->bst_type], (caddr_t)(h + o), a)); -} - -#include - -#endif /* !_MACHINE_BUS_H_ */ diff --git a/sys/sparc64/include/bus_common.h b/sys/sparc64/include/bus_common.h deleted file mode 100644 index 6d04a9cbe27d..000000000000 --- a/sys/sparc64/include/bus_common.h +++ /dev/null @@ -1,77 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-3-Clause - * - * 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. - * - * form: @(#)sbusreg.h 8.1 (Berkeley) 6/11/93 - * from: NetBSD: iommureg.h,v 1.6 2001/07/20 00:07:13 eeh Exp - * - * $FreeBSD$ - */ - -#ifndef _MACHINE_BUS_COMMON_H_ -#define _MACHINE_BUS_COMMON_H_ - -#define INTCLR_PENDING 0x000000003ULL /* Interrupt queued to CPU */ -#define INTCLR_RECEIVED 0x000000001ULL /* Interrupt received */ -#define INTCLR_IDLE 0x000000000ULL /* Interrupt idle */ - -#define INTMAP_V 0x080000000ULL /* Interrupt valid (enabled) */ -#define INTMAP_TID_MASK 0x07c000000ULL /* UPA target ID */ -#define INTMAP_TID_SHIFT 26 -#define INTMAP_IGN_MASK 0x0000007c0ULL /* Interrupt group no. */ -#define INTMAP_IGN_SHIFT 6 -#define INTMAP_INO_MASK 0x00000003fULL /* Interrupt number */ -#define INTMAP_INR_MASK (INTMAP_IGN_MASK | INTMAP_INO_MASK) -#define INTMAP_SBUSSLOT_MASK 0x000000018ULL /* SBus slot # */ -#define INTMAP_PCIBUS_MASK 0x000000010ULL /* PCI bus number (A or B) */ -#define INTMAP_PCISLOT_MASK 0x00000000cULL /* PCI slot # */ -#define INTMAP_PCIINT_MASK 0x000000003ULL /* PCI interrupt #A,#B,#C,#D */ -#define INTMAP_OBIO_MASK 0x000000020ULL /* Onboard device */ -#define INTIGN(x) (((x) & INTMAP_IGN_MASK) >> INTMAP_IGN_SHIFT) -#define INTVEC(x) ((x) & INTMAP_INR_MASK) -#define INTSLOT(x) (((x) >> 3) & 0x7) -#define INTPRI(x) ((x) & 0x7) -#define INTINO(x) ((x) & INTMAP_INO_MASK) -#define INTMAP_ENABLE(mr, mid) \ - (INTMAP_TID((mr), (mid)) | INTMAP_V) -#define INTMAP_TID(mr, mid) \ - (((mr) & ~INTMAP_TID_MASK) | ((mid) << INTMAP_TID_SHIFT)) -#define INTMAP_VEC(ign, ino) \ - ((((ign) << INTMAP_IGN_SHIFT) & INTMAP_IGN_MASK) | \ - ((ino) & INTMAP_INO_MASK)) - -/* counter-timer support. */ -void sparc64_counter_init(const char *name, bus_space_tag_t tag, - bus_space_handle_t handle, bus_addr_t offset); - -#endif /* !_MACHINE_BUS_COMMON_H_ */ diff --git a/sys/sparc64/include/bus_dma.h b/sys/sparc64/include/bus_dma.h deleted file mode 100644 index 0edb92860bd5..000000000000 --- a/sys/sparc64/include/bus_dma.h +++ /dev/null @@ -1,221 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause-NetBSD AND BSD-4-Clause - * - * Copyright (c) 1996, 1997, 1998, 2001 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, - * NASA Ames Research Center. - * - * 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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. - */ -/* - * Copyright (c) 1997-1999 Eduardo E. Horvath. All rights reserved. - * Copyright (c) 1996 Charles M. Hannum. All rights reserved. - * Copyright (c) 1996 Christopher G. Demetriou. 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. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Christopher G. Demetriou - * for the NetBSD Project. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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. - * - * from: NetBSD: bus.h,v 1.58 2008/04/28 20:23:36 martin Exp - * and - * from: FreeBSD: src/sys/alpha/include/bus.h,v 1.9 2001/01/09 - * - * $FreeBSD$ - */ - -#ifndef _SPARC64_BUS_DMA_H -#define _SPARC64_BUS_DMA_H - -#define WANT_INLINE_DMAMAP -#include - -/* DMA support */ - -/* - * Method table for a bus_dma_tag. - */ -struct bus_dma_methods { - int (*dm_dmamap_create)(bus_dma_tag_t, int, bus_dmamap_t *); - int (*dm_dmamap_destroy)(bus_dma_tag_t, bus_dmamap_t); - int (*dm_dmamap_load_phys)(bus_dma_tag_t dmat, bus_dmamap_t map, - vm_paddr_t buf, bus_size_t buflen, int flags, - bus_dma_segment_t *segs, int *segp); - int (*dm_dmamap_load_buffer)(bus_dma_tag_t dmat, bus_dmamap_t map, - void *buf, bus_size_t buflen, struct pmap *pmap, int flags, - bus_dma_segment_t *segs, int *segp); - void (*dm_dmamap_waitok)(bus_dma_tag_t dmat, bus_dmamap_t map, - struct memdesc *mem, bus_dmamap_callback_t *callback, - void *callback_arg); - bus_dma_segment_t *(*dm_dmamap_complete)(bus_dma_tag_t dmat, - bus_dmamap_t map, bus_dma_segment_t *segs, int nsegs, int error); - void (*dm_dmamap_unload)(bus_dma_tag_t, bus_dmamap_t); - void (*dm_dmamap_sync)(bus_dma_tag_t, bus_dmamap_t, - bus_dmasync_op_t); - int (*dm_dmamem_alloc)(bus_dma_tag_t, void **, int, bus_dmamap_t *); - void (*dm_dmamem_free)(bus_dma_tag_t, void *, bus_dmamap_t); -}; - -/* - * bus_dma_tag_t - * - * A machine-dependent opaque type describing the implementation of - * DMA for a given bus. - */ -struct bus_dma_tag { - void *dt_cookie; /* cookie used in the guts */ - bus_dma_tag_t dt_parent; - bus_size_t dt_alignment; - bus_addr_t dt_boundary; - bus_addr_t dt_lowaddr; - bus_addr_t dt_highaddr; - bus_dma_filter_t *dt_filter; - void *dt_filterarg; - bus_size_t dt_maxsize; - int dt_nsegments; - bus_size_t dt_maxsegsz; - int dt_flags; - int dt_ref_count; - int dt_map_count; - bus_dma_lock_t *dt_lockfunc; - void * *dt_lockfuncarg; - bus_dma_segment_t *dt_segments; - - struct bus_dma_methods *dt_mt; -}; - -static inline int -bus_dmamap_create(bus_dma_tag_t dmat, int flags, bus_dmamap_t *mapp) -{ - - return (dmat->dt_mt->dm_dmamap_create(dmat, flags, mapp)); -} - -static inline int -bus_dmamap_destroy(bus_dma_tag_t dmat, bus_dmamap_t map) -{ - - return (dmat->dt_mt->dm_dmamap_destroy(dmat, map)); -} - -static inline void -bus_dmamap_sync(bus_dma_tag_t dmat, bus_dmamap_t map, bus_dmasync_op_t op) -{ - - dmat->dt_mt->dm_dmamap_sync(dmat, map, op); -} - -static inline void -bus_dmamap_unload(bus_dma_tag_t dmat, bus_dmamap_t map) -{ - - dmat->dt_mt->dm_dmamap_unload(dmat, map); -} - -static inline int -bus_dmamem_alloc(bus_dma_tag_t dmat, void** vaddr, int flags, bus_dmamap_t *mapp) -{ - - return (dmat->dt_mt->dm_dmamem_alloc(dmat, vaddr, flags, mapp)); -} - -static inline void -bus_dmamem_free(bus_dma_tag_t dmat, void *vaddr, bus_dmamap_t map) -{ - - dmat->dt_mt->dm_dmamem_free(dmat, vaddr, map); -} - -static inline bus_dma_segment_t* -_bus_dmamap_complete(bus_dma_tag_t dmat, bus_dmamap_t map, - bus_dma_segment_t *segs, int nsegs, int error) -{ - - return (dmat->dt_mt->dm_dmamap_complete(dmat, map, segs, - nsegs, error)); -} - -static inline int -_bus_dmamap_load_buffer(bus_dma_tag_t dmat, bus_dmamap_t map, - void *buf, bus_size_t buflen, struct pmap *pmap, - int flags, bus_dma_segment_t *segs, int *segp) -{ - - return (dmat->dt_mt->dm_dmamap_load_buffer(dmat, map, buf, buflen, - pmap, flags, segs, segp)); -} - -static inline int -_bus_dmamap_load_ma(bus_dma_tag_t dmat, bus_dmamap_t map, - struct vm_page **ma, bus_size_t tlen, int ma_offs, - int flags, bus_dma_segment_t *segs, int *segp) -{ - - return (bus_dmamap_load_ma_triv(dmat, map, ma, tlen, ma_offs, flags, - segs, segp)); -} - -static inline int -_bus_dmamap_load_phys(bus_dma_tag_t dmat, bus_dmamap_t map, - vm_paddr_t paddr, bus_size_t buflen, - int flags, bus_dma_segment_t *segs, int *segp) -{ - - return (dmat->dt_mt->dm_dmamap_load_phys(dmat, map, paddr, buflen, - flags, segs, segp)); -} - -static inline void -_bus_dmamap_waitok(bus_dma_tag_t dmat, bus_dmamap_t map, - struct memdesc *mem, bus_dmamap_callback_t *callback, - void *callback_arg) -{ - - return (dmat->dt_mt->dm_dmamap_waitok(dmat, map, mem, callback, - callback_arg)); -} - -#endif /* !_SPARC64_BUS_DMA_H_ */ diff --git a/sys/sparc64/include/bus_private.h b/sys/sparc64/include/bus_private.h deleted file mode 100644 index 57f25a678c81..000000000000 --- a/sys/sparc64/include/bus_private.h +++ /dev/null @@ -1,82 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD - * - * Copyright (c) 1997, 1998 Justin T. Gibbs. - * Copyright (c) 2002 by Thomas Moestl . - * 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 ``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. - * - * from: FreeBSD: src/sys/i386/i386/busdma_machdep.c,v 1.25 2002/01/05 - * - * $FreeBSD$ - */ - -#ifndef _MACHINE_BUS_PRIVATE_H_ -#define _MACHINE_BUS_PRIVATE_H_ - -#include - -/* - * Helpers - */ -int sparc64_bus_mem_map(bus_space_tag_t tag, bus_addr_t addr, bus_size_t size, - int flags, vm_offset_t vaddr, bus_space_handle_t *hp); -int sparc64_bus_mem_unmap(bus_space_tag_t tag, bus_space_handle_t handle, - bus_size_t size); -bus_space_tag_t sparc64_alloc_bus_tag(void *cookie, int type); -bus_space_handle_t sparc64_fake_bustag(int space, bus_addr_t addr, - struct bus_space_tag *ptag); - -struct bus_dmamap_res { - struct resource *dr_res; - bus_size_t dr_used; - SLIST_ENTRY(bus_dmamap_res) dr_link; -}; - -/* - * Callers of the bus_dma interfaces must always protect their tags and maps - * appropriately against concurrent access. However, when a map is on a LRU - * queue, there is a second access path to it; for this case, the locking rules - * are given in the parenthesized comments below: - * q - locked by the mutex protecting the queue. - * p - private to the owner of the map, no access through the queue. - * * - comment refers to pointer target. - * Only the owner of the map is allowed to insert the map into a queue. Removal - * and repositioning (i.e. temporal removal and reinsertion) is allowed to all - * if the queue lock is held. - */ -struct bus_dmamap { - TAILQ_ENTRY(bus_dmamap) dm_maplruq; /* (q) */ - SLIST_HEAD(, bus_dmamap_res) dm_reslist; /* (q, *q) */ - int dm_onq; /* (q) */ - int dm_flags; /* (p) */ -}; - -/* Flag values */ -#define DMF_LOADED (1 << 0) /* Map is loaded. */ -#define DMF_COHERENT (1 << 1) /* Coherent mapping requested. */ -#define DMF_STREAMED (1 << 2) /* Streaming cache used. */ - -int sparc64_dma_alloc_map(bus_dma_tag_t dmat, bus_dmamap_t *mapp); -void sparc64_dma_free_map(bus_dma_tag_t dmat, bus_dmamap_t map); - -#endif /* !_MACHINE_BUS_PRIVATE_H_ */ diff --git a/sys/sparc64/include/cache.h b/sys/sparc64/include/cache.h deleted file mode 100644 index a299f2e4974a..000000000000 --- a/sys/sparc64/include/cache.h +++ /dev/null @@ -1,129 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-4-Clause - * - * Copyright (c) 1996 - * The President and Fellows of Harvard College. All rights reserved. - * 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. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Aaron Brown and - * Harvard University. - * 4. 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. - * - * from: @(#)cache.h 8.1 (Berkeley) 6/11/93 - * from: NetBSD: cache.h,v 1.3 2000/08/01 00:28:02 eeh Exp - * - * $FreeBSD$ - */ - -#ifndef _MACHINE_CACHE_H_ -#define _MACHINE_CACHE_H_ - -#define DCACHE_COLOR_BITS (1) -#define DCACHE_COLORS (1 << DCACHE_COLOR_BITS) -#define DCACHE_COLOR_MASK (DCACHE_COLORS - 1) -#define DCACHE_COLOR(va) (((va) >> PAGE_SHIFT) & DCACHE_COLOR_MASK) -#define DCACHE_OTHER_COLOR(color) \ - ((color) ^ DCACHE_COLOR_BITS) - -#define DC_TAG_SHIFT 2 -#define DC_VALID_SHIFT 0 - -#define DC_TAG_BITS 28 -#define DC_VALID_BITS 2 - -#define DC_TAG_MASK ((1 << DC_TAG_BITS) - 1) -#define DC_VALID_MASK ((1 << DC_VALID_BITS) - 1) - -#define IC_TAG_SHIFT 7 -#define IC_VALID_SHIFT 36 - -#define IC_TAG_BITS 28 -#define IC_VALID_BITS 1 - -#define IC_TAG_MASK ((1 << IC_TAG_BITS) - 1) -#define IC_VALID_MASK ((1 << IC_VALID_BITS) - 1) - -#ifndef LOCORE - -/* - * Cache control information - */ -struct cacheinfo { - u_int ic_size; /* instruction cache */ - u_int ic_assoc; - u_int ic_linesize; - u_int dc_size; /* data cache */ - u_int dc_assoc; - u_int dc_linesize; - u_int ec_size; /* external cache info */ - u_int ec_assoc; - u_int ec_linesize; -}; - -#ifdef _KERNEL - -extern u_int dcache_color_ignore; - -struct pcpu; - -typedef void cache_enable_t(u_int cpu_impl); -typedef void cache_flush_t(void); -typedef void dcache_page_inval_t(vm_paddr_t pa); -typedef void icache_page_inval_t(vm_paddr_t pa); - -void cache_init(struct pcpu *pcpu); - -cache_enable_t cheetah_cache_enable; -cache_flush_t cheetah_cache_flush; -dcache_page_inval_t cheetah_dcache_page_inval; -icache_page_inval_t cheetah_icache_page_inval; - -cache_enable_t spitfire_cache_enable; -cache_flush_t spitfire_cache_flush; -dcache_page_inval_t spitfire_dcache_page_inval; -icache_page_inval_t spitfire_icache_page_inval; - -cache_enable_t zeus_cache_enable; -cache_flush_t zeus_cache_flush; -dcache_page_inval_t zeus_dcache_page_inval; -icache_page_inval_t zeus_icache_page_inval; - -extern cache_enable_t *cache_enable; -extern cache_flush_t *cache_flush; -extern dcache_page_inval_t *dcache_page_inval; -extern icache_page_inval_t *icache_page_inval; - -#endif /* KERNEL */ - -#endif /* !LOCORE */ - -#endif /* !_MACHINE_CACHE_H_ */ diff --git a/sys/sparc64/include/ccr.h b/sys/sparc64/include/ccr.h deleted file mode 100644 index d370684ddd73..000000000000 --- a/sys/sparc64/include/ccr.h +++ /dev/null @@ -1,48 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD - * - * Copyright 2001 by Thomas Moestl . 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 ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE - * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $FreeBSD$ - */ - -#ifndef _MACHINE_CCR_H_ -#define _MACHINE_CCR_H_ - -#define ICC_SHIFT 0 -#define ICC_BITS 4 -#define ICC_MASK ((1UL << ICC_BITS) - 1) -#define ICC_C (1UL << 0) -#define ICC_V (1UL << 1) -#define ICC_Z (1UL << 2) -#define ICC_N (1UL << 3) - -#define XCC_SHIFT 4 -#define XCC_BITS 4 -#define XCC_MASK (((1UL << XCC_BITS) - 1) << XCC_SHIFT) -#define XCC_C (1UL << 4) -#define XCC_V (1UL << 5) -#define XCC_Z (1UL << 6) -#define XCC_N (1UL << 7) - -#endif /* !_MACHINE_CCR_H_ */ diff --git a/sys/sparc64/include/clock.h b/sys/sparc64/include/clock.h deleted file mode 100644 index 34b59d8c8b77..000000000000 --- a/sys/sparc64/include/clock.h +++ /dev/null @@ -1,10 +0,0 @@ -/*- - * This file is in the public domain. - * - * $FreeBSD$ - */ - -#ifndef _MACHINE_CLOCK_H_ -#define _MACHINE_CLOCK_H_ - -#endif /* !_MACHINE_CLOCK_H_ */ diff --git a/sys/sparc64/include/cmt.h b/sys/sparc64/include/cmt.h deleted file mode 100644 index 770f71616a8f..000000000000 --- a/sys/sparc64/include/cmt.h +++ /dev/null @@ -1,41 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD - * - * Copyright (c) 2010 Marius Strobl - * 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$ - */ - -#ifndef _MACHINE_CMT_H_ -#define _MACHINE_CMT_H_ - -#define INTR_ID_ID_SHIFT (0) -#define INTR_ID_ID_SIZE (10) -#define INTR_ID_ID_MASK \ - (((1 << INTR_ID_ID_SIZE) - 1) << INTR_ID_ID_SHIFT) - -#define INTR_ID_GET_ID(cr) ((cr & INTR_ID_ID_MASK) >> INTR_ID_ID_SHIFT) - -#endif /* _MACHINE_CMT_H_ */ diff --git a/sys/sparc64/include/counter.h b/sys/sparc64/include/counter.h deleted file mode 100644 index 128d5c0fce7e..000000000000 --- a/sys/sparc64/include/counter.h +++ /dev/null @@ -1,98 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD - * - * Copyright (c) 2012 Konstantin Belousov - * 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$ - */ - -#ifndef __MACHINE_COUNTER_H__ -#define __MACHINE_COUNTER_H__ - -#include -#ifdef INVARIANTS -#include -#endif - -extern struct pcpu dummy_pcpu[]; -#define EARLY_COUNTER &dummy_pcpu[0].pc_early_dummy_counter - -#define counter_enter() critical_enter() -#define counter_exit() critical_exit() - -#ifdef IN_SUBR_COUNTER_C -static inline uint64_t -counter_u64_read_one(uint64_t *p, int cpu) -{ - - return (*(uint64_t *)((char *)p + UMA_PCPU_ALLOC_SIZE * cpu)); -} - -static inline uint64_t -counter_u64_fetch_inline(uint64_t *p) -{ - uint64_t r; - int i; - - r = 0; - for (i = 0; i < mp_ncpus; i++) - r += counter_u64_read_one((uint64_t *)p, i); - - return (r); -} - -/* XXXKIB might interrupt increment */ -static void -counter_u64_zero_one_cpu(void *arg) -{ - - *((uint64_t *)((char *)arg + UMA_PCPU_ALLOC_SIZE * - PCPU_GET(cpuid))) = 0; -} - -static inline void -counter_u64_zero_inline(counter_u64_t c) -{ - - smp_rendezvous(smp_no_rendezvous_barrier, counter_u64_zero_one_cpu, - smp_no_rendezvous_barrier, c); -} -#endif - -#define counter_u64_add_protected(c, inc) do { \ - CRITICAL_ASSERT(curthread); \ - *(uint64_t *)zpcpu_get(c) += (inc); \ -} while (0) - -static inline void -counter_u64_add(counter_u64_t c, int64_t inc) -{ - - counter_enter(); - counter_u64_add_protected(c, inc); - counter_exit(); -} - -#endif /* ! __MACHINE_COUNTER_H__ */ diff --git a/sys/sparc64/include/cpu.h b/sys/sparc64/include/cpu.h deleted file mode 100644 index a91159f6a7a2..000000000000 --- a/sys/sparc64/include/cpu.h +++ /dev/null @@ -1,74 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-3-Clause - * - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * 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. - * - * from: @(#)cpu.h 5.4 (Berkeley) 5/9/91 - * from: FreeBSD: src/sys/i386/include/cpu.h,v 1.62 2001/06/29 - * $FreeBSD$ - */ - -#ifndef _MACHINE_CPU_H_ -#define _MACHINE_CPU_H_ - -#include -#include - -#define TRAPF_PC(tfp) ((tfp)->tf_tpc) -#define TRAPF_USERMODE(tfp) (((tfp)->tf_tstate & TSTATE_PRIV) == 0) - -#define cpu_getstack(td) ((td)->td_frame->tf_sp) -#define cpu_setstack(td, sp) ((td)->td_frame->tf_sp = (sp)) -#define cpu_spinwait() /* nothing */ -#define cpu_lock_delay() DELAY(1) - -#ifdef _KERNEL - -extern char btext[]; -extern char etext[]; - -void cheetah_init(u_int cpu_impl); -void cpu_halt(void) __dead2; -void cpu_reset(void) __dead2; -void fork_trampoline(void); -void swi_vm(void *v); -void zeus_init(u_int cpu_impl); - -static __inline u_int64_t -get_cyclecount(void) -{ - - return (rd(tick)); -} - -#endif - -#endif /* !_MACHINE_CPU_H_ */ diff --git a/sys/sparc64/include/cpufunc.h b/sys/sparc64/include/cpufunc.h deleted file mode 100644 index 934e671707b9..000000000000 --- a/sys/sparc64/include/cpufunc.h +++ /dev/null @@ -1,272 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD - * - * Copyright (c) 2001 Jake Burkholder. - * 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$ - */ - -#ifndef _MACHINE_CPUFUNC_H_ -#define _MACHINE_CPUFUNC_H_ - -#include -#include - -struct thread; - -/* - * Membar operand macros for use in other macros when # is a special - * character. Keep these in sync with what the hardware expects. - */ -#define C_Lookaside (0) -#define C_MemIssue (1) -#define C_Sync (2) -#define M_LoadLoad (0) -#define M_StoreLoad (1) -#define M_LoadStore (2) -#define M_StoreStore (3) - -#define CMASK_SHIFT (4) -#define MMASK_SHIFT (0) - -#define CMASK_GEN(bit) ((1 << (bit)) << CMASK_SHIFT) -#define MMASK_GEN(bit) ((1 << (bit)) << MMASK_SHIFT) - -#define Lookaside CMASK_GEN(C_Lookaside) -#define MemIssue CMASK_GEN(C_MemIssue) -#define Sync CMASK_GEN(C_Sync) -#define LoadLoad MMASK_GEN(M_LoadLoad) -#define StoreLoad MMASK_GEN(M_StoreLoad) -#define LoadStore MMASK_GEN(M_LoadStore) -#define StoreStore MMASK_GEN(M_StoreStore) - -#define casa(rs1, rs2, rd, asi) ({ \ - u_int __rd = (uint32_t)(rd); \ - __asm __volatile("casa [%2] %3, %4, %0" \ - : "+r" (__rd), "=m" (*rs1) \ - : "r" (rs1), "n" (asi), "r" (rs2), "m" (*rs1)); \ - __rd; \ -}) - -#define casxa(rs1, rs2, rd, asi) ({ \ - u_long __rd = (uint64_t)(rd); \ - __asm __volatile("casxa [%2] %3, %4, %0" \ - : "+r" (__rd), "=m" (*rs1) \ - : "r" (rs1), "n" (asi), "r" (rs2), "m" (*rs1)); \ - __rd; \ -}) - -#define flush(va) do { \ - __asm __volatile("flush %0" : : "r" (va)); \ -} while (0) - -#define flushw() do { \ - __asm __volatile("flushw" : :); \ -} while (0) - -#define mov(val, reg) do { \ - __asm __volatile("mov %0, %" __XSTRING(reg) : : "r" (val)); \ -} while (0) - -/* Generate ld*a/st*a functions for non-constant ASIs. */ -#define LDNC_GEN(tp, o) \ - static __inline tp \ - o ## _nc(caddr_t va, int asi) \ - { \ - tp r; \ - __asm __volatile("wr %2, 0, %%asi;" #o " [%1] %%asi, %0"\ - : "=r" (r) : "r" (va), "r" (asi)); \ - return (r); \ - } - -LDNC_GEN(u_char, lduba); -LDNC_GEN(u_short, lduha); -LDNC_GEN(u_int, lduwa); -LDNC_GEN(u_long, ldxa); - -#define LD_GENERIC(va, asi, op, type) ({ \ - type __r; \ - __asm __volatile(#op " [%1] %2, %0" \ - : "=r" (__r) : "r" (va), "n" (asi)); \ - __r; \ -}) - -#define lduba(va, asi) LD_GENERIC(va, asi, lduba, u_char) -#define lduha(va, asi) LD_GENERIC(va, asi, lduha, u_short) -#define lduwa(va, asi) LD_GENERIC(va, asi, lduwa, u_int) -#define ldxa(va, asi) LD_GENERIC(va, asi, ldxa, u_long) - -#define STNC_GEN(tp, o) \ - static __inline void \ - o ## _nc(caddr_t va, int asi, tp val) \ - { \ - __asm __volatile("wr %2, 0, %%asi;" #o " %0, [%1] %%asi"\ - : : "r" (val), "r" (va), "r" (asi)); \ - } - -STNC_GEN(u_char, stba); -STNC_GEN(u_short, stha); -STNC_GEN(u_int, stwa); -STNC_GEN(u_long, stxa); - -#define ST_GENERIC(va, asi, val, op) \ - __asm __volatile(#op " %0, [%1] %2" \ - : : "r" (val), "r" (va), "n" (asi)); \ - -#define stba(va, asi, val) ST_GENERIC(va, asi, val, stba) -#define stha(va, asi, val) ST_GENERIC(va, asi, val, stha) -#define stwa(va, asi, val) ST_GENERIC(va, asi, val, stwa) -#define stxa(va, asi, val) ST_GENERIC(va, asi, val, stxa) - -/* - * Attempt to read from addr, val. If a Data Access Error trap happens, - * they return -1 and the contents of val is undefined. A return of 0 - * means no trap happened, and the contents of val is valid. - */ -int fasword8(u_long asi, void *addr, uint8_t *val); -int fasword16(u_long asi, void *addr, uint16_t *val); -int fasword32(u_long asi, void *addr, uint32_t *val); - -#define membar(mask) do { \ - __asm __volatile("membar %0" : : "n" (mask) : "memory"); \ -} while (0) - -#define rd(name) ({ \ - uint64_t __sr; \ - __asm __volatile("rd %%" #name ", %0" : "=r" (__sr) :); \ - __sr; \ -}) - -#define wr(name, val, xorval) do { \ - __asm __volatile("wr %0, %1, %%" #name \ - : : "r" (val), "rI" (xorval)); \ -} while (0) - -#define rdpr(name) ({ \ - uint64_t __pr; \ - __asm __volatile("rdpr %%" #name", %0" : "=r" (__pr) :); \ - __pr; \ -}) - -#define wrpr(name, val, xorval) do { \ - __asm __volatile("wrpr %0, %1, %%" #name \ - : : "r" (val), "rI" (xorval)); \ -} while (0) - -/* - * Trick GAS/GCC into compiling access to TICK/(S)TICK_COMPARE independently - * of the selected instruction set. - */ -#define rdtickcmpr() rd(asr23) -#define rdstick() rd(asr24) -#define rdstickcmpr() rd(asr25) -#define wrtickcmpr(val, xorval) wr(asr23, (val), (xorval)) -#define wrstick(val, xorval) wr(asr24, (val), (xorval)) -#define wrstickcmpr(val, xorval) wr(asr25, (val), (xorval)) - -/* - * Macro intended to be used instead of wr(asr23, val, xorval) for writing to - * the TICK_COMPARE register in order to avoid a bug in BlackBird CPUs that - * can cause these writes to fail under certain conditions which in turn - * causes the hardclock to stop. The workaround is to read the TICK_COMPARE - * register back immediately after writing to it with these two instructions - * aligned to a quadword boundary in order to ensure that I$ misses won't - * split them up. - */ -#define wrtickcmpr_bbwar(val, xorval) ({ \ - __asm __volatile( \ - " ba,pt %%xcc, 1f ; " \ - " nop ; " \ - " .align 128 ; " \ - "1: wr %0, %1, %%asr23 ; " \ - " rd %%asr23, %%g0 ; " \ - : : "r" (val), "rI" (xorval)); \ -}) - -static __inline void -breakpoint(void) -{ - - __asm __volatile("ta %%xcc, 1" : :); -} - -static __inline register_t -intr_disable(void) -{ - register_t s; - - s = rdpr(pstate); - wrpr(pstate, s & ~PSTATE_IE, 0); - return (s); -} -#define intr_restore(s) wrpr(pstate, (s), 0) - -/* - * In some places, it is required that the store is directly followed by a - * membar #Sync. Don't trust the compiler to not insert instructions in - * between. We also need to disable interrupts completely. - */ -#define stxa_sync(va, asi, val) do { \ - register_t s; \ - s = intr_disable(); \ - __asm __volatile("stxa %0, [%1] %2; membar #Sync" \ - : : "r" (val), "r" (va), "n" (asi)); \ - intr_restore(s); \ -} while (0) - -void ascopy(u_long asi, vm_offset_t src, vm_offset_t dst, size_t len); -void ascopyfrom(u_long sasi, vm_offset_t src, caddr_t dst, size_t len); -void ascopyto(caddr_t src, u_long dasi, vm_offset_t dst, size_t len); -void aszero(u_long asi, vm_offset_t dst, size_t len); - -/* - * Ultrasparc II doesn't implement popc in hardware. - */ -#if 0 -#define HAVE_INLINE_FFS -/* - * See page 202 of the SPARC v9 Architecture Manual. - */ -static __inline int -ffs(int mask) -{ - int result; - int neg; - int tmp; - - __asm __volatile( - " neg %3, %1 ; " - " xnor %3, %1, %2 ; " - " popc %2, %0 ; " - " movrz %3, %%g0, %0 ; " - : "=r" (result), "=r" (neg), "=r" (tmp) : "r" (mask)); - return (result); -} -#endif - -#undef LDNC_GEN -#undef STNC_GEN - -#endif /* !_MACHINE_CPUFUNC_H_ */ diff --git a/sys/sparc64/include/db_machdep.h b/sys/sparc64/include/db_machdep.h deleted file mode 100644 index 73d737c739c4..000000000000 --- a/sys/sparc64/include/db_machdep.h +++ /dev/null @@ -1,64 +0,0 @@ -/*- - * Mach Operating System - * Copyright (c) 1991,1990 Carnegie Mellon University - * All Rights Reserved. - * - * Permission to use, copy, modify and distribute this software and its - * documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" - * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR - * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. - * - * Carnegie Mellon requests users of this software to return to - * - * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU - * School of Computer Science - * Carnegie Mellon University - * Pittsburgh PA 15213-3890 - * - * any improvements or extensions that they make and grant Carnegie Mellon - * the rights to redistribute these changes. - * - * from: FreeBSD: src/sys/i386/include/db_machdep.h,v 1.16 1999/10/04 - * $FreeBSD$ - */ - -#ifndef _MACHINE_DB_MACHDEP_H_ -#define _MACHINE_DB_MACHDEP_H_ - -#include -#include - -typedef vm_offset_t db_addr_t; -typedef long db_expr_t; - -#define PC_REGS() ((db_addr_t)kdb_thrctx->pcb_pc) - -#define BKPT_INST (0x91d03001) -#define BKPT_SIZE (4) -#define BKPT_SET(inst) (BKPT_INST) - -#define BKPT_SKIP do { \ - kdb_frame->tf_tpc = kdb_frame->tf_tnpc + 4; \ - kdb_frame->tf_tnpc += 8; \ -} while (0) - -#define db_clear_single_step kdb_cpu_clear_singlestep -#define db_set_single_step kdb_cpu_set_singlestep - -#define IS_BREAKPOINT_TRAP(type, code) (type == T_BREAKPOINT) -#define IS_WATCHPOINT_TRAP(type, code) (0) - -#define inst_trap_return(ins) (0) -#define inst_return(ins) (0) -#define inst_call(ins) (0) -#define inst_load(ins) (0) -#define inst_store(ins) (0) - -#define DB_ELFSIZE 64 - -#endif /* !_MACHINE_DB_MACHDEP_H_ */ diff --git a/sys/sparc64/include/dcr.h b/sys/sparc64/include/dcr.h deleted file mode 100644 index f6e45d8c4d66..000000000000 --- a/sys/sparc64/include/dcr.h +++ /dev/null @@ -1,72 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD - * - * Copyright (c) 2008 Marius Strobl - * 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$ - */ - -#ifndef _MACHINE_DCR_H_ -#define _MACHINE_DCR_H_ - -/* - * Definitions for the UltraSPARC-III Depatch Control Register (ASR 18). - */ -#define DCR_MS (1UL << 0) -#define DCR_IFPOE (1UL << 1) -#define DCR_SI (1UL << 3) -#define DCR_RPE (1UL << 4) -#define DCR_BPE (1UL << 5) - -#define DCR_OBSDATA_SHIFT 6 -#define DCR_OBSDATA_CT_BITS 8 -#define DCR_OBSDATA_CT_MASK \ - (((1UL << DCR_OBSDATA_CT_BITS) - 1) << DCR_OBSDATA_SHIFT) - -/* The following bits are valid for the UltraSPARC-III++/IV+ only. */ -#define DCR_IPE (1UL << 2) - -#define DCR_OBSDATA_CTP_BITS 6 -#define DCR_OBSDATA_CTP_MASK \ - (((1UL << DCR_OBSDATA_CTP_BITS) - 1) << DCR_OBSDATA_SHIFT) - -#define DCR_DPE (1UL << 12) - -/* The following bits are valid for the UltraSPARC-IV+ only. */ -#define DCR_BPM_SHIFT 13 -#define DCR_BPM_BITS 2 -#define DCR_BPM_MASK \ - (((1UL << DCR_BPM_BITS) - 1) << DCR_BPM_SHIFT) -#define DCR_BPM_1HIST_GSHARE (0UL << DCR_BPM_SHIFT) -#define DCR_BPM_2HIST_GSHARE (1UL << DCR_BPM_SHIFT) -#define DCR_BPM_PC (2UL << DCR_BPM_SHIFT) -#define DCR_BPM_2HIST_MIXED (3UL << DCR_BPM_SHIFT) - -#define DCR_JPE (1UL << 15) -#define DCR_ITPE (1UL << 16) -#define DCR_DTPE (1UL << 17) -#define DCR_PPE (1UL << 18) - -#endif /* _MACHINE_DCR_H_ */ diff --git a/sys/sparc64/include/dump.h b/sys/sparc64/include/dump.h deleted file mode 100644 index f1546603f6cf..000000000000 --- a/sys/sparc64/include/dump.h +++ /dev/null @@ -1,68 +0,0 @@ -/*- - * Copyright (c) 2014 EMC Corp. - * Author: Conrad Meyer - * 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$ - */ - -#ifndef _MACHINE_DUMP_H_ -#define _MACHINE_DUMP_H_ - -#define DUMPSYS_MD_PA_NPAIRS 128 -#define DUMPSYS_NUM_AUX_HDRS 0 -#define KERNELDUMP_ARCH_VERSION KERNELDUMP_SPARC64_VERSION -#define EM_VALUE EM_SPARCV9 - -int dumpsys(struct dumperinfo *); - -static inline struct dump_pa * -dumpsys_pa_next(struct dump_pa *p) -{ - - return (dumpsys_gen_pa_next(p)); -} - -static inline void -dumpsys_wbinv_all(void) -{ - - dumpsys_gen_wbinv_all(); -} - -static inline void -dumpsys_unmap_chunk(vm_paddr_t pa, size_t s, void *va) -{ - - dumpsys_gen_unmap_chunk(pa, s, va); -} - -static inline int -minidumpsys(struct dumperinfo *di) -{ - - return (-ENOSYS); -} - -#endif /* !_MACHINE_DUMP_H_ */ diff --git a/sys/sparc64/include/efi.h b/sys/sparc64/include/efi.h deleted file mode 100644 index 1f7ad0da18af..000000000000 --- a/sys/sparc64/include/efi.h +++ /dev/null @@ -1,14 +0,0 @@ -/*- - * This file is in the public domain since it's just boilerplate. - * - * $FreeBSD$ - */ - -#ifndef __SPARC64_INCLUDE_EFI_H_ -#define __SPARC64_INCLUDE_EFI_H_ - -#define EFIABI_ATTR - -/* Note: we don't actually support this on sparc64 */ - -#endif /* __I386_INCLUDE_EFI_H_ */ diff --git a/sys/sparc64/include/elf.h b/sys/sparc64/include/elf.h deleted file mode 100644 index 4642864cda47..000000000000 --- a/sys/sparc64/include/elf.h +++ /dev/null @@ -1,84 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD - * - * Copyright (c) 1996-1997 John D. Polstra. - * 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$ - */ - -#ifndef _MACHINE_ELF_H_ -#define _MACHINE_ELF_H_ 1 - -/* - * ELF definitions for the sparc64 architecture. - */ - -#include /* Definitions common to all 32 bit architectures. */ -#include /* Definitions common to all 64 bit architectures. */ - -#ifndef __ELF_WORD_SIZE -#define __ELF_WORD_SIZE 64 /* Used by */ -#endif -#include - -#define ELF_ARCH EM_SPARCV9 - -#define ELF_MACHINE_OK(x) ((x) == ELF_ARCH) - -/* - * Auxiliary vector entries for passing information to the interpreter. - */ - -typedef struct { /* Auxiliary vector entry on initial stack */ - int a_type; /* Entry type. */ - union { - int a_val; /* Integer value. */ - } a_un; -} Elf32_Auxinfo; - -typedef struct { /* Auxiliary vector entry on initial stack */ - long a_type; /* Entry type. */ - union { - long a_val; /* Integer value. */ - void *a_ptr; /* Address. */ - void (*a_fcn)(void); /* Function pointer (not used). */ - } a_un; -} Elf64_Auxinfo; - -__ElfType(Auxinfo); - -/* Define "machine" characteristics */ -#if __ELF_WORD_SIZE == 32 -#define ELF_TARG_CLASS ELFCLASS32 -#else -#define ELF_TARG_CLASS ELFCLASS64 -#endif -#define ELF_TARG_DATA ELFDATA2MSB -#define ELF_TARG_MACH ELF_ARCH -#define ELF_TARG_VER 1 - -#define ET_DYN_LOAD_ADDR 0x100000 - -#endif /* !_MACHINE_ELF_H_ */ diff --git a/sys/sparc64/include/endian.h b/sys/sparc64/include/endian.h deleted file mode 100644 index f94a6df29b89..000000000000 --- a/sys/sparc64/include/endian.h +++ /dev/null @@ -1,126 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-3-Clause - * - * Copyright (c) 1987, 1991, 1993 - * The Regents of the University of California. 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. - * 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. - * - * @(#)endian.h 8.1 (Berkeley) 6/10/93 - * $FreeBSD$ - */ - -#ifndef _MACHINE_ENDIAN_H_ -#define _MACHINE_ENDIAN_H_ - -#include -#include - -/* - * Define the order of 32-bit words in 64-bit words. - */ -#define _QUAD_HIGHWORD 0 -#define _QUAD_LOWWORD 1 - -/* - * Definitions for byte order, according to byte significance from low - * address to high. - */ -#define _LITTLE_ENDIAN 1234 /* LSB first: i386, vax */ -#define _BIG_ENDIAN 4321 /* MSB first: 68000, ibm, net */ -#define _PDP_ENDIAN 3412 /* LSB first in word, MSW first in long */ - -#define _BYTE_ORDER _BIG_ENDIAN - -/* - * Deprecated variants that don't have enough underscores to be useful in more - * strict namespaces. - */ -#if __BSD_VISIBLE -#define LITTLE_ENDIAN _LITTLE_ENDIAN -#define BIG_ENDIAN _BIG_ENDIAN -#define PDP_ENDIAN _PDP_ENDIAN -#define BYTE_ORDER _BYTE_ORDER -#endif - -#if defined(__GNUCLIKE_BUILTIN_CONSTANT_P) && defined(__OPTIMIZE__) -#define __is_constant(x) __builtin_constant_p(x) -#else -#define __is_constant(x) 0 -#endif - -#define __bswap16_const(x) ((((__uint16_t)(x) >> 8) & 0xff) | \ - (((__uint16_t)(x) << 8) & 0xff00)) -#define __bswap32_const(x) ((((__uint32_t)(x) >> 24) & 0xff) | \ - (((__uint32_t)(x) >> 8) & 0xff00) | \ - (((__uint32_t)(x)<< 8) & 0xff0000) | \ - (((__uint32_t)(x) << 24) & 0xff000000)) -#define __bswap64_const(x) ((((__uint64_t)(x) >> 56) & 0xff) | \ - (((__uint64_t)(x) >> 40) & 0xff00) | \ - (((__uint64_t)(x) >> 24) & 0xff0000) | \ - (((__uint64_t)(x) >> 8) & 0xff000000) | \ - (((__uint64_t)(x) << 8) & ((__uint64_t)0xff << 32)) | \ - (((__uint64_t)(x) << 24) & ((__uint64_t)0xff << 40)) | \ - (((__uint64_t)(x) << 40) & ((__uint64_t)0xff << 48)) | \ - (((__uint64_t)(x) << 56) & ((__uint64_t)0xff << 56))) - -static __inline __uint16_t -__bswap16_var(__uint16_t _x) -{ - - return ((_x >> 8) | ((_x << 8) & 0xff00)); -} - -static __inline __uint32_t -__bswap32_var(__uint32_t _x) -{ - - return ((_x >> 24) | ((_x >> 8) & 0xff00) | ((_x << 8) & 0xff0000) | - ((_x << 24) & 0xff000000)); -} - -static __inline __uint64_t -__bswap64_var(__uint64_t _x) -{ - - return ((_x >> 56) | ((_x >> 40) & 0xff00) | ((_x >> 24) & 0xff0000) | - ((_x >> 8) & 0xff000000) | ((_x << 8) & ((__uint64_t)0xff << 32)) | - ((_x << 24) & ((__uint64_t)0xff << 40)) | - ((_x << 40) & ((__uint64_t)0xff << 48)) | ((_x << 56))); -} - -#define __bswap16(x) ((__uint16_t)(__is_constant(x) ? __bswap16_const(x) : \ - __bswap16_var(x))) -#define __bswap32(x) (__is_constant(x) ? __bswap32_const(x) : \ - __bswap32_var(x)) -#define __bswap64(x) (__is_constant(x) ? __bswap64_const(x) : \ - __bswap64_var(x)) - -#define __htonl(x) ((__uint32_t)(x)) -#define __htons(x) ((__uint16_t)(x)) -#define __ntohl(x) ((__uint32_t)(x)) -#define __ntohs(x) ((__uint16_t)(x)) - -#endif /* !_MACHINE_ENDIAN_H_ */ diff --git a/sys/sparc64/include/exec.h b/sys/sparc64/include/exec.h deleted file mode 100644 index 68f933f6dd53..000000000000 --- a/sys/sparc64/include/exec.h +++ /dev/null @@ -1,36 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD - * - * Copyright (c) 2001 Jake Burkholder. - * 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$ - */ - -#ifndef _MACHINE_EXEC_H_ -#define _MACHINE_EXEC_H_ - -#define __LDPGSZ 8192 - -#endif /* !_MACHINE_EXEC_H_ */ diff --git a/sys/sparc64/include/fireplane.h b/sys/sparc64/include/fireplane.h deleted file mode 100644 index 5a95b52bc8c9..000000000000 --- a/sys/sparc64/include/fireplane.h +++ /dev/null @@ -1,42 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD - * - * Copyright (c) 2010 Marius Strobl - * 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$ - */ - -#ifndef _MACHINE_FIREPLANE_H_ -#define _MACHINE_FIREPLANE_H_ - -#define FIREPLANE_CR_AID_SHIFT (17) -#define FIREPLANE_CR_AID_SIZE (10) -#define FIREPLANE_CR_AID_MASK \ - (((1 << FIREPLANE_CR_AID_SIZE) - 1) << FIREPLANE_CR_AID_SHIFT) - -#define FIREPLANE_CR_GET_AID(cr) \ - ((cr & FIREPLANE_CR_AID_MASK) >> FIREPLANE_CR_AID_SHIFT) - -#endif /* _MACHINE_FIREPLANE_H_ */ diff --git a/sys/sparc64/include/float.h b/sys/sparc64/include/float.h deleted file mode 100644 index 104fc50fd79e..000000000000 --- a/sys/sparc64/include/float.h +++ /dev/null @@ -1,101 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-3-Clause - * - * Copyright (c) 1992, 1993, 2001 - * 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. - * - * @(#)float.h 8.1 (Berkeley) 6/11/93 - * from: NetBSD: float.h,v 1.3 2001/09/21 20:48:02 eeh Exp - * $FreeBSD$ - */ - -#ifndef _MACHINE_FLOAT_H_ -#define _MACHINE_FLOAT_H_ - -#include - -__BEGIN_DECLS -extern int __flt_rounds(void); -__END_DECLS - -#define FLT_RADIX 2 /* b */ -#define FLT_ROUNDS __flt_rounds() -#if __ISO_C_VISIBLE >= 1999 -#define FLT_EVAL_METHOD 0 /* no promotion */ -#define DECIMAL_DIG 36 /* max precision in decimal digits */ -#endif - -#define FLT_MANT_DIG 24 /* p */ -#define FLT_EPSILON 1.19209290E-7F /* b**(1-p) */ -#define FLT_DIG 6 /* floor((p-1)*log10(b))+(b == 10) */ -#define FLT_MIN_EXP (-125) /* emin */ -#define FLT_MIN 1.17549435E-38F /* b**(emin-1) */ -#define FLT_MIN_10_EXP (-37) /* ceil(log10(b**(emin-1))) */ -#define FLT_MAX_EXP 128 /* emax */ -#define FLT_MAX 3.40282347E+38F /* (1-b**(-p))*b**emax */ -#define FLT_MAX_10_EXP 38 /* floor(log10((1-b**(-p))*b**emax)) */ -#if __ISO_C_VISIBLE >= 2011 -#define FLT_TRUE_MIN 1.40129846E-45F /* b**(emin-p) */ -#define FLT_DECIMAL_DIG 9 /* ceil(1+p*log10(b)) */ -#define FLT_HAS_SUBNORM 1 -#endif /* __ISO_C_VISIBLE >= 2011 */ - -#define DBL_MANT_DIG 53 -#define DBL_EPSILON 2.2204460492503131E-16 -#define DBL_DIG 15 -#define DBL_MIN_EXP (-1021) -#define DBL_MIN 2.2250738585072014E-308 -#define DBL_MIN_10_EXP (-307) -#define DBL_MAX_EXP 1024 -#define DBL_MAX 1.7976931348623157E+308 -#define DBL_MAX_10_EXP 308 -#if __ISO_C_VISIBLE >= 2011 -#define DBL_TRUE_MIN 4.9406564584124654E-324 -#define DBL_DECIMAL_DIG 17 -#define DBL_HAS_SUBNORM 1 -#endif /* __ISO_C_VISIBLE >= 2011 */ - -#define LDBL_MANT_DIG 113 -#define LDBL_EPSILON 1.925929944387235853055977942584927319E-34L -#define LDBL_DIG 33 -#define LDBL_MIN_EXP (-16381) -#define LDBL_MIN 3.362103143112093506262677817321752603E-4932L -#define LDBL_MIN_10_EXP (-4931) -#define LDBL_MAX_EXP (+16384) -#define LDBL_MAX 1.189731495357231765085759326628007016E+4932L -#define LDBL_MAX_10_EXP (+4932) -#if __ISO_C_VISIBLE >= 2011 -#define LDBL_TRUE_MIN 6.475175119438025110924438958227646552E-4966L -#define LDBL_DECIMAL_DIG 36 -#define LDBL_HAS_SUBNORM 1 -#endif /* __ISO_C_VISIBLE >= 2011 */ - -#endif /* _MACHINE_FLOAT_H_ */ diff --git a/sys/sparc64/include/floatingpoint.h b/sys/sparc64/include/floatingpoint.h deleted file mode 100644 index d91efcebeefd..000000000000 --- a/sys/sparc64/include/floatingpoint.h +++ /dev/null @@ -1,39 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-3-Clause - * - * Copyright (c) 2002 David O'Brien . - * 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. - * 3. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY DAVID O'BRIEN 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. - * - * $FreeBSD$ - */ - -#ifndef _FLOATINGPOINT_H_ -#define _FLOATINGPOINT_H_ - -#include - -#endif /* !_FLOATINGPOINT_H_ */ diff --git a/sys/sparc64/include/fp.h b/sys/sparc64/include/fp.h deleted file mode 100644 index 67e0932880f1..000000000000 --- a/sys/sparc64/include/fp.h +++ /dev/null @@ -1,41 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD - * - * Copyright 2001 by Thomas Moestl . 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 ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE - * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $FreeBSD$ - */ - -#ifndef _MACHINE_FP_H_ -#define _MACHINE_FP_H_ - -#ifdef _KERNEL - -/* - * Note: The pointer passed to savefpctx must be aligned on a 64 byte - * boundary. - */ -void savefpctx(uint32_t *fp); - -#endif /* _KERNEL */ -#endif /* !_MACHINE_FP_H_ */ diff --git a/sys/sparc64/include/frame.h b/sys/sparc64/include/frame.h deleted file mode 100644 index 3bb28298ad80..000000000000 --- a/sys/sparc64/include/frame.h +++ /dev/null @@ -1,95 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD - * - * Copyright (c) 2001 Jake Burkholder. - * 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$ - */ - -#ifndef _MACHINE_FRAME_H_ -#define _MACHINE_FRAME_H_ - -#define RW_SHIFT 7 -#define SPOFF 2047 -#define BIAS SPOFF /* XXX - open/netbsd compat */ - -#ifndef LOCORE - -/* - * NOTE: keep this structure in sync with struct reg and struct mcontext. - */ -struct trapframe { - uint64_t tf_global[8]; - uint64_t tf_out[8]; - uint64_t tf_fprs; - uint64_t tf_fsr; - uint64_t tf_gsr; - uint64_t tf_level; - uint64_t tf_pil; - uint64_t tf_sfar; - uint64_t tf_sfsr; - uint64_t tf_tar; - uint64_t tf_tnpc; - uint64_t tf_tpc; - uint64_t tf_tstate; - uint64_t tf_type; - uint64_t tf_y; - uint64_t tf_wstate; - uint64_t tf_pad[2]; -}; -#define tf_sp tf_out[6] - -#define TF_DONE(tf) do { \ - tf->tf_tpc = tf->tf_tnpc; \ - tf->tf_tnpc += 4; \ -} while (0) - -struct frame { - u_long fr_local[8]; - u_long fr_in[8]; - u_long fr_pad[8]; -}; -#define fr_arg fr_in -#define fr_fp fr_in[6] -#define fr_pc fr_in[7] - -#define v9next_frame(fp) ((struct frame *)(fp->fr_fp + BIAS)) - -/* - * Frame used for pcb_rw. - */ -struct rwindow { - u_long rw_local[8]; - u_long rw_in[8]; -}; - -struct thread; - -int rwindow_save(struct thread *td); -int rwindow_load(struct thread *td, struct trapframe *tf, int n); - -#endif /* !LOCORE */ - -#endif /* !_MACHINE_FRAME_H_ */ diff --git a/sys/sparc64/include/fsr.h b/sys/sparc64/include/fsr.h deleted file mode 100644 index ec8c17d91a7a..000000000000 --- a/sys/sparc64/include/fsr.h +++ /dev/null @@ -1,116 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD - * - * Copyright 2001 by Thomas Moestl . 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 ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE - * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $FreeBSD$ - */ - -#ifndef _MACHINE_FSR_H_ -#define _MACHINE_FSR_H_ - -#define FPRS_DL (1 << 0) -#define FPRS_DU (1 << 1) -#define FPRS_FEF (1 << 2) - -#define VIS_BLOCKSIZE 64 - -#ifndef LOCORE - -#define FSR_EXC_BITS 5 -#define FSR_EXC_MASK ((1UL << FSR_EXC_BITS) - 1) -#define FSR_CEXC_SHIFT 0 -#define FSR_CEXC_MASK (FSR_EXC_MASK << FSR_CEXC_SHIFT) -#define FSR_CEXC(b) ((unsigned long)(b) << FSR_CEXC_SHIFT) -#define FSR_GET_CEXC(x) (((x) & FSR_CEXC_MASK) >> FSR_CEXC_SHIFT) -#define FSR_AEXC_SHIFT 5 -#define FSR_AEXC_MASK (FSR_EXC_MASK << FSR_AEXC_SHIFT) -#define FSR_AEXC(b) ((unsigned long)(b) << FSR_AEXC_SHIFT) -#define FSR_GET_AEXC(x) (((x) & FSR_AEXC_MASK) >> FSR_AEXC_SHIFT) -#define FSR_QNE (1UL << 13) -#define FSR_NS (1UL << 22) -#define FSR_TEM_SHIFT 23 -#define FSR_TEM_MASK (FSR_EXC_MASK << FSR_TEM_SHIFT) -#define FSR_TEM(b) ((unsigned long)(b) << FSR_TEM_SHIFT) -#define FSR_GET_TEM(x) (((x) & FSR_TEM_MASK) >> FSR_TEM_SHIFT) -#define FSR_FCC0_SHIFT 10 -#define FSR_FCC0_BITS 2 -#define FSR_FCC0_MASK (((1UL << FSR_FCC0_BITS) - 1) << FSR_FCC0_SHIFT) -#define FSR_FCC0(x) ((unsigned long)(x) << FSR_FCC0_SHIFT) -#define FSR_GET_FCC0(x) (((x) & FSR_FCC0_MASK) >> FSR_FCC0_SHIFT) -#define FSR_FTT_SHIFT 14 -#define FSR_FTT_BITS 3 -#define FSR_FTT_MASK (((1UL << FSR_FTT_BITS) - 1) << FSR_FTT_SHIFT) -#define FSR_FTT(x) ((unsigned long)(x) << FSR_FTT_SHIFT) -#define FSR_GET_FTT(x) (((x) & FSR_FTT_MASK) >> FSR_FTT_SHIFT) -#define FSR_VER_SHIFT 17 -#define FSR_GET_VER(x) (((x) >> FSR_VER_SHIFT) & 7) -#define FSR_RD_SHIFT 30 -#define FSR_RD_BITS 2 -#define FSR_RD_MASK (((1UL << FSR_RD_BITS) - 1) << FSR_RD_SHIFT) -#define FSR_RD(x) ((unsigned long)(x) << FSR_RD_SHIFT) -#define FSR_GET_RD(x) (((x) & FSR_RD_MASK) >> FSR_RD_SHIFT) -#define FSR_FCC1_SHIFT 32 -#define FSR_FCC1_BITS 2 -#define FSR_FCC1_MASK (((1UL << FSR_FCC1_BITS) - 1) << FSR_FCC1_SHIFT) -#define FSR_FCC1(x) ((unsigned long)(x) << FSR_FCC1_SHIFT) -#define FSR_GET_FCC1(x) (((x) & FSR_FCC1_MASK) >> FSR_FCC1_SHIFT) -#define FSR_FCC2_SHIFT 34 -#define FSR_FCC2_BITS 2 -#define FSR_FCC2_MASK (((1UL << FSR_FCC2_BITS) - 1) << FSR_FCC2_SHIFT) -#define FSR_FCC2(x) ((unsigned long)(x) << FSR_FCC2_SHIFT) -#define FSR_GET_FCC2(x) (((x) & FSR_FCC2_MASK) >> FSR_FCC2_SHIFT) -#define FSR_FCC3_SHIFT 36 -#define FSR_FCC3_BITS 2 -#define FSR_FCC3_MASK (((1UL << FSR_FCC3_BITS) - 1) << FSR_FCC3_SHIFT) -#define FSR_FCC3(x) ((unsigned long)(x) << FSR_FCC3_SHIFT) -#define FSR_GET_FCC3(x) (((x) & FSR_FCC3_MASK) >> FSR_FCC3_SHIFT) - -/* CEXC/AEXC/TEM exception values */ -#define FSR_NX (1 << 0) -#define FSR_DZ (1 << 1) -#define FSR_UF (1 << 2) -#define FSR_OF (1 << 3) -#define FSR_NV (1 << 4) -/* FTT values. */ -#define FSR_FTT_NONE 0 -#define FSR_FTT_IEEE 1 -#define FSR_FTT_UNFIN 2 -#define FSR_FTT_UNIMP 3 -#define FSR_FTT_SEQERR 4 -#define FSR_FTT_HWERR 5 -#define FSR_FTT_INVREG 6 -/* RD values */ -#define FSR_RD_N 0 /* nearest */ -#define FSR_RD_Z 1 /* zero */ -#define FSR_RD_PINF 2 /* +infinity */ -#define FSR_RD_NINF 3 /* -infinity */ -/* condition codes */ -#define FSR_CC_EQ 0 /* a = b */ -#define FSR_CC_LT 1 /* a < b */ -#define FSR_CC_GT 2 /* a > b */ -#define FSR_CC_UO 3 /* unordered */ - -#endif /* !LOCORE */ - -#endif /* !_MACHINE_FSR_H_ */ diff --git a/sys/sparc64/include/gdb_machdep.h b/sys/sparc64/include/gdb_machdep.h deleted file mode 100644 index 502d0c2e347b..000000000000 --- a/sys/sparc64/include/gdb_machdep.h +++ /dev/null @@ -1,72 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD - * - * Copyright (c) 2004 Marcel Moolenaar - * 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 ``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 BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $FreeBSD$ - */ - -#ifndef _MACHINE_GDB_MACHDEP_H_ -#define _MACHINE_GDB_MACHDEP_H_ - -#define GDB_BUFSZ 600 -#define GDB_NREGS 86 -#define GDB_REG_PC 80 - -static __inline size_t -gdb_cpu_regsz(int regnum) -{ - return ((regnum >= 32 && regnum < 64) ? sizeof(float) : sizeof(long)); -} - -static __inline int -gdb_cpu_query(void) -{ - return (0); -} - -static __inline int -gdb_cpu_signal(int vector, int _) -{ - return (vector); -} - -static __inline void * -gdb_begin_write(void) -{ - - return (NULL); -} - -static __inline void -gdb_end_write(void *arg __unused) -{ - -} - -void *gdb_cpu_getreg(int, size_t *); -void gdb_cpu_setreg(int, void *); - -#endif /* !_MACHINE_GDB_MACHDEP_H_ */ diff --git a/sys/sparc64/include/idprom.h b/sys/sparc64/include/idprom.h deleted file mode 100644 index 442b6b32bbff..000000000000 --- a/sys/sparc64/include/idprom.h +++ /dev/null @@ -1,64 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause-NetBSD - * - * Copyright (c) 1996 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Adam Glass. - * - * 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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. - * - * from: NetBSD: idprom.h,v 1.3 2008/04/28 20:23:58 martin Exp - * - * $FreeBSD$ - */ - -#ifndef _MACHINE_IDPROM_H_ -#define _MACHINE_IDPROM_H_ - -/* - * ID prom format. The ``host id'' is set up by taking the machine - * ID as the top byte and the hostid field as the remaining three. - * The id_xxx0 field appears to contain some other number. The id_xxx1 - * contains a bunch of 00's and a5's on my machines, suggesting it is - * not actually used. The checksum seems to include them, however. - */ -struct idprom { - u_char id_format; /* format identifier (= 1) */ - u_char id_machine; /* machine type (see param.h) */ - u_char id_ether[6]; /* ethernet address */ - int id_date; /* date of manufacture */ - u_char id_hostid[3]; /* ``host id'' bytes */ - u_char id_checksum; /* xor of everything else */ - /* Note: The rest is excluded from the checksum! */ - char id_undef[16]; /* undefined */ -}; - -#define ID_SUN4_100 0x22 /* Sun 4/100 */ -#define ID_SUN4_200 0x21 /* Sun 4/200 */ -#define ID_SUN4_300 0x23 /* Sun 4/300 */ -#define ID_SUN4_400 0x24 /* Sun 4/400 */ - -#define IDPROM_VERSION 1 - -#endif /* !_MACHINE_IDPROM_H_ */ diff --git a/sys/sparc64/include/ieee.h b/sys/sparc64/include/ieee.h deleted file mode 100644 index 773af1356cc6..000000000000 --- a/sys/sparc64/include/ieee.h +++ /dev/null @@ -1,139 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-3-Clause - * - * 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. - * - * @(#)ieee.h 8.1 (Berkeley) 6/11/93 - * from: NetBSD: ieee.h,v 1.1.1.1 1998/06/20 04:58:51 eeh Exp - * $FreeBSD$ - */ - -#ifndef _MACHINE_IEEE_H_ -#define _MACHINE_IEEE_H_ - -/* - * ieee.h defines the machine-dependent layout of the machine's IEEE - * floating point. It does *not* define (yet?) any of the rounding - * mode bits, exceptions, and so forth. - */ - -/* - * Define the number of bits in each fraction and exponent. - * - * k k+1 - * Note that 1.0 x 2 == 0.1 x 2 and that denorms are represented - * - * (-exp_bias+1) - * as fractions that look like 0.fffff x 2 . This means that - * - * -126 - * the number 0.10000 x 2 , for instance, is the same as the normalized - * - * -127 -128 - * float 1.0 x 2 . Thus, to represent 2 , we need one leading zero - * - * -129 - * in the fraction; to represent 2 , we need two, and so on. This - * - * (-exp_bias-fracbits+1) - * implies that the smallest denormalized number is 2 - * - * for whichever format we are talking about: for single precision, for - * - * -126 -149 - * instance, we get .00000000000000000000001 x 2 , or 1.0 x 2 , and - * - * -149 == -127 - 23 + 1. - */ -#define SNG_EXPBITS 8 -#define SNG_FRACBITS 23 - -#define DBL_EXPBITS 11 -#define DBL_FRACBITS 52 - -#ifdef notyet -#define E80_EXPBITS 15 -#define E80_FRACBITS 64 -#endif - -#define EXT_EXPBITS 15 -#define EXT_FRACBITS 112 - -struct ieee_single { - u_int sng_sign:1; - u_int sng_exp:8; - u_int sng_frac:23; -}; - -struct ieee_double { - u_int dbl_sign:1; - u_int dbl_exp:11; - u_int dbl_frach:20; - u_int dbl_fracl; -}; - -struct ieee_ext { - u_int ext_sign:1; - u_int ext_exp:15; - u_int ext_frach:16; - u_int ext_frachm; - u_int ext_fraclm; - u_int ext_fracl; -}; - -/* - * Floats whose exponent is in [1..INFNAN) (of whatever type) are - * `normal'. Floats whose exponent is INFNAN are either Inf or NaN. - * Floats whose exponent is zero are either zero (iff all fraction - * bits are zero) or subnormal values. - * - * A NaN is a `signalling NaN' if its QUIETNAN bit is clear in its - * high fraction; if the bit is set, it is a `quiet NaN'. - */ -#define SNG_EXP_INFNAN 255 -#define DBL_EXP_INFNAN 2047 -#define EXT_EXP_INFNAN 32767 - -#if 0 -#define SNG_QUIETNAN (1 << 22) -#define DBL_QUIETNAN (1 << 19) -#define EXT_QUIETNAN (1 << 15) -#endif - -/* - * Exponent biases. - */ -#define SNG_EXP_BIAS 127 -#define DBL_EXP_BIAS 1023 -#define EXT_EXP_BIAS 16383 - -#endif diff --git a/sys/sparc64/include/ieeefp.h b/sys/sparc64/include/ieeefp.h deleted file mode 100644 index bb0773730aa0..000000000000 --- a/sys/sparc64/include/ieeefp.h +++ /dev/null @@ -1,37 +0,0 @@ -/*- - * Written by J.T. Conklin, Apr 6, 1995 - * Public domain. - * $FreeBSD$ - */ - -#ifndef _MACHINE_IEEEFP_H_ -#define _MACHINE_IEEEFP_H_ - -/* Deprecated FPU control interface */ - -#include - -typedef int fp_except_t; -#define FP_X_IMP FSR_NX /* imprecise (loss of precision) */ -#define FP_X_DZ FSR_DZ /* divide-by-zero exception */ -#define FP_X_UFL FSR_UF /* underflow exception */ -#define FP_X_OFL FSR_OF /* overflow exception */ -#define FP_X_INV FSR_NV /* invalid operation exception */ - -typedef enum { - FP_RN = FSR_RD_N, /* round to nearest representable number */ - FP_RZ = FSR_RD_Z, /* round to zero (truncate) */ - FP_RP = FSR_RD_PINF, /* round toward positive infinity */ - FP_RM = FSR_RD_NINF /* round toward negative infinity */ -} fp_rnd_t; - -__BEGIN_DECLS -extern fp_rnd_t fpgetround(void); -extern fp_rnd_t fpsetround(fp_rnd_t); -extern fp_except_t fpgetmask(void); -extern fp_except_t fpsetmask(fp_except_t); -extern fp_except_t fpgetsticky(void); -__END_DECLS - - -#endif /* _MACHINE_IEEEFP_H_ */ diff --git a/sys/sparc64/include/in_cksum.h b/sys/sparc64/include/in_cksum.h deleted file mode 100644 index 6f80d6996759..000000000000 --- a/sys/sparc64/include/in_cksum.h +++ /dev/null @@ -1,177 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-3-Clause - * - * Copyright (c) 1990 The Regents of the University of California. - * 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. - * 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. - */ -/*- - * Copyright (c) 2001 by Thomas Moestl . - * 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 ``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. - * - * from tahoe: in_cksum.c 1.2 86/01/05 - * from: @(#)in_cksum.c 1.3 (Berkeley) 1/19/91 - * from: Id: in_cksum.c,v 1.8 1995/12/03 18:35:19 bde Exp - * from: FreeBSD: src/sys/alpha/include/in_cksum.h,v 1.5 2000/05/06 - * - * $FreeBSD$ - */ - -#ifndef _MACHINE_IN_CKSUM_H_ -#define _MACHINE_IN_CKSUM_H_ 1 - -#include - -#define in_cksum(m, len) in_cksum_skip(m, len, 0) - -#if defined(IPVERSION) && (IPVERSION == 4) -static __inline void -in_cksum_update(struct ip *ip) -{ - int __tmp; - - __tmp = (int)ip->ip_sum + 1; - ip->ip_sum = __tmp + (__tmp >> 16); -} -#endif - -static __inline u_short -in_addword(u_short sum, u_short b) -{ - u_long __ret, __tmp; - - __asm( - "sll %2, 16, %0\n" - "sll %3, 16, %1\n" - "addcc %0, %1, %0\n" - "srl %0, 16, %0\n" - "addc %0, 0, %0\n" - : "=&r" (__ret), "=&r" (__tmp) : "r" (sum), "r" (b) : "cc"); - return (__ret); -} - -static __inline u_short -in_pseudo(u_int sum, u_int b, u_int c) -{ - u_long __tmp; - - __asm( - "addcc %0, %3, %0\n" - "addccc %0, %4, %0\n" - "addc %0, 0, %0\n" - "sll %0, 16, %1\n" - "addcc %0, %1, %0\n" - "srl %0, 16, %0\n" - "addc %0, 0, %0\n" - : "=r" (sum), "=&r" (__tmp) : "0" (sum), "r" (b), "r" (c) : "cc"); - return (sum); -} - -#if defined(IPVERSION) && (IPVERSION == 4) -static __inline u_int -in_cksum_hdr(struct ip *ip) -{ - u_long __ret, __tmp1, __tmp2, __tmp3, __tmp4; - - /* - * Use 32-bit memory accesses and additions - addition with carry only - * works for 32 bits, and fixing up alignment issues for 64 is probably - * more trouble than it's worth. - * This may read outside of the ip header, but does not cross a page - * boundary in doing so, so that should be OK. - * Actually, this specialized implementation might be overkill - using - * a generic implementation for both in_cksum_skip and in_cksum_hdr - * should not be too much more expensive. - */ -#define __LD_ADD(addr, tmp, sum, offs, mod) \ - "lduw [" #addr " + " #offs "], " #tmp "\n" \ - "add" # mod " " #sum ", " #tmp ", " #sum "\n" - - __asm( - "and %5, 3, %3\n" - "andn %5, 3, %1\n" - "brz,pt %3, 0f\n" - " lduw [%1], %0\n" - "mov 4, %4\n" - "sub %4, %3, %4\n" - "sll %4, 3, %4\n" /* fix up unaligned buffers */ - "mov 1, %2\n" - "sll %2, %4, %4\n" - "sub %4, 1, %4\n" - "lduw [%1 + 20], %2\n" - "andn %2, %4, %2\n" - "and %0, %4, %0\n" - "or %0, %2, %0\n" - "0:\n" - __LD_ADD(%1, %2, %0, 4, cc) - __LD_ADD(%1, %2, %0, 8, ccc) - __LD_ADD(%1, %2, %0, 12, ccc) - __LD_ADD(%1, %2, %0, 16, ccc) - "addc %0, 0, %0\n" /* reduce */ - "1:\n" - "sll %0, 16, %2\n" - "addcc %0, %2, %0\n" - "srl %0, 16, %0\n" - "addc %0, 0, %0\n" - "andcc %3, 1, %3\n" /* need to byte-swap? */ - "clr %3\n" - "bne,a,pn %%xcc, 1b\n" - " sll %0, 8, %0\n" - "not %0\n" - "sll %0, 16, %0\n" - "srl %0, 16, %0\n" - : "=&r" (__ret), "=r" (__tmp1), "=&r" (__tmp2), "=&r" (__tmp3), - "=&r" (__tmp4) : "1" (ip) : "cc"); -#undef __LD_ADD - return (__ret); -} -#endif - -#ifdef _KERNEL -u_short in_cksum_skip(struct mbuf *m, int len, int skip); -#endif - -#endif /* _MACHINE_IN_CKSUM_H_ */ diff --git a/sys/sparc64/include/instr.h b/sys/sparc64/include/instr.h deleted file mode 100644 index 54d2a806d93a..000000000000 --- a/sys/sparc64/include/instr.h +++ /dev/null @@ -1,620 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-4-Clause - * - * Copyright (c) 1994 David S. Miller, davem@nadzieja.rutgers.edu - * Copyright (c) 1995 Paul Kranenburg - * Copyright (c) 2001 Thomas Moestl - * 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. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by David Miller. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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. - * - * from: NetBSD: db_disasm.c,v 1.9 2000/08/16 11:29:42 pk Exp - * - * $FreeBSD$ - */ - -#ifndef _MACHINE_INSTR_H_ -#define _MACHINE_INSTR_H_ - -/* - * Definitions for all instruction formats - */ -#define IF_OP_SHIFT 30 -#define IF_OP_BITS 2 -#define IF_IMM_SHIFT 0 /* Immediate/Displacement */ - -/* - * Definitions for format 2 - */ -#define IF_F2_RD_SHIFT 25 -#define IF_F2_RD_BITS 5 -#define IF_F2_A_SHIFT 29 -#define IF_F2_A_BITS 1 -#define IF_F2_COND_SHIFT 25 -#define IF_F2_COND_BITS 4 -#define IF_F2_RCOND_SHIFT 25 -#define IF_F2_RCOND_BITS 3 -#define IF_F2_OP2_SHIFT 22 -#define IF_F2_OP2_BITS 3 -#define IF_F2_CC1_SHIFT 21 -#define IF_F2_CC1_BITS 1 -#define IF_F2_CC0_SHIFT 20 -#define IF_F2_CC0_BITS 1 -#define IF_F2_CC_SHIFT 20 /* CC0 and CC1 combined. */ -#define IF_F2_CC_BITS 2 -#define IF_F2_D16HI_SHIFT 20 -#define IF_F2_D16HI_BITS 2 -#define IF_F2_P_SHIFT 19 -#define IF_F2_P_BITS 1 -#define IF_F2_RS1_SHIFT 14 -#define IF_F2_RS1_BITS 5 - -/* - * Definitions for format 3 - */ -#define IF_F3_OP3_SHIFT 19 -#define IF_F3_OP3_BITS 6 -#define IF_F3_RD_SHIFT IF_F2_RD_SHIFT -#define IF_F3_RD_BITS IF_F2_RD_BITS -#define IF_F3_FCN_SHIFT 25 -#define IF_F3_FCN_BITS 5 -#define IF_F3_CC1_SHIFT 26 -#define IF_F3_CC1_BITS 1 -#define IF_F3_CC0_SHIFT 25 -#define IF_F3_CC0_BITS 1 -#define IF_F3_CC_SHIFT 25 /* CC0 and CC1 combined. */ -#define IF_F3_CC_BITS 2 -#define IF_F3_RS1_SHIFT IF_F2_RS1_SHIFT -#define IF_F3_RS1_BITS IF_F2_RS1_BITS -#define IF_F3_I_SHIFT 13 -#define IF_F3_I_BITS 1 -#define IF_F3_X_SHIFT 12 -#define IF_F3_X_BITS 1 -#define IF_F3_RCOND_SHIFT 10 -#define IF_F3_RCOND_BITS 3 -#define IF_F3_IMM_ASI_SHIFT 5 -#define IF_F3_IMM_ASI_BITS 8 -#define IF_F3_OPF_SHIFT 5 -#define IF_F3_OPF_BITS 9 -#define IF_F3_CMASK_SHIFT 4 -#define IF_F3_CMASK_BITS 3 -#define IF_F3_RS2_SHIFT 0 -#define IF_F3_RS2_BITS 5 -#define IF_F3_SHCNT32_SHIFT 0 -#define IF_F3_SHCNT32_BITS 5 -#define IF_F3_SHCNT64_SHIFT 0 -#define IF_F3_SHCNT64_BITS 6 - -/* - * Definitions for format 4 - */ -#define IF_F4_OP3_SHIFT IF_F3_OP3_SHIFT -#define IF_F4_OP3_BITS IF_F3_OP3_BITS -#define IF_F4_RD_SHIFT IF_F2_RD_SHIFT -#define IF_F4_RD_BITS IF_F2_RD_BITS -#define IF_F4_RS1_SHIFT IF_F2_RS1_SHIFT -#define IF_F4_RS1_BITS IF_F2_RS1_BITS -#define IF_F4_TCOND_SHIFT IF_F2_COND_SHIFT /* cond for Tcc */ -#define IF_F4_TCOND_BITS IF_F2_COND_BITS -#define IF_F4_CC2_SHIFT 18 -#define IF_F4_CC2_BITS 1 -#define IF_F4_COND_SHIFT 14 -#define IF_F4_COND_BITS 4 -#define IF_F4_I_SHIFT IF_F3_I_SHIFT -#define IF_F4_I_BITS IF_F3_I_BITS -#define IF_F4_OPF_CC_SHIFT 11 -#define IF_F4_OPF_CC_BITS 3 -#define IF_F4_CC1_SHIFT 12 -#define IF_F4_CC1_BITS 1 -#define IF_F4_CC0_SHIFT 11 -#define IF_F4_CC0_BITS 1 -#define IF_F4_RCOND_SHIFT IF_F3_RCOND_SHIFT -#define IF_F4_RCOND_BITS IF_F3_RCOND_BITS -#define IF_F4_OPF_LOW_SHIFT 5 -#define IF_F4_RS2_SHIFT IF_F3_RS2_SHIFT -#define IF_F4_RS2_BITS IF_F3_RS2_BITS -#define IF_F4_SW_TRAP_SHIFT 0 -#define IF_F4_SW_TRAP_BITS 7 - -/* - * Macros to decode instructions - */ -/* Extract a field */ -#define IF_MASK(s, w) (((1 << (w)) - 1) << (s)) -#define IF_EXTRACT(x, s, w) (((x) & IF_MASK((s), (w))) >> (s)) -#define IF_DECODE(x, f) \ - IF_EXTRACT((x), IF_ ## f ## _SHIFT, IF_ ## f ## _BITS) - -/* Sign-extend a field of width W */ -#define IF_SEXT(x, w) \ - (((x) & (1L << ((w) - 1))) != 0 ? \ - (-1L - ((x) ^ ((1L << (w)) - 1))) : (x)) - -#if 0 -/* - * The following C variant is from db_disassemble.c, and surely faster, but it - * relies on behaviour that is undefined by the C standard (>> in conjunction - * with signed negative arguments). - */ -#define IF_SEXT(v, w) ((((long long)(v)) << (64 - w)) >> (64 - w)) -/* Assembler version of the above */ -#define IF_SEXT(v, w) \ - { u_long t; ( __asm __volatile("sllx %1, %2, %0; srax %0, %2, %0" : - "=r" (t) : "r" (v) : "i" (64 - w)); t)} -#endif - -/* All instruction formats */ -#define IF_OP(i) IF_DECODE(i, OP) - -/* Instruction format 2 */ -#define IF_F2_RD(i) IF_DECODE((i), F2_RD) -#define IF_F2_A(i) IF_DECODE((i), F2_A) -#define IF_F2_COND(i) IF_DECODE((i), F2_COND) -#define IF_F2_RCOND(i) IF_DECODE((i), F2_RCOND) -#define IF_F2_OP2(i) IF_DECODE((i), F2_OP2) -#define IF_F2_CC1(i) IF_DECODE((i), F2_CC1) -#define IF_F2_CC0(i) IF_DECODE((i), F2_CC0) -#define IF_F2_CC(i) IF_DECODE((i), F2_CC) -#define IF_F2_D16HI(i) IF_DECODE((i), F2_D16HI) -#define IF_F2_P(i) IF_DECODE((i), F2_P) -#define IF_F2_RS1(i) IF_DECODE((i), F2_RS1) - -/* Instruction format 3 */ -#define IF_F3_OP3(i) IF_DECODE((i), F3_OP3) -#define IF_F3_RD(i) IF_F2_RD((i)) -#define IF_F3_FCN(i) IF_DECODE((i), F3_FCN) -#define IF_F3_CC1(i) IF_DECODE((i), F3_CC1) -#define IF_F3_CC0(i) IF_DECODE((i), F3_CC0) -#define IF_F3_CC(i) IF_DECODE((i), F3_CC) -#define IF_F3_RS1(i) IF_F2_RS1((i)) -#define IF_F3_I(i) IF_DECODE((i), F3_I) -#define IF_F3_X(i) IF_DECODE((i), F3_X) -#define IF_F3_RCOND(i) IF_DECODE((i), F3_RCOND) -#define IF_F3_IMM_ASI(i) IF_DECODE((i), F3_IMM_ASI) -#define IF_F3_OPF(i) IF_DECODE((i), F3_OPF) -#define IF_F3_CMASK(i) IF_DECODE((i), F3_CMASK) -#define IF_F3_RS2(i) IF_DECODE((i), F3_RS2) -#define IF_F3_SHCNT32(i) IF_DECODE((i), F3_SHCNT32) -#define IF_F3_SHCNT64(i) IF_DECODE((i), F3_SHCNT64) - -/* Instruction format 4 */ -#define IF_F4_OP3(i) IF_F3_OP3((i)) -#define IF_F4_RD(i) IF_F3_RD((i)) -#define IF_F4_TCOND(i) IF_DECODE((i), F4_TCOND) -#define IF_F4_RS1(i) IF_F3_RS1((i)) -#define IF_F4_CC2(i) IF_DECODE((i), F4_CC2) -#define IF_F4_COND(i) IF_DECODE((i), F4_COND) -#define IF_F4_I(i) IF_F3_I((i)) -#define IF_F4_OPF_CC(i) IF_DECODE((i), F4_OPF_CC) -#define IF_F4_RCOND(i) IF_F3_RCOND((i)) -#define IF_F4_OPF_LOW(i, w) IF_EXTRACT((i), IF_F4_OPF_LOW_SHIFT, (w)) -#define IF_F4_RS2(i) IF_F3_RS2((i)) -#define IF_F4_SW_TRAP(i) IF_DECODE((i), F4_SW_TRAP) - -/* Extract an immediate from an instruction, with an without sign extension */ -#define IF_IMM(i, w) IF_EXTRACT((i), IF_IMM_SHIFT, (w)) -#define IF_SIMM(i, w) ({ u_long b = (w), x = IF_IMM((i), b); IF_SEXT((x), b); }) - -/* - * Macros to encode instructions - */ -#define IF_INSERT(x, s, w) (((x) & ((1 << (w)) - 1)) << (s)) -#define IF_ENCODE(x, f) \ - IF_INSERT((x), IF_ ## f ## _SHIFT, IF_ ## f ## _BITS) - -/* All instruction formats */ -#define EIF_OP(x) IF_ENCODE((x), OP) - -/* Instruction format 2 */ -#define EIF_F2_RD(x) IF_ENCODE((x), F2_RD) -#define EIF_F2_A(x) IF_ENCODE((x), F2_A) -#define EIF_F2_COND(x) IF_ENCODE((x), F2_COND) -#define EIF_F2_RCOND(x) IF_ENCODE((x), F2_RCOND) -#define EIF_F2_OP2(x) IF_ENCODE((x), F2_OP2) -#define EIF_F2_CC1(x) IF_ENCODE((x), F2_CC1) -#define EIF_F2_CC0(x) IF_ENCODE((x), F2_CC0) -#define EIF_F2_D16HI(x) IF_ENCODE((x), F2_D16HI) -#define EIF_F2_P(x) IF_ENCODE((x), F2_P) -#define EIF_F2_RS1(x) IF_ENCODE((x), F2_RS1) - -/* Instruction format 3 */ -#define EIF_F3_OP3(x) IF_ENCODE((x), F3_OP3) -#define EIF_F3_RD(x) EIF_F2_RD((x)) -#define EIF_F3_FCN(x) IF_ENCODE((x), F3_FCN) -#define EIF_F3_CC1(x) IF_ENCODE((x), F3_CC1) -#define EIF_F3_CC0(x) IF_ENCODE((x), F3_CC0) -#define EIF_F3_RS1(x) EIF_F2_RS1((x)) -#define EIF_F3_I(x) IF_ENCODE((x), F3_I) -#define EIF_F3_X(x) IF_ENCODE((x), F3_X) -#define EIF_F3_RCOND(x) IF_ENCODE((x), F3_RCOND) -#define EIF_F3_IMM_ASI(x) IF_ENCODE((x), F3_IMM_ASI) -#define EIF_F3_OPF(x) IF_ENCODE((x), F3_OPF) -#define EIF_F3_CMASK(x) IF_ENCODE((x), F3_CMASK) -#define EIF_F3_RS2(x) IF_ENCODE((x), F3_RS2) -#define EIF_F3_SHCNT32(x) IF_ENCODE((x), F3_SHCNT32) -#define EIF_F3_SHCNT64(x) IF_ENCODE((x), F3_SHCNT64) - -/* Instruction format 4 */ -#define EIF_F4_OP3(x) EIF_F3_OP3((x)) -#define EIF_F4_RD(x) EIF_F2_RD((x)) -#define EIF_F4_TCOND(x) IF_ENCODE((x), F4_TCOND) -#define EIF_F4_RS1(x) EIF_F2_RS1((x)) -#define EIF_F4_CC2(x) IF_ENCODE((x), F4_CC2) -#define EIF_F4_COND(x) IF_ENCODE((x), F4_COND) -#define EIF_F4_I(x) EIF_F3_I((x)) -#define EIF_F4_OPF_CC(x) IF_ENCODE((x), F4_OPF_CC) -#define EIF_F4_RCOND(x) EIF_F3_RCOND((x)) -#define EIF_F4_OPF_LOW(i, w) IF_INSERT((x), IF_F4_OPF_CC_SHIFT, (w)) -#define EIF_F4_RS2(x) EIF_F3_RS2((x)) -#define EIF_F4_SW_TRAP(x) IF_ENCODE((x), F4_SW_TRAP) - -/* Immediates */ -#define EIF_IMM(x, w) IF_INSERT((x), IF_IMM_SHIFT, (w)) -#define EIF_SIMM(x, w) IF_EIMM((x), (w)) - -/* - * OP field values (specifying the instruction format) - */ -#define IOP_FORM2 0x00 /* Format 2: sethi, branches */ -#define IOP_CALL 0x01 /* Format 1: call */ -#define IOP_MISC 0x02 /* Format 3 or 4: arith & misc */ -#define IOP_LDST 0x03 /* Format 4: loads and stores */ - -/* - * OP2/OP3 values (specifying the actual instruction) - */ -/* OP2 values for format 2 (OP = 0) */ -#define INS0_ILLTRAP 0x00 -#define INS0_BPcc 0x01 -#define INS0_Bicc 0x02 -#define INS0_BPr 0x03 -#define INS0_SETHI 0x04 /* with rd = 0 and imm22 = 0, nop */ -#define INS0_FBPfcc 0x05 -#define INS0_FBfcc 0x06 -/* undefined 0x07 */ - -/* OP3 values for Format 3 and 4 (OP = 2) */ -#define INS2_ADD 0x00 -#define INS2_AND 0x01 -#define INS2_OR 0x02 -#define INS2_XOR 0x03 -#define INS2_SUB 0x04 -#define INS2_ANDN 0x05 -#define INS2_ORN 0x06 -#define INS2_XNOR 0x07 -#define INS2_ADDC 0x08 -#define INS2_MULX 0x09 -#define INS2_UMUL 0x0a -#define INS2_SMUL 0x0b -#define INS2_SUBC 0x0c -#define INS2_UDIVX 0x0d -#define INS2_UDIV 0x0e -#define INS2_SDIV 0x0f -#define INS2_ADDcc 0x10 -#define INS2_ANDcc 0x11 -#define INS2_ORcc 0x12 -#define INS2_XORcc 0x13 -#define INS2_SUBcc 0x14 -#define INS2_ANDNcc 0x15 -#define INS2_ORNcc 0x16 -#define INS2_XNORcc 0x17 -#define INS2_ADDCcc 0x18 -/* undefined 0x19 */ -#define INS2_UMULcc 0x1a -#define INS2_SMULcc 0x1b -#define INS2_SUBCcc 0x1c -/* undefined 0x1d */ -#define INS2_UDIVcc 0x1e -#define INS2_SDIVcc 0x1f -#define INS2_TADDcc 0x20 -#define INS2_TSUBcc 0x21 -#define INS2_TADDccTV 0x22 -#define INS2_TSUBccTV 0x23 -#define INS2_MULScc 0x24 -#define INS2_SSL 0x25 /* SLLX when IF_X(i) == 1 */ -#define INS2_SRL 0x26 /* SRLX when IF_X(i) == 1 */ -#define INS2_SRA 0x27 /* SRAX when IF_X(i) == 1 */ -#define INS2_RD 0x28 /* and MEMBAR, STBAR */ -/* undefined 0x29 */ -#define INS2_RDPR 0x2a -#define INS2_FLUSHW 0x2b -#define INS2_MOVcc 0x2c -#define INS2_SDIVX 0x2d -#define INS2_POPC 0x2e /* undefined if IF_RS1(i) != 0 */ -#define INS2_MOVr 0x2f -#define INS2_WR 0x30 /* and SIR */ -#define INS2_SV_RSTR 0x31 /* saved, restored */ -#define INS2_WRPR 0x32 -/* undefined 0x33 */ -#define INS2_FPop1 0x34 /* further encoded in opf field */ -#define INS2_FPop2 0x35 /* further encoded in opf field */ -#define INS2_IMPLDEP1 0x36 -#define INS2_IMPLDEP2 0x37 -#define INS2_JMPL 0x38 -#define INS2_RETURN 0x39 -#define INS2_Tcc 0x3a -#define INS2_FLUSH 0x3b -#define INS2_SAVE 0x3c -#define INS2_RESTORE 0x3d -#define INS2_DONE_RETR 0x3e /* done, retry */ -/* undefined 0x3f */ - -/* OP3 values for format 3 (OP = 3) */ -#define INS3_LDUW 0x00 -#define INS3_LDUB 0x01 -#define INS3_LDUH 0x02 -#define INS3_LDD 0x03 -#define INS3_STW 0x04 -#define INS3_STB 0x05 -#define INS3_STH 0x06 -#define INS3_STD 0x07 -#define INS3_LDSW 0x08 -#define INS3_LDSB 0x09 -#define INS3_LDSH 0x0a -#define INS3_LDX 0x0b -/* undefined 0x0c */ -#define INS3_LDSTUB 0x0d -#define INS3_STX 0x0e -#define INS3_SWAP 0x0f -#define INS3_LDUWA 0x10 -#define INS3_LDUBA 0x11 -#define INS3_LDUHA 0x12 -#define INS3_LDDA 0x13 -#define INS3_STWA 0x14 -#define INS3_STBA 0x15 -#define INS3_STHA 0x16 -#define INS3_STDA 0x17 -#define INS3_LDSWA 0x18 -#define INS3_LDSBA 0x19 -#define INS3_LDSHA 0x1a -#define INS3_LDXA 0x1b -/* undefined 0x1c */ -#define INS3_LDSTUBA 0x1d -#define INS3_STXA 0x1e -#define INS3_SWAPA 0x1f -#define INS3_LDF 0x20 -#define INS3_LDFSR 0x21 /* and LDXFSR */ -#define INS3_LDQF 0x22 -#define INS3_LDDF 0x23 -#define INS3_STF 0x24 -#define INS3_STFSR 0x25 /* and STXFSR */ -#define INS3_STQF 0x26 -#define INS3_STDF 0x27 -/* undefined 0x28 - 0x2c */ -#define INS3_PREFETCH 0x2d -/* undefined 0x2e - 0x2f */ -#define INS3_LDFA 0x30 -/* undefined 0x31 */ -#define INS3_LDQFA 0x32 -#define INS3_LDDFA 0x33 -#define INS3_STFA 0x34 -/* undefined 0x35 */ -#define INS3_STQFA 0x36 -#define INS3_STDFA 0x37 -/* undefined 0x38 - 0x3b */ -#define INS3_CASA 0x39 -#define INS3_PREFETCHA 0x3a -#define INS3_CASXA 0x3b - -/* - * OPF values (floating point instructions, IMPLDEP) - */ -/* - * These values are or'ed to the FPop values to get the instructions. - * They describe the operand type(s). - */ -#define INSFP_i 0x000 /* 32-bit int */ -#define INSFP_s 0x001 /* 32-bit single */ -#define INSFP_d 0x002 /* 64-bit double */ -#define INSFP_q 0x003 /* 128-bit quad */ -/* FPop1. The comments give the types for which this instruction is defined. */ -#define INSFP1_FMOV 0x000 /* s, d, q */ -#define INSFP1_FNEG 0x004 /* s, d, q */ -#define INSFP1_FABS 0x008 /* s, d, q */ -#define INSFP1_FSQRT 0x028 /* s, d, q */ -#define INSFP1_FADD 0x040 /* s, d, q */ -#define INSFP1_FSUB 0x044 /* s, d, q */ -#define INSFP1_FMUL 0x048 /* s, d, q */ -#define INSFP1_FDIV 0x04c /* s, d, q */ -#define INSFP1_FsMULd 0x068 /* s */ -#define INSFP1_FdMULq 0x06c /* d */ -#define INSFP1_FTOx 0x080 /* s, d, q */ -#define INSFP1_FxTOs 0x084 /* special: i only */ -#define INSFP1_FxTOd 0x088 /* special: i only */ -#define INSFP1_FxTOq 0x08c /* special: i only */ -#define INSFP1_FTOs 0x0c4 /* i, d, q */ -#define INSFP1_FTOd 0x0c8 /* i, s, q */ -#define INSFP1_FTOq 0x0cc /* i, s, d */ -#define INSFP1_FTOi 0x0d0 /* i, s, d */ - -/* FPop2 */ -#define INSFP2_FMOV_CCMUL 0x40 -#define INSFP2_FMOV_CCOFFS 0x00 -/* Use the IFCC_* constants for cc. Operand types: s, d, q */ -#define INSFP2_FMOV_CC(cc) ((cc) * INSFP2_FMOV_CCMUL + INSFP2_FMOV_CCOFFS) -#define INSFP2_FMOV_RCMUL 0x20 -#define INSFP2_FMOV_RCOFFS 0x04 -/* Use the IRCOND_* constants for rc. Operand types: s, d, q */ -#define INSFP2_FMOV_RC(rc) ((rc) * INSFP2_FMOV_RCMUL + INSFP2_FMOV_RCOFFS) -#define INSFP2_FCMP 0x050 /* s, d, q */ -#define INSFP2_FCMPE 0x054 /* s, d, q */ - -/* Decode 5-bit register field into 6-bit number (for doubles and quads). */ -#define INSFPdq_RN(rn) (((rn) & ~1) | (((rn) & 1) << 5)) - -/* IMPLDEP1 for Sun UltraSparc */ -#define IIDP1_EDGE8 0x00 -#define IIDP1_EDGE8N 0x01 /* US-III */ -#define IIDP1_EDGE8L 0x02 -#define IIDP1_EDGE8LN 0x03 /* US-III */ -#define IIDP1_EDGE16 0x04 -#define IIDP1_EDGE16N 0x05 /* US-III */ -#define IIDP1_EDGE16L 0x06 -#define IIDP1_EDGE16LN 0x07 /* US-III */ -#define IIDP1_EDGE32 0x08 -#define IIDP1_EDGE32N 0x09 /* US-III */ -#define IIDP1_EDGE32L 0x0a -#define IIDP1_EDGE32LN 0x0b /* US-III */ -#define IIDP1_ARRAY8 0x10 -#define IIDP1_ARRAY16 0x12 -#define IIDP1_ARRAY32 0x14 -#define IIDP1_ALIGNADDRESS 0x18 -#define IIDP1_BMASK 0x19 /* US-III */ -#define IIDP1_ALIGNADDRESS_L 0x1a -#define IIDP1_FCMPLE16 0x20 -#define IIDP1_FCMPNE16 0x22 -#define IIDP1_FCMPLE32 0x24 -#define IIDP1_FCMPNE32 0x26 -#define IIDP1_FCMPGT16 0x28 -#define IIDP1_FCMPEQ16 0x2a -#define IIDP1_FCMPGT32 0x2c -#define IIDP1_FCMPEQ32 0x2e -#define IIDP1_FMUL8x16 0x31 -#define IIDP1_FMUL8x16AU 0x33 -#define IIDP1_FMUL8X16AL 0x35 -#define IIDP1_FMUL8SUx16 0x36 -#define IIDP1_FMUL8ULx16 0x37 -#define IIDP1_FMULD8SUx16 0x38 -#define IIDP1_FMULD8ULx16 0x39 -#define IIDP1_FPACK32 0x3a -#define IIDP1_FPACK16 0x3b -#define IIDP1_FPACKFIX 0x3d -#define IIDP1_PDIST 0x3e -#define IIDP1_FALIGNDATA 0x48 -#define IIDP1_FPMERGE 0x4b -#define IIDP1_BSHUFFLE 0x4c /* US-III */ -#define IIDP1_FEXPAND 0x4d -#define IIDP1_FPADD16 0x50 -#define IIDP1_FPADD16S 0x51 -#define IIDP1_FPADD32 0x52 -#define IIDP1_FPADD32S 0x53 -#define IIDP1_SUB16 0x54 -#define IIDP1_SUB16S 0x55 -#define IIDP1_SUB32 0x56 -#define IIDP1_SUB32S 0x57 -#define IIDP1_FZERO 0x60 -#define IIDP1_FZEROS 0x61 -#define IIDP1_FNOR 0x62 -#define IIDP1_FNORS 0x63 -#define IIDP1_FANDNOT2 0x64 -#define IIDP1_FANDNOT2S 0x65 -#define IIDP1_NOT2 0x66 -#define IIDP1_NOT2S 0x67 -#define IIDP1_FANDNOT1 0x68 -#define IIDP1_FANDNOT1S 0x69 -#define IIDP1_FNOT1 0x6a -#define IIDP1_FNOT1S 0x6b -#define IIDP1_FXOR 0x6c -#define IIDP1_FXORS 0x6d -#define IIDP1_FNAND 0x6e -#define IIDP1_FNANDS 0x6f -#define IIDP1_FAND 0x70 -#define IIDP1_FANDS 0x71 -#define IIDP1_FXNOR 0x72 -#define IIDP1_FXNORS 0x73 -#define IIDP1_FSRC1 0x74 -#define IIDP1_FSRC1S 0x75 -#define IIDP1_FORNOT2 0x76 -#define IIDP1_FORNOT2S 0x77 -#define IIDP1_FSRC2 0x78 -#define IIDP1_FSRC2S 0x79 -#define IIDP1_FORNOT1 0x7a -#define IIDP1_FORNOT1S 0x7b -#define IIDP1_FOR 0x7c -#define IIDP1_FORS 0x7d -#define IIDP1_FONE 0x7e -#define IIDP1_FONES 0x7f -#define IIDP1_SHUTDOWN 0x80 -#define IIDP1_SIAM 0x81 /* US-III */ - -/* - * Instruction modifiers - */ -/* cond values for integer ccr's */ -#define IICOND_N 0x00 -#define IICOND_E 0x01 -#define IICOND_LE 0x02 -#define IICOND_L 0x03 -#define IICOND_LEU 0x04 -#define IICOND_CS 0x05 -#define IICOND_NEG 0x06 -#define IICOND_VS 0x07 -#define IICOND_A 0x08 -#define IICOND_NE 0x09 -#define IICOND_G 0x0a -#define IICOND_GE 0x0b -#define IICOND_GU 0x0c -#define IICOND_CC 0x0d -#define IICOND_POS 0x0e -#define IICOND_VC 0x0f - -/* cond values for fp ccr's */ -#define IFCOND_N 0x00 -#define IFCOND_NE 0x01 -#define IFCOND_LG 0x02 -#define IFCOND_UL 0x03 -#define IFCOND_L 0x04 -#define IFCOND_UG 0x05 -#define IFCOND_G 0x06 -#define IFCOND_U 0x07 -#define IFCOND_A 0x08 -#define IFCOND_E 0x09 -#define IFCOND_UE 0x0a -#define IFCOND_GE 0x0b -#define IFCOND_UGE 0x0c -#define IFCOND_LE 0x0d -#define IFCOND_ULE 0x0e -#define IFCOND_O 0x0f - -/* rcond values for BPr, MOVr, FMOVr */ -#define IRCOND_Z 0x01 -#define IRCOND_LEZ 0x02 -#define IRCOND_LZ 0x03 -#define IRCOND_NZ 0x05 -#define IRCOND_GZ 0x06 -#define IRCOND_GEZ 0x07 - -/* cc values for MOVcc and FMOVcc */ -#define IFCC_ICC 0x04 -#define IFCC_XCC 0x06 -/* if true, the lower 2 bits are the fcc number */ -#define IFCC_FCC(c) ((c) & 3) -#define IFCC_GET_FCC(c) ((c) & 3) -#define IFCC_ISFCC(c) (((c) & 4) == 0) - -/* cc values for BPc and Tcc */ -#define IBCC_ICC 0x00 -#define IBCC_XCC 0x02 - -/* - * Integer registers - */ -#define IREG_G0 0x00 -#define IREG_O0 0x08 -#define IREG_L0 0x10 -#define IREQ_I0 0x18 - -#endif /* !_MACHINE_INSTR_H_ */ diff --git a/sys/sparc64/include/intr_machdep.h b/sys/sparc64/include/intr_machdep.h deleted file mode 100644 index b612893f1c35..000000000000 --- a/sys/sparc64/include/intr_machdep.h +++ /dev/null @@ -1,115 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD - * - * Copyright (c) 2001 Jake Burkholder. - * 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$ - */ - -#ifndef _MACHINE_INTR_MACHDEP_H_ -#define _MACHINE_INTR_MACHDEP_H_ - -#define IRSR_BUSY (1 << 5) - -#define PIL_MAX (1 << 4) -#define IV_MAX (1 << 11) - -#define IR_FREE (PIL_MAX * 2) - -#define IH_SHIFT PTR_SHIFT -#define IQE_SHIFT 5 -#define IV_SHIFT 6 - -#define PIL_LOW 1 /* stray interrupts */ -#define PIL_PREEMPT 2 /* preempt idle thread CPU IPI */ -#define PIL_ITHREAD 3 /* interrupts that use ithreads */ -#define PIL_RENDEZVOUS 4 /* SMP rendezvous IPI */ -#define PIL_AST 5 /* asynchronous trap IPI */ -#define PIL_HARDCLOCK 6 /* hardclock broadcast */ -#define PIL_FILTER 11 /* filter interrupts */ -#define PIL_BRIDGE 12 /* bridge interrupts */ -#define PIL_STOP 13 /* stop CPU IPI */ -#define PIL_TICK 14 /* tick interrupts */ - -#ifndef LOCORE - -#define INTR_BRIDGE INTR_MD1 - -struct trapframe; - -typedef void ih_func_t(struct trapframe *); -typedef void iv_func_t(void *); - -struct intr_request { - struct intr_request *ir_next; - iv_func_t *ir_func; - void *ir_arg; - u_int ir_vec; - u_int ir_pri; -}; - -struct intr_controller { - void (*ic_enable)(void *); - void (*ic_disable)(void *); - void (*ic_assign)(void *); - void (*ic_clear)(void *); -}; - -struct intr_vector { - iv_func_t *iv_func; - void *iv_arg; - const struct intr_controller *iv_ic; - void *iv_icarg; - struct intr_event *iv_event; - u_int iv_pri; - u_int iv_vec; - u_int iv_mid; - u_int iv_refcnt; - u_int iv_pad[2]; -}; - -extern ih_func_t *intr_handlers[]; -extern struct intr_vector intr_vectors[]; - -#ifdef SMP -void intr_add_cpu(u_int cpu); -#endif -int intr_bind(int vec, u_char cpu); -int intr_describe(int vec, void *ih, const char *descr); -void intr_setup(int level, ih_func_t *ihf, int pri, iv_func_t *ivf, - void *iva); -void intr_init1(void); -void intr_init2(void); -int intr_controller_register(int vec, const struct intr_controller *ic, - void *icarg); -int inthand_add(const char *name, int vec, int (*filt)(void *), - void (*handler)(void *), void *arg, int flags, void **cookiep); -int inthand_remove(int vec, void *cookie); - -ih_func_t intr_fast; - -#endif /* !LOCORE */ - -#endif /* !_MACHINE_INTR_MACHDEP_H_ */ diff --git a/sys/sparc64/include/iommureg.h b/sys/sparc64/include/iommureg.h deleted file mode 100644 index de794cd1e449..000000000000 --- a/sys/sparc64/include/iommureg.h +++ /dev/null @@ -1,214 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-3-Clause - * - * 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. - * - * from: @(#)sbusreg.h 8.1 (Berkeley) 6/11/93 - * from: NetBSD: iommureg.h,v 1.6 2001/07/20 00:07:13 eeh Exp - * - * $FreeBSD$ - */ - -#ifndef _MACHINE_IOMMUREG_H_ -#define _MACHINE_IOMMUREG_H_ - -/* - * UltraSPARC IOMMU registers, common to both the PCI and SBus - * controllers. - */ - -/* IOMMU registers */ -#define IMR_CTL 0x0000 /* IOMMU control register */ -#define IMR_TSB 0x0008 /* IOMMU TSB base register */ -#define IMR_FLUSH 0x0010 /* IOMMU flush register */ -/* The TTE Cache is Fire and Oberon only. */ -#define IMR_CACHE_FLUSH 0x0100 /* IOMMU TTE cache flush address register */ -#define IMR_CACHE_INVAL 0x0108 /* IOMMU TTE cache invalidate register */ - -/* streaming buffer registers */ -#define ISR_CTL 0x0000 /* streaming buffer control reg */ -#define ISR_PGFLUSH 0x0008 /* streaming buffer page flush */ -#define ISR_FLUSHSYNC 0x0010 /* streaming buffer flush sync */ - -/* streaming buffer diagnostics registers */ -#define ISD_DATA_DIAG 0x0000 /* streaming buffer data RAM diag 0..127 */ -#define ISD_ERROR_DIAG 0x0400 /* streaming buffer error status diag 0..127 */ -#define ISD_PG_TAG_DIAG 0x0800 /* streaming buffer page tag diag 0..15 */ -#define ISD_LN_TAG_DIAG 0x0900 /* streaming buffer line tag diag 0..15 */ - -/* streaming buffer control register */ -#define STRBUF_EN 0x0000000000000001UL -#define STRBUF_D 0x0000000000000002UL -#define STRBUF_RR_DIS 0x0000000000000004UL - -#define IOMMU_MAXADDR(bits) ((1UL << (bits)) - 1) - -/* - * control register bits - */ -/* Nummber of entries in the IOTSB - pre-Fire only */ -#define IOMMUCR_TSBSZ_MASK 0x0000000000070000UL -#define IOMMUCR_TSBSZ_SHIFT 16 -/* TSB cache snoop enable */ -#define IOMMUCR_SE 0x0000000000000400UL -/* Cache modes - Fire and Oberon */ -#define IOMMUCR_CM_NC_TLB_TBW 0x0000000000000000UL -#define IOMMUCR_CM_LC_NTLB_NTBW 0x0000000000000100UL -#define IOMMUCR_CM_LC_TLB_TBW 0x0000000000000200UL -#define IOMMUCR_CM_C_TLB_TBW 0x0000000000000300UL -/* IOMMU page size - pre-Fire only */ -#define IOMMUCR_8KPG 0x0000000000000000UL -#define IOMMUCR_64KPG 0x0000000000000004UL -/* Bypass enable - Fire and Oberon */ -#define IOMMUCR_BE 0x0000000000000002UL -/* Diagnostic mode enable - pre-Fire only */ -#define IOMMUCR_DE 0x0000000000000002UL -/* IOMMU/translation enable */ -#define IOMMUCR_EN 0x0000000000000001UL - -/* - * TSB base register bits - */ - /* TSB base address */ -#define IOMMUTB_TB_MASK 0x000007ffffffe000UL -#define IOMMUTB_TB_SHIFT 13 -/* IOMMU page size - Fire and Oberon */ -#define IOMMUTB_8KPG 0x0000000000000000UL -#define IOMMUTB_64KPG 0x0000000000000100UL -/* Nummber of entries in the IOTSB - Fire and Oberon */ -#define IOMMUTB_TSBSZ_MASK 0x0000000000000004UL -#define IOMMUTB_TSBSZ_SHIFT 0 - -/* - * TSB size definitions for both control and TSB base register */ -#define IOMMU_TSB1K 0 -#define IOMMU_TSB2K 1 -#define IOMMU_TSB4K 2 -#define IOMMU_TSB8K 3 -#define IOMMU_TSB16K 4 -#define IOMMU_TSB32K 5 -#define IOMMU_TSB64K 6 -#define IOMMU_TSB128K 7 -/* Fire and Oberon */ -#define IOMMU_TSB256K 8 -/* Fire and Oberon */ -#define IOMMU_TSB512K 9 -#define IOMMU_TSBENTRIES(tsbsz) \ - ((1 << (tsbsz)) << (IO_PAGE_SHIFT - IOTTE_SHIFT)) - -/* - * Diagnostic register definitions - */ -#define IOMMU_DTAG_VPNBITS 19 -#define IOMMU_DTAG_VPNMASK ((1 << IOMMU_DTAG_VPNBITS) - 1) -#define IOMMU_DTAG_VPNSHIFT 13 -#define IOMMU_DTAG_ERRBITS 3 -#define IOMMU_DTAG_ERRSHIFT 22 -#define IOMMU_DTAG_ERRMASK \ - (((1 << IOMMU_DTAG_ERRBITS) - 1) << IOMMU_DTAG_ERRSHIFT) - -#define IOMMU_DDATA_PGBITS 21 -#define IOMMU_DDATA_PGMASK ((1 << IOMMU_DDATA_PGBITS) - 1) -#define IOMMU_DDATA_PGSHIFT 13 -#define IOMMU_DDATA_C (1 << 28) -#define IOMMU_DDATA_V (1 << 30) - -/* - * IOMMU stuff - */ -/* Entry valid */ -#define IOTTE_V 0x8000000000000000UL -/* Page size - pre-Fire only */ -#define IOTTE_64K 0x2000000000000000UL -#define IOTTE_8K 0x0000000000000000UL -/* Streamable page - streaming buffer equipped variants only */ -#define IOTTE_STREAM 0x1000000000000000UL -/* Accesses to the same bus segment - SBus only */ -#define IOTTE_LOCAL 0x0800000000000000UL -/* Physical address mask (based on Oberon) */ -#define IOTTE_PAMASK 0x00007fffffffe000UL -/* Accesses to cacheable space - pre-Fire only */ -#define IOTTE_C 0x0000000000000010UL -/* Writeable */ -#define IOTTE_W 0x0000000000000002UL - -/* log2 of the IOMMU TTE size */ -#define IOTTE_SHIFT 3 - -/* Streaming buffer line size */ -#define STRBUF_LINESZ 64 - -/* - * Number of bytes written by a stream buffer flushsync operation to indicate - * completion. - */ -#define STRBUF_FLUSHSYNC_NBYTES STRBUF_LINESZ - -/* - * On sun4u each bus controller has a separate IOMMU. The IOMMU has - * a TSB which must be page aligned and physically contiguous. Mappings - * can be of 8K IOMMU pages or 64K IOMMU pages. We use 8K for compatibility - * with the CPU's MMU. - * - * On sysio, psycho, and psycho+, IOMMU TSBs using 8K pages can map the - * following size segments: - * - * VA size VA base TSB size tsbsize - * -------- -------- --------- ------- - * 8MB ff800000 8K 0 - * 16MB ff000000 16K 1 - * 32MB fe000000 32K 2 - * 64MB fc000000 64K 3 - * 128MB f8000000 128K 4 - * 256MB f0000000 256K 5 - * 512MB e0000000 512K 6 - * 1GB c0000000 1MB 7 - * - * Unfortunately, sabres on UltraSPARC IIi and IIe processors does not use - * this scheme to determine the IOVA base address. Instead, bits 31-29 are - * used to check against the Target Address Space register in the IIi and - * the IOMMU is used if they hit. God knows what goes on in the IIe. - * - */ - -#define IOTSB_BASESZ (1024 << IOTTE_SHIFT) -#define IOTSB_VEND (~IO_PAGE_MASK) -#define IOTSB_VSTART(sz) (u_int)(IOTSB_VEND << ((sz) + 10)) - -#define MAKEIOTTE(pa, w, c, s) \ - (((pa) & IOTTE_PAMASK) | ((w) ? IOTTE_W : 0) | \ - ((c) ? IOTTE_C : 0) | ((s) ? IOTTE_STREAM : 0) | \ - (IOTTE_V | IOTTE_8K)) -#define IOTSBSLOT(va) \ - ((u_int)(((vm_offset_t)(va)) - (is->is_dvmabase)) >> IO_PAGE_SHIFT) - -#endif /* !_MACHINE_IOMMUREG_H_ */ diff --git a/sys/sparc64/include/iommuvar.h b/sys/sparc64/include/iommuvar.h deleted file mode 100644 index f2fdd6c6dc75..000000000000 --- a/sys/sparc64/include/iommuvar.h +++ /dev/null @@ -1,115 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD - * - * Copyright (c) 1999 Matthew R. Green - * 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 ``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 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. - * - * from: NetBSD: iommuvar.h,v 1.6 2008/05/29 14:51:26 mrg Exp - * - * $FreeBSD$ - */ - -#ifndef _MACHINE_IOMMUVAR_H_ -#define _MACHINE_IOMMUVAR_H_ - -#define IO_PAGE_SIZE PAGE_SIZE_8K -#define IO_PAGE_MASK PAGE_MASK_8K -#define IO_PAGE_SHIFT PAGE_SHIFT_8K -#define round_io_page(x) round_page(x) -#define trunc_io_page(x) trunc_page(x) - -/* - * LRU queue handling for lazy resource allocation - */ -TAILQ_HEAD(iommu_maplruq_head, bus_dmamap); - -/* - * Per-IOMMU state; the parenthesized comments indicate the locking strategy: - * i - protected by is_mtx. - * r - read-only after initialization. - * * - comment refers to pointer target / target hardware registers - * (for bus_addr_t). - * is_maplruq is also locked by is_mtx. Elements of is_tsb may only be - * accessed from functions operating on the map owning the corresponding - * resource, so the locking the user is required to do to protect the - * map is sufficient. - * dm_reslist of all maps are locked by is_mtx as well. - * is_dvma_rman has its own internal lock. - */ -struct iommu_state { - struct mtx is_mtx; - struct rman is_dvma_rman; /* DVMA space rman */ - struct iommu_maplruq_head is_maplruq; /* (i) LRU queue */ - vm_paddr_t is_ptsb; /* (r) TSB physical address */ - uint64_t *is_tsb; /* (*i) TSB virtual address */ - int is_tsbsize; /* (r) 0 = 8K, ... */ - uint64_t is_pmaxaddr; /* (r) max. physical address */ - uint64_t is_dvmabase; /* (r) */ - uint64_t is_cr; /* (r) Control reg value */ - - vm_paddr_t is_flushpa[2]; /* (r) */ - volatile uint64_t *is_flushva[2]; /* (r, *i) */ - /* - * (i) - * When a flush is completed, 64 bytes will be stored at the given - * location, the first double word being 1, to indicate completion. - * The lower 6 address bits are ignored, so the addresses need to be - * suitably aligned; over-allocate a large enough margin to be able - * to adjust it. - * Two such buffers are needed. - */ - volatile char is_flush[STRBUF_FLUSHSYNC_NBYTES * 3 - 1]; - - /* copies of our parent's state, to allow us to be self contained */ - bus_space_tag_t is_bustag; /* (r) Our bus tag */ - bus_space_handle_t is_bushandle; /* (r) */ - bus_addr_t is_iommu; /* (r, *i) IOMMU registers */ - bus_addr_t is_sb[2]; /* (r, *i) Streaming buffer */ - /* Tag diagnostics access */ - bus_addr_t is_dtag; /* (r, *r) */ - /* Data RAM diagnostic access */ - bus_addr_t is_ddram; /* (r, *r) */ - /* LRU queue diag. access */ - bus_addr_t is_dqueue; /* (r, *r) */ - /* Virtual address diagnostics register */ - bus_addr_t is_dva; /* (r, *r) */ - /* Tag compare diagnostics access */ - bus_addr_t is_dtcmp; /* (r, *r) */ - /* behavior flags */ - u_int is_flags; /* (r) */ -#define IOMMU_RERUN_DISABLE (1 << 0) -#define IOMMU_FIRE (1 << 1) -#define IOMMU_FLUSH_CACHE (1 << 2) -#define IOMMU_PRESERVE_PROM (1 << 3) -}; - -/* interfaces for PCI/SBus code */ -void iommu_init(const char *name, struct iommu_state *is, u_int tsbsize, - uint32_t iovabase, u_int resvpg); -void iommu_reset(struct iommu_state *is); -void iommu_decode_fault(struct iommu_state *is, vm_offset_t phys); - -extern struct bus_dma_methods iommu_dma_methods; - -#endif /* !_MACHINE_IOMMUVAR_H_ */ diff --git a/sys/sparc64/include/jbus.h b/sys/sparc64/include/jbus.h deleted file mode 100644 index d644594f172f..000000000000 --- a/sys/sparc64/include/jbus.h +++ /dev/null @@ -1,41 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD - * - * Copyright (c) 2010 Marius Strobl - * 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$ - */ - -#ifndef _MACHINE_JBUS_H_ -#define _MACHINE_JBUS_H_ - -#define JBUS_CR_JID_SHIFT (17) -#define JBUS_CR_JID_SIZE (3) -#define JBUS_CR_JID_MASK \ - (((1 << JBUS_CR_JID_SIZE) - 1) << JBUS_CR_JID_SHIFT) - -#define JBUS_CR_GET_JID(cr) ((cr & JBUS_CR_JID_MASK) >> JBUS_CR_JID_SHIFT) - -#endif /* _MACHINE_JBUS_H_ */ diff --git a/sys/sparc64/include/kdb.h b/sys/sparc64/include/kdb.h deleted file mode 100644 index 8f3876e4a0e5..000000000000 --- a/sys/sparc64/include/kdb.h +++ /dev/null @@ -1,59 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD - * - * Copyright (c) 2004 Marcel Moolenaar - * 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 ``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 BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $FreeBSD$ - */ - -#ifndef _MACHINE_KDB_H_ -#define _MACHINE_KDB_H_ - -#include - -#define KDB_STOPPEDPCB(pc) &stoppcbs[pc->pc_cpuid] - -static __inline void -kdb_cpu_clear_singlestep(void) -{ -} - -static __inline void -kdb_cpu_set_singlestep(void) -{ -} - -static __inline void -kdb_cpu_sync_icache(unsigned char *addr, size_t size) -{ -} - -static __inline void -kdb_cpu_trap(int vector, int _) -{ - flushw(); -} - -#endif /* _MACHINE_KDB_H_ */ diff --git a/sys/sparc64/include/kerneldump.h b/sys/sparc64/include/kerneldump.h deleted file mode 100644 index 975b566d0ce3..000000000000 --- a/sys/sparc64/include/kerneldump.h +++ /dev/null @@ -1,54 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD - * - * Copyright (c) 2002 by Thomas Moestl . - * 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 ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE - * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $FreeBSD$ - */ - -#ifndef _MACHINE_KERNELDUMP_H_ -#define _MACHINE_KERNELDUMP_H_ - -struct sparc64_dump_reg { - uint64_t dr_pa; - uint64_t dr_size; - uint64_t dr_offs; -}; - -/* - * Kernel dump format for sparc64. This does not use ELF because it is of no - * avail (only libkvm knows how to translate addresses properly anyway) and - * would require some ugly hacks. - */ -struct sparc64_dump_hdr { - uint64_t dh_hdr_size; - uint64_t dh_tsb_pa; - uint64_t dh_tsb_size; - uint64_t dh_tsb_mask; - int32_t dh_nregions; - int32_t dh_pad; - struct sparc64_dump_reg dh_regions[]; -}; - -#endif /* _MACHINE_KERNELDUMP_H_ */ diff --git a/sys/sparc64/include/ktr.h b/sys/sparc64/include/ktr.h deleted file mode 100644 index 01bb6a2d384c..000000000000 --- a/sys/sparc64/include/ktr.h +++ /dev/null @@ -1,101 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-3-Clause - * - * Copyright (c) 1996 Berkeley Software Design, Inc. 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. - * 3. Berkeley Software Design Inc's name may not be used to endorse or - * promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY BERKELEY SOFTWARE DESIGN INC ``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 BERKELEY SOFTWARE DESIGN INC 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. - * - * from BSDI $Id: ktr.h,v 1.10.2.7 2000/03/16 21:44:42 cp Exp $ - * $FreeBSD$ - */ - -#ifndef _MACHINE_KTR_H_ -#define _MACHINE_KTR_H_ - -#include - -#ifdef LOCORE - -/* - * XXX could really use another register ... - */ -#define ATR(desc, r1, r2, r3, l1, l2) \ - .sect .rodata ; \ -l1: .asciz desc ; \ - .previous ; \ - SET(ktr_idx, r2, r1) ; \ - lduw [r1], r2 ; \ -l2: add r2, 1, r3 ; \ - set KTR_ENTRIES - 1, r1 ; \ - and r3, r1, r3 ; \ - set ktr_idx, r1 ; \ - casa [r1] ASI_N, r2, r3 ; \ - cmp r2, r3 ; \ - bne %icc, l2 ## b ; \ - mov r3, r2 ; \ - SET(ktr_buf, r3, r1) ; \ - ldx [r1], r1 ; \ - mulx r2, KTR_SIZEOF, r2 ; \ - add r1, r2, r1 ; \ - rd %tick, r2 ; \ - stx r2, [r1 + KTR_TIMESTAMP] ; \ - lduw [PCPU(CPUID)], r2 ; \ - stw r2, [r1 + KTR_CPU] ; \ - stw %g0, [r1 + KTR_LINE] ; \ - stx %g0, [r1 + KTR_FILE] ; \ - SET(l1 ## b, r3, r2) ; \ - stx r2, [r1 + KTR_DESC] - -#define CATR(mask, desc, r1, r2, r3, l1, l2, l3) \ - setx mask, r3, r1 ; \ - setx ktr_mask, r3, r2 ; \ - ldx [r2], r2 ; \ - and r2, r1, r1 ; \ - brz r1, l3 ## f ; \ - nop ; \ - lduw [PCPU(CPUID)], r2 ; \ - mov _NCPUBITS, r3 ; \ - udivx r2, r3, r2 ; \ - srl r2, 0, r2 ; \ - sllx r2, PTR_SHIFT, r2 ; \ - SET(ktr_cpumask, r3, r1) ; \ - ldx [r1 + r2], r1 ; \ - lduw [PCPU(CPUID)], r2 ; \ - mov _NCPUBITS, r3 ; \ - udivx r2, r3, r2 ; \ - srl r2, 0, r2 ; \ - smul r2, r3, r3 ; \ - lduw [PCPU(CPUID)], r2 ; \ - sub r2, r3, r3 ; \ - mov 1, r2 ; \ - sllx r2, r3, r2 ; \ - andn r1, r2, r1 ; \ - brz r1, l3 ## f ; \ - nop ; \ - ATR(desc, r1, r2, r3, l1, l2) - -#endif /* LOCORE */ - -#endif /* !_MACHINE_KTR_H_ */ diff --git a/sys/sparc64/include/limits.h b/sys/sparc64/include/limits.h deleted file mode 100644 index 689e8a91072b..000000000000 --- a/sys/sparc64/include/limits.h +++ /dev/null @@ -1,43 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD - * - * Copyright (c) 1988, 1993 - * The Regents of the University of California. 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 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. - * - * @(#)limits.h 8.3 (Berkeley) 1/4/94 - * $FreeBSD$ - */ - -#ifndef _MACHINE_LIMITS_H_ -#define _MACHINE_LIMITS_H_ - -#include - -#if __CC_SUPPORTS_WARNING -#warning "machine/limits.h is deprecated. Include sys/limits.h instead." -#endif - -#include - -#endif /* !_MACHINE_LIMITS_H_ */ diff --git a/sys/sparc64/include/lsu.h b/sys/sparc64/include/lsu.h deleted file mode 100644 index 1f62df9c8eee..000000000000 --- a/sys/sparc64/include/lsu.h +++ /dev/null @@ -1,88 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD - * - * Copyright 2001 by Thomas Moestl . 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 ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE - * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $FreeBSD$ - */ - -#ifndef _MACHINE_LSU_H_ -#define _MACHINE_LSU_H_ - -/* - * Definitions for the Load-Store-Unit Control Register. This is called - * Data Cache Unit Control Register (DCUCR) for UltraSPARC-III and greater. - */ -#define LSU_IC (1UL << 0) -#define LSU_DC (1UL << 1) -#define LSU_IM (1UL << 2) -#define LSU_DM (1UL << 3) - -/* Parity control mask, UltraSPARC-I and II series only. */ -#define LSU_FM_SHIFT 4 -#define LSU_FM_BITS 16 -#define LSU_FM_MASK (((1UL << LSU_FM_BITS) - 1) << LSU_FM_SHIFT) - -#define LSU_VM_SHIFT 25 -#define LSU_VM_BITS 8 -#define LSU_VM_MASK (((1UL << LSU_VM_BITS) - 1) << LSU_VM_SHIFT) - -#define LSU_PM_SHIFT 33 -#define LSU_PM_BITS 8 -#define LSU_PM_MASK (((1UL << LSU_PM_BITS) - 1) << LSU_PM_SHIFT) - -#define LSU_VW (1UL << 21) -#define LSU_VR (1UL << 22) -#define LSU_PW (1UL << 23) -#define LSU_PR (1UL << 24) - -/* The following bits are valid for the UltraSPARC-III series only. */ -#define LSU_WE (1UL << 41) -#define LSU_SL (1UL << 42) -#define LSU_SPE (1UL << 43) -#define LSU_HPE (1UL << 44) -#define LSU_PE (1UL << 45) -#define LSU_RE (1UL << 46) -#define LSU_ME (1UL << 47) -#define LSU_CV (1UL << 48) -#define LSU_CP (1UL << 49) - -/* The following bit is valid for the UltraSPARC-IV only. */ -#define LSU_WIH (1UL << 4) - -/* The following bits are valid for the UltraSPARC-IV+ only. */ -#define LSU_PPS_SHIFT 50 -#define LSU_PPS_BITS 2 -#define LSU_PPS_MASK (((1UL << LSU_PPS_BITS) - 1) << LSU_PPS_SHIFT) - -#define LSU_IPS_SHIFT 52 -#define LSU_IPS_BITS 2 -#define LSU_IPS_MASK (((1UL << LSU_IPS_BITS) - 1) << LSU_IPS_SHIFT) - -#define LSU_PCM (1UL << 54) -#define LSU_WCE (1UL << 55) - -/* The following bit is valid for the SPARC64 V, VI, VII and VIIIfx only. */ -#define LSU_WEAK_SPCA (1UL << 41) - -#endif /* _MACHINE_LSU_H_ */ diff --git a/sys/sparc64/include/mcntl.h b/sys/sparc64/include/mcntl.h deleted file mode 100644 index 8dcc62868cbd..000000000000 --- a/sys/sparc64/include/mcntl.h +++ /dev/null @@ -1,64 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD - * - * Copyright (c) 2010 Marius Strobl - * 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$ - */ - -#ifndef _MACHINE_MCNTL_H -#define _MACHINE_MCNTL_H - -/* - * Definitions for the SPARC64 V, VI, VII and VIIIfx Memory Control Register - */ -#define MCNTL_JPS1_TSBP (1UL << 8) - -#define MCNTL_RMD_SHIFT 12 -#define MCNTL_RMD_BITS 2 -#define MCNTL_RMD_MASK \ - (((1UL << MCNTL_RMD_BITS) - 1) << MCNTL_RMD_SHIFT) -#define MCNTL_RMD_FULL (0UL << MCNTL_RMD_SHIFT) -#define MCNTL_RMD_1024 (2UL << MCNTL_RMD_SHIFT) -#define MCNTL_RMD_512 (3UL << MCNTL_RMD_SHIFT) - -#define MCNTL_FW_FDTLB (1UL << 14) -#define MCNTL_FW_FITLB (1UL << 15) -#define MCNTL_NC_CACHE (1UL << 16) - -/* The following bits are valid for the SPARC64 VI, VII and VIIIfx only. */ -#define MCNTL_MPG_SDTLB (1UL << 6) -#define MCNTL_MPG_SITLB (1UL << 7) - -/* The following bits are valid for the SPARC64 VIIIfx only. */ -#define MCNTL_HPF_SHIFT 18 -#define MCNTL_HPF_BITS 2 -#define MCNTL_HPF_MASK \ - (((1UL << MCNTL_HPF_BITS) - 1) << MCNTL_HPF_SHIFT) -#define MCNTL_HPF_STRONG (0UL << MCNTL_HPF_SHIFT) -#define MCNTL_HPF_NOT (1UL << MCNTL_HPF_SHIFT) -#define MCNTL_HPF_WEAK (2UL << MCNTL_HPF_SHIFT) - -#endif /* _MACHINE_MCNTL_H */ diff --git a/sys/sparc64/include/md_var.h b/sys/sparc64/include/md_var.h deleted file mode 100644 index 3a30b2355935..000000000000 --- a/sys/sparc64/include/md_var.h +++ /dev/null @@ -1,80 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-3-Clause - * - * Copyright (c) 1995 Bruce D. Evans. - * 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. - * 3. Neither the name of the author nor the names of contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * 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. - * - * from: FreeBSD: src/sys/i386/include/md_var.h,v 1.40 2001/07/12 - * $FreeBSD$ - */ - -#ifndef _MACHINE_MD_VAR_H_ -#define _MACHINE_MD_VAR_H_ - -typedef void cpu_block_copy_t(const void *src, void *dst, size_t len); -typedef void cpu_block_zero_t(void *dst, size_t len); - -extern char tl0_base[]; -extern char _end[]; - -extern long Maxmem; - -extern vm_offset_t kstack0; -extern vm_paddr_t kstack0_phys; - -struct pcpu; -struct md_utrap; - -uint32_t cpu_get_mid(u_int cpu_impl); -void cpu_identify(u_long vers, u_int clock, u_int id); -const char *cpu_portid_prop(u_int cpu_impl); -void cpu_setregs(struct pcpu *pc); -int is_physical_memory(vm_paddr_t addr); -struct md_utrap *utrap_alloc(void); -void utrap_free(struct md_utrap *ut); -struct md_utrap *utrap_hold(struct md_utrap *ut); - -cpu_block_copy_t spitfire_block_copy; -cpu_block_zero_t spitfire_block_zero; -cpu_block_copy_t zeus_block_copy; -cpu_block_zero_t zeus_block_zero; - -extern cpu_block_copy_t *cpu_block_copy; -extern cpu_block_zero_t *cpu_block_zero; - -/* - * Given that the VTOC8 disk label only uses 16-bit fields for cylinders, - * heads and sectors we might need to adjust the geometry of large disks. - */ -struct ccb_calc_geometry; -int scsi_da_bios_params(struct ccb_calc_geometry *ccg); -struct disk; -void sparc64_ata_disk_firmware_geom_adjust(struct disk *disk); -#define ata_disk_firmware_geom_adjust(disk) \ - sparc64_ata_disk_firmware_geom_adjust(disk) - -#endif /* !_MACHINE_MD_VAR_H_ */ diff --git a/sys/sparc64/include/memdev.h b/sys/sparc64/include/memdev.h deleted file mode 100644 index 486dbb5a5bfa..000000000000 --- a/sys/sparc64/include/memdev.h +++ /dev/null @@ -1,42 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD - * - * Copyright (c) 2004 Mark R V Murray - * 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 - * in this position and unchanged. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``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 BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $FreeBSD$ - */ - -#ifndef _MACHINE_MEMDEV_H_ -#define _MACHINE_MEMDEV_H_ - -#define CDEV_MINOR_MEM 0 -#define CDEV_MINOR_KMEM 1 - -d_open_t memopen; -d_read_t memrw; -#define memioctl (d_ioctl_t *)NULL -#define memmmap (d_mmap_t *)NULL - -#endif /* _MACHINE_MEMDEV_H_ */ diff --git a/sys/sparc64/include/metadata.h b/sys/sparc64/include/metadata.h deleted file mode 100644 index 8eaa485469e7..000000000000 --- a/sys/sparc64/include/metadata.h +++ /dev/null @@ -1,47 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD - * - * Copyright (c) 2001 Jake Burkholder. - * 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$ - */ - -#ifndef _MACHINE_METADATA_H_ -#define _MACHINE_METADATA_H_ - -#define MODINFOMD_ENVP 0x1001 -#define MODINFOMD_HOWTO 0x1002 -#define MODINFOMD_KERNEND 0x1003 -#define MODINFOMD_DTLB_SLOTS 0x1004 -#define MODINFOMD_ITLB_SLOTS 0x1005 -#define MODINFOMD_DTLB 0x1006 -#define MODINFOMD_ITLB 0x1007 - -struct tlb_entry { - vm_offset_t te_pa; - vm_offset_t te_va; -}; - -#endif /* !_MACHINE_METADATA_H_ */ diff --git a/sys/sparc64/include/nexusvar.h b/sys/sparc64/include/nexusvar.h deleted file mode 100644 index 2e5f46183417..000000000000 --- a/sys/sparc64/include/nexusvar.h +++ /dev/null @@ -1,36 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD - * - * Copyright (c) 2010 Marius Strobl - * 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$ - */ - -#ifndef _MACHINE_NEXUSVAR_H_ -#define _MACHINE_NEXUSVAR_H_ - -DECLARE_CLASS(nexus_driver); - -#endif /* _MACHINE_NEXUSVAR_H_ */ diff --git a/sys/sparc64/include/ofw_machdep.h b/sys/sparc64/include/ofw_machdep.h deleted file mode 100644 index b3c33f449d03..000000000000 --- a/sys/sparc64/include/ofw_machdep.h +++ /dev/null @@ -1,50 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD - * - * Copyright (c) 2001 by Thomas Moestl . - * 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 ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE - * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $FreeBSD$ - */ - -#ifndef _MACHINE_OFW_MACHDEP_H_ -#define _MACHINE_OFW_MACHDEP_H_ - -#include -#include -#include - -typedef uint64_t cell_t; - -/* sparc64 doesn't use the interrupt parent #address-cells in interrupt maps */ -#define OFW_IMAP_NO_IPARENT_ADDR_CELLS - -int OF_decode_addr(phandle_t, int, int *, bus_addr_t *); -void OF_getetheraddr(device_t, u_char *); -u_int OF_getscsinitid(device_t); -void OF_panic(const char *fmt, ...) __dead2 __printflike(1, 2); -void cpu_shutdown(void *) __dead2; -int ofw_entry(void *); -void ofw_exit(void *) __dead2; - -#endif /* _MACHINE_OFW_MACHDEP_H_ */ diff --git a/sys/sparc64/include/ofw_mem.h b/sys/sparc64/include/ofw_mem.h deleted file mode 100644 index 44d7c18f36d5..000000000000 --- a/sys/sparc64/include/ofw_mem.h +++ /dev/null @@ -1,48 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD - * - * Copyright (c) 2001 Jake Burkholder. - * 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$ - */ - -#ifndef _MACHINE_OFW_MEM_H_ -#define _MACHINE_OFW_MEM_H_ - -struct ofw_mem_region { - vm_paddr_t mr_start; - vm_size_t mr_size; -}; - -struct ofw_map { - vm_offset_t om_start; - vm_size_t om_size; - u_long om_tte; -}; - -extern struct ofw_mem_region sparc64_memreg[]; -extern int sparc64_nmemreg; - -#endif diff --git a/sys/sparc64/include/ofw_nexus.h b/sys/sparc64/include/ofw_nexus.h deleted file mode 100644 index 247a311b1989..000000000000 --- a/sys/sparc64/include/ofw_nexus.h +++ /dev/null @@ -1,81 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD - * - * Copyright (c) 1999 Matthew R. Green - * 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 ``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 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. - */ - -/*- - * Copyright (c) 1998, 1999 Eduardo E. Horvath - * 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. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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. - * - * from: NetBSD: psychoreg.h,v 1.14 2008/05/30 02:29:37 mrg Exp - * - * $FreeBSD$ - */ - -#ifndef _MACHINE_OFW_NEXUS_H_ -#define _MACHINE_OFW_NEXUS_H_ - -/* - * These are the regs used for devices on the nexus. They apply to all of - * Fireplane/Safari, JBus and UPA. - */ - -struct nexus_regs { - uint32_t phys_hi; - uint32_t phys_lo; - uint32_t size_hi; - uint32_t size_lo; -}; - -#define NEXUS_REG_PHYS(r) \ - (((uint64_t)(r)->phys_hi << 32) | (uint64_t)(r)->phys_lo) -#define NEXUS_REG_SIZE(r) \ - (((uint64_t)(r)->size_hi << 32) | (uint64_t)(r)->size_lo) - -#endif /* !_MACHINE_OFW_NEXUS_H_ */ diff --git a/sys/sparc64/include/param.h b/sys/sparc64/include/param.h deleted file mode 100644 index 32083f65a111..000000000000 --- a/sys/sparc64/include/param.h +++ /dev/null @@ -1,155 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD - * - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * 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 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. - * - * from: @(#)param.h 5.8 (Berkeley) 6/28/91 - * $FreeBSD$ - */ - -#ifndef _SPARC64_INCLUDE_PARAM_H_ -#define _SPARC64_INCLUDE_PARAM_H_ - -/* - * Machine dependent constants for sparc64. - */ - -#include - -#define __PCI_BAR_ZERO_VALID - -#ifndef MACHINE -#define MACHINE "sparc64" -#endif -#ifndef MACHINE_ARCH -#define MACHINE_ARCH "sparc64" -#endif -#define MID_MACHINE MID_SPARC64 - -#if defined(SMP) || defined(KLD_MODULE) -#ifndef MAXCPU -#define MAXCPU 64 -#endif -#else -#define MAXCPU 1 -#endif /* SMP || KLD_MODULE */ - -#ifndef MAXMEMDOM -#define MAXMEMDOM 1 -#endif - -#define INT_SHIFT 2 -#define PTR_SHIFT 3 - -#define ALIGNBYTES _ALIGNBYTES -#define ALIGN(p) _ALIGN(p) -/* - * ALIGNED_POINTER is a boolean macro that checks whether an address - * is valid to fetch data elements of type t from on this architecture. - * This does not reflect the optimal alignment, just the possibility - * (within reasonable limits). - */ -#define ALIGNED_POINTER(p, t) ((((u_long)(p)) & (sizeof (t) - 1)) == 0) - -/* - * CACHE_LINE_SIZE is the compile-time maximum cache line size for an - * architecture. It should be used with appropriate caution. - */ -#define CACHE_LINE_SHIFT 7 -#define CACHE_LINE_SIZE (1 << CACHE_LINE_SHIFT) - -#define PAGE_SHIFT_8K 13 -#define PAGE_SIZE_8K (1L<> PAGE_SHIFT) -#define ptoa(x) ((unsigned long)(x) << PAGE_SHIFT) - -#define sparc64_btop(x) ((unsigned long)(x) >> PAGE_SHIFT) -#define sparc64_ptob(x) ((unsigned long)(x) << PAGE_SHIFT) - -#define pgtok(x) ((unsigned long)(x) * (PAGE_SIZE / 1024)) - -#ifdef _KERNEL -#define NO_FUEWORD 1 -#endif - -#endif /* !_SPARC64_INCLUDE_PARAM_H_ */ diff --git a/sys/sparc64/include/pcb.h b/sys/sparc64/include/pcb.h deleted file mode 100644 index e5a8c1bd9b94..000000000000 --- a/sys/sparc64/include/pcb.h +++ /dev/null @@ -1,65 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD - * - * Copyright (c) 2001 Jake Burkholder. - * 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$ - */ - -#ifndef _MACHINE_PCB_H_ -#define _MACHINE_PCB_H_ - -#ifndef LOCORE -#include -#endif - -#define MAXWIN 8 - -#define PCB_FEF (1 << 0) - -#ifndef LOCORE - -/* NOTE: pcb_ufp must be aligned on a 64 byte boundary. */ -struct pcb { - struct rwindow pcb_rw[MAXWIN]; - uint32_t pcb_kfp[64]; - uint32_t pcb_ufp[64]; - uint64_t pcb_rwsp[MAXWIN]; - uint64_t pcb_flags; - uint64_t pcb_nsaved; - uint64_t pcb_pc; - uint64_t pcb_sp; - uint64_t pcb_tpc; - uint64_t pcb_pad[3]; -} __aligned(64); - -#ifdef _KERNEL -void makectx(struct trapframe *tf, struct pcb *pcb); -int savectx(struct pcb *pcb) __returns_twice; -#endif - -#endif /* !LOCORE */ - -#endif /* !_MACHINE_PCB_H_ */ diff --git a/sys/sparc64/include/pcpu.h b/sys/sparc64/include/pcpu.h deleted file mode 100644 index 1716d95a0891..000000000000 --- a/sys/sparc64/include/pcpu.h +++ /dev/null @@ -1,103 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD - * - * Copyright (c) 1999 Luoqi Chen - * 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. - * - * from: FreeBSD: src/sys/i386/include/globaldata.h,v 1.27 2001/04/27 - * $FreeBSD$ - */ - -#ifndef _MACHINE_PCPU_H_ -#define _MACHINE_PCPU_H_ - -#include -#include -#include -#include - -#define ALT_STACK_SIZE 128 - -struct pmap; - -/* - * Inside the kernel, the globally reserved register g7 is used to - * point at the globaldata structure. - */ -#define PCPU_MD_FIELDS \ - struct cacheinfo pc_cache; \ - struct intr_request pc_irpool[IR_FREE]; \ - struct intr_request *pc_irhead; \ - struct intr_request **pc_irtail; \ - struct intr_request *pc_irfree; \ - struct pmap *pc_pmap; \ - vm_offset_t pc_addr; \ - vm_offset_t pc_qmap_addr; \ - u_long pc_tickref; \ - u_long pc_tickadj; \ - u_long pc_tickincrement; \ - u_int pc_clock; \ - u_int pc_impl; \ - u_int pc_mid; \ - u_int pc_node; \ - u_int pc_tlb_ctx; \ - u_int pc_tlb_ctx_max; \ - u_int pc_tlb_ctx_min; \ - char __pad[653] - -#ifdef _KERNEL - -extern void *dpcpu0; - -struct pcb; -struct pcpu; - -register struct pcb *curpcb __asm__(__XSTRING(PCB_REG)); -register struct pcpu *pcpup __asm__(__XSTRING(PCPU_REG)); - -#define get_pcpu() (pcpup) -#define PCPU_GET(member) (pcpup->pc_ ## member) - -static __inline __pure2 struct thread * -__curthread(void) -{ - struct thread *td; - - __asm("ldx [%" __XSTRING(PCPU_REG) "], %0" : "=r" (td)); - return (td); -} -#define curthread (__curthread()) - -/* - * XXX The implementation of this operation should be made atomic - * with respect to preemption. - */ -#define PCPU_ADD(member, value) (pcpup->pc_ ## member += (value)) -#define PCPU_INC(member) PCPU_ADD(member, 1) -#define PCPU_PTR(member) (&pcpup->pc_ ## member) -#define PCPU_SET(member,value) (pcpup->pc_ ## member = (value)) - -#endif /* _KERNEL */ - -#endif /* !_MACHINE_PCPU_H_ */ diff --git a/sys/sparc64/include/pcpu_aux.h b/sys/sparc64/include/pcpu_aux.h deleted file mode 100644 index db79491b538f..000000000000 --- a/sys/sparc64/include/pcpu_aux.h +++ /dev/null @@ -1,50 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD - * - * Copyright (c) 2019 The FreeBSD Foundation - * - * This software was developed by Konstantin Belousov - * under sponsorship from the FreeBSD Foundation. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD$ - */ - -#ifndef _MACHINE_PCPU_AUX_H_ -#define _MACHINE_PCPU_AUX_H_ - -#ifndef _KERNEL -#error "Not for userspace" -#endif - -#ifndef _SYS_PCPU_H_ -#error "Do not include machine/pcpu_aux.h directly" -#endif - -/* - * To minimize memory waste in per-cpu UMA zones, the page size should - * be a multiple of the size of struct pcpu. - */ -_Static_assert(PAGE_SIZE % sizeof(struct pcpu) == 0, "fix pcpu size"); - -#endif /* _MACHINE_PCPU_AUX_H_ */ diff --git a/sys/sparc64/include/pmap.h b/sys/sparc64/include/pmap.h deleted file mode 100644 index 8ad192782f8c..000000000000 --- a/sys/sparc64/include/pmap.h +++ /dev/null @@ -1,138 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-3-Clause - * - * Copyright (c) 1991 Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department and William Jolitz of UUNET Technologies Inc. - * - * 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. - * - * from: hp300: @(#)pmap.h 7.2 (Berkeley) 12/16/90 - * from: @(#)pmap.h 7.4 (Berkeley) 5/12/91 - * from: FreeBSD: src/sys/i386/include/pmap.h,v 1.70 2000/11/30 - * $FreeBSD$ - */ - -#ifndef _MACHINE_PMAP_H_ -#define _MACHINE_PMAP_H_ - -#include -#include -#include -#include -#include -#include -#include - -#define PMAP_CONTEXT_MAX 8192 -#define PMAP_ENTER_QUICK_LOCKED 0x10000000 - -typedef struct pmap *pmap_t; - -struct md_page { - TAILQ_HEAD(, tte) tte_list; - struct pmap *pmap; - uint32_t colors[DCACHE_COLORS]; - int32_t color; -}; - -struct pmap { - struct mtx pm_mtx; - struct tte *pm_tsb; - vm_object_t pm_tsb_obj; - cpuset_t pm_active; - u_int pm_context[MAXCPU]; - struct pmap_statistics pm_stats; -}; - -#define PMAP_LOCK(pmap) mtx_lock(&(pmap)->pm_mtx) -#define PMAP_LOCK_ASSERT(pmap, type) \ - mtx_assert(&(pmap)->pm_mtx, (type)) -#define PMAP_LOCK_DESTROY(pmap) mtx_destroy(&(pmap)->pm_mtx) -#define PMAP_LOCK_INIT(pmap) mtx_init(&(pmap)->pm_mtx, "pmap", \ - NULL, MTX_DEF | MTX_DUPOK) -#define PMAP_LOCKED(pmap) mtx_owned(&(pmap)->pm_mtx) -#define PMAP_MTX(pmap) (&(pmap)->pm_mtx) -#define PMAP_TRYLOCK(pmap) mtx_trylock(&(pmap)->pm_mtx) -#define PMAP_UNLOCK(pmap) mtx_unlock(&(pmap)->pm_mtx) - -#define pmap_page_get_memattr(m) VM_MEMATTR_DEFAULT -#define pmap_page_is_write_mapped(m) (((m)->a.flags & PGA_WRITEABLE) != 0) -#define pmap_page_set_memattr(m, ma) (void)0 - -void pmap_bootstrap(u_int cpu_impl); -vm_paddr_t pmap_kextract(vm_offset_t va); -void pmap_kenter(vm_offset_t va, vm_page_t m); -void pmap_kremove(vm_offset_t); -void pmap_kenter_flags(vm_offset_t va, vm_paddr_t pa, u_long flags); -void pmap_kremove_flags(vm_offset_t va); -boolean_t pmap_page_is_mapped(vm_page_t m); - -int pmap_cache_enter(vm_page_t m, vm_offset_t va); - -int pmap_remove_tte(struct pmap *pm1, struct pmap *pm2, struct tte *tp, - vm_offset_t va); - -void pmap_map_tsb(void); -void pmap_set_kctx(void); - -#define vtophys(va) pmap_kextract((vm_offset_t)(va)) - -extern struct pmap kernel_pmap_store; -#define kernel_pmap (&kernel_pmap_store) -extern struct rwlock_padalign tte_list_global_lock; -extern vm_offset_t virtual_avail; -extern vm_offset_t virtual_end; - -#ifdef PMAP_STATS - -SYSCTL_DECL(_debug_pmap_stats); - -#define PMAP_STATS_VAR(name) \ - static long name; \ - SYSCTL_LONG(_debug_pmap_stats, OID_AUTO, name, CTLFLAG_RW, \ - &name, 0, "") - -#define PMAP_STATS_INC(var) \ - atomic_add_long(&var, 1) - -#else - -#define PMAP_STATS_VAR(name) -#define PMAP_STATS_INC(var) - -#endif - -static inline int -pmap_vmspace_copy(pmap_t dst_pmap __unused, pmap_t src_pmap __unused) -{ - - return (0); -} - -#endif /* !_MACHINE_PMAP_H_ */ diff --git a/sys/sparc64/include/pmc_mdep.h b/sys/sparc64/include/pmc_mdep.h deleted file mode 100644 index 7ced0b9559e9..000000000000 --- a/sys/sparc64/include/pmc_mdep.h +++ /dev/null @@ -1,28 +0,0 @@ -/*- - * This file is in the public domain. - * - * $FreeBSD$ - */ - -#ifndef _MACHINE_PMC_MDEP_H_ -#define _MACHINE_PMC_MDEP_H_ - -union pmc_md_op_pmcallocate { - uint64_t __pad[4]; -}; - -/* Logging */ -#define PMCLOG_READADDR PMCLOG_READ64 -#define PMCLOG_EMITADDR PMCLOG_EMIT64 - -#if _KERNEL -union pmc_md_pmc { -}; - -#define PMC_TRAPFRAME_TO_PC(TF) (0) /* Stubs */ -#define PMC_TRAPFRAME_TO_FP(TF) (0) -#define PMC_TRAPFRAME_TO_SP(TF) (0) - -#endif - -#endif /* !_MACHINE_PMC_MDEP_H_ */ diff --git a/sys/sparc64/include/proc.h b/sys/sparc64/include/proc.h deleted file mode 100644 index a581f511bdb1..000000000000 --- a/sys/sparc64/include/proc.h +++ /dev/null @@ -1,80 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-3-Clause - * - * Copyright (c) 1991 Regents of the University of California. - * 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. - * 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. - * - * from: @(#)proc.h 7.1 (Berkeley) 5/15/91 - * from: FreeBSD: src/sys/i386/include/proc.h,v 1.11 2001/06/29 - * $FreeBSD$ - */ - -#ifndef _MACHINE_PROC_H_ -#define _MACHINE_PROC_H_ - -#include - -struct md_utrap { - utrap_entry_t *ut_precise[UT_MAX]; /* must be first */ - int ut_refcnt; -}; - -struct mdthread { - int md_spinlock_count; /* (k) */ - register_t md_saved_pil; /* (k) */ -}; - -struct mdproc { - struct md_utrap *md_utrap; - void *md_sigtramp; -}; - -#define KINFO_PROC_SIZE 1088 - -struct syscall_args { - u_int code; - struct sysent *callp; - register_t args[8]; - int narg; -}; - -#ifdef _KERNEL - -#include - -/* Get the current kernel thread stack usage. */ -#define GET_STACK_USAGE(total, used) do { \ - struct thread *td = curthread; \ - (total) = td->td_kstack_pages * PAGE_SIZE - sizeof(struct pcb); \ - (used) = (char *)td->td_kstack + \ - td->td_kstack_pages * PAGE_SIZE - \ - (char *)&td; \ -} while (0) - -#endif - -#endif /* !_MACHINE_PROC_H_ */ diff --git a/sys/sparc64/include/procctl.h b/sys/sparc64/include/procctl.h deleted file mode 100644 index 5221cfcd7be1..000000000000 --- a/sys/sparc64/include/procctl.h +++ /dev/null @@ -1,4 +0,0 @@ -/*- - * This file is in the public domain. - */ -/* $FreeBSD$ */ diff --git a/sys/sparc64/include/profile.h b/sys/sparc64/include/profile.h deleted file mode 100644 index 59cdec6b67c5..000000000000 --- a/sys/sparc64/include/profile.h +++ /dev/null @@ -1,104 +0,0 @@ -/*- - * SPDX-License-Identifier: MIT-CMU - * - * Copyright (c) 1994, 1995, 1996 Carnegie-Mellon University. - * All rights reserved. - * - * Author: Chris G. Demetriou - * - * Permission to use, copy, modify and distribute this software and - * its documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" - * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND - * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. - * - * Carnegie Mellon requests users of this software to return to - * - * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU - * School of Computer Science - * Carnegie Mellon University - * Pittsburgh PA 15213-3890 - * - * any improvements or extensions that they make and grant Carnegie the - * rights to redistribute these changes. - * - * from: NetBSD: profile.h,v 1.9 1997/04/06 08:47:37 cgd Exp - * from: FreeBSD: src/sys/alpha/include/profile.h,v 1.4 1999/12/29 - * $FreeBSD$ - */ - -#ifndef _MACHINE_PROFILE_H_ -#define _MACHINE_PROFILE_H_ - -#if !defined(_KERNEL) && !defined(_SYS_CDEFS_H_) -#error this file needs sys/cdefs.h as a prerequisite -#endif - -#define FUNCTION_ALIGNMENT 32 - -typedef u_long fptrdiff_t; - -#ifdef _KERNEL - -#include -#include - -#define _MCOUNT_DECL void mcount -#define MCOUNT - -#define MCOUNT_DECL(s) register_t s; -#define MCOUNT_ENTER(s) s = rdpr(pil); wrpr(pil, 0, PIL_TICK) -#define MCOUNT_EXIT(s) wrpr(pil, 0, s) - -void bintr(void); -void btrap(void); -void eintr(void); -void user(void); - -#define MCOUNT_FROMPC_USER(pc) \ - ((pc < (uintfptr_t)VM_MAXUSER_ADDRESS) ? (uintfptr_t)user : pc) - -#define MCOUNT_FROMPC_INTR(pc) \ - ((pc >= (uintfptr_t)btrap && pc < (uintfptr_t)eintr) ? \ - ((pc >= (uintfptr_t)bintr) ? (uintfptr_t)bintr : \ - (uintfptr_t)btrap) : ~0UL) - -void mcount(uintfptr_t frompc, uintfptr_t selfpc); - -#else /* !_KERNEL */ - -typedef u_long uintfptr_t; - -#define _MCOUNT_DECL static __inline void __mcount - -#ifdef __GNUCLIKE_ASM -#define MCOUNT \ -void \ -_mcount() \ -{ \ - uintfptr_t frompc, selfpc; \ - \ - /* \ - * Find the return address for mcount, \ - * and the return address for mcount's caller. \ - * \ - * selfpc = pc pushed by call to mcount \ - */ \ - __asm("add %%o7, 8, %0" : "=r" (selfpc)); \ - /* \ - * frompc = pc pushed by call to mcount's caller. \ - */ \ - __asm("add %%i7, 8, %0" : "=r" (frompc)); \ - __mcount(frompc, selfpc); \ -} -#else /* !__GNUCLIKE_ASM */ -#define MCOUNT -#endif /* __GNUCLIKE_ASM */ - -#endif /* _KERNEL */ - -#endif /* !_MACHINE_PROFILE_H_ */ diff --git a/sys/sparc64/include/pstate.h b/sys/sparc64/include/pstate.h deleted file mode 100644 index df3a25bd751b..000000000000 --- a/sys/sparc64/include/pstate.h +++ /dev/null @@ -1,65 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD - * - * Copyright (c) 2001 Jake Burkholder. - * 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$ - */ - -#ifndef _MACHINE_PSTATE_H_ -#define _MACHINE_PSTATE_H_ - -#define PSTATE_AG (1<<0) -#define PSTATE_IE (1<<1) -#define PSTATE_PRIV (1<<2) -#define PSTATE_AM (1<<3) -#define PSTATE_PEF (1<<4) -#define PSTATE_RED (1<<5) - -#define PSTATE_MM_SHIFT (6) -#define PSTATE_MM_SIZE (2) -#define PSTATE_MM_MASK (((1<. - * 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. - * 3. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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. - * - * $FreeBSD$ - */ diff --git a/sys/sparc64/include/resource.h b/sys/sparc64/include/resource.h deleted file mode 100644 index 229d14f253b0..000000000000 --- a/sys/sparc64/include/resource.h +++ /dev/null @@ -1,45 +0,0 @@ -/*- - * Copyright 1998 Massachusetts Institute of Technology - * - * Permission to use, copy, modify, and distribute this software and - * its documentation for any purpose and without fee is hereby - * granted, provided that both the above copyright notice and this - * permission notice appear in all copies, that both the above - * copyright notice and this permission notice appear in all - * supporting documentation, and that the name of M.I.T. not be used - * in advertising or publicity pertaining to distribution of the - * software without specific, written prior permission. M.I.T. makes - * no representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied - * warranty. - * - * THIS SOFTWARE IS PROVIDED BY M.I.T. ``AS IS''. M.I.T. DISCLAIMS - * ALL EXPRESS OR IMPLIED WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT - * SHALL M.I.T. BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD$ - */ - -#ifndef _MACHINE_RESOURCE_H_ -#define _MACHINE_RESOURCE_H_ 1 - -/* - * Definitions of resource types for Intel Architecture machines - * with support for legacy ISA devices and drivers. - */ - -#define SYS_RES_IRQ 1 /* interrupt lines */ -#define SYS_RES_DRQ 2 /* isa dma lines */ -#define SYS_RES_MEMORY 3 /* i/o memory */ -#define SYS_RES_IOPORT 4 /* i/o ports */ - -#endif /* !_MACHINE_RESOURCE_H_ */ diff --git a/sys/sparc64/include/runq.h b/sys/sparc64/include/runq.h deleted file mode 100644 index 1fb8d1bdcfe6..000000000000 --- a/sys/sparc64/include/runq.h +++ /dev/null @@ -1,60 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD - * - * Copyright (c) 2001 Jake Burkholder - * 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$ - */ - -#ifndef _MACHINE_RUNQ_H_ -#define _MACHINE_RUNQ_H_ - -#define RQB_LEN (1UL) /* Number of priority status words. */ -#define RQB_L2BPW (6UL) /* Log2(sizeof(rqb_word_t) * NBBY)). */ -#define RQB_BPW (1UL<> RQB_L2BPW) - -#define RQB_FFS(word) (ffs64(word) - 1) - -/* - * Type of run queue status word. - */ -typedef u_int64_t rqb_word_t; - -static __inline u_long -ffs64(u_long mask) -{ - u_long bit; - - if (mask == 0) - return (0); - for (bit = 1; (mask & 1UL) == 0; bit++) - mask >>= 1UL; - return (bit); -} - -#endif diff --git a/sys/sparc64/include/sc_machdep.h b/sys/sparc64/include/sc_machdep.h deleted file mode 100644 index d50ef4867f7b..000000000000 --- a/sys/sparc64/include/sc_machdep.h +++ /dev/null @@ -1,78 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD - * - * Copyright (c) 2003 Jake Burkholder. - * 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$ - */ - -#ifndef _MACHINE_SC_MACHDEP_H_ -#define _MACHINE_SC_MACHDEP_H_ - -/* Color attributes for foreground text */ - -#define FG_BLACK 0x0 -#define FG_BLUE 0x1 -#define FG_GREEN 0x2 -#define FG_CYAN 0x3 -#define FG_RED 0x4 -#define FG_MAGENTA 0x5 -#define FG_BROWN 0x6 -#define FG_LIGHTGREY 0x7 -#define FG_DARKGREY 0x8 -#define FG_LIGHTBLUE 0x9 -#define FG_LIGHTGREEN 0xa -#define FG_LIGHTCYAN 0xb -#define FG_LIGHTRED 0xc -#define FG_LIGHTMAGENTA 0xd -#define FG_YELLOW 0xe -#define FG_WHITE 0xf -#define FG_BLINK 0x80 - -/* Color attributes for text background */ - -#define BG_BLACK 0x00 -#define BG_BLUE 0x10 -#define BG_GREEN 0x20 -#define BG_CYAN 0x30 -#define BG_RED 0x40 -#define BG_MAGENTA 0x50 -#define BG_BROWN 0x60 -#define BG_LIGHTGREY 0x70 -#define BG_DARKGREY 0x80 -#define BG_LIGHTBLUE 0x90 -#define BG_LIGHTGREEN 0xa0 -#define BG_LIGHTCYAN 0xb0 -#define BG_LIGHTRED 0xc0 -#define BG_LIGHTMAGENTA 0xd0 -#define BG_YELLOW 0xe0 -#define BG_WHITE 0xf0 - -#define SC_NORM_ATTR (FG_BLACK | BG_WHITE) -#define SC_NORM_REV_ATTR (FG_WHITE | BG_BLACK) -#define SC_KERNEL_CONS_ATTR (FG_BLACK | BG_WHITE) -#define SC_KERNEL_CONS_REV_ATTR (FG_WHITE | BG_BLACK) - -#endif /* !_MACHINE_SC_MACHDEP_H_ */ diff --git a/sys/sparc64/include/setjmp.h b/sys/sparc64/include/setjmp.h deleted file mode 100644 index 12035418cbbe..000000000000 --- a/sys/sparc64/include/setjmp.h +++ /dev/null @@ -1,59 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-3-Clause - * - * Copyright (c) 1998 John Birrell . - * 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. - * 3. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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. - * - * From: FreeBSD: src/sys/i386/include/setjmp.h,v 1.5 2000/10/06 - * $FreeBSD$ - */ - -#ifndef _MACHINE_SETJMP_H_ -#define _MACHINE_SETJMP_H_ - -#include - -#define _JBLEN 5 - -#define _JB_FP 0 -#define _JB_PC 1 -#define _JB_SP 2 -#define _JB_SIGMASK 3 -#define _JB_SIGFLAG 5 - -/* - * jmp_buf and sigjmp_buf are encapsulated in different structs to force - * compile-time diagnostics for mismatches. The structs are the same - * internally to avoid some run-time errors for mismatches. - */ -#if __BSD_VISIBLE || __POSIX_VISIBLE || __XSI_VISIBLE -typedef struct _sigjmp_buf { long _sjb[_JBLEN + 1]; } sigjmp_buf[1]; -#endif - -typedef struct _jmp_buf { long _jb[_JBLEN + 1]; } jmp_buf[1]; - -#endif /* !_MACHINE_SETJMP_H_ */ diff --git a/sys/sparc64/include/sf_buf.h b/sys/sparc64/include/sf_buf.h deleted file mode 100644 index 10bbd888b592..000000000000 --- a/sys/sparc64/include/sf_buf.h +++ /dev/null @@ -1,37 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD - * - * Copyright (c) 2014 Gleb Smirnoff - * 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$ - */ - -#ifndef _MACHINE_SF_BUF_H_ -#define _MACHINE_SF_BUF_H_ - -void sf_buf_map(struct sf_buf *, int); -int sf_buf_unmap(struct sf_buf *); - -#endif /* !_MACHINE_SF_BUF_H_ */ diff --git a/sys/sparc64/include/sigframe.h b/sys/sparc64/include/sigframe.h deleted file mode 100644 index b52238785d46..000000000000 --- a/sys/sparc64/include/sigframe.h +++ /dev/null @@ -1,42 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-3-Clause - * - * Copyright (c) 1999 Marcel Moolenaar - * 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 - * in this position and unchanged. - * 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. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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. - * - * from: FreeBSD: src/sys/alpha/include/sigframe.h,v 1.1 1999/09/29 - * $FreeBSD$ - */ - -#ifndef _MACHINE_SIGFRAME_H_ -#define _MACHINE_SIGFRAME_H_ 1 - -struct sigframe { - ucontext_t sf_uc; - siginfo_t sf_si; -}; - -#endif /* _MACHINE_SIGFRAME_H_ */ diff --git a/sys/sparc64/include/signal.h b/sys/sparc64/include/signal.h deleted file mode 100644 index f0df6f512810..000000000000 --- a/sys/sparc64/include/signal.h +++ /dev/null @@ -1,49 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-3-Clause - * - * Copyright (c) 1986, 1989, 1991, 1993 - * The Regents of the University of California. 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. - * 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. - * - * @(#)signal.h 8.1 (Berkeley) 6/11/93 - * from: FreeBSD: src/sys/i386/include/signal.h,v 1.13 2000/11/09 - * $FreeBSD$ - */ - -#ifndef _MACHINE_SIGNAL_H_ -#define _MACHINE_SIGNAL_H_ - -#include - -typedef long sig_atomic_t; - -#if __BSD_VISIBLE -struct sigcontext { - int _dummy; -}; -#endif /* __BSD_VISIBLE */ - -#endif /* !_MACHINE_SIGNAL_H_ */ diff --git a/sys/sparc64/include/smp.h b/sys/sparc64/include/smp.h deleted file mode 100644 index 18b8d97268f8..000000000000 --- a/sys/sparc64/include/smp.h +++ /dev/null @@ -1,404 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD - * - * Copyright (c) 2001 Jake Burkholder. - * Copyright (c) 2007 - 2011 Marius Strobl - * 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$ - */ - -#ifndef _MACHINE_SMP_H_ -#define _MACHINE_SMP_H_ - -#ifdef SMP - -#define CPU_TICKSYNC 1 -#define CPU_STICKSYNC 2 -#define CPU_INIT 3 -#define CPU_BOOTSTRAP 4 - -#ifndef LOCORE - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#define IDR_BUSY 0x0000000000000001ULL -#define IDR_NACK 0x0000000000000002ULL -#define IDR_CHEETAH_ALL_BUSY 0x5555555555555555ULL -#define IDR_CHEETAH_ALL_NACK (~IDR_CHEETAH_ALL_BUSY) -#define IDR_CHEETAH_MAX_BN_PAIRS 32 -#define IDR_JALAPENO_MAX_BN_PAIRS 4 - -#define IDC_ITID_SHIFT 14 -#define IDC_BN_SHIFT 24 - -#define IPI_AST PIL_AST -#define IPI_RENDEZVOUS PIL_RENDEZVOUS -#define IPI_PREEMPT PIL_PREEMPT -#define IPI_HARDCLOCK PIL_HARDCLOCK -#define IPI_STOP PIL_STOP -#define IPI_STOP_HARD PIL_STOP - -#define IPI_RETRIES 5000 - -struct cpu_start_args { - u_int csa_count; - u_int csa_mid; - u_int csa_state; - vm_offset_t csa_pcpu; - u_long csa_tick; - u_long csa_stick; - u_long csa_ver; - struct tte csa_ttes[PCPU_PAGES]; -}; - -struct ipi_cache_args { - cpuset_t ica_mask; - vm_paddr_t ica_pa; -}; - -struct ipi_rd_args { - cpuset_t ira_mask; - register_t *ira_val; -}; - -struct ipi_tlb_args { - cpuset_t ita_mask; - struct pmap *ita_pmap; - u_long ita_start; - u_long ita_end; -}; -#define ita_va ita_start - -struct pcb; -struct pcpu; - -extern struct pcb stoppcbs[]; - -void cpu_mp_bootstrap(struct pcpu *pc); -void cpu_mp_shutdown(void); - -typedef void cpu_ipi_selected_t(cpuset_t, u_long, u_long, u_long); -extern cpu_ipi_selected_t *cpu_ipi_selected; -typedef void cpu_ipi_single_t(u_int, u_long, u_long, u_long); -extern cpu_ipi_single_t *cpu_ipi_single; - -void mp_init(void); - -extern struct mtx ipi_mtx; -extern struct ipi_cache_args ipi_cache_args; -extern struct ipi_rd_args ipi_rd_args; -extern struct ipi_tlb_args ipi_tlb_args; - -extern char *mp_tramp_code; -extern u_long mp_tramp_code_len; -extern u_long mp_tramp_tlb_slots; -extern u_long mp_tramp_func; - -extern void mp_startup(void); - -extern char tl_ipi_cheetah_dcache_page_inval[]; -extern char tl_ipi_spitfire_dcache_page_inval[]; -extern char tl_ipi_spitfire_icache_page_inval[]; - -extern char tl_ipi_level[]; - -extern char tl_ipi_stick_rd[]; -extern char tl_ipi_tick_rd[]; - -extern char tl_ipi_tlb_context_demap[]; -extern char tl_ipi_tlb_page_demap[]; -extern char tl_ipi_tlb_range_demap[]; - -static __inline void -ipi_all_but_self(u_int ipi) -{ - cpuset_t cpus; - - if (__predict_false(atomic_load_acq_int(&smp_started) == 0)) - return; - cpus = all_cpus; - sched_pin(); - CPU_CLR(PCPU_GET(cpuid), &cpus); - mtx_lock_spin(&ipi_mtx); - cpu_ipi_selected(cpus, 0, (u_long)tl_ipi_level, ipi); - mtx_unlock_spin(&ipi_mtx); - sched_unpin(); -} - -static __inline void -ipi_selected(cpuset_t cpus, u_int ipi) -{ - - if (__predict_false(atomic_load_acq_int(&smp_started) == 0 || - CPU_EMPTY(&cpus))) - return; - mtx_lock_spin(&ipi_mtx); - cpu_ipi_selected(cpus, 0, (u_long)tl_ipi_level, ipi); - mtx_unlock_spin(&ipi_mtx); -} - -static __inline void -ipi_cpu(int cpu, u_int ipi) -{ - - if (__predict_false(atomic_load_acq_int(&smp_started) == 0)) - return; - mtx_lock_spin(&ipi_mtx); - cpu_ipi_single(cpu, 0, (u_long)tl_ipi_level, ipi); - mtx_unlock_spin(&ipi_mtx); -} - -#if defined(_MACHINE_PMAP_H_) && defined(_SYS_MUTEX_H_) - -static __inline void * -ipi_dcache_page_inval(void *func, vm_paddr_t pa) -{ - struct ipi_cache_args *ica; - - if (__predict_false(atomic_load_acq_int(&smp_started) == 0)) - return (NULL); - sched_pin(); - ica = &ipi_cache_args; - mtx_lock_spin(&ipi_mtx); - ica->ica_mask = all_cpus; - CPU_CLR(PCPU_GET(cpuid), &ica->ica_mask); - ica->ica_pa = pa; - cpu_ipi_selected(ica->ica_mask, 0, (u_long)func, (u_long)ica); - return (&ica->ica_mask); -} - -static __inline void * -ipi_icache_page_inval(void *func, vm_paddr_t pa) -{ - struct ipi_cache_args *ica; - - if (__predict_false(atomic_load_acq_int(&smp_started) == 0)) - return (NULL); - sched_pin(); - ica = &ipi_cache_args; - mtx_lock_spin(&ipi_mtx); - ica->ica_mask = all_cpus; - CPU_CLR(PCPU_GET(cpuid), &ica->ica_mask); - ica->ica_pa = pa; - cpu_ipi_selected(ica->ica_mask, 0, (u_long)func, (u_long)ica); - return (&ica->ica_mask); -} - -static __inline void * -ipi_rd(u_int cpu, void *func, u_long *val) -{ - struct ipi_rd_args *ira; - - if (__predict_false(atomic_load_acq_int(&smp_started) == 0)) - return (NULL); - sched_pin(); - ira = &ipi_rd_args; - mtx_lock_spin(&ipi_mtx); - CPU_SETOF(cpu, &ira->ira_mask); - ira->ira_val = val; - cpu_ipi_single(cpu, 0, (u_long)func, (u_long)ira); - return (&ira->ira_mask); -} - -static __inline void * -ipi_tlb_context_demap(struct pmap *pm) -{ - struct ipi_tlb_args *ita; - cpuset_t cpus; - - if (__predict_false(atomic_load_acq_int(&smp_started) == 0)) - return (NULL); - sched_pin(); - cpus = pm->pm_active; - CPU_AND(&cpus, &all_cpus); - CPU_CLR(PCPU_GET(cpuid), &cpus); - if (CPU_EMPTY(&cpus)) { - sched_unpin(); - return (NULL); - } - ita = &ipi_tlb_args; - mtx_lock_spin(&ipi_mtx); - ita->ita_mask = cpus; - ita->ita_pmap = pm; - cpu_ipi_selected(cpus, 0, (u_long)tl_ipi_tlb_context_demap, - (u_long)ita); - return (&ita->ita_mask); -} - -static __inline void * -ipi_tlb_page_demap(struct pmap *pm, vm_offset_t va) -{ - struct ipi_tlb_args *ita; - cpuset_t cpus; - - if (__predict_false(atomic_load_acq_int(&smp_started) == 0)) - return (NULL); - sched_pin(); - cpus = pm->pm_active; - CPU_AND(&cpus, &all_cpus); - CPU_CLR(PCPU_GET(cpuid), &cpus); - if (CPU_EMPTY(&cpus)) { - sched_unpin(); - return (NULL); - } - ita = &ipi_tlb_args; - mtx_lock_spin(&ipi_mtx); - ita->ita_mask = cpus; - ita->ita_pmap = pm; - ita->ita_va = va; - cpu_ipi_selected(cpus, 0, (u_long)tl_ipi_tlb_page_demap, (u_long)ita); - return (&ita->ita_mask); -} - -static __inline void * -ipi_tlb_range_demap(struct pmap *pm, vm_offset_t start, vm_offset_t end) -{ - struct ipi_tlb_args *ita; - cpuset_t cpus; - - if (__predict_false(atomic_load_acq_int(&smp_started) == 0)) - return (NULL); - sched_pin(); - cpus = pm->pm_active; - CPU_AND(&cpus, &all_cpus); - CPU_CLR(PCPU_GET(cpuid), &cpus); - if (CPU_EMPTY(&cpus)) { - sched_unpin(); - return (NULL); - } - ita = &ipi_tlb_args; - mtx_lock_spin(&ipi_mtx); - ita->ita_mask = cpus; - ita->ita_pmap = pm; - ita->ita_start = start; - ita->ita_end = end; - cpu_ipi_selected(cpus, 0, (u_long)tl_ipi_tlb_range_demap, - (u_long)ita); - return (&ita->ita_mask); -} - -static __inline void -ipi_wait(void *cookie) -{ - volatile cpuset_t *mask; - - if (__predict_false((mask = cookie) != NULL)) { - while (!CPU_EMPTY(mask)) - ; - mtx_unlock_spin(&ipi_mtx); - sched_unpin(); - } -} - -#endif /* _MACHINE_PMAP_H_ && _SYS_MUTEX_H_ */ - -#endif /* !LOCORE */ - -#else - -#ifndef LOCORE - -static __inline void * -ipi_dcache_page_inval(void *func __unused, vm_paddr_t pa __unused) -{ - - return (NULL); -} - -static __inline void * -ipi_icache_page_inval(void *func __unused, vm_paddr_t pa __unused) -{ - - return (NULL); -} - -static __inline void * -ipi_rd(u_int cpu __unused, void *func __unused, u_long *val __unused) -{ - - return (NULL); -} - -static __inline void * -ipi_tlb_context_demap(struct pmap *pm __unused) -{ - - return (NULL); -} - -static __inline void * -ipi_tlb_page_demap(struct pmap *pm __unused, vm_offset_t va __unused) -{ - - return (NULL); -} - -static __inline void * -ipi_tlb_range_demap(struct pmap *pm __unused, vm_offset_t start __unused, - __unused vm_offset_t end) -{ - - return (NULL); -} - -static __inline void -ipi_wait(void *cookie __unused) -{ - -} - -static __inline void -tl_ipi_cheetah_dcache_page_inval(void) -{ - -} - -static __inline void -tl_ipi_spitfire_dcache_page_inval(void) -{ - -} - -static __inline void -tl_ipi_spitfire_icache_page_inval(void) -{ - -} - -#endif /* !LOCORE */ - -#endif /* SMP */ - -#endif /* !_MACHINE_SMP_H_ */ diff --git a/sys/sparc64/include/stack.h b/sys/sparc64/include/stack.h deleted file mode 100644 index a553a7a14314..000000000000 --- a/sys/sparc64/include/stack.h +++ /dev/null @@ -1,42 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD - * - * Copyright (c) 2001 Jake Burkholder. - * 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$ - */ - -#ifndef _MACHINE_STACK_H_ -#define _MACHINE_STACK_H_ - -extern char tl_trap_begin[]; -extern char tl_trap_end[]; -extern char tl_text_begin[]; -extern char tl_text_end[]; - -#define INKERNEL(va) \ - ((va) >= VM_MIN_KERNEL_ADDRESS && (va) <= VM_MAX_KERNEL_ADDRESS) - -#endif /* !_MACHINE_STACK_H_ */ diff --git a/sys/sparc64/include/stdarg.h b/sys/sparc64/include/stdarg.h deleted file mode 100644 index acb526429ac2..000000000000 --- a/sys/sparc64/include/stdarg.h +++ /dev/null @@ -1,39 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause - * - * Copyright (c) 2017 Poul-Henning Kamp. 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$ - */ - -#ifndef _MACHINE_STDARG_H_ -#define _MACHINE_STDARG_H_ - -#include - -#ifndef va_start - #error this file needs to be ported to your compiler -#endif - -#endif /* !_MACHINE_STDARG_H_ */ diff --git a/sys/sparc64/include/sysarch.h b/sys/sparc64/include/sysarch.h deleted file mode 100644 index fefaeb326868..000000000000 --- a/sys/sparc64/include/sysarch.h +++ /dev/null @@ -1,76 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-3-Clause - * - * Copyright (c) 1993 The Regents of the University of California. - * 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. - * 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. - * - * from: FreeBSD: src/sys/i386/include/sysarch.h,v 1.14 2000/09/21 - * $FreeBSD$ - */ - -/* - * Architecture specific syscalls (sparc64) - */ -#ifndef _MACHINE_SYSARCH_H_ -#define _MACHINE_SYSARCH_H_ - -#include - -#define SPARC_UTRAP_INSTALL 1 -#define SPARC_SIGTRAMP_INSTALL 2 - -struct sparc_utrap_install_args { - int num; - const struct sparc_utrap_args *handlers; -}; - -struct sparc_sigtramp_install_args { - void *sia_new; - void **sia_old; -}; - -struct sparc_utrap_args { - utrap_entry_t type; - utrap_handler_t new_precise; - utrap_handler_t new_deferred; - utrap_handler_t *old_precise; - utrap_handler_t *old_deferred; -}; - -#ifndef _KERNEL -#include - -__BEGIN_DECLS -int __sparc_utrap_install(utrap_entry_t _type, - utrap_handler_t _new_precise, utrap_handler_t _new_deferred, - utrap_handler_t *_old_precise, utrap_handler_t *_old_deferred); -int sysarch(int _number, void *_args); -__END_DECLS - -#endif - -#endif /* !_MACHINE_SYSARCH_H_ */ diff --git a/sys/sparc64/include/tick.h b/sys/sparc64/include/tick.h deleted file mode 100644 index 44ed91dd972f..000000000000 --- a/sys/sparc64/include/tick.h +++ /dev/null @@ -1,39 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD - * - * Copyright (c) 2001 Jake Burkholder. - * 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$ - */ - -#ifndef _MACHINE_TICK_H_ -#define _MACHINE_TICK_H_ - -extern u_int tick_et_use_stick; - -void tick_clear(u_int cpu_impl); -void tick_stop(u_int cpu_impl); - -#endif diff --git a/sys/sparc64/include/tlb.h b/sys/sparc64/include/tlb.h deleted file mode 100644 index 7ee4101ea8ab..000000000000 --- a/sys/sparc64/include/tlb.h +++ /dev/null @@ -1,177 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD - * - * Copyright (c) 2001 Jake Burkholder. - * Copyright (c) 2008, 2010 Marius Strobl - * 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$ - */ - -#ifndef _MACHINE_TLB_H_ -#define _MACHINE_TLB_H_ - -#define TLB_DIRECT_ADDRESS_BITS (43) -#define TLB_DIRECT_PAGE_BITS (PAGE_SHIFT_4M) - -#define TLB_DIRECT_ADDRESS_MASK ((1UL << TLB_DIRECT_ADDRESS_BITS) - 1) -#define TLB_DIRECT_PAGE_MASK ((1UL << TLB_DIRECT_PAGE_BITS) - 1) - -#define TLB_PHYS_TO_DIRECT(pa) \ - ((pa) | VM_MIN_DIRECT_ADDRESS) -#define TLB_DIRECT_TO_PHYS(va) \ - ((va) & TLB_DIRECT_ADDRESS_MASK) -#define TLB_DIRECT_TO_TTE_MASK \ - (TD_V | TD_4M | (TLB_DIRECT_ADDRESS_MASK - TLB_DIRECT_PAGE_MASK)) - -#define TLB_DAR_SLOT_SHIFT (3) -#define TLB_DAR_TLB_SHIFT (16) -#define TLB_DAR_SLOT(tlb, slot) \ - ((tlb) << TLB_DAR_TLB_SHIFT | (slot) << TLB_DAR_SLOT_SHIFT) -#define TLB_DAR_T16 (0) /* US-III{,i,+}, IV{,+} */ -#define TLB_DAR_T32 (0) /* US-I, II{,e,i} */ -#define TLB_DAR_DT512_0 (2) /* US-III{,i,+}, IV{,+} */ -#define TLB_DAR_DT512_1 (3) /* US-III{,i,+}, IV{,+} */ -#define TLB_DAR_IT128 (2) /* US-III{,i,+}, IV */ -#define TLB_DAR_IT512 (2) /* US-IV+ */ -#define TLB_DAR_FTLB (0) /* SPARC64 V, VI, VII, VIIIfx */ -#define TLB_DAR_STLB (2) /* SPARC64 V, VI, VII, VIIIfx */ - -#define TAR_VPN_SHIFT (13) -#define TAR_CTX_MASK ((1 << TAR_VPN_SHIFT) - 1) - -#define TLB_TAR_VA(va) ((va) & ~TAR_CTX_MASK) -#define TLB_TAR_CTX(ctx) ((ctx) & TAR_CTX_MASK) - -#define TLB_CXR_CTX_BITS (13) -#define TLB_CXR_CTX_MASK \ - (((1UL << TLB_CXR_CTX_BITS) - 1) << TLB_CXR_CTX_SHIFT) -#define TLB_CXR_CTX_SHIFT (0) -#define TLB_CXR_PGSZ_BITS (3) -#define TLB_CXR_PGSZ_MASK (~TLB_CXR_CTX_MASK) -#define TLB_PCXR_N_IPGSZ0_SHIFT (53) /* SPARC64 VI, VII, VIIIfx */ -#define TLB_PCXR_N_IPGSZ1_SHIFT (50) /* SPARC64 VI, VII, VIIIfx */ -#define TLB_PCXR_N_PGSZ0_SHIFT (61) -#define TLB_PCXR_N_PGSZ1_SHIFT (58) -#define TLB_PCXR_N_PGSZ_I_SHIFT (55) /* US-IV+ */ -#define TLB_PCXR_P_IPGSZ0_SHIFT (24) /* SPARC64 VI, VII, VIIIfx */ -#define TLB_PCXR_P_IPGSZ1_SHIFT (27) /* SPARC64 VI, VII, VIIIfx */ -#define TLB_PCXR_P_PGSZ0_SHIFT (16) -#define TLB_PCXR_P_PGSZ1_SHIFT (19) -/* - * Note that the US-IV+ documentation appears to have TLB_PCXR_P_PGSZ_I_SHIFT - * and TLB_PCXR_P_PGSZ0_SHIFT erroneously inverted. - */ -#define TLB_PCXR_P_PGSZ_I_SHIFT (22) /* US-IV+ */ -#define TLB_SCXR_S_PGSZ1_SHIFT (19) -#define TLB_SCXR_S_PGSZ0_SHIFT (16) - -#define TLB_TAE_PGSZ_BITS (3) -#define TLB_TAE_PGSZ0_MASK \ - (((1UL << TLB_TAE_PGSZ_BITS) - 1) << TLB_TAE_PGSZ0_SHIFT) -#define TLB_TAE_PGSZ1_MASK \ - (((1UL << TLB_TAE_PGSZ_BITS) - 1) << TLB_TAE_PGSZ1_SHIFT) -#define TLB_TAE_PGSZ0_SHIFT (16) -#define TLB_TAE_PGSZ1_SHIFT (19) - -#define TLB_DEMAP_ID_SHIFT (4) -#define TLB_DEMAP_ID_PRIMARY (0) -#define TLB_DEMAP_ID_SECONDARY (1) -#define TLB_DEMAP_ID_NUCLEUS (2) - -#define TLB_DEMAP_TYPE_SHIFT (6) -#define TLB_DEMAP_TYPE_PAGE (0) -#define TLB_DEMAP_TYPE_CONTEXT (1) -#define TLB_DEMAP_TYPE_ALL (2) /* US-III and beyond only */ - -#define TLB_DEMAP_VA(va) ((va) & ~PAGE_MASK) -#define TLB_DEMAP_ID(id) ((id) << TLB_DEMAP_ID_SHIFT) -#define TLB_DEMAP_TYPE(type) ((type) << TLB_DEMAP_TYPE_SHIFT) - -#define TLB_DEMAP_PAGE (TLB_DEMAP_TYPE(TLB_DEMAP_TYPE_PAGE)) -#define TLB_DEMAP_CONTEXT (TLB_DEMAP_TYPE(TLB_DEMAP_TYPE_CONTEXT)) -#define TLB_DEMAP_ALL (TLB_DEMAP_TYPE(TLB_DEMAP_TYPE_ALL)) - -#define TLB_DEMAP_PRIMARY (TLB_DEMAP_ID(TLB_DEMAP_ID_PRIMARY)) -#define TLB_DEMAP_SECONDARY (TLB_DEMAP_ID(TLB_DEMAP_ID_SECONDARY)) -#define TLB_DEMAP_NUCLEUS (TLB_DEMAP_ID(TLB_DEMAP_ID_NUCLEUS)) - -#define TLB_CTX_KERNEL (0) -#define TLB_CTX_USER_MIN (1) -#define TLB_CTX_USER_MAX (8192) - -#define MMU_SFSR_ASI_SHIFT (16) -#define MMU_SFSR_FT_SHIFT (7) -#define MMU_SFSR_E_SHIFT (6) -#define MMU_SFSR_CT_SHIFT (4) -#define MMU_SFSR_PR_SHIFT (3) -#define MMU_SFSR_W_SHIFT (2) -#define MMU_SFSR_OW_SHIFT (1) -#define MMU_SFSR_FV_SHIFT (0) - -#define MMU_SFSR_ASI_SIZE (8) -#define MMU_SFSR_FT_SIZE (6) -#define MMU_SFSR_CT_SIZE (2) - -#define MMU_SFSR_GET_ASI(sfsr) \ - (((sfsr) >> MMU_SFSR_ASI_SHIFT) & ((1UL << MMU_SFSR_ASI_SIZE) - 1)) -#define MMU_SFSR_GET_FT(sfsr) \ - (((sfsr) >> MMU_SFSR_FT_SHIFT) & ((1UL << MMU_SFSR_FT_SIZE) - 1)) -#define MMU_SFSR_GET_CT(sfsr) \ - (((sfsr) >> MMU_SFSR_CT_SHIFT) & ((1UL << MMU_SFSR_CT_SIZE) - 1)) - -#define MMU_SFSR_E (1UL << MMU_SFSR_E_SHIFT) -#define MMU_SFSR_PR (1UL << MMU_SFSR_PR_SHIFT) -#define MMU_SFSR_W (1UL << MMU_SFSR_W_SHIFT) -#define MMU_SFSR_OW (1UL << MMU_SFSR_OW_SHIFT) -#define MMU_SFSR_FV (1UL << MMU_SFSR_FV_SHIFT) - -typedef void tlb_flush_nonlocked_t(void); -typedef void tlb_flush_user_t(void); - -struct pmap; -struct tlb_entry; - -extern int dtlb_slots; -extern int itlb_slots; -extern int kernel_tlb_slots; -extern struct tlb_entry *kernel_tlbs; - -void tlb_context_demap(struct pmap *pm); -void tlb_page_demap(struct pmap *pm, vm_offset_t va); -void tlb_range_demap(struct pmap *pm, vm_offset_t start, vm_offset_t end); - -tlb_flush_nonlocked_t cheetah_tlb_flush_nonlocked; -tlb_flush_user_t cheetah_tlb_flush_user; - -tlb_flush_nonlocked_t spitfire_tlb_flush_nonlocked; -tlb_flush_user_t spitfire_tlb_flush_user; - -tlb_flush_nonlocked_t zeus_tlb_flush_nonlocked; -tlb_flush_user_t zeus_tlb_flush_user; - -extern tlb_flush_nonlocked_t *tlb_flush_nonlocked; -extern tlb_flush_user_t *tlb_flush_user; - -#endif /* !_MACHINE_TLB_H_ */ diff --git a/sys/sparc64/include/trap.h b/sys/sparc64/include/trap.h deleted file mode 100644 index 84d01f0750df..000000000000 --- a/sys/sparc64/include/trap.h +++ /dev/null @@ -1,101 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD - * - * Copyright (c) 2001 Jake Burkholder. - * 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$ - */ - -#ifndef _MACHINE_TRAP_H_ -#define _MACHINE_TRAP_H_ - -#ifdef _KERNEL - -#define T_RESERVED 0 -#define T_INSTRUCTION_EXCEPTION 1 -#define T_INSTRUCTION_ERROR 2 -#define T_INSTRUCTION_PROTECTION 3 -#define T_ILLTRAP_INSTRUCTION 4 -#define T_ILLEGAL_INSTRUCTION 5 -#define T_PRIVILEGED_OPCODE 6 -#define T_FP_DISABLED 7 -#define T_FP_EXCEPTION_IEEE_754 8 -#define T_FP_EXCEPTION_OTHER 9 -#define T_TAG_OVERFLOW 10 -#define T_DIVISION_BY_ZERO 11 -#define T_DATA_EXCEPTION 12 -#define T_DATA_ERROR 13 -#define T_DATA_PROTECTION 14 -#define T_MEM_ADDRESS_NOT_ALIGNED 15 -#define T_PRIVILEGED_ACTION 16 -#define T_ASYNC_DATA_ERROR 17 -#define T_TRAP_INSTRUCTION_16 18 -#define T_TRAP_INSTRUCTION_17 19 -#define T_TRAP_INSTRUCTION_18 20 -#define T_TRAP_INSTRUCTION_19 21 -#define T_TRAP_INSTRUCTION_20 22 -#define T_TRAP_INSTRUCTION_21 23 -#define T_TRAP_INSTRUCTION_22 24 -#define T_TRAP_INSTRUCTION_23 25 -#define T_TRAP_INSTRUCTION_24 26 -#define T_TRAP_INSTRUCTION_25 27 -#define T_TRAP_INSTRUCTION_26 28 -#define T_TRAP_INSTRUCTION_27 29 -#define T_TRAP_INSTRUCTION_28 30 -#define T_TRAP_INSTRUCTION_29 31 -#define T_TRAP_INSTRUCTION_30 32 -#define T_TRAP_INSTRUCTION_31 33 -#define T_INSTRUCTION_MISS 34 -#define T_DATA_MISS 35 - -#define T_INTERRUPT 36 -#define T_PA_WATCHPOINT 37 -#define T_VA_WATCHPOINT 38 -#define T_CORRECTED_ECC_ERROR 39 -#define T_SPILL 40 -#define T_FILL 41 -#define T_FILL_RET 42 -#define T_BREAKPOINT 43 -#define T_CLEAN_WINDOW 44 -#define T_RANGE_CHECK 45 -#define T_FIX_ALIGNMENT 46 -#define T_INTEGER_OVERFLOW 47 -#define T_SYSCALL 48 -#define T_RSTRWP_PHYS 49 -#define T_RSTRWP_VIRT 50 -#define T_KSTACK_FAULT 51 - -#define T_MAX (T_KSTACK_FAULT + 1) - -#define T_KERNEL 64 - -#ifndef LOCORE -void sun4u_set_traptable(void *tba_addr); -extern const char *const trap_msg[]; -#endif - -#endif - -#endif /* !_MACHINE_TRAP_H_ */ diff --git a/sys/sparc64/include/tsb.h b/sys/sparc64/include/tsb.h deleted file mode 100644 index a13b331a1db4..000000000000 --- a/sys/sparc64/include/tsb.h +++ /dev/null @@ -1,97 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-3-Clause - * - * Copyright (c) 1997 Berkeley Software Design, Inc. 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. - * 3. Berkeley Software Design Inc's name may not be used to endorse or - * promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY BERKELEY SOFTWARE DESIGN INC ``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 BERKELEY SOFTWARE DESIGN INC 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. - * - * from: BSDI: pmap.v9.h,v 1.10.2.6 1999/08/23 22:18:44 cp Exp - * $FreeBSD$ - */ - -#ifndef _MACHINE_TSB_H_ -#define _MACHINE_TSB_H_ - -#define TSB_PAGES_SHIFT (4) -#define TSB_PAGES (1 << TSB_PAGES_SHIFT) -#define TSB_BSHIFT (TSB_PAGES_SHIFT + PAGE_SHIFT) -#define TSB_BSIZE (1 << TSB_BSHIFT) -#define TSB_BUCKET_SHIFT (2) -#define TSB_BUCKET_SIZE (1 << TSB_BUCKET_SHIFT) -#define TSB_BUCKET_ADDRESS_BITS \ - (TSB_BSHIFT - TSB_BUCKET_SHIFT - TTE_SHIFT) -#define TSB_BUCKET_MASK ((1 << TSB_BUCKET_ADDRESS_BITS) - 1) - -#ifndef LOCORE - -#define TSB_SIZE (TSB_BSIZE / sizeof(struct tte)) - -extern struct tte *tsb_kernel; -extern vm_size_t tsb_kernel_mask; -extern vm_size_t tsb_kernel_size; -extern vm_paddr_t tsb_kernel_phys; - -static __inline struct tte * -tsb_vpntobucket(pmap_t pm, vm_offset_t vpn) -{ - - return (&pm->pm_tsb[(vpn & TSB_BUCKET_MASK) << TSB_BUCKET_SHIFT]); -} - -static __inline struct tte * -tsb_vtobucket(pmap_t pm, u_long sz, vm_offset_t va) -{ - - return (tsb_vpntobucket(pm, va >> TTE_PAGE_SHIFT(sz))); -} - -static __inline struct tte * -tsb_kvpntotte(vm_offset_t vpn) -{ - - return (&tsb_kernel[vpn & tsb_kernel_mask]); -} - -static __inline struct tte * -tsb_kvtotte(vm_offset_t va) -{ - - return (tsb_kvpntotte(va >> PAGE_SHIFT)); -} - -typedef int (tsb_callback_t)(struct pmap *, struct pmap *, struct tte *, - vm_offset_t); - -struct tte *tsb_tte_lookup(pmap_t pm, vm_offset_t va); -void tsb_tte_remove(struct tte *stp); -struct tte *tsb_tte_enter(pmap_t pm, vm_page_t m, vm_offset_t va, u_long sz, - u_long data); -void tsb_tte_local_remove(struct tte *tp); -void tsb_foreach(pmap_t pm1, pmap_t pm2, vm_offset_t start, vm_offset_t end, - tsb_callback_t *callback); - -#endif /* !LOCORE */ - -#endif /* !_MACHINE_TSB_H_ */ diff --git a/sys/sparc64/include/tstate.h b/sys/sparc64/include/tstate.h deleted file mode 100644 index 5e8cf0e9294b..000000000000 --- a/sys/sparc64/include/tstate.h +++ /dev/null @@ -1,84 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD - * - * Copyright 2001 by Thomas Moestl . 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 ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE - * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $FreeBSD$ - */ - -#ifndef _MACHINE_TSTATE_H_ -#define _MACHINE_TSTATE_H_ - -#include -#include - -#define TSTATE_CWP_SHIFT 0 -#define TSTATE_CWP_BITS 5 -#define TSTATE_CWP_MASK \ - (((1 << TSTATE_CWP_BITS) - 1) << TSTATE_CWP_SHIFT) -#define TSTATE_CWP(x) ((x & TSTATE_CWP_MASK) >> TSTATE_CWP_SHIFT) - -#define TSTATE_PSTATE_SHIFT 8 -#define TSTATE_PSTATE_BITS 12 -#define TSTATE_PSTATE_MASK \ - (((1 << TSTATE_PSTATE_BITS) - 1) << TSTATE_PSTATE_SHIFT) -#define TSTATE_PSTATE(x) ((x) << TSTATE_PSTATE_SHIFT) -#define TSTATE_AG TSTATE_PSTATE(PSTATE_AG) -#define TSTATE_IE TSTATE_PSTATE(PSTATE_IE) -#define TSTATE_PRIV TSTATE_PSTATE(PSTATE_PRIV) -#define TSTATE_AM TSTATE_PSTATE(PSTATE_AM) -#define TSTATE_PEF TSTATE_PSTATE(PSTATE_PEF) -#define TSTATE_RED TSTATE_PSTATE(PSTATE_RED) -#define TSTATE_MM_TSO TSTATE_PSTATE(PSTATE_MM_TSO) -#define TSTATE_MM_PSO TSTATE_PSTATE(PSTATE_MM_PSO) -#define TSTATE_MM_RMO TSTATE_PSTATE(PSTATE_MM_RMO) -#define TSTATE_TLE TSTATE_PSTATE(PSTATE_TLE) -#define TSTATE_CLE TSTATE_PSTATE(PSTATE_CLE) -#define TSTATE_MG TSTATE_PSTATE(PSTATE_MG) -#define TSTATE_IG TSTATE_PSTATE(PSTATE_IG) - -#define TSTATE_ASI_SHIFT 24 -#define TSTATE_ASI_BITS 8 -#define TSTATE_ASI_MASK \ - (((1 << TSTATE_ASI_BITS) - 1) << TSTATE_ASI_SHIFT) -#define TSTATE_ASI(x) ((x & TSTATE_ASI_MASK) >> TSTATE_ASI_SHIFT) - -#define TSTATE_CCR_SHIFT 32 -#define TSTATE_ICC_SHIFT (TSTATE_CCR_SHIFT + ICC_SHIFT) -#define TSTATE_ICC_MASK (ICC_MASK << TSTATE_CCR_SHIFT) -#define TSTATE_XCC_SHIFT (TSTATE_CCR_SHIFT + XCC_SHIFT) -#define TSTATE_XCC_MASK (XCC_MASK << TSTATE_CCR_SHIFT) -#define TSTATE_CCR(x) ((x) << TSTATE_CCR_SHIFT) -#define TSTATE_ICC_C TSTATE_CCR(ICC_C) -#define TSTATE_ICC_V TSTATE_CCR(ICC_V) -#define TSTATE_ICC_Z TSTATE_CCR(ICC_Z) -#define TSTATE_ICC_N TSTATE_CCR(ICC_N) -#define TSTATE_XCC_C TSTATE_CCR(XCC_C) -#define TSTATE_XCC_V TSTATE_CCR(XCC_V) -#define TSTATE_XCC_Z TSTATE_CCR(XCC_Z) -#define TSTATE_XCC_N TSTATE_CCR(XCC_N) - -#define TSTATE_SECURE(tstate) \ - PSTATE_SECURE(((tstate) >> TSTATE_PSTATE_SHIFT) & ((1 << TSTATE_PSTATE_BITS) - 1)) - -#endif /* !_MACHINE_TSTATE_H_ */ diff --git a/sys/sparc64/include/tte.h b/sys/sparc64/include/tte.h deleted file mode 100644 index 527f1bad882c..000000000000 --- a/sys/sparc64/include/tte.h +++ /dev/null @@ -1,168 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-3-Clause - * - * Copyright (c) 1997 Berkeley Software Design, Inc. 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. - * 3. Berkeley Software Design Inc's name may not be used to endorse or - * promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY BERKELEY SOFTWARE DESIGN INC ``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 BERKELEY SOFTWARE DESIGN INC 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. - * - * from: BSDI: pmap.v9.h,v 1.10.2.6 1999/08/23 22:18:44 cp Exp - * $FreeBSD$ - */ - -#ifndef _MACHINE_TTE_H_ -#define _MACHINE_TTE_H_ - -#define TTE_SHIFT (5) - -#define TD_SIZE_SHIFT (61) -#define TD_SOFT2_SHIFT (50) -#define TD_RSVD2_SHIFT (49) -#define TD_SIZE2_SHIFT (48) -#define TD_DIAG_SF_SHIFT (41) -#define TD_RSVD_CH_SHIFT (43) -#define TD_RSVD_OC_SHIFT (47) -#define TD_RSVD_PT_SHIFT TD_RSVD_CH_SHIFT -#define TD_RSVD_VE_SHIFT (41) -#define TD_PA_SHIFT (13) -#define TD_SOFT_SHIFT (7) - -#define TD_SIZE_BITS (2) -#define TD_SOFT2_BITS (9) -#define TD_RSVD2_BITS (1) /* US-IV+, SPARC64 VI, VII, VIIIfx */ -#define TD_SIZE2_BITS (1) /* US-IV+, SPARC64 VI, VII, VIIIfx */ -#define TD_DIAG_SF_BITS (9) /* US-I, II{,e,i} */ -#define TD_RSVD_CH_BITS (7) /* US-III{,i,+}, US-IV, SPARC64 V */ -#define TD_RSVD_OC_BITS (1) /* SPARC64 VI, VII */ -#define TD_RSVD_PT_BITS (5) /* US-IV+, SPARC64 VI, VII */ -#define TD_RSVD_VE_BITS (7) /* SPARC64 VIIIfx */ -#define TD_PA_CH_BITS (30) /* US-III{,i,+}, US-IV{,+}, SPARC64 V */ -#define TD_PA_OC_BITS (34) /* SPARC64 VI, VII */ -#define TD_PA_SF_BITS (28) /* US-I, II{,e,i}, SPARC64 VIIIfx */ -#define TD_PA_BITS TD_PA_CH_BITS -#define TD_SOFT_BITS (6) - -#define TD_SIZE_MASK ((1UL << TD_SIZE_BITS) - 1) -#define TD_SOFT2_MASK ((1UL << TD_SOFT2_BITS) - 1) -#define TD_RSVD2_MASK ((1UL << TD_RSVD2_BITS) - 1) -#define TD_SIZE2_MASK ((1UL << TD_SIZE2_BITS) - 1) -#define TD_DIAG_SF_MASK ((1UL << TD_DIAG_SF_BITS) - 1) -#define TD_RSVD_CH_MASK ((1UL << TD_RSVD_CH_BITS) - 1) -#define TD_RSVD_OC_MASK ((1UL << TD_RSVD_OC_BITS) - 1) -#define TD_RSVD_PT_MASK ((1UL << TD_RSVD_PT_BITS) - 1) -#define TD_RSVD_VE_MASK ((1UL << TD_RSVD_VE_BITS) - 1) -#define TD_PA_CH_MASK ((1UL << TD_PA_CH_BITS) - 1) -#define TD_PA_OC_MASK ((1UL << TD_PA_OC_BITS) - 1) -#define TD_PA_SF_MASK ((1UL << TD_PA_SF_BITS) - 1) -#define TD_PA_MASK ((1UL << TD_PA_BITS) - 1) -#define TD_SOFT_MASK ((1UL << TD_SOFT_BITS) - 1) - -#define TS_8K (0UL) -#define TS_64K (1UL) -#define TS_512K (2UL) -#define TS_4M (3UL) -#define TS_32M (4UL) /* US-IV+, SPARC64 VI, VII only */ -#define TS_256M (5UL) /* US-IV+, SPARC64 VI, VII only */ -#define TS_2G (6UL) /* SPARC64 VIIIfx only */ - -#define TS_MIN TS_8K -#define TS_MAX TS_4M - -#define TD_V (1UL << 63) -#define TD_8K (TS_8K << TD_SIZE_SHIFT) -#define TD_64K (TS_64K << TD_SIZE_SHIFT) -#define TD_512K (TS_512K << TD_SIZE_SHIFT) -#define TD_4M (TS_4M << TD_SIZE_SHIFT) -#define TD_32M \ - (((TS_32M & TD_SIZE_MASK) << TD_SIZE_SHIFT) | \ - (TD_SIZE2_MASK << TD_SIZE2_SHIFT)) -#define TD_256M \ - (((TS_256M & TD_SIZE_MASK) << TD_SIZE_SHIFT) | \ - (TD_SIZE2_MASK << TD_SIZE2_SHIFT)) -#define TD_2G \ - (((TS_2G & TD_SIZE_MASK) << TD_SIZE_SHIFT) | \ - (TD_SIZE2_MASK << TD_SIZE2_SHIFT)) -#define TD_NFO (1UL << 60) -#define TD_IE (1UL << 59) -#define TD_PA(pa) ((pa) & (TD_PA_MASK << TD_PA_SHIFT)) -/* NOTE: bit 6 of TD_SOFT will be sign-extended if used as an immediate. */ -#define TD_FAKE ((1UL << 5) << TD_SOFT_SHIFT) -#define TD_EXEC ((1UL << 4) << TD_SOFT_SHIFT) -#define TD_REF ((1UL << 3) << TD_SOFT_SHIFT) -#define TD_PV ((1UL << 2) << TD_SOFT_SHIFT) -#define TD_SW ((1UL << 1) << TD_SOFT_SHIFT) -#define TD_WIRED ((1UL << 0) << TD_SOFT_SHIFT) -#define TD_L (1UL << 6) -#define TD_CP (1UL << 5) -#define TD_CV (1UL << 4) -#define TD_E (1UL << 3) -#define TD_P (1UL << 2) -#define TD_W (1UL << 1) -#define TD_G (1UL << 0) - -#define TV_SIZE_BITS (TD_SIZE_BITS) -#define TV_VPN(va, sz) ((((va) >> TTE_PAGE_SHIFT(sz)) << TV_SIZE_BITS) | sz) - -#define TTE_SIZE_SPREAD (3) -#define TTE_PAGE_SHIFT(sz) \ - (PAGE_SHIFT + ((sz) * TTE_SIZE_SPREAD)) - -#define TTE_GET_SIZE(tp) \ - (((tp)->tte_data >> TD_SIZE_SHIFT) & TD_SIZE_MASK) -#define TTE_GET_PAGE_SHIFT(tp) \ - TTE_PAGE_SHIFT(TTE_GET_SIZE(tp)) -#define TTE_GET_PAGE_SIZE(tp) \ - (1 << TTE_GET_PAGE_SHIFT(tp)) -#define TTE_GET_PAGE_MASK(tp) \ - (TTE_GET_PAGE_SIZE(tp) - 1) - -#define TTE_GET_PA(tp) \ - ((tp)->tte_data & (TD_PA_MASK << TD_PA_SHIFT)) -#define TTE_GET_VPN(tp) \ - ((tp)->tte_vpn >> TV_SIZE_BITS) -#define TTE_GET_VA(tp) \ - (TTE_GET_VPN(tp) << TTE_GET_PAGE_SHIFT(tp)) -#define TTE_GET_PMAP(tp) \ - (((tp)->tte_data & TD_P) != 0 ? (kernel_pmap) : \ - (PHYS_TO_VM_PAGE(pmap_kextract((vm_offset_t)(tp)))->md.pmap)) -#define TTE_ZERO(tp) \ - memset(tp, 0, sizeof(*tp)) - -struct pmap; - -struct tte { - u_long tte_vpn; - u_long tte_data; - TAILQ_ENTRY(tte) tte_link; -}; - -static __inline int -tte_match(struct tte *tp, vm_offset_t va) -{ - - return (((tp->tte_data & TD_V) != 0) && - (tp->tte_vpn == TV_VPN(va, TTE_GET_SIZE(tp)))); -} - -#endif /* !_MACHINE_TTE_H_ */ diff --git a/sys/sparc64/include/ucontext.h b/sys/sparc64/include/ucontext.h deleted file mode 100644 index 6303b3f85636..000000000000 --- a/sys/sparc64/include/ucontext.h +++ /dev/null @@ -1,66 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-3-Clause - * - * Copyright (c) 1999 Marcel Moolenaar - * 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 - * in this position and unchanged. - * 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. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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. - * - * from: FreeBSD: src/sys/alpha/include/ucontext.h,v 1.3 1999/10/08 - * $FreeBSD$ - */ - -#ifndef _MACHINE_UCONTEXT_H_ -#define _MACHINE_UCONTEXT_H_ - -struct __mcontext { - __uint64_t mc_global[8]; - __uint64_t mc_out[8]; - __uint64_t mc_local[8]; - __uint64_t mc_in[8]; - __uint32_t mc_fp[64]; -} __aligned(64); - -typedef struct __mcontext mcontext_t; - -#define _mc_flags mc_global[0] -#define _mc_sp mc_out[6] -#define _mc_fprs mc_local[0] -#define _mc_fsr mc_local[1] -#define _mc_gsr mc_local[2] -#define _mc_tnpc mc_in[0] -#define _mc_tpc mc_in[1] -#define _mc_tstate mc_in[2] -#define _mc_y mc_in[4] -#define _mc_wstate mc_in[5] - -#define _MC_VERSION_SHIFT 0 -#define _MC_VERSION_BITS 32 -#define _MC_VERSION 1L - -#define _MC_FLAGS_SHIFT 32 -#define _MC_FLAGS_BITS 32 -#define _MC_VOLUNTARY ((1L << 0) << _MC_FLAGS_SHIFT) - -#endif /* !_MACHINE_UCONTEXT_H_ */ diff --git a/sys/sparc64/include/upa.h b/sys/sparc64/include/upa.h deleted file mode 100644 index 90aec7d647be..000000000000 --- a/sys/sparc64/include/upa.h +++ /dev/null @@ -1,43 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD - * - * Copyright (c) 2001 by Thomas Moestl . - * 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 ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE - * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $FreeBSD$ - */ - -#ifndef _MACHINE_UPA_H_ -#define _MACHINE_UPA_H_ - -#define UPA_MEMSTART 0x1c000000000UL -#define UPA_MEMEND 0x1ffffffffffUL - -#define UPA_CR_MID_SHIFT (17) -#define UPA_CR_MID_SIZE (5) -#define UPA_CR_MID_MASK \ - (((1 << UPA_CR_MID_SIZE) - 1) << UPA_CR_MID_SHIFT) - -#define UPA_CR_GET_MID(cr) ((cr & UPA_CR_MID_MASK) >> UPA_CR_MID_SHIFT) - -#endif /* _MACHINE_UPA_H_ */ diff --git a/sys/sparc64/include/utrap.h b/sys/sparc64/include/utrap.h deleted file mode 100644 index ef2d02f08294..000000000000 --- a/sys/sparc64/include/utrap.h +++ /dev/null @@ -1,112 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD - * - * Copyright (c) 2001 Jake Burkholder. - * 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$ - */ - -#ifndef _MACHINE_UTRAP_H_ -#define _MACHINE_UTRAP_H_ - -#define UT_INSTRUCTION_EXCEPTION 1 -#define UT_INSTRUCTION_ERROR 2 -#define UT_INSTRUCTION_PROTECTION 3 -#define UT_ILLTRAP_INSTRUCTION 4 -#define UT_ILLEGAL_INSTRUCTION 5 -#define UT_PRIVILEGED_OPCODE 6 -#define UT_FP_DISABLED 7 -#define UT_FP_EXCEPTION_IEEE_754 8 -#define UT_FP_EXCEPTION_OTHER 9 -#define UT_TAG_OVERFLOW 10 -#define UT_DIVISION_BY_ZERO 11 -#define UT_DATA_EXCEPTION 12 -#define UT_DATA_ERROR 13 -#define UT_DATA_PROTECTION 14 -#define UT_MEM_ADDRESS_NOT_ALIGNED 15 -#define UT_PRIVILEGED_ACTION 16 -#define UT_ASYNC_DATA_ERROR 17 -#define UT_TRAP_INSTRUCTION_16 18 -#define UT_TRAP_INSTRUCTION_17 19 -#define UT_TRAP_INSTRUCTION_18 20 -#define UT_TRAP_INSTRUCTION_19 21 -#define UT_TRAP_INSTRUCTION_20 22 -#define UT_TRAP_INSTRUCTION_21 23 -#define UT_TRAP_INSTRUCTION_22 24 -#define UT_TRAP_INSTRUCTION_23 25 -#define UT_TRAP_INSTRUCTION_24 26 -#define UT_TRAP_INSTRUCTION_25 27 -#define UT_TRAP_INSTRUCTION_26 28 -#define UT_TRAP_INSTRUCTION_27 29 -#define UT_TRAP_INSTRUCTION_28 30 -#define UT_TRAP_INSTRUCTION_29 31 -#define UT_TRAP_INSTRUCTION_30 32 -#define UT_TRAP_INSTRUCTION_31 33 -#define UT_INSTRUCTION_MISS 34 -#define UT_DATA_MISS 35 -#define UT_MAX 36 - -#define ST_SUNOS_SYSCALL 0 -#define ST_BREAKPOINT 1 -#define ST_DIVISION_BY_ZERO 2 -#define ST_FLUSH_WINDOWS 3 /* XXX implement! */ -#define ST_CLEAN_WINDOW 4 -#define ST_RANGE_CHECK 5 -#define ST_FIX_ALIGNMENT 6 -#define ST_INTEGER_OVERFLOW 7 -/* 8 is 32-bit ABI syscall (old solaris syscall?) */ -#define ST_BSD_SYSCALL 9 -#define ST_FP_RESTORE 10 -/* 11-15 are available */ -/* 16 is linux 32 bit syscall (but supposed to be reserved, grr) */ -/* 17 is old linux 64 bit syscall (but supposed to be reserved, grr) */ -/* 16-31 are reserved for user applications (utraps) */ -#define ST_GETCC 32 /* XXX implement! */ -#define ST_SETCC 33 /* XXX implement! */ -#define ST_GETPSR 34 /* XXX implement! */ -#define ST_SETPSR 35 /* XXX implement! */ -/* 36-63 are available */ -#define ST_SOLARIS_SYSCALL 64 -#define ST_SYSCALL 65 -#define ST_SYSCALL32 66 -/* 67 is reserved to OS source licensee */ -/* 68 is return from deferred trap (not supported) */ -/* 69-95 are reserved to SPARC international */ -/* 96-108 are available */ -/* 109 is linux 64 bit syscall */ -/* 110 is linux 64 bit getcontext (?) */ -/* 111 is linux 64 bit setcontext (?) */ -/* 112-255 are available */ - -#define UTH_NOCHANGE (-1) - -#ifndef __ASM__ - -typedef int utrap_entry_t; -typedef void *utrap_handler_t; - -#endif - -#endif diff --git a/sys/sparc64/include/vdso.h b/sys/sparc64/include/vdso.h deleted file mode 100644 index 903fe1f4c6da..000000000000 --- a/sys/sparc64/include/vdso.h +++ /dev/null @@ -1,36 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD - * - * Copyright 2012 Konstantin Belousov . - * 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 ``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 BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $FreeBSD$ - */ - -#ifndef _SPARC64_VDSO_H -#define _SPARC64_VDSO_H - -#define VDSO_TIMEHANDS_MD \ - uint32_t th_res[8]; - -#endif diff --git a/sys/sparc64/include/ver.h b/sys/sparc64/include/ver.h deleted file mode 100644 index 2bab327c7150..000000000000 --- a/sys/sparc64/include/ver.h +++ /dev/null @@ -1,94 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD - * - * Copyright (c) 2001 Jake Burkholder. - * 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$ - */ - -#ifndef _MACHINE_VER_H_ -#define _MACHINE_VER_H_ - -#define VER_MANUF_SHIFT (48) -#define VER_IMPL_SHIFT (32) -#define VER_MASK_SHIFT (24) -#define VER_MAXTL_SHIFT (8) -#define VER_MAXWIN_SHIFT (0) - -#define VER_MANUF_SIZE (16) -#define VER_IMPL_SIZE (16) -#define VER_MASK_SIZE (8) -#define VER_MAXTL_SIZE (8) -#define VER_MAXWIN_SIZE (5) - -#ifndef LOCORE - -#define VER_MANUF_MASK \ - (((1UL << VER_MANUF_SIZE) - 1) << VER_MANUF_SHIFT) -#define VER_IMPL_MASK \ - (((1UL << VER_IMPL_SIZE) - 1) << VER_IMPL_SHIFT) -#define VER_MASK_MASK \ - (((1UL << VER_MASK_SIZE) - 1) << VER_MASK_SHIFT) -#define VER_MAXTL_MASK \ - (((1UL << VER_MAXTL_SIZE) - 1) << VER_MAXTL_SHIFT) -#define VER_MAXWIN_MASK \ - (((1UL << VER_MAXWIN_SIZE) - 1) << VER_MAXWIN_SHIFT) - -#define VER_MANUF(ver) \ - (((ver) & VER_MANUF_MASK) >> VER_MANUF_SHIFT) -#define VER_IMPL(ver) \ - (((ver) & VER_IMPL_MASK) >> VER_IMPL_SHIFT) -#define VER_MASK(ver) \ - (((ver) & VER_MASK_MASK) >> VER_MASK_SHIFT) -#define VER_MAXTL(ver) \ - (((ver) & VER_MAXTL_MASK) >> VER_MAXTL_SHIFT) -#define VER_MAXWIN(ver) \ - (((ver) & VER_MAXWIN_MASK) >> VER_MAXWIN_SHIFT) - -extern char sparc64_model[]; - -#endif /* !LOCORE */ - -/* Known implementations */ -#define CPU_IMPL_SPARC64 0x01 -#define CPU_IMPL_SPARC64II 0x02 -#define CPU_IMPL_SPARC64III 0x03 -#define CPU_IMPL_SPARC64IV 0x04 -#define CPU_IMPL_SPARC64V 0x05 -#define CPU_IMPL_SPARC64VI 0x06 -#define CPU_IMPL_SPARC64VII 0x07 -#define CPU_IMPL_SPARC64VIIIfx 0x08 -#define CPU_IMPL_ULTRASPARCI 0x10 -#define CPU_IMPL_ULTRASPARCII 0x11 -#define CPU_IMPL_ULTRASPARCIIi 0x12 -#define CPU_IMPL_ULTRASPARCIIe 0x13 -#define CPU_IMPL_ULTRASPARCIII 0x14 -#define CPU_IMPL_ULTRASPARCIIIp 0x15 -#define CPU_IMPL_ULTRASPARCIIIi 0x16 -#define CPU_IMPL_ULTRASPARCIV 0x18 -#define CPU_IMPL_ULTRASPARCIVp 0x19 -#define CPU_IMPL_ULTRASPARCIIIip 0x22 - -#endif /* !_MACHINE_VER_H_ */ diff --git a/sys/sparc64/include/vm.h b/sys/sparc64/include/vm.h deleted file mode 100644 index 348cdf012c9b..000000000000 --- a/sys/sparc64/include/vm.h +++ /dev/null @@ -1,38 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD - * - * Copyright (c) 2009 Alan L. Cox - * 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$ - */ - -#ifndef _MACHINE_VM_H_ -#define _MACHINE_VM_H_ - -/* Memory attribute configuration is not (yet) implemented. */ -#define VM_MEMATTR_DEFAULT 0 -#define VM_MEMATTR_UNCACHEABLE 0 - -#endif /* !_MACHINE_VM_H_ */ diff --git a/sys/sparc64/include/vmparam.h b/sys/sparc64/include/vmparam.h deleted file mode 100644 index f23ebb06d65a..000000000000 --- a/sys/sparc64/include/vmparam.h +++ /dev/null @@ -1,248 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-3-Clause - * - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * Copyright (c) 1994 John S. Dyson - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * 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. - * - * from: @(#)vmparam.h 5.9 (Berkeley) 5/12/91 - * from: FreeBSD: src/sys/i386/include/vmparam.h,v 1.33 2000/03/30 - * $FreeBSD$ - */ - -#ifndef _MACHINE_VMPARAM_H_ -#define _MACHINE_VMPARAM_H_ - -/* - * Virtual memory related constants, all in bytes - */ -#ifndef MAXTSIZ -#define MAXTSIZ (1*1024*1024*1024) /* max text size */ -#endif -#ifndef DFLDSIZ -#define DFLDSIZ (128*1024*1024) /* initial data size limit */ -#endif -#ifndef MAXDSIZ -#define MAXDSIZ (1*1024*1024*1024) /* max data size */ -#endif -#ifndef DFLSSIZ -#define DFLSSIZ (128*1024*1024) /* initial stack size limit */ -#endif -#ifndef MAXSSIZ -#define MAXSSIZ (1*1024*1024*1024) /* max stack size */ -#endif -#ifndef SGROWSIZ -#define SGROWSIZ (128*1024) /* amount to grow stack */ -#endif - -/* - * The physical address space is sparsely populated. - */ -#define VM_PHYSSEG_SPARSE - -/* - * The number of PHYSSEG entries must be one greater than the number - * of phys_avail entries because the phys_avail entry that spans the - * largest physical address that is accessible by ISA DMA is split - * into two PHYSSEG entries. - */ -#define VM_PHYSSEG_MAX 64 - -/* - * Create two free page pools: VM_FREEPOOL_DEFAULT is the default pool - * from which physical pages are allocated and VM_FREEPOOL_DIRECT is - * the pool from which physical pages for small UMA objects are - * allocated. - */ -#define VM_NFREEPOOL 2 -#define VM_FREEPOOL_DEFAULT 0 -#define VM_FREEPOOL_DIRECT 1 - -/* - * Create one free page list: VM_FREELIST_DEFAULT is for all physical - * pages. - */ -#define VM_NFREELIST 1 -#define VM_FREELIST_DEFAULT 0 - -/* - * An allocation size of 16MB is supported in order to optimize the - * use of the direct map by UMA. Specifically, a cache line contains - * at most four TTEs, collectively mapping 16MB of physical memory. - * By reducing the number of distinct 16MB "pages" that are used by UMA, - * the physical memory allocator reduces the likelihood of both 4MB - * page TLB misses and cache misses caused by 4MB page TLB misses. - */ -#define VM_NFREEORDER 12 - -/* - * Enable superpage reservations: 1 level. - */ -#ifndef VM_NRESERVLEVEL -#define VM_NRESERVLEVEL 1 -#endif - -/* - * Level 0 reservations consist of 512 pages. - */ -#ifndef VM_LEVEL_0_ORDER -#define VM_LEVEL_0_ORDER 9 -#endif - -/** - * Address space layout. - * - * UltraSPARC I and II implement a 44 bit virtual address space. The address - * space is split into 2 regions at each end of the 64 bit address space, with - * an out of range "hole" in the middle. UltraSPARC III implements the full - * 64 bit virtual address space, but we don't really have any use for it and - * 43 bits of user address space is considered to be "enough", so we ignore it. - * - * Upper region: 0xffffffffffffffff - * 0xfffff80000000000 - * - * Hole: 0xfffff7ffffffffff - * 0x0000080000000000 - * - * Lower region: 0x000007ffffffffff - * 0x0000000000000000 - * - * In general we ignore the upper region, and use the lower region as mappable - * space. - * - * We define some interesting address constants: - * - * VM_MIN_ADDRESS and VM_MAX_ADDRESS define the start and end of the entire - * 64 bit address space, mostly just for convenience. - * - * VM_MIN_DIRECT_ADDRESS and VM_MAX_DIRECT_ADDRESS define the start and end - * of the direct mapped region. This maps virtual addresses to physical - * addresses directly using 4mb tlb entries, with the physical address encoded - * in the lower 43 bits of virtual address. These mappings are convenient - * because they do not require page tables, and because they never change they - * do not require tlb flushes. However, since these mappings are cacheable, - * we must ensure that all pages accessed this way are either not double - * mapped, or that all other mappings have virtual color equal to physical - * color, in order to avoid creating illegal aliases in the data cache. - * - * VM_MIN_KERNEL_ADDRESS and VM_MAX_KERNEL_ADDRESS define the start and end of - * mappable kernel virtual address space. VM_MIN_KERNEL_ADDRESS is basically - * arbitrary, a convenient address is chosen which allows both the kernel text - * and data and the prom's address space to be mapped with 1 4mb tsb page. - * VM_MAX_KERNEL_ADDRESS is variable, computed at startup time based on the - * amount of physical memory available. Each 4mb tsb page provides 1g of - * virtual address space, with the only practical limit being available - * phsyical memory. - * - * VM_MIN_PROM_ADDRESS and VM_MAX_PROM_ADDRESS define the start and end of the - * prom address space. On startup the prom's mappings are duplicated in the - * kernel tsb, to allow prom memory to be accessed normally by the kernel. - * - * VM_MIN_USER_ADDRESS and VM_MAX_USER_ADDRESS define the start and end of the - * user address space. There are some hardware errata about using addresses - * at the boundary of the va hole, so we allow just under 43 bits of user - * address space. Note that the kernel and user address spaces overlap, but - * this doesn't matter because they use different tlb contexts, and because - * the kernel address space is not mapped into each process' address space. - */ -#define VM_MIN_ADDRESS (0x0000000000000000UL) -#define VM_MAX_ADDRESS (0xffffffffffffffffUL) - -#define VM_MIN_DIRECT_ADDRESS (0xfffff80000000000UL) -#define VM_MAX_DIRECT_ADDRESS (VM_MAX_ADDRESS) - -#define VM_MIN_KERNEL_ADDRESS (0x00000000c0000000UL) -#define VM_MAX_KERNEL_ADDRESS (vm_max_kernel_address) - -#define VM_MIN_PROM_ADDRESS (0x00000000f0000000UL) -#define VM_MAX_PROM_ADDRESS (0x00000000ffffffffUL) - -#define VM_MIN_USER_ADDRESS (0x0000000000000000UL) -#define VM_MAX_USER_ADDRESS (0x000007fe00000000UL) - -#define VM_MINUSER_ADDRESS (VM_MIN_USER_ADDRESS) -#define VM_MAXUSER_ADDRESS (VM_MAX_USER_ADDRESS) - -#define KERNBASE (VM_MIN_KERNEL_ADDRESS) -#define PROMBASE (VM_MIN_PROM_ADDRESS) -#define USRSTACK (VM_MAX_USER_ADDRESS) - -/* - * How many physical pages per kmem arena virtual page. - */ -#ifndef VM_KMEM_SIZE_SCALE -#define VM_KMEM_SIZE_SCALE (tsb_kernel_ldd_phys == 0 ? 3 : 2) -#endif - -/* - * Optional floor (in bytes) on the size of the kmem arena. - */ -#ifndef VM_KMEM_SIZE_MIN -#define VM_KMEM_SIZE_MIN (16 * 1024 * 1024) -#endif - -/* - * Optional ceiling (in bytes) on the size of the kmem arena: 60% of the - * kernel map. - */ -#ifndef VM_KMEM_SIZE_MAX -#define VM_KMEM_SIZE_MAX ((VM_MAX_KERNEL_ADDRESS - \ - VM_MIN_KERNEL_ADDRESS + 1) * 3 / 5) -#endif - -/* - * Initial pagein size of beginning of executable file. - */ -#ifndef VM_INITIAL_PAGEIN -#define VM_INITIAL_PAGEIN 16 -#endif - -#define UMA_MD_SMALL_ALLOC - -extern u_int tsb_kernel_ldd_phys; -extern vm_offset_t vm_max_kernel_address; - -/* - * Older sparc64 machines have a virtually indexed L1 data cache of 16KB. - * Consequently, mapping the same physical page multiple times may have - * caching disabled. - */ -#define ZERO_REGION_SIZE PAGE_SIZE - -#include - -#define SFBUF -#define SFBUF_MAP - -#define PMAP_HAS_DMAP dcache_color_ignore -#define PHYS_TO_DMAP(x) (TLB_PHYS_TO_DIRECT(x)) - -#endif /* !_MACHINE_VMPARAM_H_ */ diff --git a/sys/sparc64/include/watch.h b/sys/sparc64/include/watch.h deleted file mode 100644 index 1adb2e1c6670..000000000000 --- a/sys/sparc64/include/watch.h +++ /dev/null @@ -1,43 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD - * - * Copyright 2001 by Thomas Moestl . 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 ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE - * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $FreeBSD$ - */ - -#ifndef _MACHINE_WATCH_H_ -#define _MACHINE_WATCH_H_ - -int watch_phys_set_mask(vm_paddr_t pa, u_long mask); -int watch_phys_set(vm_paddr_t pa, int sz); -vm_paddr_t watch_phys_get(int *bm); -void watch_phys_clear(void); -int watch_phys_active(void); -int watch_virt_set_mask(vm_offset_t va, u_long mask); -int watch_virt_set(vm_offset_t va, int sz); -vm_offset_t watch_virt_get(int *bm); -void watch_virt_clear(void); -int watch_virt_active(void); - -#endif /* _MACHINE_WATCH_H_ */ diff --git a/sys/sparc64/include/wstate.h b/sys/sparc64/include/wstate.h deleted file mode 100644 index e55916b7dcf9..000000000000 --- a/sys/sparc64/include/wstate.h +++ /dev/null @@ -1,68 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-3-Clause - * - * Copyright (c) 1997 Berkeley Software Design, Inc. 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. - * 3. Berkeley Software Design Inc's name may not be used to endorse or - * promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY BERKELEY SOFTWARE DESIGN INC ``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 BERKELEY SOFTWARE DESIGN INC 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. - * - * from: BSDI: wstate.h,v 1.4 1997/09/18 13:05:51 torek Exp - * $FreeBSD$ - */ - -#ifndef _MACHINE_WSTATE_H_ -#define _MACHINE_WSTATE_H_ - -/* - * Window state register bits - * - * There really are no bits per se, just the two fields WSTATE.NORMAL - * and WSTATE.OTHER. The rest is up to software. - * - * We use WSTATE_NORMAL to represent user mode or kernel mode saves - * (whichever is currently in effect) and WSTATE_OTHER to represent - * user mode saves (only). - * - * Note that locore.s assumes this same bit layout (since the translation - * from "bits" to "{spill,fill}_N_{normal,other}" is done in hardware). - */ - -#define WSTATE_NORMAL_MASK 1 /* wstate normal minus transition */ -#define WSTATE_OTHER_SHIFT 3 /* for wstate other / user */ -#define WSTATE_OTHER_MASK /* wstate other minus nested */ \ - (WSTATE_NORMAL_MASK << WSTATE_OTHER_SHIFT) - -#define WSTATE_KERNEL 0 /* normal kernel wstate */ -#define WSTATE_USER_64 0 /* normal 64bit user wstate */ -#define WSTATE_USER_32 1 /* normal 32bit user wstate */ - -#define WSTATE_TRANSITION 2 /* if set, force user window */ -#define WSTATE_NESTED /* if set, spill must not fault */ \ - (WSTATE_TRANSITION << WSTATE_OTHER_SHIFT) - -/* Values used by the PROM and (Open)Solaris */ -#define WSTATE_PROM_KMIX 7 -#define WSTATE_PROM_MASK 7 - -#endif /* !_MACHINE_WSTATE_H_ */ diff --git a/sys/sparc64/isa/isa.c b/sys/sparc64/isa/isa.c deleted file mode 100644 index f035ddc8c8d6..000000000000 --- a/sys/sparc64/isa/isa.c +++ /dev/null @@ -1,363 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD - * - * Copyright (c) 1998 Doug Rabson - * Copyright (c) 2001 Thomas Moestl - * 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. - * - * from: FreeBSD: src/sys/alpha/isa/isa.c,v 1.26 2001/07/11 - */ - -#include -__FBSDID("$FreeBSD$"); - -#include -#include -#include - -#include - -#include - -#include -#include -#include - -#include -#include - -#include - -#include -#include - -#include -#include - -/* There can be only one ISA bus, so it is safe to use globals. */ -static u_int64_t isa_io_base; -static u_int64_t isa_io_limit; -static u_int64_t isa_mem_base; -static u_int64_t isa_mem_limit; - -device_t isa_bus_device; - -static phandle_t isab_node; -static struct isa_ranges *isab_ranges; -static int isab_nrange; -static struct ofw_bus_iinfo isa_iinfo; - -/* - * XXX: This is really partly PCI-specific, but unfortunately is - * differently enough to have to duplicate it here... - */ -#define ISAB_RANGE_PHYS(r) \ - (((u_int64_t)(r)->phys_mid << 32) | (u_int64_t)(r)->phys_lo) -#define ISAB_RANGE_SPACE(r) (((r)->phys_hi >> 24) & 0x03) - -#define ISAR_SPACE_IO 0x01 -#define ISAR_SPACE_MEM 0x02 - -#define INRANGE(x, start, end) ((x) >= (start) && (x) <= (end)) - -static void isa_setup_children(device_t, phandle_t); - -void -isa_init(device_t dev) -{ - device_t bridge; - int i; - - /* The parent of the bus must be a PCI-ISA bridge. */ - bridge = device_get_parent(dev); - isab_node = ofw_bus_get_node(bridge); - isab_nrange = OF_getprop_alloc_multi(isab_node, "ranges", - sizeof(*isab_ranges), (void **)&isab_ranges); - if (isab_nrange <= 0) - panic("isa_init: cannot get bridge range property"); - - ofw_bus_setup_iinfo(isab_node, &isa_iinfo, sizeof(ofw_isa_intr_t)); - - isa_setup_children(dev, isab_node); - - for (i = isab_nrange - 1; i >= 0; i--) { - switch(ISAB_RANGE_SPACE(&isab_ranges[i])) { - case ISAR_SPACE_IO: - /* This is probably always 0. */ - isa_io_base = ISAB_RANGE_PHYS(&isab_ranges[i]); - isa_io_limit = isab_ranges[i].size; - break; - case ISAR_SPACE_MEM: - /* This is probably always 0. */ - isa_mem_base = ISAB_RANGE_PHYS(&isab_ranges[i]); - isa_mem_limit = isab_ranges[i].size; - break; - } - } -} - -static const struct { - const char *const name; - uint32_t id; -} ofw_isa_pnp_map[] = { - { "SUNW,lomh", 0x0000ae4e }, /* SUN0000 */ - { "dma", 0x0002d041 }, /* PNP0200 */ - { "floppy", 0x0007d041 }, /* PNP0700 */ - { "rtc", 0x000bd041 }, /* PNP0B00 */ - { "flashprom", 0x0100ae4e }, /* SUN0001 */ - { "parallel", 0x0104d041 }, /* PNP0401 */ - { "serial", 0x0105d041 }, /* PNP0501 */ - { "su", 0x0105d041 }, /* PNP0501 */ - { "i2c", 0x0200ae4e }, /* SUN0002 */ - { "rmc-comm", 0x0300ae4e }, /* SUN0003 */ - { "kb_ps2", 0x0303d041 }, /* PNP0303 */ - { "kdmouse", 0x030fd041 }, /* PNP0F03 */ - { "bscbus", 0x0400ae4e }, /* SUN0004 */ - { "power", 0x0c0cd041 }, /* PNP0C0C */ - { NULL, 0x0 } -}; - -static void -isa_setup_children(device_t dev, phandle_t parent) -{ - struct isa_regs *regs; - struct resource_list *rl; - device_t cdev; - u_int64_t end, start; - ofw_isa_intr_t *intrs, rintr; - phandle_t node; - uint32_t *drqs, *regidx; - int i, ndrq, nintr, nreg, nregidx, rid, rtype; - char *name; - - /* - * Loop through children and fake up PnP devices for them. - * Their resources are added as fully mapped and specified because - * adjusting the resources and the resource list entries respectively - * in isa_alloc_resource() causes trouble with drivers which use - * rman_get_start(), pass-through or allocate and release resources - * multiple times, etc. Adjusting the resources might be better off - * in a bus_activate_resource method but the common ISA code doesn't - * allow for an isa_activate_resource(). - */ - for (node = OF_child(parent); node != 0; node = OF_peer(node)) { - if ((OF_getprop_alloc(node, "name", (void **)&name)) == -1) - continue; - - /* - * Keyboard and mouse controllers hang off of the `8042' - * node but we have no real use for the `8042' itself. - */ - if (strcmp(name, "8042") == 0) { - isa_setup_children(dev, node); - OF_prop_free(name); - continue; - } - - for (i = 0; ofw_isa_pnp_map[i].name != NULL; i++) - if (strcmp(ofw_isa_pnp_map[i].name, name) == 0) - break; - if (ofw_isa_pnp_map[i].name == NULL) { - device_printf(dev, "no PnP map entry for node " - "0x%lx: %s\n", (unsigned long)node, name); - OF_prop_free(name); - continue; - } - - if ((cdev = BUS_ADD_CHILD(dev, ISA_ORDER_PNPBIOS, NULL, -1)) == - NULL) - panic("isa_setup_children: BUS_ADD_CHILD failed"); - isa_set_logicalid(cdev, ofw_isa_pnp_map[i].id); - isa_set_vendorid(cdev, ofw_isa_pnp_map[i].id); - - rl = BUS_GET_RESOURCE_LIST(dev, cdev); - nreg = OF_getprop_alloc_multi(node, "reg", sizeof(*regs), - (void **)®s); - for (i = 0; i < nreg; i++) { - start = ISA_REG_PHYS(®s[i]); - end = start + regs[i].size - 1; - rtype = ofw_isa_range_map(isab_ranges, isab_nrange, - &start, &end, NULL); - rid = 0; - while (resource_list_find(rl, rtype, rid) != NULL) - rid++; - bus_set_resource(cdev, rtype, rid, start, - end - start + 1); - } - if (nreg == -1 && parent != isab_node) { - /* - * The "reg" property still might be an index into - * the set of registers of the parent device like - * with the nodes hanging off of the `8042' node. - */ - nregidx = OF_getprop_alloc_multi(node, "reg", sizeof(*regidx), - (void **)®idx); - if (nregidx > 2) - panic("isa_setup_children: impossible number " - "of register indices"); - if (nregidx != -1 && (nreg = OF_getprop_alloc_multi(parent, - "reg", sizeof(*regs), (void **)®s)) >= nregidx) { - for (i = 0; i < nregidx; i++) { - start = ISA_REG_PHYS(®s[regidx[i]]); - end = start + regs[regidx[i]].size - 1; - rtype = ofw_isa_range_map(isab_ranges, - isab_nrange, &start, &end, NULL); - rid = 0; - while (resource_list_find(rl, rtype, - rid) != NULL) - rid++; - bus_set_resource(cdev, rtype, rid, - start, end - start + 1); - } - } - if (regidx != NULL) - OF_prop_free(regidx); - } - if (regs != NULL) - OF_prop_free(regs); - - nintr = OF_getprop_alloc_multi(node, "interrupts", sizeof(*intrs), - (void **)&intrs); - for (i = 0; i < nintr; i++) { - if (intrs[i] > 7) - panic("isa_setup_children: intr too large"); - rintr = ofw_isa_route_intr(device_get_parent(dev), node, - &isa_iinfo, intrs[i]); - if (rintr == PCI_INVALID_IRQ) { - device_printf(dev, "could not map ISA " - "interrupt %d for node 0x%lx: %s\n", - intrs[i], (unsigned long)node, name); - continue; - } - bus_set_resource(cdev, SYS_RES_IRQ, i, rintr, 1); - } - if (intrs != NULL) - OF_prop_free(intrs); - - ndrq = OF_getprop_alloc_multi(node, "dma-channel", sizeof(*drqs), - (void **)&drqs); - for (i = 0; i < ndrq; i++) - bus_set_resource(cdev, SYS_RES_DRQ, i, drqs[i], 1); - if (drqs != NULL) - OF_prop_free(drqs); - - /* - * Devices using DMA hang off of the `dma' node instead of - * directly from the ISA bridge node. - */ - if (strcmp(name, "dma") == 0) - isa_setup_children(dev, node); - - OF_prop_free(name); - } -} - -struct resource * -isa_alloc_resource(device_t bus, device_t child, int type, int *rid, - rman_res_t start, rman_res_t end, rman_res_t count, u_int flags) -{ - /* - * Consider adding a resource definition. - */ - int passthrough = (device_get_parent(child) != bus); - int isdefault = RMAN_IS_DEFAULT_RANGE(start, end); - struct resource_list *rl; - struct resource_list_entry *rle; - u_long base, limit; - - rl = BUS_GET_RESOURCE_LIST(bus, child); - if (!passthrough && !isdefault) { - rle = resource_list_find(rl, type, *rid); - if (!rle) { - if (*rid < 0) - return (NULL); - switch (type) { - case SYS_RES_IRQ: - if (*rid >= ISA_NIRQ) - return (NULL); - break; - case SYS_RES_DRQ: - if (*rid >= ISA_NDRQ) - return (NULL); - break; - case SYS_RES_MEMORY: - if (*rid >= ISA_NMEM) - return (NULL); - break; - case SYS_RES_IOPORT: - if (*rid >= ISA_NPORT) - return (NULL); - break; - default: - return (NULL); - } - resource_list_add(rl, type, *rid, start, end, count); - } - } - - /* - * Sanity check if the resource in the respective entry is fully - * mapped and specified and its type allocable. A driver could - * have added an out of range resource on its own. - */ - if (!passthrough) { - if ((rle = resource_list_find(rl, type, *rid)) == NULL) - return (NULL); - base = limit = 0; - switch (type) { - case SYS_RES_MEMORY: - base = isa_mem_base; - limit = base + isa_mem_limit; - break; - case SYS_RES_IOPORT: - base = isa_io_base; - limit = base + isa_io_limit; - break; - case SYS_RES_IRQ: - if (rle->start != rle->end || rle->start <= 7) - return (NULL); - break; - case SYS_RES_DRQ: - break; - default: - return (NULL); - } - if (type == SYS_RES_MEMORY || type == SYS_RES_IOPORT) { - if (!INRANGE(rle->start, base, limit) || - !INRANGE(rle->end, base, limit)) - return (NULL); - } - } - - return (resource_list_alloc(rl, bus, child, type, rid, start, end, - count, flags)); -} - -int -isa_release_resource(device_t bus, device_t child, int type, int rid, - struct resource *res) -{ - - return (bus_generic_rl_release_resource(bus, child, type, rid, res)); -} diff --git a/sys/sparc64/isa/isa_dma.c b/sys/sparc64/isa/isa_dma.c deleted file mode 100644 index 1a1b009db10e..000000000000 --- a/sys/sparc64/isa/isa_dma.c +++ /dev/null @@ -1,98 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD - * - * Copyright (c) 2004 Pyun YongHyeon. - * 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 -__FBSDID("$FreeBSD$"); - -#include -#include -#include - -#include -#include - -/* - * Glue code to load sound(4). Though fdc(4), ppc(4) don't work on - * sparc64 yet, they may need this glue code too. - */ - -int -isa_dma_init(int chan, u_int bouncebufsize, int flag) -{ - - return (0); -} - -int -isa_dma_acquire(int chan) -{ - return (0); -} - -void -isa_dma_release(int chan) -{ - -} - -void -isa_dmacascade(int chan) -{ - -} - -void -isa_dmastart(int flags, caddr_t addr, u_int nbytes, int chan) -{ - -} - -void -isa_dmadone(int flags, caddr_t addr, int nbytes, int chan) -{ - -} - -int -isa_dmastatus(int chan) -{ - return (0); -} - -int -isa_dmatc(int chan) -{ - return (0); -} - -int -isa_dmastop(int chan) -{ - return (0); -} diff --git a/sys/sparc64/isa/ofw_isa.c b/sys/sparc64/isa/ofw_isa.c deleted file mode 100644 index a66a738726ac..000000000000 --- a/sys/sparc64/isa/ofw_isa.c +++ /dev/null @@ -1,148 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-3-Clause - * - * Copyright (c) 1999, 2000 Matthew R. Green - * 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. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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. - * - * from: NetBSD: ebus.c,v 1.52 2008/05/29 14:51:26 mrg Exp - */ -/*- - * Copyright (c) 2001, 2003 Thomas Moestl - * 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. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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 -__FBSDID("$FreeBSD$"); - -/* - * Helper functions which can be used in both ISA and EBus code. - */ - -#include -#include -#include - -#include -#include - -#include -#include - -#include -#include - -#include "pcib_if.h" - -int -ofw_isa_range_restype(struct isa_ranges *range) -{ - int ps = ISA_RANGE_PS(range); - - switch (ps) { - case OFW_PCI_CS_IO: - return (SYS_RES_IOPORT); - case OFW_PCI_CS_MEM32: - return (SYS_RES_MEMORY); - default: - panic("ofw_isa_range_restype: illegal space %x", ps); - } - -} - -/* XXX: this only supports PCI as parent bus right now. */ -int -ofw_isa_range_map(struct isa_ranges *range, int nrange, u_long *start, - u_long *end, int *which) -{ - struct isa_ranges *r; - uint64_t offs, cstart, cend; - int i; - - for (i = 0; i < nrange; i++) { - r = &range[i]; - cstart = ISA_RANGE_CHILD(r); - cend = cstart + r->size - 1; - if (*start < cstart || *start > cend) - continue; - if (*end < cstart || *end > cend) { - panic("ofw_isa_map_iorange: iorange crosses PCI " - "ranges (%#lx not in %#lx - %#lx)", *end, cstart, - cend); - } - offs = ISA_RANGE_PHYS(r); - *start = *start + offs - cstart; - *end = *end + offs - cstart; - if (which != NULL) - *which = i; - return (ofw_isa_range_restype(r)); - } - panic("ofw_isa_map_iorange: could not map range %#lx - %#lx", - *start, *end); -} - -ofw_pci_intr_t -ofw_isa_route_intr(device_t bridge, phandle_t node, struct ofw_bus_iinfo *ii, - ofw_isa_intr_t intr) -{ - struct isa_regs reg; - device_t pbridge; - ofw_isa_intr_t mintr; - - pbridge = device_get_parent(device_get_parent(bridge)); - /* - * If we get a match from using the map, the resulting INO is - * fully specified, so we may not continue to map. - */ - if (!ofw_bus_lookup_imap(node, ii, ®, sizeof(reg), - &intr, sizeof(intr), &mintr, sizeof(mintr), NULL)) { - /* Try routing at the parent bridge. */ - mintr = PCIB_ROUTE_INTERRUPT(pbridge, bridge, intr); - } - return (mintr); -} diff --git a/sys/sparc64/isa/ofw_isa.h b/sys/sparc64/isa/ofw_isa.h deleted file mode 100644 index c1974f1f88b4..000000000000 --- a/sys/sparc64/isa/ofw_isa.h +++ /dev/null @@ -1,102 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-3-Clause - * - * Copyright (c) 1999, 2000 Matthew R. Green - * 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. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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. - * - * from: NetBSD: ebus.c,v 1.52 2008/05/29 14:51:26 mrg Exp - */ -/*- - * Copyright (c) 2001 Thomas Moestl - * 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. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD$ - */ - -#ifndef _SPARC64_ISA_OFW_ISA_H_ -#define _SPARC64_ISA_OFW_ISA_H_ - -/* - * ISA PROM structures - */ -struct isa_regs { - u_int32_t phys_hi; /* high bits of physaddr */ - u_int32_t phys_lo; - u_int32_t size; -}; - -#define ISA_REG_PHYS(r) \ - ((((u_int64_t)((r)->phys_hi)) << 32) | ((u_int64_t)(r)->phys_lo)) - -/* XXX: this is a guess. Verify... */ -struct isa_ranges { - u_int32_t child_hi; - u_int32_t child_lo; - u_int32_t phys_hi; - u_int32_t phys_mid; - u_int32_t phys_lo; - u_int32_t size; -}; - -#define ISA_RANGE_CHILD(r) \ - ((((u_int64_t)((r)->child_hi)) << 32) | ((u_int64_t)(r)->child_lo)) -#define ISA_RANGE_PS(r) (((r)->phys_hi >> 24) & 0x03) -#define ISA_RANGE_PHYS(r) \ - ((((u_int64_t)(r)->phys_mid) << 32) | ((u_int64_t)(r)->phys_lo)) - -typedef u_int32_t ofw_isa_intr_t; - -int ofw_isa_range_restype(struct isa_ranges *); -/* Map an IO range. Returns the resource type of the range. */ -int ofw_isa_range_map(struct isa_ranges *, int, u_long *, u_long *, int *); - -ofw_pci_intr_t ofw_isa_route_intr(device_t, phandle_t, struct ofw_bus_iinfo *, - ofw_isa_intr_t); - -#endif /* !_SPARC64_ISA_OFW_ISA_H_ */ diff --git a/sys/sparc64/pci/apb.c b/sys/sparc64/pci/apb.c deleted file mode 100644 index 757a1e8608dc..000000000000 --- a/sys/sparc64/pci/apb.c +++ /dev/null @@ -1,309 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-3-Clause - * - * Copyright (c) 1994,1995 Stefan Esser, Wolfgang StanglMeier - * Copyright (c) 2000 Michael Smith - * Copyright (c) 2000 BSDi - * Copyright (c) 2001, 2003 Thomas Moestl - * 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. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * 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. - * - * from: FreeBSD: src/sys/dev/pci/pci_pci.c,v 1.3 2000/12/13 - */ - -#include -__FBSDID("$FreeBSD$"); - -/* - * Support for the Sun APB (Advanced PCI Bridge) PCI-PCI bridge. - * This bridge does not fully comply to the PCI bridge specification, and is - * therefore not supported by the generic driver. - * We can use some of the pcib methods anyway. - */ - -#include "opt_ofw_pci.h" - -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include -#include - -#include -#include -#include - -#include "pcib_if.h" - -#include -#include - -/* - * Bridge-specific data. - */ -struct apb_softc { - struct ofw_pcib_gen_softc sc_bsc; - uint8_t sc_iomap; - uint8_t sc_memmap; -}; - -static device_probe_t apb_probe; -static device_attach_t apb_attach; -static bus_alloc_resource_t apb_alloc_resource; -static bus_adjust_resource_t apb_adjust_resource; - -static device_method_t apb_methods[] = { - /* Device interface */ - DEVMETHOD(device_probe, apb_probe), - DEVMETHOD(device_attach, apb_attach), - - /* Bus interface */ - DEVMETHOD(bus_alloc_resource, apb_alloc_resource), - DEVMETHOD(bus_adjust_resource, apb_adjust_resource), - DEVMETHOD(bus_release_resource, bus_generic_release_resource), - - /* pcib interface */ - DEVMETHOD(pcib_route_interrupt, ofw_pcib_gen_route_interrupt), - DEVMETHOD(pcib_request_feature, pcib_request_feature_allow), - - /* ofw_bus interface */ - DEVMETHOD(ofw_bus_get_node, ofw_pcib_gen_get_node), - - DEVMETHOD_END -}; - -static devclass_t pcib_devclass; - -DEFINE_CLASS_1(pcib, apb_driver, apb_methods, sizeof(struct apb_softc), - pcib_driver); -EARLY_DRIVER_MODULE(apb, pci, apb_driver, pcib_devclass, 0, 0, BUS_PASS_BUS); -MODULE_DEPEND(apb, pci, 1, 1, 1); - -/* APB specific registers */ -#define APBR_IOMAP 0xde -#define APBR_MEMMAP 0xdf - -/* Definitions for the mapping registers */ -#define APB_IO_SCALE 0x200000 -#define APB_MEM_SCALE 0x20000000 - -/* - * Generic device interface - */ -static int -apb_probe(device_t dev) -{ - - if (pci_get_vendor(dev) == 0x108e && /* Sun */ - pci_get_device(dev) == 0x5000) { /* APB */ - device_set_desc(dev, "APB PCI-PCI bridge"); - return (0); - } - return (ENXIO); -} - -static void -apb_map_print(uint8_t map, rman_res_t scale) -{ - int i, first; - - for (first = 1, i = 0; i < 8; i++) { - if ((map & (1 << i)) != 0) { - printf("%s0x%jx-0x%jx", first ? "" : ", ", - i * scale, (i + 1) * scale - 1); - first = 0; - } - } -} - -static int -apb_checkrange(uint8_t map, rman_res_t scale, rman_res_t start, rman_res_t end) -{ - int i, ei; - - i = start / scale; - ei = end / scale; - if (i > 7 || ei > 7) - return (0); - for (; i <= ei; i++) - if ((map & (1 << i)) == 0) - return (0); - return (1); -} - -static int -apb_attach(device_t dev) -{ - struct apb_softc *sc; - struct sysctl_ctx_list *sctx; - struct sysctl_oid *soid; - - sc = device_get_softc(dev); - - /* - * Get current bridge configuration. - */ - sc->sc_bsc.ops_pcib_sc.domain = pci_get_domain(dev); - sc->sc_bsc.ops_pcib_sc.pribus = pci_get_bus(dev); - pci_write_config(dev, PCIR_PRIBUS_1, sc->sc_bsc.ops_pcib_sc.pribus, 1); - sc->sc_bsc.ops_pcib_sc.bus.sec = - pci_read_config(dev, PCIR_SECBUS_1, 1); - sc->sc_bsc.ops_pcib_sc.bus.sub = - pci_read_config(dev, PCIR_SUBBUS_1, 1); - sc->sc_bsc.ops_pcib_sc.bridgectl = - pci_read_config(dev, PCIR_BRIDGECTL_1, 2); - sc->sc_iomap = pci_read_config(dev, APBR_IOMAP, 1); - sc->sc_memmap = pci_read_config(dev, APBR_MEMMAP, 1); - - /* - * Setup SYSCTL reporting nodes. - */ - sctx = device_get_sysctl_ctx(dev); - soid = device_get_sysctl_tree(dev); - SYSCTL_ADD_UINT(sctx, SYSCTL_CHILDREN(soid), OID_AUTO, "domain", - CTLFLAG_RD, &sc->sc_bsc.ops_pcib_sc.domain, 0, - "Domain number"); - SYSCTL_ADD_UINT(sctx, SYSCTL_CHILDREN(soid), OID_AUTO, "pribus", - CTLFLAG_RD, &sc->sc_bsc.ops_pcib_sc.pribus, 0, - "Primary bus number"); - SYSCTL_ADD_UINT(sctx, SYSCTL_CHILDREN(soid), OID_AUTO, "secbus", - CTLFLAG_RD, &sc->sc_bsc.ops_pcib_sc.bus.sec, 0, - "Secondary bus number"); - SYSCTL_ADD_UINT(sctx, SYSCTL_CHILDREN(soid), OID_AUTO, "subbus", - CTLFLAG_RD, &sc->sc_bsc.ops_pcib_sc.bus.sub, 0, - "Subordinate bus number"); - - ofw_pcib_gen_setup(dev); - - if (bootverbose) { - device_printf(dev, " domain %d\n", - sc->sc_bsc.ops_pcib_sc.domain); - device_printf(dev, " secondary bus %d\n", - sc->sc_bsc.ops_pcib_sc.bus.sec); - device_printf(dev, " subordinate bus %d\n", - sc->sc_bsc.ops_pcib_sc.bus.sub); - device_printf(dev, " I/O decode "); - apb_map_print(sc->sc_iomap, APB_IO_SCALE); - printf("\n"); - device_printf(dev, " memory decode "); - apb_map_print(sc->sc_memmap, APB_MEM_SCALE); - printf("\n"); - } - - device_add_child(dev, "pci", -1); - return (bus_generic_attach(dev)); -} - -/* - * We have to trap resource allocation requests and ensure that the bridge - * is set up to, or capable of handling them. - */ -static struct resource * -apb_alloc_resource(device_t dev, device_t child, int type, int *rid, - rman_res_t start, rman_res_t end, rman_res_t count, u_int flags) -{ - struct apb_softc *sc; - - sc = device_get_softc(dev); - - /* - * If this is a "default" allocation against this rid, we can't work - * out where it's coming from (we should actually never see these) so - * we just have to punt. - */ - if (RMAN_IS_DEFAULT_RANGE(start, end)) { - device_printf(dev, "can't decode default resource id %d for " - "%s, bypassing\n", *rid, device_get_nameunit(child)); - goto passup; - } - - /* - * Fail the allocation for this range if it's not supported. - * XXX we should probably just fix up the bridge decode and - * soldier on. - */ - switch (type) { - case SYS_RES_IOPORT: - if (!apb_checkrange(sc->sc_iomap, APB_IO_SCALE, start, end)) { - device_printf(dev, "device %s requested unsupported " - "I/O range 0x%jx-0x%jx\n", - device_get_nameunit(child), start, end); - return (NULL); - } - if (bootverbose) - device_printf(sc->sc_bsc.ops_pcib_sc.dev, "device " - "%s requested decoded I/O range 0x%jx-0x%jx\n", - device_get_nameunit(child), start, end); - break; - case SYS_RES_MEMORY: - if (!apb_checkrange(sc->sc_memmap, APB_MEM_SCALE, start, - end)) { - device_printf(dev, "device %s requested unsupported " - "memory range 0x%jx-0x%jx\n", - device_get_nameunit(child), start, end); - return (NULL); - } - if (bootverbose) - device_printf(sc->sc_bsc.ops_pcib_sc.dev, "device " - "%s requested decoded memory range 0x%jx-0x%jx\n", - device_get_nameunit(child), start, end); - break; - } - - passup: - /* - * Bridge is OK decoding this resource, so pass it up. - */ - return (bus_generic_alloc_resource(dev, child, type, rid, start, end, - count, flags)); -} - -static int -apb_adjust_resource(device_t dev, device_t child, int type, - struct resource *r, rman_res_t start, rman_res_t end) -{ - struct apb_softc *sc; - - sc = device_get_softc(dev); - switch (type) { - case SYS_RES_IOPORT: - if (!apb_checkrange(sc->sc_iomap, APB_IO_SCALE, start, end)) - return (ENXIO); - break; - case SYS_RES_MEMORY: - if (!apb_checkrange(sc->sc_memmap, APB_MEM_SCALE, start, end)) - return (ENXIO); - break; - } - return (bus_generic_adjust_resource(dev, child, type, r, start, end)); -} diff --git a/sys/sparc64/pci/fire.c b/sys/sparc64/pci/fire.c deleted file mode 100644 index b978d7bead0b..000000000000 --- a/sys/sparc64/pci/fire.c +++ /dev/null @@ -1,1877 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-3-Clause - * - * Copyright (c) 1999, 2000 Matthew R. Green - * Copyright (c) 2001 - 2003 by Thomas Moestl - * Copyright (c) 2009 by Marius Strobl - * 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. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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. - * - * from: NetBSD: psycho.c,v 1.39 2001/10/07 20:30:41 eeh Exp - * from: FreeBSD: psycho.c 183152 2008-09-18 19:45:22Z marius - */ - -#include -__FBSDID("$FreeBSD$"); - -/* - * Driver for `Fire' JBus to PCI Express and `Oberon' Uranus to PCI Express - * bridges - */ - -#include "opt_fire.h" -#include "opt_ofw_pci.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include -#include - -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include -#include -#include - -#include "pcib_if.h" - -struct fire_msiqarg; - -static const struct fire_desc *fire_get_desc(device_t dev); -static void fire_dmamap_sync(bus_dma_tag_t dt __unused, bus_dmamap_t map, - bus_dmasync_op_t op); -static int fire_get_intrmap(struct fire_softc *sc, u_int ino, - bus_addr_t *intrmapptr, bus_addr_t *intrclrptr); -static void fire_intr_assign(void *arg); -static void fire_intr_clear(void *arg); -static void fire_intr_disable(void *arg); -static void fire_intr_enable(void *arg); -static int fire_intr_register(struct fire_softc *sc, u_int ino); -static inline void fire_msiq_common(struct intr_vector *iv, - struct fire_msiqarg *fmqa); -static void fire_msiq_filter(void *cookie); -static void fire_msiq_handler(void *cookie); -static void fire_set_intr(struct fire_softc *sc, u_int index, u_int ino, - driver_filter_t handler, void *arg); -static timecounter_get_t fire_get_timecount; - -/* Interrupt handlers */ -static driver_filter_t fire_dmc_pec; -static driver_filter_t fire_pcie; -static driver_filter_t fire_xcb; - -/* - * Methods - */ -static pcib_alloc_msi_t fire_alloc_msi; -static pcib_alloc_msix_t fire_alloc_msix; -static bus_alloc_resource_t fire_alloc_resource; -static device_attach_t fire_attach; -static pcib_map_msi_t fire_map_msi; -static pcib_maxslots_t fire_maxslots; -static device_probe_t fire_probe; -static pcib_read_config_t fire_read_config; -static pcib_release_msi_t fire_release_msi; -static pcib_release_msix_t fire_release_msix; -static pcib_route_interrupt_t fire_route_interrupt; -static bus_setup_intr_t fire_setup_intr; -static bus_teardown_intr_t fire_teardown_intr; -static pcib_write_config_t fire_write_config; - -static device_method_t fire_methods[] = { - /* Device interface */ - DEVMETHOD(device_probe, fire_probe), - DEVMETHOD(device_attach, fire_attach), - DEVMETHOD(device_shutdown, bus_generic_shutdown), - DEVMETHOD(device_suspend, bus_generic_suspend), - DEVMETHOD(device_resume, bus_generic_resume), - - /* Bus interface */ - DEVMETHOD(bus_read_ivar, ofw_pci_read_ivar), - DEVMETHOD(bus_setup_intr, fire_setup_intr), - DEVMETHOD(bus_teardown_intr, fire_teardown_intr), - DEVMETHOD(bus_alloc_resource, fire_alloc_resource), - DEVMETHOD(bus_activate_resource, ofw_pci_activate_resource), - DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource), - DEVMETHOD(bus_adjust_resource, ofw_pci_adjust_resource), - DEVMETHOD(bus_release_resource, bus_generic_release_resource), - DEVMETHOD(bus_get_dma_tag, ofw_pci_get_dma_tag), - - /* pcib interface */ - DEVMETHOD(pcib_maxslots, fire_maxslots), - DEVMETHOD(pcib_read_config, fire_read_config), - DEVMETHOD(pcib_write_config, fire_write_config), - DEVMETHOD(pcib_route_interrupt, fire_route_interrupt), - DEVMETHOD(pcib_alloc_msi, fire_alloc_msi), - DEVMETHOD(pcib_release_msi, fire_release_msi), - DEVMETHOD(pcib_alloc_msix, fire_alloc_msix), - DEVMETHOD(pcib_release_msix, fire_release_msix), - DEVMETHOD(pcib_map_msi, fire_map_msi), - DEVMETHOD(pcib_request_feature, pcib_request_feature_allow), - - /* ofw_bus interface */ - DEVMETHOD(ofw_bus_get_node, ofw_pci_get_node), - - DEVMETHOD_END -}; - -static devclass_t fire_devclass; - -DEFINE_CLASS_0(pcib, fire_driver, fire_methods, sizeof(struct fire_softc)); -EARLY_DRIVER_MODULE(fire, nexus, fire_driver, fire_devclass, 0, 0, - BUS_PASS_BUS); -MODULE_DEPEND(fire, nexus, 1, 1, 1); - -static const struct intr_controller fire_ic = { - fire_intr_enable, - fire_intr_disable, - fire_intr_assign, - fire_intr_clear -}; - -struct fire_icarg { - struct fire_softc *fica_sc; - bus_addr_t fica_map; - bus_addr_t fica_clr; -}; - -static const struct intr_controller fire_msiqc_filter = { - fire_intr_enable, - fire_intr_disable, - fire_intr_assign, - NULL -}; - -struct fire_msiqarg { - struct fire_icarg fmqa_fica; - struct mtx fmqa_mtx; - struct fo_msiq_record *fmqa_base; - uint64_t fmqa_head; - uint64_t fmqa_tail; - uint32_t fmqa_msiq; - uint32_t fmqa_msi; -}; - -#define FIRE_PERF_CNT_QLTY 100 - -#define FIRE_SPC_BARRIER(spc, sc, offs, len, flags) \ - bus_barrier((sc)->sc_mem_res[(spc)], (offs), (len), (flags)) -#define FIRE_SPC_READ_8(spc, sc, offs) \ - bus_read_8((sc)->sc_mem_res[(spc)], (offs)) -#define FIRE_SPC_WRITE_8(spc, sc, offs, v) \ - bus_write_8((sc)->sc_mem_res[(spc)], (offs), (v)) - -#ifndef FIRE_DEBUG -#define FIRE_SPC_SET(spc, sc, offs, reg, v) \ - FIRE_SPC_WRITE_8((spc), (sc), (offs), (v)) -#else -#define FIRE_SPC_SET(spc, sc, offs, reg, v) do { \ - device_printf((sc)->sc_dev, reg " 0x%016llx -> 0x%016llx\n", \ - (unsigned long long)FIRE_SPC_READ_8((spc), (sc), (offs)), \ - (unsigned long long)(v)); \ - FIRE_SPC_WRITE_8((spc), (sc), (offs), (v)); \ - } while (0) -#endif - -#define FIRE_PCI_BARRIER(sc, offs, len, flags) \ - FIRE_SPC_BARRIER(FIRE_PCI, (sc), (offs), len, flags) -#define FIRE_PCI_READ_8(sc, offs) \ - FIRE_SPC_READ_8(FIRE_PCI, (sc), (offs)) -#define FIRE_PCI_WRITE_8(sc, offs, v) \ - FIRE_SPC_WRITE_8(FIRE_PCI, (sc), (offs), (v)) -#define FIRE_CTRL_BARRIER(sc, offs, len, flags) \ - FIRE_SPC_BARRIER(FIRE_CTRL, (sc), (offs), len, flags) -#define FIRE_CTRL_READ_8(sc, offs) \ - FIRE_SPC_READ_8(FIRE_CTRL, (sc), (offs)) -#define FIRE_CTRL_WRITE_8(sc, offs, v) \ - FIRE_SPC_WRITE_8(FIRE_CTRL, (sc), (offs), (v)) - -#define FIRE_PCI_SET(sc, offs, v) \ - FIRE_SPC_SET(FIRE_PCI, (sc), (offs), # offs, (v)) -#define FIRE_CTRL_SET(sc, offs, v) \ - FIRE_SPC_SET(FIRE_CTRL, (sc), (offs), # offs, (v)) - -struct fire_desc { - const char *fd_string; - int fd_mode; - const char *fd_name; -}; - -static const struct fire_desc fire_compats[] = { - { "pciex108e,80f0", FIRE_MODE_FIRE, "Fire" }, -#if 0 - { "pciex108e,80f8", FIRE_MODE_OBERON, "Oberon" }, -#endif - { NULL, 0, NULL } -}; - -static const struct fire_desc * -fire_get_desc(device_t dev) -{ - const struct fire_desc *desc; - const char *compat; - - compat = ofw_bus_get_compat(dev); - if (compat == NULL) - return (NULL); - for (desc = fire_compats; desc->fd_string != NULL; desc++) - if (strcmp(desc->fd_string, compat) == 0) - return (desc); - return (NULL); -} - -static int -fire_probe(device_t dev) -{ - const char *dtype; - - dtype = ofw_bus_get_type(dev); - if (dtype != NULL && strcmp(dtype, OFW_TYPE_PCIE) == 0 && - fire_get_desc(dev) != NULL) { - device_set_desc(dev, "Sun Host-PCIe bridge"); - return (BUS_PROBE_GENERIC); - } - return (ENXIO); -} - -static int -fire_attach(device_t dev) -{ - struct fire_softc *sc; - const struct fire_desc *desc; - struct ofw_pci_msi_ranges msi_ranges; - struct ofw_pci_msi_addr_ranges msi_addr_ranges; - struct ofw_pci_msi_eq_to_devino msi_eq_to_devino; - struct fire_msiqarg *fmqa; - struct timecounter *tc; - bus_dma_tag_t dmat; - uint64_t ino_bitmap, val; - phandle_t node; - uint32_t prop, prop_array[2]; - int i, j, mode; - u_int lw; - uint16_t mps; - - sc = device_get_softc(dev); - node = ofw_bus_get_node(dev); - desc = fire_get_desc(dev); - mode = desc->fd_mode; - - sc->sc_dev = dev; - sc->sc_mode = mode; - sc->sc_flags = 0; - - mtx_init(&sc->sc_msi_mtx, "msi_mtx", NULL, MTX_DEF); - mtx_init(&sc->sc_pcib_mtx, "pcib_mtx", NULL, MTX_SPIN); - - /* - * Fire and Oberon have two register banks: - * (0) per-PBM PCI Express configuration and status registers - * (1) (shared) Fire/Oberon controller configuration and status - * registers - */ - for (i = 0; i < FIRE_NREG; i++) { - j = i; - sc->sc_mem_res[i] = bus_alloc_resource_any(dev, - SYS_RES_MEMORY, &j, RF_ACTIVE); - if (sc->sc_mem_res[i] == NULL) - panic("%s: could not allocate register bank %d", - __func__, i); - } - - if (OF_getprop(node, "portid", &sc->sc_ign, sizeof(sc->sc_ign)) == -1) - panic("%s: could not determine IGN", __func__); - if (OF_getprop(node, "module-revision#", &prop, sizeof(prop)) == -1) - panic("%s: could not determine module-revision", __func__); - - device_printf(dev, "%s, module-revision %d, IGN %#x\n", - desc->fd_name, prop, sc->sc_ign); - - /* - * Hunt through all the interrupt mapping regs and register - * the interrupt controller for our interrupt vectors. We do - * this early in order to be able to catch stray interrupts. - */ - i = OF_getprop(node, "ino-bitmap", (void *)prop_array, - sizeof(prop_array)); - if (i == -1) - panic("%s: could not get ino-bitmap", __func__); - ino_bitmap = ((uint64_t)prop_array[1] << 32) | prop_array[0]; - for (i = 0; i <= FO_MAX_INO; i++) { - if ((ino_bitmap & (1ULL << i)) == 0) - continue; - j = fire_intr_register(sc, i); - if (j != 0) - device_printf(dev, "could not register interrupt " - "controller for INO %d (%d)\n", i, j); - } - - /* JBC/UBC module initialization */ - FIRE_CTRL_SET(sc, FO_XBC_ERR_LOG_EN, ~0ULL); - FIRE_CTRL_SET(sc, FO_XBC_ERR_STAT_CLR, ~0ULL); - /* not enabled by OpenSolaris */ - FIRE_CTRL_SET(sc, FO_XBC_INT_EN, ~0ULL); - if (sc->sc_mode == FIRE_MODE_FIRE) { - FIRE_CTRL_SET(sc, FIRE_JBUS_PAR_CTRL, - FIRE_JBUS_PAR_CTRL_P_EN); - FIRE_CTRL_SET(sc, FIRE_JBC_FATAL_RST_EN, - ((1ULL << FIRE_JBC_FATAL_RST_EN_SPARE_P_INT_SHFT) & - FIRE_JBC_FATAL_RST_EN_SPARE_P_INT_MASK) | - FIRE_JBC_FATAL_RST_EN_MB_PEA_P_INT | - FIRE_JBC_FATAL_RST_EN_CPE_P_INT | - FIRE_JBC_FATAL_RST_EN_APE_P_INT | - FIRE_JBC_FATAL_RST_EN_PIO_CPE_INT | - FIRE_JBC_FATAL_RST_EN_JTCEEW_P_INT | - FIRE_JBC_FATAL_RST_EN_JTCEEI_P_INT | - FIRE_JBC_FATAL_RST_EN_JTCEER_P_INT); - FIRE_CTRL_SET(sc, FIRE_JBC_CORE_BLOCK_INT_EN, ~0ULL); - } - - /* TLU initialization */ - FIRE_PCI_SET(sc, FO_PCI_TLU_OEVENT_STAT_CLR, - FO_PCI_TLU_OEVENT_S_MASK | FO_PCI_TLU_OEVENT_P_MASK); - /* not enabled by OpenSolaris */ - FIRE_PCI_SET(sc, FO_PCI_TLU_OEVENT_INT_EN, - FO_PCI_TLU_OEVENT_S_MASK | FO_PCI_TLU_OEVENT_P_MASK); - FIRE_PCI_SET(sc, FO_PCI_TLU_UERR_STAT_CLR, - FO_PCI_TLU_UERR_INT_S_MASK | FO_PCI_TLU_UERR_INT_P_MASK); - /* not enabled by OpenSolaris */ - FIRE_PCI_SET(sc, FO_PCI_TLU_UERR_INT_EN, - FO_PCI_TLU_UERR_INT_S_MASK | FO_PCI_TLU_UERR_INT_P_MASK); - FIRE_PCI_SET(sc, FO_PCI_TLU_CERR_STAT_CLR, - FO_PCI_TLU_CERR_INT_S_MASK | FO_PCI_TLU_CERR_INT_P_MASK); - /* not enabled by OpenSolaris */ - FIRE_PCI_SET(sc, FO_PCI_TLU_CERR_INT_EN, - FO_PCI_TLU_CERR_INT_S_MASK | FO_PCI_TLU_CERR_INT_P_MASK); - val = FIRE_PCI_READ_8(sc, FO_PCI_TLU_CTRL) | - ((FO_PCI_TLU_CTRL_L0S_TIM_DFLT << FO_PCI_TLU_CTRL_L0S_TIM_SHFT) & - FO_PCI_TLU_CTRL_L0S_TIM_MASK) | - ((FO_PCI_TLU_CTRL_CFG_DFLT << FO_PCI_TLU_CTRL_CFG_SHFT) & - FO_PCI_TLU_CTRL_CFG_MASK); - if (sc->sc_mode == FIRE_MODE_OBERON) - val &= ~FO_PCI_TLU_CTRL_NWPR_EN; - val |= FO_PCI_TLU_CTRL_CFG_REMAIN_DETECT_QUIET; - FIRE_PCI_SET(sc, FO_PCI_TLU_CTRL, val); - FIRE_PCI_SET(sc, FO_PCI_TLU_DEV_CTRL, 0); - FIRE_PCI_SET(sc, FO_PCI_TLU_LNK_CTRL, FO_PCI_TLU_LNK_CTRL_CLK); - - /* DLU/LPU initialization */ - if (sc->sc_mode == FIRE_MODE_OBERON) - FIRE_PCI_SET(sc, FO_PCI_LPU_INT_MASK, 0); - else - FIRE_PCI_SET(sc, FO_PCI_LPU_RST, 0); - FIRE_PCI_SET(sc, FO_PCI_LPU_LNK_LYR_CFG, - FO_PCI_LPU_LNK_LYR_CFG_VC0_EN); - FIRE_PCI_SET(sc, FO_PCI_LPU_FLW_CTRL_UPDT_CTRL, - FO_PCI_LPU_FLW_CTRL_UPDT_CTRL_FC0_NP_EN | - FO_PCI_LPU_FLW_CTRL_UPDT_CTRL_FC0_P_EN); - if (sc->sc_mode == FIRE_MODE_OBERON) - FIRE_PCI_SET(sc, FO_PCI_LPU_TXLNK_RPLY_TMR_THRS, - (OBERON_PCI_LPU_TXLNK_RPLY_TMR_THRS_DFLT << - FO_PCI_LPU_TXLNK_RPLY_TMR_THRS_SHFT) & - FO_PCI_LPU_TXLNK_RPLY_TMR_THRS_MASK); - else { - switch ((FIRE_PCI_READ_8(sc, FO_PCI_TLU_LNK_STAT) & - FO_PCI_TLU_LNK_STAT_WDTH_MASK) >> - FO_PCI_TLU_LNK_STAT_WDTH_SHFT) { - case 1: - lw = 0; - break; - case 4: - lw = 1; - break; - case 8: - lw = 2; - break; - case 16: - lw = 3; - break; - default: - lw = 0; - } - mps = (FIRE_PCI_READ_8(sc, FO_PCI_TLU_CTRL) & - FO_PCI_TLU_CTRL_CFG_MPS_MASK) >> - FO_PCI_TLU_CTRL_CFG_MPS_SHFT; - i = sizeof(fire_freq_nak_tmr_thrs) / - sizeof(*fire_freq_nak_tmr_thrs); - if (mps >= i) - mps = i - 1; - FIRE_PCI_SET(sc, FO_PCI_LPU_TXLNK_FREQ_LAT_TMR_THRS, - (fire_freq_nak_tmr_thrs[mps][lw] << - FO_PCI_LPU_TXLNK_FREQ_LAT_TMR_THRS_SHFT) & - FO_PCI_LPU_TXLNK_FREQ_LAT_TMR_THRS_MASK); - FIRE_PCI_SET(sc, FO_PCI_LPU_TXLNK_RPLY_TMR_THRS, - (fire_rply_tmr_thrs[mps][lw] << - FO_PCI_LPU_TXLNK_RPLY_TMR_THRS_SHFT) & - FO_PCI_LPU_TXLNK_RPLY_TMR_THRS_MASK); - FIRE_PCI_SET(sc, FO_PCI_LPU_TXLNK_RTR_FIFO_PTR, - ((FO_PCI_LPU_TXLNK_RTR_FIFO_PTR_TL_DFLT << - FO_PCI_LPU_TXLNK_RTR_FIFO_PTR_TL_SHFT) & - FO_PCI_LPU_TXLNK_RTR_FIFO_PTR_TL_MASK) | - ((FO_PCI_LPU_TXLNK_RTR_FIFO_PTR_HD_DFLT << - FO_PCI_LPU_TXLNK_RTR_FIFO_PTR_HD_SHFT) & - FO_PCI_LPU_TXLNK_RTR_FIFO_PTR_HD_MASK)); - FIRE_PCI_SET(sc, FO_PCI_LPU_LTSSM_CFG2, - (FO_PCI_LPU_LTSSM_CFG2_12_TO_DFLT << - FO_PCI_LPU_LTSSM_CFG2_12_TO_SHFT) & - FO_PCI_LPU_LTSSM_CFG2_12_TO_MASK); - FIRE_PCI_SET(sc, FO_PCI_LPU_LTSSM_CFG3, - (FO_PCI_LPU_LTSSM_CFG3_2_TO_DFLT << - FO_PCI_LPU_LTSSM_CFG3_2_TO_SHFT) & - FO_PCI_LPU_LTSSM_CFG3_2_TO_MASK); - FIRE_PCI_SET(sc, FO_PCI_LPU_LTSSM_CFG4, - ((FO_PCI_LPU_LTSSM_CFG4_DATA_RATE_DFLT << - FO_PCI_LPU_LTSSM_CFG4_DATA_RATE_SHFT) & - FO_PCI_LPU_LTSSM_CFG4_DATA_RATE_MASK) | - ((FO_PCI_LPU_LTSSM_CFG4_N_FTS_DFLT << - FO_PCI_LPU_LTSSM_CFG4_N_FTS_SHFT) & - FO_PCI_LPU_LTSSM_CFG4_N_FTS_MASK)); - FIRE_PCI_SET(sc, FO_PCI_LPU_LTSSM_CFG5, 0); - } - - /* ILU initialization */ - FIRE_PCI_SET(sc, FO_PCI_ILU_ERR_STAT_CLR, ~0ULL); - /* not enabled by OpenSolaris */ - FIRE_PCI_SET(sc, FO_PCI_ILU_INT_EN, ~0ULL); - - /* IMU initialization */ - FIRE_PCI_SET(sc, FO_PCI_IMU_ERR_STAT_CLR, ~0ULL); - FIRE_PCI_SET(sc, FO_PCI_IMU_INT_EN, - FIRE_PCI_READ_8(sc, FO_PCI_IMU_INT_EN) & - ~(FO_PCI_IMU_ERR_INT_FATAL_MES_NOT_EN_S | - FO_PCI_IMU_ERR_INT_NFATAL_MES_NOT_EN_S | - FO_PCI_IMU_ERR_INT_COR_MES_NOT_EN_S | - FO_PCI_IMU_ERR_INT_FATAL_MES_NOT_EN_P | - FO_PCI_IMU_ERR_INT_NFATAL_MES_NOT_EN_P | - FO_PCI_IMU_ERR_INT_COR_MES_NOT_EN_P)); - - /* MMU initialization */ - FIRE_PCI_SET(sc, FO_PCI_MMU_ERR_STAT_CLR, - FO_PCI_MMU_ERR_INT_S_MASK | FO_PCI_MMU_ERR_INT_P_MASK); - /* not enabled by OpenSolaris */ - FIRE_PCI_SET(sc, FO_PCI_MMU_INT_EN, - FO_PCI_MMU_ERR_INT_S_MASK | FO_PCI_MMU_ERR_INT_P_MASK); - - /* DMC initialization */ - FIRE_PCI_SET(sc, FO_PCI_DMC_CORE_BLOCK_INT_EN, ~0ULL); - FIRE_PCI_SET(sc, FO_PCI_DMC_DBG_SEL_PORTA, 0); - FIRE_PCI_SET(sc, FO_PCI_DMC_DBG_SEL_PORTB, 0); - - /* PEC initialization */ - FIRE_PCI_SET(sc, FO_PCI_PEC_CORE_BLOCK_INT_EN, ~0ULL); - - /* Establish handlers for interesting interrupts. */ - if ((ino_bitmap & (1ULL << FO_DMC_PEC_INO)) != 0) - fire_set_intr(sc, 1, FO_DMC_PEC_INO, fire_dmc_pec, sc); - if ((ino_bitmap & (1ULL << FO_XCB_INO)) != 0) - fire_set_intr(sc, 0, FO_XCB_INO, fire_xcb, sc); - - /* MSI/MSI-X support */ - if (OF_getprop(node, "#msi", &sc->sc_msi_count, - sizeof(sc->sc_msi_count)) == -1) - panic("%s: could not determine MSI count", __func__); - if (OF_getprop(node, "msi-ranges", &msi_ranges, - sizeof(msi_ranges)) == -1) - sc->sc_msi_first = 0; - else - sc->sc_msi_first = msi_ranges.first; - if (OF_getprop(node, "msi-data-mask", &sc->sc_msi_data_mask, - sizeof(sc->sc_msi_data_mask)) == -1) - panic("%s: could not determine MSI data mask", __func__); - if (OF_getprop(node, "msix-data-width", &sc->sc_msix_data_width, - sizeof(sc->sc_msix_data_width)) > 0) - sc->sc_flags |= FIRE_MSIX; - if (OF_getprop(node, "msi-address-ranges", &msi_addr_ranges, - sizeof(msi_addr_ranges)) == -1) - panic("%s: could not determine MSI address ranges", __func__); - sc->sc_msi_addr32 = OFW_PCI_MSI_ADDR_RANGE_32(&msi_addr_ranges); - sc->sc_msi_addr64 = OFW_PCI_MSI_ADDR_RANGE_64(&msi_addr_ranges); - if (OF_getprop(node, "#msi-eqs", &sc->sc_msiq_count, - sizeof(sc->sc_msiq_count)) == -1) - panic("%s: could not determine MSI event queue count", - __func__); - if (OF_getprop(node, "msi-eq-size", &sc->sc_msiq_size, - sizeof(sc->sc_msiq_size)) == -1) - panic("%s: could not determine MSI event queue size", - __func__); - if (OF_getprop(node, "msi-eq-to-devino", &msi_eq_to_devino, - sizeof(msi_eq_to_devino)) == -1 && - OF_getprop(node, "msi-eq-devino", &msi_eq_to_devino, - sizeof(msi_eq_to_devino)) == -1) { - sc->sc_msiq_first = 0; - sc->sc_msiq_ino_first = FO_EQ_FIRST_INO; - } else { - sc->sc_msiq_first = msi_eq_to_devino.eq_first; - sc->sc_msiq_ino_first = msi_eq_to_devino.devino_first; - } - if (sc->sc_msiq_ino_first < FO_EQ_FIRST_INO || - sc->sc_msiq_ino_first + sc->sc_msiq_count - 1 > FO_EQ_LAST_INO) - panic("%s: event queues exceed INO range", __func__); - sc->sc_msi_bitmap = malloc(roundup2(sc->sc_msi_count, NBBY) / NBBY, - M_DEVBUF, M_NOWAIT | M_ZERO); - if (sc->sc_msi_bitmap == NULL) - panic("%s: could not malloc MSI bitmap", __func__); - sc->sc_msi_msiq_table = malloc(sc->sc_msi_count * - sizeof(*sc->sc_msi_msiq_table), M_DEVBUF, M_NOWAIT | M_ZERO); - if (sc->sc_msi_msiq_table == NULL) - panic("%s: could not malloc MSI-MSI event queue table", - __func__); - sc->sc_msiq_bitmap = malloc(roundup2(sc->sc_msiq_count, NBBY) / NBBY, - M_DEVBUF, M_NOWAIT | M_ZERO); - if (sc->sc_msiq_bitmap == NULL) - panic("%s: could not malloc MSI event queue bitmap", __func__); - j = FO_EQ_RECORD_SIZE * FO_EQ_NRECORDS * sc->sc_msiq_count; - sc->sc_msiq = contigmalloc(j, M_DEVBUF, M_NOWAIT, 0, ~0UL, - FO_EQ_ALIGNMENT, 0); - if (sc->sc_msiq == NULL) - panic("%s: could not contigmalloc MSI event queue", __func__); - memset(sc->sc_msiq, 0, j); - FIRE_PCI_SET(sc, FO_PCI_EQ_BASE_ADDR, FO_PCI_EQ_BASE_ADDR_BYPASS | - (pmap_kextract((vm_offset_t)sc->sc_msiq) & - FO_PCI_EQ_BASE_ADDR_MASK)); - for (i = 0; i < sc->sc_msi_count; i++) { - j = (i + sc->sc_msi_first) << 3; - FIRE_PCI_WRITE_8(sc, FO_PCI_MSI_MAP_BASE + j, - FIRE_PCI_READ_8(sc, FO_PCI_MSI_MAP_BASE + j) & - ~FO_PCI_MSI_MAP_V); - } - for (i = 0; i < sc->sc_msiq_count; i++) { - j = i + sc->sc_msiq_ino_first; - if ((ino_bitmap & (1ULL << j)) == 0) { - mtx_lock(&sc->sc_msi_mtx); - setbit(sc->sc_msiq_bitmap, i); - mtx_unlock(&sc->sc_msi_mtx); - } - fmqa = intr_vectors[INTMAP_VEC(sc->sc_ign, j)].iv_icarg; - mtx_init(&fmqa->fmqa_mtx, "msiq_mtx", NULL, MTX_SPIN); - fmqa->fmqa_base = - (struct fo_msiq_record *)((caddr_t)sc->sc_msiq + - (FO_EQ_RECORD_SIZE * FO_EQ_NRECORDS * i)); - j = i + sc->sc_msiq_first; - fmqa->fmqa_msiq = j; - j <<= 3; - fmqa->fmqa_head = FO_PCI_EQ_HD_BASE + j; - fmqa->fmqa_tail = FO_PCI_EQ_TL_BASE + j; - FIRE_PCI_WRITE_8(sc, FO_PCI_EQ_CTRL_CLR_BASE + j, - FO_PCI_EQ_CTRL_CLR_COVERR | FO_PCI_EQ_CTRL_CLR_E2I | - FO_PCI_EQ_CTRL_CLR_DIS); - FIRE_PCI_WRITE_8(sc, fmqa->fmqa_tail, - (0 << FO_PCI_EQ_TL_SHFT) & FO_PCI_EQ_TL_MASK); - FIRE_PCI_WRITE_8(sc, fmqa->fmqa_head, - (0 << FO_PCI_EQ_HD_SHFT) & FO_PCI_EQ_HD_MASK); - } - FIRE_PCI_SET(sc, FO_PCI_MSI_32_BIT_ADDR, sc->sc_msi_addr32 & - FO_PCI_MSI_32_BIT_ADDR_MASK); - FIRE_PCI_SET(sc, FO_PCI_MSI_64_BIT_ADDR, sc->sc_msi_addr64 & - FO_PCI_MSI_64_BIT_ADDR_MASK); - - /* - * Establish a handler for interesting PCIe messages and disable - * unintersting ones. - */ - mtx_lock(&sc->sc_msi_mtx); - for (i = 0; i < sc->sc_msiq_count; i++) { - if (isclr(sc->sc_msiq_bitmap, i) != 0) { - j = i; - break; - } - } - if (i == sc->sc_msiq_count) { - mtx_unlock(&sc->sc_msi_mtx); - panic("%s: no spare event queue for PCIe messages", __func__); - } - setbit(sc->sc_msiq_bitmap, j); - mtx_unlock(&sc->sc_msi_mtx); - i = INTMAP_VEC(sc->sc_ign, j + sc->sc_msiq_ino_first); - if (bus_set_resource(dev, SYS_RES_IRQ, 2, i, 1) != 0) - panic("%s: failed to add interrupt for PCIe messages", - __func__); - fire_set_intr(sc, 2, INTINO(i), fire_pcie, intr_vectors[i].iv_icarg); - j += sc->sc_msiq_first; - /* - * "Please note that setting the EQNUM field to a value larger than - * 35 will yield unpredictable results." - */ - if (j > 35) - panic("%s: invalid queue for PCIe messages (%d)", - __func__, j); - FIRE_PCI_SET(sc, FO_PCI_ERR_COR, FO_PCI_ERR_PME_V | - ((j << FO_PCI_ERR_PME_EQNUM_SHFT) & FO_PCI_ERR_PME_EQNUM_MASK)); - FIRE_PCI_SET(sc, FO_PCI_ERR_NONFATAL, FO_PCI_ERR_PME_V | - ((j << FO_PCI_ERR_PME_EQNUM_SHFT) & FO_PCI_ERR_PME_EQNUM_MASK)); - FIRE_PCI_SET(sc, FO_PCI_ERR_FATAL, FO_PCI_ERR_PME_V | - ((j << FO_PCI_ERR_PME_EQNUM_SHFT) & FO_PCI_ERR_PME_EQNUM_MASK)); - FIRE_PCI_SET(sc, FO_PCI_PM_PME, 0); - FIRE_PCI_SET(sc, FO_PCI_PME_TO_ACK, 0); - FIRE_PCI_WRITE_8(sc, FO_PCI_EQ_CTRL_SET_BASE + (j << 3), - FO_PCI_EQ_CTRL_SET_EN); - -#define TC_COUNTER_MAX_MASK 0xffffffff - - /* - * Setup JBC/UBC performance counter 0 in bus cycle counting - * mode as timecounter. - */ - if (device_get_unit(dev) == 0) { - FIRE_CTRL_SET(sc, FO_XBC_PRF_CNT0, 0); - FIRE_CTRL_SET(sc, FO_XBC_PRF_CNT1, 0); - FIRE_CTRL_SET(sc, FO_XBC_PRF_CNT_SEL, - (FO_XBC_PRF_CNT_NONE << FO_XBC_PRF_CNT_CNT1_SHFT) | - (FO_XBC_PRF_CNT_XB_CLK << FO_XBC_PRF_CNT_CNT0_SHFT)); - tc = malloc(sizeof(*tc), M_DEVBUF, M_NOWAIT | M_ZERO); - if (tc == NULL) - panic("%s: could not malloc timecounter", __func__); - tc->tc_get_timecount = fire_get_timecount; - tc->tc_counter_mask = TC_COUNTER_MAX_MASK; - if (OF_getprop(OF_peer(0), "clock-frequency", &prop, - sizeof(prop)) == -1) - panic("%s: could not determine clock frequency", - __func__); - tc->tc_frequency = prop; - tc->tc_name = strdup(device_get_nameunit(dev), M_DEVBUF); - tc->tc_priv = sc; - /* - * Due to initial problems with the JBus-driven performance - * counters not advancing which might be firmware dependent - * ensure that it actually works. - */ - if (fire_get_timecount(tc) - fire_get_timecount(tc) != 0) - tc->tc_quality = FIRE_PERF_CNT_QLTY; - else - tc->tc_quality = -FIRE_PERF_CNT_QLTY; - tc_init(tc); - } - - /* - * Set up the IOMMU. Both Fire and Oberon have one per PBM, but - * neither has a streaming buffer. - */ - memcpy(&sc->sc_dma_methods, &iommu_dma_methods, - sizeof(sc->sc_dma_methods)); - sc->sc_is.is_flags = IOMMU_FIRE | IOMMU_PRESERVE_PROM; - if (sc->sc_mode == FIRE_MODE_OBERON) { - sc->sc_is.is_flags |= IOMMU_FLUSH_CACHE; - sc->sc_is.is_pmaxaddr = IOMMU_MAXADDR(OBERON_IOMMU_BITS); - } else { - sc->sc_dma_methods.dm_dmamap_sync = fire_dmamap_sync; - sc->sc_is.is_pmaxaddr = IOMMU_MAXADDR(FIRE_IOMMU_BITS); - } - sc->sc_is.is_sb[0] = sc->sc_is.is_sb[1] = 0; - /* Punch in our copies. */ - sc->sc_is.is_bustag = rman_get_bustag(sc->sc_mem_res[FIRE_PCI]); - sc->sc_is.is_bushandle = rman_get_bushandle(sc->sc_mem_res[FIRE_PCI]); - sc->sc_is.is_iommu = FO_PCI_MMU; - val = FIRE_PCI_READ_8(sc, FO_PCI_MMU + IMR_CTL); - iommu_init(device_get_nameunit(dev), &sc->sc_is, 7, -1, 0); -#ifdef FIRE_DEBUG - device_printf(dev, "FO_PCI_MMU + IMR_CTL 0x%016llx -> 0x%016llx\n", - (long long unsigned)val, (long long unsigned)sc->sc_is.is_cr); -#endif - /* Create our DMA tag. */ - if (bus_dma_tag_create(bus_get_dma_tag(dev), 8, 0x100000000, - sc->sc_is.is_pmaxaddr, ~0, NULL, NULL, sc->sc_is.is_pmaxaddr, - 0xff, 0xffffffff, 0, NULL, NULL, &dmat) != 0) - panic("%s: could not create PCI DMA tag", __func__); - dmat->dt_cookie = &sc->sc_is; - dmat->dt_mt = &sc->sc_dma_methods; - - if (ofw_pci_attach_common(dev, dmat, FO_IO_SIZE, FO_MEM_SIZE) != 0) - panic("%s: ofw_pci_attach_common() failed", __func__); - -#define FIRE_SYSCTL_ADD_UINT(name, arg, desc) \ - SYSCTL_ADD_UINT(device_get_sysctl_ctx(dev), \ - SYSCTL_CHILDREN(device_get_sysctl_tree(dev)), OID_AUTO, \ - (name), CTLFLAG_RD, (arg), 0, (desc)) - - FIRE_SYSCTL_ADD_UINT("ilu_err", &sc->sc_stats_ilu_err, - "ILU unknown errors"); - FIRE_SYSCTL_ADD_UINT("jbc_ce_async", &sc->sc_stats_jbc_ce_async, - "JBC correctable errors"); - FIRE_SYSCTL_ADD_UINT("jbc_unsol_int", &sc->sc_stats_jbc_unsol_int, - "JBC unsolicited interrupt ACK/NACK errors"); - FIRE_SYSCTL_ADD_UINT("jbc_unsol_rd", &sc->sc_stats_jbc_unsol_rd, - "JBC unsolicited read response errors"); - FIRE_SYSCTL_ADD_UINT("mmu_err", &sc->sc_stats_mmu_err, "MMU errors"); - FIRE_SYSCTL_ADD_UINT("tlu_ce", &sc->sc_stats_tlu_ce, - "DLU/TLU correctable errors"); - FIRE_SYSCTL_ADD_UINT("tlu_oe_non_fatal", - &sc->sc_stats_tlu_oe_non_fatal, - "DLU/TLU other event non-fatal errors summary"); - FIRE_SYSCTL_ADD_UINT("tlu_oe_rx_err", &sc->sc_stats_tlu_oe_rx_err, - "DLU/TLU receive other event errors"); - FIRE_SYSCTL_ADD_UINT("tlu_oe_tx_err", &sc->sc_stats_tlu_oe_tx_err, - "DLU/TLU transmit other event errors"); - FIRE_SYSCTL_ADD_UINT("ubc_dmardue", &sc->sc_stats_ubc_dmardue, - "UBC DMARDUE erros"); - -#undef FIRE_SYSCTL_ADD_UINT - - device_add_child(dev, "pci", -1); - return (bus_generic_attach(dev)); -} - -static void -fire_set_intr(struct fire_softc *sc, u_int index, u_int ino, - driver_filter_t handler, void *arg) -{ - u_long vec; - int rid; - - rid = index; - sc->sc_irq_res[index] = bus_alloc_resource_any(sc->sc_dev, - SYS_RES_IRQ, &rid, RF_ACTIVE); - if (sc->sc_irq_res[index] == NULL || - INTINO(vec = rman_get_start(sc->sc_irq_res[index])) != ino || - INTIGN(vec) != sc->sc_ign || - intr_vectors[vec].iv_ic != &fire_ic || - bus_setup_intr(sc->sc_dev, sc->sc_irq_res[index], - INTR_TYPE_MISC | INTR_BRIDGE, handler, NULL, arg, - &sc->sc_ihand[index]) != 0) - panic("%s: failed to set up interrupt %d", __func__, index); -} - -static int -fire_intr_register(struct fire_softc *sc, u_int ino) -{ - struct fire_icarg *fica; - bus_addr_t intrclr, intrmap; - int error; - - if (fire_get_intrmap(sc, ino, &intrmap, &intrclr) == 0) - return (ENXIO); - fica = malloc((ino >= FO_EQ_FIRST_INO && ino <= FO_EQ_LAST_INO) ? - sizeof(struct fire_msiqarg) : sizeof(struct fire_icarg), M_DEVBUF, - M_NOWAIT | M_ZERO); - if (fica == NULL) - return (ENOMEM); - fica->fica_sc = sc; - fica->fica_map = intrmap; - fica->fica_clr = intrclr; - error = (intr_controller_register(INTMAP_VEC(sc->sc_ign, ino), - &fire_ic, fica)); - if (error != 0) - free(fica, M_DEVBUF); - return (error); -} - -static int -fire_get_intrmap(struct fire_softc *sc, u_int ino, bus_addr_t *intrmapptr, - bus_addr_t *intrclrptr) -{ - - if (ino > FO_MAX_INO) { - device_printf(sc->sc_dev, "out of range INO %d requested\n", - ino); - return (0); - } - - ino <<= 3; - if (intrmapptr != NULL) - *intrmapptr = FO_PCI_INT_MAP_BASE + ino; - if (intrclrptr != NULL) - *intrclrptr = FO_PCI_INT_CLR_BASE + ino; - return (1); -} - -/* - * Interrupt handlers - */ -static int -fire_dmc_pec(void *arg) -{ - struct fire_softc *sc; - device_t dev; - uint64_t cestat, dmcstat, ilustat, imustat, mcstat, mmustat, mmutfar; - uint64_t mmutfsr, oestat, pecstat, uestat, val; - u_int fatal, oenfatal; - - fatal = 0; - sc = arg; - dev = sc->sc_dev; - mtx_lock_spin(&sc->sc_pcib_mtx); - mcstat = FIRE_PCI_READ_8(sc, FO_PCI_MULTI_CORE_ERR_STAT); - if ((mcstat & FO_PCI_MULTI_CORE_ERR_STAT_DMC) != 0) { - dmcstat = FIRE_PCI_READ_8(sc, FO_PCI_DMC_CORE_BLOCK_ERR_STAT); - if ((dmcstat & FO_PCI_DMC_CORE_BLOCK_INT_EN_IMU) != 0) { - imustat = FIRE_PCI_READ_8(sc, FO_PCI_IMU_INT_STAT); - device_printf(dev, "IMU error %#llx\n", - (unsigned long long)imustat); - if ((imustat & - FO_PCI_IMU_ERR_INT_EQ_NOT_EN_P) != 0) { - fatal = 1; - val = FIRE_PCI_READ_8(sc, - FO_PCI_IMU_SCS_ERR_LOG); - device_printf(dev, "SCS error log %#llx\n", - (unsigned long long)val); - } - if ((imustat & FO_PCI_IMU_ERR_INT_EQ_OVER_P) != 0) { - fatal = 1; - val = FIRE_PCI_READ_8(sc, - FO_PCI_IMU_EQS_ERR_LOG); - device_printf(dev, "EQS error log %#llx\n", - (unsigned long long)val); - } - if ((imustat & (FO_PCI_IMU_ERR_INT_MSI_MAL_ERR_P | - FO_PCI_IMU_ERR_INT_MSI_PAR_ERR_P | - FO_PCI_IMU_ERR_INT_PMEACK_MES_NOT_EN_P | - FO_PCI_IMU_ERR_INT_PMPME_MES_NOT_EN_P | - FO_PCI_IMU_ERR_INT_FATAL_MES_NOT_EN_P | - FO_PCI_IMU_ERR_INT_NFATAL_MES_NOT_EN_P | - FO_PCI_IMU_ERR_INT_COR_MES_NOT_EN_P | - FO_PCI_IMU_ERR_INT_MSI_NOT_EN_P)) != 0) { - fatal = 1; - val = FIRE_PCI_READ_8(sc, - FO_PCI_IMU_RDS_ERR_LOG); - device_printf(dev, "RDS error log %#llx\n", - (unsigned long long)val); - } - } - if ((dmcstat & FO_PCI_DMC_CORE_BLOCK_INT_EN_MMU) != 0) { - fatal = 1; - mmustat = FIRE_PCI_READ_8(sc, FO_PCI_MMU_INT_STAT); - mmutfar = FIRE_PCI_READ_8(sc, - FO_PCI_MMU_TRANS_FAULT_ADDR); - mmutfsr = FIRE_PCI_READ_8(sc, - FO_PCI_MMU_TRANS_FAULT_STAT); - if ((mmustat & (FO_PCI_MMU_ERR_INT_TBW_DPE_P | - FO_PCI_MMU_ERR_INT_TBW_ERR_P | - FO_PCI_MMU_ERR_INT_TBW_UDE_P | - FO_PCI_MMU_ERR_INT_TBW_DME_P | - FO_PCI_MMU_ERR_INT_TTC_CAE_P | - FIRE_PCI_MMU_ERR_INT_TTC_DPE_P | - OBERON_PCI_MMU_ERR_INT_TTC_DUE_P | - FO_PCI_MMU_ERR_INT_TRN_ERR_P)) != 0) - fatal = 1; - else { - sc->sc_stats_mmu_err++; - FIRE_PCI_WRITE_8(sc, FO_PCI_MMU_ERR_STAT_CLR, - mmustat); - } - device_printf(dev, - "MMU error %#llx: TFAR %#llx TFSR %#llx\n", - (unsigned long long)mmustat, - (unsigned long long)mmutfar, - (unsigned long long)mmutfsr); - } - } - if ((mcstat & FO_PCI_MULTI_CORE_ERR_STAT_PEC) != 0) { - pecstat = FIRE_PCI_READ_8(sc, FO_PCI_PEC_CORE_BLOCK_INT_STAT); - if ((pecstat & FO_PCI_PEC_CORE_BLOCK_INT_STAT_UERR) != 0) { - fatal = 1; - uestat = FIRE_PCI_READ_8(sc, - FO_PCI_TLU_UERR_INT_STAT); - device_printf(dev, - "DLU/TLU uncorrectable error %#llx\n", - (unsigned long long)uestat); - if ((uestat & (FO_PCI_TLU_UERR_INT_UR_P | - OBERON_PCI_TLU_UERR_INT_POIS_P | - FO_PCI_TLU_UERR_INT_MFP_P | - FO_PCI_TLU_UERR_INT_ROF_P | - FO_PCI_TLU_UERR_INT_UC_P | - FIRE_PCI_TLU_UERR_INT_PP_P | - OBERON_PCI_TLU_UERR_INT_POIS_P)) != 0) { - val = FIRE_PCI_READ_8(sc, - FO_PCI_TLU_RX_UERR_HDR1_LOG); - device_printf(dev, - "receive header log %#llx\n", - (unsigned long long)val); - val = FIRE_PCI_READ_8(sc, - FO_PCI_TLU_RX_UERR_HDR2_LOG); - device_printf(dev, - "receive header log 2 %#llx\n", - (unsigned long long)val); - } - if ((uestat & FO_PCI_TLU_UERR_INT_CTO_P) != 0) { - val = FIRE_PCI_READ_8(sc, - FO_PCI_TLU_TX_UERR_HDR1_LOG); - device_printf(dev, - "transmit header log %#llx\n", - (unsigned long long)val); - val = FIRE_PCI_READ_8(sc, - FO_PCI_TLU_TX_UERR_HDR2_LOG); - device_printf(dev, - "transmit header log 2 %#llx\n", - (unsigned long long)val); - } - if ((uestat & FO_PCI_TLU_UERR_INT_DLP_P) != 0) { - val = FIRE_PCI_READ_8(sc, - FO_PCI_LPU_LNK_LYR_INT_STAT); - device_printf(dev, - "link layer interrupt and status %#llx\n", - (unsigned long long)val); - } - if ((uestat & FO_PCI_TLU_UERR_INT_TE_P) != 0) { - val = FIRE_PCI_READ_8(sc, - FO_PCI_LPU_PHY_LYR_INT_STAT); - device_printf(dev, - "phy layer interrupt and status %#llx\n", - (unsigned long long)val); - } - } - if ((pecstat & FO_PCI_PEC_CORE_BLOCK_INT_STAT_CERR) != 0) { - sc->sc_stats_tlu_ce++; - cestat = FIRE_PCI_READ_8(sc, - FO_PCI_TLU_CERR_INT_STAT); - device_printf(dev, - "DLU/TLU correctable error %#llx\n", - (unsigned long long)cestat); - val = FIRE_PCI_READ_8(sc, - FO_PCI_LPU_LNK_LYR_INT_STAT); - device_printf(dev, - "link layer interrupt and status %#llx\n", - (unsigned long long)val); - if ((cestat & FO_PCI_TLU_CERR_INT_RE_P) != 0) { - FIRE_PCI_WRITE_8(sc, - FO_PCI_LPU_LNK_LYR_INT_STAT, val); - val = FIRE_PCI_READ_8(sc, - FO_PCI_LPU_PHY_LYR_INT_STAT); - device_printf(dev, - "phy layer interrupt and status %#llx\n", - (unsigned long long)val); - } - FIRE_PCI_WRITE_8(sc, FO_PCI_TLU_CERR_STAT_CLR, - cestat); - } - if ((pecstat & FO_PCI_PEC_CORE_BLOCK_INT_STAT_OEVENT) != 0) { - oenfatal = 0; - oestat = FIRE_PCI_READ_8(sc, - FO_PCI_TLU_OEVENT_INT_STAT); - device_printf(dev, "DLU/TLU other event %#llx\n", - (unsigned long long)oestat); - if ((oestat & (FO_PCI_TLU_OEVENT_MFC_P | - FO_PCI_TLU_OEVENT_MRC_P | - FO_PCI_TLU_OEVENT_WUC_P | - FO_PCI_TLU_OEVENT_RUC_P | - FO_PCI_TLU_OEVENT_CRS_P)) != 0) { - val = FIRE_PCI_READ_8(sc, - FO_PCI_TLU_RX_OEVENT_HDR1_LOG); - device_printf(dev, - "receive header log %#llx\n", - (unsigned long long)val); - val = FIRE_PCI_READ_8(sc, - FO_PCI_TLU_RX_OEVENT_HDR2_LOG); - device_printf(dev, - "receive header log 2 %#llx\n", - (unsigned long long)val); - if ((oestat & (FO_PCI_TLU_OEVENT_MFC_P | - FO_PCI_TLU_OEVENT_MRC_P | - FO_PCI_TLU_OEVENT_WUC_P | - FO_PCI_TLU_OEVENT_RUC_P)) != 0) - fatal = 1; - else { - sc->sc_stats_tlu_oe_rx_err++; - oenfatal = 1; - } - } - if ((oestat & (FO_PCI_TLU_OEVENT_MFC_P | - FO_PCI_TLU_OEVENT_CTO_P | - FO_PCI_TLU_OEVENT_WUC_P | - FO_PCI_TLU_OEVENT_RUC_P)) != 0) { - val = FIRE_PCI_READ_8(sc, - FO_PCI_TLU_TX_OEVENT_HDR1_LOG); - device_printf(dev, - "transmit header log %#llx\n", - (unsigned long long)val); - val = FIRE_PCI_READ_8(sc, - FO_PCI_TLU_TX_OEVENT_HDR2_LOG); - device_printf(dev, - "transmit header log 2 %#llx\n", - (unsigned long long)val); - if ((oestat & (FO_PCI_TLU_OEVENT_MFC_P | - FO_PCI_TLU_OEVENT_CTO_P | - FO_PCI_TLU_OEVENT_WUC_P | - FO_PCI_TLU_OEVENT_RUC_P)) != 0) - fatal = 1; - else { - sc->sc_stats_tlu_oe_tx_err++; - oenfatal = 1; - } - } - if ((oestat & (FO_PCI_TLU_OEVENT_ERO_P | - FO_PCI_TLU_OEVENT_EMP_P | - FO_PCI_TLU_OEVENT_EPE_P | - FIRE_PCI_TLU_OEVENT_ERP_P | - OBERON_PCI_TLU_OEVENT_ERBU_P | - FIRE_PCI_TLU_OEVENT_EIP_P | - OBERON_PCI_TLU_OEVENT_EIUE_P)) != 0) { - fatal = 1; - val = FIRE_PCI_READ_8(sc, - FO_PCI_LPU_LNK_LYR_INT_STAT); - device_printf(dev, - "link layer interrupt and status %#llx\n", - (unsigned long long)val); - } - if ((oestat & (FO_PCI_TLU_OEVENT_IIP_P | - FO_PCI_TLU_OEVENT_EDP_P | - FIRE_PCI_TLU_OEVENT_EHP_P | - OBERON_PCI_TLU_OEVENT_TLUEITMO_S | - FO_PCI_TLU_OEVENT_ERU_P)) != 0) - fatal = 1; - if ((oestat & (FO_PCI_TLU_OEVENT_NFP_P | - FO_PCI_TLU_OEVENT_LWC_P | - FO_PCI_TLU_OEVENT_LIN_P | - FO_PCI_TLU_OEVENT_LRS_P | - FO_PCI_TLU_OEVENT_LDN_P | - FO_PCI_TLU_OEVENT_LUP_P)) != 0) - oenfatal = 1; - if (oenfatal != 0) { - sc->sc_stats_tlu_oe_non_fatal++; - FIRE_PCI_WRITE_8(sc, - FO_PCI_TLU_OEVENT_STAT_CLR, oestat); - if ((oestat & FO_PCI_TLU_OEVENT_LIN_P) != 0) - FIRE_PCI_WRITE_8(sc, - FO_PCI_LPU_LNK_LYR_INT_STAT, - FIRE_PCI_READ_8(sc, - FO_PCI_LPU_LNK_LYR_INT_STAT)); - } - } - if ((pecstat & FO_PCI_PEC_CORE_BLOCK_INT_STAT_ILU) != 0) { - ilustat = FIRE_PCI_READ_8(sc, FO_PCI_ILU_INT_STAT); - device_printf(dev, "ILU error %#llx\n", - (unsigned long long)ilustat); - if ((ilustat & (FIRE_PCI_ILU_ERR_INT_IHB_PE_P | - FIRE_PCI_ILU_ERR_INT_IHB_PE_P)) != 0) - fatal = 1; - else { - sc->sc_stats_ilu_err++; - FIRE_PCI_WRITE_8(sc, FO_PCI_ILU_INT_STAT, - ilustat); - } - } - } - mtx_unlock_spin(&sc->sc_pcib_mtx); - if (fatal != 0) - panic("%s: fatal DMC/PEC error", - device_get_nameunit(sc->sc_dev)); - return (FILTER_HANDLED); -} - -static int -fire_xcb(void *arg) -{ - struct fire_softc *sc; - device_t dev; - uint64_t errstat, intstat, val; - u_int fatal; - - fatal = 0; - sc = arg; - dev = sc->sc_dev; - mtx_lock_spin(&sc->sc_pcib_mtx); - if (sc->sc_mode == FIRE_MODE_OBERON) { - intstat = FIRE_CTRL_READ_8(sc, FO_XBC_INT_STAT); - device_printf(dev, "UBC error: interrupt status %#llx\n", - (unsigned long long)intstat); - if ((intstat & ~(OBERON_UBC_ERR_INT_DMARDUEB_P | - OBERON_UBC_ERR_INT_DMARDUEA_P)) != 0) - fatal = 1; - else - sc->sc_stats_ubc_dmardue++; - if (fatal != 0) { - mtx_unlock_spin(&sc->sc_pcib_mtx); - panic("%s: fatal UBC core block error", - device_get_nameunit(sc->sc_dev)); - } else { - FIRE_CTRL_SET(sc, FO_XBC_ERR_STAT_CLR, ~0ULL); - mtx_unlock_spin(&sc->sc_pcib_mtx); - } - } else { - errstat = FIRE_CTRL_READ_8(sc, FIRE_JBC_CORE_BLOCK_ERR_STAT); - if ((errstat & (FIRE_JBC_CORE_BLOCK_ERR_STAT_MERGE | - FIRE_JBC_CORE_BLOCK_ERR_STAT_JBCINT | - FIRE_JBC_CORE_BLOCK_ERR_STAT_DMCINT)) != 0) { - intstat = FIRE_CTRL_READ_8(sc, FO_XBC_INT_STAT); - device_printf(dev, "JBC interrupt status %#llx\n", - (unsigned long long)intstat); - if ((intstat & FIRE_JBC_ERR_INT_EBUS_TO_P) != 0) { - val = FIRE_CTRL_READ_8(sc, - FIRE_JBC_CSR_ERR_LOG); - device_printf(dev, "CSR error log %#llx\n", - (unsigned long long)val); - } - if ((intstat & (FIRE_JBC_ERR_INT_UNSOL_RD_P | - FIRE_JBC_ERR_INT_UNSOL_INT_P)) != 0) { - if ((intstat & - FIRE_JBC_ERR_INT_UNSOL_RD_P) != 0) - sc->sc_stats_jbc_unsol_rd++; - if ((intstat & - FIRE_JBC_ERR_INT_UNSOL_INT_P) != 0) - sc->sc_stats_jbc_unsol_int++; - val = FIRE_CTRL_READ_8(sc, - FIRE_DMCINT_IDC_ERR_LOG); - device_printf(dev, - "DMCINT IDC error log %#llx\n", - (unsigned long long)val); - } - if ((intstat & (FIRE_JBC_ERR_INT_MB_PER_P | - FIRE_JBC_ERR_INT_MB_PEW_P)) != 0) { - fatal = 1; - val = FIRE_CTRL_READ_8(sc, - FIRE_MERGE_TRANS_ERR_LOG); - device_printf(dev, - "merge transaction error log %#llx\n", - (unsigned long long)val); - } - if ((intstat & FIRE_JBC_ERR_INT_IJP_P) != 0) { - fatal = 1; - val = FIRE_CTRL_READ_8(sc, - FIRE_JBCINT_OTRANS_ERR_LOG); - device_printf(dev, - "JBCINT out transaction error log " - "%#llx\n", (unsigned long long)val); - val = FIRE_CTRL_READ_8(sc, - FIRE_JBCINT_OTRANS_ERR_LOG2); - device_printf(dev, - "JBCINT out transaction error log 2 " - "%#llx\n", (unsigned long long)val); - } - if ((intstat & (FIRE_JBC_ERR_INT_UE_ASYN_P | - FIRE_JBC_ERR_INT_CE_ASYN_P | - FIRE_JBC_ERR_INT_JTE_P | FIRE_JBC_ERR_INT_JBE_P | - FIRE_JBC_ERR_INT_JUE_P | - FIRE_JBC_ERR_INT_ICISE_P | - FIRE_JBC_ERR_INT_WR_DPE_P | - FIRE_JBC_ERR_INT_RD_DPE_P | - FIRE_JBC_ERR_INT_ILL_BMW_P | - FIRE_JBC_ERR_INT_ILL_BMR_P | - FIRE_JBC_ERR_INT_BJC_P)) != 0) { - if ((intstat & (FIRE_JBC_ERR_INT_UE_ASYN_P | - FIRE_JBC_ERR_INT_JTE_P | - FIRE_JBC_ERR_INT_JBE_P | - FIRE_JBC_ERR_INT_JUE_P | - FIRE_JBC_ERR_INT_ICISE_P | - FIRE_JBC_ERR_INT_WR_DPE_P | - FIRE_JBC_ERR_INT_RD_DPE_P | - FIRE_JBC_ERR_INT_ILL_BMW_P | - FIRE_JBC_ERR_INT_ILL_BMR_P | - FIRE_JBC_ERR_INT_BJC_P)) != 0) - fatal = 1; - else - sc->sc_stats_jbc_ce_async++; - val = FIRE_CTRL_READ_8(sc, - FIRE_JBCINT_ITRANS_ERR_LOG); - device_printf(dev, - "JBCINT in transaction error log %#llx\n", - (unsigned long long)val); - val = FIRE_CTRL_READ_8(sc, - FIRE_JBCINT_ITRANS_ERR_LOG2); - device_printf(dev, - "JBCINT in transaction error log 2 " - "%#llx\n", (unsigned long long)val); - } - if ((intstat & (FIRE_JBC_ERR_INT_PIO_UNMAP_RD_P | - FIRE_JBC_ERR_INT_ILL_ACC_RD_P | - FIRE_JBC_ERR_INT_PIO_UNMAP_P | - FIRE_JBC_ERR_INT_PIO_DPE_P | - FIRE_JBC_ERR_INT_PIO_CPE_P | - FIRE_JBC_ERR_INT_ILL_ACC_P)) != 0) { - fatal = 1; - val = FIRE_CTRL_READ_8(sc, - FIRE_JBC_CSR_ERR_LOG); - device_printf(dev, - "DMCINT ODCD error log %#llx\n", - (unsigned long long)val); - } - if ((intstat & (FIRE_JBC_ERR_INT_MB_PEA_P | - FIRE_JBC_ERR_INT_CPE_P | FIRE_JBC_ERR_INT_APE_P | - FIRE_JBC_ERR_INT_PIO_CPE_P | - FIRE_JBC_ERR_INT_JTCEEW_P | - FIRE_JBC_ERR_INT_JTCEEI_P | - FIRE_JBC_ERR_INT_JTCEER_P)) != 0) { - fatal = 1; - val = FIRE_CTRL_READ_8(sc, - FIRE_FATAL_ERR_LOG); - device_printf(dev, "fatal error log %#llx\n", - (unsigned long long)val); - val = FIRE_CTRL_READ_8(sc, - FIRE_FATAL_ERR_LOG2); - device_printf(dev, "fatal error log 2 " - "%#llx\n", (unsigned long long)val); - } - if (fatal != 0) { - mtx_unlock_spin(&sc->sc_pcib_mtx); - panic("%s: fatal JBC core block error", - device_get_nameunit(sc->sc_dev)); - } else { - FIRE_CTRL_SET(sc, FO_XBC_ERR_STAT_CLR, ~0ULL); - mtx_unlock_spin(&sc->sc_pcib_mtx); - } - } else { - mtx_unlock_spin(&sc->sc_pcib_mtx); - panic("%s: unknown JCB core block error status %#llx", - device_get_nameunit(sc->sc_dev), - (unsigned long long)errstat); - } - } - return (FILTER_HANDLED); -} - -static int -fire_pcie(void *arg) -{ - struct fire_msiqarg *fmqa; - struct fire_softc *sc; - struct fo_msiq_record *qrec; - device_t dev; - uint64_t word0; - u_int head, msg, msiq; - - fmqa = arg; - sc = fmqa->fmqa_fica.fica_sc; - dev = sc->sc_dev; - msiq = fmqa->fmqa_msiq; - mtx_lock_spin(&fmqa->fmqa_mtx); - head = (FIRE_PCI_READ_8(sc, fmqa->fmqa_head) & FO_PCI_EQ_HD_MASK) >> - FO_PCI_EQ_HD_SHFT; - qrec = &fmqa->fmqa_base[head]; - word0 = qrec->fomqr_word0; - for (;;) { - KASSERT((word0 & FO_MQR_WORD0_FMT_TYPE_MSG) != 0, - ("%s: received non-PCIe message in event queue %d " - "(word0 %#llx)", device_get_nameunit(dev), msiq, - (unsigned long long)word0)); - msg = (word0 & FO_MQR_WORD0_DATA0_MASK) >> - FO_MQR_WORD0_DATA0_SHFT; - -#define PCIE_MSG_CODE_ERR_COR 0x30 -#define PCIE_MSG_CODE_ERR_NONFATAL 0x31 -#define PCIE_MSG_CODE_ERR_FATAL 0x33 - - if (msg == PCIE_MSG_CODE_ERR_COR) - device_printf(dev, "correctable PCIe error\n"); - else if (msg == PCIE_MSG_CODE_ERR_NONFATAL || - msg == PCIE_MSG_CODE_ERR_FATAL) - panic("%s: %sfatal PCIe error", - device_get_nameunit(dev), - msg == PCIE_MSG_CODE_ERR_NONFATAL ? "non-" : ""); - else - panic("%s: received unknown PCIe message %#x", - device_get_nameunit(dev), msg); - qrec->fomqr_word0 &= ~FO_MQR_WORD0_FMT_TYPE_MASK; - head = (head + 1) % sc->sc_msiq_size; - qrec = &fmqa->fmqa_base[head]; - word0 = qrec->fomqr_word0; - if (__predict_true((word0 & FO_MQR_WORD0_FMT_TYPE_MASK) == 0)) - break; - } - FIRE_PCI_WRITE_8(sc, fmqa->fmqa_head, (head & FO_PCI_EQ_HD_MASK) << - FO_PCI_EQ_HD_SHFT); - if ((FIRE_PCI_READ_8(sc, fmqa->fmqa_tail) & - FO_PCI_EQ_TL_OVERR) != 0) { - device_printf(dev, "event queue %d overflow\n", msiq); - msiq <<= 3; - FIRE_PCI_WRITE_8(sc, FO_PCI_EQ_CTRL_CLR_BASE + msiq, - FIRE_PCI_READ_8(sc, FO_PCI_EQ_CTRL_CLR_BASE + msiq) | - FO_PCI_EQ_CTRL_CLR_COVERR); - } - mtx_unlock_spin(&fmqa->fmqa_mtx); - return (FILTER_HANDLED); -} - -static int -fire_maxslots(device_t dev) -{ - - return (1); -} - -static uint32_t -fire_read_config(device_t dev, u_int bus, u_int slot, u_int func, u_int reg, - int width) -{ - - return (ofw_pci_read_config_common(dev, PCIE_REGMAX, FO_CONF_OFF(bus, - slot, func, reg), bus, slot, func, reg, width)); -} - -static void -fire_write_config(device_t dev, u_int bus, u_int slot, u_int func, u_int reg, - uint32_t val, int width) -{ - - ofw_pci_write_config_common(dev, PCIE_REGMAX, FO_CONF_OFF(bus, slot, - func, reg), bus, slot, func, reg, val, width); -} - -static int -fire_route_interrupt(device_t bridge, device_t dev, int pin) -{ - ofw_pci_intr_t mintr; - - mintr = ofw_pci_route_interrupt_common(bridge, dev, pin); - if (!PCI_INTERRUPT_VALID(mintr)) - device_printf(bridge, - "could not route pin %d for device %d.%d\n", - pin, pci_get_slot(dev), pci_get_function(dev)); - return (mintr); -} - -static void -fire_dmamap_sync(bus_dma_tag_t dt __unused, bus_dmamap_t map, - bus_dmasync_op_t op) -{ - - if ((map->dm_flags & DMF_LOADED) == 0) - return; - - if ((op & BUS_DMASYNC_POSTREAD) != 0) - ofw_pci_dmamap_sync_stst_order_common(); - else if ((op & BUS_DMASYNC_PREWRITE) != 0) - membar(Sync); -} - -static void -fire_intr_enable(void *arg) -{ - struct intr_vector *iv; - struct fire_icarg *fica; - struct fire_softc *sc; - struct pcpu *pc; - uint64_t mr; - u_int ctrl, i; - - iv = arg; - fica = iv->iv_icarg; - sc = fica->fica_sc; - mr = FO_PCI_IMAP_V; - if (sc->sc_mode == FIRE_MODE_OBERON) - mr |= (iv->iv_mid << OBERON_PCI_IMAP_T_DESTID_SHFT) & - OBERON_PCI_IMAP_T_DESTID_MASK; - else - mr |= (iv->iv_mid << FIRE_PCI_IMAP_T_JPID_SHFT) & - FIRE_PCI_IMAP_T_JPID_MASK; - /* - * Given that all mondos for the same target are required to use the - * same interrupt controller we just use the CPU ID for indexing the - * latter. - */ - ctrl = 0; - for (i = 0; i < mp_ncpus; ++i) { - pc = pcpu_find(i); - if (pc == NULL || iv->iv_mid != pc->pc_mid) - continue; - ctrl = pc->pc_cpuid % 4; - break; - } - mr |= (1ULL << ctrl) << FO_PCI_IMAP_INT_CTRL_NUM_SHFT & - FO_PCI_IMAP_INT_CTRL_NUM_MASK; - FIRE_PCI_WRITE_8(sc, fica->fica_map, mr); -} - -static void -fire_intr_disable(void *arg) -{ - struct intr_vector *iv; - struct fire_icarg *fica; - struct fire_softc *sc; - - iv = arg; - fica = iv->iv_icarg; - sc = fica->fica_sc; - FIRE_PCI_WRITE_8(sc, fica->fica_map, - FIRE_PCI_READ_8(sc, fica->fica_map) & ~FO_PCI_IMAP_V); -} - -static void -fire_intr_assign(void *arg) -{ - struct intr_vector *iv; - struct fire_icarg *fica; - struct fire_softc *sc; - uint64_t mr; - - iv = arg; - fica = iv->iv_icarg; - sc = fica->fica_sc; - mr = FIRE_PCI_READ_8(sc, fica->fica_map); - if ((mr & FO_PCI_IMAP_V) != 0) { - FIRE_PCI_WRITE_8(sc, fica->fica_map, mr & ~FO_PCI_IMAP_V); - FIRE_PCI_BARRIER(sc, fica->fica_map, 8, - BUS_SPACE_BARRIER_READ | BUS_SPACE_BARRIER_WRITE); - } - while (FIRE_PCI_READ_8(sc, fica->fica_clr) != INTCLR_IDLE) - ; - if ((mr & FO_PCI_IMAP_V) != 0) - fire_intr_enable(arg); -} - -static void -fire_intr_clear(void *arg) -{ - struct intr_vector *iv; - struct fire_icarg *fica; - - iv = arg; - fica = iv->iv_icarg; - FIRE_PCI_WRITE_8(fica->fica_sc, fica->fica_clr, INTCLR_IDLE); -} - -/* - * Given that the event queue implementation matches our current MD and MI - * interrupt frameworks like square pegs fit into round holes we are generous - * and use one event queue per MSI for now, which limits us to 35 MSIs/MSI-Xs - * per Host-PCIe-bridge (we use one event queue for the PCIe error messages). - * This seems tolerable as long as most devices just use one MSI/MSI-X anyway. - * Adding knowledge about MSIs/MSI-Xs to the MD interrupt code should allow us - * to decouple the 1:1 mapping at the cost of no longer being able to bind - * MSIs/MSI-Xs to specific CPUs as we currently have no reliable way to - * quiesce a device while we move its MSIs/MSI-Xs to another event queue. - */ - -static int -fire_alloc_msi(device_t dev, device_t child, int count, int maxcount __unused, - int *irqs) -{ - struct fire_softc *sc; - u_int i, j, msiqrun; - - if (powerof2(count) == 0 || count > 32) - return (EINVAL); - - sc = device_get_softc(dev); - mtx_lock(&sc->sc_msi_mtx); - msiqrun = 0; - for (i = 0; i < sc->sc_msiq_count; i++) { - for (j = i; j < i + count; j++) { - if (isclr(sc->sc_msiq_bitmap, j) == 0) - break; - } - if (j == i + count) { - msiqrun = i; - break; - } - } - if (i == sc->sc_msiq_count) { - mtx_unlock(&sc->sc_msi_mtx); - return (ENXIO); - } - for (i = 0; i + count < sc->sc_msi_count; i += count) { - for (j = i; j < i + count; j++) - if (isclr(sc->sc_msi_bitmap, j) == 0) - break; - if (j == i + count) { - for (j = 0; j < count; j++) { - setbit(sc->sc_msiq_bitmap, msiqrun + j); - setbit(sc->sc_msi_bitmap, i + j); - sc->sc_msi_msiq_table[i + j] = msiqrun + j; - irqs[j] = sc->sc_msi_first + i + j; - } - mtx_unlock(&sc->sc_msi_mtx); - return (0); - } - } - mtx_unlock(&sc->sc_msi_mtx); - return (ENXIO); -} - -static int -fire_release_msi(device_t dev, device_t child, int count, int *irqs) -{ - struct fire_softc *sc; - u_int i; - - sc = device_get_softc(dev); - mtx_lock(&sc->sc_msi_mtx); - for (i = 0; i < count; i++) { - clrbit(sc->sc_msiq_bitmap, - sc->sc_msi_msiq_table[irqs[i] - sc->sc_msi_first]); - clrbit(sc->sc_msi_bitmap, irqs[i] - sc->sc_msi_first); - } - mtx_unlock(&sc->sc_msi_mtx); - return (0); -} - -static int -fire_alloc_msix(device_t dev, device_t child, int *irq) -{ - struct fire_softc *sc; - int i, msiq; - - sc = device_get_softc(dev); - if ((sc->sc_flags & FIRE_MSIX) == 0) - return (ENXIO); - mtx_lock(&sc->sc_msi_mtx); - msiq = 0; - for (i = 0; i < sc->sc_msiq_count; i++) { - if (isclr(sc->sc_msiq_bitmap, i) != 0) { - msiq = i; - break; - } - } - if (i == sc->sc_msiq_count) { - mtx_unlock(&sc->sc_msi_mtx); - return (ENXIO); - } - for (i = sc->sc_msi_count - 1; i >= 0; i--) { - if (isclr(sc->sc_msi_bitmap, i) != 0) { - setbit(sc->sc_msiq_bitmap, msiq); - setbit(sc->sc_msi_bitmap, i); - sc->sc_msi_msiq_table[i] = msiq; - *irq = sc->sc_msi_first + i; - mtx_unlock(&sc->sc_msi_mtx); - return (0); - } - } - mtx_unlock(&sc->sc_msi_mtx); - return (ENXIO); -} - -static int -fire_release_msix(device_t dev, device_t child, int irq) -{ - struct fire_softc *sc; - - sc = device_get_softc(dev); - if ((sc->sc_flags & FIRE_MSIX) == 0) - return (ENXIO); - mtx_lock(&sc->sc_msi_mtx); - clrbit(sc->sc_msiq_bitmap, - sc->sc_msi_msiq_table[irq - sc->sc_msi_first]); - clrbit(sc->sc_msi_bitmap, irq - sc->sc_msi_first); - mtx_unlock(&sc->sc_msi_mtx); - return (0); -} - -static int -fire_map_msi(device_t dev, device_t child, int irq, uint64_t *addr, - uint32_t *data) -{ - struct fire_softc *sc; - struct pci_devinfo *dinfo; - - sc = device_get_softc(dev); - dinfo = device_get_ivars(child); - if (dinfo->cfg.msi.msi_alloc > 0) { - if ((irq & ~sc->sc_msi_data_mask) != 0) { - device_printf(dev, "invalid MSI 0x%x\n", irq); - return (EINVAL); - } - } else { - if ((sc->sc_flags & FIRE_MSIX) == 0) - return (ENXIO); - if (fls(irq) > sc->sc_msix_data_width) { - device_printf(dev, "invalid MSI-X 0x%x\n", irq); - return (EINVAL); - } - } - if (dinfo->cfg.msi.msi_alloc > 0 && - (dinfo->cfg.msi.msi_ctrl & PCIM_MSICTRL_64BIT) == 0) - *addr = sc->sc_msi_addr32; - else - *addr = sc->sc_msi_addr64; - *data = irq; - return (0); -} - -static void -fire_msiq_handler(void *cookie) -{ - struct intr_vector *iv; - struct fire_msiqarg *fmqa; - - iv = cookie; - fmqa = iv->iv_icarg; - /* - * Note that since fire_intr_clear() will clear the event queue - * interrupt after the handler associated with the MSI [sic] has - * been executed we have to protect the access to the event queue as - * otherwise nested event queue interrupts cause corruption of the - * event queue on MP machines. Obviously especially when abandoning - * the 1:1 mapping it would be better to not clear the event queue - * interrupt after each handler invocation but only once when the - * outstanding MSIs have been processed but unfortunately that - * doesn't work well and leads to interrupt storms with controllers/ - * drivers which don't mask interrupts while the handler is executed. - * Maybe delaying clearing the MSI until after the handler has been - * executed could be used to work around this but that's not the - * intended usage and might in turn cause lost MSIs. - */ - mtx_lock_spin(&fmqa->fmqa_mtx); - fire_msiq_common(iv, fmqa); - mtx_unlock_spin(&fmqa->fmqa_mtx); -} - -static void -fire_msiq_filter(void *cookie) -{ - struct intr_vector *iv; - struct fire_msiqarg *fmqa; - - iv = cookie; - fmqa = iv->iv_icarg; - /* - * For filters we don't use fire_intr_clear() since it would clear - * the event queue interrupt while we're still processing the event - * queue as filters and associated post-filter handler are executed - * directly, which in turn would lead to lost MSIs. So we clear the - * event queue interrupt only once after processing the event queue. - * Given that this still guarantees the filters to not be executed - * concurrently and no other CPU can clear the event queue interrupt - * while the event queue is still processed, we don't even need to - * interlock the access to the event queue in this case. - */ - critical_enter(); - fire_msiq_common(iv, fmqa); - FIRE_PCI_WRITE_8(fmqa->fmqa_fica.fica_sc, fmqa->fmqa_fica.fica_clr, - INTCLR_IDLE); - critical_exit(); -} - -static inline void -fire_msiq_common(struct intr_vector *iv, struct fire_msiqarg *fmqa) -{ - struct fire_softc *sc; - struct fo_msiq_record *qrec; - device_t dev; - uint64_t word0; - u_int head, msi, msiq; - - sc = fmqa->fmqa_fica.fica_sc; - dev = sc->sc_dev; - msiq = fmqa->fmqa_msiq; - head = (FIRE_PCI_READ_8(sc, fmqa->fmqa_head) & FO_PCI_EQ_HD_MASK) >> - FO_PCI_EQ_HD_SHFT; - qrec = &fmqa->fmqa_base[head]; - word0 = qrec->fomqr_word0; - for (;;) { - if (__predict_false((word0 & FO_MQR_WORD0_FMT_TYPE_MASK) == 0)) - break; - KASSERT((word0 & FO_MQR_WORD0_FMT_TYPE_MSI64) != 0 || - (word0 & FO_MQR_WORD0_FMT_TYPE_MSI32) != 0, - ("%s: received non-MSI/MSI-X message in event queue %d " - "(word0 %#llx)", device_get_nameunit(dev), msiq, - (unsigned long long)word0)); - msi = (word0 & FO_MQR_WORD0_DATA0_MASK) >> - FO_MQR_WORD0_DATA0_SHFT; - /* - * Sanity check the MSI/MSI-X as long as we use a 1:1 mapping. - */ - KASSERT(msi == fmqa->fmqa_msi, - ("%s: received non-matching MSI/MSI-X in event queue %d " - "(%d versus %d)", device_get_nameunit(dev), msiq, msi, - fmqa->fmqa_msi)); - FIRE_PCI_WRITE_8(sc, FO_PCI_MSI_CLR_BASE + (msi << 3), - FO_PCI_MSI_CLR_EQWR_N); - if (__predict_false(intr_event_handle(iv->iv_event, - NULL) != 0)) - printf("stray MSI/MSI-X in event queue %d\n", msiq); - qrec->fomqr_word0 &= ~FO_MQR_WORD0_FMT_TYPE_MASK; - head = (head + 1) % sc->sc_msiq_size; - qrec = &fmqa->fmqa_base[head]; - word0 = qrec->fomqr_word0; - } - FIRE_PCI_WRITE_8(sc, fmqa->fmqa_head, (head & FO_PCI_EQ_HD_MASK) << - FO_PCI_EQ_HD_SHFT); - if (__predict_false((FIRE_PCI_READ_8(sc, fmqa->fmqa_tail) & - FO_PCI_EQ_TL_OVERR) != 0)) { - device_printf(dev, "event queue %d overflow\n", msiq); - msiq <<= 3; - FIRE_PCI_WRITE_8(sc, FO_PCI_EQ_CTRL_CLR_BASE + msiq, - FIRE_PCI_READ_8(sc, FO_PCI_EQ_CTRL_CLR_BASE + msiq) | - FO_PCI_EQ_CTRL_CLR_COVERR); - } -} - -static int -fire_setup_intr(device_t dev, device_t child, struct resource *ires, - int flags, driver_filter_t *filt, driver_intr_t *intr, void *arg, - void **cookiep) -{ - struct fire_softc *sc; - struct fire_msiqarg *fmqa; - u_long vec; - int error; - u_int msi, msiq; - - sc = device_get_softc(dev); - /* - * XXX this assumes that a device only has one INTx, while in fact - * Cassini+ and Saturn can use all four the firmware has assigned - * to them, but so does pci(4). - */ - if (rman_get_rid(ires) != 0) { - msi = rman_get_start(ires); - msiq = sc->sc_msi_msiq_table[msi - sc->sc_msi_first]; - vec = INTMAP_VEC(sc->sc_ign, sc->sc_msiq_ino_first + msiq); - msiq += sc->sc_msiq_first; - if (intr_vectors[vec].iv_ic != &fire_ic) { - device_printf(dev, - "invalid interrupt controller for vector 0x%lx\n", - vec); - return (EINVAL); - } - /* - * The MD interrupt code needs the vector rather than the MSI. - */ - rman_set_start(ires, vec); - rman_set_end(ires, vec); - error = bus_generic_setup_intr(dev, child, ires, flags, filt, - intr, arg, cookiep); - rman_set_start(ires, msi); - rman_set_end(ires, msi); - if (error != 0) - return (error); - fmqa = intr_vectors[vec].iv_icarg; - /* - * XXX inject our event queue handler. - */ - if (filt != NULL) { - intr_vectors[vec].iv_func = fire_msiq_filter; - intr_vectors[vec].iv_ic = &fire_msiqc_filter; - /* - * Ensure the event queue interrupt is cleared, it - * might have triggered before. Given we supply NULL - * as ic_clear, inthand_add() won't do this for us. - */ - FIRE_PCI_WRITE_8(sc, fmqa->fmqa_fica.fica_clr, - INTCLR_IDLE); - } else - intr_vectors[vec].iv_func = fire_msiq_handler; - /* Record the MSI/MSI-X as long as we we use a 1:1 mapping. */ - fmqa->fmqa_msi = msi; - FIRE_PCI_WRITE_8(sc, FO_PCI_EQ_CTRL_SET_BASE + (msiq << 3), - FO_PCI_EQ_CTRL_SET_EN); - msi <<= 3; - FIRE_PCI_WRITE_8(sc, FO_PCI_MSI_MAP_BASE + msi, - (FIRE_PCI_READ_8(sc, FO_PCI_MSI_MAP_BASE + msi) & - ~FO_PCI_MSI_MAP_EQNUM_MASK) | - ((msiq << FO_PCI_MSI_MAP_EQNUM_SHFT) & - FO_PCI_MSI_MAP_EQNUM_MASK)); - FIRE_PCI_WRITE_8(sc, FO_PCI_MSI_CLR_BASE + msi, - FO_PCI_MSI_CLR_EQWR_N); - FIRE_PCI_WRITE_8(sc, FO_PCI_MSI_MAP_BASE + msi, - FIRE_PCI_READ_8(sc, FO_PCI_MSI_MAP_BASE + msi) | - FO_PCI_MSI_MAP_V); - return (error); - } - - /* - * Make sure the vector is fully specified and we registered - * our interrupt controller for it. - */ - vec = rman_get_start(ires); - if (INTIGN(vec) != sc->sc_ign) { - device_printf(dev, "invalid interrupt vector 0x%lx\n", vec); - return (EINVAL); - } - if (intr_vectors[vec].iv_ic != &fire_ic) { - device_printf(dev, - "invalid interrupt controller for vector 0x%lx\n", vec); - return (EINVAL); - } - return (bus_generic_setup_intr(dev, child, ires, flags, filt, intr, - arg, cookiep)); -} - -static int -fire_teardown_intr(device_t dev, device_t child, struct resource *ires, - void *cookie) -{ - struct fire_softc *sc; - u_long vec; - int error; - u_int msi, msiq; - - sc = device_get_softc(dev); - if (rman_get_rid(ires) != 0) { - msi = rman_get_start(ires); - msiq = sc->sc_msi_msiq_table[msi - sc->sc_msi_first]; - vec = INTMAP_VEC(sc->sc_ign, msiq + sc->sc_msiq_ino_first); - msiq += sc->sc_msiq_first; - msi <<= 3; - FIRE_PCI_WRITE_8(sc, FO_PCI_MSI_MAP_BASE + msi, - FIRE_PCI_READ_8(sc, FO_PCI_MSI_MAP_BASE + msi) & - ~FO_PCI_MSI_MAP_V); - msiq <<= 3; - FIRE_PCI_WRITE_8(sc, FO_PCI_EQ_CTRL_CLR_BASE + msiq, - FO_PCI_EQ_CTRL_CLR_COVERR | FO_PCI_EQ_CTRL_CLR_E2I | - FO_PCI_EQ_CTRL_CLR_DIS); - FIRE_PCI_WRITE_8(sc, FO_PCI_EQ_TL_BASE + msiq, - (0 << FO_PCI_EQ_TL_SHFT) & FO_PCI_EQ_TL_MASK); - FIRE_PCI_WRITE_8(sc, FO_PCI_EQ_HD_BASE + msiq, - (0 << FO_PCI_EQ_HD_SHFT) & FO_PCI_EQ_HD_MASK); - intr_vectors[vec].iv_ic = &fire_ic; - /* - * The MD interrupt code needs the vector rather than the MSI. - */ - rman_set_start(ires, vec); - rman_set_end(ires, vec); - error = bus_generic_teardown_intr(dev, child, ires, cookie); - msi >>= 3; - rman_set_start(ires, msi); - rman_set_end(ires, msi); - return (error); - } - return (bus_generic_teardown_intr(dev, child, ires, cookie)); -} - -static struct resource * -fire_alloc_resource(device_t bus, device_t child, int type, int *rid, - rman_res_t start, rman_res_t end, rman_res_t count, u_int flags) -{ - struct fire_softc *sc; - - if (type == SYS_RES_IRQ && *rid == 0) { - sc = device_get_softc(bus); - start = end = INTMAP_VEC(sc->sc_ign, end); - } - return (ofw_pci_alloc_resource(bus, child, type, rid, start, end, - count, flags)); -} - -static u_int -fire_get_timecount(struct timecounter *tc) -{ - struct fire_softc *sc; - - sc = tc->tc_priv; - return (FIRE_CTRL_READ_8(sc, FO_XBC_PRF_CNT0) & TC_COUNTER_MAX_MASK); -} diff --git a/sys/sparc64/pci/firereg.h b/sys/sparc64/pci/firereg.h deleted file mode 100644 index c3ebc1511104..000000000000 --- a/sys/sparc64/pci/firereg.h +++ /dev/null @@ -1,1012 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD - * - * Copyright (c) 2009 Marius Strobl - * 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$ - */ - -#ifndef _SPARC64_PCI_FIREREG_H_ -#define _SPARC64_PCI_FIREREG_H_ - -#define FIRE_NINTR 3 /* 2 OFW + 1 MSIq */ -#define FIRE_NREG 2 - -#define FIRE_PCI 0 -#define FIRE_CTRL 1 - -/* PCI configuration and status registers */ -#define FO_PCI_INT_MAP_BASE 0x01000 -#define FO_PCI_INT_CLR_BASE 0x01400 -#define FO_PCI_EQ_BASE_ADDR 0x10000 -#define FO_PCI_EQ_CTRL_SET_BASE 0x11000 -#define FO_PCI_EQ_CTRL_CLR_BASE 0x11200 -#define FO_PCI_EQ_TL_BASE 0x11600 -#define FO_PCI_EQ_HD_BASE 0x11800 -#define FO_PCI_MSI_MAP_BASE 0x20000 -#define FO_PCI_MSI_CLR_BASE 0x28000 -#define FO_PCI_ERR_COR 0x30000 -#define FO_PCI_ERR_NONFATAL 0x30008 -#define FO_PCI_ERR_FATAL 0x30010 -#define FO_PCI_PM_PME 0x30018 -#define FO_PCI_PME_TO_ACK 0x30020 -#define FO_PCI_IMU_INT_EN 0x31008 -#define FO_PCI_IMU_INT_STAT 0x31010 -#define FO_PCI_IMU_ERR_STAT_CLR 0x31018 -#define FO_PCI_IMU_RDS_ERR_LOG 0x31028 -#define FO_PCI_IMU_SCS_ERR_LOG 0x31030 -#define FO_PCI_IMU_EQS_ERR_LOG 0x31038 -#define FO_PCI_DMC_CORE_BLOCK_INT_EN 0x31800 -#define FO_PCI_DMC_CORE_BLOCK_ERR_STAT 0x31808 -#define FO_PCI_MULTI_CORE_ERR_STAT 0x31810 -#define FO_PCI_MSI_32_BIT_ADDR 0x34000 -#define FO_PCI_MSI_64_BIT_ADDR 0x34008 -#define FO_PCI_MMU 0x40000 -#define FO_PCI_MMU_INT_EN 0x41008 -#define FO_PCI_MMU_INT_STAT 0x41010 -#define FO_PCI_MMU_ERR_STAT_CLR 0x41018 -#define FO_PCI_MMU_TRANS_FAULT_ADDR 0x41028 -#define FO_PCI_MMU_TRANS_FAULT_STAT 0x41030 -#define FO_PCI_ILU_INT_EN 0x51008 -#define FO_PCI_ILU_INT_STAT 0x51010 -#define FO_PCI_ILU_ERR_STAT_CLR 0x51018 -#define FO_PCI_DMC_DBG_SEL_PORTA 0x53000 -#define FO_PCI_DMC_DBG_SEL_PORTB 0x53008 -#define FO_PCI_PEC_CORE_BLOCK_INT_EN 0x51800 -#define FO_PCI_PEC_CORE_BLOCK_INT_STAT 0x51808 -#define FO_PCI_TLU_CTRL 0x80000 -#define FO_PCI_TLU_OEVENT_INT_EN 0x81008 -#define FO_PCI_TLU_OEVENT_INT_STAT 0x81010 -#define FO_PCI_TLU_OEVENT_STAT_CLR 0x81018 -#define FO_PCI_TLU_RX_OEVENT_HDR1_LOG 0x81028 -#define FO_PCI_TLU_RX_OEVENT_HDR2_LOG 0x81030 -#define FO_PCI_TLU_TX_OEVENT_HDR1_LOG 0x81038 -#define FO_PCI_TLU_TX_OEVENT_HDR2_LOG 0x81040 -#define FO_PCI_TLU_DEV_CTRL 0x90008 -#define FO_PCI_TLU_LNK_CTRL 0x90020 -#define FO_PCI_TLU_LNK_STAT 0x90028 -#define FO_PCI_TLU_UERR_INT_EN 0x91008 -#define FO_PCI_TLU_UERR_INT_STAT 0x91010 -#define FO_PCI_TLU_UERR_STAT_CLR 0x91018 -#define FO_PCI_TLU_RX_UERR_HDR1_LOG 0x91028 -#define FO_PCI_TLU_RX_UERR_HDR2_LOG 0x91030 -#define FO_PCI_TLU_TX_UERR_HDR1_LOG 0x91038 -#define FO_PCI_TLU_TX_UERR_HDR2_LOG 0x91040 -#define FO_PCI_TLU_CERR_INT_EN 0xa1008 -#define FO_PCI_TLU_CERR_INT_STAT 0xa1010 -#define FO_PCI_TLU_CERR_STAT_CLR 0xa1018 -#define FO_PCI_LPU_RST 0xe2008 -#define FO_PCI_LPU_INT_STAT 0xe2040 -#define FO_PCI_LPU_INT_MASK 0xe0248 -#define FO_PCI_LPU_LNK_LYR_CFG 0xe2200 -#define FO_PCI_LPU_LNK_LYR_INT_STAT 0xe2210 -#define FO_PCI_LPU_FLW_CTRL_UPDT_CTRL 0xe2240 -#define FO_PCI_LPU_TXLNK_FREQ_LAT_TMR_THRS 0xe2400 -#define FO_PCI_LPU_TXLNK_RPLY_TMR_THRS 0xe2410 -#define FO_PCI_LPU_TXLNK_RTR_FIFO_PTR 0xe2430 -#define FO_PCI_LPU_PHY_LYR_INT_STAT 0xe2610 -#define FO_PCI_LPU_LTSSM_CFG2 0xe2788 -#define FO_PCI_LPU_LTSSM_CFG3 0xe2790 -#define FO_PCI_LPU_LTSSM_CFG4 0xe2798 -#define FO_PCI_LPU_LTSSM_CFG5 0xe27a0 - -/* PCI interrupt mapping registers */ -#define FO_PCI_IMAP_MDO_MODE 0x8000000000000000ULL -#define FO_PCI_IMAP_V 0x0000000080000000ULL -#define FIRE_PCI_IMAP_T_JPID_MASK 0x000000007c000000ULL -#define FIRE_PCI_IMAP_T_JPID_SHFT 26 -#define OBERON_PCI_IMAP_T_DESTID_MASK 0x000000007fe00000ULL -#define OBERON_PCI_IMAP_T_DESTID_SHFT 21 -#define FO_PCI_IMAP_INT_CTRL_NUM_MASK 0x00000000000003c0ULL -#define FO_PCI_IMAP_INT_CTRL_NUM_SHFT 6 - -/* PCI interrupt clear registers - use INTCLR_* from */ - -/* PCI event queue base address register */ -#define FO_PCI_EQ_BASE_ADDR_BYPASS 0xfffc000000000000ULL -#define FO_PCI_EQ_BASE_ADDR_MASK 0xfffffffffff80000ULL -#define FO_PCI_EQ_BASE_ADDR_SHFT 19 - -/* PCI event queue control set registers */ -#define FO_PCI_EQ_CTRL_SET_ENOVERR 0x0200000000000000ULL -#define FO_PCI_EQ_CTRL_SET_EN 0x0000100000000000ULL - -/* PCI event queue control clear registers */ -#define FO_PCI_EQ_CTRL_CLR_COVERR 0x0200000000000000ULL -#define FO_PCI_EQ_CTRL_CLR_E2I 0x0000800000000000ULL -#define FO_PCI_EQ_CTRL_CLR_DIS 0x0000100000000000ULL - -/* PCI event queue tail registers */ -#define FO_PCI_EQ_TL_OVERR 0x0200000000000000ULL -#define FO_PCI_EQ_TL_MASK 0x000000000000007fULL -#define FO_PCI_EQ_TL_SHFT 0 - -/* PCI event queue head registers */ -#define FO_PCI_EQ_HD_MASK 0x000000000000007fULL -#define FO_PCI_EQ_HD_SHFT 0 - -/* PCI MSI mapping registers */ -#define FO_PCI_MSI_MAP_V 0x8000000000000000ULL -#define FO_PCI_MSI_MAP_EQWR_N 0x4000000000000000ULL -#define FO_PCI_MSI_MAP_EQNUM_MASK 0x000000000000003fULL -#define FO_PCI_MSI_MAP_EQNUM_SHFT 0 - -/* PCI MSI clear registers */ -#define FO_PCI_MSI_CLR_EQWR_N 0x4000000000000000ULL - -/* - * PCI IMU interrupt enable, interrupt status and error status clear - * registers - */ -#define FO_PCI_IMU_ERR_INT_SPARE_S_MASK 0x00007c0000000000ULL -#define FO_PCI_IMU_ERR_INT_SPARE_S_SHFT 42 -#define FO_PCI_IMU_ERR_INT_EQ_OVER_S 0x0000020000000000ULL -#define FO_PCI_IMU_ERR_INT_EQ_NOT_EN_S 0x0000010000000000ULL -#define FO_PCI_IMU_ERR_INT_MSI_MAL_ERR_S 0x0000008000000000ULL -#define FO_PCI_IMU_ERR_INT_MSI_PAR_ERR_S 0x0000004000000000ULL -#define FO_PCI_IMU_ERR_INT_PMEACK_MES_NOT_EN_S 0x0000002000000000ULL -#define FO_PCI_IMU_ERR_INT_PMPME_MES_NOT_EN_S 0x0000001000000000ULL -#define FO_PCI_IMU_ERR_INT_FATAL_MES_NOT_EN_S 0x0000000800000000ULL -#define FO_PCI_IMU_ERR_INT_NFATAL_MES_NOT_EN_S 0x0000000400000000ULL -#define FO_PCI_IMU_ERR_INT_COR_MES_NOT_EN_S 0x0000000200000000ULL -#define FO_PCI_IMU_ERR_INT_MSI_NOT_EN_S 0x0000000100000000ULL -#define FO_PCI_IMU_ERR_INT_SPARE_P_MASK 0x0000000000007c00ULL -#define FO_PCI_IMU_ERR_INT_SPARE_P_SHFT 10 -#define FO_PCI_IMU_ERR_INT_EQ_OVER_P 0x0000000000000200ULL -#define FO_PCI_IMU_ERR_INT_EQ_NOT_EN_P 0x0000000000000100ULL -#define FO_PCI_IMU_ERR_INT_MSI_MAL_ERR_P 0x0000000000000080ULL -#define FO_PCI_IMU_ERR_INT_MSI_PAR_ERR_P 0x0000000000000040ULL -#define FO_PCI_IMU_ERR_INT_PMEACK_MES_NOT_EN_P 0x0000000000000020ULL -#define FO_PCI_IMU_ERR_INT_PMPME_MES_NOT_EN_P 0x0000000000000010ULL -#define FO_PCI_IMU_ERR_INT_FATAL_MES_NOT_EN_P 0x0000000000000008ULL -#define FO_PCI_IMU_ERR_INT_NFATAL_MES_NOT_EN_P 0x0000000000000004ULL -#define FO_PCI_IMU_ERR_INT_COR_MES_NOT_EN_P 0x0000000000000002ULL -#define FO_PCI_IMU_ERR_INT_MSI_NOT_EN_P 0x0000000000000001ULL - -/* PCI IMU RDS error log register */ -#define FO_PCI_IMU_RDS_ERR_LOG_TYPE_MASK 0xfc00000000000000ULL -#define FO_PCI_IMU_RDS_ERR_LOG_TYPE_SHFT 58 -#define FO_PCI_IMU_RDS_ERR_LOG_LENGTH_MASK 0x03ff000000000000ULL -#define FO_PCI_IMU_RDS_ERR_LOG_LENGTH_SHFT 48 -#define FO_PCI_IMU_RDS_ERR_LOG_REQ_ID_MASK 0x0000ffff00000000ULL -#define FO_PCI_IMU_RDS_ERR_LOG_REQ_ID_SHFT 32 -#define FO_PCI_IMU_RDS_ERR_LOG_TLP_TAG_MASK 0x00000000ff000000ULL -#define FO_PCI_IMU_RDS_ERR_LOG_TLP_TAG_SHFT 24 -#define FO_PCI_IMU_RDS_ERR_LOG_BE_MCODE_MASK 0x0000000000ff0000ULL -#define FO_PCI_IMU_RDS_ERR_LOG_BE_MCODE_SHFT 16 -#define FO_PCI_IMU_RDS_ERR_LOG_MSI_DATA_MASK 0x000000000000ffffULL -#define FO_PCI_IMU_RDS_ERR_LOG_MSI_DATA_SHFT 0 - -/* PCI IMU SCS error log register */ -#define FO_PCI_IMU_SCS_ERR_LOG_TYPE_MASK 0xfc00000000000000ULL -#define FO_PCI_IMU_SCS_ERR_LOG_TYPE_SHFT 58 -#define FO_PCI_IMU_SCS_ERR_LOG_LENGTH_MASK 0x03ff000000000000ULL -#define FO_PCI_IMU_SCS_ERR_LOG_LENGTH_SHFT 48 -#define FO_PCI_IMU_SCS_ERR_LOG_REQ_ID_MASK 0x0000ffff00000000ULL -#define FO_PCI_IMU_SCS_ERR_LOG_REQ_ID_SHFT 32 -#define FO_PCI_IMU_SCS_ERR_LOG_TLP_TAG_MASK 0x00000000ff000000ULL -#define FO_PCI_IMU_SCS_ERR_LOG_TLP_TAG_SHFT 24 -#define FO_PCI_IMU_SCS_ERR_LOG_BE_MODE_MASK 0x0000000000ff0000ULL -#define FO_PCI_IMU_SCS_ERR_LOG_BE_MCODE_SHFT 16 -#define FO_PCI_IMU_SCS_ERR_LOG_EQ_NUM_MASK 0x000000000000003fULL -#define FO_PCI_IMU_SCS_ERR_LOG_EQ_NUM_SHFT 0 - -/* PCI IMU EQS error log register */ -#define FO_PCI_IMU_EQS_ERR_LOG_EQ_NUM_MASK 0x000000000000003fULL -#define FO_PCI_IMU_EQS_ERROR_LOG_EQ_NUM_SHFT 0 - -/* - * PCI ERR COR, ERR NONFATAL, ERR FATAL, PM PME and PME To ACK mapping - * registers - */ -#define FO_PCI_ERR_PME_V 0x8000000000000000ULL -#define FO_PCI_ERR_PME_EQNUM_MASK 0x000000000000003fULL -#define FO_PCI_ERR_PME_EQNUM_SHFT 0 - -/* PCI DMC core and block interrupt enable register */ -#define FO_PCI_DMC_CORE_BLOCK_INT_EN_DMC 0x8000000000000000ULL -#define FO_PCI_DMC_CORE_BLOCK_INT_EN_MMU 0x0000000000000002ULL -#define FO_PCI_DMC_CORE_BLOCK_INT_EN_IMU 0x0000000000000001ULL - -/* PCI DMC core and block error status register */ -#define FO_PCI_DMC_CORE_BLOCK_ERR_STAT_MMU 0x0000000000000002ULL -#define FO_PCI_DMC_CORE_BLOCK_ERR_STAT_IMU 0x0000000000000001ULL - -/* PCI multi core error status register */ -#define FO_PCI_MULTI_CORE_ERR_STAT_PEC 0x0000000000000002ULL -#define FO_PCI_MULTI_CORE_ERR_STAT_DMC 0x0000000000000001ULL - -/* PCI MSI 32-bit address register */ -#define FO_PCI_MSI_32_BIT_ADDR_MASK 0x00000000ffff0000ULL -#define FO_PCI_MSI_32_BIT_ADDR_SHFT 16 - -/* PCI MSI 64-bit address register */ -#define FO_PCI_MSI_64_BIT_ADDR_MASK 0x0000ffffffff0000ULL -#define FO_PCI_MSI_64_BIT_ADDR_SHFT 16 - -/* - * PCI MMU interrupt enable, interrupt status and error status clear - * registers - */ -#define FO_PCI_MMU_ERR_INT_S_MASK 0x0000ffff00000000ULL -#define FO_PCI_MMU_ERR_INT_S_SHFT 32 -#define FO_PCI_MMU_ERR_INT_TBW_DPE_S 0x0000800000000000ULL -#define FO_PCI_MMU_ERR_INT_TBW_ERR_S 0x0000400000000000ULL -#define FO_PCI_MMU_ERR_INT_TBW_UDE_S 0x0000200000000000ULL -#define FO_PCI_MMU_ERR_INT_TBW_DME_S 0x0000100000000000ULL -#define FO_PCI_MMU_ERR_INT_SPARE3_S 0x0000080000000000ULL -#define FO_PCI_MMU_ERR_INT_SPARE2_S 0x0000040000000000ULL -#define FO_PCI_MMU_ERR_INT_TTC_CAE_S 0x0000020000000000ULL -#define FIRE_PCI_MMU_ERR_INT_TTC_DPE_S 0x0000010000000000ULL -#define OBERON_PCI_MMU_ERR_INT_TTC_DUE_S 0x0000010000000000ULL -#define FO_PCI_MMU_ERR_INT_TTE_PRT_S 0x0000008000000000ULL -#define FO_PCI_MMU_ERR_INT_TTE_INV_S 0x0000004000000000ULL -#define FO_PCI_MMU_ERR_INT_TRN_OOR_S 0x0000002000000000ULL -#define FO_PCI_MMU_ERR_INT_TRN_ERR_S 0x0000001000000000ULL -#define FO_PCI_MMU_ERR_INT_SPARE1_S 0x0000000800000000ULL -#define FO_PCI_MMU_ERR_INT_SPARE0_S 0x0000000400000000ULL -#define FO_PCI_MMU_ERR_INT_BYP_OOR_S 0x0000000200000000ULL -#define FO_PCI_MMU_ERR_INT_BYP_ERR_S 0x0000000100000000ULL -#define FO_PCI_MMU_ERR_INT_P_MASK 0x000000000000ffffULL -#define FO_PCI_MMU_ERR_INT_P_SHFT 0 -#define FO_PCI_MMU_ERR_INT_TBW_DPE_P 0x0000000000008000ULL -#define FO_PCI_MMU_ERR_INT_TBW_ERR_P 0x0000000000004000ULL -#define FO_PCI_MMU_ERR_INT_TBW_UDE_P 0x0000000000002000ULL -#define FO_PCI_MMU_ERR_INT_TBW_DME_P 0x0000000000001000ULL -#define FO_PCI_MMU_ERR_INT_SPARE3_P 0x0000000000000800ULL -#define FO_PCI_MMU_ERR_INT_SPARE2_P 0x0000000000000400ULL -#define FO_PCI_MMU_ERR_INT_TTC_CAE_P 0x0000000000000200ULL -#define FIRE_PCI_MMU_ERR_INT_TTC_DPE_P 0x0000000000000100ULL -#define OBERON_PCI_MMU_ERR_INT_TTC_DUE_P 0x0000000000000100ULL -#define FO_PCI_MMU_ERR_INT_TTE_PRT_P 0x0000000000000080ULL -#define FO_PCI_MMU_ERR_INT_TTE_INV_P 0x0000000000000040ULL -#define FO_PCI_MMU_ERR_INT_TRN_OOR_P 0x0000000000000020ULL -#define FO_PCI_MMU_ERR_INT_TRN_ERR_P 0x0000000000000010ULL -#define FO_PCI_MMU_ERR_INT_SPARE1_P 0x0000000000000008ULL -#define FO_PCI_MMU_ERR_INT_SPARE0_P 0x0000000000000004ULL -#define FO_PCI_MMU_ERR_INT_BYP_OOR_P 0x0000000000000002ULL -#define FO_PCI_MMU_ERR_INT_BYP_ERR_P 0x0000000000000001ULL - -/* PCI MMU translation fault address register */ -#define FO_PCI_MMU_TRANS_FAULT_ADDR_VA_MASK 0xfffffffffffffffcULL -#define FO_PCI_MMU_TRANS_FAULT_ADDR_VA_SHFT 2 - -/* PCI MMU translation fault status register */ -#define FO_PCI_MMU_TRANS_FAULT_STAT_ENTRY_MASK 0x000001ff00000000ULL -#define FO_PCI_MMU_TRANS_FAULT_STAT_ENTRY_SHFT 32 -#define FO_PCI_MMU_TRANS_FAULT_STAT_TYPE_MASK 0x00000000007f0000ULL -#define FO_PCI_MMU_TRANS_FAULT_STAT_TYPE_SHFT 16 -#define FO_PCI_MMU_TRANS_FAULT_STAT_ID_MASK 0x000000000000ffffULL -#define FO_PCI_MMU_TRANS_FAULT_STAT_ID_SHFT 0 - -/* - * PCI ILU interrupt enable, interrupt status and error status clear - * registers - */ -#define FO_PCI_ILU_ERR_INT_SPARE3_S 0x0000008000000000ULL -#define FO_PCI_ILU_ERR_INT_SPARE2_S 0x0000004000000000ULL -#define FO_PCI_ILU_ERR_INT_SPARE1_S 0x0000002000000000ULL -#define FIRE_PCI_ILU_ERR_INT_IHB_PE_S 0x0000001000000000ULL -#define OBERON_PCI_ILU_ERR_INT_IHB_UE_S 0x0000001000000000ULL -#define FO_PCI_ILU_ERR_INT_SPARE3_P 0x0000000000000080ULL -#define FO_PCI_ILU_ERR_INT_SPARE2_P 0x0000000000000040ULL -#define FO_PCI_ILU_ERR_INT_SPARE1_P 0x0000000000000020ULL -#define FIRE_PCI_ILU_ERR_INT_IHB_PE_P 0x0000000000000010ULL -#define OBERON_PCI_ILU_ERR_INT_IHB_UE_P 0x0000000000000010ULL - -/* PCI DMC debug select registers for port a/b */ -#define FO_PCI_DMC_DBG_SEL_PORT_BLCK_MASK 0x00000000000003c0ULL -#define FO_PCI_DMC_DBG_SEL_PORT_BLCK_SHFT 6 -#define FO_PCI_DMC_DBG_SEL_PORT_SUB_MASK 0x0000000000000038ULL -#define FO_PCI_DMC_DBG_SEL_PORT_SUB_SHFT 3 -#define FO_PCI_DMC_DBG_SEL_PORT_SUB_SGNL_MASK 0x0000000000000007ULL -#define FO_PCI_DMC_DBG_SEL_PORT_SUB_SGNL_SHFT 0 - -/* PCI PEC core and block interrupt enable register */ -#define FO_PCI_PEC_CORE_BLOCK_INT_EN_PEC 0x8000000000000000ULL -#define FO_PCI_PEC_CORE_BLOCK_INT_EN_ILU 0x0000000000000008ULL -#define FO_PCI_PEC_CORE_BLOCK_INT_EN_UERR 0x0000000000000004ULL -#define FO_PCI_PEC_CORE_BLOCK_INT_EN_CERR 0x0000000000000002ULL -#define FO_PCI_PEC_CORE_BLOCK_INT_EN_OEVENT 0x0000000000000001ULL - -/* PCI PEC core and block interrupt status register */ -#define FO_PCI_PEC_CORE_BLOCK_INT_STAT_ILU 0x0000000000000008ULL -#define FO_PCI_PEC_CORE_BLOCK_INT_STAT_UERR 0x0000000000000004ULL -#define FO_PCI_PEC_CORE_BLOCK_INT_STAT_CERR 0x0000000000000002ULL -#define FO_PCI_PEC_CORE_BLOCK_INT_STAT_OEVENT 0x0000000000000001ULL - -/* PCI TLU control register */ -#define FO_PCI_TLU_CTRL_L0S_TIM_MASK 0x00000000ff000000ULL -#define FO_PCI_TLU_CTRL_L0S_TIM_SHFT 24 -#define FO_PCI_TLU_CTRL_NWPR_EN 0x0000000000100000ULL -#define FO_PCI_TLU_CTRL_CTO_SEL_MASK 0x0000000000070000ULL -#define FO_PCI_TLU_CTRL_CTO_SEL_SHFT 16 -#define FO_PCI_TLU_CTRL_CFG_MASK 0x000000000000ffffULL -#define FO_PCI_TLU_CTRL_CFG_SHFT 0 -#define FO_PCI_TLU_CTRL_CFG_REMAIN_DETECT_QUIET 0x0000000000000100ULL -#define FO_PCI_TLU_CTRL_CFG_PAD_LOOPBACK_EN 0x0000000000000080ULL -#define FO_PCI_TLU_CTRL_CFG_EWRAP_LOOPBACK_EN 0x0000000000000040ULL -#define FO_PCI_TLU_CTRL_CFG_DIGITAL_LOOPBACK_EN 0x0000000000000020ULL -#define FO_PCI_TLU_CTRL_CFG_MPS_MASK 0x000000000000001cULL -#define FO_PCI_TLU_CTRL_CFG_MPS_SHFT 2 -#define FO_PCI_TLU_CTRL_CFG_COMMON_CLK_CFG 0x0000000000000002ULL -#define FO_PCI_TLU_CTRL_CFG_PORT 0x0000000000000001ULL - -/* - * PCI TLU other event interrupt enable, interrupt status and status clear - * registers - */ -#define FO_PCI_TLU_OEVENT_S_MASK 0x00ffffff00000000ULL -#define FO_PCI_TLU_OEVENT_S_SHFT 32 -#define FO_PCI_TLU_OEVENT_SPARE_S 0x0080000000000000ULL -#define FO_PCI_TLU_OEVENT_MFC_S 0x0040000000000000ULL -#define FO_PCI_TLU_OEVENT_CTO_S 0x0020000000000000ULL -#define FO_PCI_TLU_OEVENT_NFP_S 0x0010000000000000ULL -#define FO_PCI_TLU_OEVENT_LWC_S 0x0008000000000000ULL -#define FO_PCI_TLU_OEVENT_MRC_S 0x0004000000000000ULL -#define FO_PCI_TLU_OEVENT_WUC_S 0x0002000000000000ULL -#define FO_PCI_TLU_OEVENT_RUC_S 0x0001000000000000ULL -#define FO_PCI_TLU_OEVENT_CRS_S 0x0000800000000000ULL -#define FO_PCI_TLU_OEVENT_IIP_S 0x0000400000000000ULL -#define FO_PCI_TLU_OEVENT_EDP_S 0x0000200000000000ULL -#define FIRE_PCI_TLU_OEVENT_EHP_S 0x0000100000000000ULL -#define OBERON_PCI_TLU_OEVENT_EHBUE_S 0x0000100000000000ULL -#define OBERON_PCI_TLU_OEVENT_EDBUE_S 0x0000100000000000ULL -#define FO_PCI_TLU_OEVENT_LIN_S 0x0000080000000000ULL -#define FO_PCI_TLU_OEVENT_LRS_S 0x0000040000000000ULL -#define FO_PCI_TLU_OEVENT_LDN_S 0x0000020000000000ULL -#define FO_PCI_TLU_OEVENT_LUP_S 0x0000010000000000ULL -#define FO_PCI_TLU_OEVENT_LPU_S_MASK 0x000000c000000000ULL -#define FO_PCI_TLU_OEVENT_LPU_S_SHFT 38 -#define OBERON_PCI_TLU_OEVENT_TLUEITMO_S 0x0000008000000000ULL -#define FO_PCI_TLU_OEVENT_ERU_S 0x0000002000000000ULL -#define FO_PCI_TLU_OEVENT_ERO_S 0x0000001000000000ULL -#define FO_PCI_TLU_OEVENT_EMP_S 0x0000000800000000ULL -#define FO_PCI_TLU_OEVENT_EPE_S 0x0000000400000000ULL -#define FIRE_PCI_TLU_OEVENT_ERP_S 0x0000000200000000ULL -#define OBERON_PCI_TLU_OEVENT_ERBU_S 0x0000000200000000ULL -#define FIRE_PCI_TLU_OEVENT_EIP_S 0x0000000100000000ULL -#define OBERON_PCI_TLU_OEVENT_EIUE_S 0x0000000100000000ULL -#define FO_PCI_TLU_OEVENT_P_MASK 0x0000000000ffffffULL -#define FO_PCI_TLU_OEVENT_P_SHFT 0 -#define FO_PCI_TLU_OEVENT_SPARE_P 0x0000000000800000ULL -#define FO_PCI_TLU_OEVENT_MFC_P 0x0000000000400000ULL -#define FO_PCI_TLU_OEVENT_CTO_P 0x0000000000200000ULL -#define FO_PCI_TLU_OEVENT_NFP_P 0x0000000000100000ULL -#define FO_PCI_TLU_OEVENT_LWC_P 0x0000000000080000ULL -#define FO_PCI_TLU_OEVENT_MRC_P 0x0000000000040000ULL -#define FO_PCI_TLU_OEVENT_WUC_P 0x0000000000020000ULL -#define FO_PCI_TLU_OEVENT_RUC_P 0x0000000000010000ULL -#define FO_PCI_TLU_OEVENT_CRS_P 0x0000000000008000ULL -#define FO_PCI_TLU_OEVENT_IIP_P 0x0000000000004000ULL -#define FO_PCI_TLU_OEVENT_EDP_P 0x0000000000002000ULL -#define FIRE_PCI_TLU_OEVENT_EHP_P 0x0000000000001000ULL -#define OBERON_PCI_TLU_OEVENT_EHBUE_P 0x0000000000001000ULL -#define OBERON_PCI_TLU_OEVENT_EDBUE_P 0x0000000000001000ULL -#define FO_PCI_TLU_OEVENT_LIN_P 0x0000000000000800ULL -#define FO_PCI_TLU_OEVENT_LRS_P 0x0000000000000400ULL -#define FO_PCI_TLU_OEVENT_LDN_P 0x0000000000000200ULL -#define FO_PCI_TLU_OEVENT_LUP_P 0x0000000000000100ULL -#define FO_PCI_TLU_OEVENT_LPU_P_MASK 0x00000000000000c0ULL -#define FO_PCI_TLU_OEVENT_LPU_P_SHFT 6 -#define OBERON_PCI_TLU_OEVENT_TLUEITMO_P 0x0000000000000080ULL -#define FO_PCI_TLU_OEVENT_ERU_P 0x0000000000000020ULL -#define FO_PCI_TLU_OEVENT_ERO_P 0x0000000000000010ULL -#define FO_PCI_TLU_OEVENT_EMP_P 0x0000000000000008ULL -#define FO_PCI_TLU_OEVENT_EPE_P 0x0000000000000004ULL -#define FIRE_PCI_TLU_OEVENT_ERP_P 0x0000000000000002ULL -#define OBERON_PCI_TLU_OEVENT_ERBU_P 0x0000000000000002ULL -#define FIRE_PCI_TLU_OEVENT_EIP_P 0x0000000000000001ULL -#define OBERON_PCI_TLU_OEVENT_EIUE_P 0x0000000000000001ULL - -/* PCI receive/transmit DLU/TLU other event header 1/2 log registers */ -#define FO_PCI_TLU_OEVENT_HDR_LOG_MASK 0xffffffffffffffffULL -#define FO_PCI_TLU_OEVENT_HDR_LOG_SHFT 0 - -/* PCI TLU device control register */ -#define FO_PCI_TLU_DEV_CTRL_MRRS_MASK 0x0000000000007000ULL -#define FO_PCI_TLU_DEV_CTRL_MRRS_SHFT 12 -#define FO_PCI_TLU_DEV_CTRL_MPS_MASK 0x00000000000000e0ULL -#define FO_PCI_TLU_DEV_CTRL_MPS_SHFT 5 - -/* - * PCI TLU uncorrectable error interrupt enable, interrupt status and - * status clear registers - */ -#define FO_PCI_TLU_UERR_INT_S_MASK 0x001fffff00000000ULL -#define FO_PCI_TLU_UERR_INT_S_SHFT 32 -#define FO_PCI_TLU_UERR_INT_UR_S 0x0010000000000000ULL -#define OBERON_PCI_TLU_UERR_INT_ECRC_S 0x0008000000000000ULL -#define FO_PCI_TLU_UERR_INT_MFP_S 0x0004000000000000ULL -#define FO_PCI_TLU_UERR_INT_ROF_S 0x0002000000000000ULL -#define FO_PCI_TLU_UERR_INT_UC_S 0x0001000000000000ULL -#define FO_PCI_TLU_UERR_INT_CA_S 0x0000800000000000ULL -#define FO_PCI_TLU_UERR_INT_CTO_S 0x0000400000000000ULL -#define FO_PCI_TLU_UERR_INT_FCP_S 0x0000200000000000ULL -#define FIRE_PCI_TLU_UERR_INT_PP_S 0x0000100000000000ULL -#define OBERON_PCI_TLU_UERR_INT_POIS_S 0x0000100000000000ULL -#define FO_PCI_TLU_UERR_INT_DLP_S 0x0000001000000000ULL -#define FO_PCI_TLU_UERR_INT_TE_S 0x0000000100000000ULL -#define FO_PCI_TLU_UERR_INT_P_MASK 0x00000000001fffffULL -#define FO_PCI_TLU_UERR_INT_P_SHFT 0 -#define FO_PCI_TLU_UERR_INT_UR_P 0x0000000000100000ULL -#define OBERON_PCI_TLU_UERR_INT_ECRC_P 0x0000000000080000ULL -#define FO_PCI_TLU_UERR_INT_MFP_P 0x0000000000040000ULL -#define FO_PCI_TLU_UERR_INT_ROF_P 0x0000000000020000ULL -#define FO_PCI_TLU_UERR_INT_UC_P 0x0000000000010000ULL -#define FO_PCI_TLU_UERR_INT_CA_P 0x0000000000008000ULL -#define FO_PCI_TLU_UERR_INT_CTO_P 0x0000000000004000ULL -#define FO_PCI_TLU_UERR_INT_FCP_P 0x0000000000002000ULL -#define FIRE_PCI_TLU_UERR_INT_PP_P 0x0000000000001000ULL -#define OBERON_PCI_TLU_UERR_INT_POIS_P 0x0000000000001000ULL -#define FO_PCI_TLU_UERR_INT_DLP_P 0x0000000000000010ULL -#define FO_PCI_TLU_UERR_INT_TE_P 0x0000000000000001ULL - -/* - * PCI TLU correctable error interrupt enable, interrupt status and - * status clear registers - */ -#define FO_PCI_TLU_CERR_INT_S_MASK 0x001fffff00000000ULL -#define FO_PCI_TLU_CERR_INT_S_SHFT 32 -#define FO_PCI_TLU_CERR_INT_RTO_S 0x0000100000000000ULL -#define FO_PCI_TLU_CERR_INT_RNR_S 0x0000010000000000ULL -#define FO_PCI_TLU_CERR_INT_BDP_S 0x0000008000000000ULL -#define FO_PCI_TLU_CERR_INT_BTP_S 0x0000004000000000ULL -#define FO_PCI_TLU_CERR_INT_RE_S 0x0000000100000000ULL -#define FO_PCI_TLU_CERR_INT_P_MASK 0x00000000001fffffULL -#define FO_PCI_TLU_CERR_INT_P_SHFT 0 -#define FO_PCI_TLU_CERR_INT_RTO_P 0x0000000000001000ULL -#define FO_PCI_TLU_CERR_INT_RNR_P 0x0000000000000100ULL -#define FO_PCI_TLU_CERR_INT_BDP_P 0x0000000000000080ULL -#define FO_PCI_TLU_CERR_INT_BTP_P 0x0000000000000040ULL -#define FO_PCI_TLU_CERR_INT_RE_P 0x0000000000000001ULL - -/* PCI TLU reset register */ -#define FO_PCI_LPU_RST_WE 0x0000000080000000ULL -#define FO_PCI_LPU_RST_UNUSED_MASK 0x0000000000000e00ULL -#define FO_PCI_LPU_RST_UNUSED_SHFT 9 -#define FO_PCI_LPU_RST_ERR 0x0000000000000100ULL -#define FO_PCI_LPU_RST_TXLINK 0x0000000000000080ULL -#define FO_PCI_LPU_RST_RXLINK 0x0000000000000040ULL -#define FO_PCI_LPU_RST_SMLINK 0x0000000000000020ULL -#define FO_PCI_LPU_RST_LTSSM 0x0000000000000010ULL -#define FO_PCI_LPU_RST_TXPHY 0x0000000000000008ULL -#define FO_PCI_LPU_RST_RXPHY 0x0000000000000004ULL -#define FO_PCI_LPU_RST_TXPCS 0x0000000000000002ULL -#define FO_PCI_LPU_RST_RXPCS 0x0000000000000001ULL - -/* PCI TLU link control register */ -#define FO_PCI_TLU_LNK_CTRL_EXTSYNC 0x0000000000000080ULL -#define FO_PCI_TLU_LNK_CTRL_CLK 0x0000000000000040ULL -#define FO_PCI_TLU_LNK_CTRL_RETRAIN 0x0000000000000020ULL -#define FO_PCI_TLU_LNK_CTRL_DIS 0x0000000000000010ULL -#define FO_PCI_TLU_LNK_CTRL_RCB 0x0000000000000008ULL -#define FO_PCI_TLU_LNK_CTRL_ASPM_L0S_L1S 0x0000000000000003ULL -#define FO_PCI_TLU_LNK_CTRL_ASPM_L1S 0x0000000000000002ULL -#define FO_PCI_TLU_LNK_CTRL_ASPM_L0S 0x0000000000000001ULL -#define FO_PCI_TLU_LNK_CTRL_ASPM_DIS 0x0000000000000000ULL - -/* PCI TLU link status register */ -#define FO_PCI_TLU_LNK_STAT_CLK 0x0000000000001000ULL -#define FO_PCI_TLU_LNK_STAT_TRAIN 0x0000000000000800ULL -#define FO_PCI_TLU_LNK_STAT_ERR 0x0000000000000400ULL -#define FO_PCI_TLU_LNK_STAT_WDTH_MASK 0x00000000000003f0ULL -#define FO_PCI_TLU_LNK_STAT_WDTH_SHFT 4 -#define FO_PCI_TLU_LNK_STAT_SPEED_MASK 0x000000000000000fULL -#define FO_PCI_TLU_LNK_STAT_SPEED_SHFT 0 - -/* - * PCI receive/transmit DLU/TLU uncorrectable error header 1/2 log - * registers - */ -#define FO_PCI_TLU_UERR_HDR_LOG_MASK 0xffffffffffffffffULL -#define FO_PCI_TLU_UERR_HDR_LOG_SHFT 0 - -/* PCI DLU/LPU interrupt status and mask registers */ -#define FO_PCI_LPU_INT_INT 0x0000000080000000ULL -#define FIRE_PCI_LPU_INT_PRF_CNT2_OFLW 0x0000000000000080ULL -#define FIRE_PCI_LPU_INT_PRF_CNT1_OFLW 0x0000000000000040ULL -#define FO_PCI_LPU_INT_LNK_LYR 0x0000000000000020ULL -#define FO_PCI_LPU_INT_PHY_ERR 0x0000000000000010ULL -#define FIRE_PCI_LPU_INT_LTSSM 0x0000000000000008ULL -#define FIRE_PCI_LPU_INT_PHY_TX 0x0000000000000004ULL -#define FIRE_PCI_LPU_INT_PHY_RX 0x0000000000000002ULL -#define FIRE_PCI_LPU_INT_PHY_GB 0x0000000000000001ULL - -/* PCI DLU/LPU link layer config register */ -#define FIRE_PCI_LPU_LNK_LYR_CFG_AUTO_UPDT_DIS 0x0000000000080000ULL -#define FIRE_PCI_LPU_LNK_LYR_CFG_FREQ_NAK_EN 0x0000000000040000ULL -#define FIRE_PCI_LPU_LNK_LYR_CFG_RPLY_AFTER_REQ 0x0000000000020000ULL -#define FIRE_PCI_LPU_LNK_LYR_CFG_LAT_THRS_WR_EN 0x0000000000010000ULL -#define FO_PCI_LPU_LNK_LYR_CFG_VC0_EN 0x0000000000000100ULL -#define FIRE_PCI_LPU_LNK_LYR_CFG_L0S_ADJ_FAC_EN 0x0000000000000010ULL -#define FIER_PCI_LPU_LNK_LYR_CFG_TLP_XMIT_FC_EN 0x0000000000000008ULL -#define FO_PCI_LPU_LNK_LYR_CFG_FREQ_ACK_EN 0x0000000000000004ULL -#define FO_PCI_LPU_LNK_LYR_CFG_RETRY_DIS 0x0000000000000002ULL - -/* PCI DLU/LPU link layer interrupt and status register */ -#define FO_PCI_LPU_LNK_LYR_INT_STAT_LNK_ERR_ACT 0x0000000080000000ULL -#define OBERON_PCI_LPU_LNK_LYR_INT_STAT_PBUS_PE 0x0000000000800000ULL -#define FO_PCI_LPU_LNK_LYR_INT_STAT_USPRTD_DLLP 0x0000000000400000ULL -#define FO_PCI_LPU_LNK_LYR_INT_STAT_DLLP_RX_ERR 0x0000000000200000ULL -#define FO_PCI_LPU_LNK_LYR_INT_STAT_BAD_DLLP 0x0000000000100000ULL -#define FO_PCI_LPU_LNK_LYR_INT_STAT_TLP_RX_ERR 0x0000000000040000ULL -#define FO_PCI_LPU_LNK_LYR_INT_STAT_SRC_ERR_TLP 0x0000000000020000ULL -#define FO_PCI_LPU_LNK_LYR_INT_STAT_BAD_TLP 0x0000000000010000ULL -#define FO_PCI_LPU_LNK_LYR_INT_STAT_RBF_UDF_ERR 0x0000000000000200ULL -#define FO_PCI_LPU_LNK_LYR_INT_STAT_RBF_OVF_ERR 0x0000000000000100ULL -#define FO_PCI_LPU_LNK_LYR_INT_STAT_EG_TLPM_ERR 0x0000000000000080ULL -#define FO_PCI_LPU_LNK_LYR_INT_STAT_EG_TFRM_ERR 0x0000000000000040ULL -#define FO_PCI_LPU_LNK_LYR_INT_STAT_RBF_PE 0x0000000000000020ULL -#define FO_PCI_LPU_LNK_LYR_INT_STAT_EGRESS_PE 0x0000000000000010ULL -#define FO_PCI_LPU_LNK_LYR_INT_STAT_RPLY_TMR_TO 0x0000000000000004ULL -#define FO_PCI_LPU_LNK_LYR_INT_STAT_RPLY_NUM_RO 0x0000000000000002ULL -#define FO_PCI_LPU_LNK_LYR_INT_STAT_DLNK_PES 0x0000000000000001ULL - -/* PCI DLU/LPU flow control update control register */ -#define FO_PCI_LPU_FLW_CTRL_UPDT_CTRL_FC0_C_EN 0x0000000000000004ULL -#define FO_PCI_LPU_FLW_CTRL_UPDT_CTRL_FC0_NP_EN 0x0000000000000002ULL -#define FO_PCI_LPU_FLW_CTRL_UPDT_CTRL_FC0_P_EN 0x0000000000000001ULL - -/* PCI DLU/LPU txlink ACKNAK latency timer threshold register */ -#define FO_PCI_LPU_TXLNK_FREQ_LAT_TMR_THRS_MASK 0x000000000000ffffULL -#define FO_PCI_LPU_TXLNK_FREQ_LAT_TMR_THRS_SHFT 0 - -/* PCI DLU/LPU txlink replay timer threshold register */ -#define FO_PCI_LPU_TXLNK_RPLY_TMR_THRS_MASK 0x00000000000fffffULL -#define FO_PCI_LPU_TXLNK_RPLY_TMR_THRS_SHFT 0 - -/* PCI DLU/LPU txlink FIFO pointer register */ -#define FO_PCI_LPU_TXLNK_RTR_FIFO_PTR_TL_MASK 0x00000000ffff0000ULL -#define FO_PCI_LPU_TXLNK_RTR_FIFO_PTR_TL_SHFT 16 -#define FO_PCI_LPU_TXLNK_RTR_FIFO_PTR_HD_MASK 0x000000000000ffffULL -#define FO_PCI_LPU_TXLNK_RTR_FIFO_PTR_HD_SHFT 0 - -/* PCI DLU/LPU phy layer interrupt and status register */ -#define FO_PCI_LPU_PHY_LYR_INT_STAT_PHY_LYR_ERR 0x0000000080000000ULL -#define FO_PCI_LPU_PHY_LYR_INT_STAT_KC_DLLP_ERR 0x0000000000000800ULL -#define FO_PCI_LPU_PHY_LYR_INT_STAT_END_POS_ERR 0x0000000000000400ULL -#define FO_PCI_LPU_PHY_LYR_INT_STAT_LNK_ERR 0x0000000000000200ULL -#define FO_PCI_LPU_PHY_LYR_INT_STAT_TRN_ERR 0x0000000000000100ULL -#define FO_PCI_LPU_PHY_LYR_INT_STAT_EDB_DET 0x0000000000000080ULL -#define FO_PCI_LPU_PHY_LYR_INT_STAT_SDP_END 0x0000000000000040ULL -#define FO_PCI_LPU_PHY_LYR_INT_STAT_STP_END_EDB 0x0000000000000020ULL -#define FO_PCI_LPU_PHY_LYR_INT_STAT_INVC_ERR 0x0000000000000010ULL -#define FO_PCI_LPU_PHY_LYR_INT_STAT_MULTI_SDP 0x0000000000000008ULL -#define FO_PCI_LPU_PHY_LYR_INT_STAT_MULTI_STP 0x0000000000000004ULL -#define FO_PCI_LPU_PHY_LYR_INT_STAT_ILL_SDP_POS 0x0000000000000002ULL -#define FO_PCI_LPU_PHY_LYR_INT_STAT_ILL_STP_POS 0x0000000000000001ULL - -/* PCI DLU/LPU LTSSM config2 register */ -#define FO_PCI_LPU_LTSSM_CFG2_12_TO_MASK 0x00000000ffffffffULL -#define FO_PCI_LPU_LTSSM_CFG2_12_TO_SHFT 0 - -/* PCI DLU/LPU LTSSM config3 register */ -#define FO_PCI_LPU_LTSSM_CFG3_2_TO_MASK 0x00000000ffffffffULL -#define FO_PCI_LPU_LTSSM_CFG3_2_TO_SHFT 0 - -/* PCI DLU/LPU LTSSM config4 register */ -#define FO_PCI_LPU_LTSSM_CFG4_TRN_CTRL_MASK 0x00000000ff000000ULL -#define FO_PCI_LPU_LTSSM_CFG4_TRN_CTRL_SHFT 24 -#define FO_PCI_LPU_LTSSM_CFG4_DATA_RATE_MASK 0x0000000000ff0000ULL -#define FO_PCI_LPU_LTSSM_CFG4_DATA_RATE_SHFT 16 -#define FO_PCI_LPU_LTSSM_CFG4_N_FTS_MASK 0x000000000000ff00ULL -#define FO_PCI_LPU_LTSSM_CFG4_N_FTS_SHFT 8 -#define FO_PCI_LPU_LTSSM_CFG4_LNK_NUM_MASK 0x00000000000000ffULL -#define FO_PCI_LPU_LTSSM_CFG4_LNK_NUM_SHFT 0 - -/* PCI DLU/LPU LTSSM config5 register */ -#define FO_PCI_LPU_LTSSM_CFG5_UNUSED0_MASK 0x00000000ffffe000ULL -#define FO_PCI_LPU_LTSSM_CFG5_UNUSED0_SHFT 13 -#define FO_PCI_LPU_LTSSM_CFG5_RCV_DET_TST_MODE 0x0000000000001000ULL -#define FO_PCI_LPU_LTSSM_CFG5_POLL_CMPLNC_DIS 0x0000000000000800ULL -#define FO_PCI_LPU_LTSSM_CFG5_TX_IDLE_TX_FTS 0x0000000000000400ULL -#define FO_PCI_LPU_LTSSM_CFG5_RX_FTS_RVR_LK 0x0000000000000200ULL -#define FO_PCI_LPU_LTSSM_CFG5_UNUSED1_MASK 0x0000000000000180ULL -#define FO_PCI_LPU_LTSSM_CFG5_UNUSED1_SHFT 7 -#define FO_PCI_LPU_LTSSM_CFG5_LPBK_NTRY_ACTIVE 0x0000000000000040ULL -#define FO_PCI_LPU_LTSSM_CFG5_LPBK_NTRY_EXIT 0x0000000000000020ULL -#define FO_PCI_LPU_LTSSM_CFG5_LPBK_ACTIVE_EXIT 0x0000000000000010ULL -#define FO_PCI_LPU_LTSSM_CFG5_L1_IDLE_RCVRY_LK 0x0000000000000008ULL -#define FO_PCI_LPU_LTSSM_CFG5_L0_TRN_CNTRL_RST 0x0000000000000004ULL -#define FO_PCI_LPU_LTSSM_CFG5_L0_LPBK 0x0000000000000002ULL -#define FO_PCI_LPU_LTSSM_CFG5_UNUSED2 0x0000000000000001ULL - -/* Controller configuration and status registers */ -#define FIRE_JBUS_PAR_CTRL 0x60010 -#define FO_XBC_ERR_LOG_EN 0x61000 -#define FO_XBC_INT_EN 0x61008 -#define FO_XBC_INT_STAT 0x61010 -#define FO_XBC_ERR_STAT_CLR 0x61018 -#define FIRE_JBC_FATAL_RST_EN 0x61028 -#define FIRE_JBCINT_ITRANS_ERR_LOG 0x61040 -#define FIRE_JBCINT_ITRANS_ERR_LOG2 0x61048 -#define FIRE_JBCINT_OTRANS_ERR_LOG 0x61040 -#define FIRE_JBCINT_OTRANS_ERR_LOG2 0x61048 -#define FIRE_FATAL_ERR_LOG 0x61050 -#define FIRE_FATAL_ERR_LOG2 0x61058 -#define FIRE_MERGE_TRANS_ERR_LOG 0x61060 -#define FIRE_DMCINT_ODCD_ERR_LOG 0x61068 -#define FIRE_DMCINT_IDC_ERR_LOG 0x61070 -#define FIRE_JBC_CSR_ERR_LOG 0x61078 -#define FIRE_JBC_CORE_BLOCK_INT_EN 0x61800 -#define FIRE_JBC_CORE_BLOCK_ERR_STAT 0x61808 -#define FO_XBC_PRF_CNT_SEL 0x62000 -#define FO_XBC_PRF_CNT0 0x62008 -#define FO_XBC_PRF_CNT1 0x62010 - -/* JBus parity control register */ -#define FIRE_JBUS_PAR_CTRL_P_EN 0x8000000000000000ULL -#define FIRE_JBUS_PAR_CTRL_INVRTD_PAR_MASK 0x000000000000003cULL -#define FIRE_JBUS_PAR_CTRL_INVRTD_PAR_SHFT 2 -#define FIRE_JBUS_PAR_CTRL_NEXT_DATA 0x0000000000000002ULL -#define FIRE_JBUS_PAR_CTRL_NEXT_ADDR 0x0000000000000001ULL - -/* JBC error log enable register - may also apply to UBC */ -#define FIRE_JBC_ERR_LOG_EN_SPARE_MASK 0x00000000e0000000ULL -#define FIRE_JBC_ERR_LOG_EN_SPARE_SHFT 29 -#define FIRE_JBC_ERR_LOG_EN_PIO_UNMAP_RD 0x0000000010000000ULL -#define FIRE_JBC_ERR_LOG_EN_ILL_ACC_RD 0x0000000008000000ULL -#define FIRE_JBC_ERR_LOG_EN_EBUS_TO 0x0000000004000000ULL -#define FIRE_JBC_ERR_LOG_EN_MB_PEA 0x0000000002000000ULL -#define FIRE_JBC_ERR_LOG_EN_MB_PER 0x0000000001000000ULL -#define FIRE_JBC_ERR_LOG_EN_MB_PEW 0x0000000000800000ULL -#define FIRE_JBC_ERR_LOG_EN_UE_ASYN 0x0000000000400000ULL -#define FIRE_JBC_ERR_LOG_EN_CE_ASYN 0x0000000000200000ULL -#define FIRE_JBC_ERR_LOG_EN_JTE 0x0000000000100000ULL -#define FIRE_JBC_ERR_LOG_EN_JBE 0x0000000000080000ULL -#define FIRE_JBC_ERR_LOG_EN_JUE 0x0000000000040000ULL -#define FIRE_JBC_ERR_LOG_EN_IJP 0x0000000000020000ULL -#define FIRE_JBC_ERR_LOG_EN_ICISE 0x0000000000010000ULL -#define FIRE_JBC_ERR_LOG_EN_CPE 0x0000000000008000ULL -#define FIRE_JBC_ERR_LOG_EN_APE 0x0000000000004000ULL -#define FIRE_JBC_ERR_LOG_EN_WR_DPE 0x0000000000002000ULL -#define FIRE_JBC_ERR_LOG_EN_RD_DPE 0x0000000000001000ULL -#define FIRE_JBC_ERR_LOG_EN_ILL_BMW 0x0000000000000800ULL -#define FIRE_JBC_ERR_LOG_EN_ILL_BMR 0x0000000000000400ULL -#define FIRE_JBC_ERR_LOG_EN_BJC 0x0000000000000200ULL -#define FIRE_JBC_ERR_LOG_EN_PIO_UNMAP 0x0000000000000100ULL -#define FIRE_JBC_ERR_LOG_EN_PIO_DPE 0x0000000000000080ULL -#define FIRE_JBC_ERR_LOG_EN_PIO_CPE 0x0000000000000040ULL -#define FIRE_JBC_ERR_LOG_EN_ILL_ACC 0x0000000000000020ULL -#define FIRE_JBC_ERR_LOG_EN_UNSOL_RD 0x0000000000000010ULL -#define FIRE_JBC_ERR_LOG_EN_UNSOL_INT 0x0000000000000008ULL -#define FIRE_JBC_ERR_LOG_EN_JTCEEW 0x0000000000000004ULL -#define FIRE_JBC_ERR_LOG_EN_JTCEEI 0x0000000000000002ULL -#define FIRE_JBC_ERR_LOG_EN_JTCEER 0x0000000000000001ULL - -/* JBC interrupt enable, interrupt status and error status clear registers */ -#define FIRE_JBC_ERR_INT_SPARE_S_MASK 0xe000000000000000ULL -#define FIRE_JBC_ERR_INT_SPARE_S_SHFT 61 -#define FIRE_JBC_ERR_INT_PIO_UNMAP_RD_S 0x1000000000000000ULL -#define FIRE_JBC_ERR_INT_ILL_ACC_RD_S 0x0800000000000000ULL -#define FIRE_JBC_ERR_INT_EBUS_TO_S 0x0400000000000000ULL -#define FIRE_JBC_ERR_INT_MB_PEA_S 0x0200000000000000ULL -#define FIRE_JBC_ERR_INT_MB_PER_S 0x0100000000000000ULL -#define FIRE_JBC_ERR_INT_MB_PEW_S 0x0080000000000000ULL -#define FIRE_JBC_ERR_INT_UE_ASYN_S 0x0040000000000000ULL -#define FIRE_JBC_ERR_INT_CE_ASYN_S 0x0020000000000000ULL -#define FIRE_JBC_ERR_INT_JTE_S 0x0010000000000000ULL -#define FIRE_JBC_ERR_INT_JBE_S 0x0008000000000000ULL -#define FIRE_JBC_ERR_INT_JUE_S 0x0004000000000000ULL -#define FIRE_JBC_ERR_INT_IJP_S 0x0002000000000000ULL -#define FIRE_JBC_ERR_INT_ICISE_S 0x0001000000000000ULL -#define FIRE_JBC_ERR_INT_CPE_S 0x0000800000000000ULL -#define FIRE_JBC_ERR_INT_APE_S 0x0000400000000000ULL -#define FIRE_JBC_ERR_INT_WR_DPE_S 0x0000200000000000ULL -#define FIRE_JBC_ERR_INT_RD_DPE_S 0x0000100000000000ULL -#define FIRE_JBC_ERR_INT_ILL_BMW_S 0x0000080000000000ULL -#define FIRE_JBC_ERR_INT_ILL_BMR_S 0x0000040000000000ULL -#define FIRE_JBC_ERR_INT_BJC_S 0x0000020000000000ULL -#define FIRE_JBC_ERR_INT_PIO_UNMAP_S 0x0000010000000000ULL -#define FIRE_JBC_ERR_INT_PIO_DPE_S 0x0000008000000000ULL -#define FIRE_JBC_ERR_INT_PIO_CPE_S 0x0000004000000000ULL -#define FIRE_JBC_ERR_INT_ILL_ACC_S 0x0000002000000000ULL -#define FIRE_JBC_ERR_INT_UNSOL_RD_S 0x0000001000000000ULL -#define FIRE_JBC_ERR_INT_UNSOL_INT_S 0x0000000800000000ULL -#define FIRE_JBC_ERR_INT_JTCEEW_S 0x0000000400000000ULL -#define FIRE_JBC_ERR_INT_JTCEEI_S 0x0000000200000000ULL -#define FIRE_JBC_ERR_INT_JTCEER_S 0x0000000100000000ULL -#define FIRE_JBC_ERR_INT_SPARE_P_MASK 0x00000000e0000000ULL -#define FIRE_JBC_ERR_INT_SPARE_P_SHFT 29 -#define FIRE_JBC_ERR_INT_PIO_UNMAP_RD_P 0x0000000010000000ULL -#define FIRE_JBC_ERR_INT_ILL_ACC_RD_P 0x0000000008000000ULL -#define FIRE_JBC_ERR_INT_EBUS_TO_P 0x0000000004000000ULL -#define FIRE_JBC_ERR_INT_MB_PEA_P 0x0000000002000000ULL -#define FIRE_JBC_ERR_INT_MB_PER_P 0x0000000001000000ULL -#define FIRE_JBC_ERR_INT_MB_PEW_P 0x0000000000800000ULL -#define FIRE_JBC_ERR_INT_UE_ASYN_P 0x0000000000400000ULL -#define FIRE_JBC_ERR_INT_CE_ASYN_P 0x0000000000200000ULL -#define FIRE_JBC_ERR_INT_JTE_P 0x0000000000100000ULL -#define FIRE_JBC_ERR_INT_JBE_P 0x0000000000080000ULL -#define FIRE_JBC_ERR_INT_JUE_P 0x0000000000040000ULL -#define FIRE_JBC_ERR_INT_IJP_P 0x0000000000020000ULL -#define FIRE_JBC_ERR_INT_ICISE_P 0x0000000000010000ULL -#define FIRE_JBC_ERR_INT_CPE_P 0x0000000000008000ULL -#define FIRE_JBC_ERR_INT_APE_P 0x0000000000004000ULL -#define FIRE_JBC_ERR_INT_WR_DPE_P 0x0000000000002000ULL -#define FIRE_JBC_ERR_INT_RD_DPE_P 0x0000000000001000ULL -#define FIRE_JBC_ERR_INT_ILL_BMW_P 0x0000000000000800ULL -#define FIRE_JBC_ERR_INT_ILL_BMR_P 0x0000000000000400ULL -#define FIRE_JBC_ERR_INT_BJC_P 0x0000000000000200ULL -#define FIRE_JBC_ERR_INT_PIO_UNMAP_P 0x0000000000000100ULL -#define FIRE_JBC_ERR_INT_PIO_DPE_P 0x0000000000000080ULL -#define FIRE_JBC_ERR_INT_PIO_CPE_P 0x0000000000000040ULL -#define FIRE_JBC_ERR_INT_ILL_ACC_P 0x0000000000000020ULL -#define FIRE_JBC_ERR_INT_UNSOL_RD_P 0x0000000000000010ULL -#define FIRE_JBC_ERR_INT_UNSOL_INT_P 0x0000000000000008ULL -#define FIRE_JBC_ERR_INT_JTCEEW_P 0x0000000000000004ULL -#define FIRE_JBC_ERR_INT_JTCEEI_P 0x0000000000000002ULL -#define FIRE_JBC_ERR_INT_JTCEER_P 0x0000000000000001ULL - -/* UBC interrupt enable, error status and error status clear registers */ -#define OBERON_UBC_ERR_INT_PIORBEUE_S 0x0004000000000000ULL -#define OBERON_UBC_ERR_INT_PIOWBEUE_S 0x0002000000000000ULL -#define OBERON_UBC_ERR_INT_PIOWTUE_S 0x0001000000000000ULL -#define OBERON_UBC_ERR_INT_MEMWTAXB_S 0x0000080000000000ULL -#define OBERON_UBC_ERR_INT_MEMRDAXB_S 0x0000040000000000ULL -#define OBERON_UBC_ERR_INT_DMAWTUEB_S 0x0000020000000000ULL -#define OBERON_UBC_ERR_INT_DMARDUEB_S 0x0000010000000000ULL -#define OBERON_UBC_ERR_INT_MEMWTAXA_S 0x0000000800000000ULL -#define OBERON_UBC_ERR_INT_MEMRDAXA_S 0x0000000400000000ULL -#define OBERON_UBC_ERR_INT_DMAWTUEA_S 0x0000000200000000ULL -#define OBERON_UBC_ERR_INT_DMARDUEA_S 0x0000000100000000ULL -#define OBERON_UBC_ERR_INT_PIORBEUE_P 0x0000000000040000ULL -#define OBERON_UBC_ERR_INT_PIOWBEUE_P 0x0000000000020000ULL -#define OBERON_UBC_ERR_INT_PIOWTUE_P 0x0000000000010000ULL -#define OBERON_UBC_ERR_INT_MEMWTAXB_P 0x0000000000000800ULL -#define OBERON_UBC_ERR_INT_MEMRDAXB_P 0x0000000000000400ULL -#define OBERON_UBC_ERR_INT_DMARDUEB_P 0x0000000000000200ULL -#define OBERON_UBC_ERR_INT_DMAWTUEB_P 0x0000000000000100ULL -#define OBERON_UBC_ERR_INT_MEMWTAXA_P 0x0000000000000008ULL -#define OBERON_UBC_ERR_INT_MEMRDAXA_P 0x0000000000000004ULL -#define OBERON_UBC_ERR_INT_DMAWTUEA_P 0x0000000000000002ULL -#define OBERON_UBC_ERR_INT_DMARDUEA_P 0x0000000000000001ULL - -/* JBC fatal reset enable register */ -#define FIRE_JBC_FATAL_RST_EN_SPARE_P_INT_MASK 0x000000000c000000ULL -#define FIRE_JBC_FATAL_RST_EN_SPARE_P_INT_SHFT 26 -#define FIRE_JBC_FATAL_RST_EN_MB_PEA_P_INT 0x0000000002000000ULL -#define FIRE_JBC_FATAL_RST_EN_CPE_P_INT 0x0000000000008000ULL -#define FIRE_JBC_FATAL_RST_EN_APE_P_INT 0x0000000000004000ULL -#define FIRE_JBC_FATAL_RST_EN_PIO_CPE_INT 0x0000000000000040ULL -#define FIRE_JBC_FATAL_RST_EN_JTCEEW_P_INT 0x0000000000000004ULL -#define FIRE_JBC_FATAL_RST_EN_JTCEEI_P_INT 0x0000000000000002ULL -#define FIRE_JBC_FATAL_RST_EN_JTCEER_P_INT 0x0000000000000001ULL - -/* JBC JBCINT in transaction error log register */ -#define FIRE_JBCINT_ITRANS_ERR_LOG_Q_WORD_MASK 0x00c0000000000000ULL -#define FIRE_JBCINT_ITRANS_ERR_LOG_Q_WORD_SHFT 54 -#define FIRE_JBCINT_ITRANS_ERR_LOG_TRANSID_MASK 0x0003000000000000ULL -#define FIRE_JBCINT_ITRANS_ERR_LOG_TRANSID_SHFT 48 -#define FIRE_JBCINT_ITRANS_ERR_LOG_ADDR_MASK 0x000007ffffffffffULL -#define FIRE_JBCINT_ITRANS_ERR_LOG_ADDR_SHFT 0 - -/* JBC JBCINT in transaction error log register 2 */ -#define FIRE_JBCINT_ITRANS_ERR_LOG2_ARB_WN_MASK 0x000ffffff0000000ULL -#define FIRE_JBCINT_ITRANS_ERR_LOG2_ARB_WN_SHFT 28 -#define FIRE_JBCINT_ITRANS_ERR_LOG2_J_REQ_MASK 0x000000000fe00000ULL -#define FIRE_JBCINT_ITRANS_ERR_LOG2_J_REQ_SHFT 21 -#define FIRE_JBCINT_ITRANS_ERR_LOG2_J_PACK_MASK 0x00000000001fffffULL -#define FIRE_JBCINT_ITRANS_ERR_LOG2_J_PACK_SHFT 0 - -/* JBC JBCINT out transaction error log register */ -#define FIRE_JBCINT_OTRANS_ERR_LOG_TRANSID_MASK 0x003f000000000000ULL -#define FIRE_JBCINT_OTRANS_ERR_LOG_TRANSID_SHFT 48 -#define FIRE_JBCINT_OTRANS_ERR_LOG_ADDR_MASK 0x000007ffffffffffULL -#define FIRE_JBCINT_OTRANS_ERR_LOG_ADDR_SHFT 0 - -/* JBC JBCINT out transaction error log register 2 */ -#define FIRE_JBCINT_OTRANS_ERR_LOG2_ARB_WN_MASK 0x000ffffff0000000ULL -#define FIRE_JBCINT_OTRANS_ERR_LOG2_ARB_WN_SHFT 28 -#define FIRE_JBCINT_OTRANS_ERR_LOG2_J_REQ_MASK 0x000000000fe00000ULL -#define FIRE_JBCINT_OTRANS_ERR_LOG2_J_REQ_SHFT 21 -#define FIRE_JBCINT_OTRANS_ERR_LOG2_J_PACK_MASK 0x00000000001fffffULL -#define FIRE_JBCINT_OTRANS_ERR_LOG2_J_PACK_SHFT 0 - -/* JBC merge transaction error log register */ -#define FIRE_FATAL_ERR_LOG_DATA_MASK 0xffffffffffffffffULL -#define FIRE_FATAL_ERR_LOG_DATA_SHFT 0 - -/* JBC merge transaction error log register 2 */ -#define FIRE_FATAL_ERR_LOG2_ARB_WN_MASK 0x000ffffff0000000ULL -#define FIRE_FATAL_ERR_LOG2_ARB_WN_SHFT 28 -#define FIRE_FATAL_ERR_LOG2_J_REQ_MASK 0x000000000fe00000ULL -#define FIRE_FATAL_ERR_LOG2_J_REQ_SHFT 21 -#define FIRE_FATAL_ERR_LOG2_J_PACK_MASK 0x00000000001fffffULL -#define FIRE_FATAL_ERR_LOG2_J_PACK_SHFT 0 - -/* JBC merge transaction error log register */ -#define FIRE_MERGE_TRANS_ERR_LOG_Q_WORD_MASK 0x00c0000000000000ULL -#define FIRE_MERGE_TRANS_ERR_LOG_Q_WORD_SHFT 54 -#define FIRE_MERGE_TRANS_ERR_LOG_TRANSID_MASK 0x0003000000000000ULL -#define FIRE_MERGE_TRANS_ERR_LOG_TRANSID_SHFT 48 -#define FIRE_MERGE_TRANS_ERR_LOG_JBC_TAG_MASK 0x0000f80000000000ULL -#define FIRE_MERGE_TRANS_ERR_LOG_JBC_TAG_SHFT 43 -#define FIRE_MERGE_TRANS_ERR_LOG_ADDR_MASK 0x000007ffffffffffULL -#define FIRE_MERGE_TRANS_ERR_LOG_ADDR_SHFT 0 - -/* JBC DMCINT ODCD error log register */ -#define FIRE_DMCINT_ODCD_ERR_LOG_TRANS_ID_MASK 0x0030000000000000ULL -#define FIRE_DMCINT_ODCD_ERR_LOG_TRANS_ID_SHFT 52 -#define FIRE_DMCINT_ODCD_ERR_LOG_AID_MASK 0x000f000000000000ULL -#define FIRE_DMCINT_ODCD_ERR_LOG_AID_SHFT 48 -#define FIRE_DMCINT_ODCD_ERR_LOG_TTYPE_MASK 0x0000f80000000000ULL -#define FIRE_DMCINT_ODCD_ERR_LOG_TTYPE_SHFT 43 -#define FIRE_DMCINT_ODCD_ERR_LOG_ADDR_MASK 0x000007ffffffffffULL -#define FIRE_DMCINT_ODCD_ERR_LOG_ADDR_SHFT 0 - -/* JBC DMCINT IDC error log register */ -#define FIRE_DMCINT_IDC_ERR_DMC_CTAG_MASK 0x000000000fff0000ULL -#define FIRE_DMCINT_IDC_ERR_DMC_CTAG_SHFT 16 -#define FIRE_DMCINT_IDC_ERR_TRANSID_MASK 0x000000000000c000ULL -#define FIRE_DMCINT_IDC_ERR_AGNTID_MASK 0x0000000000003c00ULL -#define FIRE_DMCINT_IDC_ERR_AGNTID_SHFT 10 -#define FIRE_DMCINT_IDC_ERR_SRCID_MASK 0x00000000000003e0ULL -#define FIRE_DMCINT_IDC_ERR_SRCID_SHFT 5 -#define FIRE_DMCINT_IDC_ERR_TARGID_MASK 0x000000000000001fULL -#define FIRE_DMCINT_IDC_ERRO_TARGID_SHFT 0 - -/* JBC CSR error log register */ -#define FIRE_JBC_CSR_ERR_LOG_WR 0x0000040000000000ULL -#define FIRE_JBC_CSR_ERR_LOG_BMASK_MASK 0x000003fffc000000ULL -#define FIRE_JBC_CSR_ERR_LOG_BMASK_SHFT 26 -#define FIRE_JBC_CSR_ERR_LOG_ADDR_MASK 0x0000000003ffffffULL -#define FIRE_JBC_CSR_ERR_LOG_ADDR_SHFT 0 - -/* JBC core and block interrupt enable register */ -#define FIRE_JBC_CORE_BLOCK_INT_EN_JBC 0x8000000000000000ULL -#define FIRE_JBC_CORE_BLOCK_INT_EN_CSR 0x0000000000000008ULL -#define FIRE_JBC_CORE_BLOCK_INT_EN_MERGE 0x0000000000000004ULL -#define FIRE_JBC_CORE_BLOCK_INT_EN_JBCINT 0x0000000000000002ULL -#define FIRE_JBC_CORE_BLOCK_INT_EN_DMCINT 0x0000000000000001ULL - -/* JBC core and block error status register */ -#define FIRE_JBC_CORE_BLOCK_ERR_STAT_CSR 0x0000000000000008ULL -#define FIRE_JBC_CORE_BLOCK_ERR_STAT_MERGE 0x0000000000000004ULL -#define FIRE_JBC_CORE_BLOCK_ERR_STAT_JBCINT 0x0000000000000002ULL -#define FIRE_JBC_CORE_BLOCK_ERR_STAT_DMCINT 0x0000000000000001ULL - -/* JBC performance counter select register - may also apply to UBC */ -#define FO_XBC_PRF_CNT_PIO_RD_PCIEB 0x0000000000000018ULL -#define FO_XBC_PRF_CNT_PIO_WR_PCIEB 0x0000000000000017ULL -#define FO_XBC_PRF_CNT_PIO_RD_PCIEA 0x0000000000000016ULL -#define FO_XBC_PRF_CNT_PIO_WR_PCIEA 0x0000000000000015ULL -#define FO_XBC_PRF_CNT_WB 0x0000000000000014ULL -#define FO_XBC_PRF_CNT_PIO_FRGN 0x0000000000000013ULL -#define FO_XBC_PRF_CNT_XB_NCHRNT 0x0000000000000012ULL -#define FO_XBC_PRF_CNT_FO_CHRNT 0x0000000000000011ULL -#define FO_XBC_PRF_CNT_XB_CHRNT 0x0000000000000010ULL -#define FO_XBC_PRF_CNT_AOKOFF_DOKOFF 0x000000000000000fULL -#define FO_XBC_PRF_CNT_DOKOFF 0x000000000000000eULL -#define FO_XBC_PRF_CNT_AOKOFF 0x000000000000000dULL -#define FO_XBC_PRF_CNT_RD_TOTAL 0x000000000000000cULL -#define FO_XBC_PRF_CNT_WR_TOTAL 0x000000000000000bULL -#define FO_XBC_PRF_CNT_WR_PARTIAL 0x000000000000000aULL -#define FO_XBC_PRF_CNT_PIOS_CSR_RINGB 0x0000000000000009ULL -#define FO_XBC_PRF_CNT_PIOS_CSR_RINGA 0x0000000000000008ULL -#define FO_XBC_PRF_CNT_PIOS_EBUS 0x0000000000000007ULL -#define FO_XBC_PRF_CNT_PIOS_I2C 0x0000000000000006ULL -#define FO_XBC_PRF_CNT_RD_LAT_SMPLS 0x0000000000000005ULL -#define FO_XBC_PRF_CNT_RD_LAT 0x0000000000000004ULL -#define FO_XBC_PRF_CNT_ON_XB 0x0000000000000003ULL -#define FO_XBC_PRF_CNT_XB_IDL 0x0000000000000002ULL -#define FO_XBC_PRF_CNT_XB_CLK 0x0000000000000001ULL -#define FO_XBC_PRF_CNT_NONE 0x0000000000000000ULL -#define FO_XBC_PRF_CNT_CNT1_SHFT 8 -#define FO_XBC_PRF_CNT_CNT0_SHFT 0 - -/* JBC performance counter 0/1 registers - may also apply to UBC */ -#define FO_XBC_PRF_CNT_MASK 0xffffffffffffffffULL -#define FO_XBC_PRF_CNT_SHFT 0 - -/* Lookup tables */ -const uint16_t fire_freq_nak_tmr_thrs[6][4] = { - { 0x00ed, 0x049, 0x043, 0x030 }, - { 0x01a0, 0x076, 0x06b, 0x048 }, - { 0x022f, 0x09a, 0x056, 0x056 }, - { 0x042f, 0x11a, 0x096, 0x096 }, - { 0x082f, 0x21a, 0x116, 0x116 }, - { 0x102f, 0x41a, 0x216, 0x216 } -}; - -const uint16_t fire_rply_tmr_thrs[6][4] = { - { 0x0379, 0x112, 0x0fc, 0x0b4 }, - { 0x0618, 0x1BA, 0x192, 0x10e }, - { 0x0831, 0x242, 0x143, 0x143 }, - { 0x0fb1, 0x422, 0x233, 0x233 }, - { 0x1eb0, 0x7e1, 0x412, 0x412 }, - { 0x3cb0, 0xf61, 0x7d2, 0x7d2 } -}; - -/* Register default values */ -#define FO_PCI_TLU_CTRL_L0S_TIM_DFLT 0xda -#define FO_PCI_TLU_CTRL_CFG_DFLT 0x1 -#define FO_PCI_LPU_LTSSM_CFG2_12_TO_DFLT 0x2dc6c0 -#define FO_PCI_LPU_LTSSM_CFG3_2_TO_DFLT 0x7a120 -#define FO_PCI_LPU_LTSSM_CFG4_DATA_RATE_DFLT 0x2 -#define FO_PCI_LPU_LTSSM_CFG4_N_FTS_DFLT 0x8c -#define OBERON_PCI_LPU_TXLNK_RPLY_TMR_THRS_DFLT 0xc9 -#define FO_PCI_LPU_TXLNK_RTR_FIFO_PTR_HD_DFLT 0x0 -#define FO_PCI_LPU_TXLNK_RTR_FIFO_PTR_TL_DFLT 0xffff - -/* INO macros */ -#define FO_EQ_FIRST_INO 0x18 -#define FO_EQ_LAST_INO 0x3b -#define FO_DMC_PEC_INO 0x3e -#define FO_XCB_INO 0x3f -#define FO_MAX_INO FO_XCB_INO - -/* Device space macros */ -#define FO_CONF_BUS_SHFT 20 -#define FO_CONF_DEV_SHFT 15 -#define FO_CONF_FUNC_SHFT 12 -#define FO_CONF_REG_SHFT 0 -#define FO_IO_SIZE 0x10000000 -#define FO_MEM_SIZE 0x1ffff0000 - -#define FO_CONF_OFF(bus, slot, func, reg) \ - (((bus) << FO_CONF_BUS_SHFT) | \ - ((slot) << FO_CONF_DEV_SHFT) | \ - ((func) << FO_CONF_FUNC_SHFT) | \ - ((reg) << FO_CONF_REG_SHFT)) - -/* Width of the physical addresses the IOMMU translates to */ -#define FIRE_IOMMU_BITS 43 -#define OBERON_IOMMU_BITS 47 - -/* Event queue macros */ -#define FO_EQ_ALIGNMENT (512 * 1024) -#define FO_EQ_NRECORDS 128 -#define FO_EQ_RECORD_SIZE 64 - -/* Event queue record format */ -struct fo_msiq_record { - uint64_t fomqr_word0; - uint64_t fomqr_word1; - uint64_t fomqr_reserved[6]; -}; - -#define FO_MQR_WORD0_FMT_TYPE_MASK 0x7f00000000000000ULL -#define FO_MQR_WORD0_FMT_TYPE_SHFT 56 -#define FO_MQR_WORD0_FMT_TYPE_MSI64 0x7800000000000000ULL -#define FO_MQR_WORD0_FMT_TYPE_MSI32 0x5800000000000000ULL -#define FO_MQR_WORD0_FMT_TYPE_MSG 0x3000000000000000ULL -#define FO_MQR_WORD0_FMT_TYPE_MSG_ROUTE_MASK 0x0700000000000000ULL -#define FO_MQR_WORD0_FMT_TYPE_MSG_ROUTE_SHFT 56 -#define FO_MQR_WORD0_LENGTH_MASK 0x00ffc00000000000ULL -#define FO_MQR_WORD0_LENGTH_SHFT 46 -#define FO_MQR_WORD0_ADDR0_MASK 0x00003fff00000000ULL -#define FO_MQR_WORD0_ADDR0_SHFT 32 -#define FO_MQR_WORD0_RID_MASK 0x00000000ffff0000ULL -#define FO_MQR_WORD0_RID_SHFT 16 -#define FO_MQR_WORD0_DATA0_MASK 0x000000000000ffffULL -#define FO_MQR_WORD0_DATA0_SHFT 0 -#define FO_MQR_WORD1_ADDR1_MASK 0xffffffffffff0000ULL -#define FO_MQR_WORD1_ADDR1_SHFT 16 -#define FO_MQR_WORD1_DATA1_MASK 0x000000000000ffffULL -#define FO_MQR_WORD1_DATA1_SHFT 0 - -#endif /* !_SPARC64_PCI_FIREREG_H_ */ diff --git a/sys/sparc64/pci/firevar.h b/sys/sparc64/pci/firevar.h deleted file mode 100644 index 6f5765b036e0..000000000000 --- a/sys/sparc64/pci/firevar.h +++ /dev/null @@ -1,91 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD - * - * Copyright (c) 2009 by Marius Strobl . - * 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, - * without modification, immediately at the beginning of the file. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD$ - */ - -#ifndef _SPARC64_PCI_FIREVAR_H_ -#define _SPARC64_PCI_FIREVAR_H_ - -struct fire_softc { - /* - * This is here so that we can hook up the common bus interface - * methods in ofw_pci.c directly. - */ - struct ofw_pci_softc sc_ops; - - struct iommu_state sc_is; - struct bus_dma_methods sc_dma_methods; - - struct mtx sc_msi_mtx; - struct mtx sc_pcib_mtx; - - struct resource *sc_mem_res[FIRE_NREG]; - struct resource *sc_irq_res[FIRE_NINTR]; - void *sc_ihand[FIRE_NINTR]; - - device_t sc_dev; - - uint64_t *sc_msiq; - u_char *sc_msi_bitmap; - uint32_t *sc_msi_msiq_table; - u_char *sc_msiq_bitmap; - uint64_t sc_msi_addr32; - uint64_t sc_msi_addr64; - uint32_t sc_msi_count; - uint32_t sc_msi_first; - uint32_t sc_msi_data_mask; - uint32_t sc_msix_data_width; - uint32_t sc_msiq_count; - uint32_t sc_msiq_size; - uint32_t sc_msiq_first; - uint32_t sc_msiq_ino_first; - - u_int sc_mode; -#define FIRE_MODE_FIRE 0 -#define FIRE_MODE_OBERON 1 - - u_int sc_flags; -#define FIRE_MSIX (1 << 0) - - uint32_t sc_ign; - - uint32_t sc_stats_ilu_err; - uint32_t sc_stats_jbc_ce_async; - uint32_t sc_stats_jbc_unsol_int; - uint32_t sc_stats_jbc_unsol_rd; - uint32_t sc_stats_mmu_err; - uint32_t sc_stats_tlu_ce; - uint32_t sc_stats_tlu_oe_non_fatal; - uint32_t sc_stats_tlu_oe_rx_err; - uint32_t sc_stats_tlu_oe_tx_err; - uint32_t sc_stats_ubc_dmardue; -}; - -#endif /* !_SPARC64_PCI_FIREVAR_H_ */ diff --git a/sys/sparc64/pci/ofw_pci.c b/sys/sparc64/pci/ofw_pci.c deleted file mode 100644 index 67b07b727cd6..000000000000 --- a/sys/sparc64/pci/ofw_pci.c +++ /dev/null @@ -1,406 +0,0 @@ -/*- - * Copyright (c) 1999, 2000 Matthew R. Green - * Copyright (c) 2001 - 2003 by Thomas Moestl - * Copyright (c) 2005 - 2015 by Marius Strobl - * 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. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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. - * - * from: NetBSD: psycho.c,v 1.35 2001/09/10 16:17:06 eeh Exp - */ - -#include -__FBSDID("$FreeBSD$"); - -#include "opt_ofw_pci.h" - -#include -#include -#include -#include -#include - -#include -#include -#include - -#include -#include - -#include -#include -#include -#include -#include -#include - -#include - -int -ofw_pci_attach_common(device_t dev, bus_dma_tag_t dmat, u_long iosize, - u_long memsize) -{ - struct ofw_pci_softc *sc; - struct ofw_pci_ranges *range; - phandle_t node; - uint32_t prop_array[2]; - u_int i, j, nrange; - - sc = device_get_softc(dev); - node = ofw_bus_get_node(dev); - sc->sc_node = node; - sc->sc_pci_dmat = dmat; - - /* Initialize memory and I/O rmans. */ - sc->sc_pci_io_rman.rm_type = RMAN_ARRAY; - sc->sc_pci_io_rman.rm_descr = "PCI I/O Ports"; - if (rman_init(&sc->sc_pci_io_rman) != 0 || - rman_manage_region(&sc->sc_pci_io_rman, 0, iosize) != 0) { - device_printf(dev, "failed to set up I/O rman\n"); - return (ENXIO); - } - sc->sc_pci_mem_rman.rm_type = RMAN_ARRAY; - sc->sc_pci_mem_rman.rm_descr = "PCI Memory"; - if (rman_init(&sc->sc_pci_mem_rman) != 0 || - rman_manage_region(&sc->sc_pci_mem_rman, 0, memsize) != 0) { - device_printf(dev, "failed to set up memory rman\n"); - return (ENXIO); - } - - /* - * Find the addresses of the various bus spaces. The physical - * start addresses of the ranges are the configuration, I/O and - * memory handles. There should not be multiple ones of one kind. - */ - nrange = OF_getprop_alloc_multi(node, "ranges", sizeof(*range), - (void **)&range); - for (i = 0; i < nrange; i++) { - j = OFW_PCI_RANGE_CS(&range[i]); - if (sc->sc_pci_bh[j] != 0) { - device_printf(dev, "duplicate range for space %d\n", - j); - OF_prop_free(range); - return (EINVAL); - } - sc->sc_pci_bh[j] = OFW_PCI_RANGE_PHYS(&range[i]); - } - OF_prop_free(range); - - /* - * Make sure that the expected ranges are actually present. - * The OFW_PCI_CS_MEM64 one is not currently used. - */ - if (sc->sc_pci_bh[OFW_PCI_CS_CONFIG] == 0) { - device_printf(dev, "missing CONFIG range\n"); - return (ENXIO); - } - if (sc->sc_pci_bh[OFW_PCI_CS_IO] == 0) { - device_printf(dev, "missing IO range\n"); - return (ENXIO); - } - if (sc->sc_pci_bh[OFW_PCI_CS_MEM32] == 0) { - device_printf(dev, "missing MEM32 range\n"); - return (ENXIO); - } - - /* Allocate our tags. */ - sc->sc_pci_iot = sparc64_alloc_bus_tag(NULL, PCI_IO_BUS_SPACE); - if (sc->sc_pci_iot == NULL) { - device_printf(dev, "could not allocate PCI I/O tag\n"); - return (ENXIO); - } - sc->sc_pci_cfgt = sparc64_alloc_bus_tag(NULL, PCI_CONFIG_BUS_SPACE); - if (sc->sc_pci_cfgt == NULL) { - device_printf(dev, - "could not allocate PCI configuration space tag\n"); - return (ENXIO); - } - - /* - * Get the bus range from the firmware. - */ - i = OF_getprop(node, "bus-range", (void *)prop_array, - sizeof(prop_array)); - if (i == -1) { - device_printf(dev, "could not get bus-range\n"); - return (ENXIO); - } - if (i != sizeof(prop_array)) { - device_printf(dev, "broken bus-range (%d)", i); - return (EINVAL); - } - sc->sc_pci_secbus = prop_array[0]; - sc->sc_pci_subbus = prop_array[1]; - if (bootverbose != 0) - device_printf(dev, "bus range %u to %u; PCI bus %d\n", - sc->sc_pci_secbus, sc->sc_pci_subbus, sc->sc_pci_secbus); - - ofw_bus_setup_iinfo(node, &sc->sc_pci_iinfo, sizeof(ofw_pci_intr_t)); - - return (0); -} - -uint32_t -ofw_pci_read_config_common(device_t dev, u_int regmax, u_long offset, - u_int bus, u_int slot, u_int func, u_int reg, int width) -{ - struct ofw_pci_softc *sc; - bus_space_handle_t bh; - uint32_t r, wrd; - int i; - uint16_t shrt; - uint8_t byte; - - sc = device_get_softc(dev); - if (bus < sc->sc_pci_secbus || bus > sc->sc_pci_subbus || - slot > PCI_SLOTMAX || func > PCI_FUNCMAX || reg > regmax) - return (-1); - - bh = sc->sc_pci_bh[OFW_PCI_CS_CONFIG]; - switch (width) { - case 1: - i = bus_space_peek_1(sc->sc_pci_cfgt, bh, offset, &byte); - r = byte; - break; - case 2: - i = bus_space_peek_2(sc->sc_pci_cfgt, bh, offset, &shrt); - r = shrt; - break; - case 4: - i = bus_space_peek_4(sc->sc_pci_cfgt, bh, offset, &wrd); - r = wrd; - break; - default: - panic("%s: bad width %d", __func__, width); - /* NOTREACHED */ - } - - if (i) { -#ifdef OFW_PCI_DEBUG - printf("%s: read data error reading: %d.%d.%d: 0x%x\n", - __func__, bus, slot, func, reg); -#endif - r = -1; - } - return (r); -} - -void -ofw_pci_write_config_common(device_t dev, u_int regmax, u_long offset, - u_int bus, u_int slot, u_int func, u_int reg, uint32_t val, int width) -{ - struct ofw_pci_softc *sc; - bus_space_handle_t bh; - - sc = device_get_softc(dev); - if (bus < sc->sc_pci_secbus || bus > sc->sc_pci_subbus || - slot > PCI_SLOTMAX || func > PCI_FUNCMAX || reg > regmax) - return; - - bh = sc->sc_pci_bh[OFW_PCI_CS_CONFIG]; - switch (width) { - case 1: - bus_space_write_1(sc->sc_pci_cfgt, bh, offset, val); - break; - case 2: - bus_space_write_2(sc->sc_pci_cfgt, bh, offset, val); - break; - case 4: - bus_space_write_4(sc->sc_pci_cfgt, bh, offset, val); - break; - default: - panic("%s: bad width %d", __func__, width); - /* NOTREACHED */ - } -} - -ofw_pci_intr_t -ofw_pci_route_interrupt_common(device_t bridge, device_t dev, int pin) -{ - struct ofw_pci_softc *sc; - struct ofw_pci_register reg; - ofw_pci_intr_t pintr, mintr; - - sc = device_get_softc(bridge); - pintr = pin; - if (ofw_bus_lookup_imap(ofw_bus_get_node(dev), &sc->sc_pci_iinfo, - ®, sizeof(reg), &pintr, sizeof(pintr), &mintr, sizeof(mintr), - NULL) != 0) - return (mintr); - return (PCI_INVALID_IRQ); -} - -void -ofw_pci_dmamap_sync_stst_order_common(void) -{ - static u_char buf[VIS_BLOCKSIZE] __aligned(VIS_BLOCKSIZE); - register_t reg, s; - - s = intr_disable(); - reg = rd(fprs); - wr(fprs, reg | FPRS_FEF, 0); - __asm __volatile("stda %%f0, [%0] %1" - : : "r" (buf), "n" (ASI_BLK_COMMIT_S)); - membar(Sync); - wr(fprs, reg, 0); - intr_restore(s); -} - -int -ofw_pci_read_ivar(device_t dev, device_t child __unused, int which, - uintptr_t *result) -{ - struct ofw_pci_softc *sc; - - switch (which) { - case PCIB_IVAR_DOMAIN: - *result = device_get_unit(dev); - return (0); - case PCIB_IVAR_BUS: - sc = device_get_softc(dev); - *result = sc->sc_pci_secbus; - return (0); - } - return (ENOENT); -} - -struct resource * -ofw_pci_alloc_resource(device_t bus, device_t child, int type, int *rid, - rman_res_t start, rman_res_t end, rman_res_t count, u_int flags) -{ - struct ofw_pci_softc *sc; - struct resource *rv; - struct rman *rm; - - sc = device_get_softc(bus); - switch (type) { - case SYS_RES_IRQ: - /* - * XXX: Don't accept blank ranges for now, only single - * interrupts. The other case should not happen with - * the MI PCI code ... - * XXX: This may return a resource that is out of the - * range that was specified. Is this correct ...? - */ - if (start != end) - panic("%s: XXX: interrupt range", __func__); - return (bus_generic_alloc_resource(bus, child, type, rid, - start, end, count, flags)); - case SYS_RES_MEMORY: - rm = &sc->sc_pci_mem_rman; - break; - case SYS_RES_IOPORT: - rm = &sc->sc_pci_io_rman; - break; - default: - return (NULL); - } - - rv = rman_reserve_resource(rm, start, end, count, flags & ~RF_ACTIVE, - child); - if (rv == NULL) - return (NULL); - rman_set_rid(rv, *rid); - - if ((flags & RF_ACTIVE) != 0 && bus_activate_resource(child, type, - *rid, rv) != 0) { - rman_release_resource(rv); - return (NULL); - } - return (rv); -} - -int -ofw_pci_activate_resource(device_t bus, device_t child, int type, int rid, - struct resource *r) -{ - struct ofw_pci_softc *sc; - struct bus_space_tag *tag; - - sc = device_get_softc(bus); - switch (type) { - case SYS_RES_IRQ: - return (bus_generic_activate_resource(bus, child, type, rid, - r)); - case SYS_RES_MEMORY: - tag = sparc64_alloc_bus_tag(r, PCI_MEMORY_BUS_SPACE); - if (tag == NULL) - return (ENOMEM); - rman_set_bustag(r, tag); - rman_set_bushandle(r, sc->sc_pci_bh[OFW_PCI_CS_MEM32] + - rman_get_start(r)); - break; - case SYS_RES_IOPORT: - rman_set_bustag(r, sc->sc_pci_iot); - rman_set_bushandle(r, sc->sc_pci_bh[OFW_PCI_CS_IO] + - rman_get_start(r)); - break; - } - return (rman_activate_resource(r)); -} - -int -ofw_pci_adjust_resource(device_t bus, device_t child, int type, - struct resource *r, rman_res_t start, rman_res_t end) -{ - struct ofw_pci_softc *sc; - struct rman *rm; - - sc = device_get_softc(bus); - switch (type) { - case SYS_RES_IRQ: - return (bus_generic_adjust_resource(bus, child, type, r, - start, end)); - case SYS_RES_MEMORY: - rm = &sc->sc_pci_mem_rman; - break; - case SYS_RES_IOPORT: - rm = &sc->sc_pci_io_rman; - break; - default: - return (EINVAL); - } - if (rman_is_region_manager(r, rm) == 0) - return (EINVAL); - return (rman_adjust_resource(r, start, end)); -} - -bus_dma_tag_t -ofw_pci_get_dma_tag(device_t bus, device_t child __unused) -{ - struct ofw_pci_softc *sc; - - sc = device_get_softc(bus); - return (sc->sc_pci_dmat); -} - -phandle_t -ofw_pci_get_node(device_t bus, device_t child __unused) -{ - struct ofw_pci_softc *sc; - - sc = device_get_softc(bus); - /* We only have one child, the PCI bus, which needs our own node. */ - return (sc->sc_node); -} diff --git a/sys/sparc64/pci/ofw_pci.h b/sys/sparc64/pci/ofw_pci.h deleted file mode 100644 index 908e35d8fcd8..000000000000 --- a/sys/sparc64/pci/ofw_pci.h +++ /dev/null @@ -1,172 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-3-Clause - * - * Copyright (c) 1999, 2000 Matthew R. Green - * 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. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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. - */ - -/*- - * Copyright (c) 1998, 1999 Eduardo E. Horvath - * Copyright (c) 2001, 2003 by Thomas Moestl - * 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. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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. - * - * from: NetBSD: psychoreg.h,v 1.14 2008/05/30 02:29:37 mrg Exp - * - * $FreeBSD$ - */ - -#ifndef _SPARC64_PCI_OFW_PCI_H_ -#define _SPARC64_PCI_OFW_PCI_H_ - -#include - -#include - -#include "ofw_pci_if.h" - -typedef uint32_t ofw_pci_intr_t; - -/* PCI range child spaces. XXX: are these MI? */ -#define OFW_PCI_CS_CONFIG 0x00 -#define OFW_PCI_CS_IO 0x01 -#define OFW_PCI_CS_MEM32 0x02 -#define OFW_PCI_CS_MEM64 0x03 -#define OFW_PCI_NUM_CS 4 - -/* OFW device types */ -#define OFW_TYPE_PCI "pci" -#define OFW_TYPE_PCIE "pciex" - -struct ofw_pci_msi_addr_ranges { - uint32_t addr32_hi; - uint32_t addr32_lo; - uint32_t addr32_sz; - uint32_t addr64_hi; - uint32_t addr64_lo; - uint32_t addr64_sz; -}; - -#define OFW_PCI_MSI_ADDR_RANGE_32(r) \ - (((uint64_t)(r)->addr32_hi << 32) | (uint64_t)(r)->addr32_lo) -#define OFW_PCI_MSI_ADDR_RANGE_64(r) \ - (((uint64_t)(r)->addr64_hi << 32) | (uint64_t)(r)->addr64_lo) - -struct ofw_pci_msi_eq_to_devino { - uint32_t eq_first; - uint32_t eq_count; - uint32_t devino_first; -}; - -struct ofw_pci_msi_ranges { - uint32_t first; - uint32_t count; -}; - -struct ofw_pci_ranges { - uint32_t cspace; - uint32_t child_hi; - uint32_t child_lo; - uint32_t phys_hi; - uint32_t phys_lo; - uint32_t size_hi; - uint32_t size_lo; -}; - -#define OFW_PCI_RANGE_CHILD(r) \ - (((uint64_t)(r)->child_hi << 32) | (uint64_t)(r)->child_lo) -#define OFW_PCI_RANGE_PHYS(r) \ - (((uint64_t)(r)->phys_hi << 32) | (uint64_t)(r)->phys_lo) -#define OFW_PCI_RANGE_SIZE(r) \ - (((uint64_t)(r)->size_hi << 32) | (uint64_t)(r)->size_lo) -#define OFW_PCI_RANGE_CS(r) (((r)->cspace >> 24) & 0x03) - -/* default values */ -#define OFW_PCI_LATENCY 64 - -/* - * Common and generic parts of host-PCI-bridge support - */ - -struct ofw_pci_softc { - struct rman sc_pci_mem_rman; - struct rman sc_pci_io_rman; - - bus_space_handle_t sc_pci_bh[OFW_PCI_NUM_CS]; - bus_space_tag_t sc_pci_cfgt; - bus_space_tag_t sc_pci_iot; - bus_dma_tag_t sc_pci_dmat; - - struct ofw_bus_iinfo sc_pci_iinfo; - - phandle_t sc_node; - - uint8_t sc_pci_secbus; - uint8_t sc_pci_subbus; -}; - -int ofw_pci_attach_common(device_t dev, bus_dma_tag_t dmat, u_long iosize, - u_long memsize); -uint32_t ofw_pci_read_config_common(device_t dev, u_int regmax, u_long offset, - u_int bus, u_int slot, u_int func, u_int reg, int width); -void ofw_pci_write_config_common(device_t dev, u_int regmax, u_long offset, - u_int bus, u_int slot, u_int func, u_int reg, uint32_t val, int width); -ofw_pci_intr_t ofw_pci_route_interrupt_common(device_t bridge, device_t dev, - int pin); - -void ofw_pci_dmamap_sync_stst_order_common(void); - -bus_activate_resource_t ofw_pci_activate_resource; -bus_adjust_resource_t ofw_pci_adjust_resource; -bus_alloc_resource_t ofw_pci_alloc_resource; -bus_get_dma_tag_t ofw_pci_get_dma_tag; -bus_read_ivar_t ofw_pci_read_ivar; - -ofw_bus_get_node_t ofw_pci_get_node; - -#endif /* ! _SPARC64_PCI_OFW_PCI_H_ */ diff --git a/sys/sparc64/pci/ofw_pci_if.m b/sys/sparc64/pci/ofw_pci_if.m deleted file mode 100644 index f9490bd78282..000000000000 --- a/sys/sparc64/pci/ofw_pci_if.m +++ /dev/null @@ -1,48 +0,0 @@ -#- -# Copyright (c) 2001, 2003 by Thomas Moestl -# Copyright (c) 2011 Marius Strobl -# 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 ``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$ - -#include - -INTERFACE ofw_pci; - -CODE { - static ofw_pci_setup_device_t ofw_pci_default_setup_device; - - static void - ofw_pci_default_setup_device(device_t dev, device_t child) - { - - if (device_get_parent(dev) != NULL) - OFW_PCI_SETUP_DEVICE(device_get_parent(dev), child); - } -}; - -# Setup a device further upward in the tree. -METHOD void setup_device { - device_t dev; - device_t child; -} DEFAULT ofw_pci_default_setup_device; diff --git a/sys/sparc64/pci/ofw_pcib.c b/sys/sparc64/pci/ofw_pcib.c deleted file mode 100644 index 3589b00f32fa..000000000000 --- a/sys/sparc64/pci/ofw_pcib.c +++ /dev/null @@ -1,176 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-3-Clause - * - * Copyright (c) 1994,1995 Stefan Esser, Wolfgang StanglMeier - * Copyright (c) 2000 Michael Smith - * Copyright (c) 2000 BSDi - * Copyright (c) 2001 - 2003 Thomas Moestl - * Copyright (c) 2009 by Marius Strobl - * 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. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * 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. - * - * from: FreeBSD: src/sys/dev/pci/pci_pci.c,v 1.3 2000/12/13 - */ - -#include -__FBSDID("$FreeBSD$"); - -#include "opt_ofw_pci.h" - -#include -#include -#include -#include -#include -#include - -#include -#include - -#include -#include -#include - -#include "pcib_if.h" - -#include -#include - -#define PCI_DEVID_ALI_M5249 0x524910b9 -#define PCI_VENDOR_PLX 0x10b5 - -static device_probe_t ofw_pcib_probe; -static device_attach_t ofw_pcib_attach; -static ofw_pci_setup_device_t ofw_pcib_setup_device; - -static device_method_t ofw_pcib_methods[] = { - /* Device interface */ - DEVMETHOD(device_probe, ofw_pcib_probe), - DEVMETHOD(device_attach, ofw_pcib_attach), - - /* Bus interface */ - - /* pcib interface */ - DEVMETHOD(pcib_route_interrupt, ofw_pcib_gen_route_interrupt), - DEVMETHOD(pcib_request_feature, pcib_request_feature_allow), - - /* ofw_bus interface */ - DEVMETHOD(ofw_bus_get_node, ofw_pcib_gen_get_node), - DEVMETHOD(ofw_pci_setup_device, ofw_pcib_setup_device), - - DEVMETHOD_END -}; - -static devclass_t pcib_devclass; - -DEFINE_CLASS_1(pcib, ofw_pcib_driver, ofw_pcib_methods, - sizeof(struct ofw_pcib_gen_softc), pcib_driver); -EARLY_DRIVER_MODULE(ofw_pcib, pci, ofw_pcib_driver, pcib_devclass, NULL, NULL, - BUS_PASS_BUS); -MODULE_DEPEND(ofw_pcib, pci, 1, 1, 1); - -static int -ofw_pcib_probe(device_t dev) -{ - char desc[sizeof("OFW PCIe-PCIe bridge")]; - const char *dtype, *pbdtype; - -#define ISDTYPE(dtype, type) \ - (((dtype) != NULL) && strcmp((dtype), (type)) == 0) - - if ((pci_get_class(dev) == PCIC_BRIDGE) && - (pci_get_subclass(dev) == PCIS_BRIDGE_PCI) && - ofw_bus_get_node(dev) != 0) { - dtype = ofw_bus_get_type(dev); - pbdtype = ofw_bus_get_type(device_get_parent( - device_get_parent(dev))); - snprintf(desc, sizeof(desc), "OFW PCI%s-PCI%s bridge", - ISDTYPE(pbdtype, OFW_TYPE_PCIE) ? "e" : "", - ISDTYPE(dtype, OFW_TYPE_PCIE) ? "e" : ""); - device_set_desc_copy(dev, desc); - return (BUS_PROBE_DEFAULT); - } - -#undef ISDTYPE - - return (ENXIO); -} - -static int -ofw_pcib_attach(device_t dev) -{ - struct ofw_pcib_gen_softc *sc; - - sc = device_get_softc(dev); - - switch (pci_get_devid(dev)) { - /* - * The ALi M5249 found in Fire-based machines by definition must me - * subtractive as they have a ISA bridge on their secondary side but - * don't indicate this in the class code although the ISA I/O range - * isn't included in their bridge decode. - */ - case PCI_DEVID_ALI_M5249: - sc->ops_pcib_sc.flags |= PCIB_SUBTRACTIVE; - break; - } - - switch (pci_get_vendor(dev)) { - /* - * Concurrently write the primary and secondary bus numbers in order - * to work around a bug in PLX PEX 8114 causing the internal shadow - * copies of these not to be updated when setting them bytewise. - */ - case PCI_VENDOR_PLX: - pci_write_config(dev, PCIR_PRIBUS_1, - pci_read_config(dev, PCIR_SECBUS_1, 1) << 8 | - pci_read_config(dev, PCIR_PRIBUS_1, 1), 2); - break; - } - - ofw_pcib_gen_setup(dev); - pcib_attach_common(dev); - return (pcib_attach_child(dev)); -} - -static void -ofw_pcib_setup_device(device_t bus, device_t child) -{ - int i; - uint16_t reg; - - switch (pci_get_vendor(bus)) { - /* - * For PLX PEX 8532 issue 64 TLPs to the child from the downstream - * port to the child device in order to work around a hardware bug. - */ - case PCI_VENDOR_PLX: - for (i = 0, reg = 0; i < 64; i++) - reg |= pci_get_devid(child); - break; - } - - OFW_PCI_SETUP_DEVICE(device_get_parent(bus), child); -} diff --git a/sys/sparc64/pci/ofw_pcib_subr.c b/sys/sparc64/pci/ofw_pcib_subr.c deleted file mode 100644 index d6f3b264745a..000000000000 --- a/sys/sparc64/pci/ofw_pcib_subr.c +++ /dev/null @@ -1,109 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD - * - * Copyright (c) 2003 by Thomas Moestl - * 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 ``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 -__FBSDID("$FreeBSD$"); - -#include "opt_ofw_pci.h" - -#include -#include -#include -#include - -#include -#include -#include - -#include - -#include -#include -#include - -#include "pcib_if.h" - -#include -#include - -void -ofw_pcib_gen_setup(device_t bridge) -{ - struct ofw_pcib_gen_softc *sc; - - sc = device_get_softc(bridge); - sc->ops_pcib_sc.dev = bridge; - sc->ops_node = ofw_bus_get_node(bridge); - KASSERT(sc->ops_node != 0, - ("ofw_pcib_gen_setup: no ofw pci parent bus!")); - - ofw_bus_setup_iinfo(sc->ops_node, &sc->ops_iinfo, - sizeof(ofw_pci_intr_t)); -} - -int -ofw_pcib_gen_route_interrupt(device_t bridge, device_t dev, int intpin) -{ - struct ofw_pcib_gen_softc *sc; - struct ofw_bus_iinfo *ii; - struct ofw_pci_register reg; - ofw_pci_intr_t pintr, mintr; - - sc = device_get_softc(bridge); - ii = &sc->ops_iinfo; - if (ii->opi_imapsz > 0) { - pintr = intpin; - if (ofw_bus_lookup_imap(ofw_bus_get_node(dev), ii, ®, - sizeof(reg), &pintr, sizeof(pintr), &mintr, sizeof(mintr), - NULL)) { - /* - * If we've found a mapping, return it and don't map - * it again on higher levels - that causes problems - * in some cases, and never seems to be required. - */ - return (mintr); - } - } else if (intpin >= 1 && intpin <= 4) { - /* - * When an interrupt map is missing, we need to do the - * standard PCI swizzle and continue mapping at the parent. - */ - return (pcib_route_interrupt(bridge, dev, intpin)); - } - /* Try at the parent. */ - return (PCIB_ROUTE_INTERRUPT(device_get_parent(device_get_parent( - bridge)), bridge, intpin)); -} - -phandle_t -ofw_pcib_gen_get_node(device_t bridge, device_t dev) -{ - struct ofw_pcib_gen_softc *sc; - - sc = device_get_softc(bridge); - return (sc->ops_node); -} diff --git a/sys/sparc64/pci/ofw_pcib_subr.h b/sys/sparc64/pci/ofw_pcib_subr.h deleted file mode 100644 index cc551b673edf..000000000000 --- a/sys/sparc64/pci/ofw_pcib_subr.h +++ /dev/null @@ -1,48 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD - * - * Copyright (c) 2003 by Thomas Moestl - * 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 ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE - * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $FreeBSD$ - */ - -#ifndef _SPARC64_PCI_OFW_PCI_SUBR_H -#define _SPARC64_PCI_OFW_PCI_SUBR_H - -struct ofw_pcib_gen_softc { - /* - * This is here so that we can use pci bridge methods, too - the - * generic routines only need the dev, secbus and subbus members - * filled. - */ - struct pcib_softc ops_pcib_sc; - phandle_t ops_node; - struct ofw_bus_iinfo ops_iinfo; -}; - -void ofw_pcib_gen_setup(device_t); -pcib_route_interrupt_t ofw_pcib_gen_route_interrupt; -ofw_bus_get_node_t ofw_pcib_gen_get_node; - -#endif /* !_SPARC64_PCI_OFW_PCI_SUBR_H */ diff --git a/sys/sparc64/pci/ofw_pcibus.c b/sys/sparc64/pci/ofw_pcibus.c deleted file mode 100644 index f214ce27696f..000000000000 --- a/sys/sparc64/pci/ofw_pcibus.c +++ /dev/null @@ -1,368 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD - * - * Copyright (c) 1997, Stefan Esser - * Copyright (c) 2000, Michael Smith - * Copyright (c) 2000, BSDi - * Copyright (c) 2003, Thomas Moestl - * Copyright (c) 2005 - 2009 Marius Strobl - * 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 unmodified, 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 ``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 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 -__FBSDID("$FreeBSD$"); - -#include "opt_ofw_pci.h" - -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include -#ifndef SUN4V -#include -#include -#endif -#include - -#include -#include -#include - -#include - -#include "pcib_if.h" -#include "pci_if.h" - -/* Helper functions */ -static void ofw_pcibus_setup_device(device_t bridge, uint32_t clock, - u_int busno, u_int slot, u_int func); - -/* Methods */ -static bus_child_deleted_t ofw_pcibus_child_deleted; -static bus_child_pnpinfo_str_t ofw_pcibus_pnpinfo_str; -static device_attach_t ofw_pcibus_attach; -static device_probe_t ofw_pcibus_probe; -static ofw_bus_get_devinfo_t ofw_pcibus_get_devinfo; -static pci_alloc_devinfo_t ofw_pcibus_alloc_devinfo; -static pci_assign_interrupt_t ofw_pcibus_assign_interrupt; - -static device_method_t ofw_pcibus_methods[] = { - /* Device interface */ - DEVMETHOD(device_probe, ofw_pcibus_probe), - DEVMETHOD(device_attach, ofw_pcibus_attach), - - /* Bus interface */ - DEVMETHOD(bus_child_deleted, ofw_pcibus_child_deleted), - DEVMETHOD(bus_child_pnpinfo_str, ofw_pcibus_pnpinfo_str), - DEVMETHOD(bus_rescan, bus_null_rescan), - - /* PCI interface */ - DEVMETHOD(pci_alloc_devinfo, ofw_pcibus_alloc_devinfo), - DEVMETHOD(pci_assign_interrupt, ofw_pcibus_assign_interrupt), - - /* ofw_bus interface */ - DEVMETHOD(ofw_bus_get_devinfo, ofw_pcibus_get_devinfo), - DEVMETHOD(ofw_bus_get_compat, ofw_bus_gen_get_compat), - DEVMETHOD(ofw_bus_get_model, ofw_bus_gen_get_model), - DEVMETHOD(ofw_bus_get_name, ofw_bus_gen_get_name), - DEVMETHOD(ofw_bus_get_node, ofw_bus_gen_get_node), - DEVMETHOD(ofw_bus_get_type, ofw_bus_gen_get_type), - - DEVMETHOD_END -}; - -struct ofw_pcibus_devinfo { - struct pci_devinfo opd_dinfo; - struct ofw_bus_devinfo opd_obdinfo; -}; - -static devclass_t pci_devclass; - -DEFINE_CLASS_1(pci, ofw_pcibus_driver, ofw_pcibus_methods, - sizeof(struct pci_softc), pci_driver); -EARLY_DRIVER_MODULE(ofw_pcibus, pcib, ofw_pcibus_driver, pci_devclass, 0, 0, - BUS_PASS_BUS); -MODULE_VERSION(ofw_pcibus, 1); -MODULE_DEPEND(ofw_pcibus, pci, 1, 1, 1); - -static int -ofw_pcibus_probe(device_t dev) -{ - - if (ofw_bus_get_node(dev) == -1) - return (ENXIO); - device_set_desc(dev, "OFW PCI bus"); - - return (0); -} - -/* - * Perform miscellaneous setups the firmware usually does not do for us. - */ -static void -ofw_pcibus_setup_device(device_t bridge, uint32_t clock, u_int busno, - u_int slot, u_int func) -{ -#define CS_READ(n, w) \ - PCIB_READ_CONFIG(bridge, busno, slot, func, (n), (w)) -#define CS_WRITE(n, v, w) \ - PCIB_WRITE_CONFIG(bridge, busno, slot, func, (n), (v), (w)) - -#ifndef SUN4V - uint32_t reg; - - /* - * Initialize the latency timer register for busmaster devices to - * work properly. This is another task which the firmware doesn't - * always perform. The Min_Gnt register can be used to compute its - * recommended value: it contains the desired latency in units of - * 1/4 us assuming a clock rate of 33MHz. To calculate the correct - * latency timer value, the clock frequency of the bus (defaulting - * to 33MHz) should be used and no wait states assumed. - * For bridges, we additionally set up the bridge control and the - * secondary latency registers. - */ - if ((CS_READ(PCIR_HDRTYPE, 1) & PCIM_HDRTYPE) == - PCIM_HDRTYPE_BRIDGE) { - reg = CS_READ(PCIR_BRIDGECTL_1, 1); - reg |= PCIB_BCR_MASTER_ABORT_MODE | PCIB_BCR_SERR_ENABLE | - PCIB_BCR_PERR_ENABLE; -#ifdef OFW_PCI_DEBUG - device_printf(bridge, - "bridge %d/%d/%d: control 0x%x -> 0x%x\n", - busno, slot, func, CS_READ(PCIR_BRIDGECTL_1, 1), reg); -#endif /* OFW_PCI_DEBUG */ - CS_WRITE(PCIR_BRIDGECTL_1, reg, 1); - - reg = OFW_PCI_LATENCY; -#ifdef OFW_PCI_DEBUG - device_printf(bridge, - "bridge %d/%d/%d: latency timer %d -> %d\n", - busno, slot, func, CS_READ(PCIR_SECLAT_1, 1), reg); -#endif /* OFW_PCI_DEBUG */ - CS_WRITE(PCIR_SECLAT_1, reg, 1); - } else { - reg = CS_READ(PCIR_MINGNT, 1); - if ((int)reg > 0) { - switch (clock) { - case 33000000: - reg *= 8; - break; - case 66000000: - reg *= 4; - break; - } - reg = min(reg, 255); - } else - reg = OFW_PCI_LATENCY; - } -#ifdef OFW_PCI_DEBUG - device_printf(bridge, "device %d/%d/%d: latency timer %d -> %d\n", - busno, slot, func, CS_READ(PCIR_LATTIMER, 1), reg); -#endif /* OFW_PCI_DEBUG */ - CS_WRITE(PCIR_LATTIMER, reg, 1); - - /* - * Compute a value to write into the cache line size register. - * The role of the streaming cache is unclear in write invalidate - * transfers, so it is made sure that it's line size is always - * reached. Generally, the cache line size is fixed at 64 bytes - * by Fireplane/Safari, JBus and UPA. - */ - CS_WRITE(PCIR_CACHELNSZ, STRBUF_LINESZ / sizeof(uint32_t), 1); -#endif - - /* - * Ensure that ALi M5229 report the actual content of PCIR_PROGIF - * and that IDE I/O is force enabled. The former is done in order - * to have unique behavior across revisions as some default to - * hiding bits 4-6 for compliance with PCI 2.3. The latter is done - * as at least revision 0xc8 requires the PCIM_CMD_PORTEN bypass - * to be always enabled as otherwise even enabling PCIM_CMD_PORTEN - * results in an instant data access trap on Fire-based machines. - * Thus these quirks have to be handled before pci(4) adds the maps. - * Note that for older revisions bit 0 of register 0x50 enables the - * internal IDE function instead of force enabling IDE I/O. - */ - if ((CS_READ(PCIR_VENDOR, 2) == 0x10b9 && - CS_READ(PCIR_DEVICE, 2) == 0x5229)) - CS_WRITE(0x50, CS_READ(0x50, 1) | 0x3, 1); - - /* - * The preset in the intline register is usually wrong. Reset - * it to 255, so that the PCI code will reroute the interrupt if - * needed. - */ - CS_WRITE(PCIR_INTLINE, PCI_INVALID_IRQ, 1); - -#undef CS_READ -#undef CS_WRITE -} - -static int -ofw_pcibus_attach(device_t dev) -{ - device_t pcib; - struct ofw_pci_register pcir; - struct ofw_pcibus_devinfo *dinfo; - phandle_t node, child; - uint32_t clock; - u_int busno, domain, func, slot; - int error; - - error = pci_attach_common(dev); - if (error) - return (error); - pcib = device_get_parent(dev); - domain = pcib_get_domain(dev); - busno = pcib_get_bus(dev); - node = ofw_bus_get_node(dev); - - /* - * Add the PCI side of the host-PCI bridge itself to the bus. - * Note that we exclude the host-PCIe bridges here as these - * have no configuration space implemented themselves. - */ - if (strcmp(device_get_name(device_get_parent(pcib)), "nexus") == 0 && - ofw_bus_get_type(pcib) != NULL && - strcmp(ofw_bus_get_type(pcib), OFW_TYPE_PCIE) != 0 && - (dinfo = (struct ofw_pcibus_devinfo *)pci_read_device(pcib, dev, - domain, busno, 0, 0)) != NULL) { - if (ofw_bus_gen_setup_devinfo(&dinfo->opd_obdinfo, node) != 0) - pci_freecfg((struct pci_devinfo *)dinfo); - else - pci_add_child(dev, (struct pci_devinfo *)dinfo); - } - - if (OF_getprop(ofw_bus_get_node(pcib), "clock-frequency", &clock, - sizeof(clock)) == -1) - clock = 33000000; - for (child = OF_child(node); child != 0; child = OF_peer(child)) { - if (OF_getprop(child, "reg", &pcir, sizeof(pcir)) == -1) - continue; - slot = OFW_PCI_PHYS_HI_DEVICE(pcir.phys_hi); - func = OFW_PCI_PHYS_HI_FUNCTION(pcir.phys_hi); - /* Some OFW device trees contain dupes. */ - if (pci_find_dbsf(domain, busno, slot, func) != NULL) - continue; - ofw_pcibus_setup_device(pcib, clock, busno, slot, func); - dinfo = (struct ofw_pcibus_devinfo *)pci_read_device(pcib, dev, - domain, busno, slot, func); - if (dinfo == NULL) - continue; - if (ofw_bus_gen_setup_devinfo(&dinfo->opd_obdinfo, child) != - 0) { - pci_freecfg((struct pci_devinfo *)dinfo); - continue; - } - pci_add_child(dev, (struct pci_devinfo *)dinfo); - OFW_PCI_SETUP_DEVICE(pcib, dinfo->opd_dinfo.cfg.dev); - } - - return (bus_generic_attach(dev)); -} - -struct pci_devinfo * -ofw_pcibus_alloc_devinfo(device_t dev) -{ - struct ofw_pcibus_devinfo *dinfo; - - dinfo = malloc(sizeof(*dinfo), M_DEVBUF, M_WAITOK | M_ZERO); - return (&dinfo->opd_dinfo); -} - -static int -ofw_pcibus_assign_interrupt(device_t dev, device_t child) -{ - ofw_pci_intr_t intr; - int isz; - - isz = OF_getprop(ofw_bus_get_node(child), "interrupts", &intr, - sizeof(intr)); - if (isz != sizeof(intr)) { - /* No property; our best guess is the intpin. */ - intr = pci_get_intpin(child); -#ifndef SUN4V - } else if (intr >= 255) { - /* - * A fully specified interrupt (including IGN), as present on - * SPARCengine Ultra AX and E450. Extract the INO and return - * it. - */ - return (INTINO(intr)); -#endif - } - /* - * If we got intr from a property, it may or may not be an intpin. - * For on-board devices, it frequently is not, and is completely out - * of the valid intpin range. For PCI slots, it hopefully is, - * otherwise we will have trouble interfacing with non-OFW buses - * such as cardbus. - * Since we cannot tell which it is without violating layering, we - * will always use the route_interrupt method, and treat exceptions - * on the level they become apparent. - */ - return (PCIB_ROUTE_INTERRUPT(device_get_parent(dev), child, intr)); -} - -static const struct ofw_bus_devinfo * -ofw_pcibus_get_devinfo(device_t bus, device_t dev) -{ - struct ofw_pcibus_devinfo *dinfo; - - dinfo = device_get_ivars(dev); - return (&dinfo->opd_obdinfo); -} - -static void -ofw_pcibus_child_deleted(device_t dev, device_t child) -{ - struct ofw_pcibus_devinfo *dinfo; - - dinfo = device_get_ivars(dev); - ofw_bus_gen_destroy_devinfo(&dinfo->opd_obdinfo); - pci_child_deleted(dev, child); -} - -static int -ofw_pcibus_pnpinfo_str(device_t dev, device_t child, char *buf, - size_t buflen) -{ - - pci_child_pnpinfo_str_method(dev, child, buf, buflen); - if (ofw_bus_get_node(child) != -1) { - strlcat(buf, " ", buflen); /* Separate info. */ - ofw_bus_gen_child_pnpinfo_str(dev, child, buf, buflen); - } - - return (0); -} diff --git a/sys/sparc64/pci/psycho.c b/sys/sparc64/pci/psycho.c deleted file mode 100644 index f7f4c40e389c..000000000000 --- a/sys/sparc64/pci/psycho.c +++ /dev/null @@ -1,1074 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-3-Clause - * - * Copyright (c) 1999, 2000 Matthew R. Green - * Copyright (c) 2001 - 2003 by Thomas Moestl - * Copyright (c) 2005 - 2006 Marius Strobl - * 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. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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. - * - * from: NetBSD: psycho.c,v 1.39 2001/10/07 20:30:41 eeh Exp - */ - -#include -__FBSDID("$FreeBSD$"); - -/* - * Support for `Hummingbird' (UltraSPARC IIe), `Psycho' and `Psycho+' - * (UltraSPARC II) and `Sabre' (UltraSPARC IIi) UPA to PCI bridges. - */ - -#include "opt_ofw_pci.h" -#include "opt_psycho.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include -#include -#include - -#include "pcib_if.h" - -static const struct psycho_desc *psycho_find_desc(const struct psycho_desc *, - const char *); -static const struct psycho_desc *psycho_get_desc(device_t); -static void psycho_set_intr(struct psycho_softc *, u_int, bus_addr_t, - driver_filter_t, driver_intr_t); -static int psycho_find_intrmap(struct psycho_softc *, u_int, bus_addr_t *, - bus_addr_t *, u_long *); -static void sabre_dmamap_sync(bus_dma_tag_t dt, bus_dmamap_t map, - bus_dmasync_op_t op); -static void psycho_intr_enable(void *); -static void psycho_intr_disable(void *); -static void psycho_intr_assign(void *); -static void psycho_intr_clear(void *); - -/* Interrupt handlers */ -static driver_filter_t psycho_ue; -static driver_filter_t psycho_ce; -static driver_filter_t psycho_pci_bus; -static driver_filter_t psycho_powerdebug; -static driver_intr_t psycho_powerdown; -static driver_intr_t psycho_overtemp; -#ifdef PSYCHO_MAP_WAKEUP -static driver_filter_t psycho_wakeup; -#endif - -/* IOMMU support */ -static void psycho_iommu_init(struct psycho_softc *, int, uint32_t); - -/* - * Methods - */ -static device_probe_t psycho_probe; -static device_attach_t psycho_attach; -static bus_setup_intr_t psycho_setup_intr; -static bus_alloc_resource_t psycho_alloc_resource; -static pcib_maxslots_t psycho_maxslots; -static pcib_read_config_t psycho_read_config; -static pcib_write_config_t psycho_write_config; -static pcib_route_interrupt_t psycho_route_interrupt; -static ofw_pci_setup_device_t psycho_setup_device; - -static device_method_t psycho_methods[] = { - /* Device interface */ - DEVMETHOD(device_probe, psycho_probe), - DEVMETHOD(device_attach, psycho_attach), - DEVMETHOD(device_shutdown, bus_generic_shutdown), - DEVMETHOD(device_suspend, bus_generic_suspend), - DEVMETHOD(device_resume, bus_generic_resume), - - /* Bus interface */ - DEVMETHOD(bus_read_ivar, ofw_pci_read_ivar), - DEVMETHOD(bus_setup_intr, psycho_setup_intr), - DEVMETHOD(bus_teardown_intr, bus_generic_teardown_intr), - DEVMETHOD(bus_alloc_resource, psycho_alloc_resource), - DEVMETHOD(bus_activate_resource, ofw_pci_activate_resource), - DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource), - DEVMETHOD(bus_adjust_resource, ofw_pci_adjust_resource), - DEVMETHOD(bus_release_resource, bus_generic_release_resource), - DEVMETHOD(bus_get_dma_tag, ofw_pci_get_dma_tag), - - /* pcib interface */ - DEVMETHOD(pcib_maxslots, psycho_maxslots), - DEVMETHOD(pcib_read_config, psycho_read_config), - DEVMETHOD(pcib_write_config, psycho_write_config), - DEVMETHOD(pcib_route_interrupt, psycho_route_interrupt), - DEVMETHOD(pcib_request_feature, pcib_request_feature_allow), - - /* ofw_bus interface */ - DEVMETHOD(ofw_bus_get_node, ofw_pci_get_node), - - /* ofw_pci interface */ - DEVMETHOD(ofw_pci_setup_device, psycho_setup_device), - - DEVMETHOD_END -}; - -static devclass_t psycho_devclass; - -DEFINE_CLASS_0(pcib, psycho_driver, psycho_methods, - sizeof(struct psycho_softc)); -EARLY_DRIVER_MODULE(psycho, nexus, psycho_driver, psycho_devclass, NULL, NULL, - BUS_PASS_BUS); - -static SYSCTL_NODE(_hw, OID_AUTO, psycho, CTLFLAG_RD, 0, "psycho parameters"); - -static u_int psycho_powerfail = 1; -SYSCTL_UINT(_hw_psycho, OID_AUTO, powerfail, CTLFLAG_RDTUN, &psycho_powerfail, - 0, "powerfail action (0: none, 1: shutdown (default), 2: debugger)"); - -static SLIST_HEAD(, psycho_softc) psycho_softcs = - SLIST_HEAD_INITIALIZER(psycho_softcs); - -static const struct intr_controller psycho_ic = { - psycho_intr_enable, - psycho_intr_disable, - psycho_intr_assign, - psycho_intr_clear -}; - -struct psycho_icarg { - struct psycho_softc *pica_sc; - bus_addr_t pica_map; - bus_addr_t pica_clr; -}; - -#define PSYCHO_READ8(sc, off) \ - bus_read_8((sc)->sc_mem_res, (off)) -#define PSYCHO_WRITE8(sc, off, v) \ - bus_write_8((sc)->sc_mem_res, (off), (v)) -#define PCICTL_READ8(sc, off) \ - PSYCHO_READ8((sc), (sc)->sc_pcictl + (off)) -#define PCICTL_WRITE8(sc, off, v) \ - PSYCHO_WRITE8((sc), (sc)->sc_pcictl + (off), (v)) - -/* - * "Sabre" is the UltraSPARC IIi onboard UPA to PCI bridge. It manages a - * single PCI bus and does not have a streaming buffer. It often has an APB - * (advanced PCI bridge) connected to it, which was designed specifically for - * the IIi. The APB lets the IIi handle two independent PCI buses, and - * appears as two "Simba"'s underneath the Sabre. - * - * "Hummingbird" is the UltraSPARC IIe onboard UPA to PCI bridge. It's - * basically the same as Sabre but without an APB underneath it. - * - * "Psycho" and "Psycho+" are dual UPA to PCI bridges. They sit on the UPA - * bus and manage two PCI buses. "Psycho" has two 64-bit 33MHz buses, while - * "Psycho+" controls both a 64-bit 33Mhz and a 64-bit 66Mhz PCI bus. You - * will usually find a "Psycho+" since I don't think the original "Psycho" - * ever shipped, and if it did it would be in the U30. - * - * Each "Psycho" PCI bus appears as a separate OFW node, but since they are - * both part of the same IC, they only have a single register space. As such, - * they need to be configured together, even though the autoconfiguration will - * attach them separately. - * - * On UltraIIi machines, "Sabre" itself usually takes pci0, with "Simba" often - * as pci1 and pci2, although they have been implemented with other PCI bus - * numbers on some machines. - * - * On UltraII machines, there can be any number of "Psycho+" ICs, each - * providing two PCI buses. - */ - -struct psycho_desc { - const char *pd_string; - int pd_mode; - const char *pd_name; -}; - -static const struct psycho_desc psycho_compats[] = { - { "pci108e,8000", PSYCHO_MODE_PSYCHO, "Psycho compatible" }, - { "pci108e,a000", PSYCHO_MODE_SABRE, "Sabre compatible" }, - { "pci108e,a001", PSYCHO_MODE_SABRE, "Hummingbird compatible" }, - { NULL, 0, NULL } -}; - -static const struct psycho_desc psycho_models[] = { - { "SUNW,psycho", PSYCHO_MODE_PSYCHO, "Psycho" }, - { "SUNW,sabre", PSYCHO_MODE_SABRE, "Sabre" }, - { NULL, 0, NULL } -}; - -static const struct psycho_desc * -psycho_find_desc(const struct psycho_desc *table, const char *string) -{ - const struct psycho_desc *desc; - - if (string == NULL) - return (NULL); - for (desc = table; desc->pd_string != NULL; desc++) - if (strcmp(desc->pd_string, string) == 0) - return (desc); - return (NULL); -} - -static const struct psycho_desc * -psycho_get_desc(device_t dev) -{ - const struct psycho_desc *rv; - - rv = psycho_find_desc(psycho_models, ofw_bus_get_model(dev)); - if (rv == NULL) - rv = psycho_find_desc(psycho_compats, - ofw_bus_get_compat(dev)); - return (rv); -} - -static int -psycho_probe(device_t dev) -{ - const char *dtype; - - dtype = ofw_bus_get_type(dev); - if (dtype != NULL && strcmp(dtype, OFW_TYPE_PCI) == 0 && - psycho_get_desc(dev) != NULL) { - device_set_desc(dev, "U2P UPA-PCI bridge"); - return (0); - } - return (ENXIO); -} - -static int -psycho_attach(device_t dev) -{ - struct psycho_icarg *pica; - struct psycho_softc *asc, *sc, *osc; - const struct psycho_desc *desc; - bus_addr_t intrclr, intrmap; - bus_dma_tag_t dmat; - uint64_t csr, dr; - phandle_t node; - uint32_t dvmabase, prop; - u_int rerun, ver; - int i, j; - - node = ofw_bus_get_node(dev); - sc = device_get_softc(dev); - desc = psycho_get_desc(dev); - - sc->sc_dev = dev; - sc->sc_mode = desc->pd_mode; - - /* - * The Psycho gets three register banks: - * (0) per-PBM configuration and status registers - * (1) per-PBM PCI configuration space, containing only the - * PBM 256-byte PCI header - * (2) the shared Psycho configuration registers - */ - if (sc->sc_mode == PSYCHO_MODE_PSYCHO) { - i = 2; - sc->sc_pcictl = - bus_get_resource_start(dev, SYS_RES_MEMORY, 0) - - bus_get_resource_start(dev, SYS_RES_MEMORY, 2); - switch (sc->sc_pcictl) { - case PSR_PCICTL0: - sc->sc_half = 0; - break; - case PSR_PCICTL1: - sc->sc_half = 1; - break; - default: - panic("%s: bogus PCI control register location", - __func__); - /* NOTREACHED */ - } - } else { - i = 0; - sc->sc_pcictl = PSR_PCICTL0; - sc->sc_half = 0; - } - sc->sc_mem_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &i, - (sc->sc_mode == PSYCHO_MODE_PSYCHO ? RF_SHAREABLE : 0) | - RF_ACTIVE); - if (sc->sc_mem_res == NULL) - panic("%s: could not allocate registers", __func__); - - /* - * Match other Psychos that are already configured against - * the base physical address. This will be the same for a - * pair of devices that share register space. - */ - osc = NULL; - SLIST_FOREACH(asc, &psycho_softcs, sc_link) { - if (rman_get_start(asc->sc_mem_res) == - rman_get_start(sc->sc_mem_res)) { - /* Found partner. */ - osc = asc; - break; - } - } - if (osc == NULL) { - sc->sc_mtx = malloc(sizeof(*sc->sc_mtx), M_DEVBUF, - M_NOWAIT | M_ZERO); - if (sc->sc_mtx == NULL) - panic("%s: could not malloc mutex", __func__); - mtx_init(sc->sc_mtx, "pcib_mtx", NULL, MTX_SPIN); - } else { - if (sc->sc_mode != PSYCHO_MODE_PSYCHO) - panic("%s: no partner expected", __func__); - if (mtx_initialized(osc->sc_mtx) == 0) - panic("%s: mutex not initialized", __func__); - sc->sc_mtx = osc->sc_mtx; - } - SLIST_INSERT_HEAD(&psycho_softcs, sc, sc_link); - - csr = PSYCHO_READ8(sc, PSR_CS); - ver = PSYCHO_GCSR_VERS(csr); - sc->sc_ign = 0x1f; /* Hummingbird/Sabre IGN is always 0x1f. */ - if (sc->sc_mode == PSYCHO_MODE_PSYCHO) - sc->sc_ign = PSYCHO_GCSR_IGN(csr); - if (OF_getprop(node, "clock-frequency", &prop, sizeof(prop)) == -1) - prop = 33000000; - - device_printf(dev, - "%s, impl %d, version %d, IGN %#x, bus %c, %dMHz\n", - desc->pd_name, (u_int)PSYCHO_GCSR_IMPL(csr), ver, sc->sc_ign, - 'A' + sc->sc_half, prop / 1000 / 1000); - - /* Set up the PCI control and PCI diagnostic registers. */ - - csr = PCICTL_READ8(sc, PCR_CS); - csr &= ~PCICTL_ARB_PARK; - if (OF_getproplen(node, "no-bus-parking") < 0) - csr |= PCICTL_ARB_PARK; - - /* Workarounds for version specific bugs. */ - dr = PCICTL_READ8(sc, PCR_DIAG); - switch (ver) { - case 0: - dr |= DIAG_RTRY_DIS; - dr &= ~DIAG_DWSYNC_DIS; - rerun = 0; - break; - case 1: - csr &= ~PCICTL_ARB_PARK; - dr |= DIAG_RTRY_DIS | DIAG_DWSYNC_DIS; - rerun = 0; - break; - default: - dr |= DIAG_DWSYNC_DIS; - dr &= ~DIAG_RTRY_DIS; - rerun = 1; - break; - } - - csr |= PCICTL_ERRINTEN | PCICTL_ARB_4; - csr &= ~(PCICTL_SBHINTEN | PCICTL_WAKEUPEN); -#ifdef PSYCHO_DEBUG - device_printf(dev, "PCI CSR 0x%016llx -> 0x%016llx\n", - (unsigned long long)PCICTL_READ8(sc, PCR_CS), - (unsigned long long)csr); -#endif - PCICTL_WRITE8(sc, PCR_CS, csr); - - dr &= ~DIAG_ISYNC_DIS; -#ifdef PSYCHO_DEBUG - device_printf(dev, "PCI DR 0x%016llx -> 0x%016llx\n", - (unsigned long long)PCICTL_READ8(sc, PCR_DIAG), - (unsigned long long)dr); -#endif - PCICTL_WRITE8(sc, PCR_DIAG, dr); - - if (sc->sc_mode == PSYCHO_MODE_SABRE) { - /* Use the PROM preset for now. */ - csr = PCICTL_READ8(sc, PCR_TAS); - if (csr == 0) - panic("%s: Hummingbird/Sabre TAS not initialized.", - __func__); - dvmabase = (ffs(csr) - 1) << PCITAS_ADDR_SHIFT; - } else - dvmabase = -1; - - /* - * If we're a Hummingbird/Sabre or the first of a pair of Psychos - * to arrive here, do the interrupt setup and start up the IOMMU. - */ - if (osc == NULL) { - /* - * Hunt through all the interrupt mapping regs and register - * our interrupt controller for the corresponding interrupt - * vectors. We do this early in order to be able to catch - * stray interrupts. - */ - for (i = 0; i <= PSYCHO_MAX_INO; i++) { - if (psycho_find_intrmap(sc, i, &intrmap, &intrclr, - NULL) == 0) - continue; - pica = malloc(sizeof(*pica), M_DEVBUF, M_NOWAIT); - if (pica == NULL) - panic("%s: could not allocate interrupt " - "controller argument", __func__); - pica->pica_sc = sc; - pica->pica_map = intrmap; - pica->pica_clr = intrclr; -#ifdef PSYCHO_DEBUG - /* - * Enable all interrupts and clear all interrupt - * states. This aids the debugging of interrupt - * routing problems. - */ - device_printf(dev, - "intr map (INO %d, %s) %#lx: %#lx, clr: %#lx\n", - i, intrmap <= PSR_PCIB3_INT_MAP ? "PCI" : "OBIO", - (u_long)intrmap, (u_long)PSYCHO_READ8(sc, - intrmap), (u_long)intrclr); - PSYCHO_WRITE8(sc, intrmap, INTMAP_VEC(sc->sc_ign, i)); - PSYCHO_WRITE8(sc, intrclr, INTCLR_IDLE); - PSYCHO_WRITE8(sc, intrmap, - INTMAP_ENABLE(INTMAP_VEC(sc->sc_ign, i), - PCPU_GET(mid))); -#endif - j = intr_controller_register(INTMAP_VEC(sc->sc_ign, - i), &psycho_ic, pica); - if (j != 0) - device_printf(dev, "could not register " - "interrupt controller for INO %d (%d)\n", - i, j); - } - - if (sc->sc_mode == PSYCHO_MODE_PSYCHO) - sparc64_counter_init(device_get_nameunit(dev), - rman_get_bustag(sc->sc_mem_res), - rman_get_bushandle(sc->sc_mem_res), PSR_TC0); - - /* - * Set up IOMMU and PCI configuration if we're the first - * of a pair of Psychos to arrive here or a Hummingbird - * or Sabre. - * - * We should calculate a TSB size based on amount of RAM - * and number of bus controllers and number and type of - * child devices. - * - * For the moment, 32KB should be more than enough. - */ - sc->sc_is = malloc(sizeof(*sc->sc_is), M_DEVBUF, M_NOWAIT | - M_ZERO); - if (sc->sc_is == NULL) - panic("%s: could not malloc IOMMU state", __func__); - sc->sc_is->is_flags = IOMMU_PRESERVE_PROM; - if (sc->sc_mode == PSYCHO_MODE_SABRE) { - sc->sc_dma_methods = - malloc(sizeof(*sc->sc_dma_methods), M_DEVBUF, - M_NOWAIT); - if (sc->sc_dma_methods == NULL) - panic("%s: could not malloc DMA methods", - __func__); - memcpy(sc->sc_dma_methods, &iommu_dma_methods, - sizeof(*sc->sc_dma_methods)); - sc->sc_dma_methods->dm_dmamap_sync = - sabre_dmamap_sync; - sc->sc_is->is_pmaxaddr = - IOMMU_MAXADDR(SABRE_IOMMU_BITS); - } else { - sc->sc_dma_methods = &iommu_dma_methods; - sc->sc_is->is_pmaxaddr = - IOMMU_MAXADDR(PSYCHO_IOMMU_BITS); - } - sc->sc_is->is_sb[0] = sc->sc_is->is_sb[1] = 0; - if (OF_getproplen(node, "no-streaming-cache") < 0) - sc->sc_is->is_sb[0] = sc->sc_pcictl + PCR_STRBUF; - sc->sc_is->is_flags |= (rerun != 1) ? IOMMU_RERUN_DISABLE : 0; - psycho_iommu_init(sc, 3, dvmabase); - } else { - /* Just copy IOMMU state, config tag and address. */ - sc->sc_dma_methods = &iommu_dma_methods; - sc->sc_is = osc->sc_is; - if (OF_getproplen(node, "no-streaming-cache") < 0) - sc->sc_is->is_sb[1] = sc->sc_pcictl + PCR_STRBUF; - iommu_reset(sc->sc_is); - } - - /* Create our DMA tag. */ - if (bus_dma_tag_create(bus_get_dma_tag(dev), 8, 0, - sc->sc_is->is_pmaxaddr, ~0, NULL, NULL, sc->sc_is->is_pmaxaddr, - 0xff, 0xffffffff, 0, NULL, NULL, &dmat) != 0) - panic("%s: could not create PCI DMA tag", __func__); - dmat->dt_cookie = sc->sc_is; - dmat->dt_mt = sc->sc_dma_methods; - - if (ofw_pci_attach_common(dev, dmat, PSYCHO_IO_SIZE, - PSYCHO_MEM_SIZE) != 0) - panic("%s: ofw_pci_attach_common() failed", __func__); - - /* Clear any pending PCI error bits. */ - PCIB_WRITE_CONFIG(dev, sc->sc_ops.sc_pci_secbus, PCS_DEVICE, PCS_FUNC, - PCIR_STATUS, PCIB_READ_CONFIG(dev, sc->sc_ops.sc_pci_secbus, - PCS_DEVICE, PCS_FUNC, PCIR_STATUS, 2), 2); - PCICTL_WRITE8(sc, PCR_CS, PCICTL_READ8(sc, PCR_CS)); - PCICTL_WRITE8(sc, PCR_AFS, PCICTL_READ8(sc, PCR_AFS)); - - if (osc == NULL) { - /* - * Establish handlers for interesting interrupts... - * - * XXX We need to remember these and remove this to support - * hotplug on the UPA/FHC bus. - * - * XXX Not all controllers have these, but installing them - * is better than trying to sort through this mess. - */ - psycho_set_intr(sc, 1, PSR_UE_INT_MAP, psycho_ue, NULL); - psycho_set_intr(sc, 2, PSR_CE_INT_MAP, psycho_ce, NULL); - switch (psycho_powerfail) { - case 0: - break; - case 2: - psycho_set_intr(sc, 3, PSR_POWER_INT_MAP, - psycho_powerdebug, NULL); - break; - default: - psycho_set_intr(sc, 3, PSR_POWER_INT_MAP, NULL, - psycho_powerdown); - break; - } - if (sc->sc_mode == PSYCHO_MODE_PSYCHO) { - /* - * Hummingbirds/Sabres do not have the following two - * interrupts. - */ - - /* - * The spare hardware interrupt is used for the - * over-temperature interrupt. - */ - psycho_set_intr(sc, 4, PSR_SPARE_INT_MAP, NULL, - psycho_overtemp); -#ifdef PSYCHO_MAP_WAKEUP - /* - * psycho_wakeup() doesn't do anything useful right - * now. - */ - psycho_set_intr(sc, 5, PSR_PWRMGT_INT_MAP, - psycho_wakeup, NULL); -#endif /* PSYCHO_MAP_WAKEUP */ - } - } - /* - * Register a PCI bus error interrupt handler according to which - * half this is. Hummingbird/Sabre don't have a PCI bus B error - * interrupt but they are also only used for PCI bus A. - */ - psycho_set_intr(sc, 0, sc->sc_half == 0 ? PSR_PCIAERR_INT_MAP : - PSR_PCIBERR_INT_MAP, psycho_pci_bus, NULL); - - /* - * Set the latency timer register as this isn't always done by the - * firmware. - */ - PCIB_WRITE_CONFIG(dev, sc->sc_ops.sc_pci_secbus, PCS_DEVICE, PCS_FUNC, - PCIR_LATTIMER, OFW_PCI_LATENCY, 1); - - for (i = PCIR_VENDOR; i < PCIR_STATUS; i += sizeof(uint16_t)) - le16enc(&sc->sc_pci_hpbcfg[i], - bus_space_read_2(sc->sc_ops.sc_pci_cfgt, - sc->sc_ops.sc_pci_bh[OFW_PCI_CS_CONFIG], - PSYCHO_CONF_OFF(sc->sc_ops.sc_pci_secbus, PCS_DEVICE, - PCS_FUNC, i))); - for (i = PCIR_REVID; i <= PCIR_BIST; i += sizeof(uint8_t)) - sc->sc_pci_hpbcfg[i] = bus_space_read_1(sc->sc_ops.sc_pci_cfgt, - sc->sc_ops.sc_pci_bh[OFW_PCI_CS_CONFIG], PSYCHO_CONF_OFF( - sc->sc_ops.sc_pci_secbus, PCS_DEVICE, PCS_FUNC, i)); - - /* - * On E250 the interrupt map entry for the EBus bridge is wrong, - * causing incorrect interrupts to be assigned to some devices on - * the EBus. Work around it by changing our copy of the interrupt - * map mask to perform a full comparison of the INO. That way - * the interrupt map entry for the EBus bridge won't match at all - * and the INOs specified in the "interrupts" properties of the - * EBus devices will be used directly instead. - */ - if (strcmp(sparc64_model, "SUNW,Ultra-250") == 0 && - sc->sc_ops.sc_pci_iinfo.opi_imapmsk != NULL) - *(ofw_pci_intr_t *)(&sc->sc_ops.sc_pci_iinfo.opi_imapmsk[ - sc->sc_ops.sc_pci_iinfo.opi_addrc]) = INTMAP_INO_MASK; - - device_add_child(dev, "pci", -1); - return (bus_generic_attach(dev)); -} - -static void -psycho_set_intr(struct psycho_softc *sc, u_int index, bus_addr_t intrmap, - driver_filter_t filt, driver_intr_t intr) -{ - u_long vec; - int rid; - - rid = index; - sc->sc_irq_res[index] = bus_alloc_resource_any(sc->sc_dev, - SYS_RES_IRQ, &rid, RF_ACTIVE); - if (sc->sc_irq_res[index] == NULL && intrmap >= PSR_POWER_INT_MAP) { - /* - * These interrupts aren't mandatory and not available - * with all controllers (not even Psychos). - */ - return; - } - if (sc->sc_irq_res[index] == NULL || - INTIGN(vec = rman_get_start(sc->sc_irq_res[index])) != - sc->sc_ign || - INTVEC(PSYCHO_READ8(sc, intrmap)) != vec || - intr_vectors[vec].iv_ic != &psycho_ic || - bus_setup_intr(sc->sc_dev, sc->sc_irq_res[index], - INTR_TYPE_MISC | INTR_BRIDGE | INTR_MPSAFE, filt, intr, sc, - &sc->sc_ihand[index]) != 0) - panic("%s: failed to set up interrupt %d", __func__, index); -} - -static int -psycho_find_intrmap(struct psycho_softc *sc, u_int ino, - bus_addr_t *intrmapptr, bus_addr_t *intrclrptr, bus_addr_t *intrdiagptr) -{ - bus_addr_t intrclr, intrmap; - uint64_t diag; - int found; - - /* - * XXX we only compare INOs rather than INRs since the firmware may - * not provide the IGN and the IGN is constant for all devices on - * that PCI controller. - * This could cause problems for the FFB/external interrupt which - * has a full vector that can be set arbitrarily. - */ - - if (ino > PSYCHO_MAX_INO) { - device_printf(sc->sc_dev, "out of range INO %d requested\n", - ino); - return (0); - } - - found = 0; - /* Hunt through OBIO first. */ - diag = PSYCHO_READ8(sc, PSR_OBIO_INT_DIAG); - for (intrmap = PSR_SCSI_INT_MAP, intrclr = PSR_SCSI_INT_CLR; - intrmap <= PSR_PWRMGT_INT_MAP; intrmap += 8, intrclr += 8, - diag >>= 2) { - if (sc->sc_mode == PSYCHO_MODE_SABRE && - (intrmap == PSR_TIMER0_INT_MAP || - intrmap == PSR_TIMER1_INT_MAP || - intrmap == PSR_PCIBERR_INT_MAP || - intrmap == PSR_PWRMGT_INT_MAP)) - continue; - if (INTINO(PSYCHO_READ8(sc, intrmap)) == ino) { - diag &= 2; - found = 1; - break; - } - } - - if (!found) { - diag = PSYCHO_READ8(sc, PSR_PCI_INT_DIAG); - /* Now do PCI interrupts. */ - for (intrmap = PSR_PCIA0_INT_MAP, intrclr = PSR_PCIA0_INT_CLR; - intrmap <= PSR_PCIB3_INT_MAP; intrmap += 8, intrclr += 32, - diag >>= 8) { - if (sc->sc_mode == PSYCHO_MODE_PSYCHO && - (intrmap == PSR_PCIA2_INT_MAP || - intrmap == PSR_PCIA3_INT_MAP)) - continue; - if (((PSYCHO_READ8(sc, intrmap) ^ ino) & 0x3c) == 0) { - intrclr += 8 * (ino & 3); - diag = (diag >> ((ino & 3) * 2)) & 2; - found = 1; - break; - } - } - } - if (intrmapptr != NULL) - *intrmapptr = intrmap; - if (intrclrptr != NULL) - *intrclrptr = intrclr; - if (intrdiagptr != NULL) - *intrdiagptr = diag; - return (found); -} - -/* - * Interrupt handlers - */ -static int -psycho_ue(void *arg) -{ - struct psycho_softc *sc = arg; - uint64_t afar, afsr; - - afar = PSYCHO_READ8(sc, PSR_UE_AFA); - afsr = PSYCHO_READ8(sc, PSR_UE_AFS); - /* - * On the UltraSPARC-IIi/IIe, IOMMU misses/protection faults cause - * the AFAR to be set to the physical address of the TTE entry that - * was invalid/write protected. Call into the IOMMU code to have - * them decoded to virtual I/O addresses. - */ - if ((afsr & UEAFSR_P_DTE) != 0) - iommu_decode_fault(sc->sc_is, afar); - panic("%s: uncorrectable DMA error AFAR %#lx AFSR %#lx", - device_get_nameunit(sc->sc_dev), (u_long)afar, (u_long)afsr); - return (FILTER_HANDLED); -} - -static int -psycho_ce(void *arg) -{ - struct psycho_softc *sc = arg; - uint64_t afar, afsr; - - mtx_lock_spin(sc->sc_mtx); - afar = PSYCHO_READ8(sc, PSR_CE_AFA); - afsr = PSYCHO_READ8(sc, PSR_CE_AFS); - device_printf(sc->sc_dev, "correctable DMA error AFAR %#lx " - "AFSR %#lx\n", (u_long)afar, (u_long)afsr); - /* Clear the error bits that we caught. */ - PSYCHO_WRITE8(sc, PSR_CE_AFS, afsr); - mtx_unlock_spin(sc->sc_mtx); - return (FILTER_HANDLED); -} - -static int -psycho_pci_bus(void *arg) -{ - struct psycho_softc *sc = arg; - uint64_t afar, afsr; - - afar = PCICTL_READ8(sc, PCR_AFA); - afsr = PCICTL_READ8(sc, PCR_AFS); - panic("%s: PCI bus %c error AFAR %#lx AFSR %#lx", - device_get_nameunit(sc->sc_dev), 'A' + sc->sc_half, (u_long)afar, - (u_long)afsr); - return (FILTER_HANDLED); -} - -static int -psycho_powerdebug(void *arg __unused) -{ - - kdb_enter(KDB_WHY_POWERFAIL, "powerfail"); - return (FILTER_HANDLED); -} - -static void -psycho_powerdown(void *arg __unused) -{ - static int shutdown; - - /* As the interrupt is cleared we may be called multiple times. */ - if (shutdown != 0) - return; - shutdown++; - printf("Power Failure Detected: Shutting down NOW.\n"); - shutdown_nice(RB_POWEROFF); -} - -static void -psycho_overtemp(void *arg __unused) -{ - static int shutdown; - - /* As the interrupt is cleared we may be called multiple times. */ - if (shutdown != 0) - return; - shutdown++; - printf("DANGER: OVER TEMPERATURE detected.\nShutting down NOW.\n"); - shutdown_nice(RB_POWEROFF); -} - -#ifdef PSYCHO_MAP_WAKEUP -static int -psycho_wakeup(void *arg) -{ - struct psycho_softc *sc = arg; - - /* We don't really have a framework to deal with this properly. */ - device_printf(sc->sc_dev, "power management wakeup\n"); - return (FILTER_HANDLED); -} -#endif /* PSYCHO_MAP_WAKEUP */ - -static void -psycho_iommu_init(struct psycho_softc *sc, int tsbsize, uint32_t dvmabase) -{ - struct iommu_state *is = sc->sc_is; - - /* Punch in our copies. */ - is->is_bustag = rman_get_bustag(sc->sc_mem_res); - is->is_bushandle = rman_get_bushandle(sc->sc_mem_res); - is->is_iommu = PSR_IOMMU; - is->is_dtag = PSR_IOMMU_TLB_TAG_DIAG; - is->is_ddram = PSR_IOMMU_TLB_DATA_DIAG; - is->is_dqueue = PSR_IOMMU_QUEUE_DIAG; - is->is_dva = PSR_IOMMU_SVADIAG; - is->is_dtcmp = PSR_IOMMU_TLB_CMP_DIAG; - - iommu_init(device_get_nameunit(sc->sc_dev), is, tsbsize, dvmabase, 0); -} - -static int -psycho_maxslots(device_t dev) -{ - - /* XXX: is this correct? */ - return (PCI_SLOTMAX); -} - -static uint32_t -psycho_read_config(device_t dev, u_int bus, u_int slot, u_int func, u_int reg, - int width) -{ - struct psycho_softc *sc; - - sc = device_get_softc(dev); - /* - * The Hummingbird and Sabre bridges are picky in that they - * only allow their config space to be accessed using the - * "native" width of the respective register being accessed - * and return semi-random other content of their config space - * otherwise. Given that the PCI specs don't say anything - * about such a (unusual) limitation and lots of stuff expects - * to be able to access the contents of the config space at - * any width we allow just that. We do this by using a copy - * of the header of the bridge (the rest is all zero anyway) - * read during attach (expect for PCIR_STATUS) in order to - * simplify things. - * The Psycho bridges contain a dupe of their header at 0x80 - * which we nullify that way also. - */ - if (bus == sc->sc_ops.sc_pci_secbus && slot == PCS_DEVICE && - func == PCS_FUNC) { - if (reg % width != 0) - return (-1); - - if (reg >= sizeof(sc->sc_pci_hpbcfg)) - return (0); - - if ((reg < PCIR_STATUS && reg + width > PCIR_STATUS) || - reg == PCIR_STATUS || reg == PCIR_STATUS + 1) - le16enc(&sc->sc_pci_hpbcfg[PCIR_STATUS], - bus_space_read_2(sc->sc_ops.sc_pci_cfgt, - sc->sc_ops.sc_pci_bh[OFW_PCI_CS_CONFIG], - PSYCHO_CONF_OFF(sc->sc_ops.sc_pci_secbus, - PCS_DEVICE, PCS_FUNC, PCIR_STATUS))); - - switch (width) { - case 1: - return (sc->sc_pci_hpbcfg[reg]); - case 2: - return (le16dec(&sc->sc_pci_hpbcfg[reg])); - case 4: - return (le32dec(&sc->sc_pci_hpbcfg[reg])); - } - } - - return (ofw_pci_read_config_common(dev, PCI_REGMAX, - PSYCHO_CONF_OFF(bus, slot, func, reg), bus, slot, func, reg, - width)); -} - -static void -psycho_write_config(device_t dev, u_int bus, u_int slot, u_int func, - u_int reg, uint32_t val, int width) -{ - - ofw_pci_write_config_common(dev, PCI_REGMAX, PSYCHO_CONF_OFF(bus, - slot, func, reg), bus, slot, func, reg, val, width); -} - -static int -psycho_route_interrupt(device_t bridge, device_t dev, int pin) -{ - struct psycho_softc *sc; - bus_addr_t intrmap; - ofw_pci_intr_t mintr; - - mintr = ofw_pci_route_interrupt_common(bridge, dev, pin); - if (PCI_INTERRUPT_VALID(mintr)) - return (mintr); - /* - * If this is outside of the range for an intpin, it's likely a full - * INO, and no mapping is required at all; this happens on the U30, - * where there's no interrupt map at the Psycho node. Fortunately, - * there seem to be no INOs in the intpin range on this boxen, so - * this easy heuristics will do. - */ - if (pin > 4) - return (pin); - /* - * Guess the INO; we always assume that this is a non-OBIO device, - * and that pin is a "real" intpin number. Determine the mapping - * register to be used by the slot number. - * We only need to do this on E450s and U30s, though; here, the - * slot numbers for bus A are one-based, while those for bus B - * seemingly have an offset of 2 (hence the factor of 3 below). - */ - sc = device_get_softc(bridge); - intrmap = PSR_PCIA0_INT_MAP + - 8 * (pci_get_slot(dev) - 1 + 3 * sc->sc_half); - mintr = INTINO(PSYCHO_READ8(sc, intrmap)) + pin - 1; - device_printf(bridge, - "guessing interrupt %d for device %d.%d pin %d\n", - (int)mintr, pci_get_slot(dev), pci_get_function(dev), pin); - return (mintr); -} - -static void -sabre_dmamap_sync(bus_dma_tag_t dt, bus_dmamap_t map, bus_dmasync_op_t op) -{ - struct iommu_state *is = dt->dt_cookie; - - if ((map->dm_flags & DMF_LOADED) == 0) - return; - - if ((op & BUS_DMASYNC_POSTREAD) != 0) - (void)bus_space_read_8(is->is_bustag, is->is_bushandle, - PSR_DMA_WRITE_SYNC); - - if ((op & BUS_DMASYNC_PREWRITE) != 0) - membar(Sync); -} - -static void -psycho_intr_enable(void *arg) -{ - struct intr_vector *iv = arg; - struct psycho_icarg *pica = iv->iv_icarg; - - PSYCHO_WRITE8(pica->pica_sc, pica->pica_map, - INTMAP_ENABLE(iv->iv_vec, iv->iv_mid)); -} - -static void -psycho_intr_disable(void *arg) -{ - struct intr_vector *iv = arg; - struct psycho_icarg *pica = iv->iv_icarg; - - PSYCHO_WRITE8(pica->pica_sc, pica->pica_map, iv->iv_vec); -} - -static void -psycho_intr_assign(void *arg) -{ - struct intr_vector *iv = arg; - struct psycho_icarg *pica = iv->iv_icarg; - - PSYCHO_WRITE8(pica->pica_sc, pica->pica_map, INTMAP_TID( - PSYCHO_READ8(pica->pica_sc, pica->pica_map), iv->iv_mid)); -} - -static void -psycho_intr_clear(void *arg) -{ - struct intr_vector *iv = arg; - struct psycho_icarg *pica = iv->iv_icarg; - - PSYCHO_WRITE8(pica->pica_sc, pica->pica_clr, INTCLR_IDLE); -} - -static int -psycho_setup_intr(device_t dev, device_t child, struct resource *ires, - int flags, driver_filter_t *filt, driver_intr_t *intr, void *arg, - void **cookiep) -{ - struct psycho_softc *sc; - u_long vec; - - sc = device_get_softc(dev); - /* - * Make sure the vector is fully specified and we registered - * our interrupt controller for it. - */ - vec = rman_get_start(ires); - if (INTIGN(vec) != sc->sc_ign || - intr_vectors[vec].iv_ic != &psycho_ic) { - device_printf(dev, "invalid interrupt vector 0x%lx\n", vec); - return (EINVAL); - } - return (bus_generic_setup_intr(dev, child, ires, flags, filt, intr, - arg, cookiep)); -} - -static struct resource * -psycho_alloc_resource(device_t bus, device_t child, int type, int *rid, - rman_res_t start, rman_res_t end, rman_res_t count, u_int flags) -{ - struct psycho_softc *sc; - - if (type == SYS_RES_IRQ) { - sc = device_get_softc(bus); - start = end = INTMAP_VEC(sc->sc_ign, end); - } - return (ofw_pci_alloc_resource(bus, child, type, rid, start, end, - count, flags)); -} - -static void -psycho_setup_device(device_t bus, device_t child) -{ - struct psycho_softc *sc; - uint32_t rev; - - sc = device_get_softc(bus); - /* - * Revision 0 EBus bridges have a bug which prevents them from - * working when bus parking is enabled. - */ - if ((strcmp(ofw_bus_get_name(child), "ebus") == 0 || - strcmp(ofw_bus_get_name(child), "pci108e,1000") == 0) && - OF_getprop(ofw_bus_get_node(child), "revision-id", &rev, - sizeof(rev)) > 0 && rev == 0) - PCICTL_WRITE8(sc, PCR_CS, PCICTL_READ8(sc, PCR_CS) & - ~PCICTL_ARB_PARK); -} diff --git a/sys/sparc64/pci/psychoreg.h b/sys/sparc64/pci/psychoreg.h deleted file mode 100644 index ec7fe29aa1b0..000000000000 --- a/sys/sparc64/pci/psychoreg.h +++ /dev/null @@ -1,330 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-3-Clause - * - * Copyright (c) 1999 Matthew R. Green - * 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. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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. - */ - -/*- - * Copyright (c) 1998, 1999 Eduardo E. Horvath - * 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. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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. - * - * from: NetBSD: psychoreg.h,v 1.14 2008/05/30 02:29:37 mrg Exp - * - * $FreeBSD$ - */ - -#ifndef _SPARC64_PCI_PSYCHOREG_H_ -#define _SPARC64_PCI_PSYCHOREG_H_ - -/* - * Sun4u PCI definitions. Here's where we deal w/the machine - * dependencies of Psycho and the PCI controller on the UltraIIi. - * - * All PCI registers are bit-swapped, however they are not byte-swapped. - * This means that they must be accessed using little-endian access modes, - * either map the pages little-endian or use little-endian ASIs. - * - * PSYCHO implements two PCI buses, A and B. - */ - -#define PSYCHO_NINTR 6 - -/* - * Psycho register offsets - * - * NB: FFB0 and FFB1 intr map regs also appear at 0x6000 and 0x8000 - * respectively. - */ -#define PSR_UPA_PORTID 0x0000 /* UPA port ID register */ -#define PSR_UPA_CONFIG 0x0008 /* UPA config register */ -#define PSR_CS 0x0010 /* PSYCHO control/status register */ -#define PSR_ECCC 0x0020 /* ECC control register */ -#define PSR_UE_AFS 0x0030 /* Uncorrectable Error AFSR */ -#define PSR_UE_AFA 0x0038 /* Uncorrectable Error AFAR */ -#define PSR_CE_AFS 0x0040 /* Correctable Error AFSR */ -#define PSR_CE_AFA 0x0048 /* Correctable Error AFAR */ -#define PSR_PM_CTL 0x0100 /* Performance monitor control reg */ -#define PSR_PM_COUNT 0x0108 /* Performance monitor counter reg */ -#define PSR_IOMMU 0x0200 /* IOMMU registers */ -#define PSR_PCIA0_INT_MAP 0x0c00 /* PCI bus a slot 0 irq map reg */ -#define PSR_PCIA1_INT_MAP 0x0c08 /* PCI bus a slot 1 irq map reg */ -#define PSR_PCIA2_INT_MAP 0x0c10 /* PCI bus a slot 2 irq map reg (IIi) */ -#define PSR_PCIA3_INT_MAP 0x0c18 /* PCI bus a slot 3 irq map reg (IIi) */ -#define PSR_PCIB0_INT_MAP 0x0c20 /* PCI bus b slot 0 irq map reg */ -#define PSR_PCIB1_INT_MAP 0x0c28 /* PCI bus b slot 1 irq map reg */ -#define PSR_PCIB2_INT_MAP 0x0c30 /* PCI bus b slot 2 irq map reg */ -#define PSR_PCIB3_INT_MAP 0x0c38 /* PCI bus b slot 3 irq map reg */ -#define PSR_SCSI_INT_MAP 0x1000 /* SCSI interrupt map reg */ -#define PSR_ETHER_INT_MAP 0x1008 /* ethernet interrupt map reg */ -#define PSR_BPP_INT_MAP 0x1010 /* parallel interrupt map reg */ -#define PSR_AUDIOR_INT_MAP 0x1018 /* audio record interrupt map reg */ -#define PSR_AUDIOP_INT_MAP 0x1020 /* audio playback interrupt map reg */ -#define PSR_POWER_INT_MAP 0x1028 /* power fail interrupt map reg */ -#define PSR_SKBDMS_INT_MAP 0x1030 /* serial/kbd/mouse interrupt map reg */ -#define PSR_FD_INT_MAP 0x1038 /* floppy interrupt map reg */ -#define PSR_SPARE_INT_MAP 0x1040 /* spare interrupt map reg */ -#define PSR_KBD_INT_MAP 0x1048 /* kbd [unused] interrupt map reg */ -#define PSR_MOUSE_INT_MAP 0x1050 /* mouse [unused] interrupt map reg */ -#define PSR_SERIAL_INT_MAP 0x1058 /* second serial interrupt map reg */ -#define PSR_TIMER0_INT_MAP 0x1060 /* timer 0 interrupt map reg */ -#define PSR_TIMER1_INT_MAP 0x1068 /* timer 1 interrupt map reg */ -#define PSR_UE_INT_MAP 0x1070 /* UE interrupt map reg */ -#define PSR_CE_INT_MAP 0x1078 /* CE interrupt map reg */ -#define PSR_PCIAERR_INT_MAP 0x1080 /* PCI bus a error interrupt map reg */ -#define PSR_PCIBERR_INT_MAP 0x1088 /* PCI bus b error interrupt map reg */ -#define PSR_PWRMGT_INT_MAP 0x1090 /* power mgmt wake interrupt map reg */ -#define PSR_FFB0_INT_MAP 0x1098 /* FFB0 graphics interrupt map reg */ -#define PSR_FFB1_INT_MAP 0x10a0 /* FFB1 graphics interrupt map reg */ -/* Note: Clear interrupt 0 registers are not really used. */ -#define PSR_PCIA0_INT_CLR 0x1400 /* PCI a slot 0 clear int regs 0..3 */ -#define PSR_PCIA1_INT_CLR 0x1420 /* PCI a slot 1 clear int regs 0..3 */ -#define PSR_PCIA2_INT_CLR 0x1440 /* PCI a slot 2 clear int regs 0..3 */ -#define PSR_PCIA3_INT_CLR 0x1460 /* PCI a slot 3 clear int regs 0..3 */ -#define PSR_PCIB0_INT_CLR 0x1480 /* PCI b slot 0 clear int regs 0..3 */ -#define PSR_PCIB1_INT_CLR 0x14a0 /* PCI b slot 1 clear int regs 0..3 */ -#define PSR_PCIB2_INT_CLR 0x14c0 /* PCI b slot 2 clear int regs 0..3 */ -#define PSR_PCIB3_INT_CLR 0x14d0 /* PCI b slot 3 clear int regs 0..3 */ -#define PSR_SCSI_INT_CLR 0x1800 /* SCSI clear int reg */ -#define PSR_ETHER_INT_CLR 0x1808 /* ethernet clear int reg */ -#define PSR_BPP_INT_CLR 0x1810 /* parallel clear int reg */ -#define PSR_AUDIOR_INT_CLR 0x1818 /* audio record clear int reg */ -#define PSR_AUDIOP_INT_CLR 0x1820 /* audio playback clear int reg */ -#define PSR_POWER_INT_CLR 0x1828 /* power fail clear int reg */ -#define PSR_SKBDMS_INT_CLR 0x1830 /* serial/kbd/mouse clear int reg */ -#define PSR_FD_INT_CLR 0x1838 /* floppy clear int reg */ -#define PSR_SPARE_INT_CLR 0x1840 /* spare clear int reg */ -#define PSR_KBD_INT_CLR 0x1848 /* kbd [unused] clear int reg */ -#define PSR_MOUSE_INT_CLR 0x1850 /* mouse [unused] clear int reg */ -#define PSR_SERIAL_INT_CLR 0x1858 /* second serial clear int reg */ -#define PSR_TIMER0_INT_CLR 0x1860 /* timer 0 clear int reg */ -#define PSR_TIMER1_INT_CLR 0x1868 /* timer 1 clear int reg */ -#define PSR_UE_INT_CLR 0x1870 /* UE clear int reg */ -#define PSR_CE_INT_CLR 0x1878 /* CE clear int reg */ -#define PSR_PCIAERR_INT_CLR 0x1880 /* PCI bus a error clear int reg */ -#define PSR_PCIBERR_INT_CLR 0x1888 /* PCI bus b error clear int reg */ -#define PSR_PWRMGT_INT_CLR 0x1890 /* power mgmt wake clr interrupt reg */ -#define PSR_INTR_RETRY_TIM 0x1a00 /* interrupt retry timer */ -#define PSR_TC0 0x1c00 /* timer/counter 0 */ -#define PSR_TC1 0x1c10 /* timer/counter 1 */ -#define PSR_DMA_WRITE_SYNC 0x1c20 /* PCI DMA write sync register (IIi) */ -#define PSR_PCICTL0 0x2000 /* PCICTL registers for 1st Psycho */ -#define PSR_PCICTL1 0x4000 /* PCICTL registers for 2nd Psycho */ -#define PSR_DMA_SCB_DIAG0 0xa000 /* DMA scoreboard diag reg 0 */ -#define PSR_DMA_SCB_DIAG1 0xa008 /* DMA scoreboard diag reg 1 */ -#define PSR_IOMMU_SVADIAG 0xa400 /* IOMMU virtual addr diag reg */ -#define PSR_IOMMU_TLB_CMP_DIAG 0xa408 /* IOMMU TLB tag compare diag reg */ -#define PSR_IOMMU_QUEUE_DIAG 0xa500 /* IOMMU LRU queue diag regs 0..15 */ -#define PSR_IOMMU_TLB_TAG_DIAG 0xa580 /* TLB tag diag regs 0..15 */ -#define PSR_IOMMU_TLB_DATA_DIAG 0xa600 /* TLB data RAM diag regs 0..15 */ -#define PSR_PCI_INT_DIAG 0xa800 /* PCI int state diag reg */ -#define PSR_OBIO_INT_DIAG 0xa808 /* OBIO and misc int state diag reg */ -#define PSR_STRBUF_DIAG 0xb000 /* Streaming buffer diag regs */ - -/* - * Here is the rest of the map, which we're not specifying: - * - * 1fe.0100.0000 - 1fe.01ff.ffff PCI configuration space - * 1fe.0100.0000 - 1fe.0100.00ff PCI B configuration header - * 1fe.0101.0000 - 1fe.0101.00ff PCI A configuration header - * 1fe.0200.0000 - 1fe.0200.ffff PCI A I/O space - * 1fe.0201.0000 - 1fe.0201.ffff PCI B I/O space - * 1ff.0000.0000 - 1ff.7fff.ffff PCI A memory space - * 1ff.8000.0000 - 1ff.ffff.ffff PCI B memory space - * - * NB: Config and I/O space can use 1-4 byte accesses, not 8 byte - * accesses. Memory space can use any sized accesses. - * - * Note that the SUNW,sabre/SUNW,simba combinations found on the - * Ultra5 and Ultra10 machines uses slightly differrent addresses - * than the above. This is mostly due to the fact that the APB is - * a multi-function PCI device with two PCI bridges, and the U2P is - * two separate PCI bridges. It uses the same PCI configuration - * space, though the configuration header for each PCI bus is - * located differently due to the SUNW,simba PCI busses being - * function 0 and function 1 of the APB, whereas the Psycho's are - * each their own PCI device. The I/O and memory spaces are each - * split into 8 equally sized areas (8x2MB blocks for I/O space, - * and 8x512MB blocks for memory space). These are allocated in to - * either PCI A or PCI B, or neither in the APB's `I/O Address Map - * Register A/B' (0xde) and `Memory Address Map Register A/B' (0xdf) - * registers of each Simba. We must ensure that both of the - * following are correct (the prom should do this for us): - * - * (PCI A Memory Address Map) & (PCI B Memory Address Map) == 0 - * - * (PCI A I/O Address Map) & (PCI B I/O Address Map) == 0 - * - * 1fe.0100.0000 - 1fe.01ff.ffff PCI configuration space - * 1fe.0100.0800 - 1fe.0100.08ff PCI B configuration header - * 1fe.0100.0900 - 1fe.0100.09ff PCI A configuration header - * 1fe.0200.0000 - 1fe.02ff.ffff PCI I/O space (divided) - * 1ff.0000.0000 - 1ff.ffff.ffff PCI memory space (divided) - */ - -/* - * PSR_CS defines: - * - * 63 59 55 50 45 4 3 2 1 0 - * +------+------+------+------+--//---+--------+-------+-----+------+ - * | IMPL | VERS | MID | IGN | xxx | APCKEN | APERR | IAP | MODE | - * +------+------+------+------+--//---+--------+-------+-----+------+ - * - */ -#define PSYCHO_GCSR_IMPL(csr) ((u_int)(((csr) >> 60) & 0xf)) -#define PSYCHO_GCSR_VERS(csr) ((u_int)(((csr) >> 56) & 0xf)) -#define PSYCHO_GCSR_MID(csr) ((u_int)(((csr) >> 51) & 0x1f)) -#define PSYCHO_GCSR_IGN(csr) ((u_int)(((csr) >> 46) & 0x1f)) -#define PSYCHO_CSR_APCKEN 8 /* UPA addr parity check enable */ -#define PSYCHO_CSR_APERR 4 /* UPA addr parity error */ -#define PSYCHO_CSR_IAP 2 /* invert UPA address parity */ -#define PSYCHO_CSR_MODE 1 /* UPA/PCI handshake */ - -/* Offsets into the PSR_PCICTL* register block */ -#define PCR_CS 0x0000 /* PCI control/status register */ -#define PCR_AFS 0x0010 /* PCI AFSR register */ -#define PCR_AFA 0x0018 /* PCI AFAR register */ -#define PCR_DIAG 0x0020 /* PCI diagnostic register */ -#define PCR_TAS 0x0028 /* PCI target address space reg (IIi) */ -#define PCR_STRBUF 0x0800 /* IOMMU streaming buffer registers. */ - -/* INO defines */ -#define PSYCHO_MAX_INO 0x3f - -/* Device space defines */ -#define PSYCHO_CONF_SIZE 0x1000000 -#define PSYCHO_CONF_BUS_SHIFT 16 -#define PSYCHO_CONF_DEV_SHIFT 11 -#define PSYCHO_CONF_FUNC_SHIFT 8 -#define PSYCHO_CONF_REG_SHIFT 0 -#define PSYCHO_IO_SIZE 0x1000000 -#define PSYCHO_MEM_SIZE 0x100000000 - -#define PSYCHO_CONF_OFF(bus, slot, func, reg) \ - (((bus) << PSYCHO_CONF_BUS_SHIFT) | \ - ((slot) << PSYCHO_CONF_DEV_SHIFT) | \ - ((func) << PSYCHO_CONF_FUNC_SHIFT) | \ - ((reg) << PSYCHO_CONF_REG_SHIFT)) - -/* what the bits mean! */ - -/* - * PCI [a|b] control/status register - * Note that the Hummingbird/Sabre only has one set of PCI control/status - * registers. - */ -#define PCICTL_SBHERR 0x0000000800000000 /* strm. byte hole error; W1C */ -#define PCICTL_SERR 0x0000000400000000 /* SERR asserted; W1C */ -#define PCICTL_PCISPEED 0x0000000200000000 /* 0:half 1:full bus speed */ -#define PCICTL_ARB_PARK 0x0000000000200000 /* PCI arbitration parking */ -#define PCICTL_SBHINTEN 0x0000000000000400 /* strm. byte hole int. en. */ -#define PCICTL_WAKEUPEN 0x0000000000000200 /* power mgmt. wakeup enable */ -#define PCICTL_ERRINTEN 0x0000000000000100 /* PCI error interrupt enable */ -#define PCICTL_ARB_4 0x000000000000000f /* DVMA arb. 4 PCI slots mask */ -#define PCICTL_ARB_6 0x000000000000003f /* DVMA arb. 6 PCI slots mask */ -/* The following are Hummingbird/Sabre only. */ -#define PCICTL_MRLM 0x0000001000000000 /* Memory Read Line/Multiple */ -#define PCICTL_CPU_PRIO 0x0000000000100000 /* CPU extra arb. prio. en. */ -#define PCICTL_ARB_PRIO 0x00000000000f0000 /* PCI extra arb. prio. en. */ -#define PCICTL_RTRYWAIT 0x0000000000000080 /* 0:wait 1:retry DMA write */ - -/* Uncorrectable error asynchronous fault status register */ -#define UEAFSR_BLK (1UL << 23) /* Error caused by block transaction */ -#define UEAFSR_P_DTE (1UL << 56) /* Pri. DVMA translation error */ -#define UEAFSR_S_DTE (1UL << 57) /* Sec. DVMA translation error */ -#define UEAFSR_S_DWR (1UL << 58) /* Sec. error during DVMA write */ -#define UEAFSR_S_DRD (1UL << 59) /* Sec. error during DVMA read */ -#define UEAFSR_S_PIO (1UL << 60) /* Sec. error during PIO access */ -#define UEAFSR_P_DWR (1UL << 61) /* Pri. error during DVMA write */ -#define UEAFSR_P_DRD (1UL << 62) /* Pri. error during DVMA read */ -#define UEAFSR_P_PIO (1UL << 63) /* Pri. error during PIO access */ - -/* Correctable error asynchronous fault status register */ -#define CEAFSR_BLK (1UL << 23) /* Error caused by block transaction */ -#define CEAFSR_S_DWR (1UL << 58) /* Sec. error caused by DVMA write */ -#define CEAFSR_S_DRD (1UL << 59) /* Sec. error caused by DVMA read */ -#define CEAFSR_S_PIO (1UL << 60) /* Sec. error caused by PIO access */ -#define CEAFSR_P_DWR (1UL << 61) /* Pri. error caused by DVMA write */ -#define CEAFSR_P_DRD (1UL << 62) /* Pri. error caused by DVMA read */ -#define CEAFSR_P_PIO (1UL << 63) /* Pri. error caused by PIO access */ - -/* PCI asynchronous fault status register */ -#define PCIAFSR_P_MA (1UL << 63) /* Pri. master abort */ -#define PCIAFSR_P_TA (1UL << 62) /* Pri. target abort */ -#define PCIAFSR_P_RTRY (1UL << 61) /* Pri. excessive retries */ -#define PCIAFSR_P_RERR (1UL << 60) /* Pri. parity error */ -#define PCIAFSR_S_MA (1UL << 59) /* Sec. master abort */ -#define PCIAFSR_S_TA (1UL << 58) /* Sec. target abort */ -#define PCIAFSR_S_RTRY (1UL << 57) /* Sec. excessive retries */ -#define PCIAFSR_S_RERR (1UL << 56) /* Sec. parity error */ -#define PCIAFSR_BMASK (0xffffUL << 32)/* Bytemask of failed pri. transfer */ -#define PCIAFSR_BLK (1UL << 31) /* failed pri. transfer was block r/w */ -#define PCIAFSR_MID (0x3eUL << 25) /* UPA MID causing error transaction */ - -/* PCI diagnostic register */ -#define DIAG_RTRY_DIS 0x0000000000000040 /* dis. retry limit */ -#define DIAG_ISYNC_DIS 0x0000000000000020 /* dis. DMA write / int sync */ -#define DIAG_DWSYNC_DIS 0x0000000000000010 /* dis. DMA write / PIO sync */ - -/* Definitions for the target address space register */ -#define PCITAS_ADDR_SHIFT 29 - -/* Definitions for the Psycho configuration space */ -#define PCS_DEVICE 0 /* Device number of Psycho CS entry */ -#define PCS_FUNC 0 /* Function number of Psycho CS entry */ - -/* Non-Standard registers in the configration space */ -#define PCSR_SECBUS 0x40 /* Secondary bus number register */ -#define PCSR_SUBBUS 0x41 /* Subordinate bus number register */ - -/* Width of the physical addresses the IOMMU translates to */ -#define PSYCHO_IOMMU_BITS 41 -#define SABRE_IOMMU_BITS 34 - -#endif /* !_SPARC64_PCI_PSYCHOREG_H_ */ diff --git a/sys/sparc64/pci/psychovar.h b/sys/sparc64/pci/psychovar.h deleted file mode 100644 index 1b82136dfc24..000000000000 --- a/sys/sparc64/pci/psychovar.h +++ /dev/null @@ -1,75 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause-NetBSD - * - * Copyright (c) 1999, 2000 Matthew R. Green - * 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 ``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 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. - * - * from: NetBSD: psychovar.h,v 1.15 2008/05/29 14:51:26 mrg Exp - * - * $FreeBSD$ - */ - -#ifndef _SPARC64_PCI_PSYCHOVAR_H_ -#define _SPARC64_PCI_PSYCHOVAR_H_ - -/* - * Per-PCI bus on mainbus softc structure; one for sabre, or two - * per pair of psychos. - */ -struct psycho_softc { - /* - * This is here so that we can hook up the common bus interface - * methods in ofw_pci.c directly. - */ - struct ofw_pci_softc sc_ops; - - struct iommu_state *sc_is; - struct bus_dma_methods *sc_dma_methods; - - struct mtx *sc_mtx; - - struct resource *sc_mem_res; - struct resource *sc_irq_res[PSYCHO_NINTR]; - void *sc_ihand[PSYCHO_NINTR]; - - uint8_t sc_pci_hpbcfg[16]; - - SLIST_ENTRY(psycho_softc) sc_link; - - device_t sc_dev; - - bus_addr_t sc_pcictl; - - u_int sc_mode; -#define PSYCHO_MODE_SABRE 0 -#define PSYCHO_MODE_PSYCHO 1 - - /* Bus A or B of a psycho pair? */ - u_int sc_half; - - /* Interrupt Group Number for this device */ - uint32_t sc_ign; -}; - -#endif /* !_SPARC64_PCI_PSYCHOVAR_H_ */ diff --git a/sys/sparc64/pci/sbbc.c b/sys/sparc64/pci/sbbc.c deleted file mode 100644 index a5975fff82a3..000000000000 --- a/sys/sparc64/pci/sbbc.c +++ /dev/null @@ -1,1113 +0,0 @@ -/* $OpenBSD: sbbc.c,v 1.7 2009/11/09 17:53:39 nicm Exp $ */ -/*- - * SPDX-License-Identifier: (ISC AND BSD-2-Clause-FreeBSD) - * - * Copyright (c) 2008 Mark Kettenis - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ -/*- - * Copyright (c) 2010 Marius Strobl - * 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 -__FBSDID("$FreeBSD$"); - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include -#include -#include - -#include -#include -#include -#include -#include - -#include "clock_if.h" -#include "uart_if.h" - -#define SBBC_PCI_BAR PCIR_BAR(0) -#define SBBC_PCI_VENDOR 0x108e -#define SBBC_PCI_PRODUCT 0xc416 - -#define SBBC_REGS_OFFSET 0x800000 -#define SBBC_REGS_SIZE 0x6230 -#define SBBC_EPLD_OFFSET 0x8e0000 -#define SBBC_EPLD_SIZE 0x20 -#define SBBC_SRAM_OFFSET 0x900000 -#define SBBC_SRAM_SIZE 0x20000 /* 128KB SRAM */ - -#define SBBC_PCI_INT_STATUS 0x2320 -#define SBBC_PCI_INT_ENABLE 0x2330 -#define SBBC_PCI_ENABLE_INT_A 0x11 - -#define SBBC_EPLD_INTERRUPT 0x13 -#define SBBC_EPLD_INTERRUPT_ON 0x01 - -#define SBBC_SRAM_CONS_IN 0x00000001 -#define SBBC_SRAM_CONS_OUT 0x00000002 -#define SBBC_SRAM_CONS_BRK 0x00000004 -#define SBBC_SRAM_CONS_SPACE_IN 0x00000008 -#define SBBC_SRAM_CONS_SPACE_OUT 0x00000010 - -#define SBBC_TAG_KEY_SIZE 8 -#define SBBC_TAG_KEY_SCSOLIE "SCSOLIE" /* SC -> OS int. enable */ -#define SBBC_TAG_KEY_SCSOLIR "SCSOLIR" /* SC -> OS int. reason */ -#define SBBC_TAG_KEY_SOLCONS "SOLCONS" /* OS console buffer */ -#define SBBC_TAG_KEY_SOLSCIE "SOLSCIE" /* OS -> SC int. enable */ -#define SBBC_TAG_KEY_SOLSCIR "SOLSCIR" /* OS -> SC int. reason */ -#define SBBC_TAG_KEY_TODDATA "TODDATA" /* OS TOD struct */ -#define SBBC_TAG_OFF(x) offsetof(struct sbbc_sram_tag, x) - -struct sbbc_sram_tag { - char tag_key[SBBC_TAG_KEY_SIZE]; - uint32_t tag_size; - uint32_t tag_offset; -} __packed; - -#define SBBC_TOC_MAGIC "TOCSRAM" -#define SBBC_TOC_MAGIC_SIZE 8 -#define SBBC_TOC_TAGS_MAX 32 -#define SBBC_TOC_OFF(x) offsetof(struct sbbc_sram_toc, x) - -struct sbbc_sram_toc { - char toc_magic[SBBC_TOC_MAGIC_SIZE]; - uint8_t toc_reserved; - uint8_t toc_type; - uint16_t toc_version; - uint32_t toc_ntags; - struct sbbc_sram_tag toc_tag[SBBC_TOC_TAGS_MAX]; -} __packed; - -#define SBBC_TOD_MAGIC 0x54443100 /* "TD1" */ -#define SBBC_TOD_VERSION 1 -#define SBBC_TOD_OFF(x) offsetof(struct sbbc_sram_tod, x) - -struct sbbc_sram_tod { - uint32_t tod_magic; - uint32_t tod_version; - uint64_t tod_time; - uint64_t tod_skew; - uint32_t tod_reserved; - uint32_t tod_heartbeat; - uint32_t tod_timeout; -} __packed; - -#define SBBC_CONS_MAGIC 0x434f4e00 /* "CON" */ -#define SBBC_CONS_VERSION 1 -#define SBBC_CONS_OFF(x) offsetof(struct sbbc_sram_cons, x) - -struct sbbc_sram_cons { - uint32_t cons_magic; - uint32_t cons_version; - uint32_t cons_size; - - uint32_t cons_in_begin; - uint32_t cons_in_end; - uint32_t cons_in_rdptr; - uint32_t cons_in_wrptr; - - uint32_t cons_out_begin; - uint32_t cons_out_end; - uint32_t cons_out_rdptr; - uint32_t cons_out_wrptr; -} __packed; - -struct sbbc_softc { - struct resource *sc_res; -}; - -#define SBBC_READ_N(wdth, offs) \ - bus_space_read_ ## wdth((bst), (bsh), (offs)) -#define SBBC_WRITE_N(wdth, offs, val) \ - bus_space_write_ ## wdth((bst), (bsh), (offs), (val)) - -#define SBBC_READ_1(offs) \ - SBBC_READ_N(1, (offs)) -#define SBBC_READ_2(offs) \ - bswap16(SBBC_READ_N(2, (offs))) -#define SBBC_READ_4(offs) \ - bswap32(SBBC_READ_N(4, (offs))) -#define SBBC_READ_8(offs) \ - bswap64(SBBC_READ_N(8, (offs))) -#define SBBC_WRITE_1(offs, val) \ - SBBC_WRITE_N(1, (offs), (val)) -#define SBBC_WRITE_2(offs, val) \ - SBBC_WRITE_N(2, (offs), bswap16(val)) -#define SBBC_WRITE_4(offs, val) \ - SBBC_WRITE_N(4, (offs), bswap32(val)) -#define SBBC_WRITE_8(offs, val) \ - SBBC_WRITE_N(8, (offs), bswap64(val)) - -#define SBBC_REGS_READ_1(offs) \ - SBBC_READ_1((offs) + SBBC_REGS_OFFSET) -#define SBBC_REGS_READ_2(offs) \ - SBBC_READ_2((offs) + SBBC_REGS_OFFSET) -#define SBBC_REGS_READ_4(offs) \ - SBBC_READ_4((offs) + SBBC_REGS_OFFSET) -#define SBBC_REGS_READ_8(offs) \ - SBBC_READ_8((offs) + SBBC_REGS_OFFSET) -#define SBBC_REGS_WRITE_1(offs, val) \ - SBBC_WRITE_1((offs) + SBBC_REGS_OFFSET, (val)) -#define SBBC_REGS_WRITE_2(offs, val) \ - SBBC_WRITE_2((offs) + SBBC_REGS_OFFSET, (val)) -#define SBBC_REGS_WRITE_4(offs, val) \ - SBBC_WRITE_4((offs) + SBBC_REGS_OFFSET, (val)) -#define SBBC_REGS_WRITE_8(offs, val) \ - SBBC_WRITE_8((offs) + SBBC_REGS_OFFSET, (val)) - -#define SBBC_EPLD_READ_1(offs) \ - SBBC_READ_1((offs) + SBBC_EPLD_OFFSET) -#define SBBC_EPLD_READ_2(offs) \ - SBBC_READ_2((offs) + SBBC_EPLD_OFFSET) -#define SBBC_EPLD_READ_4(offs) \ - SBBC_READ_4((offs) + SBBC_EPLD_OFFSET) -#define SBBC_EPLD_READ_8(offs) \ - SBBC_READ_8((offs) + SBBC_EPLD_OFFSET) -#define SBBC_EPLD_WRITE_1(offs, val) \ - SBBC_WRITE_1((offs) + SBBC_EPLD_OFFSET, (val)) -#define SBBC_EPLD_WRITE_2(offs, val) \ - SBBC_WRITE_2((offs) + SBBC_EPLD_OFFSET, (val)) -#define SBBC_EPLD_WRITE_4(offs, val) \ - SBBC_WRITE_4((offs) + SBBC_EPLD_OFFSET, (val)) -#define SBBC_EPLD_WRITE_8(offs, val) \ - SBBC_WRITE_8((offs) + SBBC_EPLD_OFFSET, (val)) - -#define SBBC_SRAM_READ_1(offs) \ - SBBC_READ_1((offs) + SBBC_SRAM_OFFSET) -#define SBBC_SRAM_READ_2(offs) \ - SBBC_READ_2((offs) + SBBC_SRAM_OFFSET) -#define SBBC_SRAM_READ_4(offs) \ - SBBC_READ_4((offs) + SBBC_SRAM_OFFSET) -#define SBBC_SRAM_READ_8(offs) \ - SBBC_READ_8((offs) + SBBC_SRAM_OFFSET) -#define SBBC_SRAM_WRITE_1(offs, val) \ - SBBC_WRITE_1((offs) + SBBC_SRAM_OFFSET, (val)) -#define SBBC_SRAM_WRITE_2(offs, val) \ - SBBC_WRITE_2((offs) + SBBC_SRAM_OFFSET, (val)) -#define SBBC_SRAM_WRITE_4(offs, val) \ - SBBC_WRITE_4((offs) + SBBC_SRAM_OFFSET, (val)) -#define SBBC_SRAM_WRITE_8(offs, val) \ - SBBC_WRITE_8((offs) + SBBC_SRAM_OFFSET, (val)) - -#define SUNW_SETCONSINPUT "SUNW,set-console-input" -#define SUNW_SETCONSINPUT_CLNT "CON_CLNT" -#define SUNW_SETCONSINPUT_OBP "CON_OBP" - -static u_int sbbc_console; - -static uint32_t sbbc_scsolie; -static uint32_t sbbc_scsolir; -static uint32_t sbbc_solcons; -static uint32_t sbbc_solscie; -static uint32_t sbbc_solscir; -static uint32_t sbbc_toddata; - -/* - * internal helpers - */ -static int sbbc_parse_toc(bus_space_tag_t bst, bus_space_handle_t bsh); -static inline void sbbc_send_intr(bus_space_tag_t bst, - bus_space_handle_t bsh); -static const char *sbbc_serengeti_set_console_input(char *new); - -/* - * SBBC PCI interface - */ -static bus_activate_resource_t sbbc_bus_activate_resource; -static bus_adjust_resource_t sbbc_bus_adjust_resource; -static bus_deactivate_resource_t sbbc_bus_deactivate_resource; -static bus_alloc_resource_t sbbc_bus_alloc_resource; -static bus_release_resource_t sbbc_bus_release_resource; -static bus_get_resource_list_t sbbc_bus_get_resource_list; -static bus_setup_intr_t sbbc_bus_setup_intr; -static bus_teardown_intr_t sbbc_bus_teardown_intr; - -static device_attach_t sbbc_pci_attach; -static device_probe_t sbbc_pci_probe; - -static clock_gettime_t sbbc_tod_gettime; -static clock_settime_t sbbc_tod_settime; - -static device_method_t sbbc_pci_methods[] = { - /* Device interface */ - DEVMETHOD(device_probe, sbbc_pci_probe), - DEVMETHOD(device_attach, sbbc_pci_attach), - - DEVMETHOD(bus_alloc_resource, sbbc_bus_alloc_resource), - DEVMETHOD(bus_activate_resource,sbbc_bus_activate_resource), - DEVMETHOD(bus_deactivate_resource,sbbc_bus_deactivate_resource), - DEVMETHOD(bus_adjust_resource, sbbc_bus_adjust_resource), - DEVMETHOD(bus_release_resource, sbbc_bus_release_resource), - DEVMETHOD(bus_setup_intr, sbbc_bus_setup_intr), - DEVMETHOD(bus_teardown_intr, sbbc_bus_teardown_intr), - DEVMETHOD(bus_get_resource, bus_generic_rl_get_resource), - DEVMETHOD(bus_get_resource_list, sbbc_bus_get_resource_list), - - /* clock interface */ - DEVMETHOD(clock_gettime, sbbc_tod_gettime), - DEVMETHOD(clock_settime, sbbc_tod_settime), - - DEVMETHOD_END -}; - -static devclass_t sbbc_devclass; - -DEFINE_CLASS_0(sbbc, sbbc_driver, sbbc_pci_methods, sizeof(struct sbbc_softc)); -DRIVER_MODULE(sbbc, pci, sbbc_driver, sbbc_devclass, NULL, NULL); - -static int -sbbc_pci_probe(device_t dev) -{ - - if (pci_get_vendor(dev) == SBBC_PCI_VENDOR && - pci_get_device(dev) == SBBC_PCI_PRODUCT) { - device_set_desc(dev, "Sun BootBus controller"); - return (BUS_PROBE_DEFAULT); - } - return (ENXIO); -} - -static int -sbbc_pci_attach(device_t dev) -{ - struct sbbc_softc *sc; - struct timespec ts; - device_t child; - bus_space_tag_t bst; - bus_space_handle_t bsh; - phandle_t node; - int error, rid; - uint32_t val; - - /* Nothing to do if we're not the chosen one. */ - if ((node = OF_finddevice("/chosen")) == -1) { - device_printf(dev, "failed to find /chosen\n"); - return (ENXIO); - } - if (OF_getprop(node, "iosram", &node, sizeof(node)) == -1) { - device_printf(dev, "failed to get iosram\n"); - return (ENXIO); - } - if (node != ofw_bus_get_node(dev)) - return (0); - - sc = device_get_softc(dev); - rid = SBBC_PCI_BAR; - sc->sc_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid, - RF_ACTIVE); - if (sc->sc_res == NULL) { - device_printf(dev, "failed to allocate resources\n"); - return (ENXIO); - } - bst = rman_get_bustag(sc->sc_res); - bsh = rman_get_bushandle(sc->sc_res); - if (sbbc_console != 0) { - /* Once again the interrupt pin isn't set. */ - if (pci_get_intpin(dev) == 0) - pci_set_intpin(dev, 1); - child = device_add_child(dev, NULL, -1); - if (child == NULL) - device_printf(dev, "failed to add UART device\n"); - error = bus_generic_attach(dev); - if (error != 0) - device_printf(dev, "failed to attach UART device\n"); - } else { - error = sbbc_parse_toc(bst, bsh); - if (error != 0) { - device_printf(dev, "failed to parse TOC\n"); - if (sbbc_console != 0) { - bus_release_resource(dev, SYS_RES_MEMORY, rid, - sc->sc_res); - return (error); - } - } - } - if (sbbc_toddata != 0) { - if ((val = SBBC_SRAM_READ_4(sbbc_toddata + - SBBC_TOD_OFF(tod_magic))) != SBBC_TOD_MAGIC) - device_printf(dev, "invalid TOD magic %#x\n", val); - else if ((val = SBBC_SRAM_READ_4(sbbc_toddata + - SBBC_TOD_OFF(tod_version))) < SBBC_TOD_VERSION) - device_printf(dev, "invalid TOD version %#x\n", val); - else { - clock_register(dev, 1000000); /* 1 sec. resolution */ - if (bootverbose) { - sbbc_tod_gettime(dev, &ts); - device_printf(dev, - "current time: %ld.%09ld\n", - (long)ts.tv_sec, ts.tv_nsec); - } - } - } - return (0); -} - -/* - * Note that the bus methods don't pass-through the uart(4) requests but act - * as if they would come from sbbc(4) in order to avoid complications with - * pci(4) (actually, uart(4) isn't a real child but rather a function of - * sbbc(4) anyway). - */ - -static struct resource * -sbbc_bus_alloc_resource(device_t dev, device_t child __unused, int type, - int *rid, rman_res_t start, rman_res_t end, rman_res_t count, u_int flags) -{ - struct sbbc_softc *sc; - - sc = device_get_softc(dev); - switch (type) { - case SYS_RES_IRQ: - return (bus_generic_alloc_resource(dev, dev, type, rid, start, - end, count, flags)); - case SYS_RES_MEMORY: - return (sc->sc_res); - default: - return (NULL); - } -} - -static int -sbbc_bus_activate_resource(device_t bus, device_t child, int type, int rid, - struct resource *res) -{ - - if (type == SYS_RES_MEMORY) - return (0); - return (bus_generic_activate_resource(bus, child, type, rid, res)); -} - -static int -sbbc_bus_deactivate_resource(device_t bus, device_t child, int type, int rid, - struct resource *res) -{ - - if (type == SYS_RES_MEMORY) - return (0); - return (bus_generic_deactivate_resource(bus, child, type, rid, res)); -} - -static int -sbbc_bus_adjust_resource(device_t bus __unused, device_t child __unused, - int type __unused, struct resource *res __unused, rman_res_t start __unused, - rman_res_t end __unused) -{ - - return (ENXIO); -} - -static int -sbbc_bus_release_resource(device_t dev, device_t child __unused, int type, - int rid, struct resource *res) -{ - - if (type == SYS_RES_IRQ) - return (bus_generic_release_resource(dev, dev, type, rid, - res)); - return (0); -} - -static struct resource_list * -sbbc_bus_get_resource_list(device_t dev, device_t child __unused) -{ - - return (bus_generic_get_resource_list(dev, dev)); -} - -static int -sbbc_bus_setup_intr(device_t dev, device_t child __unused, - struct resource *res, int flags, driver_filter_t *filt, - driver_intr_t *intr, void *arg, void **cookiep) -{ - - return (bus_generic_setup_intr(dev, dev, res, flags, filt, intr, arg, - cookiep)); -} - -static int -sbbc_bus_teardown_intr(device_t dev, device_t child __unused, - struct resource *res, void *cookie) -{ - - return (bus_generic_teardown_intr(dev, dev, res, cookie)); -} - -/* - * internal helpers - */ -static int -sbbc_parse_toc(bus_space_tag_t bst, bus_space_handle_t bsh) -{ - char buf[MAX(SBBC_TAG_KEY_SIZE, SBBC_TOC_MAGIC_SIZE)]; - bus_size_t tag; - phandle_t node; - uint32_t off, sram_toc; - u_int i, tags; - - if ((node = OF_finddevice("/chosen")) == -1) - return (ENXIO); - /* SRAM TOC offset defaults to 0. */ - if (OF_getprop(node, "iosram-toc", &sram_toc, sizeof(sram_toc)) <= 0) - sram_toc = 0; - - bus_space_read_region_1(bst, bsh, SBBC_SRAM_OFFSET + sram_toc + - SBBC_TOC_OFF(toc_magic), buf, SBBC_TOC_MAGIC_SIZE); - buf[SBBC_TOC_MAGIC_SIZE - 1] = '\0'; - if (strcmp(buf, SBBC_TOC_MAGIC) != 0) - return (ENXIO); - - tags = SBBC_SRAM_READ_4(sram_toc + SBBC_TOC_OFF(toc_ntags)); - for (i = 0; i < tags; i++) { - tag = sram_toc + SBBC_TOC_OFF(toc_tag) + - i * sizeof(struct sbbc_sram_tag); - bus_space_read_region_1(bst, bsh, SBBC_SRAM_OFFSET + tag + - SBBC_TAG_OFF(tag_key), buf, SBBC_TAG_KEY_SIZE); - buf[SBBC_TAG_KEY_SIZE - 1] = '\0'; - off = SBBC_SRAM_READ_4(tag + SBBC_TAG_OFF(tag_offset)); - if (strcmp(buf, SBBC_TAG_KEY_SCSOLIE) == 0) - sbbc_scsolie = off; - else if (strcmp(buf, SBBC_TAG_KEY_SCSOLIR) == 0) - sbbc_scsolir = off; - else if (strcmp(buf, SBBC_TAG_KEY_SOLCONS) == 0) - sbbc_solcons = off; - else if (strcmp(buf, SBBC_TAG_KEY_SOLSCIE) == 0) - sbbc_solscie = off; - else if (strcmp(buf, SBBC_TAG_KEY_SOLSCIR) == 0) - sbbc_solscir = off; - else if (strcmp(buf, SBBC_TAG_KEY_TODDATA) == 0) - sbbc_toddata = off; - } - return (0); -} - -static const char * -sbbc_serengeti_set_console_input(char *new) -{ - struct { - cell_t name; - cell_t nargs; - cell_t nreturns; - cell_t new; - cell_t old; - } args = { - (cell_t)SUNW_SETCONSINPUT, - 1, - 1, - }; - - args.new = (cell_t)new; - if (ofw_entry(&args) == -1) - return (NULL); - return ((const char *)args.old); -} - -static inline void -sbbc_send_intr(bus_space_tag_t bst, bus_space_handle_t bsh) -{ - - SBBC_EPLD_WRITE_1(SBBC_EPLD_INTERRUPT, SBBC_EPLD_INTERRUPT_ON); - bus_space_barrier(bst, bsh, SBBC_EPLD_OFFSET + SBBC_EPLD_INTERRUPT, 1, - BUS_SPACE_BARRIER_READ | BUS_SPACE_BARRIER_WRITE); -} - -/* - * TOD interface - */ -static int -sbbc_tod_gettime(device_t dev, struct timespec *ts) -{ - struct sbbc_softc *sc; - bus_space_tag_t bst; - bus_space_handle_t bsh; - - sc = device_get_softc(dev); - bst = rman_get_bustag(sc->sc_res); - bsh = rman_get_bushandle(sc->sc_res); - - ts->tv_sec = SBBC_SRAM_READ_8(sbbc_toddata + SBBC_TOD_OFF(tod_time)) + - SBBC_SRAM_READ_8(sbbc_toddata + SBBC_TOD_OFF(tod_skew)); - ts->tv_nsec = 0; - return (0); -} - -static int -sbbc_tod_settime(device_t dev, struct timespec *ts) -{ - struct sbbc_softc *sc; - bus_space_tag_t bst; - bus_space_handle_t bsh; - - sc = device_get_softc(dev); - bst = rman_get_bustag(sc->sc_res); - bsh = rman_get_bushandle(sc->sc_res); - - SBBC_SRAM_WRITE_8(sbbc_toddata + SBBC_TOD_OFF(tod_skew), ts->tv_sec - - SBBC_SRAM_READ_8(sbbc_toddata + SBBC_TOD_OFF(tod_time))); - return (0); -} - -/* - * UART bus front-end - */ -static device_probe_t sbbc_uart_sbbc_probe; - -static device_method_t sbbc_uart_sbbc_methods[] = { - /* Device interface */ - DEVMETHOD(device_probe, sbbc_uart_sbbc_probe), - DEVMETHOD(device_attach, uart_bus_attach), - DEVMETHOD(device_detach, uart_bus_detach), - - DEVMETHOD_END -}; - -DEFINE_CLASS_0(uart, sbbc_uart_driver, sbbc_uart_sbbc_methods, - sizeof(struct uart_softc)); -DRIVER_MODULE(uart, sbbc, sbbc_uart_driver, uart_devclass, NULL, NULL); - -static int -sbbc_uart_sbbc_probe(device_t dev) -{ - struct uart_softc *sc; - - sc = device_get_softc(dev); - sc->sc_class = &uart_sbbc_class; - device_set_desc(dev, "Serengeti console"); - return (uart_bus_probe(dev, 0, 0, 0, SBBC_PCI_BAR, 0, 0)); -} - -/* - * Low-level UART interface - */ -static int sbbc_uart_probe(struct uart_bas *bas); -static void sbbc_uart_init(struct uart_bas *bas, int baudrate, int databits, - int stopbits, int parity); -static void sbbc_uart_term(struct uart_bas *bas); -static void sbbc_uart_putc(struct uart_bas *bas, int c); -static int sbbc_uart_rxready(struct uart_bas *bas); -static int sbbc_uart_getc(struct uart_bas *bas, struct mtx *hwmtx); - -static struct uart_ops sbbc_uart_ops = { - .probe = sbbc_uart_probe, - .init = sbbc_uart_init, - .term = sbbc_uart_term, - .putc = sbbc_uart_putc, - .rxready = sbbc_uart_rxready, - .getc = sbbc_uart_getc, -}; - -static int -sbbc_uart_probe(struct uart_bas *bas) -{ - bus_space_tag_t bst; - bus_space_handle_t bsh; - int error; - - sbbc_console = 1; - bst = bas->bst; - bsh = bas->bsh; - error = sbbc_parse_toc(bst, bsh); - if (error != 0) - return (error); - - if (sbbc_scsolie == 0 || sbbc_scsolir == 0 || sbbc_solcons == 0 || - sbbc_solscie == 0 || sbbc_solscir == 0) - return (ENXIO); - - if (SBBC_SRAM_READ_4(sbbc_solcons + SBBC_CONS_OFF(cons_magic)) != - SBBC_CONS_MAGIC || SBBC_SRAM_READ_4(sbbc_solcons + - SBBC_CONS_OFF(cons_version)) < SBBC_CONS_VERSION) - return (ENXIO); - return (0); -} - -static void -sbbc_uart_init(struct uart_bas *bas, int baudrate __unused, - int databits __unused, int stopbits __unused, int parity __unused) -{ - bus_space_tag_t bst; - bus_space_handle_t bsh; - - bst = bas->bst; - bsh = bas->bsh; - - /* Enable output to and space in from the SC interrupts. */ - SBBC_SRAM_WRITE_4(sbbc_solscie, SBBC_SRAM_READ_4(sbbc_solscie) | - SBBC_SRAM_CONS_OUT | SBBC_SRAM_CONS_SPACE_IN); - uart_barrier(bas); - - /* Take over the console input. */ - sbbc_serengeti_set_console_input(SUNW_SETCONSINPUT_CLNT); -} - -static void -sbbc_uart_term(struct uart_bas *bas __unused) -{ - - /* Give back the console input. */ - sbbc_serengeti_set_console_input(SUNW_SETCONSINPUT_OBP); -} - -static void -sbbc_uart_putc(struct uart_bas *bas, int c) -{ - bus_space_tag_t bst; - bus_space_handle_t bsh; - uint32_t wrptr; - - bst = bas->bst; - bsh = bas->bsh; - - wrptr = SBBC_SRAM_READ_4(sbbc_solcons + - SBBC_CONS_OFF(cons_out_wrptr)); - SBBC_SRAM_WRITE_1(sbbc_solcons + wrptr, c); - uart_barrier(bas); - if (++wrptr == SBBC_SRAM_READ_4(sbbc_solcons + - SBBC_CONS_OFF(cons_out_end))) - wrptr = SBBC_SRAM_READ_4(sbbc_solcons + - SBBC_CONS_OFF(cons_out_begin)); - SBBC_SRAM_WRITE_4(sbbc_solcons + SBBC_CONS_OFF(cons_out_wrptr), - wrptr); - uart_barrier(bas); - - SBBC_SRAM_WRITE_4(sbbc_solscir, SBBC_SRAM_READ_4(sbbc_solscir) | - SBBC_SRAM_CONS_OUT); - uart_barrier(bas); - sbbc_send_intr(bst, bsh); -} - -static int -sbbc_uart_rxready(struct uart_bas *bas) -{ - bus_space_tag_t bst; - bus_space_handle_t bsh; - - bst = bas->bst; - bsh = bas->bsh; - - if (SBBC_SRAM_READ_4(sbbc_solcons + SBBC_CONS_OFF(cons_in_rdptr)) == - SBBC_SRAM_READ_4(sbbc_solcons + SBBC_CONS_OFF(cons_in_wrptr))) - return (0); - return (1); -} - -static int -sbbc_uart_getc(struct uart_bas *bas, struct mtx *hwmtx) -{ - bus_space_tag_t bst; - bus_space_handle_t bsh; - int c; - uint32_t rdptr; - - bst = bas->bst; - bsh = bas->bsh; - - uart_lock(hwmtx); - - while (sbbc_uart_rxready(bas) == 0) { - uart_unlock(hwmtx); - DELAY(4); - uart_lock(hwmtx); - } - - rdptr = SBBC_SRAM_READ_4(sbbc_solcons + SBBC_CONS_OFF(cons_in_rdptr)); - c = SBBC_SRAM_READ_1(sbbc_solcons + rdptr); - uart_barrier(bas); - if (++rdptr == SBBC_SRAM_READ_4(sbbc_solcons + - SBBC_CONS_OFF(cons_in_end))) - rdptr = SBBC_SRAM_READ_4(sbbc_solcons + - SBBC_CONS_OFF(cons_in_begin)); - SBBC_SRAM_WRITE_4(sbbc_solcons + SBBC_CONS_OFF(cons_in_rdptr), - rdptr); - uart_barrier(bas); - SBBC_SRAM_WRITE_4(sbbc_solscir, SBBC_SRAM_READ_4(sbbc_solscir) | - SBBC_SRAM_CONS_SPACE_IN); - uart_barrier(bas); - sbbc_send_intr(bst, bsh); - - uart_unlock(hwmtx); - return (c); -} - -/* - * High-level UART interface - */ -static int sbbc_uart_bus_attach(struct uart_softc *sc); -static int sbbc_uart_bus_detach(struct uart_softc *sc); -static int sbbc_uart_bus_flush(struct uart_softc *sc, int what); -static int sbbc_uart_bus_getsig(struct uart_softc *sc); -static int sbbc_uart_bus_ioctl(struct uart_softc *sc, int request, - intptr_t data); -static int sbbc_uart_bus_ipend(struct uart_softc *sc); -static int sbbc_uart_bus_param(struct uart_softc *sc, int baudrate, - int databits, int stopbits, int parity); -static int sbbc_uart_bus_probe(struct uart_softc *sc); -static int sbbc_uart_bus_receive(struct uart_softc *sc); -static int sbbc_uart_bus_setsig(struct uart_softc *sc, int sig); -static int sbbc_uart_bus_transmit(struct uart_softc *sc); - -static kobj_method_t sbbc_uart_methods[] = { - KOBJMETHOD(uart_attach, sbbc_uart_bus_attach), - KOBJMETHOD(uart_detach, sbbc_uart_bus_detach), - KOBJMETHOD(uart_flush, sbbc_uart_bus_flush), - KOBJMETHOD(uart_getsig, sbbc_uart_bus_getsig), - KOBJMETHOD(uart_ioctl, sbbc_uart_bus_ioctl), - KOBJMETHOD(uart_ipend, sbbc_uart_bus_ipend), - KOBJMETHOD(uart_param, sbbc_uart_bus_param), - KOBJMETHOD(uart_probe, sbbc_uart_bus_probe), - KOBJMETHOD(uart_receive, sbbc_uart_bus_receive), - KOBJMETHOD(uart_setsig, sbbc_uart_bus_setsig), - KOBJMETHOD(uart_transmit, sbbc_uart_bus_transmit), - - DEVMETHOD_END -}; - -struct uart_class uart_sbbc_class = { - "sbbc", - sbbc_uart_methods, - sizeof(struct uart_softc), - .uc_ops = &sbbc_uart_ops, - .uc_range = 1, - .uc_rclk = 0x5bbc, /* arbitrary */ - .uc_rshift = 0 -}; - -#define SIGCHG(c, i, s, d) \ - if ((c) != 0) { \ - i |= (((i) & (s)) != 0) ? (s) : (s) | (d); \ - } else { \ - i = (((i) & (s)) != 0) ? ((i) & ~(s)) | (d) : (i); \ - } - -static int -sbbc_uart_bus_attach(struct uart_softc *sc) -{ - struct uart_bas *bas; - bus_space_tag_t bst; - bus_space_handle_t bsh; - uint32_t wrptr; - - bas = &sc->sc_bas; - bst = bas->bst; - bsh = bas->bsh; - - uart_lock(sc->sc_hwmtx); - - /* - * Let the current output drain before enabling interrupts. Not - * doing so tends to cause lost output when turning them on. - */ - wrptr = SBBC_SRAM_READ_4(sbbc_solcons + - SBBC_CONS_OFF(cons_out_wrptr)); - while (SBBC_SRAM_READ_4(sbbc_solcons + - SBBC_CONS_OFF(cons_out_rdptr)) != wrptr); - cpu_spinwait(); - - /* Clear and acknowledge possibly outstanding interrupts. */ - SBBC_SRAM_WRITE_4(sbbc_scsolir, 0); - uart_barrier(bas); - SBBC_REGS_WRITE_4(SBBC_PCI_INT_STATUS, - SBBC_SRAM_READ_4(sbbc_scsolir)); - uart_barrier(bas); - /* Enable PCI interrupts. */ - SBBC_REGS_WRITE_4(SBBC_PCI_INT_ENABLE, SBBC_PCI_ENABLE_INT_A); - uart_barrier(bas); - /* Enable input from and output to SC as well as break interrupts. */ - SBBC_SRAM_WRITE_4(sbbc_scsolie, SBBC_SRAM_READ_4(sbbc_scsolie) | - SBBC_SRAM_CONS_IN | SBBC_SRAM_CONS_BRK | - SBBC_SRAM_CONS_SPACE_OUT); - uart_barrier(bas); - - uart_unlock(sc->sc_hwmtx); - return (0); -} - -static int -sbbc_uart_bus_detach(struct uart_softc *sc) -{ - - /* Give back the console input. */ - sbbc_serengeti_set_console_input(SUNW_SETCONSINPUT_OBP); - return (0); -} - -static int -sbbc_uart_bus_flush(struct uart_softc *sc, int what) -{ - struct uart_bas *bas; - bus_space_tag_t bst; - bus_space_handle_t bsh; - - bas = &sc->sc_bas; - bst = bas->bst; - bsh = bas->bsh; - - if ((what & UART_FLUSH_TRANSMITTER) != 0) - return (ENODEV); - if ((what & UART_FLUSH_RECEIVER) != 0) { - SBBC_SRAM_WRITE_4(sbbc_solcons + - SBBC_CONS_OFF(cons_in_rdptr), - SBBC_SRAM_READ_4(sbbc_solcons + - SBBC_CONS_OFF(cons_in_wrptr))); - uart_barrier(bas); - } - return (0); -} - -static int -sbbc_uart_bus_getsig(struct uart_softc *sc) -{ - uint32_t dummy, new, old, sig; - - do { - old = sc->sc_hwsig; - sig = old; - dummy = 0; - SIGCHG(dummy, sig, SER_CTS, SER_DCTS); - SIGCHG(dummy, sig, SER_DCD, SER_DDCD); - SIGCHG(dummy, sig, SER_DSR, SER_DDSR); - new = sig & ~SER_MASK_DELTA; - } while (!atomic_cmpset_32(&sc->sc_hwsig, old, new)); - return (sig); -} - -static int -sbbc_uart_bus_ioctl(struct uart_softc *sc, int request, intptr_t data) -{ - int error; - - error = 0; - uart_lock(sc->sc_hwmtx); - switch (request) { - case UART_IOCTL_BAUD: - *(int*)data = 9600; /* arbitrary */ - break; - default: - error = EINVAL; - break; - } - uart_unlock(sc->sc_hwmtx); - return (error); -} - -static int -sbbc_uart_bus_ipend(struct uart_softc *sc) -{ - struct uart_bas *bas; - bus_space_tag_t bst; - bus_space_handle_t bsh; - int ipend; - uint32_t reason, status; - - bas = &sc->sc_bas; - bst = bas->bst; - bsh = bas->bsh; - - uart_lock(sc->sc_hwmtx); - status = SBBC_REGS_READ_4(SBBC_PCI_INT_STATUS); - if (status == 0) { - uart_unlock(sc->sc_hwmtx); - return (0); - } - - /* - * Unfortunately, we can't use compare and swap for non-cachable - * memory. - */ - reason = SBBC_SRAM_READ_4(sbbc_scsolir); - SBBC_SRAM_WRITE_4(sbbc_scsolir, 0); - uart_barrier(bas); - /* Acknowledge the interrupt. */ - SBBC_REGS_WRITE_4(SBBC_PCI_INT_STATUS, status); - uart_barrier(bas); - - uart_unlock(sc->sc_hwmtx); - - ipend = 0; - if ((reason & SBBC_SRAM_CONS_IN) != 0) - ipend |= SER_INT_RXREADY; - if ((reason & SBBC_SRAM_CONS_BRK) != 0) - ipend |= SER_INT_BREAK; - if ((reason & SBBC_SRAM_CONS_SPACE_OUT) != 0 && - SBBC_SRAM_READ_4(sbbc_solcons + SBBC_CONS_OFF(cons_out_rdptr)) == - SBBC_SRAM_READ_4(sbbc_solcons + SBBC_CONS_OFF(cons_out_wrptr))) - ipend |= SER_INT_TXIDLE; - return (ipend); -} - -static int -sbbc_uart_bus_param(struct uart_softc *sc __unused, int baudrate __unused, - int databits __unused, int stopbits __unused, int parity __unused) -{ - - return (0); -} - -static int -sbbc_uart_bus_probe(struct uart_softc *sc) -{ - struct uart_bas *bas; - bus_space_tag_t bst; - bus_space_handle_t bsh; - - if (sbbc_console != 0) { - bas = &sc->sc_bas; - bst = bas->bst; - bsh = bas->bsh; - sc->sc_rxfifosz = SBBC_SRAM_READ_4(sbbc_solcons + - SBBC_CONS_OFF(cons_in_end)) - SBBC_SRAM_READ_4(sbbc_solcons + - SBBC_CONS_OFF(cons_in_begin)) - 1; - sc->sc_txfifosz = SBBC_SRAM_READ_4(sbbc_solcons + - SBBC_CONS_OFF(cons_out_end)) - SBBC_SRAM_READ_4(sbbc_solcons + - SBBC_CONS_OFF(cons_out_begin)) - 1; - return (0); - } - return (ENXIO); -} - -static int -sbbc_uart_bus_receive(struct uart_softc *sc) -{ - struct uart_bas *bas; - bus_space_tag_t bst; - bus_space_handle_t bsh; - int c; - uint32_t end, rdptr, wrptr; - - bas = &sc->sc_bas; - bst = bas->bst; - bsh = bas->bsh; - - uart_lock(sc->sc_hwmtx); - - end = SBBC_SRAM_READ_4(sbbc_solcons + SBBC_CONS_OFF(cons_in_end)); - rdptr = SBBC_SRAM_READ_4(sbbc_solcons + SBBC_CONS_OFF(cons_in_rdptr)); - wrptr = SBBC_SRAM_READ_4(sbbc_solcons + SBBC_CONS_OFF(cons_in_wrptr)); - while (rdptr != wrptr) { - if (uart_rx_full(sc) != 0) { - sc->sc_rxbuf[sc->sc_rxput] = UART_STAT_OVERRUN; - break; - } - c = SBBC_SRAM_READ_1(sbbc_solcons + rdptr); - uart_rx_put(sc, c); - if (++rdptr == end) - rdptr = SBBC_SRAM_READ_4(sbbc_solcons + - SBBC_CONS_OFF(cons_in_begin)); - } - uart_barrier(bas); - SBBC_SRAM_WRITE_4(sbbc_solcons + SBBC_CONS_OFF(cons_in_rdptr), - rdptr); - uart_barrier(bas); - SBBC_SRAM_WRITE_4(sbbc_solscir, SBBC_SRAM_READ_4(sbbc_solscir) | - SBBC_SRAM_CONS_SPACE_IN); - uart_barrier(bas); - sbbc_send_intr(bst, bsh); - - uart_unlock(sc->sc_hwmtx); - return (0); -} - -static int -sbbc_uart_bus_setsig(struct uart_softc *sc, int sig) -{ - struct uart_bas *bas; - uint32_t new, old; - - bas = &sc->sc_bas; - do { - old = sc->sc_hwsig; - new = old; - if ((sig & SER_DDTR) != 0) { - SIGCHG(sig & SER_DTR, new, SER_DTR, SER_DDTR); - } - if ((sig & SER_DRTS) != 0) { - SIGCHG(sig & SER_RTS, new, SER_RTS, SER_DRTS); - } - } while (!atomic_cmpset_32(&sc->sc_hwsig, old, new)); - return (0); -} - -static int -sbbc_uart_bus_transmit(struct uart_softc *sc) -{ - struct uart_bas *bas; - bus_space_tag_t bst; - bus_space_handle_t bsh; - int i; - uint32_t end, wrptr; - - bas = &sc->sc_bas; - bst = bas->bst; - bsh = bas->bsh; - - uart_lock(sc->sc_hwmtx); - - end = SBBC_SRAM_READ_4(sbbc_solcons + SBBC_CONS_OFF(cons_out_end)); - wrptr = SBBC_SRAM_READ_4(sbbc_solcons + - SBBC_CONS_OFF(cons_out_wrptr)); - for (i = 0; i < sc->sc_txdatasz; i++) { - SBBC_SRAM_WRITE_1(sbbc_solcons + wrptr, sc->sc_txbuf[i]); - if (++wrptr == end) - wrptr = SBBC_SRAM_READ_4(sbbc_solcons + - SBBC_CONS_OFF(cons_out_begin)); - } - uart_barrier(bas); - SBBC_SRAM_WRITE_4(sbbc_solcons + SBBC_CONS_OFF(cons_out_wrptr), - wrptr); - uart_barrier(bas); - SBBC_SRAM_WRITE_4(sbbc_solscir, SBBC_SRAM_READ_4(sbbc_solscir) | - SBBC_SRAM_CONS_OUT); - uart_barrier(bas); - sbbc_send_intr(bst, bsh); - sc->sc_txbusy = 1; - - uart_unlock(sc->sc_hwmtx); - return (0); -} diff --git a/sys/sparc64/pci/schizo.c b/sys/sparc64/pci/schizo.c deleted file mode 100644 index 09987b10f421..000000000000 --- a/sys/sparc64/pci/schizo.c +++ /dev/null @@ -1,1260 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-3-Clause - * - * Copyright (c) 1999, 2000 Matthew R. Green - * Copyright (c) 2001 - 2003 by Thomas Moestl - * Copyright (c) 2005 - 2011 by Marius Strobl - * 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. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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. - * - * from: NetBSD: psycho.c,v 1.39 2001/10/07 20:30:41 eeh Exp - * from: FreeBSD: psycho.c 183152 2008-09-18 19:45:22Z marius - */ - -#include -__FBSDID("$FreeBSD$"); - -/* - * Driver for `Schizo' Fireplane/Safari to PCI 2.1, `Tomatillo' JBus to - * PCI 2.2 and `XMITS' Fireplane/Safari to PCI-X bridges - */ - -#include "opt_ofw_pci.h" -#include "opt_schizo.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include -#include -#include - -#include "pcib_if.h" - -static const struct schizo_desc *schizo_get_desc(device_t); -static void schizo_set_intr(struct schizo_softc *, u_int, u_int, - driver_filter_t); -static void schizo_dmamap_sync(bus_dma_tag_t dt, bus_dmamap_t map, - bus_dmasync_op_t op); -static void ichip_dmamap_sync(bus_dma_tag_t dt, bus_dmamap_t map, - bus_dmasync_op_t op); -static void schizo_intr_enable(void *); -static void schizo_intr_disable(void *); -static void schizo_intr_assign(void *); -static void schizo_intr_clear(void *); -static int schizo_intr_register(struct schizo_softc *sc, u_int ino); -static int schizo_get_intrmap(struct schizo_softc *, u_int, - bus_addr_t *, bus_addr_t *); -static timecounter_get_t schizo_get_timecount; - -/* Interrupt handlers */ -static driver_filter_t schizo_pci_bus; -static driver_filter_t schizo_ue; -static driver_filter_t schizo_ce; -static driver_filter_t schizo_host_bus; -static driver_filter_t schizo_cdma; - -/* IOMMU support */ -static void schizo_iommu_init(struct schizo_softc *, int, uint32_t); - -/* - * Methods - */ -static device_probe_t schizo_probe; -static device_attach_t schizo_attach; -static bus_setup_intr_t schizo_setup_intr; -static bus_alloc_resource_t schizo_alloc_resource; -static pcib_maxslots_t schizo_maxslots; -static pcib_read_config_t schizo_read_config; -static pcib_write_config_t schizo_write_config; -static pcib_route_interrupt_t schizo_route_interrupt; -static ofw_pci_setup_device_t schizo_setup_device; - -static device_method_t schizo_methods[] = { - /* Device interface */ - DEVMETHOD(device_probe, schizo_probe), - DEVMETHOD(device_attach, schizo_attach), - DEVMETHOD(device_shutdown, bus_generic_shutdown), - DEVMETHOD(device_suspend, bus_generic_suspend), - DEVMETHOD(device_resume, bus_generic_resume), - - /* Bus interface */ - DEVMETHOD(bus_read_ivar, ofw_pci_read_ivar), - DEVMETHOD(bus_setup_intr, schizo_setup_intr), - DEVMETHOD(bus_teardown_intr, bus_generic_teardown_intr), - DEVMETHOD(bus_alloc_resource, schizo_alloc_resource), - DEVMETHOD(bus_activate_resource, ofw_pci_activate_resource), - DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource), - DEVMETHOD(bus_adjust_resource, ofw_pci_adjust_resource), - DEVMETHOD(bus_release_resource, bus_generic_release_resource), - DEVMETHOD(bus_get_dma_tag, ofw_pci_get_dma_tag), - - /* pcib interface */ - DEVMETHOD(pcib_maxslots, schizo_maxslots), - DEVMETHOD(pcib_read_config, schizo_read_config), - DEVMETHOD(pcib_write_config, schizo_write_config), - DEVMETHOD(pcib_route_interrupt, schizo_route_interrupt), - DEVMETHOD(pcib_request_feature, pcib_request_feature_allow), - - /* ofw_bus interface */ - DEVMETHOD(ofw_bus_get_node, ofw_pci_get_node), - - /* ofw_pci interface */ - DEVMETHOD(ofw_pci_setup_device, schizo_setup_device), - - DEVMETHOD_END -}; - -static devclass_t schizo_devclass; - -DEFINE_CLASS_0(pcib, schizo_driver, schizo_methods, - sizeof(struct schizo_softc)); -EARLY_DRIVER_MODULE(schizo, nexus, schizo_driver, schizo_devclass, 0, 0, - BUS_PASS_BUS); - -static SLIST_HEAD(, schizo_softc) schizo_softcs = - SLIST_HEAD_INITIALIZER(schizo_softcs); - -static const struct intr_controller schizo_ic = { - schizo_intr_enable, - schizo_intr_disable, - schizo_intr_assign, - schizo_intr_clear -}; - -struct schizo_icarg { - struct schizo_softc *sica_sc; - bus_addr_t sica_map; - bus_addr_t sica_clr; -}; - -#define SCHIZO_CDMA_TIMEOUT 1 /* 1 second per try */ -#define SCHIZO_CDMA_TRIES 15 -#define SCHIZO_PERF_CNT_QLTY 100 - -#define SCHIZO_SPC_BARRIER(spc, sc, offs, len, flags) \ - bus_barrier((sc)->sc_mem_res[(spc)], (offs), (len), (flags)) -#define SCHIZO_SPC_READ_8(spc, sc, offs) \ - bus_read_8((sc)->sc_mem_res[(spc)], (offs)) -#define SCHIZO_SPC_WRITE_8(spc, sc, offs, v) \ - bus_write_8((sc)->sc_mem_res[(spc)], (offs), (v)) - -#ifndef SCHIZO_DEBUG -#define SCHIZO_SPC_SET(spc, sc, offs, reg, v) \ - SCHIZO_SPC_WRITE_8((spc), (sc), (offs), (v)) -#else -#define SCHIZO_SPC_SET(spc, sc, offs, reg, v) do { \ - device_printf((sc)->sc_dev, reg " 0x%016llx -> 0x%016llx\n", \ - (unsigned long long)SCHIZO_SPC_READ_8((spc), (sc), (offs)), \ - (unsigned long long)(v)); \ - SCHIZO_SPC_WRITE_8((spc), (sc), (offs), (v)); \ - } while (0) -#endif - -#define SCHIZO_PCI_READ_8(sc, offs) \ - SCHIZO_SPC_READ_8(STX_PCI, (sc), (offs)) -#define SCHIZO_PCI_WRITE_8(sc, offs, v) \ - SCHIZO_SPC_WRITE_8(STX_PCI, (sc), (offs), (v)) -#define SCHIZO_CTRL_READ_8(sc, offs) \ - SCHIZO_SPC_READ_8(STX_CTRL, (sc), (offs)) -#define SCHIZO_CTRL_WRITE_8(sc, offs, v) \ - SCHIZO_SPC_WRITE_8(STX_CTRL, (sc), (offs), (v)) -#define SCHIZO_PCICFG_READ_8(sc, offs) \ - SCHIZO_SPC_READ_8(STX_PCICFG, (sc), (offs)) -#define SCHIZO_PCICFG_WRITE_8(sc, offs, v) \ - SCHIZO_SPC_WRITE_8(STX_PCICFG, (sc), (offs), (v)) -#define SCHIZO_ICON_READ_8(sc, offs) \ - SCHIZO_SPC_READ_8(STX_ICON, (sc), (offs)) -#define SCHIZO_ICON_WRITE_8(sc, offs, v) \ - SCHIZO_SPC_WRITE_8(STX_ICON, (sc), (offs), (v)) - -#define SCHIZO_PCI_SET(sc, offs, v) \ - SCHIZO_SPC_SET(STX_PCI, (sc), (offs), # offs, (v)) -#define SCHIZO_CTRL_SET(sc, offs, v) \ - SCHIZO_SPC_SET(STX_CTRL, (sc), (offs), # offs, (v)) - -struct schizo_desc { - const char *sd_string; - int sd_mode; - const char *sd_name; -}; - -static const struct schizo_desc schizo_compats[] = { - { "pci108e,8001", SCHIZO_MODE_SCZ, "Schizo" }, -#if 0 - { "pci108e,8002", SCHIZO_MODE_XMS, "XMITS" }, -#endif - { "pci108e,a801", SCHIZO_MODE_TOM, "Tomatillo" }, - { NULL, 0, NULL } -}; - -static const struct schizo_desc * -schizo_get_desc(device_t dev) -{ - const struct schizo_desc *desc; - const char *compat; - - compat = ofw_bus_get_compat(dev); - if (compat == NULL) - return (NULL); - for (desc = schizo_compats; desc->sd_string != NULL; desc++) - if (strcmp(desc->sd_string, compat) == 0) - return (desc); - return (NULL); -} - -static int -schizo_probe(device_t dev) -{ - const char *dtype; - - dtype = ofw_bus_get_type(dev); - if (dtype != NULL && strcmp(dtype, OFW_TYPE_PCI) == 0 && - schizo_get_desc(dev) != NULL) { - device_set_desc(dev, "Sun Host-PCI bridge"); - return (0); - } - return (ENXIO); -} - -static int -schizo_attach(device_t dev) -{ - const struct schizo_desc *desc; - struct schizo_softc *asc, *sc, *osc; - struct timecounter *tc; - bus_dma_tag_t dmat; - uint64_t ino_bitmap, reg; - phandle_t node; - uint32_t prop, prop_array[2]; - int i, j, mode, rid, tsbsize; - - sc = device_get_softc(dev); - node = ofw_bus_get_node(dev); - desc = schizo_get_desc(dev); - mode = desc->sd_mode; - - sc->sc_dev = dev; - sc->sc_mode = mode; - sc->sc_flags = 0; - - /* - * The Schizo has three register banks: - * (0) per-PBM PCI configuration and status registers, but for bus B - * shared with the UPA64s interrupt mapping register banks - * (1) shared Schizo controller configuration and status registers - * (2) per-PBM PCI configuration space - * - * The Tomatillo has four register banks: - * (0) per-PBM PCI configuration and status registers - * (1) per-PBM Tomatillo controller configuration registers, but on - * machines having the `jbusppm' device shared with its Estar - * register bank for bus A - * (2) per-PBM PCI configuration space - * (3) per-PBM interrupt concentrator registers - */ - sc->sc_half = (bus_get_resource_start(dev, SYS_RES_MEMORY, STX_PCI) >> - 20) & 1; - for (i = 0; i < (mode == SCHIZO_MODE_SCZ ? SCZ_NREG : TOM_NREG); - i++) { - rid = i; - sc->sc_mem_res[i] = bus_alloc_resource_any(dev, - SYS_RES_MEMORY, &rid, - (((mode == SCHIZO_MODE_SCZ && ((sc->sc_half == 1 && - i == STX_PCI) || i == STX_CTRL)) || - (mode == SCHIZO_MODE_TOM && sc->sc_half == 0 && - i == STX_CTRL)) ? RF_SHAREABLE : 0) | RF_ACTIVE); - if (sc->sc_mem_res[i] == NULL) - panic("%s: could not allocate register bank %d", - __func__, i); - } - - /* - * Match other Schizos that are already configured against - * the controller base physical address. This will be the - * same for a pair of devices that share register space. - */ - osc = NULL; - SLIST_FOREACH(asc, &schizo_softcs, sc_link) { - if (rman_get_start(asc->sc_mem_res[STX_CTRL]) == - rman_get_start(sc->sc_mem_res[STX_CTRL])) { - /* Found partner. */ - osc = asc; - break; - } - } - if (osc == NULL) { - sc->sc_mtx = malloc(sizeof(*sc->sc_mtx), M_DEVBUF, - M_NOWAIT | M_ZERO); - if (sc->sc_mtx == NULL) - panic("%s: could not malloc mutex", __func__); - mtx_init(sc->sc_mtx, "pcib_mtx", NULL, MTX_SPIN); - } else { - if (sc->sc_mode != SCHIZO_MODE_SCZ) - panic("%s: no partner expected", __func__); - if (mtx_initialized(osc->sc_mtx) == 0) - panic("%s: mutex not initialized", __func__); - sc->sc_mtx = osc->sc_mtx; - } - SLIST_INSERT_HEAD(&schizo_softcs, sc, sc_link); - - if (OF_getprop(node, "portid", &sc->sc_ign, sizeof(sc->sc_ign)) == -1) - panic("%s: could not determine IGN", __func__); - if (OF_getprop(node, "version#", &sc->sc_ver, sizeof(sc->sc_ver)) == - -1) - panic("%s: could not determine version", __func__); - if (mode == SCHIZO_MODE_XMS && OF_getprop(node, "module-revision#", - &sc->sc_mrev, sizeof(sc->sc_mrev)) == -1) - panic("%s: could not determine module-revision", __func__); - if (OF_getprop(node, "clock-frequency", &prop, sizeof(prop)) == -1) - prop = 33000000; - - if (mode == SCHIZO_MODE_XMS && (SCHIZO_PCI_READ_8(sc, STX_PCI_CTRL) & - XMS_PCI_CTRL_X_MODE) != 0) { - if (sc->sc_mrev < 1) - panic("PCI-X mode unsupported"); - sc->sc_flags |= SCHIZO_FLAGS_XMODE; - } - - device_printf(dev, "%s, version %d, ", desc->sd_name, sc->sc_ver); - if (mode == SCHIZO_MODE_XMS) - printf("module-revision %d, ", sc->sc_mrev); - printf("IGN %#x, bus %c, PCI%s mode, %dMHz\n", sc->sc_ign, - 'A' + sc->sc_half, (sc->sc_flags & SCHIZO_FLAGS_XMODE) != 0 ? - "-X" : "", prop / 1000 / 1000); - - /* Set up the PCI interrupt retry timer. */ - SCHIZO_PCI_SET(sc, STX_PCI_INTR_RETRY_TIM, 5); - - /* Set up the PCI control register. */ - reg = SCHIZO_PCI_READ_8(sc, STX_PCI_CTRL); - reg &= ~(TOM_PCI_CTRL_DTO_IEN | STX_PCI_CTRL_ARB_PARK | - STX_PCI_CTRL_ARB_MASK); - reg |= STX_PCI_CTRL_MMU_IEN | STX_PCI_CTRL_SBH_IEN | - STX_PCI_CTRL_ERR_IEN; - if (OF_getproplen(node, "no-bus-parking") < 0) - reg |= STX_PCI_CTRL_ARB_PARK; - if (mode == SCHIZO_MODE_XMS && sc->sc_mrev == 1) - reg |= XMS_PCI_CTRL_XMITS10_ARB_MASK; - else - reg |= STX_PCI_CTRL_ARB_MASK; - if (mode == SCHIZO_MODE_TOM) { - reg |= TOM_PCI_CTRL_PRM | TOM_PCI_CTRL_PRO | TOM_PCI_CTRL_PRL; - if (sc->sc_ver <= 1) /* revision <= 2.0 */ - reg |= TOM_PCI_CTRL_DTO_IEN; - else - reg |= STX_PCI_CTRL_PTO; - } else if (mode == SCHIZO_MODE_XMS) { - SCHIZO_PCI_SET(sc, XMS_PCI_PARITY_DETECT, 0x3fff); - SCHIZO_PCI_SET(sc, XMS_PCI_UPPER_RETRY_COUNTER, 0x3e8); - reg |= XMS_PCI_CTRL_X_ERRINT_EN; - } - SCHIZO_PCI_SET(sc, STX_PCI_CTRL, reg); - - /* Set up the PCI diagnostic register. */ - reg = SCHIZO_PCI_READ_8(sc, STX_PCI_DIAG); - reg &= ~(SCZ_PCI_DIAG_RTRYARB_DIS | STX_PCI_DIAG_RETRY_DIS | - STX_PCI_DIAG_INTRSYNC_DIS); - SCHIZO_PCI_SET(sc, STX_PCI_DIAG, reg); - - /* - * Enable DMA write parity error interrupts of version >= 7 (i.e. - * revision >= 2.5) Schizo and XMITS (enabling it on XMITS < 3.0 has - * no effect though). - */ - if ((mode == SCHIZO_MODE_SCZ && sc->sc_ver >= 7) || - mode == SCHIZO_MODE_XMS) { - reg = SCHIZO_PCI_READ_8(sc, SX_PCI_CFG_ICD); - reg |= SX_PCI_CFG_ICD_DMAW_PERR_IEN; - SCHIZO_PCI_SET(sc, SX_PCI_CFG_ICD, reg); - } - - /* - * On Tomatillo clear the I/O prefetch lengths (workaround for a - * Jalapeno bug). - */ - if (mode == SCHIZO_MODE_TOM) - SCHIZO_PCI_SET(sc, TOM_PCI_IOC_CSR, TOM_PCI_IOC_PW | - (1 << TOM_PCI_IOC_PREF_OFF_SHIFT) | TOM_PCI_IOC_CPRM | - TOM_PCI_IOC_CPRO | TOM_PCI_IOC_CPRL); - - /* - * Hunt through all the interrupt mapping regs and register - * the interrupt controller for our interrupt vectors. We do - * this early in order to be able to catch stray interrupts. - * This is complicated by the fact that a pair of Schizo PBMs - * shares one IGN. - */ - i = OF_getprop(node, "ino-bitmap", (void *)prop_array, - sizeof(prop_array)); - if (i != -1) - ino_bitmap = ((uint64_t)prop_array[1] << 32) | prop_array[0]; - else { - /* - * If the ino-bitmap property is missing, just provide the - * default set of interrupts for this controller and let - * schizo_setup_intr() take care of child interrupts. - */ - if (sc->sc_half == 0) - ino_bitmap = (1ULL << STX_UE_INO) | - (1ULL << STX_CE_INO) | - (1ULL << STX_PCIERR_A_INO) | - (1ULL << STX_BUS_INO); - else - ino_bitmap = 1ULL << STX_PCIERR_B_INO; - } - for (i = 0; i <= STX_MAX_INO; i++) { - if ((ino_bitmap & (1ULL << i)) == 0) - continue; - if (i == STX_FB0_INO || i == STX_FB1_INO) - /* Leave for upa(4). */ - continue; - j = schizo_intr_register(sc, i); - if (j != 0) - device_printf(dev, "could not register interrupt " - "controller for INO %d (%d)\n", i, j); - } - - /* - * Setup Safari/JBus performance counter 0 in bus cycle counting - * mode as timecounter. Unfortunately, this is broken with at - * least the version 4 Tomatillos found in Fire V120 and Blade - * 1500, which apparently actually count some different event at - * ~0.5 and 3MHz respectively instead (also when running in full - * power mode). Besides, one counter seems to be shared by a - * "pair" of Tomatillos, too. - */ - if (sc->sc_half == 0) { - SCHIZO_CTRL_SET(sc, STX_CTRL_PERF, - (STX_CTRL_PERF_DIS << STX_CTRL_PERF_CNT1_SHIFT) | - (STX_CTRL_PERF_BUSCYC << STX_CTRL_PERF_CNT0_SHIFT)); - tc = malloc(sizeof(*tc), M_DEVBUF, M_NOWAIT | M_ZERO); - if (tc == NULL) - panic("%s: could not malloc timecounter", __func__); - tc->tc_get_timecount = schizo_get_timecount; - tc->tc_counter_mask = STX_CTRL_PERF_CNT_MASK; - if (OF_getprop(OF_peer(0), "clock-frequency", &prop, - sizeof(prop)) == -1) - panic("%s: could not determine clock frequency", - __func__); - tc->tc_frequency = prop; - tc->tc_name = strdup(device_get_nameunit(dev), M_DEVBUF); - if (mode == SCHIZO_MODE_SCZ) - tc->tc_quality = SCHIZO_PERF_CNT_QLTY; - else - tc->tc_quality = -SCHIZO_PERF_CNT_QLTY; - tc->tc_priv = sc; - tc_init(tc); - } - - /* - * Set up the IOMMU. Schizo, Tomatillo and XMITS all have - * one per PBM. Schizo and XMITS additionally have a streaming - * buffer, in Schizo version < 5 (i.e. revision < 2.3) it's - * affected by several errata though. However, except for context - * flushes, taking advantage of it should be okay even with those. - */ - memcpy(&sc->sc_dma_methods, &iommu_dma_methods, - sizeof(sc->sc_dma_methods)); - sc->sc_is.sis_sc = sc; - sc->sc_is.sis_is.is_flags = IOMMU_PRESERVE_PROM; - sc->sc_is.sis_is.is_pmaxaddr = IOMMU_MAXADDR(STX_IOMMU_BITS); - sc->sc_is.sis_is.is_sb[0] = sc->sc_is.sis_is.is_sb[1] = 0; - if (OF_getproplen(node, "no-streaming-cache") < 0) - sc->sc_is.sis_is.is_sb[0] = STX_PCI_STRBUF; - -#define TSBCASE(x) \ - case (IOTSB_BASESZ << (x)) << (IO_PAGE_SHIFT - IOTTE_SHIFT): \ - tsbsize = (x); \ - break; \ - - i = OF_getprop(node, "virtual-dma", (void *)prop_array, - sizeof(prop_array)); - if (i == -1 || i != sizeof(prop_array)) - schizo_iommu_init(sc, 7, -1); - else { - switch (prop_array[1]) { - TSBCASE(1); - TSBCASE(2); - TSBCASE(3); - TSBCASE(4); - TSBCASE(5); - TSBCASE(6); - TSBCASE(7); - TSBCASE(8); - default: - panic("%s: unsupported DVMA size 0x%x", - __func__, prop_array[1]); - /* NOTREACHED */ - } - schizo_iommu_init(sc, tsbsize, prop_array[0]); - } - -#undef TSBCASE - - /* Create our DMA tag. */ - if (bus_dma_tag_create(bus_get_dma_tag(dev), 8, 0, - sc->sc_is.sis_is.is_pmaxaddr, ~0, NULL, NULL, - sc->sc_is.sis_is.is_pmaxaddr, 0xff, 0xffffffff, 0, NULL, NULL, - &dmat) != 0) - panic("%s: could not create PCI DMA tag", __func__); - dmat->dt_cookie = &sc->sc_is; - dmat->dt_mt = &sc->sc_dma_methods; - - if (ofw_pci_attach_common(dev, dmat, STX_IO_SIZE, STX_MEM_SIZE) != 0) - panic("%s: ofw_pci_attach_common() failed", __func__); - - /* Clear any pending PCI error bits. */ - PCIB_WRITE_CONFIG(dev, sc->sc_ops.sc_pci_secbus, STX_CS_DEVICE, - STX_CS_FUNC, PCIR_STATUS, PCIB_READ_CONFIG(dev, - sc->sc_ops.sc_pci_secbus, STX_CS_DEVICE, STX_CS_FUNC, PCIR_STATUS, - 2), 2); - SCHIZO_PCI_SET(sc, STX_PCI_CTRL, SCHIZO_PCI_READ_8(sc, STX_PCI_CTRL)); - SCHIZO_PCI_SET(sc, STX_PCI_AFSR, SCHIZO_PCI_READ_8(sc, STX_PCI_AFSR)); - - /* - * Establish handlers for interesting interrupts... - * Someone at Sun clearly was smoking crack; with Schizos PCI - * bus error interrupts for one PBM can be routed to the other - * PBM though we obviously need to use the softc of the former - * as the argument for the interrupt handler and the softc of - * the latter as the argument for the interrupt controller. - */ - if (sc->sc_half == 0) { - if ((ino_bitmap & (1ULL << STX_PCIERR_A_INO)) != 0 || - (osc != NULL && ((struct schizo_icarg *)intr_vectors[ - INTMAP_VEC(sc->sc_ign, STX_PCIERR_A_INO)].iv_icarg)-> - sica_sc == osc)) - /* - * We are the driver for PBM A and either also - * registered the interrupt controller for us or - * the driver for PBM B has probed first and - * registered it for us. - */ - schizo_set_intr(sc, 0, STX_PCIERR_A_INO, - schizo_pci_bus); - if ((ino_bitmap & (1ULL << STX_PCIERR_B_INO)) != 0 && - osc != NULL) - /* - * We are the driver for PBM A but registered - * the interrupt controller for PBM B, i.e. the - * driver for PBM B attached first but couldn't - * set up a handler for PBM B. - */ - schizo_set_intr(osc, 0, STX_PCIERR_B_INO, - schizo_pci_bus); - } else { - if ((ino_bitmap & (1ULL << STX_PCIERR_B_INO)) != 0 || - (osc != NULL && ((struct schizo_icarg *)intr_vectors[ - INTMAP_VEC(sc->sc_ign, STX_PCIERR_B_INO)].iv_icarg)-> - sica_sc == osc)) - /* - * We are the driver for PBM B and either also - * registered the interrupt controller for us or - * the driver for PBM A has probed first and - * registered it for us. - */ - schizo_set_intr(sc, 0, STX_PCIERR_B_INO, - schizo_pci_bus); - if ((ino_bitmap & (1ULL << STX_PCIERR_A_INO)) != 0 && - osc != NULL) - /* - * We are the driver for PBM B but registered - * the interrupt controller for PBM A, i.e. the - * driver for PBM A attached first but couldn't - * set up a handler for PBM A. - */ - schizo_set_intr(osc, 0, STX_PCIERR_A_INO, - schizo_pci_bus); - } - if ((ino_bitmap & (1ULL << STX_UE_INO)) != 0) - schizo_set_intr(sc, 1, STX_UE_INO, schizo_ue); - if ((ino_bitmap & (1ULL << STX_CE_INO)) != 0) - schizo_set_intr(sc, 2, STX_CE_INO, schizo_ce); - if ((ino_bitmap & (1ULL << STX_BUS_INO)) != 0) - schizo_set_intr(sc, 3, STX_BUS_INO, schizo_host_bus); - - /* - * According to the Schizo Errata I-13, consistent DMA flushing/ - * syncing is FUBAR in version < 5 (i.e. revision < 2.3) bridges, - * so we can't use it and need to live with the consequences. With - * Schizo version >= 5, CDMA flushing/syncing is usable but requires - * the workaround described in Schizo Errata I-23. With Tomatillo - * and XMITS, CDMA flushing/syncing works as expected, Tomatillo - * version <= 4 (i.e. revision <= 2.3) bridges additionally require - * a block store after a write to TOMXMS_PCI_DMA_SYNC_PEND though. - */ - if ((sc->sc_mode == SCHIZO_MODE_SCZ && sc->sc_ver >= 5) || - sc->sc_mode == SCHIZO_MODE_TOM || - sc->sc_mode == SCHIZO_MODE_XMS) { - if (sc->sc_mode == SCHIZO_MODE_SCZ) { - sc->sc_dma_methods.dm_dmamap_sync = - schizo_dmamap_sync; - sc->sc_cdma_state = SCHIZO_CDMA_STATE_IDLE; - /* - * Some firmware versions include the CDMA interrupt - * at RID 4 but most don't. With the latter we add - * it ourselves at the spare RID 5. - */ - i = INTINO(bus_get_resource_start(dev, SYS_RES_IRQ, - 4)); - if (i == STX_CDMA_A_INO || i == STX_CDMA_B_INO) { - sc->sc_cdma_vec = INTMAP_VEC(sc->sc_ign, i); - (void)schizo_get_intrmap(sc, i, - &sc->sc_cdma_map, &sc->sc_cdma_clr); - schizo_set_intr(sc, 4, i, schizo_cdma); - } else { - i = STX_CDMA_A_INO + sc->sc_half; - sc->sc_cdma_vec = INTMAP_VEC(sc->sc_ign, i); - if (bus_set_resource(dev, SYS_RES_IRQ, 5, - sc->sc_cdma_vec, 1) != 0) - panic("%s: failed to add CDMA " - "interrupt", __func__); - j = schizo_intr_register(sc, i); - if (j != 0) - panic("%s: could not register " - "interrupt controller for CDMA " - "(%d)", __func__, j); - (void)schizo_get_intrmap(sc, i, - &sc->sc_cdma_map, &sc->sc_cdma_clr); - schizo_set_intr(sc, 5, i, schizo_cdma); - } - } else { - if (sc->sc_mode == SCHIZO_MODE_XMS) - mtx_init(&sc->sc_sync_mtx, "pcib_sync_mtx", - NULL, MTX_SPIN); - sc->sc_sync_val = 1ULL << (STX_PCIERR_A_INO + - sc->sc_half); - sc->sc_dma_methods.dm_dmamap_sync = - ichip_dmamap_sync; - } - if (sc->sc_mode == SCHIZO_MODE_TOM && sc->sc_ver <= 4) - sc->sc_flags |= SCHIZO_FLAGS_BSWAR; - } - - /* - * Set the latency timer register as this isn't always done by the - * firmware. - */ - PCIB_WRITE_CONFIG(dev, sc->sc_ops.sc_pci_secbus, STX_CS_DEVICE, - STX_CS_FUNC, PCIR_LATTIMER, OFW_PCI_LATENCY, 1); - -#define SCHIZO_SYSCTL_ADD_UINT(name, arg, desc) \ - SYSCTL_ADD_UINT(device_get_sysctl_ctx(dev), \ - SYSCTL_CHILDREN(device_get_sysctl_tree(dev)), OID_AUTO, \ - (name), CTLFLAG_RD, (arg), 0, (desc)) - - SCHIZO_SYSCTL_ADD_UINT("dma_ce", &sc->sc_stats_dma_ce, - "DMA correctable errors"); - SCHIZO_SYSCTL_ADD_UINT("pci_non_fatal", &sc->sc_stats_pci_non_fatal, - "PCI bus non-fatal errors"); - -#undef SCHIZO_SYSCTL_ADD_UINT - - device_add_child(dev, "pci", -1); - return (bus_generic_attach(dev)); -} - -static void -schizo_set_intr(struct schizo_softc *sc, u_int index, u_int ino, - driver_filter_t handler) -{ - u_long vec; - int rid; - - rid = index; - sc->sc_irq_res[index] = bus_alloc_resource_any(sc->sc_dev, - SYS_RES_IRQ, &rid, RF_ACTIVE); - if (sc->sc_irq_res[index] == NULL || - INTINO(vec = rman_get_start(sc->sc_irq_res[index])) != ino || - INTIGN(vec) != sc->sc_ign || - intr_vectors[vec].iv_ic != &schizo_ic || - bus_setup_intr(sc->sc_dev, sc->sc_irq_res[index], - INTR_TYPE_MISC | INTR_BRIDGE, handler, NULL, sc, - &sc->sc_ihand[index]) != 0) - panic("%s: failed to set up interrupt %d", __func__, index); -} - -static int -schizo_intr_register(struct schizo_softc *sc, u_int ino) -{ - struct schizo_icarg *sica; - bus_addr_t intrclr, intrmap; - int error; - - if (schizo_get_intrmap(sc, ino, &intrmap, &intrclr) == 0) - return (ENXIO); - sica = malloc(sizeof(*sica), M_DEVBUF, M_NOWAIT); - if (sica == NULL) - return (ENOMEM); - sica->sica_sc = sc; - sica->sica_map = intrmap; - sica->sica_clr = intrclr; -#ifdef SCHIZO_DEBUG - device_printf(sc->sc_dev, "intr map (INO %d) %#lx: %#lx, clr: %#lx\n", - ino, (u_long)intrmap, (u_long)SCHIZO_PCI_READ_8(sc, intrmap), - (u_long)intrclr); -#endif - error = (intr_controller_register(INTMAP_VEC(sc->sc_ign, ino), - &schizo_ic, sica)); - if (error != 0) - free(sica, M_DEVBUF); - return (error); -} - -static int -schizo_get_intrmap(struct schizo_softc *sc, u_int ino, - bus_addr_t *intrmapptr, bus_addr_t *intrclrptr) -{ - bus_addr_t intrclr, intrmap; - uint64_t mr; - - /* - * XXX we only look for INOs rather than INRs since the firmware - * may not provide the IGN and the IGN is constant for all devices - * on that PCI controller. - */ - - if (ino > STX_MAX_INO) { - device_printf(sc->sc_dev, "out of range INO %d requested\n", - ino); - return (0); - } - - intrmap = STX_PCI_IMAP_BASE + (ino << 3); - intrclr = STX_PCI_ICLR_BASE + (ino << 3); - mr = SCHIZO_PCI_READ_8(sc, intrmap); - if (INTINO(mr) != ino) { - device_printf(sc->sc_dev, - "interrupt map entry does not match INO (%d != %d)\n", - (int)INTINO(mr), ino); - return (0); - } - - if (intrmapptr != NULL) - *intrmapptr = intrmap; - if (intrclrptr != NULL) - *intrclrptr = intrclr; - return (1); -} - -/* - * Interrupt handlers - */ -static int -schizo_pci_bus(void *arg) -{ - struct schizo_softc *sc = arg; - uint64_t afar, afsr, csr, iommu, xstat; - uint32_t status; - u_int fatal; - - fatal = 0; - - mtx_lock_spin(sc->sc_mtx); - - afar = SCHIZO_PCI_READ_8(sc, STX_PCI_AFAR); - afsr = SCHIZO_PCI_READ_8(sc, STX_PCI_AFSR); - csr = SCHIZO_PCI_READ_8(sc, STX_PCI_CTRL); - iommu = SCHIZO_PCI_READ_8(sc, STX_PCI_IOMMU); - if ((sc->sc_flags & SCHIZO_FLAGS_XMODE) != 0) - xstat = SCHIZO_PCI_READ_8(sc, XMS_PCI_X_ERR_STAT); - else - xstat = 0; - status = PCIB_READ_CONFIG(sc->sc_dev, sc->sc_ops.sc_pci_secbus, - STX_CS_DEVICE, STX_CS_FUNC, PCIR_STATUS, 2); - - /* - * IOMMU errors are only fatal on Tomatillo and there also only if - * target abort was not signaled. - */ - if ((csr & STX_PCI_CTRL_MMU_ERR) != 0 && - (iommu & TOM_PCI_IOMMU_ERR) != 0 && - ((status & PCIM_STATUS_STABORT) == 0 || - ((iommu & TOM_PCI_IOMMU_ERRMASK) != TOM_PCI_IOMMU_INVALID_ERR && - (iommu & TOM_PCI_IOMMU_ERR_ILLTSBTBW) == 0 && - (iommu & TOM_PCI_IOMMU_ERR_BAD_VA) == 0))) - fatal = 1; - else if ((status & PCIM_STATUS_STABORT) != 0) - fatal = 1; - if ((status & (PCIM_STATUS_PERR | PCIM_STATUS_SERR | - PCIM_STATUS_RMABORT | PCIM_STATUS_RTABORT | - PCIM_STATUS_MDPERR)) != 0 || - (csr & (SCZ_PCI_CTRL_BUS_UNUS | TOM_PCI_CTRL_DTO_ERR | - STX_PCI_CTRL_TTO_ERR | STX_PCI_CTRL_RTRY_ERR | - SCZ_PCI_CTRL_SBH_ERR | STX_PCI_CTRL_SERR)) != 0 || - (afsr & (STX_PCI_AFSR_P_MA | STX_PCI_AFSR_P_TA | - STX_PCI_AFSR_P_RTRY | STX_PCI_AFSR_P_PERR | STX_PCI_AFSR_P_TTO | - STX_PCI_AFSR_P_UNUS)) != 0) - fatal = 1; - if (xstat & (XMS_PCI_X_ERR_STAT_P_SC_DSCRD | - XMS_PCI_X_ERR_STAT_P_SC_TTO | XMS_PCI_X_ERR_STAT_P_SDSTAT | - XMS_PCI_X_ERR_STAT_P_SMMU | XMS_PCI_X_ERR_STAT_P_CDSTAT | - XMS_PCI_X_ERR_STAT_P_CMMU | XMS_PCI_X_ERR_STAT_PERR_RCV)) - fatal = 1; - if (fatal == 0) - sc->sc_stats_pci_non_fatal++; - - device_printf(sc->sc_dev, "PCI bus %c error AFAR %#llx AFSR %#llx " - "PCI CSR %#llx IOMMU %#llx PCI-X %#llx STATUS %#x\n", - 'A' + sc->sc_half, (unsigned long long)afar, - (unsigned long long)afsr, (unsigned long long)csr, - (unsigned long long)iommu, (unsigned long long)xstat, status); - - /* Clear the error bits that we caught. */ - PCIB_WRITE_CONFIG(sc->sc_dev, sc->sc_ops.sc_pci_secbus, STX_CS_DEVICE, - STX_CS_FUNC, PCIR_STATUS, status, 2); - SCHIZO_PCI_WRITE_8(sc, STX_PCI_CTRL, csr); - SCHIZO_PCI_WRITE_8(sc, STX_PCI_AFSR, afsr); - SCHIZO_PCI_WRITE_8(sc, STX_PCI_IOMMU, iommu); - if ((sc->sc_flags & SCHIZO_FLAGS_XMODE) != 0) - SCHIZO_PCI_WRITE_8(sc, XMS_PCI_X_ERR_STAT, xstat); - - mtx_unlock_spin(sc->sc_mtx); - - if (fatal != 0) - panic("%s: fatal PCI bus error", - device_get_nameunit(sc->sc_dev)); - return (FILTER_HANDLED); -} - -static int -schizo_ue(void *arg) -{ - struct schizo_softc *sc = arg; - uint64_t afar, afsr; - int i; - - afar = SCHIZO_CTRL_READ_8(sc, STX_CTRL_UE_AFAR); - for (i = 0; i < 1000; i++) - if (((afsr = SCHIZO_CTRL_READ_8(sc, STX_CTRL_UE_AFSR)) & - STX_CTRL_CE_AFSR_ERRPNDG) == 0) - break; - panic("%s: uncorrectable DMA error AFAR %#llx AFSR %#llx", - device_get_nameunit(sc->sc_dev), (unsigned long long)afar, - (unsigned long long)afsr); - return (FILTER_HANDLED); -} - -static int -schizo_ce(void *arg) -{ - struct schizo_softc *sc = arg; - uint64_t afar, afsr; - int i; - - mtx_lock_spin(sc->sc_mtx); - - afar = SCHIZO_CTRL_READ_8(sc, STX_CTRL_CE_AFAR); - for (i = 0; i < 1000; i++) - if (((afsr = SCHIZO_CTRL_READ_8(sc, STX_CTRL_UE_AFSR)) & - STX_CTRL_CE_AFSR_ERRPNDG) == 0) - break; - sc->sc_stats_dma_ce++; - device_printf(sc->sc_dev, - "correctable DMA error AFAR %#llx AFSR %#llx\n", - (unsigned long long)afar, (unsigned long long)afsr); - - /* Clear the error bits that we caught. */ - SCHIZO_CTRL_WRITE_8(sc, STX_CTRL_UE_AFSR, afsr); - - mtx_unlock_spin(sc->sc_mtx); - - return (FILTER_HANDLED); -} - -static int -schizo_host_bus(void *arg) -{ - struct schizo_softc *sc = arg; - uint64_t errlog; - - errlog = SCHIZO_CTRL_READ_8(sc, STX_CTRL_BUS_ERRLOG); - panic("%s: %s error %#llx", device_get_nameunit(sc->sc_dev), - sc->sc_mode == SCHIZO_MODE_TOM ? "JBus" : "Safari", - (unsigned long long)errlog); - return (FILTER_HANDLED); -} - -static int -schizo_cdma(void *arg) -{ - struct schizo_softc *sc = arg; - - atomic_cmpset_32(&sc->sc_cdma_state, SCHIZO_CDMA_STATE_PENDING, - SCHIZO_CDMA_STATE_RECEIVED); - return (FILTER_HANDLED); -} - -static void -schizo_iommu_init(struct schizo_softc *sc, int tsbsize, uint32_t dvmabase) -{ - - /* Punch in our copies. */ - sc->sc_is.sis_is.is_bustag = rman_get_bustag(sc->sc_mem_res[STX_PCI]); - sc->sc_is.sis_is.is_bushandle = - rman_get_bushandle(sc->sc_mem_res[STX_PCI]); - sc->sc_is.sis_is.is_iommu = STX_PCI_IOMMU; - sc->sc_is.sis_is.is_dtag = STX_PCI_IOMMU_TLB_TAG_DIAG; - sc->sc_is.sis_is.is_ddram = STX_PCI_IOMMU_TLB_DATA_DIAG; - sc->sc_is.sis_is.is_dqueue = STX_PCI_IOMMU_QUEUE_DIAG; - sc->sc_is.sis_is.is_dva = STX_PCI_IOMMU_SVADIAG; - sc->sc_is.sis_is.is_dtcmp = STX_PCI_IOMMU_TLB_CMP_DIAG; - - iommu_init(device_get_nameunit(sc->sc_dev), - (struct iommu_state *)&sc->sc_is, tsbsize, dvmabase, 0); -} - -static int -schizo_maxslots(device_t dev) -{ - struct schizo_softc *sc; - - sc = device_get_softc(dev); - if (sc->sc_mode == SCHIZO_MODE_SCZ) - return (sc->sc_half == 0 ? 4 : 6); - - /* XXX: is this correct? */ - return (PCI_SLOTMAX); -} - -static uint32_t -schizo_read_config(device_t dev, u_int bus, u_int slot, u_int func, u_int reg, - int width) -{ - struct schizo_softc *sc; - - sc = device_get_softc(dev); - /* - * The Schizo bridges contain a dupe of their header at 0x80. - */ - if (sc->sc_mode == SCHIZO_MODE_SCZ && - bus == sc->sc_ops.sc_pci_secbus && slot == STX_CS_DEVICE && - func == STX_CS_FUNC && reg + width > 0x80) - return (0); - - return (ofw_pci_read_config_common(dev, PCI_REGMAX, STX_CONF_OFF(bus, - slot, func, reg), bus, slot, func, reg, width)); -} - -static void -schizo_write_config(device_t dev, u_int bus, u_int slot, u_int func, - u_int reg, uint32_t val, int width) -{ - - ofw_pci_write_config_common(dev, PCI_REGMAX, STX_CONF_OFF(bus, slot, - func, reg), bus, slot, func, reg, val, width); -} - -static int -schizo_route_interrupt(device_t bridge, device_t dev, int pin) -{ - ofw_pci_intr_t mintr; - - mintr = ofw_pci_route_interrupt_common(bridge, dev, pin); - if (!PCI_INTERRUPT_VALID(mintr)) - device_printf(bridge, - "could not route pin %d for device %d.%d\n", - pin, pci_get_slot(dev), pci_get_function(dev)); - return (mintr); -} - -static void -schizo_dmamap_sync(bus_dma_tag_t dt, bus_dmamap_t map, bus_dmasync_op_t op) -{ - struct timeval cur, end; - struct schizo_iommu_state *sis = dt->dt_cookie; - struct schizo_softc *sc = sis->sis_sc; - int i, res; -#ifdef INVARIANTS - register_t pil; -#endif - - if ((map->dm_flags & DMF_STREAMED) != 0) { - iommu_dma_methods.dm_dmamap_sync(dt, map, op); - return; - } - - if ((map->dm_flags & DMF_LOADED) == 0) - return; - - if ((op & BUS_DMASYNC_POSTREAD) != 0) { - /* - * Note that in order to allow this function to be called from - * filters we would need to use a spin mutex for serialization - * but given that these disable interrupts we have to emulate - * one. - */ - critical_enter(); - KASSERT((rdpr(pstate) & PSTATE_IE) != 0, - ("%s: interrupts disabled", __func__)); - KASSERT((pil = rdpr(pil)) <= PIL_BRIDGE, - ("%s: PIL too low (%ld)", __func__, pil)); - for (; atomic_cmpset_acq_32(&sc->sc_cdma_state, - SCHIZO_CDMA_STATE_IDLE, SCHIZO_CDMA_STATE_PENDING) == 0;) - ; - SCHIZO_PCI_WRITE_8(sc, sc->sc_cdma_map, - INTMAP_ENABLE(sc->sc_cdma_vec, PCPU_GET(mid))); - for (i = 0; i < SCHIZO_CDMA_TRIES; i++) { - if (i > 0) - printf("%s: try %d\n", __func__, i); - SCHIZO_PCI_WRITE_8(sc, sc->sc_cdma_clr, - INTCLR_RECEIVED); - microuptime(&cur); - end.tv_sec = SCHIZO_CDMA_TIMEOUT; - end.tv_usec = 0; - timevaladd(&end, &cur); - for (; (res = atomic_cmpset_rel_32(&sc->sc_cdma_state, - SCHIZO_CDMA_STATE_RECEIVED, - SCHIZO_CDMA_STATE_IDLE)) == 0 && - timevalcmp(&cur, &end, <=);) - microuptime(&cur); - if (res != 0) - break; - } - if (res == 0) - panic("%s: DMA does not sync", __func__); - critical_exit(); - } - - if ((op & BUS_DMASYNC_PREWRITE) != 0) - membar(Sync); -} - -static void -ichip_dmamap_sync(bus_dma_tag_t dt, bus_dmamap_t map, bus_dmasync_op_t op) -{ - struct timeval cur, end; - struct schizo_iommu_state *sis = dt->dt_cookie; - struct schizo_softc *sc = sis->sis_sc; - uint64_t reg; - - if ((map->dm_flags & DMF_STREAMED) != 0) { - iommu_dma_methods.dm_dmamap_sync(dt, map, op); - return; - } - - if ((map->dm_flags & DMF_LOADED) == 0) - return; - - if ((op & BUS_DMASYNC_POSTREAD) != 0) { - if (sc->sc_mode == SCHIZO_MODE_XMS) - mtx_lock_spin(&sc->sc_sync_mtx); - SCHIZO_PCI_WRITE_8(sc, TOMXMS_PCI_DMA_SYNC_PEND, - sc->sc_sync_val); - microuptime(&cur); - end.tv_sec = 1; - end.tv_usec = 0; - timevaladd(&end, &cur); - for (; ((reg = SCHIZO_PCI_READ_8(sc, - TOMXMS_PCI_DMA_SYNC_PEND)) & sc->sc_sync_val) != 0 && - timevalcmp(&cur, &end, <=);) - microuptime(&cur); - if ((reg & sc->sc_sync_val) != 0) - panic("%s: DMA does not sync", __func__); - if (sc->sc_mode == SCHIZO_MODE_XMS) - mtx_unlock_spin(&sc->sc_sync_mtx); - else if ((sc->sc_flags & SCHIZO_FLAGS_BSWAR) != 0) { - ofw_pci_dmamap_sync_stst_order_common(); - return; - } - } - - if ((op & BUS_DMASYNC_PREWRITE) != 0) - membar(Sync); -} - -static void -schizo_intr_enable(void *arg) -{ - struct intr_vector *iv = arg; - struct schizo_icarg *sica = iv->iv_icarg; - - SCHIZO_PCI_WRITE_8(sica->sica_sc, sica->sica_map, - INTMAP_ENABLE(iv->iv_vec, iv->iv_mid)); -} - -static void -schizo_intr_disable(void *arg) -{ - struct intr_vector *iv = arg; - struct schizo_icarg *sica = iv->iv_icarg; - - SCHIZO_PCI_WRITE_8(sica->sica_sc, sica->sica_map, iv->iv_vec); -} - -static void -schizo_intr_assign(void *arg) -{ - struct intr_vector *iv = arg; - struct schizo_icarg *sica = iv->iv_icarg; - - SCHIZO_PCI_WRITE_8(sica->sica_sc, sica->sica_map, INTMAP_TID( - SCHIZO_PCI_READ_8(sica->sica_sc, sica->sica_map), iv->iv_mid)); -} - -static void -schizo_intr_clear(void *arg) -{ - struct intr_vector *iv = arg; - struct schizo_icarg *sica = iv->iv_icarg; - - SCHIZO_PCI_WRITE_8(sica->sica_sc, sica->sica_clr, INTCLR_IDLE); -} - -static int -schizo_setup_intr(device_t dev, device_t child, struct resource *ires, - int flags, driver_filter_t *filt, driver_intr_t *intr, void *arg, - void **cookiep) -{ - struct schizo_softc *sc; - u_long vec; - int error; - - sc = device_get_softc(dev); - /* - * Make sure the vector is fully specified. - */ - vec = rman_get_start(ires); - if (INTIGN(vec) != sc->sc_ign) { - device_printf(dev, "invalid interrupt vector 0x%lx\n", vec); - return (EINVAL); - } - - if (intr_vectors[vec].iv_ic == &schizo_ic) { - /* - * Ensure we use the right softc in case the interrupt - * is routed to our companion PBM for some odd reason. - */ - sc = ((struct schizo_icarg *)intr_vectors[vec].iv_icarg)-> - sica_sc; - } else if (intr_vectors[vec].iv_ic == NULL) { - /* - * Work around broken firmware which misses entries in - * the ino-bitmap. - */ - error = schizo_intr_register(sc, INTINO(vec)); - if (error != 0) { - device_printf(dev, "could not register interrupt " - "controller for vector 0x%lx (%d)\n", vec, error); - return (error); - } - if (bootverbose) - device_printf(dev, "belatedly registered as " - "interrupt controller for vector 0x%lx\n", vec); - } else { - device_printf(dev, - "invalid interrupt controller for vector 0x%lx\n", vec); - return (EINVAL); - } - return (bus_generic_setup_intr(dev, child, ires, flags, filt, intr, - arg, cookiep)); -} - -static struct resource * -schizo_alloc_resource(device_t bus, device_t child, int type, int *rid, - rman_res_t start, rman_res_t end, rman_res_t count, u_int flags) -{ - struct schizo_softc *sc; - - if (type == SYS_RES_IRQ) { - sc = device_get_softc(bus); - start = end = INTMAP_VEC(sc->sc_ign, end); - } - return (ofw_pci_alloc_resource(bus, child, type, rid, start, end, - count, flags)); -} - -static void -schizo_setup_device(device_t bus, device_t child) -{ - struct schizo_softc *sc; - uint64_t reg; - int capreg; - - sc = device_get_softc(bus); - /* - * Disable bus parking in order to work around a bus hang caused by - * Casinni/Skyhawk combinations. - */ - if (OF_getproplen(ofw_bus_get_node(child), "pci-req-removal") >= 0) - SCHIZO_PCI_SET(sc, STX_PCI_CTRL, SCHIZO_PCI_READ_8(sc, - STX_PCI_CTRL) & ~STX_PCI_CTRL_ARB_PARK); - - if (sc->sc_mode == SCHIZO_MODE_XMS) { - /* XMITS NCPQ WAR: set outstanding split transactions to 1. */ - if ((sc->sc_flags & SCHIZO_FLAGS_XMODE) != 0 && - (pci_read_config(child, PCIR_HDRTYPE, 1) & - PCIM_HDRTYPE) != PCIM_HDRTYPE_BRIDGE && - pci_find_cap(child, PCIY_PCIX, &capreg) == 0) - pci_write_config(child, capreg + PCIXR_COMMAND, - pci_read_config(child, capreg + PCIXR_COMMAND, - 2) & 0x7c, 2); - /* XMITS 3.x WAR: set BUGCNTL iff value is unexpected. */ - if (sc->sc_mrev >= 4) { - reg = ((sc->sc_flags & SCHIZO_FLAGS_XMODE) != 0 ? - 0xa0UL : 0xffUL) << XMS_PCI_X_DIAG_BUGCNTL_SHIFT; - if ((SCHIZO_PCI_READ_8(sc, XMS_PCI_X_DIAG) & - XMS_PCI_X_DIAG_BUGCNTL_MASK) != reg) - SCHIZO_PCI_SET(sc, XMS_PCI_X_DIAG, reg); - } - } -} - -static u_int -schizo_get_timecount(struct timecounter *tc) -{ - struct schizo_softc *sc; - - sc = tc->tc_priv; - return ((SCHIZO_CTRL_READ_8(sc, STX_CTRL_PERF_CNT) & - (STX_CTRL_PERF_CNT_MASK << STX_CTRL_PERF_CNT_CNT0_SHIFT)) >> - STX_CTRL_PERF_CNT_CNT0_SHIFT); -} diff --git a/sys/sparc64/pci/schizoreg.h b/sys/sparc64/pci/schizoreg.h deleted file mode 100644 index 0640df4b744f..000000000000 --- a/sys/sparc64/pci/schizoreg.h +++ /dev/null @@ -1,359 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD - * - * Copyright (c) 2002 Jason L. Wright (jason@thought.net) - * Copyright (c) 2005 by Marius Strobl - * 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 ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULLAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR 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. - * - * from: OpenBSD: schizoreg.h,v 1.8 2005/05/19 18:28:59 mickey Exp - * $FreeBSD$ - */ - -#ifndef _SPARC64_PCI_SCHIZOREG_H_ -#define _SPARC64_PCI_SCHIZOREG_H_ - -#define STX_NINTR 5 /* 4 via OFW + 1 CDMA */ -#define SCZ_NREG 3 -#define TOM_NREG 4 - -#define STX_PCI 0 -#define STX_CTRL 1 -#define STX_PCICFG 2 -#define STX_ICON 3 - -/* PCI configuration and status registers */ -#define SX_PCI_CFG_ICD 0x00110 -#define STX_PCI_IOMMU 0x00200 -#define STX_PCI_IOMMU_CTXFLUSH 0x00218 -#define STX_PCI_IMAP_BASE 0x01000 -#define STX_PCI_ICLR_BASE 0x01400 -#define STX_PCI_INTR_RETRY_TIM 0x01a00 -#define SCZ_PCI_DMA_SYNC 0x01a08 -#define TOM_PCI_DMA_SYNC_COMP 0x01a10 -#define TOMXMS_PCI_DMA_SYNC_PEND 0x01a18 -#define STX_PCI_CTRL 0x02000 -#define STX_PCI_AFSR 0x02010 -#define STX_PCI_AFAR 0x02018 -#define STX_PCI_DIAG 0x02020 -#define XMS_PCI_PARITY_DETECT 0x02040 -#define TOM_PCI_IOC_CSR 0x02248 -#define TOM_PCI_IOC_TAG 0x02290 -#define TOM_PCI_IOC_DATA 0x02290 -#define XMS_PCI_X_ERR_STAT 0x02300 -#define XMS_PCI_X_DIAG 0x02308 -#define XMS_PCI_UPPER_RETRY_COUNTER 0x02310 -#define STX_PCI_STRBUF 0x02800 -#define STX_PCI_STRBUF_CTXFLUSH 0x02818 -#define STX_PCI_IOMMU_SVADIAG 0x0a400 -#define STX_PCI_IOMMU_TLB_CMP_DIAG 0x0a408 -#define STX_PCI_IOMMU_QUEUE_DIAG 0x0a500 -#define STX_PCI_IOMMU_TLB_TAG_DIAG 0x0a580 -#define STX_PCI_IOMMU_TLB_DATA_DIAG 0x0a600 -#define STX_PCI_IOBIO_DIAG 0x0a808 -#define STX_PCI_STRBUF_CTXMATCH 0x10000 - -/* PCI configuration/idle check diagnostic register */ -#define SX_PCI_CFG_ICD_PCI_2_0_COMPAT 0x0000000000008000ULL -#define SX_PCI_CFG_ICD_DMAW_PERR_IEN 0x0000000000004000ULL -#define SX_PCI_CFG_ICD_IFC_NOT_IDLE 0x0000000000000010ULL -#define SX_PCI_CFG_ICD_MDU_NOT_IDLE 0x0000000000000008ULL -#define SX_PCI_CFG_ICD_MMU_NOT_IDLE 0x0000000000000004ULL -#define SX_PCI_CFG_ICD_PBM_NOT_IDLE 0x0000000000000002ULL -#define SX_PCI_CFG_ICD_STC_NOT_IDLE 0x0000000000000001ULL - -/* PCI IOMMU control register */ -#define TOM_PCI_IOMMU_ERR_BAD_VA 0x0000000010000000ULL -#define TOM_PCI_IOMMU_ERR_ILLTSBTBW 0x0000000008000000ULL -#define TOM_PCI_IOMMU_ECC_ERR 0x0000000006000000ULL -#define TOM_PCI_IOMMU_TIMEOUT_ERR 0x0000000004000000ULL -#define TOM_PCI_IOMMU_INVALID_ERR 0x0000000002000000ULL -#define TOM_PCI_IOMMU_PROTECTION_ERR 0x0000000000000000ULL -#define TOM_PCI_IOMMU_ERRMASK \ - (TOM_PCI_IOMMU_PROTECTION_ERR | TOM_PCI_IOMMU_INVALID_ERR | \ - TOM_PCI_IOMMU_TIMEOUT_ERR | TOM_PCI_IOMMU_ECC_ERR) -#define TOM_PCI_IOMMU_ERR 0x0000000001000000ULL - -/* PCI control/status register */ -#define SCZ_PCI_CTRL_BUS_UNUS 0x8000000000000000ULL -#define TOM_PCI_CTRL_DTO_ERR 0x4000000000000000ULL -#define TOM_PCI_CTRL_DTO_IEN 0x2000000000000000ULL -#define SCZ_PCI_CTRL_ESLCK 0x0008000000000000ULL -#define XMS_PCI_CTRL_DMA_WR_PERR 0x0008000000000000ULL -#define SCZ_PCI_CTRL_ERRSLOT 0x0007000000000000ULL -#define STX_PCI_CTRL_TTO_ERR 0x0000004000000000ULL -#define STX_PCI_CTRL_RTRY_ERR 0x0000002000000000ULL -#define STX_PCI_CTRL_MMU_ERR 0x0000001000000000ULL -#define SCZ_PCI_CTRL_SBH_ERR 0x0000000800000000ULL -#define STX_PCI_CTRL_SERR 0x0000000400000000ULL -#define SCZ_PCI_CTRL_PCISPD 0x0000000200000000ULL -#define XMS_PCI_CTRL_X_MODE 0x0000000100000000ULL -#define TOM_PCI_CTRL_PRM 0x0000000040000000ULL -#define TOM_PCI_CTRL_PRO 0x0000000020000000ULL -#define TOM_PCI_CTRL_PRL 0x0000000010000000ULL -#define STX_PCI_CTRL_PTO 0x0000000003000000ULL -#define XMS_PCI_CTRL_X_ERRINT_EN 0x0000000000100000ULL -#define STX_PCI_CTRL_MMU_IEN 0x0000000000080000ULL -#define STX_PCI_CTRL_SBH_IEN 0x0000000000040000ULL -#define STX_PCI_CTRL_ERR_IEN 0x0000000000020000ULL -#define STX_PCI_CTRL_ARB_PARK 0x0000000000010000ULL -#define SCZ_PCI_CTRL_PCIRST 0x0000000000000100ULL -#define STX_PCI_CTRL_ARB_MASK 0x00000000000000ffULL -#define XMS_PCI_CTRL_XMITS10_ARB_MASK 0x000000000000000fULL - -/* PCI asynchronous fault status register */ -#define STX_PCI_AFSR_P_MA 0x8000000000000000ULL -#define STX_PCI_AFSR_P_TA 0x4000000000000000ULL -#define STX_PCI_AFSR_P_RTRY 0x2000000000000000ULL -#define STX_PCI_AFSR_P_PERR 0x1000000000000000ULL -#define STX_PCI_AFSR_P_TTO 0x0800000000000000ULL -#define STX_PCI_AFSR_P_UNUS 0x0400000000000000ULL -#define STX_PCI_AFSR_S_MA 0x0200000000000000ULL -#define STX_PCI_AFSR_S_TA 0x0100000000000000ULL -#define STX_PCI_AFSR_S_RTRY 0x0080000000000000ULL -#define STX_PCI_AFSR_S_PERR 0x0040000000000000ULL -#define STX_PCI_AFSR_S_TTO 0x0020000000000000ULL -#define STX_PCI_AFSR_S_UNUS 0x0010000000000000ULL -#define STX_PCI_AFSR_DWMASK 0x0000030000000000ULL -#define STX_PCI_AFSR_BMASK 0x000000ff00000000ULL -#define STX_PCI_AFSR_BLK 0x0000000080000000ULL -#define STX_PCI_AFSR_CFG 0x0000000040000000ULL -#define STX_PCI_AFSR_MEM 0x0000000020000000ULL -#define STX_PCI_AFSR_IO 0x0000000010000000ULL - -/* PCI diagnostic register */ -#define SCZ_PCI_DIAG_BADECC_DIS 0x0000000000000400ULL -#define STX_PCI_DIAG_BYPASS_DIS 0x0000000000000200ULL -#define STX_PCI_DIAG_TTO_DIS 0x0000000000000100ULL -#define SCZ_PCI_DIAG_RTRYARB_DIS 0x0000000000000080ULL -#define STX_PCI_DIAG_RETRY_DIS 0x0000000000000040ULL -#define STX_PCI_DIAG_INTRSYNC_DIS 0x0000000000000020ULL -#define STX_PCI_DIAG_DMAPARITY_INV 0x0000000000000008ULL -#define STX_PCI_DIAG_PIODPARITY_INV 0x0000000000000004ULL -#define STX_PCI_DIAG_PIOAPARITY_INV 0x0000000000000002ULL - -/* Tomatillo I/O cache register */ -#define TOM_PCI_IOC_PW 0x0000000000080000ULL -#define TOM_PCI_IOC_PRM 0x0000000000040000ULL -#define TOM_PCI_IOC_PRO 0x0000000000020000ULL -#define TOM_PCI_IOC_PRL 0x0000000000010000ULL -#define TOM_PCI_IOC_PRM_LEN 0x000000000000c000ULL -#define TOM_PCI_IOC_PRM_LEN_SHIFT 14 -#define TOM_PCI_IOC_PRO_LEN 0x0000000000003000ULL -#define TOM_PCI_IOC_PRO_LEN_SHIFT 12 -#define TOM_PCI_IOC_PRL_LEN 0x0000000000000c00ULL -#define TOM_PCI_IOC_PRL_LEN_SHIFT 10 -#define TOM_PCI_IOC_PREF_OFF 0x0000000000000038ULL -#define TOM_PCI_IOC_PREF_OFF_SHIFT 3 -#define TOM_PCI_IOC_CPRM 0x0000000000000004ULL -#define TOM_PCI_IOC_CPRO 0x0000000000000002ULL -#define TOM_PCI_IOC_CPRL 0x0000000000000001ULL - -/* XMITS PCI-X error status register */ -#define XMS_PCI_X_ERR_STAT_P_SC_DSCRD 0x8000000000000000ULL -#define XMS_PCI_X_ERR_STAT_P_SC_TTO 0x4000000000000000ULL -#define XMS_PCI_X_ERR_STAT_P_SDSTAT 0x2000000000000000ULL -#define XMS_PCI_X_ERR_STAT_P_SMMU 0x1000000000000000ULL -#define XMS_PCI_X_ERR_STAT_P_CDSTAT 0x0800000000000000ULL -#define XMS_PCI_X_ERR_STAT_P_CMMU 0x0400000000000000ULL -#define XMS_PCI_X_ERR_STAT_S_SC_DSCRD 0x0080000000000000ULL -#define XMS_PCI_X_ERR_STAT_S_SC_TTO 0x0040000000000000ULL -#define XMS_PCI_X_ERR_STAT_S_SDSTAT 0x0020000000000000ULL -#define XMS_PCI_X_ERR_STAT_S_SMMU 0x0010000000000000ULL -#define XMS_PCI_X_ERR_STAT_S_CDSTAT 0x0008000000000000ULL -#define XMS_PCI_X_ERR_STAT_S_CMMU 0x0004000000000000ULL -#define XMS_PCI_X_ERR_STAT_PERR_RCV_IEN 0x0000000400000000ULL -#define XMS_PCI_X_ERR_STAT_PERR_RCV 0x0000000200000000ULL -#define XMS_PCI_X_ERR_STAT_SERR_ON_PERR 0x0000000100000000ULL - -/* XMITS PCI-X diagnostic register */ -#define XMS_PCI_X_DIAG_DIS_FAIR 0x0000000000080000ULL -#define XMS_PCI_X_DIAG_CRCQ_VALID 0x0000000000040000ULL -#define XMS_PCI_X_DIAG_SRCQ_ONE 0x0000000000000200ULL -#define XMS_PCI_X_DIAG_CRCQ_FLUSH 0x0000000000000100ULL -#define XMS_PCI_X_DIAG_BUGCNTL_MASK 0x0000ffff00000000ULL -#define XMS_PCI_X_DIAG_BUGCNTL_SHIFT 32 -#define XMS_PCI_X_DIAG_SRCQ_MASK 0x00000000000000ffULL - -/* Controller configuration and status registers */ -/* Note that these are shared on Schizo but per-PBM on Tomatillo. */ -#define STX_CTRL_BUS_ERRLOG 0x00018 -#define STX_CTRL_ECCCTRL 0x00020 -#define STX_CTRL_UE_AFSR 0x00030 -#define STX_CTRL_UE_AFAR 0x00038 -#define STX_CTRL_CE_AFSR 0x00040 -#define STX_CTRL_CE_AFAR 0x00048 -#define STX_CTRL_PERF 0x07000 -#define STX_CTRL_PERF_CNT 0x07008 - -/* Safari/JBus error log register */ -#define STX_CTRL_BUS_ERRLOG_BADCMD 0x4000000000000000ULL -#define SCZ_CTRL_BUS_ERRLOG_SSMDIS 0x2000000000000000ULL -#define SCZ_CTRL_BUS_ERRLOG_BADMA 0x1000000000000000ULL -#define SCZ_CTRL_BUS_ERRLOG_BADMB 0x0800000000000000ULL -#define SCZ_CTRL_BUS_ERRLOG_BADMC 0x0400000000000000ULL -#define TOM_CTRL_BUS_ERRLOG_SNOOP_GR 0x0000000000200000ULL -#define TOM_CTRL_BUS_ERRLOG_SNOOP_PCI 0x0000000000100000ULL -#define TOM_CTRL_BUS_ERRLOG_SNOOP_RD 0x0000000000080000ULL -#define TOM_CTRL_BUS_ERRLOG_SNOOP_RDS 0x0000000000020000ULL -#define TOM_CTRL_BUS_ERRLOG_SNOOP_RDSA 0x0000000000010000ULL -#define TOM_CTRL_BUS_ERRLOG_SNOOP_OWN 0x0000000000008000ULL -#define TOM_CTRL_BUS_ERRLOG_SNOOP_RDO 0x0000000000004000ULL -#define SCZ_CTRL_BUS_ERRLOG_CPU1PS 0x0000000000002000ULL -#define TOM_CTRL_BUS_ERRLOG_WDATA_PERR 0x0000000000002000ULL -#define SCZ_CTRL_BUS_ERRLOG_CPU1PB 0x0000000000001000ULL -#define TOM_CTRL_BUS_ERRLOG_CTRL_PERR 0x0000000000001000ULL -#define SCZ_CTRL_BUS_ERRLOG_CPU0PS 0x0000000000000800ULL -#define TOM_CTRL_BUS_ERRLOG_SNOOP_ERR 0x0000000000000800ULL -#define SCZ_CTRL_BUS_ERRLOG_CPU0PB 0x0000000000000400ULL -#define TOM_CTRL_BUS_ERRLOG_JBUS_ILL_B 0x0000000000000400ULL -#define SCZ_CTRL_BUS_ERRLOG_CIQTO 0x0000000000000200ULL -#define SCZ_CTRL_BUS_ERRLOG_LPQTO 0x0000000000000100ULL -#define TOM_CTRL_BUS_ERRLOG_JBUS_ILL_C 0x0000000000000100ULL -#define SCZ_CTRL_BUS_ERRLOG_SFPQTO 0x0000000000000080ULL -#define SCZ_CTRL_BUS_ERRLOG_UFPQTO 0x0000000000000040ULL -#define TOM_CTRL_BUS_ERRLOG_RD_PERR 0x0000000000000040ULL -#define STX_CTRL_BUS_ERRLOG_APERR 0x0000000000000020ULL -#define STX_CTRL_BUS_ERRLOG_UNMAP 0x0000000000000010ULL -#define STX_CTRL_BUS_ERRLOG_BUSERR 0x0000000000000004ULL -#define STX_CTRL_BUS_ERRLOG_TIMEOUT 0x0000000000000002ULL -#define SCZ_CTRL_BUS_ERRLOG_ILL 0x0000000000000001ULL - -/* ECC control register */ -#define STX_CTRL_ECCCTRL_EE 0x8000000000000000ULL -#define STX_CTRL_ECCCTRL_UE 0x4000000000000000ULL -#define STX_CTRL_ECCCTRL_CE 0x2000000000000000ULL - -/* Uncorrectable error asynchronous fault status register */ -#define STX_CTRL_UE_AFSR_P_PIO 0x8000000000000000ULL -#define STX_CTRL_UE_AFSR_P_DRD 0x4000000000000000ULL -#define STX_CTRL_UE_AFSR_P_DWR 0x2000000000000000ULL -#define STX_CTRL_UE_AFSR_S_PIO 0x1000000000000000ULL -#define STX_CTRL_UE_AFSR_S_DRD 0x0800000000000000ULL -#define STX_CTRL_UE_AFSR_S_DWR 0x0400000000000000ULL -#define STX_CTRL_UE_AFSR_ERRPNDG 0x0300000000000000ULL -#define STX_CTRL_UE_AFSR_BMASK 0x000003ff00000000ULL -#define STX_CTRL_UE_AFSR_QOFF 0x00000000c0000000ULL -#define STX_CTRL_UE_AFSR_AID 0x000000001f000000ULL -#define STX_CTRL_UE_AFSR_PARTIAL 0x0000000000800000ULL -#define STX_CTRL_UE_AFSR_OWNEDIN 0x0000000000400000ULL -#define STX_CTRL_UE_AFSR_MTAGSYND 0x00000000000f0000ULL -#define STX_CTRL_UE_AFSR_MTAG 0x000000000000e000ULL -#define STX_CTRL_UE_AFSR_ECCSYND 0x00000000000001ffULL - -/* Correctable error asynchronous fault status register */ -#define STX_CTRL_CE_AFSR_P_PIO 0x8000000000000000ULL -#define STX_CTRL_CE_AFSR_P_DRD 0x4000000000000000ULL -#define STX_CTRL_CE_AFSR_P_DWR 0x2000000000000000ULL -#define STX_CTRL_CE_AFSR_S_PIO 0x1000000000000000ULL -#define STX_CTRL_CE_AFSR_S_DRD 0x0800000000000000ULL -#define STX_CTRL_CE_AFSR_S_DWR 0x0400000000000000ULL -#define STX_CTRL_CE_AFSR_ERRPNDG 0x0300000000000000ULL -#define STX_CTRL_CE_AFSR_BMASK 0x000003ff00000000ULL -#define STX_CTRL_CE_AFSR_QOFF 0x00000000c0000000ULL -#define STX_CTRL_CE_AFSR_AID 0x000000001f000000ULL -#define STX_CTRL_CE_AFSR_PARTIAL 0x0000000000800000ULL -#define STX_CTRL_CE_AFSR_OWNEDIN 0x0000000000400000ULL -#define STX_CTRL_CE_AFSR_MTAGSYND 0x00000000000f0000ULL -#define STX_CTRL_CE_AFSR_MTAG 0x000000000000e000ULL -#define STX_CTRL_CE_AFSR_ECCSYND 0x00000000000001ffULL - -/* - * Safari/JBus performance control register - * NB: For Tomatillo only events 0x00 through 0x08 are documented as - * implemented. - */ -#define SCZ_CTRL_PERF_ZDATA_OUT 0x0000000000000016ULL -#define SCZ_CTRL_PERF_ZDATA_IN 0x0000000000000015ULL -#define SCZ_CTRL_PERF_ORQFULL 0x0000000000000014ULL -#define SCZ_CTRL_PERF_DVMA_WR 0x0000000000000013ULL -#define SCZ_CTRL_PERF_DVMA_RD 0x0000000000000012ULL -#define SCZ_CTRL_PERF_CYCPSESYS 0x0000000000000011ULL -#define STX_CTRL_PERF_PCI_B 0x000000000000000fULL -#define STX_CTRL_PERF_PCI_A 0x000000000000000eULL -#define STX_CTRL_PERF_UPA 0x000000000000000dULL -#define STX_CTRL_PERF_PIOINTRNL 0x000000000000000cULL -#define TOM_CTRL_PERF_WRI_WRIS 0x000000000000000bULL -#define STX_CTRL_PERF_INTRS 0x000000000000000aULL -#define STX_CTRL_PERF_PRTLWRMRGBUF 0x0000000000000009ULL -#define STX_CTRL_PERF_FGN_IO_HITS 0x0000000000000008ULL -#define STX_CTRL_PERF_FGN_IO_TRNS 0x0000000000000007ULL -#define STX_CTRL_PERF_OWN_CHRNT_HITS 0x0000000000000006ULL -#define STX_CTRL_PERF_OWN_CHRNT_TRNS 0x0000000000000005ULL -#define SCZ_CTRL_PERF_FGN_CHRNT_HITS 0x0000000000000004ULL -#define STX_CTRL_PERF_FGN_CHRNT_TRNS 0x0000000000000003ULL -#define STX_CTRL_PERF_CYCLES_PAUSE 0x0000000000000002ULL -#define STX_CTRL_PERF_BUSCYC 0x0000000000000001ULL -#define STX_CTRL_PERF_DIS 0x0000000000000000ULL -#define STX_CTRL_PERF_CNT1_SHIFT 11 -#define STX_CTRL_PERF_CNT0_SHIFT 4 - -/* Safari/JBus performance counter register */ -#define STX_CTRL_PERF_CNT_MASK 0x00000000ffffffffULL -#define STX_CTRL_PERF_CNT_CNT1_SHIFT 32 -#define STX_CTRL_PERF_CNT_CNT0_SHIFT 0 - -/* INO defines */ -#define STX_FB0_INO 0x2a /* FB0 int. shared w/ UPA64s */ -#define STX_FB1_INO 0x2b /* FB1 int. shared w/ UPA64s */ -#define STX_UE_INO 0x30 /* uncorrectable error */ -#define STX_CE_INO 0x31 /* correctable error */ -#define STX_PCIERR_A_INO 0x32 /* PCI bus A error */ -#define STX_PCIERR_B_INO 0x33 /* PCI bus B error */ -#define STX_BUS_INO 0x34 /* Safari/JBus error */ -#define STX_CDMA_A_INO 0x35 /* PCI bus A CDMA */ -#define STX_CDMA_B_INO 0x36 /* PCI bus B CDMA */ -#define STX_MAX_INO 0x37 - -/* Device space defines */ -#define STX_CONF_SIZE 0x1000000 -#define STX_CONF_BUS_SHIFT 16 -#define STX_CONF_DEV_SHIFT 11 -#define STX_CONF_FUNC_SHIFT 8 -#define STX_CONF_REG_SHIFT 0 -#define STX_IO_SIZE 0x1000000 -#define STX_MEM_SIZE 0x100000000 - -#define STX_CONF_OFF(bus, slot, func, reg) \ - (((bus) << STX_CONF_BUS_SHIFT) | \ - ((slot) << STX_CONF_DEV_SHIFT) | \ - ((func) << STX_CONF_FUNC_SHIFT) | \ - ((reg) << STX_CONF_REG_SHIFT)) - -/* Definitions for the Schizo/Tomatillo configuration space */ -#define STX_CS_DEVICE 0 /* bridge CS device number */ -#define STX_CS_FUNC 0 /* brdige CS function number */ - -/* Non-Standard registers in the configration space */ -/* - * NB: For Tomatillo the secondary and subordinate bus number registers - * apparently are read-only although documented otherwise; writing to - * them just triggers a PCI bus error interrupt or has no effect at best. - */ -#define STX_CSR_SECBUS 0x40 /* secondary bus number */ -#define STX_CSR_SUBBUS 0x41 /* subordinate bus number */ - -/* Width of the physical addresses the IOMMU translates to */ -#define STX_IOMMU_BITS 43 - -#endif /* !_SPARC64_PCI_SCHIZOREG_H_ */ diff --git a/sys/sparc64/pci/schizovar.h b/sys/sparc64/pci/schizovar.h deleted file mode 100644 index b153a020dbb4..000000000000 --- a/sys/sparc64/pci/schizovar.h +++ /dev/null @@ -1,92 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD - * - * Copyright (c) 2005 by Marius Strobl . - * 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, - * without modification, immediately at the beginning of the file. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD$ - */ - -#ifndef _SPARC64_PCI_SCHIZOVAR_H_ -#define _SPARC64_PCI_SCHIZOVAR_H_ - -struct schizo_softc; - -struct schizo_iommu_state { - struct iommu_state sis_is; - struct schizo_softc *sis_sc; -}; - -struct schizo_softc { - /* - * This is here so that we can hook up the common bus interface - * methods in ofw_pci.c directly. - */ - struct ofw_pci_softc sc_ops; - - struct schizo_iommu_state sc_is; - struct bus_dma_methods sc_dma_methods; - - struct mtx sc_sync_mtx; - uint64_t sc_sync_val; - - struct mtx *sc_mtx; - - struct resource *sc_mem_res[TOM_NREG]; - struct resource *sc_irq_res[STX_NINTR]; - void *sc_ihand[STX_NINTR]; - - SLIST_ENTRY(schizo_softc) sc_link; - - device_t sc_dev; - - u_int sc_mode; -#define SCHIZO_MODE_SCZ 0 -#define SCHIZO_MODE_TOM 1 -#define SCHIZO_MODE_XMS 2 - - u_int sc_flags; -#define SCHIZO_FLAGS_BSWAR (1 << 0) -#define SCHIZO_FLAGS_XMODE (1 << 1) - - bus_addr_t sc_cdma_map; - bus_addr_t sc_cdma_clr; - uint32_t sc_cdma_vec; - uint32_t sc_cdma_state; -#define SCHIZO_CDMA_STATE_IDLE (1 << 0) -#define SCHIZO_CDMA_STATE_PENDING (1 << 1) -#define SCHIZO_CDMA_STATE_RECEIVED (1 << 2) - - u_int sc_half; - uint32_t sc_ign; - uint32_t sc_ver; - uint32_t sc_mrev; - - uint32_t sc_stats_dma_ce; - uint32_t sc_stats_pci_non_fatal; -}; - -#endif /* !_SPARC64_PCI_SCHIZOVAR_H_ */ diff --git a/sys/sparc64/sbus/dma_sbus.c b/sys/sparc64/sbus/dma_sbus.c deleted file mode 100644 index 7e4887e56e24..000000000000 --- a/sys/sparc64/sbus/dma_sbus.c +++ /dev/null @@ -1,417 +0,0 @@ -/* $OpenBSD: dma_sbus.c,v 1.16 2008/06/26 05:42:18 ray Exp $ */ -/* $NetBSD: dma_sbus.c,v 1.32 2008/04/28 20:23:57 martin Exp $ */ - -/*- - * SPDX-License-Identifier: BSD-2-Clause-NetBSD AND BSD-2-Clause-FreeBSD - * - * Copyright (c) 1998 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Paul Kranenburg. - * - * 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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. - */ - -/*- - * Copyright (c) 1994 Peter Galbavy. All rights reserved. - * Copyright (c) 2005 Marius Strobl . 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 ``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 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 -__FBSDID("$FreeBSD$"); - -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include -#include -#include - -#include -#include -#include -#include -#include - -struct dma_devinfo { - struct ofw_bus_devinfo ddi_obdinfo; - struct resource_list ddi_rl; -}; - -struct dma_softc { - struct lsi64854_softc sc_lsi64854; /* base device */ - int sc_ign; - int sc_slot; -}; - -static devclass_t dma_devclass; - -static device_probe_t dma_probe; -static device_attach_t dma_attach; -static bus_print_child_t dma_print_child; -static bus_probe_nomatch_t dma_probe_nomatch; -static bus_get_resource_list_t dma_get_resource_list; -static ofw_bus_get_devinfo_t dma_get_devinfo; - -static struct dma_devinfo *dma_setup_dinfo(device_t, struct dma_softc *, - phandle_t); -static void dma_destroy_dinfo(struct dma_devinfo *); -static int dma_print_res(struct dma_devinfo *); - -static device_method_t dma_methods[] = { - /* Device interface */ - DEVMETHOD(device_probe, dma_probe), - DEVMETHOD(device_attach, dma_attach), - DEVMETHOD(device_shutdown, bus_generic_shutdown), - DEVMETHOD(device_suspend, bus_generic_suspend), - DEVMETHOD(device_resume, bus_generic_resume), - - /* Bus interface */ - DEVMETHOD(bus_print_child, dma_print_child), - DEVMETHOD(bus_probe_nomatch, dma_probe_nomatch), - DEVMETHOD(bus_alloc_resource, bus_generic_rl_alloc_resource), - DEVMETHOD(bus_activate_resource, bus_generic_activate_resource), - DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource), - DEVMETHOD(bus_adjust_resource, bus_generic_adjust_resource), - DEVMETHOD(bus_release_resource, bus_generic_rl_release_resource), - DEVMETHOD(bus_setup_intr, bus_generic_setup_intr), - DEVMETHOD(bus_teardown_intr, bus_generic_teardown_intr), - DEVMETHOD(bus_get_resource, bus_generic_rl_get_resource), - DEVMETHOD(bus_get_resource_list, dma_get_resource_list), - DEVMETHOD(bus_child_pnpinfo_str, ofw_bus_gen_child_pnpinfo_str), - - /* ofw_bus interface */ - DEVMETHOD(ofw_bus_get_devinfo, dma_get_devinfo), - DEVMETHOD(ofw_bus_get_compat, ofw_bus_gen_get_compat), - DEVMETHOD(ofw_bus_get_model, ofw_bus_gen_get_model), - DEVMETHOD(ofw_bus_get_name, ofw_bus_gen_get_name), - DEVMETHOD(ofw_bus_get_node, ofw_bus_gen_get_node), - DEVMETHOD(ofw_bus_get_type, ofw_bus_gen_get_type), - - DEVMETHOD_END -}; - -static driver_t dma_driver = { - "dma", - dma_methods, - sizeof(struct dma_softc), -}; - -/* - * The probe order is handled by sbus(4) as we don't want the variants - * with children to be attached earlier than the stand-alone controllers - * in order to generally preserve the OFW device tree order. - */ -EARLY_DRIVER_MODULE(dma, sbus, dma_driver, dma_devclass, 0, 0, - BUS_PASS_DEFAULT); -MODULE_DEPEND(dma, sbus, 1, 1, 1); -MODULE_VERSION(dma, 1); - -static int -dma_probe(device_t dev) -{ - const char *name; - - name = ofw_bus_get_name(dev); - if (strcmp(name, "espdma") == 0 || strcmp(name, "dma") == 0 || - strcmp(name, "ledma") == 0) { - device_set_desc_copy(dev, name); - return (0); - } - return (ENXIO); -} - -static int -dma_attach(device_t dev) -{ - struct dma_softc *dsc; - struct lsi64854_softc *lsc; - struct dma_devinfo *ddi; - device_t cdev; - const char *name; - char *cabletype; - uint32_t csr; - phandle_t child, node; - int error, i; - - dsc = device_get_softc(dev); - lsc = &dsc->sc_lsi64854; - - name = ofw_bus_get_name(dev); - node = ofw_bus_get_node(dev); - dsc->sc_ign = sbus_get_ign(dev); - dsc->sc_slot = sbus_get_slot(dev); - - i = 0; - lsc->sc_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &i, - RF_ACTIVE); - if (lsc->sc_res == NULL) { - device_printf(dev, "cannot allocate resources\n"); - return (ENXIO); - } - - if (strcmp(name, "espdma") == 0 || strcmp(name, "dma") == 0) - lsc->sc_channel = L64854_CHANNEL_SCSI; - else if (strcmp(name, "ledma") == 0) { - /* - * Check to see which cable type is currently active and - * set the appropriate bit in the ledma csr so that it - * gets used. If we didn't netboot, the PROM won't have - * the "cable-selection" property; default to TP and then - * the user can change it via a "media" option to ifconfig. - */ - csr = L64854_GCSR(lsc); - if ((OF_getprop_alloc(node, "cable-selection", - (void **)&cabletype)) == -1) { - /* assume TP if nothing there */ - csr |= E_TP_AUI; - } else { - if (strcmp(cabletype, "aui") == 0) - csr &= ~E_TP_AUI; - else - csr |= E_TP_AUI; - OF_prop_free(cabletype); - } - L64854_SCSR(lsc, csr); - DELAY(20000); /* manual says we need a 20ms delay */ - lsc->sc_channel = L64854_CHANNEL_ENET; - } else { - device_printf(dev, "unsupported DMA channel\n"); - error = ENXIO; - goto fail_lres; - } - - error = bus_dma_tag_create( - bus_get_dma_tag(dev), /* parent */ - 1, 0, /* alignment, boundary */ - BUS_SPACE_MAXADDR, /* lowaddr */ - BUS_SPACE_MAXADDR, /* highaddr */ - NULL, NULL, /* filter, filterarg */ - BUS_SPACE_MAXSIZE, /* maxsize */ - BUS_SPACE_UNRESTRICTED, /* nsegments */ - BUS_SPACE_MAXSIZE, /* maxsegsize */ - 0, /* flags */ - NULL, NULL, /* no locking */ - &lsc->sc_parent_dmat); - if (error != 0) { - device_printf(dev, "cannot allocate parent DMA tag\n"); - goto fail_lres; - } - - i = sbus_get_burstsz(dev); - lsc->sc_burst = (i & SBUS_BURST_32) ? 32 : - (i & SBUS_BURST_16) ? 16 : 0; - lsc->sc_dev = dev; - - /* Attach children. */ - i = 0; - for (child = OF_child(node); child != 0; child = OF_peer(child)) { - if ((ddi = dma_setup_dinfo(dev, dsc, child)) == NULL) - continue; - if (i != 0) { - device_printf(dev, - "<%s>: only one child per DMA channel supported\n", - ddi->ddi_obdinfo.obd_name); - dma_destroy_dinfo(ddi); - continue; - } - if ((cdev = device_add_child(dev, NULL, -1)) == NULL) { - device_printf(dev, "<%s>: device_add_child failed\n", - ddi->ddi_obdinfo.obd_name); - dma_destroy_dinfo(ddi); - continue; - } - device_set_ivars(cdev, ddi); - i++; - } - return (bus_generic_attach(dev)); - - fail_lres: - bus_release_resource(dev, SYS_RES_MEMORY, rman_get_rid(lsc->sc_res), - lsc->sc_res); - return (error); -} - -static struct dma_devinfo * -dma_setup_dinfo(device_t dev, struct dma_softc *dsc, phandle_t node) -{ - struct dma_devinfo *ddi; - struct sbus_regs *reg; - uint32_t base, iv, *intr; - int i, nreg, nintr, slot, rslot; - - ddi = malloc(sizeof(*ddi), M_DEVBUF, M_WAITOK | M_ZERO); - if (ofw_bus_gen_setup_devinfo(&ddi->ddi_obdinfo, node) != 0) { - free(ddi, M_DEVBUF); - return (NULL); - } - resource_list_init(&ddi->ddi_rl); - slot = -1; - nreg = OF_getprop_alloc_multi(node, "reg", sizeof(*reg), (void **)®); - if (nreg == -1) { - device_printf(dev, "<%s>: incomplete\n", - ddi->ddi_obdinfo.obd_name); - goto fail; - } - for (i = 0; i < nreg; i++) { - base = reg[i].sbr_offset; - if (SBUS_ABS(base)) { - rslot = SBUS_ABS_TO_SLOT(base); - base = SBUS_ABS_TO_OFFSET(base); - } else - rslot = reg[i].sbr_slot; - if (slot != -1 && slot != rslot) { - device_printf(dev, "<%s>: multiple slots\n", - ddi->ddi_obdinfo.obd_name); - OF_prop_free(reg); - goto fail; - } - slot = rslot; - - resource_list_add(&ddi->ddi_rl, SYS_RES_MEMORY, i, base, - base + reg[i].sbr_size, reg[i].sbr_size); - } - OF_prop_free(reg); - if (slot != dsc->sc_slot) { - device_printf(dev, "<%s>: parent and child slot do not match\n", - ddi->ddi_obdinfo.obd_name); - goto fail; - } - - /* - * The `interrupts' property contains the SBus interrupt level. - */ - nintr = OF_getprop_alloc_multi(node, "interrupts", sizeof(*intr), - (void **)&intr); - if (nintr != -1) { - for (i = 0; i < nintr; i++) { - iv = intr[i]; - /* - * SBus card devices need the slot number encoded into - * the vector as this is generally not done. - */ - if ((iv & INTMAP_OBIO_MASK) == 0) - iv |= slot << 3; - /* Set the IGN as appropriate. */ - iv |= dsc->sc_ign << INTMAP_IGN_SHIFT; - resource_list_add(&ddi->ddi_rl, SYS_RES_IRQ, i, - iv, iv, 1); - } - OF_prop_free(intr); - } - return (ddi); - - fail: - dma_destroy_dinfo(ddi); - return (NULL); -} - -static void -dma_destroy_dinfo(struct dma_devinfo *dinfo) -{ - - resource_list_free(&dinfo->ddi_rl); - ofw_bus_gen_destroy_devinfo(&dinfo->ddi_obdinfo); - free(dinfo, M_DEVBUF); -} - -static int -dma_print_child(device_t dev, device_t child) -{ - int rv; - - rv = bus_print_child_header(dev, child); - rv += dma_print_res(device_get_ivars(child)); - rv += bus_print_child_footer(dev, child); - return (rv); -} - -static void -dma_probe_nomatch(device_t dev, device_t child) -{ - const char *type; - - device_printf(dev, "<%s>", ofw_bus_get_name(child)); - dma_print_res(device_get_ivars(child)); - type = ofw_bus_get_type(child); - printf(" type %s (no driver attached)\n", - type != NULL ? type : "unknown"); -} - -static struct resource_list * -dma_get_resource_list(device_t dev, device_t child) -{ - struct dma_devinfo *ddi; - - ddi = device_get_ivars(child); - return (&ddi->ddi_rl); -} - -static const struct ofw_bus_devinfo * -dma_get_devinfo(device_t bus, device_t child) -{ - struct dma_devinfo *ddi; - - ddi = device_get_ivars(child); - return (&ddi->ddi_obdinfo); -} - -static int -dma_print_res(struct dma_devinfo *ddi) -{ - int rv; - - rv = 0; - rv += resource_list_print_type(&ddi->ddi_rl, "mem", SYS_RES_MEMORY, - "%#jx"); - rv += resource_list_print_type(&ddi->ddi_rl, "irq", SYS_RES_IRQ, "%jd"); - return (rv); -} diff --git a/sys/sparc64/sbus/lsi64854.c b/sys/sparc64/sbus/lsi64854.c deleted file mode 100644 index 866f6c3cac18..000000000000 --- a/sys/sparc64/sbus/lsi64854.c +++ /dev/null @@ -1,764 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD AND BSD-2-Clause-NetBSD - * - * Copyright (c) 2004 Scott Long - * 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. - * - */ - -/* $NetBSD: lsi64854.c,v 1.33 2008/04/28 20:23:50 martin Exp $ */ - -/*- - * Copyright (c) 1998 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Paul Kranenburg. - * - * 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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 -__FBSDID("$FreeBSD$"); - -#include -#include -#include -#include -#include -#include -#include - -#include - -#include -#include -#include - -#include -#include - -#include -#include - -#ifdef DEBUG -#define LDB_SCSI 1 -#define LDB_ENET 2 -#define LDB_PP 4 -#define LDB_ANY 0xff -int lsi64854debug = 0; -#define DPRINTF(a,x) \ - do { \ - if ((lsi64854debug & (a)) != 0) \ - printf x; \ - } while (/* CONSTCOND */0) -#else -#define DPRINTF(a,x) -#endif - -/* - * The rules say we cannot transfer more than the limit of this DMA chip (64k - * for old and 16Mb for new), and we cannot cross a 16Mb boundary. - */ -#define MAX_DMA_SZ (64 * 1024) -#define BOUNDARY (16 * 1024 * 1024) - -static void lsi64854_reset(struct lsi64854_softc *); -static void lsi64854_map_scsi(void *, bus_dma_segment_t *, int, int); -static int lsi64854_setup(struct lsi64854_softc *, void **, size_t *, - int, size_t *); -static int lsi64854_scsi_intr(void *); -static int lsi64854_enet_intr(void *); -static int lsi64854_setup_pp(struct lsi64854_softc *, void **, - size_t *, int, size_t *); -static int lsi64854_pp_intr(void *); - -/* - * Finish attaching this DMA device. - * Front-end must fill in these fields: - * sc_res - * sc_burst - * sc_channel (one of SCSI, ENET, PP) - * sc_client (one of SCSI, ENET, PP `soft_c' pointers) - */ -int -lsi64854_attach(struct lsi64854_softc *sc) -{ - bus_dma_lock_t *lockfunc; - struct ncr53c9x_softc *nsc; - void *lockfuncarg; - uint32_t csr; - int error; - - lockfunc = NULL; - lockfuncarg = NULL; - sc->sc_maxdmasize = MAX_DMA_SZ; - - switch (sc->sc_channel) { - case L64854_CHANNEL_SCSI: - nsc = sc->sc_client; - if (NCR_LOCK_INITIALIZED(nsc) == 0) { - device_printf(sc->sc_dev, "mutex not initialized\n"); - return (ENXIO); - } - lockfunc = busdma_lock_mutex; - lockfuncarg = &nsc->sc_lock; - sc->sc_maxdmasize = nsc->sc_maxxfer; - sc->intr = lsi64854_scsi_intr; - sc->setup = lsi64854_setup; - break; - case L64854_CHANNEL_ENET: - sc->intr = lsi64854_enet_intr; - break; - case L64854_CHANNEL_PP: - sc->intr = lsi64854_pp_intr; - sc->setup = lsi64854_setup_pp; - break; - default: - device_printf(sc->sc_dev, "unknown channel\n"); - } - sc->reset = lsi64854_reset; - - if (sc->setup != NULL) { - error = bus_dma_tag_create( - sc->sc_parent_dmat, /* parent */ - 1, BOUNDARY, /* alignment, boundary */ - BUS_SPACE_MAXADDR_32BIT, /* lowaddr */ - BUS_SPACE_MAXADDR, /* highaddr */ - NULL, NULL, /* filter, filterarg */ - sc->sc_maxdmasize, /* maxsize */ - 1, /* nsegments */ - sc->sc_maxdmasize, /* maxsegsize */ - BUS_DMA_ALLOCNOW, /* flags */ - lockfunc, lockfuncarg, /* lockfunc, lockfuncarg */ - &sc->sc_buffer_dmat); - if (error != 0) { - device_printf(sc->sc_dev, - "cannot allocate buffer DMA tag\n"); - return (error); - } - - error = bus_dmamap_create(sc->sc_buffer_dmat, 0, - &sc->sc_dmamap); - if (error != 0) { - device_printf(sc->sc_dev, "DMA map create failed\n"); - bus_dma_tag_destroy(sc->sc_buffer_dmat); - return (error); - } - } - - csr = L64854_GCSR(sc); - sc->sc_rev = csr & L64854_DEVID; - if (sc->sc_rev == DMAREV_HME) - return (0); - device_printf(sc->sc_dev, "DMA rev. "); - switch (sc->sc_rev) { - case DMAREV_0: - printf("0"); - break; - case DMAREV_ESC: - printf("ESC"); - break; - case DMAREV_1: - printf("1"); - break; - case DMAREV_PLUS: - printf("1+"); - break; - case DMAREV_2: - printf("2"); - break; - default: - printf("unknown (0x%x)", sc->sc_rev); - } - - DPRINTF(LDB_ANY, (", burst 0x%x, csr 0x%x", sc->sc_burst, csr)); - printf("\n"); - - return (0); -} - -int -lsi64854_detach(struct lsi64854_softc *sc) -{ - - if (sc->setup != NULL) { - bus_dmamap_sync(sc->sc_buffer_dmat, sc->sc_dmamap, - (L64854_GCSR(sc) & L64854_WRITE) != 0 ? - BUS_DMASYNC_PREREAD : BUS_DMASYNC_PREWRITE); - bus_dmamap_unload(sc->sc_buffer_dmat, sc->sc_dmamap); - bus_dmamap_destroy(sc->sc_buffer_dmat, sc->sc_dmamap); - bus_dma_tag_destroy(sc->sc_buffer_dmat); - } - - return (0); -} - -/* - * DMAWAIT waits while condition is true. - */ -#define DMAWAIT(SC, COND, MSG, DONTPANIC) do if (COND) { \ - int count = 500000; \ - while ((COND) && --count > 0) DELAY(1); \ - if (count == 0) { \ - printf("%s: line %d: CSR = 0x%lx\n", __FILE__, __LINE__, \ - (u_long)L64854_GCSR(SC)); \ - if (DONTPANIC) \ - printf(MSG); \ - else \ - panic(MSG); \ - } \ -} while (/* CONSTCOND */0) - -#define DMA_DRAIN(sc, dontpanic) do { \ - uint32_t csr; \ - /* \ - * DMA rev0 & rev1: we are not allowed to touch the DMA "flush" \ - * and "drain" bits while it is still thinking about a \ - * request. \ - * other revs: D_ESC_R_PEND bit reads as 0 \ - */ \ - DMAWAIT(sc, L64854_GCSR(sc) & D_ESC_R_PEND, "R_PEND", dontpanic);\ - if (sc->sc_rev != DMAREV_HME) { \ - /* \ - * Select drain bit based on revision \ - * also clears errors and D_TC flag \ - */ \ - csr = L64854_GCSR(sc); \ - if (sc->sc_rev == DMAREV_1 || sc->sc_rev == DMAREV_0) \ - csr |= D_ESC_DRAIN; \ - else \ - csr |= L64854_INVALIDATE; \ - \ - L64854_SCSR(sc, csr); \ - } \ - /* \ - * Wait for draining to finish \ - * rev0 & rev1 call this PACKCNT \ - */ \ - DMAWAIT(sc, L64854_GCSR(sc) & L64854_DRAINING, "DRAINING", \ - dontpanic); \ -} while (/* CONSTCOND */0) - -#define DMA_FLUSH(sc, dontpanic) do { \ - uint32_t csr; \ - /* \ - * DMA rev0 & rev1: we are not allowed to touch the DMA "flush" \ - * and "drain" bits while it is still thinking about a \ - * request. \ - * other revs: D_ESC_R_PEND bit reads as 0 \ - */ \ - DMAWAIT(sc, L64854_GCSR(sc) & D_ESC_R_PEND, "R_PEND", dontpanic);\ - csr = L64854_GCSR(sc); \ - csr &= ~(L64854_WRITE|L64854_EN_DMA); /* no-ops on ENET */ \ - csr |= L64854_INVALIDATE; /* XXX FAS ? */ \ - L64854_SCSR(sc, csr); \ -} while (/* CONSTCOND */0) - -static void -lsi64854_reset(struct lsi64854_softc *sc) -{ - bus_dma_tag_t dmat; - bus_dmamap_t dmam; - uint32_t csr; - - DMA_FLUSH(sc, 1); - csr = L64854_GCSR(sc); - - DPRINTF(LDB_ANY, ("%s: csr 0x%x\n", __func__, csr)); - - if (sc->sc_dmasize != 0) { - dmat = sc->sc_buffer_dmat; - dmam = sc->sc_dmamap; - bus_dmamap_sync(dmat, dmam, (csr & D_WRITE) != 0 ? - BUS_DMASYNC_PREREAD : BUS_DMASYNC_PREWRITE); - bus_dmamap_unload(dmat, dmam); - } - - if (sc->sc_rev == DMAREV_HME) - L64854_SCSR(sc, csr | D_HW_RESET_FAS366); - - csr |= L64854_RESET; /* reset DMA */ - L64854_SCSR(sc, csr); - DELAY(200); /* > 10 Sbus clocks(?) */ - - /*DMAWAIT1(sc); why was this here? */ - csr = L64854_GCSR(sc); - csr &= ~L64854_RESET; /* de-assert reset line */ - L64854_SCSR(sc, csr); - DELAY(5); /* allow a few ticks to settle */ - - csr = L64854_GCSR(sc); - csr |= L64854_INT_EN; /* enable interrupts */ - if (sc->sc_rev > DMAREV_1 && sc->sc_channel == L64854_CHANNEL_SCSI) { - if (sc->sc_rev == DMAREV_HME) - csr |= D_TWO_CYCLE; - else - csr |= D_FASTER; - } - - /* Set burst */ - switch (sc->sc_rev) { - case DMAREV_HME: - case DMAREV_2: - csr &= ~L64854_BURST_SIZE; - if (sc->sc_burst == 32) - csr |= L64854_BURST_32; - else if (sc->sc_burst == 16) - csr |= L64854_BURST_16; - else - csr |= L64854_BURST_0; - break; - case DMAREV_ESC: - csr |= D_ESC_AUTODRAIN; /* Auto-drain */ - if (sc->sc_burst == 32) - csr &= ~D_ESC_BURST; - else - csr |= D_ESC_BURST; - break; - default: - break; - } - L64854_SCSR(sc, csr); - - if (sc->sc_rev == DMAREV_HME) { - bus_write_4(sc->sc_res, L64854_REG_ADDR, 0); - sc->sc_dmactl = csr; - } - sc->sc_active = 0; - - DPRINTF(LDB_ANY, ("%s: done, csr 0x%x\n", __func__, csr)); -} - -static void -lsi64854_map_scsi(void *arg, bus_dma_segment_t *segs, int nseg, int error) -{ - struct lsi64854_softc *sc; - - sc = (struct lsi64854_softc *)arg; - - if (error != 0) - return; - if (nseg != 1) - panic("%s: cannot map %d segments\n", __func__, nseg); - - bus_dmamap_sync(sc->sc_buffer_dmat, sc->sc_dmamap, - sc->sc_datain != 0 ? BUS_DMASYNC_PREREAD : BUS_DMASYNC_PREWRITE); - bus_write_4(sc->sc_res, L64854_REG_ADDR, segs[0].ds_addr); -} - -/* - * setup a DMA transfer - */ -static int -lsi64854_setup(struct lsi64854_softc *sc, void **addr, size_t *len, - int datain, size_t *dmasize) -{ - long bcnt; - int error; - uint32_t csr; - - DMA_FLUSH(sc, 0); - -#if 0 - DMACSR(sc) &= ~D_INT_EN; -#endif - sc->sc_dmaaddr = addr; - sc->sc_dmalen = len; - sc->sc_datain = datain; - - KASSERT(*dmasize <= sc->sc_maxdmasize, - ("%s: transfer size %ld too large", __func__, (long)*dmasize)); - - sc->sc_dmasize = *dmasize; - - DPRINTF(LDB_ANY, ("%s: dmasize=%ld\n", __func__, (long)*dmasize)); - - /* - * XXX what length? - */ - if (sc->sc_rev == DMAREV_HME) { - L64854_SCSR(sc, sc->sc_dmactl | L64854_RESET); - L64854_SCSR(sc, sc->sc_dmactl); - - bus_write_4(sc->sc_res, L64854_REG_CNT, *dmasize); - } - - /* - * Load the transfer buffer and program the DMA address. - * Note that the NCR53C9x core can't handle EINPROGRESS so we set - * BUS_DMA_NOWAIT. - */ - if (*dmasize != 0) { - error = bus_dmamap_load(sc->sc_buffer_dmat, sc->sc_dmamap, - *sc->sc_dmaaddr, *dmasize, lsi64854_map_scsi, sc, - BUS_DMA_NOWAIT); - if (error != 0) - return (error); - } - - if (sc->sc_rev == DMAREV_ESC) { - /* DMA ESC chip bug work-around */ - bcnt = *dmasize; - if (((bcnt + (long)*sc->sc_dmaaddr) & PAGE_MASK_8K) != 0) - bcnt = roundup(bcnt, PAGE_SIZE_8K); - bus_write_4(sc->sc_res, L64854_REG_CNT, bcnt); - } - - /* Setup the DMA control register. */ - csr = L64854_GCSR(sc); - - if (datain != 0) - csr |= L64854_WRITE; - else - csr &= ~L64854_WRITE; - csr |= L64854_INT_EN; - - if (sc->sc_rev == DMAREV_HME) - csr |= (D_DSBL_SCSI_DRN | D_EN_DMA); - - L64854_SCSR(sc, csr); - - return (0); -} - -/* - * Pseudo (chained) interrupt from the esp driver to kick the - * current running DMA transfer. Called from ncr53c9x_intr() - * for now. - * - * return 1 if it was a DMA continue. - */ -static int -lsi64854_scsi_intr(void *arg) -{ - struct lsi64854_softc *sc = arg; - struct ncr53c9x_softc *nsc = sc->sc_client; - bus_dma_tag_t dmat; - bus_dmamap_t dmam; - size_t dmasize; - int lxfer, resid, trans; - uint32_t csr; - - csr = L64854_GCSR(sc); - - DPRINTF(LDB_SCSI, ("%s: addr 0x%x, csr %b\n", __func__, - bus_read_4(sc->sc_res, L64854_REG_ADDR), csr, DDMACSR_BITS)); - - if (csr & (D_ERR_PEND | D_SLAVE_ERR)) { - device_printf(sc->sc_dev, "error: csr=%b\n", csr, - DDMACSR_BITS); - csr &= ~D_EN_DMA; /* Stop DMA. */ - /* Invalidate the queue; SLAVE_ERR bit is write-to-clear */ - csr |= D_INVALIDATE | D_SLAVE_ERR; - L64854_SCSR(sc, csr); - return (-1); - } - - /* This is an "assertion" :) */ - if (sc->sc_active == 0) - panic("%s: DMA wasn't active", __func__); - - DMA_DRAIN(sc, 0); - - /* DMA has stopped */ - csr &= ~D_EN_DMA; - L64854_SCSR(sc, csr); - sc->sc_active = 0; - - dmasize = sc->sc_dmasize; - if (dmasize == 0) { - /* A "Transfer Pad" operation completed. */ - DPRINTF(LDB_SCSI, ("%s: discarded %d bytes (tcl=%d, " - "tcm=%d)\n", __func__, NCR_READ_REG(nsc, NCR_TCL) | - (NCR_READ_REG(nsc, NCR_TCM) << 8), - NCR_READ_REG(nsc, NCR_TCL), NCR_READ_REG(nsc, NCR_TCM))); - return (0); - } - - resid = 0; - /* - * If a transfer onto the SCSI bus gets interrupted by the device - * (e.g. for a SAVEPOINTER message), the data in the FIFO counts - * as residual since the NCR53C9X counter registers get decremented - * as bytes are clocked into the FIFO. - */ - if ((csr & D_WRITE) == 0 && - (resid = (NCR_READ_REG(nsc, NCR_FFLAG) & NCRFIFO_FF)) != 0) { - DPRINTF(LDB_SCSI, ("%s: empty esp FIFO of %d ", __func__, - resid)); - if (nsc->sc_rev == NCR_VARIANT_FAS366 && - (NCR_READ_REG(nsc, NCR_CFG3) & NCRFASCFG3_EWIDE)) - resid <<= 1; - } - - if ((nsc->sc_espstat & NCRSTAT_TC) == 0) { - lxfer = nsc->sc_features & NCR_F_LARGEXFER; - /* - * "Terminal count" is off, so read the residue - * out of the NCR53C9X counter registers. - */ - resid += (NCR_READ_REG(nsc, NCR_TCL) | - (NCR_READ_REG(nsc, NCR_TCM) << 8) | - (lxfer != 0 ? (NCR_READ_REG(nsc, NCR_TCH) << 16) : 0)); - - if (resid == 0 && dmasize == 65536 && lxfer == 0) - /* A transfer of 64k is encoded as TCL=TCM=0. */ - resid = 65536; - } - - trans = dmasize - resid; - if (trans < 0) { /* transferred < 0? */ -#if 0 - /* - * This situation can happen in perfectly normal operation - * if the ESP is reselected while using DMA to select - * another target. As such, don't print the warning. - */ - device_printf(sc->sc_dev, "xfer (%d) > req (%d)\n", trans, - dmasize); -#endif - trans = dmasize; - } - - DPRINTF(LDB_SCSI, ("%s: tcl=%d, tcm=%d, tch=%d; trans=%d, resid=%d\n", - __func__, NCR_READ_REG(nsc, NCR_TCL), NCR_READ_REG(nsc, NCR_TCM), - (nsc->sc_features & NCR_F_LARGEXFER) != 0 ? - NCR_READ_REG(nsc, NCR_TCH) : 0, trans, resid)); - - if (dmasize != 0) { - dmat = sc->sc_buffer_dmat; - dmam = sc->sc_dmamap; - bus_dmamap_sync(dmat, dmam, (csr & D_WRITE) != 0 ? - BUS_DMASYNC_POSTREAD : BUS_DMASYNC_POSTWRITE); - bus_dmamap_unload(dmat, dmam); - } - - *sc->sc_dmalen -= trans; - *sc->sc_dmaaddr = (char *)*sc->sc_dmaaddr + trans; - -#if 0 /* this is not normal operation just yet */ - if (*sc->sc_dmalen == 0 || nsc->sc_phase != nsc->sc_prevphase) - return (0); - - /* and again */ - dma_start(sc, sc->sc_dmaaddr, sc->sc_dmalen, DMACSR(sc) & D_WRITE); - return (1); -#endif - return (0); -} - -/* - * Pseudo (chained) interrupt to le(4) driver to handle DMA errors - */ -static int -lsi64854_enet_intr(void *arg) -{ - struct lsi64854_softc *sc = arg; - uint32_t csr; - int i, rv; - - csr = L64854_GCSR(sc); - - /* If the DMA logic shows an interrupt, claim it */ - rv = ((csr & E_INT_PEND) != 0) ? 1 : 0; - - if (csr & (E_ERR_PEND | E_SLAVE_ERR)) { - device_printf(sc->sc_dev, "error: csr=%b\n", csr, - EDMACSR_BITS); - csr &= ~L64854_EN_DMA; /* Stop DMA. */ - /* Invalidate the queue; SLAVE_ERR bit is write-to-clear */ - csr |= E_INVALIDATE | E_SLAVE_ERR; - L64854_SCSR(sc, csr); - /* Will be drained with the LE_C0_IDON interrupt. */ - sc->sc_dodrain = 1; - return (-1); - } - - /* XXX - is this necessary with E_DSBL_WR_INVAL on? */ - if (sc->sc_dodrain) { - i = 10; - csr |= E_DRAIN; - L64854_SCSR(sc, csr); - while (i-- > 0 && (L64854_GCSR(sc) & E_DRAINING)) - DELAY(1); - sc->sc_dodrain = 0; - } - - return (rv); -} - -static void -lsi64854_map_pp(void *arg, bus_dma_segment_t *segs, int nsegs, int error) -{ - struct lsi64854_softc *sc; - - sc = (struct lsi64854_softc *)arg; - - if (error != 0) - return; - if (nsegs != 1) - panic("%s: cannot map %d segments\n", __func__, nsegs); - - bus_dmamap_sync(sc->sc_buffer_dmat, sc->sc_dmamap, - sc->sc_datain != 0 ? BUS_DMASYNC_PREREAD : BUS_DMASYNC_PREWRITE); - bus_write_4(sc->sc_res, L64854_REG_ADDR, segs[0].ds_addr); - - bus_write_4(sc->sc_res, L64854_REG_CNT, sc->sc_dmasize); -} - -/* - * Setup a DMA transfer. - */ -static int -lsi64854_setup_pp(struct lsi64854_softc *sc, void **addr, size_t *len, - int datain, size_t *dmasize) -{ - int error; - uint32_t csr; - - DMA_FLUSH(sc, 0); - - sc->sc_dmaaddr = addr; - sc->sc_dmalen = len; - sc->sc_datain = datain; - - DPRINTF(LDB_PP, ("%s: pp start %ld@%p,%d\n", __func__, - (long)*sc->sc_dmalen, *sc->sc_dmaaddr, datain != 0 ? 1 : 0)); - - KASSERT(*dmasize <= sc->sc_maxdmasize, - ("%s: transfer size %ld too large", __func__, (long)*dmasize)); - - sc->sc_dmasize = *dmasize; - - DPRINTF(LDB_PP, ("%s: dmasize=%ld\n", __func__, (long)*dmasize)); - - /* Load the transfer buffer and program the DMA address. */ - if (*dmasize != 0) { - error = bus_dmamap_load(sc->sc_buffer_dmat, sc->sc_dmamap, - *sc->sc_dmaaddr, *dmasize, lsi64854_map_pp, sc, - BUS_DMA_NOWAIT); - if (error != 0) - return (error); - } - - /* Setup the DMA control register. */ - csr = L64854_GCSR(sc); - csr &= ~L64854_BURST_SIZE; - if (sc->sc_burst == 32) - csr |= L64854_BURST_32; - else if (sc->sc_burst == 16) - csr |= L64854_BURST_16; - else - csr |= L64854_BURST_0; - csr |= P_EN_DMA | P_INT_EN | P_EN_CNT; -#if 0 - /* This bit is read-only in PP csr register. */ - if (datain != 0) - csr |= P_WRITE; - else - csr &= ~P_WRITE; -#endif - L64854_SCSR(sc, csr); - - return (0); -} - -/* - * Parallel port DMA interrupt - */ -static int -lsi64854_pp_intr(void *arg) -{ - struct lsi64854_softc *sc = arg; - bus_dma_tag_t dmat; - bus_dmamap_t dmam; - size_t dmasize; - int ret, trans, resid = 0; - uint32_t csr; - - csr = L64854_GCSR(sc); - - DPRINTF(LDB_PP, ("%s: addr 0x%x, csr %b\n", __func__, - bus_read_4(sc->sc_res, L64854_REG_ADDR), csr, PDMACSR_BITS)); - - if ((csr & (P_ERR_PEND | P_SLAVE_ERR)) != 0) { - resid = bus_read_4(sc->sc_res, L64854_REG_CNT); - device_printf(sc->sc_dev, "error: resid %d csr=%b\n", resid, - csr, PDMACSR_BITS); - csr &= ~P_EN_DMA; /* Stop DMA. */ - /* Invalidate the queue; SLAVE_ERR bit is write-to-clear */ - csr |= P_INVALIDATE | P_SLAVE_ERR; - L64854_SCSR(sc, csr); - return (-1); - } - - ret = (csr & P_INT_PEND) != 0; - - if (sc->sc_active != 0) { - DMA_DRAIN(sc, 0); - resid = bus_read_4(sc->sc_res, L64854_REG_CNT); - } - - /* DMA has stopped */ - csr &= ~D_EN_DMA; - L64854_SCSR(sc, csr); - sc->sc_active = 0; - - dmasize = sc->sc_dmasize; - trans = dmasize - resid; - if (trans < 0) /* transferred < 0? */ - trans = dmasize; - *sc->sc_dmalen -= trans; - *sc->sc_dmaaddr = (char *)*sc->sc_dmaaddr + trans; - - if (dmasize != 0) { - dmat = sc->sc_buffer_dmat; - dmam = sc->sc_dmamap; - bus_dmamap_sync(dmat, dmam, (csr & D_WRITE) != 0 ? - BUS_DMASYNC_POSTREAD : BUS_DMASYNC_POSTWRITE); - bus_dmamap_unload(dmat, dmam); - } - - return (ret != 0); -} diff --git a/sys/sparc64/sbus/lsi64854reg.h b/sys/sparc64/sbus/lsi64854reg.h deleted file mode 100644 index 9726ec07d1e4..000000000000 --- a/sys/sparc64/sbus/lsi64854reg.h +++ /dev/null @@ -1,200 +0,0 @@ -/* $NetBSD: lsi64854reg.h,v 1.6 2008/04/28 20:23:50 martin Exp $ */ - -/*- - * SPDX-License-Identifier: BSD-2-Clause-NetBSD - * - * Copyright (c) 1998 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Paul Kranenburg. - * - * 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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$ */ - -/* - * LSI 64854 DMA engine. Contains three independent channels - * designed to interface with (a) a NCR539X SCSI controller, - * (b) a AM7990 Ethernet controller, (c) Parallel port hardware.. - */ - -/* - * Register offsets to bus handle. - */ -#define L64854_REG_CSR 0 /* Control bits */ -#define L64854_REG_ADDR 4 /* DMA Address */ -#define L64854_REG_CNT 8 /* DMA count */ -#define L64854_REG_CNT_MASK 0x00ffffff /* only 24 bits */ -#define L64854_REG_ENBAR 12 /* ENET Base register */ -#define L64854_REG_TEST 12 /* SCSI Test register */ -#define L64854_REG_HCR 16 /* PP Hardware Configuration */ -#define L64854_REG_OCR 18 /* PP Operation Configuration */ -#define L64854_REG_DR 20 /* PP Data register */ -#define L64854_REG_TCR 21 /* PP Transfer Control */ -#define L64854_REG_OR 22 /* PP Output register */ -#define L64854_REG_IR 23 /* PP Input register */ -#define L64854_REG_ICR 24 /* PP Interrupt Control */ - - -/* - * Control bits common to all three channels. - */ -#define L64854_INT_PEND 0x00000001 /* Interrupt pending */ -#define L64854_ERR_PEND 0x00000002 /* Error pending */ -#define L64854_DRAINING 0x0000000c /* FIFO draining */ -#define L64854_INT_EN 0x00000010 /* Interrupt enable */ -#define L64854_INVALIDATE 0x00000020 /* Invalidate FIFO */ -#define L64854_SLAVE_ERR 0x00000040 /* Slave access size error */ -#define L64854_RESET 0x00000080 /* Reset device */ -#define L64854_WRITE 0x00000100 /* 1: xfer to memory */ -#define L64854_EN_DMA 0x00000200 /* enable DMA transfers */ - -#define L64854_BURST_SIZE 0x000c0000 /* Read/write burst size */ -#define L64854_BURST_0 0x00080000 /* no bursts (SCSI-only) */ -#define L64854_BURST_16 0x00000000 /* 16-byte bursts */ -#define L64854_BURST_32 0x00040000 /* 32-byte bursts */ -#define L64854_BURST_64 0x000c0000 /* 64-byte bursts (fas) */ - -#define L64854_RST_FAS366 0x08000000 /* FAS366 hardware reset */ - -#define L64854_DEVID 0xf0000000 /* device ID bits */ - -/* - * SCSI DMA control bits. - */ -#define D_INT_PEND L64854_INT_PEND /* interrupt pending */ -#define D_ERR_PEND L64854_ERR_PEND /* error pending */ -#define D_DRAINING L64854_DRAINING /* fifo draining */ -#define D_INT_EN L64854_INT_EN /* interrupt enable */ -#define D_INVALIDATE L64854_INVALIDATE/* invalidate fifo */ -#define D_SLAVE_ERR L64854_SLAVE_ERR/* slave access size error */ -#define D_RESET L64854_RESET /* reset scsi */ -#define D_WRITE L64854_WRITE /* 1 = dev -> mem */ -#define D_EN_DMA L64854_EN_DMA /* enable DMA requests */ -#define D_EN_CNT 0x00002000 /* enable byte counter */ -#define D_TC 0x00004000 /* terminal count */ -#define D_WIDE_EN 0x00008000 /* enable wide mode SBUS DMA (fas) */ -#define D_DSBL_CSR_DRN 0x00010000 /* disable fifo drain on csr */ -#define D_DSBL_SCSI_DRN 0x00020000 /* disable fifo drain on reg */ - -#define D_DIAG 0x00100000 /* disable fifo drain on addr */ -#define D_TWO_CYCLE 0x00200000 /* 2 clocks per transfer */ -#define D_FASTER 0x00400000 /* 3 clocks per transfer */ -#define D_TCI_DIS 0x00800000 /* disable intr on D_TC */ -#define D_EN_NEXT 0x01000000 /* enable auto next address */ -#define D_DMA_ON 0x02000000 /* enable dma from scsi XXX */ -#define D_DSBL_PARITY_CHK \ - 0x02000000 /* disable checking for parity on bus (default 1:fas) */ -#define D_A_LOADED 0x04000000 /* address loaded */ -#define D_NA_LOADED 0x08000000 /* next address loaded */ -#define D_HW_RESET_FAS366 \ - 0x08000000 /* hardware reset FAS366 (fas) */ -#define D_DEV_ID L64854_DEVID /* device ID */ -#define DMAREV_0 0x00000000 /* Sunray DMA */ -#define DMAREV_ESC 0x40000000 /* DMA ESC array */ -#define DMAREV_1 0x80000000 /* 'DMA' */ -#define DMAREV_PLUS 0x90000000 /* 'DMA+' */ -#define DMAREV_2 0xa0000000 /* 'DMA2' */ -#define DMAREV_HME 0xb0000000 /* 'HME' */ - -/* - * revisions 0,1 and ESC have different bits. - */ -#define D_ESC_DRAIN 0x00000040 /* rev0,1,esc: drain fifo */ -#define D_ESC_R_PEND 0x00000400 /* rev0,1: request pending */ -#define D_ESC_BURST 0x00000800 /* DMA ESC: 16 byte bursts */ -#define D_ESC_AUTODRAIN 0x00040000 /* DMA ESC: Auto-drain */ - -#define DDMACSR_BITS "\177\020" \ - "b\00INT\0b\01ERR\0f\02\02DRAINING\0b\04IEN\0" \ - "b\06SLVERR\0b\07RST\0b\10WRITE\0b\11ENDMA\0" \ - "b\15ENCNT\0b\16TC\0\b\20DSBL_CSR_DRN\0" \ - "b\21DSBL_SCSI_DRN\0f\22\2BURST\0b\25TWOCYCLE\0" \ - "b\26FASTER\0b\27TCIDIS\0b\30ENNXT\0b\031DMAON\0" \ - "b\32ALOADED\0b\33NALOADED\0" - - -/* - * ENET DMA control bits. - */ -#define E_INT_PEND L64854_INT_PEND /* interrupt pending */ -#define E_ERR_PEND L64854_ERR_PEND /* error pending */ -#define E_DRAINING L64854_DRAINING /* fifo draining */ -#define E_INT_EN L64854_INT_EN /* interrupt enable */ -#define E_INVALIDATE L64854_INVALIDATE/* invalidate fifo */ -#define E_SLAVE_ERR L64854_SLAVE_ERR/* slave access size error */ -#define E_RESET L64854_RESET /* reset ENET */ -#define E_reserved1 0x00000300 /* */ -#define E_DRAIN 0x00000400 /* force Ecache drain */ -#define E_DSBL_WR_DRN 0x00000800 /* disable Ecache drain on .. */ -#define E_DSBL_RD_DRN 0x00001000 /* disable Ecache drain on .. */ -#define E_reserved2 0x00006000 /* */ -#define E_ILACC 0x00008000 /* ... */ -#define E_DSBL_BUF_WR 0x00010000 /* no buffering of slave writes */ -#define E_DSBL_WR_INVAL 0x00020000 /* no Ecache invalidate on slave writes */ - -#define E_reserved3 0x00100000 /* */ -#define E_LOOP_TEST 0x00200000 /* loopback mode */ -#define E_TP_AUI 0x00400000 /* 1 for TP, 0 for AUI */ -#define E_reserved4 0x0c800000 /* */ -#define E_DEV_ID L64854_DEVID /* ID bits */ - -#define EDMACSR_BITS "\177\020" \ - "b\00INT\0b\01ERR\0f\02\02DRAINING\0b\04IEN\0" \ - "b\06SLVERR\0b\07RST\0b\10WRITE\0b\12DRAIN\0" \ - "b\13DSBL_WR_DRN\0b\14DSBL_RD_DRN\0b\17ILACC\0" \ - "b\20DSBL_BUF_WR\0b\21DSBL_WR_INVAL\0" \ - "b\25LOOPTEST\0b\26TP\0" - -/* - * PP DMA control bits. - */ -#define P_INT_PEND L64854_INT_PEND /* interrupt pending */ -#define P_ERR_PEND L64854_ERR_PEND /* error pending */ -#define P_DRAINING L64854_DRAINING /* fifo draining */ -#define P_INT_EN L64854_INT_EN /* interrupt enable */ -#define P_INVALIDATE L64854_INVALIDATE/* invalidate fifo */ -#define P_SLAVE_ERR L64854_SLAVE_ERR/* slave access size error */ -#define P_RESET L64854_RESET /* reset PP */ -#define P_WRITE L64854_WRITE /* 1: xfer to memory */ -#define P_EN_DMA L64854_EN_DMA /* enable DMA transfers */ -#define P_reserved1 0x00001c00 /* */ -#define P_EN_CNT 0x00002000 /* enable counter */ -#define P_TC 0x00004000 /* terminal count */ -#define P_reserved2 0x00038000 /* */ - -#define P_DIAG 0x00100000 /* ... */ -#define P_reserved3 0x00600000 /* */ -#define P_TCI_DIS 0x00800000 /* no interrupt on terminal count */ -#define P_EN_NEXT 0x01000000 /* enable DMA chaining */ -#define P_DMA_ON 0x02000000 /* DMA xfers enabled */ -#define P_A_LOADED 0x04000000 /* addr and byte count valid */ -#define P_NA_LOADED 0x08000000 /* next addr & count valid but not used */ -#define P_DEV_ID L64854_DEVID /* ID bits */ - -#define PDMACSR_BITS "\177\020" \ - "b\00INT\0b\01ERR\0f\02\02DRAINING\0b\04IEN\0" \ - "b\06SLVERR\0b\07RST\0b\10WRITE\0b\11ENDMA\0" \ - "b\15ENCNT\0b\16TC\0\b\24DIAG\0b\27TCIDIS\0" \ - "b\30ENNXT\0b\031DMAON\0b\32ALOADED\0b\33NALOADED\0" diff --git a/sys/sparc64/sbus/lsi64854var.h b/sys/sparc64/sbus/lsi64854var.h deleted file mode 100644 index b47a013957af..000000000000 --- a/sys/sparc64/sbus/lsi64854var.h +++ /dev/null @@ -1,96 +0,0 @@ -/* $NetBSD: lsi64854var.h,v 1.12 2008/04/28 20:23:50 martin Exp $ */ - -/*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD - * - * Copyright (c) 1998 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Paul Kranenburg. - * - * 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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$ */ - -struct lsi64854_softc { - device_t sc_dev; - - struct resource *sc_res; - u_int sc_rev; /* revision */ - int sc_burst; /* max suported burst size */ - - int sc_channel; -#define L64854_CHANNEL_SCSI 1 -#define L64854_CHANNEL_ENET 2 -#define L64854_CHANNEL_PP 3 - void *sc_client; - - int sc_active; /* DMA active? */ - bus_dmamap_t sc_dmamap; /* DMA map for bus_dma_* */ - - bus_dma_tag_t sc_parent_dmat; - bus_dma_tag_t sc_buffer_dmat; - bus_size_t sc_maxdmasize; - int sc_datain; - size_t sc_dmasize; - void **sc_dmaaddr; - size_t *sc_dmalen; - - void (*reset)(struct lsi64854_softc *);/* reset routine */ - int (*setup)(struct lsi64854_softc *, void **, size_t *, - int, size_t *); /* DMA setup */ - int (*intr)(void *); /* interrupt handler */ - - u_int sc_dmactl; - int sc_dodrain; -}; - -#define L64854_GCSR(sc) bus_read_4((sc)->sc_res, L64854_REG_CSR) -#define L64854_SCSR(sc, csr) bus_write_4((sc)->sc_res, L64854_REG_CSR, csr) - -/* - * DMA engine interface functions. - */ -#define DMA_RESET(sc) (((sc)->reset)(sc)) -#define DMA_INTR(sc) (((sc)->intr)(sc)) -#define DMA_SETUP(sc, a, l, d, s) (((sc)->setup)(sc, a, l, d, s)) -#define DMA_ISACTIVE(sc) ((sc)->sc_active) - -#define DMA_ENINTR(sc) do { \ - uint32_t csr = L64854_GCSR(sc); \ - csr |= L64854_INT_EN; \ - L64854_SCSR(sc, csr); \ -} while (/* CONSTCOND */0) - -#define DMA_ISINTR(sc) (L64854_GCSR(sc) & (D_INT_PEND|D_ERR_PEND)) - -#define DMA_GO(sc) do { \ - uint32_t csr = L64854_GCSR(sc); \ - csr |= D_EN_DMA; \ - L64854_SCSR(sc, csr); \ - sc->sc_active = 1; \ -} while (/* CONSTCOND */0) - -int lsi64854_attach(struct lsi64854_softc *); -int lsi64854_detach(struct lsi64854_softc *); diff --git a/sys/sparc64/sbus/ofw_sbus.h b/sys/sparc64/sbus/ofw_sbus.h deleted file mode 100644 index 38cad40a6839..000000000000 --- a/sys/sparc64/sbus/ofw_sbus.h +++ /dev/null @@ -1,55 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD - * - * Copyright (c) 1998 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Paul Kranenburg. - * - * 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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. - * - * from: NetBSD: sbusvar.h,v 1.15 2008/04/28 20:23:36 martin Exp - * - * $FreeBSD$ - */ - -#ifndef _SPARC64_SBUS_OFW_SBUS_H_ -#define _SPARC64_SBUS_OFW_SBUS_H_ - -/* Device register space description */ -struct sbus_regs { - u_int32_t sbr_slot; - u_int32_t sbr_offset; - u_int32_t sbr_size; -}; - -/* Address translation across busses */ -struct sbus_ranges { - u_int32_t cspace; /* Client space */ - u_int32_t coffset; /* Client offset */ - u_int32_t pspace; /* Parent space */ - u_int32_t poffset; /* Parent offset */ - u_int32_t size; /* Size in bytes of this range */ -}; - -#endif /* ! _SPARC64_SBUS_OFW_SBUS_H_ */ diff --git a/sys/sparc64/sbus/sbus.c b/sys/sparc64/sbus/sbus.c deleted file mode 100644 index 7731d97fb471..000000000000 --- a/sys/sparc64/sbus/sbus.c +++ /dev/null @@ -1,938 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-3-Clause - * - * Copyright (c) 1999-2002 Eduardo Horvath - * 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. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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. - * - * from: NetBSD: sbus.c,v 1.50 2002/06/20 18:26:24 eeh Exp - */ -/*- - * Copyright (c) 2002 by Thomas Moestl . - * Copyright (c) 2005 Marius Strobl - * 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. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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 -__FBSDID("$FreeBSD$"); - -/* - * SBus support. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -struct sbus_devinfo { - int sdi_burstsz; - int sdi_clockfreq; - int sdi_slot; - - struct ofw_bus_devinfo sdi_obdinfo; - struct resource_list sdi_rl; -}; - -/* Range descriptor, allocated for each sc_range. */ -struct sbus_rd { - bus_addr_t rd_poffset; - bus_addr_t rd_pend; - int rd_slot; - bus_addr_t rd_coffset; - bus_addr_t rd_cend; - struct rman rd_rman; - bus_space_handle_t rd_bushandle; - struct resource *rd_res; -}; - -struct sbus_softc { - device_t sc_dev; - bus_dma_tag_t sc_cdmatag; - int sc_clockfreq; /* clock frequency (in Hz) */ - int sc_nrange; - struct sbus_rd *sc_rd; - int sc_burst; /* burst transfer sizes supp. */ - - struct resource *sc_sysio_res; - int sc_ign; /* IGN for this sysio */ - struct iommu_state sc_is; /* IOMMU state (iommuvar.h) */ - - struct resource *sc_ot_ires; - void *sc_ot_ihand; - struct resource *sc_pf_ires; - void *sc_pf_ihand; -}; - -#define SYSIO_READ8(sc, off) \ - bus_read_8((sc)->sc_sysio_res, (off)) -#define SYSIO_WRITE8(sc, off, v) \ - bus_write_8((sc)->sc_sysio_res, (off), (v)) - -static device_probe_t sbus_probe; -static device_attach_t sbus_attach; -static bus_print_child_t sbus_print_child; -static bus_probe_nomatch_t sbus_probe_nomatch; -static bus_read_ivar_t sbus_read_ivar; -static bus_get_resource_list_t sbus_get_resource_list; -static bus_setup_intr_t sbus_setup_intr; -static bus_alloc_resource_t sbus_alloc_resource; -static bus_activate_resource_t sbus_activate_resource; -static bus_adjust_resource_t sbus_adjust_resource; -static bus_release_resource_t sbus_release_resource; -static bus_get_dma_tag_t sbus_get_dma_tag; -static ofw_bus_get_devinfo_t sbus_get_devinfo; - -static int sbus_inlist(const char *, const char *const *); -static struct sbus_devinfo * sbus_setup_dinfo(device_t, struct sbus_softc *, - phandle_t); -static void sbus_destroy_dinfo(struct sbus_devinfo *); -static void sbus_intr_enable(void *); -static void sbus_intr_disable(void *); -static void sbus_intr_assign(void *); -static void sbus_intr_clear(void *); -static int sbus_find_intrmap(struct sbus_softc *, u_int, bus_addr_t *, - bus_addr_t *); -static driver_intr_t sbus_overtemp; -static driver_intr_t sbus_pwrfail; -static int sbus_print_res(struct sbus_devinfo *); - -static device_method_t sbus_methods[] = { - /* Device interface */ - DEVMETHOD(device_probe, sbus_probe), - DEVMETHOD(device_attach, sbus_attach), - DEVMETHOD(device_shutdown, bus_generic_shutdown), - DEVMETHOD(device_suspend, bus_generic_suspend), - DEVMETHOD(device_resume, bus_generic_resume), - - /* Bus interface */ - DEVMETHOD(bus_print_child, sbus_print_child), - DEVMETHOD(bus_probe_nomatch, sbus_probe_nomatch), - DEVMETHOD(bus_read_ivar, sbus_read_ivar), - DEVMETHOD(bus_alloc_resource, sbus_alloc_resource), - DEVMETHOD(bus_activate_resource, sbus_activate_resource), - DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource), - DEVMETHOD(bus_adjust_resource, sbus_adjust_resource), - DEVMETHOD(bus_release_resource, sbus_release_resource), - DEVMETHOD(bus_setup_intr, sbus_setup_intr), - DEVMETHOD(bus_teardown_intr, bus_generic_teardown_intr), - DEVMETHOD(bus_get_resource, bus_generic_rl_get_resource), - DEVMETHOD(bus_get_resource_list, sbus_get_resource_list), - DEVMETHOD(bus_child_pnpinfo_str, ofw_bus_gen_child_pnpinfo_str), - DEVMETHOD(bus_get_dma_tag, sbus_get_dma_tag), - - /* ofw_bus interface */ - DEVMETHOD(ofw_bus_get_devinfo, sbus_get_devinfo), - DEVMETHOD(ofw_bus_get_compat, ofw_bus_gen_get_compat), - DEVMETHOD(ofw_bus_get_model, ofw_bus_gen_get_model), - DEVMETHOD(ofw_bus_get_name, ofw_bus_gen_get_name), - DEVMETHOD(ofw_bus_get_node, ofw_bus_gen_get_node), - DEVMETHOD(ofw_bus_get_type, ofw_bus_gen_get_type), - - DEVMETHOD_END -}; - -static driver_t sbus_driver = { - "sbus", - sbus_methods, - sizeof(struct sbus_softc), -}; - -static devclass_t sbus_devclass; - -EARLY_DRIVER_MODULE(sbus, nexus, sbus_driver, sbus_devclass, NULL, NULL, - BUS_PASS_BUS); -MODULE_DEPEND(sbus, nexus, 1, 1, 1); -MODULE_VERSION(sbus, 1); - -#define OFW_SBUS_TYPE "sbus" -#define OFW_SBUS_NAME "sbus" - -static const struct intr_controller sbus_ic = { - sbus_intr_enable, - sbus_intr_disable, - sbus_intr_assign, - sbus_intr_clear -}; - -struct sbus_icarg { - struct sbus_softc *sica_sc; - bus_addr_t sica_map; - bus_addr_t sica_clr; -}; - -static const char *const sbus_order_first[] = { - "auxio", - "dma", - NULL -}; - -static int -sbus_inlist(const char *name, const char *const *list) -{ - int i; - - if (name == NULL) - return (0); - for (i = 0; list[i] != NULL; i++) { - if (strcmp(name, list[i]) == 0) - return (1); - } - return (0); -} - -static int -sbus_probe(device_t dev) -{ - const char *t; - - t = ofw_bus_get_type(dev); - if (((t == NULL || strcmp(t, OFW_SBUS_TYPE) != 0)) && - strcmp(ofw_bus_get_name(dev), OFW_SBUS_NAME) != 0) - return (ENXIO); - device_set_desc(dev, "U2S UPA-SBus bridge"); - return (0); -} - -static int -sbus_attach(device_t dev) -{ - struct sbus_softc *sc; - struct sbus_devinfo *sdi; - struct sbus_icarg *sica; - struct sbus_ranges *range; - struct resource *res; - struct resource_list *rl; - device_t cdev; - bus_addr_t intrclr, intrmap, phys; - bus_size_t size; - u_long vec; - phandle_t child, node; - uint32_t prop; - int i, j; - - sc = device_get_softc(dev); - sc->sc_dev = dev; - node = ofw_bus_get_node(dev); - - i = 0; - sc->sc_sysio_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &i, - RF_ACTIVE); - if (sc->sc_sysio_res == NULL) - panic("%s: cannot allocate device memory", __func__); - - if (OF_getprop(node, "interrupts", &prop, sizeof(prop)) == -1) - panic("%s: cannot get IGN", __func__); - sc->sc_ign = INTIGN(prop); - - /* - * Record clock frequency for synchronous SCSI. - * IS THIS THE CORRECT DEFAULT?? - */ - if (OF_getprop(node, "clock-frequency", &prop, sizeof(prop)) == -1) - prop = 25000000; - sc->sc_clockfreq = prop; - prop /= 1000; - device_printf(dev, "clock %d.%03d MHz\n", prop / 1000, prop % 1000); - - /* - * Collect address translations from the OBP. - */ - if ((sc->sc_nrange = OF_getprop_alloc_multi(node, "ranges", - sizeof(*range), (void **)&range)) == -1) { - panic("%s: error getting ranges property", __func__); - } - sc->sc_rd = malloc(sizeof(*sc->sc_rd) * sc->sc_nrange, M_DEVBUF, - M_NOWAIT | M_ZERO); - if (sc->sc_rd == NULL) - panic("%s: cannot allocate rmans", __func__); - /* - * Preallocate all space that the SBus bridge decodes, so that nothing - * else gets in the way; set up rmans etc. - */ - rl = BUS_GET_RESOURCE_LIST(device_get_parent(dev), dev); - for (i = 0; i < sc->sc_nrange; i++) { - phys = range[i].poffset | ((bus_addr_t)range[i].pspace << 32); - size = range[i].size; - sc->sc_rd[i].rd_slot = range[i].cspace; - sc->sc_rd[i].rd_coffset = range[i].coffset; - sc->sc_rd[i].rd_cend = sc->sc_rd[i].rd_coffset + size; - j = resource_list_add_next(rl, SYS_RES_MEMORY, phys, - phys + size - 1, size); - if ((res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &j, - RF_ACTIVE)) == NULL) - panic("%s: cannot allocate decoded range", __func__); - sc->sc_rd[i].rd_bushandle = rman_get_bushandle(res); - sc->sc_rd[i].rd_rman.rm_type = RMAN_ARRAY; - sc->sc_rd[i].rd_rman.rm_descr = "SBus Device Memory"; - if (rman_init(&sc->sc_rd[i].rd_rman) != 0 || - rman_manage_region(&sc->sc_rd[i].rd_rman, 0, size) != 0) - panic("%s: failed to set up memory rman", __func__); - sc->sc_rd[i].rd_poffset = phys; - sc->sc_rd[i].rd_pend = phys + size; - sc->sc_rd[i].rd_res = res; - } - OF_prop_free(range); - - /* - * Get the SBus burst transfer size if burst transfers are supported. - */ - if (OF_getprop(node, "up-burst-sizes", &sc->sc_burst, - sizeof(sc->sc_burst)) == -1 || sc->sc_burst == 0) - sc->sc_burst = - (SBUS_BURST64_DEF << SBUS_BURST64_SHIFT) | SBUS_BURST_DEF; - - /* initialise the IOMMU */ - - /* punch in our copies */ - sc->sc_is.is_pmaxaddr = IOMMU_MAXADDR(SBUS_IOMMU_BITS); - sc->sc_is.is_bustag = rman_get_bustag(sc->sc_sysio_res); - sc->sc_is.is_bushandle = rman_get_bushandle(sc->sc_sysio_res); - sc->sc_is.is_iommu = SBR_IOMMU; - sc->sc_is.is_dtag = SBR_IOMMU_TLB_TAG_DIAG; - sc->sc_is.is_ddram = SBR_IOMMU_TLB_DATA_DIAG; - sc->sc_is.is_dqueue = SBR_IOMMU_QUEUE_DIAG; - sc->sc_is.is_dva = SBR_IOMMU_SVADIAG; - sc->sc_is.is_dtcmp = 0; - sc->sc_is.is_sb[0] = SBR_STRBUF; - sc->sc_is.is_sb[1] = 0; - - /* - * Note: the SBus IOMMU ignores the high bits of an address, so a NULL - * DMA pointer will be translated by the first page of the IOTSB. - * To detect bugs we'll allocate and ignore the first entry. - */ - iommu_init(device_get_nameunit(dev), &sc->sc_is, 3, -1, 1); - - /* Create the DMA tag. */ - if (bus_dma_tag_create(bus_get_dma_tag(dev), 8, 0, - sc->sc_is.is_pmaxaddr, ~0, NULL, NULL, sc->sc_is.is_pmaxaddr, - 0xff, 0xffffffff, 0, NULL, NULL, &sc->sc_cdmatag) != 0) - panic("%s: bus_dma_tag_create failed", __func__); - /* Customize the tag. */ - sc->sc_cdmatag->dt_cookie = &sc->sc_is; - sc->sc_cdmatag->dt_mt = &iommu_dma_methods; - - /* - * Hunt through all the interrupt mapping regs and register our - * interrupt controller for the corresponding interrupt vectors. - * We do this early in order to be able to catch stray interrupts. - */ - for (i = 0; i <= SBUS_MAX_INO; i++) { - if (sbus_find_intrmap(sc, i, &intrmap, &intrclr) == 0) - continue; - sica = malloc(sizeof(*sica), M_DEVBUF, M_NOWAIT); - if (sica == NULL) - panic("%s: could not allocate interrupt controller " - "argument", __func__); - sica->sica_sc = sc; - sica->sica_map = intrmap; - sica->sica_clr = intrclr; -#ifdef SBUS_DEBUG - device_printf(dev, - "intr map (INO %d, %s) %#lx: %#lx, clr: %#lx\n", - i, (i & INTMAP_OBIO_MASK) == 0 ? "SBus slot" : "OBIO", - (u_long)intrmap, (u_long)SYSIO_READ8(sc, intrmap), - (u_long)intrclr); -#endif - j = intr_controller_register(INTMAP_VEC(sc->sc_ign, i), - &sbus_ic, sica); - if (j != 0) - device_printf(dev, "could not register interrupt " - "controller for INO %d (%d)\n", i, j); - } - - /* Enable the over-temperature and power-fail interrupts. */ - i = 4; - sc->sc_ot_ires = bus_alloc_resource_any(dev, SYS_RES_IRQ, &i, - RF_ACTIVE); - if (sc->sc_ot_ires == NULL || - INTIGN(vec = rman_get_start(sc->sc_ot_ires)) != sc->sc_ign || - INTVEC(SYSIO_READ8(sc, SBR_THERM_INT_MAP)) != vec || - intr_vectors[vec].iv_ic != &sbus_ic || - bus_setup_intr(dev, sc->sc_ot_ires, INTR_TYPE_MISC | INTR_BRIDGE | INTR_MPSAFE, - NULL, sbus_overtemp, sc, &sc->sc_ot_ihand) != 0) - panic("%s: failed to set up temperature interrupt", __func__); - i = 3; - sc->sc_pf_ires = bus_alloc_resource_any(dev, SYS_RES_IRQ, &i, - RF_ACTIVE); - if (sc->sc_pf_ires == NULL || - INTIGN(vec = rman_get_start(sc->sc_pf_ires)) != sc->sc_ign || - INTVEC(SYSIO_READ8(sc, SBR_POWER_INT_MAP)) != vec || - intr_vectors[vec].iv_ic != &sbus_ic || - bus_setup_intr(dev, sc->sc_pf_ires, INTR_TYPE_MISC | INTR_BRIDGE | INTR_MPSAFE, - NULL, sbus_pwrfail, sc, &sc->sc_pf_ihand) != 0) - panic("%s: failed to set up power fail interrupt", __func__); - - /* Initialize the counter-timer. */ - sparc64_counter_init(device_get_nameunit(dev), - rman_get_bustag(sc->sc_sysio_res), - rman_get_bushandle(sc->sc_sysio_res), SBR_TC0); - - /* - * Loop through ROM children, fixing any relative addresses - * and then configuring each device. - */ - for (child = OF_child(node); child != 0; child = OF_peer(child)) { - if ((sdi = sbus_setup_dinfo(dev, sc, child)) == NULL) - continue; - /* - * For devices where there are variants that are actually - * split into two SBus devices (as opposed to the first - * half of the device being a SBus device and the second - * half hanging off of the first one) like 'auxio' and - * 'SUNW,fdtwo' or 'dma' and 'esp' probe the SBus device - * which is a prerequisite to the driver attaching to the - * second one with a lower order. Saves us from dealing - * with different probe orders in the respective device - * drivers which generally is more hackish. - */ - cdev = device_add_child_ordered(dev, (OF_child(child) == 0 && - sbus_inlist(sdi->sdi_obdinfo.obd_name, sbus_order_first)) ? - SBUS_ORDER_FIRST : SBUS_ORDER_NORMAL, NULL, -1); - if (cdev == NULL) { - device_printf(dev, - "<%s>: device_add_child_ordered failed\n", - sdi->sdi_obdinfo.obd_name); - sbus_destroy_dinfo(sdi); - continue; - } - device_set_ivars(cdev, sdi); - } - return (bus_generic_attach(dev)); -} - -static struct sbus_devinfo * -sbus_setup_dinfo(device_t dev, struct sbus_softc *sc, phandle_t node) -{ - struct sbus_devinfo *sdi; - struct sbus_regs *reg; - u_int32_t base, iv, *intr; - int i, nreg, nintr, slot, rslot; - - sdi = malloc(sizeof(*sdi), M_DEVBUF, M_ZERO | M_WAITOK); - if (ofw_bus_gen_setup_devinfo(&sdi->sdi_obdinfo, node) != 0) { - free(sdi, M_DEVBUF); - return (NULL); - } - resource_list_init(&sdi->sdi_rl); - slot = -1; - nreg = OF_getprop_alloc_multi(node, "reg", sizeof(*reg), (void **)®); - if (nreg == -1) { - if (sdi->sdi_obdinfo.obd_type == NULL || - strcmp(sdi->sdi_obdinfo.obd_type, "hierarchical") != 0) { - device_printf(dev, "<%s>: incomplete\n", - sdi->sdi_obdinfo.obd_name); - goto fail; - } - } else { - for (i = 0; i < nreg; i++) { - base = reg[i].sbr_offset; - if (SBUS_ABS(base)) { - rslot = SBUS_ABS_TO_SLOT(base); - base = SBUS_ABS_TO_OFFSET(base); - } else - rslot = reg[i].sbr_slot; - if (slot != -1 && slot != rslot) { - device_printf(dev, "<%s>: multiple slots\n", - sdi->sdi_obdinfo.obd_name); - OF_prop_free(reg); - goto fail; - } - slot = rslot; - - resource_list_add(&sdi->sdi_rl, SYS_RES_MEMORY, i, - base, base + reg[i].sbr_size, reg[i].sbr_size); - } - OF_prop_free(reg); - } - sdi->sdi_slot = slot; - - /* - * The `interrupts' property contains the SBus interrupt level. - */ - nintr = OF_getprop_alloc_multi(node, "interrupts", sizeof(*intr), - (void **)&intr); - if (nintr != -1) { - for (i = 0; i < nintr; i++) { - iv = intr[i]; - /* - * SBus card devices need the slot number encoded into - * the vector as this is generally not done. - */ - if ((iv & INTMAP_OBIO_MASK) == 0) - iv |= slot << 3; - iv = INTMAP_VEC(sc->sc_ign, iv); - resource_list_add(&sdi->sdi_rl, SYS_RES_IRQ, i, - iv, iv, 1); - } - OF_prop_free(intr); - } - if (OF_getprop(node, "burst-sizes", &sdi->sdi_burstsz, - sizeof(sdi->sdi_burstsz)) == -1) - sdi->sdi_burstsz = sc->sc_burst; - else - sdi->sdi_burstsz &= sc->sc_burst; - if (OF_getprop(node, "clock-frequency", &sdi->sdi_clockfreq, - sizeof(sdi->sdi_clockfreq)) == -1) - sdi->sdi_clockfreq = sc->sc_clockfreq; - - return (sdi); - -fail: - sbus_destroy_dinfo(sdi); - return (NULL); -} - -static void -sbus_destroy_dinfo(struct sbus_devinfo *dinfo) -{ - - resource_list_free(&dinfo->sdi_rl); - ofw_bus_gen_destroy_devinfo(&dinfo->sdi_obdinfo); - free(dinfo, M_DEVBUF); -} - -static int -sbus_print_child(device_t dev, device_t child) -{ - int rv; - - rv = bus_print_child_header(dev, child); - rv += sbus_print_res(device_get_ivars(child)); - rv += bus_print_child_footer(dev, child); - return (rv); -} - -static void -sbus_probe_nomatch(device_t dev, device_t child) -{ - const char *type; - - device_printf(dev, "<%s>", ofw_bus_get_name(child)); - sbus_print_res(device_get_ivars(child)); - type = ofw_bus_get_type(child); - printf(" type %s (no driver attached)\n", - type != NULL ? type : "unknown"); -} - -static int -sbus_read_ivar(device_t dev, device_t child, int which, uintptr_t *result) -{ - struct sbus_softc *sc; - struct sbus_devinfo *dinfo; - - sc = device_get_softc(dev); - if ((dinfo = device_get_ivars(child)) == NULL) - return (ENOENT); - switch (which) { - case SBUS_IVAR_BURSTSZ: - *result = dinfo->sdi_burstsz; - break; - case SBUS_IVAR_CLOCKFREQ: - *result = dinfo->sdi_clockfreq; - break; - case SBUS_IVAR_IGN: - *result = sc->sc_ign; - break; - case SBUS_IVAR_SLOT: - *result = dinfo->sdi_slot; - break; - default: - return (ENOENT); - } - return (0); -} - -static struct resource_list * -sbus_get_resource_list(device_t dev, device_t child) -{ - struct sbus_devinfo *sdi; - - sdi = device_get_ivars(child); - return (&sdi->sdi_rl); -} - -static void -sbus_intr_enable(void *arg) -{ - struct intr_vector *iv = arg; - struct sbus_icarg *sica = iv->iv_icarg; - - SYSIO_WRITE8(sica->sica_sc, sica->sica_map, - INTMAP_ENABLE(iv->iv_vec, iv->iv_mid)); -} - -static void -sbus_intr_disable(void *arg) -{ - struct intr_vector *iv = arg; - struct sbus_icarg *sica = iv->iv_icarg; - - SYSIO_WRITE8(sica->sica_sc, sica->sica_map, iv->iv_vec); -} - -static void -sbus_intr_assign(void *arg) -{ - struct intr_vector *iv = arg; - struct sbus_icarg *sica = iv->iv_icarg; - - SYSIO_WRITE8(sica->sica_sc, sica->sica_map, INTMAP_TID( - SYSIO_READ8(sica->sica_sc, sica->sica_map), iv->iv_mid)); -} - -static void -sbus_intr_clear(void *arg) -{ - struct intr_vector *iv = arg; - struct sbus_icarg *sica = iv->iv_icarg; - - SYSIO_WRITE8(sica->sica_sc, sica->sica_clr, INTCLR_IDLE); -} - -static int -sbus_find_intrmap(struct sbus_softc *sc, u_int ino, bus_addr_t *intrmapptr, - bus_addr_t *intrclrptr) -{ - bus_addr_t intrclr, intrmap; - int i; - - if (ino > SBUS_MAX_INO) { - device_printf(sc->sc_dev, "out of range INO %d requested\n", - ino); - return (0); - } - - if ((ino & INTMAP_OBIO_MASK) == 0) { - intrmap = SBR_SLOT0_INT_MAP + INTSLOT(ino) * 8; - intrclr = SBR_SLOT0_INT_CLR + - (INTSLOT(ino) * 8 * 8) + (INTPRI(ino) * 8); - } else { - intrclr = 0; - for (i = 0, intrmap = SBR_SCSI_INT_MAP; - intrmap <= SBR_RESERVED_INT_MAP; intrmap += 8, i++) { - if (INTVEC(SYSIO_READ8(sc, intrmap)) == - INTMAP_VEC(sc->sc_ign, ino)) { - intrclr = SBR_SCSI_INT_CLR + i * 8; - break; - } - } - if (intrclr == 0) - return (0); - } - if (intrmapptr != NULL) - *intrmapptr = intrmap; - if (intrclrptr != NULL) - *intrclrptr = intrclr; - return (1); -} - -static int -sbus_setup_intr(device_t dev, device_t child, struct resource *ires, int flags, - driver_filter_t *filt, driver_intr_t *intr, void *arg, void **cookiep) -{ - struct sbus_softc *sc; - u_long vec; - - sc = device_get_softc(dev); - /* - * Make sure the vector is fully specified and we registered - * our interrupt controller for it. - */ - vec = rman_get_start(ires); - if (INTIGN(vec) != sc->sc_ign || intr_vectors[vec].iv_ic != &sbus_ic) { - device_printf(dev, "invalid interrupt vector 0x%lx\n", vec); - return (EINVAL); - } - return (bus_generic_setup_intr(dev, child, ires, flags, filt, intr, - arg, cookiep)); -} - -static struct resource * -sbus_alloc_resource(device_t bus, device_t child, int type, int *rid, - rman_res_t start, rman_res_t end, rman_res_t count, u_int flags) -{ - struct sbus_softc *sc; - struct rman *rm; - struct resource *rv; - struct resource_list *rl; - struct resource_list_entry *rle; - device_t schild; - bus_addr_t toffs; - bus_size_t tend; - int i, slot; - int isdefault, passthrough; - - isdefault = RMAN_IS_DEFAULT_RANGE(start, end); - passthrough = (device_get_parent(child) != bus); - rle = NULL; - sc = device_get_softc(bus); - rl = BUS_GET_RESOURCE_LIST(bus, child); - switch (type) { - case SYS_RES_IRQ: - return (resource_list_alloc(rl, bus, child, type, rid, start, - end, count, flags)); - case SYS_RES_MEMORY: - if (!passthrough) { - rle = resource_list_find(rl, type, *rid); - if (rle == NULL) - return (NULL); - if (rle->res != NULL) - panic("%s: resource entry is busy", __func__); - if (isdefault) { - start = rle->start; - count = ulmax(count, rle->count); - end = ulmax(rle->end, start + count - 1); - } - } - rm = NULL; - schild = child; - while (device_get_parent(schild) != bus) - schild = device_get_parent(schild); - slot = sbus_get_slot(schild); - for (i = 0; i < sc->sc_nrange; i++) { - if (sc->sc_rd[i].rd_slot != slot || - start < sc->sc_rd[i].rd_coffset || - start > sc->sc_rd[i].rd_cend) - continue; - /* Disallow cross-range allocations. */ - if (end > sc->sc_rd[i].rd_cend) - return (NULL); - /* We've found the connection to the parent bus */ - toffs = start - sc->sc_rd[i].rd_coffset; - tend = end - sc->sc_rd[i].rd_coffset; - rm = &sc->sc_rd[i].rd_rman; - break; - } - if (rm == NULL) - return (NULL); - - rv = rman_reserve_resource(rm, toffs, tend, count, flags & - ~RF_ACTIVE, child); - if (rv == NULL) - return (NULL); - rman_set_rid(rv, *rid); - - if ((flags & RF_ACTIVE) != 0 && bus_activate_resource(child, - type, *rid, rv)) { - rman_release_resource(rv); - return (NULL); - } - if (!passthrough) - rle->res = rv; - return (rv); - default: - return (NULL); - } -} - -static int -sbus_activate_resource(device_t bus, device_t child, int type, int rid, - struct resource *r) -{ - struct sbus_softc *sc; - struct bus_space_tag *tag; - int i; - - switch (type) { - case SYS_RES_IRQ: - return (bus_generic_activate_resource(bus, child, type, rid, - r)); - case SYS_RES_MEMORY: - sc = device_get_softc(bus); - for (i = 0; i < sc->sc_nrange; i++) { - if (rman_is_region_manager(r, - &sc->sc_rd[i].rd_rman) != 0) { - tag = sparc64_alloc_bus_tag(r, SBUS_BUS_SPACE); - if (tag == NULL) - return (ENOMEM); - rman_set_bustag(r, tag); - rman_set_bushandle(r, - sc->sc_rd[i].rd_bushandle + - rman_get_start(r)); - return (rman_activate_resource(r)); - } - } - /* FALLTHROUGH */ - default: - return (EINVAL); - } -} - -static int -sbus_adjust_resource(device_t bus, device_t child, int type, - struct resource *r, rman_res_t start, rman_res_t end) -{ - struct sbus_softc *sc; - int i; - - if (type == SYS_RES_MEMORY) { - sc = device_get_softc(bus); - for (i = 0; i < sc->sc_nrange; i++) - if (rman_is_region_manager(r, - &sc->sc_rd[i].rd_rman) != 0) - return (rman_adjust_resource(r, start, end)); - return (EINVAL); - } - return (bus_generic_adjust_resource(bus, child, type, r, start, end)); -} - -static int -sbus_release_resource(device_t bus, device_t child, int type, int rid, - struct resource *r) -{ - struct resource_list *rl; - struct resource_list_entry *rle; - int error, passthrough; - - passthrough = (device_get_parent(child) != bus); - rl = BUS_GET_RESOURCE_LIST(bus, child); - if (type == SYS_RES_MEMORY) { - if ((rman_get_flags(r) & RF_ACTIVE) != 0) { - error = bus_deactivate_resource(child, type, rid, r); - if (error) - return (error); - } - error = rman_release_resource(r); - if (error != 0) - return (error); - if (!passthrough) { - rle = resource_list_find(rl, type, rid); - KASSERT(rle != NULL, - ("%s: resource entry not found!", __func__)); - KASSERT(rle->res != NULL, - ("%s: resource entry is not busy", __func__)); - rle->res = NULL; - } - return (0); - } - return (resource_list_release(rl, bus, child, type, rid, r)); -} - -static bus_dma_tag_t -sbus_get_dma_tag(device_t bus, device_t child) -{ - struct sbus_softc *sc; - - sc = device_get_softc(bus); - return (sc->sc_cdmatag); -} - -static const struct ofw_bus_devinfo * -sbus_get_devinfo(device_t bus, device_t child) -{ - struct sbus_devinfo *sdi; - - sdi = device_get_ivars(child); - return (&sdi->sdi_obdinfo); -} - -/* - * Handle an overtemp situation. - * - * SPARCs have temperature sensors which generate interrupts - * if the machine's temperature exceeds a certain threshold. - * This handles the interrupt and powers off the machine. - * The same needs to be done to PCI controller drivers. - */ -static void -sbus_overtemp(void *arg __unused) -{ - static int shutdown; - - /* As the interrupt is cleared we may be called multiple times. */ - if (shutdown != 0) - return; - shutdown++; - printf("DANGER: OVER TEMPERATURE detected\nShutting down NOW.\n"); - shutdown_nice(RB_POWEROFF); -} - -/* Try to shut down in time in case of power failure. */ -static void -sbus_pwrfail(void *arg __unused) -{ - static int shutdown; - - /* As the interrupt is cleared we may be called multiple times. */ - if (shutdown != 0) - return; - shutdown++; - printf("Power failure detected\nShutting down NOW.\n"); - shutdown_nice(RB_POWEROFF); -} - -static int -sbus_print_res(struct sbus_devinfo *sdi) -{ - int rv; - - rv = 0; - rv += resource_list_print_type(&sdi->sdi_rl, "mem", SYS_RES_MEMORY, - "%#jx"); - rv += resource_list_print_type(&sdi->sdi_rl, "irq", SYS_RES_IRQ, - "%jd"); - return (rv); -} diff --git a/sys/sparc64/sbus/sbusreg.h b/sys/sparc64/sbus/sbusreg.h deleted file mode 100644 index 7271d697f913..000000000000 --- a/sys/sparc64/sbus/sbusreg.h +++ /dev/null @@ -1,145 +0,0 @@ -/*- - * Copyright (c) 1996-1999 Eduardo Horvath - * - * 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. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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. - * - * from: NetBSD: sbusreg.h,v 1.7 1999/06/07 05:28:03 eeh Exp - * - * $FreeBSD$ - */ - -#ifndef _SPARC64_SBUS_SBUSREG_H_ -#define _SPARC64_SBUS_SBUSREG_H_ - -/* - * Sbus device addresses are obtained from the FORTH PROMs. They come - * in `absolute' and `relative' address flavors, so we have to handle both. - * Relative addresses do *not* include the slot number. - */ -#define SBUS_BASE 0xf8000000 -#define SBUS_ADDR(slot, off) (SBUS_BASE + ((slot) << 25) + (off)) -#define SBUS_ABS(a) ((unsigned)(a) >= SBUS_BASE) -#define SBUS_ABS_TO_SLOT(a) (((a) - SBUS_BASE) >> 25) -#define SBUS_ABS_TO_OFFSET(a) (((a) - SBUS_BASE) & 0x1ffffff) - -/* - * Sun4u S-bus definitions. Here's where we deal w/the machine - * dependencies of sysio. - * - * SYSIO implements or is the interface to several things: - * - * o The SBUS interface itself - * o The IOMMU - * o The DVMA units - * o The interrupt controller - * o The counter/timers - * - * Since it has registers to control lots of different things - * as well as several on-board SBUS devices and external SBUS - * slots scattered throughout its address space, it's a pain. - * - * One good point, however, is that all registers are 64-bit. - */ -#define SBR_UPA_PORTID 0x0000 /* UPA port ID register */ -#define SBR_UPA_CONFIG 0x0008 /* UPA config register */ -#define SBR_CS 0x0010 /* SYSIO control/status register */ -#define SBR_ECCC 0x0020 /* ECC control register */ -#define SBR_UE_AFS 0x0030 /* Uncorrectable Error AFSR */ -#define SBR_UE_AFA 0x0038 /* Uncorrectable Error AFAR */ -#define SBR_CE_AFS 0x0040 /* Correctable Error AFSR */ -#define SBR_CE_AFA 0x0048 /* Correctable Error AFAR */ -#define SBR_PM_CTL 0x0100 /* Performance monitor control reg */ -#define SBR_PM_COUNT 0x0108 /* Performance monitor counter reg */ -#define SBR_CTL 0x2000 /* SBUS Control Register */ -#define SBR_AFS 0x2010 /* SBUS AFSR */ -#define SBR_AFA 0x2018 /* SBUS AFAR */ -#define SBR_CONFIG0 0x2020 /* SBUS Slot 0 config register */ -#define SBR_CONFIG1 0x2028 /* SBUS Slot 1 config register */ -#define SBR_CONFIG2 0x2030 /* SBUS Slot 2 config register */ -#define SBR_CONFIG3 0x2038 /* SBUS Slot 3 config register */ -#define SBR_CONFIG13 0x2040 /* Slot 13 config register