hilid.c 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. /* $OpenBSD: hilid.c,v 1.4 2005/01/09 23:49:36 miod Exp $ */
  2. /*
  3. * Copyright (c) 2003, Miodrag Vallat.
  4. * All rights reserved.
  5. *
  6. * Redistribution and use in source and binary forms, with or without
  7. * modification, are permitted provided that the following conditions
  8. * are met:
  9. * 1. Redistributions of source code must retain the above copyright
  10. * notice, this list of conditions and the following disclaimer.
  11. * 2. Redistributions in binary form must reproduce the above copyright
  12. * notice, this list of conditions and the following disclaimer in the
  13. * documentation and/or other materials provided with the distribution.
  14. *
  15. * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
  16. * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  17. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  18. * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
  19. * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  20. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  21. * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  22. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
  23. * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
  24. * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  25. * POSSIBILITY OF SUCH DAMAGE.
  26. *
  27. */
  28. #include <sys/param.h>
  29. #include <sys/systm.h>
  30. #include <sys/device.h>
  31. #include <sys/ioctl.h>
  32. #include <machine/autoconf.h>
  33. #include <machine/bus.h>
  34. #include <machine/cpu.h>
  35. #include <dev/hil/hilreg.h>
  36. #include <dev/hil/hilvar.h>
  37. #include <dev/hil/hildevs.h>
  38. struct hilid_softc {
  39. struct hildev_softc sc_hildev;
  40. u_int8_t sc_id[16];
  41. };
  42. int hilidprobe(struct device *, void *, void *);
  43. void hilidattach(struct device *, struct device *, void *);
  44. int hiliddetach(struct device *, int);
  45. struct cfdriver hilid_cd = {
  46. NULL, "hilid", DV_DULL
  47. };
  48. struct cfattach hilid_ca = {
  49. sizeof(struct hilid_softc), hilidprobe, hilidattach, hiliddetach,
  50. };
  51. int
  52. hilidprobe(struct device *parent, void *match, void *aux)
  53. {
  54. struct hil_attach_args *ha = aux;
  55. if (ha->ha_type != HIL_DEVICE_IDMODULE)
  56. return (0);
  57. return (1);
  58. }
  59. void
  60. hilidattach(struct device *parent, struct device *self, void *aux)
  61. {
  62. struct hilid_softc *sc = (void *)self;
  63. struct hil_attach_args *ha = aux;
  64. u_int i, len;
  65. sc->hd_code = ha->ha_code;
  66. sc->hd_type = ha->ha_type;
  67. sc->hd_infolen = ha->ha_infolen;
  68. bcopy(ha->ha_info, sc->hd_info, ha->ha_infolen);
  69. sc->hd_fn = NULL;
  70. printf("\n");
  71. bzero(sc->sc_id, sizeof(sc->sc_id));
  72. len = sizeof(sc->sc_id);
  73. printf("%s: security code", self->dv_xname);
  74. if (send_hildev_cmd((struct hildev_softc *)sc,
  75. HIL_SECURITY, sc->sc_id, &len) == 0) {
  76. for (i = 0; i < sizeof(sc->sc_id); i++)
  77. printf(" %02x", sc->sc_id[i]);
  78. printf("\n");
  79. } else
  80. printf(" unavailable\n");
  81. }
  82. int
  83. hiliddetach(struct device *self, int flags)
  84. {
  85. return (0);
  86. }