From owner-svn-src-projects@FreeBSD.ORG Mon Nov 25 21:57:17 2013 Return-Path: Delivered-To: svn-src-projects@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 49EB42E9; Mon, 25 Nov 2013 21:57:17 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 38BBB2C90; Mon, 25 Nov 2013 21:57:17 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id rAPLvHvO052828; Mon, 25 Nov 2013 21:57:17 GMT (envelope-from andrew@svn.freebsd.org) Received: (from andrew@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id rAPLvGMs052819; Mon, 25 Nov 2013 21:57:16 GMT (envelope-from andrew@svn.freebsd.org) Message-Id: <201311252157.rAPLvGMs052819@svn.freebsd.org> From: Andrew Turner Date: Mon, 25 Nov 2013 21:57:16 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r258599 - in projects/specific_leg/sys/arm: arm broadcom/bcm2835 include X-SVN-Group: projects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 25 Nov 2013 21:57:17 -0000 Author: andrew Date: Mon Nov 25 21:57:15 2013 New Revision: 258599 URL: http://svnweb.freebsd.org/changeset/base/258599 Log: Move the functions each SoC needs to define to the new platform code. While here add more debug info to the FDT initarm. Modified: projects/specific_leg/sys/arm/arm/machdep.c projects/specific_leg/sys/arm/arm/platform.c projects/specific_leg/sys/arm/arm/platform_if.m projects/specific_leg/sys/arm/broadcom/bcm2835/bcm2835_machdep.c projects/specific_leg/sys/arm/include/machdep.h projects/specific_leg/sys/arm/include/platform.h Modified: projects/specific_leg/sys/arm/arm/machdep.c ============================================================================== --- projects/specific_leg/sys/arm/arm/machdep.c Mon Nov 25 21:30:45 2013 (r258598) +++ projects/specific_leg/sys/arm/arm/machdep.c Mon Nov 25 21:57:15 2013 (r258599) @@ -108,6 +108,7 @@ __FBSDID("$FreeBSD$"); #include #endif +#define DEBUG #ifdef DEBUG #define debugf(fmt, args...) printf(fmt, ##args) #else @@ -1239,8 +1240,6 @@ initarm(struct arm_boot_params *abp) if (OF_init((void *)dtbp) != 0) while (1); - platform_probe_and_attach(); - /* Grab physical memory regions information from device tree. */ if (fdt_get_mem_regions(memory_regions, &memory_regions_sz, &memsize) != 0) @@ -1250,6 +1249,8 @@ initarm(struct arm_boot_params *abp) if (fdt_get_reserved_regions(reserved_regions, &reserved_regions_sz) != 0) reserved_regions_sz = 0; + platform_probe_and_attach(); + /* * Build the dump_avail table */ @@ -1320,9 +1321,6 @@ initarm(struct arm_boot_params *abp) availmem_regions_sz = curr; - /* Platform-specific initialisation */ - initarm_early_init(); - pcpu0_init(); /* Do basic tuning, hz etc */ @@ -1438,9 +1436,9 @@ initarm(struct arm_boot_params *abp) VM_PROT_READ|VM_PROT_WRITE|VM_PROT_EXECUTE, PTE_CACHE); /* Establish static device mappings. */ - err_devmap = initarm_devmap_init(); + err_devmap = platform_devmap_init(); arm_devmap_bootstrap(l1pagetable, NULL); - vm_max_kernel_address = initarm_lastaddr(); + vm_max_kernel_address = platform_lastaddr(); cpu_domains((DOMAIN_CLIENT << (PMAP_DOMAIN_KERNEL * 2)) | DOMAIN_CLIENT); pmap_pa = kernel_l1pt.pv_pa; @@ -1454,16 +1452,21 @@ initarm(struct arm_boot_params *abp) */ OF_interpret("perform-fixup", 0); - initarm_gpio_init(); + platform_gpio_init(); cninit(); physmem = memsize / PAGE_SIZE; debugf("initarm: console initialized\n"); - debugf(" arg1 kmdp = 0x%08x\n", (uint32_t)kmdp); - debugf(" boothowto = 0x%08x\n", boothowto); - debugf(" dtbp = 0x%08x\n", (uint32_t)dtbp); + debugf(" arg1 kmdp = 0x%08x\n", (uint32_t)kmdp); + debugf(" boothowto = 0x%08x\n", boothowto); + debugf(" dtbp = 0x%08x\n", (uint32_t)dtbp); + debugf(" abp = %p\n", abp); + debugf(" abp->abp_r0 = 0x%08x\n", abp->abp_r0); + debugf(" abp->abp_r1 = 0x%08x\n", abp->abp_r1); + debugf(" abp->abp_r2 = 0x%08x\n", abp->abp_r2); + debugf(" abp->abp_r3 = 0x%08x\n", abp->abp_r3); print_kenv(); env = getenv("kernelname"); @@ -1474,7 +1477,7 @@ initarm(struct arm_boot_params *abp) printf("WARNING: could not fully configure devmap, error=%d\n", err_devmap); - initarm_late_init(); + platform_late_init(); /* * Pages were allocated during the secondary bootstrap for the Modified: projects/specific_leg/sys/arm/arm/platform.c ============================================================================== --- projects/specific_leg/sys/arm/arm/platform.c Mon Nov 25 21:30:45 2013 (r258598) +++ projects/specific_leg/sys/arm/arm/platform.c Mon Nov 25 21:57:15 2013 (r258599) @@ -79,13 +79,11 @@ platform_probe_and_attach(void) plat_obj = &plat_kernel_obj; best_prio = 0; -printf("platform_probe_and_attach\n"); /* * Try to locate the best platform kobj */ SET_FOREACH(platpp, platform_set) { platp = *platpp; -printf("platp = %p %p\n", platp, platp->baseclasses); /* * Take care of compiling the selected class, and @@ -140,3 +138,31 @@ printf("platp = %p %p\n", platp, platp-> PLATFORM_ATTACH(plat_obj); } +int +platform_devmap_init(void) +{ + + return PLATFORM_DEVMAP_INIT(plat_obj); +} + +vm_offset_t +platform_lastaddr(void) +{ + + return PLATFORM_LASTADDR(plat_obj); +} + +void +platform_gpio_init(void) +{ + + PLATFORM_GPIO_INIT(plat_obj); +} + +void +platform_late_init(void) +{ + + PLATFORM_LATE_INIT(plat_obj); +} + Modified: projects/specific_leg/sys/arm/arm/platform_if.m ============================================================================== --- projects/specific_leg/sys/arm/arm/platform_if.m Mon Nov 25 21:30:45 2013 (r258598) +++ projects/specific_leg/sys/arm/arm/platform_if.m Mon Nov 25 21:57:15 2013 (r258599) @@ -98,3 +98,40 @@ METHOD int attach { platform_t _plat; } DEFAULT platform_null_attach; +/** + * @brief Called as one of the last steps of early virtual memory + * initialization, shortly before the new page tables are installed. + */ +METHOD int devmap_init { + platform_t _plat; +}; + +/** + * @brief Called after devmap_init(), and must return the address of the + * first byte of unusable KVA space. This allows a platform to carve out + * of the top of the KVA space whatever reserves it needs for things like + * static device mapping, and this is called to get the value before + * calling pmap_bootstrap() which uses the value to size the available KVA. + */ +METHOD vm_offset_t lastaddr { + platform_t _plat; +}; + +/** + * @brief Called after the static device mappings are established and just + * before cninit(). The intention is that the routine can do any hardware + * setup (such as gpio or pinmux) necessary to make the console functional. + */ +METHOD void gpio_init { + platform_t _plat; +}; + +/** + * @brief Called just after cninit(). This is the first of the init + * routines that can use printf() and expect the output to appear on + * a standard console. + */ +METHOD void late_init { + platform_t _plat; +}; + Modified: projects/specific_leg/sys/arm/broadcom/bcm2835/bcm2835_machdep.c ============================================================================== --- projects/specific_leg/sys/arm/broadcom/bcm2835/bcm2835_machdep.c Mon Nov 25 21:30:45 2013 (r258598) +++ projects/specific_leg/sys/arm/broadcom/bcm2835/bcm2835_machdep.c Mon Nov 25 21:57:15 2013 (r258599) @@ -65,26 +65,15 @@ __FBSDID("$FreeBSD$"); /* Start of address space used for bootstrap map */ #define DEVMAP_BOOTSTRAP_MAP_START 0xE0000000 -vm_offset_t -initarm_lastaddr(void) +static vm_offset_t +bcm2835_lastaddr(platform_t plat) { return (DEVMAP_BOOTSTRAP_MAP_START); } -void -initarm_early_init(void) -{ - -} - -void -initarm_gpio_init(void) -{ -} - -void -initarm_late_init(void) +static void +bcm2835_late_init(platform_t plat) { phandle_t system; pcell_t cells[2]; @@ -111,8 +100,8 @@ static struct arm_devmap_entry fdt_devma /* * Construct pmap_devmap[] with DT-derived config data. */ -int -initarm_devmap_init(void) +static int +bcm2835_devmap_init(platform_t plat) { int i = 0; @@ -149,6 +138,10 @@ cpu_reset() } static platform_method_t bcm2835_methods[] = { + PLATFORMMETHOD(platform_devmap_init, bcm2835_devmap_init), + PLATFORMMETHOD(platform_lastaddr, bcm2835_lastaddr), + PLATFORMMETHOD(platform_late_init, bcm2835_late_init), + PLATFORMMETHOD_END, }; Modified: projects/specific_leg/sys/arm/include/machdep.h ============================================================================== --- projects/specific_leg/sys/arm/include/machdep.h Mon Nov 25 21:30:45 2013 (r258598) +++ projects/specific_leg/sys/arm/include/machdep.h Mon Nov 25 21:57:15 2013 (r258599) @@ -40,32 +40,9 @@ vm_offset_t parse_boot_param(struct arm_ * * - initarm_early_init() is called very early, after parsing the boot params * and after physical memory has been located and sized. - * - * - platform_devmap_init() is called as one of the last steps of early virtual - * memory initialization, shortly before the new page tables are installed. - * - * - initarm_lastaddr() is called after platform_devmap_init(), and must return - * the address of the first byte of unusable KVA space. This allows a - * platform to carve out of the top of the KVA space whatever reserves it - * needs for things like static device mapping, and this is called to get the - * value before calling pmap_bootstrap() which uses the value to size the - * available KVA. - * - * - initarm_gpio_init() is called after the static device mappings are - * established and just before cninit(). The intention is that the routine - * can do any hardware setup (such as gpio or pinmux) necessary to make the - * console functional. - * - * - initarm_late_init() is called just after cninit(). This is the first of - * the init routines that can use printf() and expect the output to appear on - * a standard console. - * + * TODO: Move contents to the platform attach function. */ -void initarm_early_init(void); -int initarm_devmap_init(void); -vm_offset_t initarm_lastaddr(void); -void initarm_gpio_init(void); -void initarm_late_init(void); +//void initarm_early_init(void); /* Board-specific attributes */ void board_set_serial(uint64_t); Modified: projects/specific_leg/sys/arm/include/platform.h ============================================================================== --- projects/specific_leg/sys/arm/include/platform.h Mon Nov 25 21:30:45 2013 (r258598) +++ projects/specific_leg/sys/arm/include/platform.h Mon Nov 25 21:57:15 2013 (r258599) @@ -55,5 +55,9 @@ void platform_smp_ap_init(void); const char *installed_platform(void); #endif void platform_probe_and_attach(void); +int platform_devmap_init(void); +vm_offset_t platform_lastaddr(void); +void platform_gpio_init(void); +void platform_late_init(void); #endif /* _MACHINE_PLATFORM_H_ */