From owner-p4-projects@FreeBSD.ORG Sat Sep 2 02:58:34 2006 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id E277616A4E1; Sat, 2 Sep 2006 02:58:33 +0000 (UTC) X-Original-To: perforce@freebsd.org Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id BE6CB16A4DD for ; Sat, 2 Sep 2006 02:58:33 +0000 (UTC) (envelope-from kmacy@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 519A643D46 for ; Sat, 2 Sep 2006 02:58:33 +0000 (GMT) (envelope-from kmacy@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.6/8.13.6) with ESMTP id k822wXmI043148 for ; Sat, 2 Sep 2006 02:58:33 GMT (envelope-from kmacy@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.6/8.13.4/Submit) id k822wWIX043145 for perforce@freebsd.org; Sat, 2 Sep 2006 02:58:32 GMT (envelope-from kmacy@freebsd.org) Date: Sat, 2 Sep 2006 02:58:32 GMT Message-Id: <200609020258.k822wWIX043145@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to kmacy@freebsd.org using -f From: Kip Macy To: Perforce Change Reviews Cc: Subject: PERFORCE change 105499 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 02 Sep 2006 02:58:34 -0000 http://perforce.freebsd.org/chv.cgi?CH=105499 Change 105499 by kmacy@kmacy_storage:sun4v_work_stable on 2006/09/02 02:58:20 add machine description support to the virtual nexus Affected files ... .. //depot/projects/kmacy_sun4v_stable/src/sys/conf/files.sun4v#3 edit .. //depot/projects/kmacy_sun4v_stable/src/sys/sun4v/include/cddl/mdesc.h#1 add .. //depot/projects/kmacy_sun4v_stable/src/sys/sun4v/include/cddl/mdesc_impl.h#1 add .. //depot/projects/kmacy_sun4v_stable/src/sys/sun4v/include/mdesc_bus.h#1 add .. //depot/projects/kmacy_sun4v_stable/src/sys/sun4v/include/mdesc_bus_subr.h#1 add .. //depot/projects/kmacy_sun4v_stable/src/sys/sun4v/include/pcpu.h#4 edit .. //depot/projects/kmacy_sun4v_stable/src/sys/sun4v/include/trap.h#2 edit .. //depot/projects/kmacy_sun4v_stable/src/sys/sun4v/mdesc/mdesc_bus_if.m#1 add .. //depot/projects/kmacy_sun4v_stable/src/sys/sun4v/mdesc/mdesc_bus_subr.c#1 add .. //depot/projects/kmacy_sun4v_stable/src/sys/sun4v/mdesc/mdesc_diff.c#1 add .. //depot/projects/kmacy_sun4v_stable/src/sys/sun4v/mdesc/mdesc_findname.c#1 add .. //depot/projects/kmacy_sun4v_stable/src/sys/sun4v/mdesc/mdesc_findnodeprop.c#1 add .. //depot/projects/kmacy_sun4v_stable/src/sys/sun4v/mdesc/mdesc_fini.c#1 add .. //depot/projects/kmacy_sun4v_stable/src/sys/sun4v/mdesc/mdesc_getbinsize.c#1 add .. //depot/projects/kmacy_sun4v_stable/src/sys/sun4v/mdesc/mdesc_getgen.c#1 add .. //depot/projects/kmacy_sun4v_stable/src/sys/sun4v/mdesc/mdesc_getpropdata.c#1 add .. //depot/projects/kmacy_sun4v_stable/src/sys/sun4v/mdesc/mdesc_getpropstr.c#1 add .. //depot/projects/kmacy_sun4v_stable/src/sys/sun4v/mdesc/mdesc_getpropval.c#1 add .. //depot/projects/kmacy_sun4v_stable/src/sys/sun4v/mdesc/mdesc_init.c#1 add .. //depot/projects/kmacy_sun4v_stable/src/sys/sun4v/mdesc/mdesc_init_intern.c#1 add .. //depot/projects/kmacy_sun4v_stable/src/sys/sun4v/mdesc/mdesc_nodecount.c#1 add .. //depot/projects/kmacy_sun4v_stable/src/sys/sun4v/mdesc/mdesc_rootnode.c#1 add .. //depot/projects/kmacy_sun4v_stable/src/sys/sun4v/mdesc/mdesc_scandag.c#1 add .. //depot/projects/kmacy_sun4v_stable/src/sys/sun4v/mdesc/mdesc_subr.c#1 add .. //depot/projects/kmacy_sun4v_stable/src/sys/sun4v/sun4v/exception.S#5 edit .. //depot/projects/kmacy_sun4v_stable/src/sys/sun4v/sun4v/hvcons.c#3 edit .. //depot/projects/kmacy_sun4v_stable/src/sys/sun4v/sun4v/machdep.c#5 edit .. //depot/projects/kmacy_sun4v_stable/src/sys/sun4v/sun4v/vnex.c#3 edit Differences ... ==== //depot/projects/kmacy_sun4v_stable/src/sys/conf/files.sun4v#3 (text+ko) ==== @@ -98,3 +98,18 @@ sun4v/sun4v/uio_machdep.c standard sun4v/sun4v/vm_machdep.c standard sun4v/sun4v/vnex.c standard + + +sun4v/mdesc/mdesc_bus_if.m standard +sun4v/mdesc/mdesc_scandag.c standard +sun4v/mdesc/mdesc_init.c standard +sun4v/mdesc/mdesc_init_intern.c standard +sun4v/mdesc/mdesc_subr.c standard +sun4v/mdesc/mdesc_bus_subr.c standard +sun4v/mdesc/mdesc_getpropstr.c standard +sun4v/mdesc/mdesc_getpropval.c standard +sun4v/mdesc/mdesc_rootnode.c standard +sun4v/mdesc/mdesc_findname.c standard +sun4v/mdesc/mdesc_nodecount.c standard +sun4v/mdesc/mdesc_findnodeprop.c standard + ==== //depot/projects/kmacy_sun4v_stable/src/sys/sun4v/include/pcpu.h#4 (text+ko) ==== @@ -77,8 +77,10 @@ u_int pc_kwbuf_full; \ struct rwindow pc_tsbwbuf[2]; \ uint64_t pc_caller; \ + uint32_t pc_tl; \ + uint32_t pc_trapid; \ uint16_t pc_cpulist[MAXCPU]; \ - uint64_t pad[7]; + uint64_t pad[6]; /* XXX SUN4V_FIXME - as we access the *_ra and *_size fields in quick * succession we _really_ want them to be L1 cache line size aligned ==== //depot/projects/kmacy_sun4v_stable/src/sys/sun4v/include/trap.h#2 (text+ko) ==== @@ -119,6 +119,12 @@ #define PTL1_BAD_GL 15 +#define TL_CPU_MONDO 0x1 +#define TL_DEV_MONDO 0x2 +#define TL_TSB_MISS 0x3 +#define TL_TL0_TRAP 0x4 +#define TL_SET_ACKMASK 0x5 + /* * These defines are used by the TL1 tlb miss handlers to calculate * the pc to jump to in the case the entry was not found in the TSB. ==== //depot/projects/kmacy_sun4v_stable/src/sys/sun4v/sun4v/exception.S#5 (text+ko) ==== @@ -1379,6 +1379,23 @@ wrpr %g0, %g5, %cleanwin ldx [%g6 + PCB_KSTACK], %g6 sub %g6, TF_SIZEOF, %g6 +#ifdef DEBUG_KSTACK + mov %o0, %g5 + mov %o3, %l0 + mov %o4, %l1 + mov %o5, %l2 + mov %o6, %l3 + mov %o7, %l4 + mov 0x10, %o0 + mov %g6, %o1 + ta TTRACE_ADDENTRY + mov %g5, %o0 + mov %l0, %o3 + mov %l1, %o4 + mov %l2, %o5 + mov %l3, %o6 + mov %l4, %o7 +#endif save %g6, 0, %sp rdpr %canrestore, %l0 @@ -1433,19 +1450,16 @@ bge,pt %xcc, 0f nop call panic -! MAGIC_EXIT 0: #endif wrpr %g0, %g4, %pil 1: wrpr %g0, %g6, %tnpc - wrpr %g0, 0, %gl stx %g7, [%l7 + TF_G7] ! save g7 before it can be overwritten by PCPU when returning from an interrupt wrpr %g0, 1, %gl - - rdpr %cwp, %l0 + rdpr %cwp, %l0 set TSTATE_KERNEL, %l1 wrpr %l1, %l0, %tstate done @@ -1475,6 +1489,7 @@ mov 1, lock_bit ; \ add addr, 8, addr ; \ sllx lock_bit, 56, lock_bit ; \ + stxa %o7, [PCPU(CALLER)]%asi ; /* XXX DEBUG */\ label1: ; \ ldxa [addr]%asi, oldval; \ or oldval, lock_bit, newval; \ @@ -1515,7 +1530,7 @@ label2: ENTRY(hash_bucket_lock) - wr %g0, ASI_N, %asi + wr %g0, ASI_N, %asi rdpr %pstate, %o1 and %o1, PSTATE_INTR_DISABLE, %o2 wrpr %o2, %pstate @@ -1588,7 +1603,6 @@ add PCPU_REG, %g1, %g1 SAVE_LOCALS_ASI(%g1) mov 0, %g1 ! cansave is 0 - ! %g1 == %cansave ! %g2 == hash scratch value ! %g3 == TWDW ASI @@ -1907,4 +1921,4 @@ sllx %g7, TRAP_CTX_SHIFT, %g7 or %g7, %g5, %g5 done -END(tl1_trap) +END(tl1_trap) ==== //depot/projects/kmacy_sun4v_stable/src/sys/sun4v/sun4v/hvcons.c#3 (text+ko) ==== @@ -37,9 +37,10 @@ #include #include -#include -#include -#include +#include +#include + +#include "mdesc_bus_if.h" #include "opt_simulator.h" @@ -158,7 +159,8 @@ static void hvcnprobe(struct consdev *cp) { - phandle_t node; + +#if 0 char name[64]; node = OF_peer(0); @@ -179,12 +181,9 @@ if (!strcmp(name, "console")) break; } - done: - if (node != 0) - cp->cn_pri = CN_NORMAL; - else - cp->cn_pri = CN_DEAD; +#endif + cp->cn_pri = CN_NORMAL; } @@ -329,7 +328,7 @@ hvcn_probe(device_t dev) { - if (strcmp(ofw_bus_get_name(dev), "console")) + if (strcmp(mdesc_bus_get_name(dev), "console")) return (ENXIO); device_set_desc(dev, "sun4v virtual console"); @@ -344,7 +343,6 @@ struct cdev *cdev; char output[32]; - phandle_t options; int error, rid; /* belongs in attach - but attach is getting called multiple times @@ -354,13 +352,13 @@ if (hvcn_consdev.cn_pri == CN_DEAD || hvcn_consdev.cn_name[0] == '\0') return (ENXIO); - +#if 0 if ((options = OF_finddevice("/options")) == -1 || OF_getprop(options, "output-device", output, sizeof(output)) == -1) return (ENXIO); - +#endif cdev = make_dev(&hvcn_cdevsw, 0, UID_ROOT, GID_WHEEL, 0600, "%s", output); make_dev_alias(cdev, "hvcn"); ==== //depot/projects/kmacy_sun4v_stable/src/sys/sun4v/sun4v/machdep.c#5 (text+ko) ==== @@ -110,6 +110,9 @@ #include #include +/* XXX move this to a header */ +extern void mdesc_init(void); + typedef int ofw_vec_t(void *); #ifdef DDB @@ -443,6 +446,8 @@ msgbufinit(msgbufp, MSGBUF_SIZE); mutex_init(); + + mdesc_init(); OF_getprop(root, "name", sparc64_model, sizeof(sparc64_model) - 1); ==== //depot/projects/kmacy_sun4v_stable/src/sys/sun4v/sun4v/vnex.c#3 (text+ko) ==== @@ -44,16 +44,19 @@ #include #include #include -#include #include #include +#include +#include +#include + #include + #define SUN4V_REG_SPEC2CFG_HDL(x) ((x >> 32) & ~(0xfull << 28)) static device_probe_t vnex_probe; -static device_probe_t channex_probe; static device_attach_t vnex_attach; static bus_print_child_t vnex_print_child; static bus_add_child_t vnex_add_child; @@ -61,14 +64,14 @@ static bus_setup_intr_t vnex_setup_intr; static bus_teardown_intr_t vnex_teardown_intr; static bus_get_resource_list_t vnex_get_resource_list; -static ofw_bus_get_devinfo_t vnex_get_devinfo; +static mdesc_bus_get_devinfo_t vnex_get_devinfo; -static struct vnex_devinfo * vnex_setup_dinfo(device_t, phandle_t); +static struct vnex_devinfo * vnex_setup_dinfo(device_t, mde_cookie_t node); static void vnex_destroy_dinfo(struct vnex_devinfo *); static int vnex_print_res(struct vnex_devinfo *); struct vnex_devinfo { - struct ofw_bus_devinfo vndi_obdinfo; + struct mdesc_bus_devinfo vndi_mbdinfo; struct resource_list vndi_rl; /* Some common properties. */ @@ -81,62 +84,6 @@ struct rman sc_mem_rman; }; -static device_method_t channex_methods[] = { - /* Device interface */ - DEVMETHOD(device_probe, channex_probe), - DEVMETHOD(device_attach, vnex_attach), - DEVMETHOD(device_detach, bus_generic_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, vnex_print_child), - DEVMETHOD(bus_probe_nomatch, vnex_probe_nomatch), - DEVMETHOD(bus_read_ivar, bus_generic_read_ivar), - DEVMETHOD(bus_write_ivar, bus_generic_write_ivar), - DEVMETHOD(bus_add_child, vnex_add_child), - DEVMETHOD(bus_alloc_resource, bus_generic_alloc_resource), - DEVMETHOD(bus_activate_resource, bus_generic_activate_resource), - DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource), - DEVMETHOD(bus_release_resource, bus_generic_release_resource), - DEVMETHOD(bus_setup_intr, vnex_setup_intr), - DEVMETHOD(bus_teardown_intr, vnex_teardown_intr), - DEVMETHOD(bus_get_resource, bus_generic_rl_get_resource), - DEVMETHOD(bus_get_resource_list, vnex_get_resource_list), - - /* ofw_bus interface */ - DEVMETHOD(ofw_bus_get_devinfo, vnex_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 } -}; - -static driver_t channex_driver = { - "channex", - channex_methods, - sizeof(struct vnex_softc), -}; - - -static devclass_t channex_devclass; -DRIVER_MODULE(channex, vnex, channex_driver, channex_devclass, 0, 0); - - -static int -channex_probe(device_t dev) -{ - if (strcmp(ofw_bus_get_name(dev), "channel-devices")) - return (ENXIO); - - device_set_desc(dev, "virtual channel devices"); - return (0); -} - static device_method_t vnex_methods[] = { /* Device interface */ DEVMETHOD(device_probe, vnex_probe), @@ -162,12 +109,11 @@ DEVMETHOD(bus_get_resource_list, vnex_get_resource_list), /* ofw_bus interface */ - DEVMETHOD(ofw_bus_get_devinfo, vnex_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), + /* mdesc_bus interface */ + DEVMETHOD(mdesc_bus_get_devinfo, vnex_get_devinfo), + DEVMETHOD(mdesc_bus_get_compat, mdesc_bus_gen_get_compat), + DEVMETHOD(mdesc_bus_get_name, mdesc_bus_gen_get_name), + DEVMETHOD(mdesc_bus_get_type, mdesc_bus_gen_get_type), { 0, 0 } }; @@ -198,10 +144,14 @@ static int vnex_attach(device_t dev) { - struct vnex_devinfo *vndi; - struct vnex_softc *sc; - device_t cdev; - phandle_t node; + struct vnex_devinfo *vndi; + struct vnex_softc *sc; + device_t cdev; + phandle_t node; + mde_cookie_t rootnode, *listp = NULL; + int i, listsz, num_nodes, num_devices; + md_t *mdp; + node = ofw_bus_get_node(dev); if (node == -1) @@ -218,17 +168,29 @@ rman_manage_region(&sc->sc_mem_rman, 0ULL, ~0ULL) != 0) panic("%s: failed to set up rmans.", __func__); + if ((mdp = md_get()) == NULL) + return (ENXIO); + + num_nodes = md_node_count(mdp); + listsz = num_nodes * sizeof(mde_cookie_t); + listp = (mde_cookie_t *)malloc(listsz, M_DEVBUF, M_WAITOK); + rootnode = md_root_node(mdp); + /* - * Now walk the OFW tree and attach top-level devices. + * scan the machine description for virtual devices */ - for (node = OF_child(node); node > 0; node = OF_peer(node)) { - if ((vndi = vnex_setup_dinfo(dev, node)) == NULL) + num_devices = md_scan_dag(mdp, rootnode, + md_find_name(mdp, "virtual-device"), + md_find_name(mdp, "fwd"), listp); + + for (i = 0; i < num_devices; i++) { + if ((vndi = vnex_setup_dinfo(dev, listp[i])) == NULL) continue; cdev = device_add_child(dev, NULL, -1); if (cdev == NULL) { device_printf(dev, "<%s>: device_add_child failed\n", - vndi->vndi_obdinfo.obd_name); + vndi->vndi_mbdinfo.mbd_name); vnex_destroy_dinfo(vndi); continue; } @@ -250,8 +212,7 @@ return (NULL); vndi = malloc(sizeof(*vndi), M_DEVBUF, M_WAITOK | M_ZERO); - vndi->vndi_obdinfo.obd_node = -1; - vndi->vndi_obdinfo.obd_name = strdup(name, M_OFWPROP); + vndi->vndi_mbdinfo.mbd_name = strdup(name, M_OFWPROP); resource_list_init(&vndi->vndi_rl); device_set_ivars(cdev, vndi); @@ -274,9 +235,9 @@ { const char *type; - device_printf(dev, "<%s>", ofw_bus_get_name(child)); + device_printf(dev, "<%s>", mdesc_bus_get_name(child)); vnex_print_res(device_get_ivars(child)); - type = ofw_bus_get_type(child); + type = mdesc_bus_get_type(child); printf(" type %s (no driver attached)\n", type != NULL ? type : "unknown"); } @@ -358,40 +319,26 @@ return (&vndi->vndi_rl); } -static const struct ofw_bus_devinfo * +static const struct mdesc_bus_devinfo * vnex_get_devinfo(device_t dev, device_t child) { struct vnex_devinfo *vndi; vndi = device_get_ivars(child); - return (&vndi->vndi_obdinfo); + return (&vndi->vndi_mbdinfo); } static struct vnex_devinfo * -vnex_setup_dinfo(device_t dev, phandle_t node) +vnex_setup_dinfo(device_t dev, mde_cookie_t node) { struct vnex_devinfo *vndi; - uint32_t *intr; - int i; - int nintr; vndi = malloc(sizeof(*vndi), M_DEVBUF, M_WAITOK | M_ZERO); - if (ofw_bus_gen_setup_devinfo(&vndi->vndi_obdinfo, node) != 0) { + if (mdesc_bus_gen_setup_devinfo(&vndi->vndi_mbdinfo, node) != 0) { free(vndi, M_DEVBUF); return (NULL); } - resource_list_init(&vndi->vndi_rl); - nintr = OF_getprop_alloc(node, "interrupts", sizeof(*intr), - (void **)&intr); - if (nintr > 0) { - for (i = 0; i < nintr; i++) { - resource_list_add(&vndi->vndi_rl, SYS_RES_IRQ, i, intr[i], - intr[i], 1); - } - free(intr, M_OFWPROP); - } - return (vndi); } @@ -400,7 +347,7 @@ { resource_list_free(&vndi->vndi_rl); - ofw_bus_gen_destroy_devinfo(&vndi->vndi_obdinfo); + mdesc_bus_gen_destroy_devinfo(&vndi->vndi_mbdinfo); free(vndi, M_DEVBUF); }