Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F175222823
D24153.id69773.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
15 KB
Referenced Files
None
Subscribers
None
D24153.id69773.diff
View Options
Index: sys/arm/arm/machdep.c
===================================================================
--- sys/arm/arm/machdep.c
+++ sys/arm/arm/machdep.c
@@ -66,6 +66,7 @@
#include <sys/ktr.h>
#include <sys/linker.h>
#include <sys/msgbuf.h>
+#include <sys/physmem.h>
#include <sys/reboot.h>
#include <sys/rwlock.h>
#include <sys/sched.h>
@@ -83,7 +84,6 @@
#include <machine/machdep.h>
#include <machine/metadata.h>
#include <machine/pcb.h>
-#include <machine/physmem.h>
#include <machine/platform.h>
#include <machine/sysarch.h>
#include <machine/undefined.h>
@@ -123,6 +123,9 @@
int cold = 1;
vm_offset_t vector_page;
+/* The address at which the kernel was loaded. Set early in initarm(). */
+vm_paddr_t arm_physmem_kernaddr;
+
int (*_arm_memcpy)(void *, void *, int, int) = NULL;
int (*_arm_bzero)(void *, int, int) = NULL;
int _min_memcpy_size = 0;
@@ -160,7 +163,6 @@
#endif
struct kva_md_info kmi;
-
/*
* arm32_vector_init:
*
@@ -237,7 +239,7 @@
(uintmax_t)arm32_ptob(vm_free_count()),
(uintmax_t)arm32_ptob(vm_free_count()) / mbyte);
if (bootverbose) {
- arm_physmem_print_tables();
+ physmem_print_tables();
devmap_print_table();
}
@@ -870,11 +872,11 @@
/* Grab physical memory regions information from device tree. */
if (fdt_get_mem_regions(mem_regions, &mem_regions_sz, &memsize) != 0)
panic("Cannot get physical memory regions");
- arm_physmem_hardware_regions(mem_regions, mem_regions_sz);
+ physmem_hardware_regions(mem_regions, mem_regions_sz);
/* Grab reserved memory regions information from device tree. */
if (fdt_get_reserved_regions(mem_regions, &mem_regions_sz) == 0)
- arm_physmem_exclude_regions(mem_regions, mem_regions_sz,
+ physmem_exclude_regions(mem_regions, mem_regions_sz,
EXFLAG_NODUMP | EXFLAG_NOALLOC);
/* Platform-specific initialisation */
@@ -1081,9 +1083,9 @@
*
* Prepare the list of physical memory available to the vm subsystem.
*/
- arm_physmem_exclude_region(abp->abp_physaddr,
+ physmem_exclude_region(abp->abp_physaddr,
(virtual_avail - KERNVIRTADDR), EXFLAG_NOALLOC);
- arm_physmem_init_kernel_globals();
+ physmem_init_kernel_globals();
init_param2(physmem);
dbg_monitor_init();
@@ -1149,11 +1151,11 @@
if (fdt_get_mem_regions(mem_regions, &mem_regions_sz,NULL) != 0)
panic("Cannot get physical memory regions");
}
- arm_physmem_hardware_regions(mem_regions, mem_regions_sz);
+ physmem_hardware_regions(mem_regions, mem_regions_sz);
/* Grab reserved memory regions information from device tree. */
if (fdt_get_reserved_regions(mem_regions, &mem_regions_sz) == 0)
- arm_physmem_exclude_regions(mem_regions, mem_regions_sz,
+ physmem_exclude_regions(mem_regions, mem_regions_sz,
EXFLAG_NODUMP | EXFLAG_NOALLOC);
/*
@@ -1288,9 +1290,9 @@
*
* Prepare the list of physical memory available to the vm subsystem.
*/
- arm_physmem_exclude_region(abp->abp_physaddr,
+ physmem_exclude_region(abp->abp_physaddr,
pmap_preboot_get_pages(0) - abp->abp_physaddr, EXFLAG_NOALLOC);
- arm_physmem_init_kernel_globals();
+ physmem_init_kernel_globals();
init_param2(physmem);
/* Init message buffer. */
Index: sys/arm/arm/machdep_boot.c
===================================================================
--- sys/arm/arm/machdep_boot.c
+++ sys/arm/arm/machdep_boot.c
@@ -36,6 +36,7 @@
#include <sys/systm.h>
#include <sys/ctype.h>
#include <sys/linker.h>
+#include <sys/physmem.h>
#include <sys/reboot.h>
#include <sys/sysctl.h>
#if defined(LINUX_BOOT_ABI)
@@ -46,7 +47,6 @@
#include <machine/cpu.h>
#include <machine/machdep.h>
#include <machine/metadata.h>
-#include <machine/physmem.h>
#include <machine/vmparam.h> /* For KERNVIRTADDR */
#ifdef FDT
@@ -228,7 +228,7 @@
case ATAG_CORE:
break;
case ATAG_MEM:
- arm_physmem_hardware_region(walker->u.tag_mem.start,
+ physmem_hardware_region(walker->u.tag_mem.start,
walker->u.tag_mem.size);
break;
case ATAG_INITRD2:
Index: sys/arm/arm/mp_machdep.c
===================================================================
--- sys/arm/arm/mp_machdep.c
+++ sys/arm/arm/mp_machdep.c
@@ -53,7 +53,6 @@
#include <machine/debug_monitor.h>
#include <machine/smp.h>
#include <machine/pcb.h>
-#include <machine/physmem.h>
#include <machine/intr.h>
#include <machine/vmparam.h>
#ifdef VFP
Index: sys/arm/arm/pmap-v6.c
===================================================================
--- sys/arm/arm/pmap-v6.c
+++ sys/arm/arm/pmap-v6.c
@@ -102,6 +102,7 @@
#include <sys/kernel.h>
#include <sys/ktr.h>
#include <sys/lock.h>
+#include <sys/physmem.h>
#include <sys/proc.h>
#include <sys/rwlock.h>
#include <sys/malloc.h>
@@ -117,8 +118,6 @@
#include <ddb/ddb.h>
#endif
-#include <machine/physmem.h>
-
#include <vm/vm.h>
#include <vm/uma.h>
#include <vm/pmap.h>
Index: sys/arm/include/md_var.h
===================================================================
--- sys/arm/include/md_var.h
+++ sys/arm/include/md_var.h
@@ -42,6 +42,7 @@
extern int vm_page_dump_size;
extern u_long elf_hwcap;
extern u_long elf_hwcap2;
+extern vm_paddr_t arm_physmem_kernaddr;
extern int (*_arm_memcpy)(void *, void *, int, int);
extern int (*_arm_bzero)(void *, int, int);
Index: sys/arm64/arm64/machdep.c
===================================================================
--- sys/arm64/arm64/machdep.c
+++ sys/arm64/arm64/machdep.c
@@ -50,6 +50,7 @@
#include <sys/linker.h>
#include <sys/msgbuf.h>
#include <sys/pcpu.h>
+#include <sys/physmem.h>
#include <sys/proc.h>
#include <sys/ptrace.h>
#include <sys/reboot.h>
@@ -82,8 +83,6 @@
#include <machine/undefined.h>
#include <machine/vmparam.h>
-#include <arm/include/physmem.h>
-
#ifdef VFP
#include <machine/vfp.h>
#endif
@@ -855,7 +854,7 @@
*/
break;
default:
- arm_physmem_exclude_region(p->md_phys, p->md_pages * PAGE_SIZE,
+ physmem_exclude_region(p->md_phys, p->md_pages * PAGE_SIZE,
EXFLAG_NOALLOC);
}
}
@@ -886,7 +885,7 @@
/*
* We're allowed to use any entry with these types.
*/
- arm_physmem_hardware_region(p->md_phys,
+ physmem_hardware_region(p->md_phys,
p->md_pages * PAGE_SIZE);
break;
}
@@ -1113,10 +1112,10 @@
if (fdt_get_mem_regions(mem_regions, &mem_regions_sz,
NULL) != 0)
panic("Cannot get physical memory regions");
- arm_physmem_hardware_regions(mem_regions, mem_regions_sz);
+ physmem_hardware_regions(mem_regions, mem_regions_sz);
}
if (fdt_get_reserved_mem(mem_regions, &mem_regions_sz) == 0)
- arm_physmem_exclude_regions(mem_regions, mem_regions_sz,
+ physmem_exclude_regions(mem_regions, mem_regions_sz,
EXFLAG_NODUMP | EXFLAG_NOALLOC);
#endif
@@ -1124,7 +1123,7 @@
efifb = (struct efi_fb *)preload_search_info(kmdp,
MODINFO_METADATA | MODINFOMD_EFI_FB);
if (efifb != NULL)
- arm_physmem_exclude_region(efifb->fb_addr, efifb->fb_size,
+ physmem_exclude_region(efifb->fb_addr, efifb->fb_size,
EXFLAG_NOALLOC);
/* Set the pcpu data, this is needed by pmap_bootstrap */
@@ -1153,7 +1152,7 @@
/* Exclude entries neexed in teh DMAP region, but not phys_avail */
if (efihdr != NULL)
exclude_efi_map_entries(efihdr);
- arm_physmem_init_kernel_globals();
+ physmem_init_kernel_globals();
devmap_bootstrap(0, NULL);
@@ -1182,7 +1181,7 @@
if (boothowto & RB_VERBOSE) {
print_efi_map_entries(efihdr);
- arm_physmem_print_tables();
+ physmem_print_tables();
}
early_boot = 0;
Index: sys/arm64/arm64/pmap.c
===================================================================
--- sys/arm64/arm64/pmap.c
+++ sys/arm64/arm64/pmap.c
@@ -119,6 +119,7 @@
#include <sys/mman.h>
#include <sys/msgbuf.h>
#include <sys/mutex.h>
+#include <sys/physmem.h>
#include <sys/proc.h>
#include <sys/rwlock.h>
#include <sys/sbuf.h>
@@ -148,8 +149,6 @@
#include <machine/md_var.h>
#include <machine/pcb.h>
-#include <arm/include/physmem.h>
-
#define PMAP_ASSERT_STAGE1(pmap) MPASS((pmap)->pm_stage == PM_STAGE1)
#define NL0PG (PAGE_SIZE/(sizeof (pd_entry_t)))
@@ -861,7 +860,7 @@
/* Assume the address we were loaded to is a valid physical address */
min_pa = KERNBASE - kern_delta;
- physmap_idx = arm_physmem_avail(physmap, nitems(physmap));
+ physmap_idx = physmem_avail(physmap, nitems(physmap));
physmap_idx /= 2;
/*
@@ -942,7 +941,7 @@
pa = pmap_early_vtophys(l1pt, freemempos);
- arm_physmem_exclude_region(start_pa, pa - start_pa, EXFLAG_NOALLOC);
+ physmem_exclude_region(start_pa, pa - start_pa, EXFLAG_NOALLOC);
cpu_tlb_flushID();
}
Index: sys/conf/files.arm
===================================================================
--- sys/conf/files.arm
+++ sys/conf/files.arm
@@ -58,7 +58,6 @@
arm/arm/mpcore_timer.c optional mpcore_timer
arm/arm/nexus.c standard
arm/arm/ofw_machdep.c optional fdt
-arm/arm/physmem.c standard
arm/arm/pl190.c optional pl190
arm/arm/pl310.c optional pl310
arm/arm/platform.c optional platform
@@ -116,6 +115,7 @@
kern/pic_if.m optional intrng
kern/subr_busdma_bufalloc.c standard
kern/subr_devmap.c standard
+kern/subr_physmem.c standard
kern/subr_sfbuf.c standard
libkern/arm/aeabi_unwind.c standard
libkern/arm/divsi3.S standard
Index: sys/conf/files.arm64
===================================================================
--- sys/conf/files.arm64
+++ sys/conf/files.arm64
@@ -85,7 +85,6 @@
arm/arm/gic_acpi.c optional acpi
arm/arm/gic_fdt.c optional fdt
arm/arm/pmu.c standard
-arm/arm/physmem.c standard
arm/broadcom/bcm2835/bcm2835_audio.c optional sound vchiq fdt \
compile-with "${NORMAL_C} -DUSE_VCHIQ_ARM -D__VCCOREVER__=0x04000000 -I$S/contrib/vchiq"
arm/broadcom/bcm2835/bcm2835_bsc.c optional bcm2835_bsc fdt
@@ -288,6 +287,7 @@
kern/pic_if.m optional intrng
kern/subr_devmap.c standard
kern/subr_intr.c optional intrng
+kern/subr_physmem.c standard
libkern/bcmp.c standard
libkern/memcmp.c standard \
compile-with "${NORMAL_C:N-fsanitize*}"
Index: sys/kern/subr_physmem.c
===================================================================
--- sys/kern/subr_physmem.c
+++ sys/kern/subr_physmem.c
@@ -38,12 +38,12 @@
#include <sys/param.h>
#include <sys/systm.h>
+#include <sys/physmem.h>
#include <vm/vm.h>
#include <vm/vm_param.h>
#include <vm/vm_page.h>
#include <vm/vm_phys.h>
#include <machine/md_var.h>
-#include <arm/include/physmem.h>
/*
* These structures are used internally to keep track of regions of physical
@@ -62,10 +62,8 @@
#if defined(__arm__)
#define MAX_PHYS_ADDR 0xFFFFFFFFull
-#define pm_btop(x) arm32_btop(x)
-#elif defined(__aarch64__)
+#elif defined(__aarch64__) || defined(__riscv)
#define MAX_PHYS_ADDR 0xFFFFFFFFFFFFFFFFull
-#define pm_btop(x) arm64_btop(x)
#endif
struct region {
@@ -87,9 +85,6 @@
long realmem;
long Maxmem;
-/* The address at which the kernel was loaded. Set early in initarm(). */
-vm_paddr_t arm_physmem_kernaddr;
-
/*
* Print the contents of the physical and excluded region tables using the
* provided printf-like output function (which will be either printf or
@@ -136,7 +131,7 @@
* Print the contents of the static mapping table. Used for bootverbose.
*/
void
-arm_physmem_print_tables(void)
+physmem_print_tables(void)
{
physmem_dump_tables(printf);
@@ -165,7 +160,7 @@
for (hwi = 0, hwp = hwregions; hwi < hwcnt; ++hwi, ++hwp) {
start = hwp->addr;
end = hwp->size + start;
- totalmem += pm_btop((vm_offset_t)(end - start));
+ totalmem += atop((vm_offset_t)(end - start));
for (exi = 0, exp = exregions; exi < excnt; ++exi, ++exp) {
/*
* If the excluded region does not match given flags,
@@ -213,8 +208,7 @@
avail[acnt++] = (vm_paddr_t)start;
avail[acnt++] = (vm_paddr_t)xstart;
}
- availmem +=
- pm_btop((vm_offset_t)(xstart - start));
+ availmem += atop((vm_offset_t)(xstart - start));
start = xend;
continue;
}
@@ -239,7 +233,7 @@
avail[acnt++] = (vm_paddr_t)start;
avail[acnt++] = (vm_paddr_t)end;
}
- availmem += pm_btop((vm_offset_t)(end - start));
+ availmem += atop((vm_offset_t)(end - start));
}
if (acnt >= maxavail)
panic("Not enough space in the dump/phys_avail arrays");
@@ -293,7 +287,7 @@
* Add a hardware memory region.
*/
void
-arm_physmem_hardware_region(uint64_t pa, uint64_t sz)
+physmem_hardware_region(uint64_t pa, uint64_t sz)
{
vm_offset_t adj;
@@ -345,7 +339,7 @@
* Add an exclusion region.
*/
void
-arm_physmem_exclude_region(vm_paddr_t pa, vm_size_t sz, uint32_t exflags)
+physmem_exclude_region(vm_paddr_t pa, vm_size_t sz, uint32_t exflags)
{
vm_offset_t adj;
@@ -364,7 +358,7 @@
}
size_t
-arm_physmem_avail(vm_paddr_t *avail, size_t maxavail)
+physmem_avail(vm_paddr_t *avail, size_t maxavail)
{
return (regions_to_avail(avail, EXFLAG_NOALLOC, maxavail, NULL, NULL));
@@ -380,7 +374,7 @@
* last page of physical memory in the system.
*/
void
-arm_physmem_init_kernel_globals(void)
+physmem_init_kernel_globals(void)
{
size_t nextidx;
@@ -403,4 +397,3 @@
}
#endif /* DDB */
-
Index: sys/sys/physmem.h
===================================================================
--- sys/sys/physmem.h
+++ sys/sys/physmem.h
@@ -28,13 +28,8 @@
* $FreeBSD$
*/
-#ifndef _MACHINE_PHYSMEM_H_
-#define _MACHINE_PHYSMEM_H_
-
-/*
- * The physical address at which the kernel was loaded.
- */
-extern vm_paddr_t arm_physmem_kernaddr;
+#ifndef _SYS_PHYSMEM_H_
+#define _SYS_PHYSMEM_H_
/*
* Routines to help configure physical ram.
@@ -46,7 +41,7 @@
*
* After all early kernel init is done and it's time to configure all
* remainining non-excluded physical ram for use by other parts of the kernel,
- * arm_physmem_init_kernel_globals() processes the hardware regions and
+ * physmem_init_kernel_globals() processes the hardware regions and
* exclusion regions to generate the global dump_avail and phys_avail arrays
* that communicate physical ram configuration to other parts of the kernel.
*/
@@ -54,11 +49,11 @@
#define EXFLAG_NODUMP 0x01
#define EXFLAG_NOALLOC 0x02
-void arm_physmem_hardware_region(uint64_t pa, uint64_t sz);
-void arm_physmem_exclude_region(vm_paddr_t pa, vm_size_t sz, uint32_t flags);
-size_t arm_physmem_avail(vm_paddr_t *avail, size_t maxavail);
-void arm_physmem_init_kernel_globals(void);
-void arm_physmem_print_tables(void);
+void physmem_hardware_region(uint64_t pa, uint64_t sz);
+void physmem_exclude_region(vm_paddr_t pa, vm_size_t sz, uint32_t flags);
+size_t physmem_avail(vm_paddr_t *avail, size_t maxavail);
+void physmem_init_kernel_globals(void);
+void physmem_print_tables(void);
/*
* Convenience routines for FDT.
@@ -69,20 +64,20 @@
#include <machine/ofw_machdep.h>
static inline void
-arm_physmem_hardware_regions(struct mem_region * mrptr, int mrcount)
+physmem_hardware_regions(struct mem_region * mrptr, int mrcount)
{
while (mrcount--) {
- arm_physmem_hardware_region(mrptr->mr_start, mrptr->mr_size);
+ physmem_hardware_region(mrptr->mr_start, mrptr->mr_size);
++mrptr;
}
}
static inline void
-arm_physmem_exclude_regions(struct mem_region * mrptr, int mrcount,
+physmem_exclude_regions(struct mem_region * mrptr, int mrcount,
uint32_t exflags)
{
while (mrcount--) {
- arm_physmem_exclude_region(mrptr->mr_start, mrptr->mr_size,
+ physmem_exclude_region(mrptr->mr_start, mrptr->mr_size,
exflags);
++mrptr;
}
@@ -90,5 +85,4 @@
#endif /* FDT */
-#endif
-
+#endif /* !_SYS_PHYSMEM_H_ */
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Oct 10, 5:41 AM (11 h, 58 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
40527487
Default Alt Text
D24153.id69773.diff (15 KB)
Attached To
Mode
D24153: Convert arm's physmem interface to MI code
Attached
Detach File
Event Timeline
Log In to Comment