Services and Modeling for Embedded Software Development
Embecosm divider strip
Prev  Next

3.3.1.  Extending configure.host for a New Target

The configure.host file needs changes in two places, to identify the architecture specific machine directory and the platform directory for BSP implementations.

The machine name is specified in a case switch on the ${host_cpu} early on in the file. Add a new case entry defining machine_type for the architecture. Thus for OpenRISC 1000  32-bit architecture we have:

  or32)
        machine_dir=or32
        ;;
	  

This specifies that the machine specific code for this architecture will be found in the directory newlib/libc/machine/or32.

The platform directory and details are specified in a subsequent case switch on ${host} (i.e. the full triplet, not just the CPU type). For the 32-bit OpenRISC 1000  we have the following.

  or32-*-*)
        syscall_dir=syscalls
        ;;
	  

This is the simplest option, specifying that the BSPs for all OpenRISC 1000  32-bit targets will implement namespace clean system calls, and rely on newlib to map reentrant calls down to them. The directory name for the BSP implementations will match that of the machine directory, but within the libgloss directory. So for OpenRISC 1000  32-bit targets; the BSP implementations are in libgloss/or32.

There are four common alternatives for specifying how the BSP will be implemented.

  1. The implementer defines reentrant namespace clean versions of the system calls. In this case, syscall_dir is set to syscalls as above, but in addition, -DREENTRANT_SYSCALLS_PROVIDED is added to newlib_cflags in configure.host. For the OpenRISC 1000  32-bit target we could have done this with:

      or32-*-*)
            syscall_dir=syscalls
            newlib_cflags="${newlib_cflags} -DREENTRANT_SYSCALLS_PROVIDED"
            ;;
    		

    For convenience, stub versions of the reentrant functions may be found in the libc/reent directory. These are in fact the functions used if the reentrant system calls are not provided, and map to the non-reentrant versions.

  2. The implementer defines non-reentrant, but namespace clean versions of the system calls. This is the approach we have used with the OpenRISC 1000  and all the implementer needs to do in this case is to set syscall_dir to syscalls in configure.host. newlib will map reentrant calls down to the non-reentrant versions.

  3. The implementer defines non-reentrant, regular versions of the system calls (i.e. close rather than _close). The library will be neither reentrant, not namespace clean, but will work. In this case, -DMISSING_SYSCALL_NAMES is added to newlib_cflags in configure.host. For the OpenRISC 1000  we could have done this with:

      or32-*-*)
            newlib_cflags="${newlib_cflags} -DMISSING_SYSCALL_NAMES"
            ;;
    		

    Note in particular that syscall_dir is not defined in this case.

  4. The implementer defines non-reentrant, regular versions of the system calls (i.e. close rather than _close). The reentrant system calls are mapped onto these functions. The library will not be namespace clean, but will offer reentrancy at the library level. In this case, -DMISSING_SYSCALL_NAMES and -DREENTRANT_SYSCALLS_PROVIDED are both added to newlib_cflags in configure.host. For the OpenRISC 1000  we could have done this with:

      or32-*-*)
            newlib_cflags="${newlib_cflags} -DMISSING_SYSCALL_NAMES"
            newlib_cflags="${newlib_cflags} -DREENTRANT_SYSCALLS_PROVIDED"
            ;;
    		

    Note in particular that syscall_dir is not defined in this case.

Embecosm divider strip