Subject: Re: Changing kernel base address (was: Re: Heads up: shared arm include files)
To: Chris Gilbert <chris@buzzbee.freeserve.co.uk>
From: Mike Pumford <mpumford@black-star.demon.co.uk>
List: port-arm32
Date: 01/22/2001 02:11:09
This is a multipart MIME message.

--==_Exmh_-20608819230
Content-Type: text/plain; charset=us-ascii


> Hi Mike,
> 
> As I'm not around this weekend I thought I'd send you the patch I've done 
> (non-working)  See if you can see anything that looks wrong or if you've 
> missed something in your changes.  One thought I had was to not enable the 
> console till the 2nd mapping has completed...
> 
I have got things working with IOMD remapped. I added some code in initarm to 
remap the IOMD and VIDC before consinit gets called. Both your patches and 
mine were being bitten by a flaw in the kernel build system for arm32.

The kernel build process does not do any depency checking for assembler files 
so assembler files do not get rebuilt if a header that they depend on is 
changed. iomd_iic.S uses the IOMD base address defined in iomd.h. These 
routines are first invoked in initarm and when they were not being rebuilt the 
kernel crashed when attempting to read the reboot count from the CMOS.
The final mapping I went for is:

0xf7000000      IOMD
0xf7100000      VIDC
0xf7200000      IO base (podules)
0xf7400000      VRAM (or video DRAM)
0xf8000000	EASI podule space.

This is still a bit wasteful but it avoids the assembler in iomd_iic.S having 
to do anything complicated to load the IOMD base address.

My patch (including the VM space growth) is attached.

Mike



--==_Exmh_-20608819230
Content-Type: application/x-patch ; name="vmspace.patch"
Content-Description: vmspace.patch
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment; filename="vmspace.patch"

Index: riscpc/rpc_machdep.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /overflow/cvsrep/netbsd/sys/arch/arm32/riscpc/rpc_machdep.c,v
retrieving revision 1.1.1.18
diff -c -r1.1.1.18 rpc_machdep.c
*** riscpc/rpc_machdep.c	2001/01/10 00:10:25	1.1.1.18
--- riscpc/rpc_machdep.c	2001/01/21 23:59:01
***************
*** 411,416 ****
--- 411,430 ----
  			videomemory.vidm_type =3D VIDEOMEM_TYPE_DRAM;
  	}
  =

+ 	/* XXX dirty trick. consinit assumes that the bootloader
+ 	 * has mapped IOMD and VIDC to their final locations.
+ 	 * if we wish to remap VIDC/IOMD from the locations defined in the
+ 	 * the bootloader then we must either avoid using VIDC/IOMD until
+ 	 * they have been mapped or do some remapping here.
+ 	 * =

+ 	 * The magic numbers are lifted directly from the original =

+ 	 * bootloader code. I have not checked if the Risc OS 4 =

+ 	 * compatible bootloader does things differently. (MP 21/01/2001)
+ 	 */
+ 	WriteWord(0x02c0c000 + ((IOMD_BASE >> 18) & 0xfffffffc),
+ 		  0x00000412 | (IOMD_HW_BASE & 0xfffff000));
+ 	WriteWord(0x02c0c000 + ((VIDC_BASE >> 18) & 0xfffffffc),
+ 		  0x00000412 | (VIDC_HW_BASE & 0xfffff000));
  	/*
  	 * Initialise the physical console
  	 * This is done in main() but for the moment we do it here so that
***************
*** 750,756 ****
  	 * Eventually if the top end of the memory gets used for process L1
  	 * page tables the kernel L1 page table may be moved up there.
  	 */
- =

  #ifdef VERBOSE_INIT_ARM
  	printf("Allocating page tables\n");
  #endif
--- 764,769 ----
Index: iomd/iomdreg.h
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /overflow/cvsrep/netbsd/sys/arch/arm32/iomd/iomdreg.h,v
retrieving revision 1.1.1.3
diff -c -r1.1.1.3 iomdreg.h
*** iomd/iomdreg.h	1998/04/18 13:21:30	1.1.1.3
--- iomd/iomdreg.h	2001/01/19 16:43:19
***************
*** 47,53 ****
  =

  #define IOMD_HW_BASE	0x03200000
  =

! #define IOMD_BASE	0xf6000000
  =

  #define IOMD_IOCR	0x00000000
  #define IOMD_KBDDAT	0x00000001
--- 47,53 ----
  =

  #define IOMD_HW_BASE	0x03200000
  =

! #define IOMD_BASE	0xf7000000
  =

  #define IOMD_IOCR	0x00000000
  #define IOMD_KBDDAT	0x00000001
***************
*** 190,196 ****
   */
  =

  #define IO_HW_MOUSE_BUTTONS	0x03210000
! #define IO_MOUSE_BUTTONS	0xf6010000
  =

  #define MOUSE_BUTTON_RIGHT  0x10
  #define MOUSE_BUTTON_MIDDLE 0x20
--- 190,196 ----
   */
  =

  #define IO_HW_MOUSE_BUTTONS	0x03210000
! #define IO_MOUSE_BUTTONS	(IOMD_BASE + 0x010000)
  =

  #define MOUSE_BUTTON_RIGHT  0x10
  #define MOUSE_BUTTON_MIDDLE 0x20
Index: include/vmparam.h
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /overflow/cvsrep/netbsd/sys/arch/arm32/include/vmparam.h,v
retrieving revision 1.1.1.12
diff -c -r1.1.1.12 vmparam.h
*** include/vmparam.h	2001/01/10 00:10:01	1.1.1.12
--- include/vmparam.h	2001/01/20 19:54:00
***************
*** 122,131 ****
  #define	KERNEL_VM_SIZE		0x04000000
  #else
  /*
!  * The range 0xf1000000 - 0xf3ffffff is available for kernel VM space
!  * Fixed mappings exist from 0xf4000000 - 0xffffffff
   */
! #define	KERNEL_VM_SIZE		0x03000000
  #endif
  #define	PROCESS_PAGE_TBLS_BASE	PAGE_TABLE_SPACE_START
  =

--- 122,131 ----
  #define	KERNEL_VM_SIZE		0x04000000
  #else
  /*
!  * The range 0xf1000000 - 0xf6ffffff is available for kernel VM space
!  * Fixed mappings exist from 0xf7000000 - 0xffffffff
   */
! #define	KERNEL_VM_SIZE		0x06000000
  #endif
  #define	PROCESS_PAGE_TBLS_BASE	PAGE_TABLE_SPACE_START
  =

***************
*** 155,161 ****
  /* XXX max. amount of KVM to be used by buffers. */
  #ifndef VM_MAX_KERNEL_BUF
  #define VM_MAX_KERNEL_BUF \
! 	((VM_MAXKERN_ADDRESS - KERNEL_VM_BASE) * 4 / 10)
  #endif
  =

  /* virtual sizes (bytes) for various kernel submaps */
--- 155,161 ----
  /* XXX max. amount of KVM to be used by buffers. */
  #ifndef VM_MAX_KERNEL_BUF
  #define VM_MAX_KERNEL_BUF \
! 	((VM_MAXKERN_ADDRESS - KERNEL_VM_BASE) * 2 / 10)
  #endif
  =

  /* virtual sizes (bytes) for various kernel submaps */
Index: include/io.h
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /overflow/cvsrep/netbsd/sys/arch/arm32/include/io.h,v
retrieving revision 1.1.1.1
diff -c -r1.1.1.1 io.h
*** include/io.h	1998/02/18 20:56:02	1.1.1.1
--- include/io.h	2001/01/21 23:58:41
***************
*** 51,79 ****
   * other IO devices thus making it difficult to separate them.
   */
   =

! #define IO_CONF_BASE			0xf6000000
  =

  #define IO_HW_BASE			0x03000000
  =

! #define IO_BASE				0xf6200000
  =

! #define COMBO_BASE			0xf6210000
  =

! #define IDE_CONTROLLER_BASE		0xf62107c0
  =

! #define FLOPPY_CONTROLLER_BASE		0xf6210fc0
  =

  #define FLOPPY_DACK			0x00002000
  =

! #define SERIAL0_CONTROLLER_BASE		0xf6210fe0
  =

! #define SERIAL1_CONTROLLER_BASE		0xf6210be0
  =

! #define PARALLEL_CONTROLLER_BASE	0xf62109e0
  =

  #ifdef RC7500
  =

! #define IDE_CONTROLLER_BASE2		0xf622B000
  =

  /*
   * a bit low turns attached LED on
--- 51,79 ----
   * other IO devices thus making it difficult to separate them.
   */
   =

! #define IO_CONF_BASE			0xf7000000
  =

  #define IO_HW_BASE			0x03000000
  =

! #define IO_BASE				(IO_CONF_BASE + 0x200000)
  =

! #define COMBO_BASE			(IO_BASE + 0x10000)
  =

! #define IDE_CONTROLLER_BASE		(COMBO_BASE + 0x7c0)
  =

! #define FLOPPY_CONTROLLER_BASE		(COMBO_BASE + 0xfc0)
  =

  #define FLOPPY_DACK			0x00002000
  =

! #define SERIAL0_CONTROLLER_BASE		(COMBO_BASE + 0xfe0)
  =

! #define SERIAL1_CONTROLLER_BASE		(COMBO_BASE + 0xbe0)
  =

! #define PARALLEL_CONTROLLER_BASE	(COMBO_BASE + 0x9e0)
  =

  #ifdef RC7500
  =

! #define IDE_CONTROLLER_BASE2		(IO_BASE + 0x2B000)
  =

  /*
   * a bit low turns attached LED on
***************
*** 98,114 ****
  =

  #define SIMPLE_PODULE_SIZE	0x00004000
  =

! #define MOD_PODULE_BASE		0xf6200000
! #define SYNC_PODULE_BASE	0xf63c0000
  #define SYNC_PODULE_HW_BASE	0x033c0000
! #define FAST_PODULE_BASE	0xf6340000
! #define MEDIUM_PODULE_BASE	0xf60c0000
! #define SLOW_PODULE_BASE	0xf6040000
  =

  #define PODULE_GAP		0x00020000
  #define MAX_PODULES		8
  =

! #define NETSLOT_BASE		0xf622b000
  #define MAX_NETSLOTS		1
  =

  /* End of io.h */
--- 98,114 ----
  =

  #define SIMPLE_PODULE_SIZE	0x00004000
  =

! #define MOD_PODULE_BASE		(IO_CONF_BASE + 0x200000)
! #define SYNC_PODULE_BASE	(IO_CONF_BASE + 0x3c0000)
  #define SYNC_PODULE_HW_BASE	0x033c0000
! #define FAST_PODULE_BASE	(IO_CONF_BASE + 0x340000)
! #define MEDIUM_PODULE_BASE	(IO_CONF_BASE + 0x0c0000)
! #define SLOW_PODULE_BASE	(IO_CONF_BASE + 0x040000)
  =

  #define PODULE_GAP		0x00020000
  #define MAX_PODULES		8
  =

! #define NETSLOT_BASE		(IO_CONF_BASE + 0x22b000)
  #define MAX_NETSLOTS		1
  =

  /* End of io.h */
Index: include/vidc.h
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /overflow/cvsrep/netbsd/sys/arch/arm32/include/vidc.h,v
retrieving revision 1.1.1.3
diff -c -r1.1.1.3 vidc.h
*** include/vidc.h	1999/06/07 20:07:10	1.1.1.3
--- include/vidc.h	2001/01/19 19:33:45
***************
*** 63,69 ****
  =

  #define VIDC_HW_BASE 0x03400000
  =

! #define VIDC_BASE    0xf6100000
  =

  /* Video registers */
  =

--- 63,69 ----
  =

  #define VIDC_HW_BASE 0x03400000
  =

! #define VIDC_BASE    0xf7100000
  =

  /* Video registers */
  =

***************
*** 155,161 ****
  =

  /* Where the display memory is mapped */
  =

! #define VMEM_VBASE 0xf4000000
  =

  /* Where the VRAM will be found */
  =

--- 155,161 ----
  =

  /* Where the display memory is mapped */
  =

! #define VMEM_VBASE 0xf7400000
  =

  /* Where the VRAM will be found */
  =


--==_Exmh_-20608819230--