LCOV - code coverage report
Current view: top level - dev/acpi - acpimcfg.c (source / functions) Hit Total Coverage
Test: 6.4 Lines: 0 22 0.0 %
Date: 2018-10-19 03:25:38 Functions: 0 2 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* $OpenBSD: acpimcfg.c,v 1.4 2018/08/19 08:23:47 kettenis Exp $ */
       2             : /*
       3             :  * Copyright (c) 2010 Mark Kettenis <kettenis@openbsd.org>
       4             :  *
       5             :  * Permission to use, copy, modify, and distribute this software for any
       6             :  * purpose with or without fee is hereby granted, provided that the above
       7             :  * copyright notice and this permission notice appear in all copies.
       8             :  *
       9             :  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
      10             :  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
      11             :  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
      12             :  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
      13             :  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
      14             :  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
      15             :  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
      16             :  */
      17             : 
      18             : #include <sys/param.h>
      19             : #include <sys/systm.h>
      20             : #include <sys/device.h>
      21             : 
      22             : #include <dev/acpi/acpireg.h>
      23             : #include <dev/acpi/acpivar.h>
      24             : #include <dev/pci/pcivar.h>
      25             : 
      26             : int acpimcfg_match(struct device *, void *, void *);
      27             : void acpimcfg_attach(struct device *, struct device *, void *);
      28             : 
      29             : struct cfattach acpimcfg_ca = {
      30             :         sizeof(struct device), acpimcfg_match, acpimcfg_attach
      31             : };
      32             : 
      33             : struct cfdriver acpimcfg_cd = {
      34             :         NULL, "acpimcfg", DV_DULL
      35             : };
      36             : 
      37             : int
      38           0 : acpimcfg_match(struct device *parent, void *match, void *aux)
      39             : {
      40           0 :         struct acpi_attach_args *aaa = aux;
      41             :         struct acpi_table_header *hdr;
      42             : 
      43             :         /*
      44             :          * If we do not have a table, it is not us
      45             :          */
      46           0 :         if (aaa->aaa_table == NULL)
      47           0 :                 return (0);
      48             : 
      49             :         /*
      50             :          * If it is an MCFG table, we can attach
      51             :          */
      52           0 :         hdr = (struct acpi_table_header *)aaa->aaa_table;
      53           0 :         if (memcmp(hdr->signature, MCFG_SIG, sizeof(MCFG_SIG) - 1) != 0)
      54           0 :                 return (0);
      55             : 
      56           0 :         return (1);
      57           0 : }
      58             : 
      59             : void
      60           0 : acpimcfg_attach(struct device *parent, struct device *self, void *aux)
      61             : {
      62           0 :         struct acpi_attach_args *aaa = aux;
      63           0 :         struct acpi_mcfg *mcfg = (struct acpi_mcfg *)aaa->aaa_table;
      64           0 :         caddr_t addr = (caddr_t)(mcfg + 1);
      65             : 
      66           0 :         printf("\n");
      67             : 
      68           0 :         while (addr < (caddr_t)mcfg + mcfg->hdr.length) {
      69           0 :                 struct acpi_mcfg_entry *entry = (struct acpi_mcfg_entry *)addr;
      70             : 
      71           0 :                 printf("%s: addr 0x%llx, bus %d-%d\n", self->dv_xname,
      72           0 :                     entry->base_address, entry->min_bus_number, entry->max_bus_number);
      73             : 
      74           0 :                 pci_mcfg_init(aaa->aaa_memt, entry->base_address,
      75           0 :                      entry->segment, entry->min_bus_number, entry->max_bus_number);
      76           0 :                 addr += sizeof(struct acpi_mcfg_entry);
      77             :         }
      78           0 : }

Generated by: LCOV version 1.13