11.2Stsutsui/* $NetBSD: hilid.c,v 1.2 2011/02/15 11:05:51 tsutsui Exp $ */ 21.1Stsutsui/* $OpenBSD: hilid.c,v 1.4 2005/01/09 23:49:36 miod Exp $ */ 31.1Stsutsui/* 41.1Stsutsui * Copyright (c) 2003, Miodrag Vallat. 51.1Stsutsui * All rights reserved. 61.1Stsutsui * 71.1Stsutsui * Redistribution and use in source and binary forms, with or without 81.1Stsutsui * modification, are permitted provided that the following conditions 91.1Stsutsui * are met: 101.1Stsutsui * 1. Redistributions of source code must retain the above copyright 111.1Stsutsui * notice, this list of conditions and the following disclaimer. 121.1Stsutsui * 2. Redistributions in binary form must reproduce the above copyright 131.1Stsutsui * notice, this list of conditions and the following disclaimer in the 141.1Stsutsui * documentation and/or other materials provided with the distribution. 151.1Stsutsui * 161.1Stsutsui * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 171.1Stsutsui * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 181.1Stsutsui * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 191.1Stsutsui * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, 201.1Stsutsui * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 211.1Stsutsui * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 221.1Stsutsui * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 231.1Stsutsui * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 241.1Stsutsui * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 251.1Stsutsui * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 261.1Stsutsui * POSSIBILITY OF SUCH DAMAGE. 271.1Stsutsui * 281.1Stsutsui */ 291.1Stsutsui 301.1Stsutsui#include <sys/param.h> 311.1Stsutsui#include <sys/systm.h> 321.1Stsutsui#include <sys/device.h> 331.1Stsutsui#include <sys/ioctl.h> 341.1Stsutsui#include <sys/bus.h> 351.1Stsutsui#include <sys/cpu.h> 361.1Stsutsui 371.1Stsutsui#include <machine/autoconf.h> 381.1Stsutsui 391.1Stsutsui#include <dev/hil/hilreg.h> 401.1Stsutsui#include <dev/hil/hilvar.h> 411.1Stsutsui#include <dev/hil/hildevs.h> 421.1Stsutsui 431.1Stsutsuistruct hilid_softc { 441.1Stsutsui struct hildev_softc sc_hildev; 451.1Stsutsui 461.2Stsutsui uint8_t sc_id[16]; 471.1Stsutsui}; 481.1Stsutsui 491.2Stsutsuistatic int hilidprobe(device_t, cfdata_t, void *); 501.2Stsutsuistatic void hilidattach(device_t, device_t, void *); 511.2Stsutsuistatic int hiliddetach(device_t, int); 521.1Stsutsui 531.1StsutsuiCFATTACH_DECL_NEW(hilid, sizeof(struct hilid_softc), 541.1Stsutsui hilidprobe, hilidattach, hiliddetach, NULL); 551.1Stsutsui 561.1Stsutsuiint 571.1Stsutsuihilidprobe(device_t parent, cfdata_t cf, void *aux) 581.1Stsutsui{ 591.1Stsutsui struct hil_attach_args *ha = aux; 601.1Stsutsui 611.1Stsutsui if (ha->ha_type != HIL_DEVICE_IDMODULE) 621.2Stsutsui return 0; 631.1Stsutsui 641.2Stsutsui return 1; 651.1Stsutsui} 661.1Stsutsui 671.1Stsutsuivoid 681.1Stsutsuihilidattach(device_t parent, device_t self, void *aux) 691.1Stsutsui{ 701.1Stsutsui struct hilid_softc *sc = device_private(self); 711.1Stsutsui struct hildev_softc *hdsc = &sc->sc_hildev; 721.1Stsutsui struct hil_attach_args *ha = aux; 731.1Stsutsui u_int i, len; 741.1Stsutsui 751.1Stsutsui sc->sc_hildev.sc_dev = self; 761.1Stsutsui sc->hd_code = ha->ha_code; 771.1Stsutsui sc->hd_type = ha->ha_type; 781.1Stsutsui sc->hd_infolen = ha->ha_infolen; 791.1Stsutsui memcpy(sc->hd_info, ha->ha_info, ha->ha_infolen); 801.1Stsutsui sc->hd_fn = NULL; 811.1Stsutsui 821.2Stsutsui aprint_normal("\n"); 831.1Stsutsui 841.1Stsutsui memset(sc->sc_id, 0, sizeof(sc->sc_id)); 851.1Stsutsui len = sizeof(sc->sc_id); 861.2Stsutsui aprint_normal("%s: security code", device_xname(self)); 871.1Stsutsui 881.1Stsutsui if (send_hildev_cmd(hdsc, 891.1Stsutsui HIL_SECURITY, sc->sc_id, &len) == 0) { 901.1Stsutsui for (i = 0; i < sizeof(sc->sc_id); i++) 911.1Stsutsui printf(" %02x", sc->sc_id[i]); 921.2Stsutsui aprint_normal("\n"); 931.1Stsutsui } else 941.2Stsutsui aprint_normal(" unavailable\n"); 951.1Stsutsui} 961.1Stsutsui 971.1Stsutsuiint 981.2Stsutsuihiliddetach(device_t self, int flags) 991.1Stsutsui{ 1001.2Stsutsui 1011.2Stsutsui return 0; 1021.1Stsutsui} 103