pci_tools.c (1ee1bcba) pci_tools.c (49ee6bfb)
1/*
2 * CDDL HEADER START
3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE

--- 859 unchanged lines hidden (view full) ---

868 *num_pages = 1;
869
870 /* Desired mapping would span more than two pages. */
871 if ((offset + size) > (MMU_PAGESIZE * 2)) {
872 if (pcitool_debug)
873 prom_printf("boundary violation: "
874 "offset:0x%" PRIx64 ", size:%ld, pagesize:0x%lx\n",
875 offset, (uintptr_t)size, (uintptr_t)MMU_PAGESIZE);
1/*
2 * CDDL HEADER START
3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE

--- 859 unchanged lines hidden (view full) ---

868 *num_pages = 1;
869
870 /* Desired mapping would span more than two pages. */
871 if ((offset + size) > (MMU_PAGESIZE * 2)) {
872 if (pcitool_debug)
873 prom_printf("boundary violation: "
874 "offset:0x%" PRIx64 ", size:%ld, pagesize:0x%lx\n",
875 offset, (uintptr_t)size, (uintptr_t)MMU_PAGESIZE);
876 return (NULL);
876 return (0);
877
878 } else if ((offset + size) > MMU_PAGESIZE) {
879 (*num_pages)++;
880 }
881
882 /* Get page(s) of virtual space. */
883 virt_base = vmem_alloc(heap_arena, ptob(*num_pages), VM_NOSLEEP);
884 if (virt_base == NULL) {
885 if (pcitool_debug)
886 prom_printf("Couldn't get virtual base address.\n");
877
878 } else if ((offset + size) > MMU_PAGESIZE) {
879 (*num_pages)++;
880 }
881
882 /* Get page(s) of virtual space. */
883 virt_base = vmem_alloc(heap_arena, ptob(*num_pages), VM_NOSLEEP);
884 if (virt_base == NULL) {
885 if (pcitool_debug)
886 prom_printf("Couldn't get virtual base address.\n");
887 return (NULL);
887 return (0);
888 }
889
890 if (pcitool_debug)
891 prom_printf("Got base virtual address:0x%p\n", virt_base);
892
893#ifdef __xpv
894 /*
895 * We should only get here if we are dom0.

--- 275 unchanged lines hidden (view full) ---

1171 * Use offset provided by caller to index into
1172 * desired space, then access.
1173 * Note that prg.status is modified on error.
1174 */
1175 prg.phys_addr = base_addr + prg.offset;
1176
1177 virt_addr = pcitool_map(prg.phys_addr, size,
1178 &num_virt_pages);
888 }
889
890 if (pcitool_debug)
891 prom_printf("Got base virtual address:0x%p\n", virt_base);
892
893#ifdef __xpv
894 /*
895 * We should only get here if we are dom0.

--- 275 unchanged lines hidden (view full) ---

1171 * Use offset provided by caller to index into
1172 * desired space, then access.
1173 * Note that prg.status is modified on error.
1174 */
1175 prg.phys_addr = base_addr + prg.offset;
1176
1177 virt_addr = pcitool_map(prg.phys_addr, size,
1178 &num_virt_pages);
1179 if (virt_addr == NULL) {
1179 if (virt_addr == 0) {
1180 prg.status = PCITOOL_IO_ERROR;
1181 rval = EIO;
1182 goto done_reg;
1183 }
1184
1185 rval = pcitool_mem_access(&prg, virt_addr, write_flag);
1186 pcitool_unmap(virt_addr, num_virt_pages);
1187 }

--- 15 unchanged lines hidden ---
1180 prg.status = PCITOOL_IO_ERROR;
1181 rval = EIO;
1182 goto done_reg;
1183 }
1184
1185 rval = pcitool_mem_access(&prg, virt_addr, write_flag);
1186 pcitool_unmap(virt_addr, num_virt_pages);
1187 }

--- 15 unchanged lines hidden ---