1 <!-- Copyright (C) 2003 Red Hat, Inc. -->
2 <!-- This material may be distributed only subject to the terms -->
3 <!-- and conditions set forth in the Open Publication License, v1.0 -->
4 <!-- or later (the latest version is presently available at -->
5 <!-- http://www.opencontent.org/openpub/). -->
6 <!-- Distribution of the work or derivative of the work in any -->
7 <!-- standard (paper) book form is prohibited unless prior -->
8 <!-- permission is obtained from the copyright holder. -->
12 >Platform HAL Porting</TITLE
13 ><meta name="MSSmartTagsPreventParsing" content="TRUE">
16 CONTENT="Modular DocBook HTML Stylesheet Version 1.76b+
19 TITLE="eCos Reference Manual"
20 HREF="ecos-ref.html"><LINK
22 TITLE=" Porting Guide"
23 HREF="hal-porting-guide.html"><LINK
25 TITLE="HAL Coding Conventions"
26 HREF="hal-porting-coding-conventions.html"><LINK
28 TITLE="Variant HAL Porting"
29 HREF="hal-porting-variant.html"></HEAD
40 SUMMARY="Header navigation table"
49 >eCos Reference Manual</TH
57 HREF="hal-porting-coding-conventions.html"
65 >Chapter 11. Porting Guide</TD
71 HREF="hal-porting-variant.html"
85 NAME="HAL-PORTING-PLATFORM">Platform HAL Porting</H1
87 >This is the type of port that takes the least effort. It basically
88 consists of describing the platform (board) for the HAL: memory
89 layout, early platform initialization, interrupt controllers, and a
90 simple serial device driver.</P
92 >Doing a platform port requires a preexisting architecture and
93 possibly a variant HAL port.</P
99 NAME="AEN9415">HAL Platform Porting Process</H2
105 NAME="AEN9417">Brief overview</H3
107 >The easiest way to make a new platform HAL is simply to copy an
108 existing platform HAL of the same architecture/variant and change all
109 the files to match the new one. In case this is the first platform for
110 the architecture/variant, a platform HAL from another architecture
111 should be used as a template.</P
113 >The best way to start a platform port is to concentrate on getting
114 RedBoot to run. RedBoot is a simpler environment than full eCos, it
115 does not use interrupts or threads, but covers most of the
116 basic startup requirements.</P
118 >RedBoot normally runs out of FLASH or ROM and provides program loading
119 and debugging facilities. This allows further HAL development to
120 happen using RAM startup configurations, which is desirable for the
121 simple reason that downloading an image which you need to test is
122 often many times faster than either updating a flash part, or indeed,
123 erasing and reprogramming an EPROM.</P
125 >There are two approaches to getting to this first goal:</P
132 >The board is equipped with a ROM monitor which allows "load and go" of
133 ELF, binary, S-record or some other image type which can be created
137 >. This allows you to develop
138 RedBoot by downloading and running the code (saving time).</P
140 >When the stub is running it is a good idea to examine the various
141 hardware registers to help you write the platform initialization code.</P
143 >Then you may have to fiddle a bit going through step two (getting it
144 to run from ROM startup). If at all possible, preserve the original
145 ROM monitor so you can revert to it if necessary.</P
149 >The board has no ROM monitor. You need to get the platform
150 initialization and stub working by repeatedly making changes, updating
151 flash or EPROM and testing the changes. If you are lucky, you have a
152 JTAG or similar CPU debugger to help you. If not, you will probably
153 learn to appreciate LEDs. This approach may also be needed during the
154 initial phase of moving RedBoot from RAM startup to ROM, since it is
155 very unlikely to work first time.</P
164 NAME="AEN9431">Step-by-step</H3
166 >Given that no two platforms are exactly the same, you may have to
167 deviate from the below. Also, you should expect a fair amount of
168 fiddling - things almost never go right the first time. See the hints
169 section below for some suggestions that might help debugging.</P
171 >The description below is based on the HAL layout used in the MIPS,
172 PC and MN10300 HALs. Eventually all HALs should be converted to look like
173 these - but in a transition period there will be other HALs which look
174 substantially different. Please try to adhere to the following as much is
175 possible without causing yourself too much grief integrating with a
176 HAL which does not follow this layout.</P
182 NAME="AEN9435">Minimal requirements</H4
184 >These are the changes you must make before you attempt to build
185 RedBoot. You are advised to read all the sources though.</P
192 >Copy an existing platform HAL from the same or another
193 architecture. Rename the files as necessary to follow the
194 standard: CDL and MLT related files should contain the
195 <arch>_<variant>_<platform> triplet.</P
199 >Adjust CDL options. Primarily option naming, real-time
200 clock/counter, and CYGHWR_MEMORY_LAYOUT variables, but also other
201 options may need editing. Look through the architecture/variant
202 CDL files to see if there are any requirements/features which
203 where not used on the platform you copied. If so, add appropriate
205 HREF="hal-porting-platform.html#HAL-PORTING-CDL-REQUIREMENTS"
206 >the Section called <I
214 >Add the necessary packages and target descriptions to the
219 HREF="hal-porting-platform.html#HAL-PORTING-ECOS-DATABASE"
220 >the Section called <I
223 >. Initially, the target entry
224 should only contain the HAL packages. Other hardware support
225 packages will be added later.</P
229 >Adjust the MLT files in
233 > to match the memory layout on
234 the platform. For initial testing it should be enough to just hand
235 edit .h and .ldi files, but eventually you should generate all
236 files using the memory layout editor in the configuration
238 HREF="hal-porting-platform.html#HAL-PORTING-PLATFORM-MEMORY-LAYOUT"
239 >the Section called <I
240 >Platform Memory Layout</I
249 >misc/redboot_<STARTUP>.ecm</TT
251 the startup type you have chosen to begin with. Rename any
252 platform specific options and remove any that do not apply. In the
255 >cdl_configuration</TT
256 > section, comment out any
257 extra packages that are added, particularly packages such as
264 >CYGPKG_IO_ETH_DRIVERS</TT
265 >. These are not needed for
266 initial porting and will be added back later.
271 >If the default IO macros are not correct, override them in
272 plf_io.h. This may be necessary if the platform uses a different
273 endianness from the default for the CPU.</P
277 >Leave out/comment out code that enables caches and/or MMU if
278 possible. Execution speed will not be a concern until the port is
283 >Implement a simple serial driver (polled mode only). Make sure the
284 initialization function properly hooks the procedures up in the
285 virtual vector IO channel tables. RedBoot will call the serial
286 driver via these tables.</P
288 > By copying an existing platform HAL most of this code will be
289 already done, and will only need the platform specific hardware
290 access code to be written.
295 >Adjust/implement necessary platform
296 initialization. This can be found in
307 >hal_platform_setup.h</TT
311 ><platform>_misc.c</TT
315 ><platform>.S</TT
317 postponed if you are doing a RAM startup RedBoot first and the
318 existing ROM monitor handles board initialization.</P
324 >HAL_STUB_PLATFORM_RESET</TT
326 (optionally empty) and
329 >HAL_STUB_PLATFORM_RESET_ENTRY</TT
331 can reset-on-detach - this is very handy, often removing the need
332 for physically resetting the board between downloads.</P
336 >You should now be able to build RedBoot. For ROM startup:</P
344 CLASS="PROGRAMLISTING"
345 >% ecosconfig new <target_name> redboot
346 % ecosconfig import $(ECOS_REPOSITORY)/hal/<architecture>/<platform>/<version>/misc/redboot_ROM.ecm
353 >You may have to make further changes than suggested above to get
354 the make command to succeed. But when it does, you should find a
355 RedBoot image in install/bin. To program this image into flash or
356 EPROM, you may need to convert to some other file type, and possibly
357 adjust the start address. When you have the correct
361 > command to do this, add it to the
364 >CYGBLD_BUILD_GDB_STUBS</TT
365 > custom build rule in the
366 platform CDL file.</P
368 >Having updated the flash/EPROM on the board, you should see output
369 on the serial port looking like this when powering on the board:</P
377 CLASS="PROGRAMLISTING"
378 >RedBoot(tm) bootstrap and debug environment [ROMRAM]
379 Non-certified release, version UNKNOWN - built 15:42:24, Mar 14 2002
381 Platform: <PLATFORM> (<ARCHITECTURE> <VARIANT>)
382 Copyright (C) 2000, 2001, 2002, Red Hat, Inc.
384 RAM: 0x00000000-0x01000000, 0x000293e8-0x00ed1000 available
385 FLASH: 0x24000000 - 0x26000000, 256 blocks of 0x00020000 bytes each.
391 >If you do not see this output, you need to go through all your
392 changes and figure out what's wrong. If there's a user programmable
393 LED or LCD on the board it may help you figure out how far RedBoot
394 gets before it hangs. Unfortunately there's no good way to describe
395 what to do in this situation - other than that you have to play with
396 the code and the board.</P
403 NAME="AEN9484">Adding features</H4
405 >Now you should have a basic RedBoot running on the board. This
406 means you have a the correct board initialization and a working serial
407 driver. It's time to flesh out the remaining HAL features.</P
414 >Reset. As mentioned above it is desirable to get the board to
415 reset when GDB disconnects. When GDB disconnects it sends RedBoot
416 a kill-packet, and RedBoot first calls <TT
418 >HAL_STUB_PLATFORM_RESET()</TT
420 attempting to perform a software-invoked reset. Most embedded
421 CPUs/boards have a watchdog which is capable of triggering a reset.
422 If your target does not have a watchdog, leave
425 >HAL_STUB_PLATFORM_RESET()</TT
426 > empty and rely on the fallback approach.</P
430 >HAL_STUB_PLATFORM_RESET()</TT
431 > did not cause a reset, RedBoot will
434 >HAL_STUB_PLATFORM_RESET_ENTRY</TT
435 > - this should be the address
436 where the CPU will start execution after a reset. Re-initializing the
437 board and drivers will <SPAN
443 > be good enough to make a
444 hardware reset unnecessary.</P
446 >After the reset caused by the kill-packet, the target will be ready
447 for GDB to connect again. During a days work, this will save you from
448 pressing the reset button many times.</P
450 >Note that it is possible to disconnect from the board without
451 causing it to reset by using the GDB command "detach".</P
455 >Single-stepping is necessary for both instruction-level debugging
456 and for breakpoint support. Single-stepping support should already be
457 in place as part of the architecture/variant HAL, but you want to give
458 it a quick test since you will come to rely on it.</P
462 >Real-time clock interrupts drive the eCos scheduler clock. Many
463 embedded CPUs have an on-core timer (e.g. SH) or decrementer
464 (e.g. MIPS, PPC) that can be used, and in this case it will already be
465 supported by the architecture/variant HAL. You only have to calculate
466 and enter the proper <TT
468 >CYGNUM_HAL_RTC_CONSTANTS</TT
470 definitions in the platform CDL file.</P
472 >On some targets it may be necessary to use a platform-specific
473 timer source for driving the real-time clock. In this case you also
474 have to enter the proper CDL definitions, but must also define
475 suitable versions of the <TT
482 >Interrupt decoding usually differs between platforms because the
483 number and type of devices on the board differ. In
490 >hal_platform_ints.h</TT
491 >) you must either extend or
492 replace the default vector definitions provided by the architecture
493 or variant interrupt headers. You may also have to define
496 >HAL_INTERRUPT_XXXX</TT
501 >Caching may also differ from architecture/variant definitions.
502 This maybe just the cache sizes, but there can also be bigger
503 differences for example if the platform supports 2nd level caches.</P
505 >When cache definitions are in place, enable the caches on
506 startup. First verify that the system is stable for RAM startups, then
507 build a new RedBoot and install it. This will test if caching, and in
508 particular the cache sync/flush operations, also work for ROM startup.</P
512 >Asynchronous breakpoints allow you to stop application execution
513 and enter the debugger. Asynchronous breakpoint details are described
518 >You should now have a completed platform HAL port. Verify its
519 stability and completeness by running all the eCos tests and fix any
520 problems that show up (you have a working RedBoot now, remember! That
521 means you can debug the code to see why it fails).</P
523 >Given the many configuration options in eCos, there may be hidden
524 bugs or missing features that do not show up even if you run all the
525 tests successfully with a default configuration. A comprehensive test
526 of the entire system will take many configuration permutations and
527 many many thousands of tests executed.</P
535 NAME="AEN9517">Hints</H3
541 >JTAG or similar CPU debugging hardware can greatly reduce the time
542 it takes to write a HAL port since you always have full visibility
543 of what the CPU is doing.
548 >LEDs can be your friends if you don't have a JTAG
549 device. Especially in the start of the porting effort if you don't
550 already have a working ROM monitor on the target. Then you have to
551 get a basic RedBoot working while basically being blindfolded. The
552 LED can make it little easier, as you'll be able to do limited
553 tracking of program flow and behavior by switching the LED on and
554 off. If the board has multiple LEDs you can show a number (using
555 binary notation with the LEDs) and sprinkle code which sets
556 different numbers throughout the code.</P
560 >Debugging the interrupt processing is possible if you are
561 careful with the way you program the very early interrupt entry
562 handling. Write it so that as soon as possible in the interrupt
563 path, taking a trap (exception) does not harm execution. See the
564 SH vectors.S code for an example. Look for
567 >cyg_hal_default_interrupt_vsr</TT
571 >cyg_hal_default_interrupt_vsr_bp_safe</TT
573 marks the point after which traps/single-stepping is safe.
576 >Being able to display memory content, CPU registers,
577 interrupt controller details at the time of an interrupt can save
582 >Using assertions is a good idea. They can sometimes reveal subtle
583 bugs or missing features long before you would otherwise have
584 found them, let alone notice them.
587 >The default eCos configuration does not use assertions, so you
588 have to enable them by switching on the option <TT
590 >CYGPKG_INFRA_DEBUG</TT
592 in the infra package.</P
596 >The idle loop can be used to help debug the system.
599 >Triggering clock from the idle loop is a neat trick for
600 examining system behavior either before interrupts are fully
601 working, or to speed up "the clock".
604 >Use the idle loop to monitor and/or print out variables or
605 hardware registers.</P
612 > is used in some of the
613 HALs (ARM, SH) as a way to generate assembler symbol definitions from
614 C header files without imposing an assembler/C syntax separation in
615 the C header files.</P
625 NAME="HAL-PORTING-CDL-REQUIREMENTS">HAL Platform CDL</H2
627 >The platform CDL both contains details necessary for the building
628 of eCos, and platform-specific configuration options. For this reason
629 the options differ between platforms, and the below is just a brief
630 description of the most common options.</P
632 > See Components Writers Guide
633 for more details on CDL. Also have a quick look around in
634 existing platform CDL files to get an idea of what is possible and how
635 various configuration issues can be represented with CDL.</P
641 NAME="HAL-PORTING-ECOS-DATABASE">eCos Database</H3
643 >The eCos configuration system is made aware of a package by
644 adding a package description in <TT
648 example we use the <TT
659 CLASS="PROGRAMLISTING"
660 >package CYGPKG_HAL_MIPS_TX39_JMR3904 {
661 alias { "Toshiba JMR-TX3904 board" hal_tx39_jmr3904 tx39_jmr3904_hal }
662 directory hal/mips/jmr3904
663 script hal_mips_tx39_jmr3904.cdl
666 The JMR3904 HAL package should be used when targeting the
667 actual hardware. The same package can also be used when
668 running on the full simulator, since this provides an
669 accurate simulation of the hardware including I/O devices.
670 To use the simulator in this mode the command
671 `target sim --board=jmr3904' should be used from inside gdb."
677 >This contains the title and description presented in the
678 Configuration Tool when the package is selected. It also specifies
679 where in the tree the package files can be found (<TT
683 and the name of the CDL file which contains the package details
689 >To be able to build and test a configuration for the new target, there
690 also needs to be a <TT
705 CLASS="PROGRAMLISTING"
707 alias { "Toshiba JMR-TX3904 board" jmr tx39 }
708 packages { CYGPKG_HAL_MIPS
710 CYGPKG_HAL_MIPS_TX39_JMR3904
713 The jmr3904 target provides the packages needed to run
714 eCos on a Toshiba JMR-TX3904 board. This target can also
715 be used when running in the full simulator, since the simulator provides an
716 accurate simulation of the hardware including I/O devices.
717 To use the simulator in this mode the command
718 `target sim --board=jmr3904' should be used from inside gdb."
724 >The important part here is the <TT
728 which defines the various hardware specific packages that contribute
729 to support for this target. In this case the MIPS architecture
730 package, the TX39 variant package, and the JMR-TX3904 platform
731 packages are selected. Other packages, for serial drivers, ethernet
732 drivers and FLASH memory drivers may also appear here.</P
739 NAME="AEN9559">CDL File Layout</H3
741 >All the platform options are contained in a CDL package named
744 >CYGPKG_HAL_<architecture>_<variant>_<platform></TT
746 They all share more or less the same <TT
758 CLASS="PROGRAMLISTING"
759 >cdl_package CYGPKG_HAL_MIPS_TX39_JMR3904 {
760 display "JMR3904 evaluation board"
761 parent CYGPKG_HAL_MIPS
762 requires CYGPKG_HAL_MIPS_TX39
763 define_header hal_mips_tx39_jmr3904.h
766 The JMR3904 HAL package should be used when targeting the
767 actual hardware. The same package can also be used when
768 running on the full simulator, since this provides an
769 accurate simulation of the hardware including I/O devices.
770 To use the simulator in this mode the command
771 `target sim --board=jmr3904' should be used from inside gdb."
773 compile platform.S plf_misc.c plf_stub.c
776 puts $::cdl_system_header "#define CYGBLD_HAL_TARGET_H <pkgconf/hal_mips_tx39.h>"
777 puts $::cdl_system_header "#define CYGBLD_HAL_PLATFORM_H <pkgconf/hal_mips_tx39_jmr3904.h>"
786 >This specifies that the platform package should be parented under
787 the MIPS packages, requires the TX39 variant HAL and all configuration
788 settings should be saved in
791 >cyg/hal/hal_mips_tx39_jmt3904.h</TT
797 > line specifies which files should be built
798 when this package is enabled, and the <TT
802 some macros that are used to access the variant or architecture (the
806 > name is a bit of a misnomer) and platform
807 configuration options. </P
814 NAME="AEN9571">Startup Type</H3
816 >eCos uses an option to select between a set of valid startup
817 configurations. These are normally RAM, ROM and possibly ROMRAM. This
818 setting is used to select which linker map to use (i.e., where to link
819 eCos and the application in the memory space), and how the startup
820 code should behave.</P
828 CLASS="PROGRAMLISTING"
829 >cdl_component CYG_HAL_STARTUP {
830 display "Startup type"
832 legal_values {"RAM" "ROM"}
833 default_value {"RAM"}
835 define -file system.h CYG_HAL_STARTUP
837 When targeting the JMR3904 board it is possible to build
838 the system for either RAM bootstrap, ROM bootstrap, or STUB
839 bootstrap. RAM bootstrap generally requires that the board
840 is equipped with ROMs containing a suitable ROM monitor or
841 equivalent software that allows GDB to download the eCos
842 application on to the board. The ROM bootstrap typically
843 requires that the eCos application be blown into EPROMs or
844 equivalent technology."
857 pair is used to make the setting of this option appear in the file
861 > instead of the default specified in the
869 NAME="AEN9579">Build options</H3
871 >A set of options under the components
874 >CYGBLD_GLOBAL_OPTIONS</TT
878 >CYGHWR_MEMORY_LAYOUT</TT
879 > specify how eCos should be
880 built: what tools and compiler options should be used, and which
881 linker fragments should be used.</P
889 CLASS="PROGRAMLISTING"
890 > cdl_component CYGBLD_GLOBAL_OPTIONS {
891 display "Global build options"
895 Global build options including control over
896 compiler flags, linker flags and choice of toolchain."
899 cdl_option CYGBLD_GLOBAL_COMMAND_PREFIX {
900 display "Global command prefix"
903 default_value { "mips-tx39-elf" }
905 This option specifies the command prefix used when
906 invoking the build tools."
909 cdl_option CYGBLD_GLOBAL_CFLAGS {
910 display "Global compiler flags"
913 default_value { "-Wall -Wpointer-arith -Wstrict-prototypes -Winline -Wundef -Woverloaded-virtual -g -O2 -ffunction-sections -fdata-sections -fno-rtti -fno-exceptions -fvtable-gc -finit-priority" }
915 This option controls the global compiler flags which
916 are used to compile all packages by
917 default. Individual packages may define
918 options which override these global flags."
921 cdl_option CYGBLD_GLOBAL_LDFLAGS {
922 display "Global linker flags"
925 default_value { "-g -nostdlib -Wl,--gc-sections -Wl,-static" }
927 This option controls the global linker flags. Individual
928 packages may define options which override these global flags."
932 cdl_component CYGHWR_MEMORY_LAYOUT {
933 display "Memory layout"
936 calculated { CYG_HAL_STARTUP == "RAM" ? "mips_tx39_jmr3904_ram" : \
937 "mips_tx39_jmr3904_rom" }
939 cdl_option CYGHWR_MEMORY_LAYOUT_LDI {
940 display "Memory layout linker script fragment"
943 define -file system.h CYGHWR_MEMORY_LAYOUT_LDI
944 calculated { CYG_HAL_STARTUP == "RAM" ? "<pkgconf/mlt_mips_tx39_jmr3904_ram.ldi>" : \
945 "<pkgconf/mlt_mips_tx39_jmr3904_rom.ldi>" }
948 cdl_option CYGHWR_MEMORY_LAYOUT_H {
949 display "Memory layout header file"
952 define -file system.h CYGHWR_MEMORY_LAYOUT_H
953 calculated { CYG_HAL_STARTUP == "RAM" ? "<pkgconf/mlt_mips_tx39_jmr3904_ram.h>" : \
954 "<pkgconf/mlt_mips_tx39_jmr3904_rom.h>" }
966 NAME="AEN9585">Common Target Options</H3
968 >All platforms also specify real-time clock details:</P
976 CLASS="PROGRAMLISTING"
977 ># Real-time clock/counter specifics
978 cdl_component CYGNUM_HAL_RTC_CONSTANTS {
979 display "Real-time clock constants."
982 cdl_option CYGNUM_HAL_RTC_NUMERATOR {
983 display "Real-time clock numerator"
985 calculated 1000000000
987 cdl_option CYGNUM_HAL_RTC_DENOMINATOR {
988 display "Real-time clock denominator"
992 # Isn't a nice way to handle freq requirement!
993 cdl_option CYGNUM_HAL_RTC_PERIOD {
994 display "Real-time clock period"
996 legal_values { 15360 20736 }
997 calculated { CYGHWR_HAL_MIPS_CPU_FREQ == 50 ? 15360 : \
998 CYGHWR_HAL_MIPS_CPU_FREQ == 66 ? 20736 : 0 }
1012 > gives the number of nanoseconds per
1016 > is the divider to be programmed
1017 into a hardware timer that is driven from an appropriate hardware
1018 clock, such that the timer overflows once per tick (normally
1019 generating a CPU interrupt to mark the end of a tick). The tick
1020 default rate is typically 100Hz.</P
1022 >Platforms that make use of the virtual vector
1023 ROM calling interface (see <A
1024 HREF="hal-calling-if.html"
1025 >the Section called <I
1026 >Virtual Vectors (eCos/ROM Monitor Calling Interface)</I
1029 specify details necessary to define configuration channels (these
1030 options are from the SH/EDK7707 HAL) :</P
1038 CLASS="PROGRAMLISTING"
1039 >cdl_option CYGNUM_HAL_VIRTUAL_VECTOR_COMM_CHANNELS {
1040 display "Number of communication channels on the board"
1045 cdl_option CYGNUM_HAL_VIRTUAL_VECTOR_DEBUG_CHANNEL {
1046 display "Debug serial port"
1048 legal_values 0 to CYGNUM_HAL_VIRTUAL_VECTOR_COMM_CHANNELS-1
1051 The EDK/7708 board has only one serial port. This option
1052 chooses which port will be used to connect to a host
1056 cdl_option CYGNUM_HAL_VIRTUAL_VECTOR_CONSOLE_CHANNEL {
1057 display "Diagnostic serial port"
1059 legal_values 0 to CYGNUM_HAL_VIRTUAL_VECTOR_COMM_CHANNELS-1
1062 The EDK/7708 board has only one serial port. This option
1063 chooses which port will be used for diagnostic output."
1069 >The platform usually also specify an option controlling the ability
1070 to co-exist with a ROM monitor:</P
1078 CLASS="PROGRAMLISTING"
1079 >cdl_option CYGSEM_HAL_USE_ROM_MONITOR {
1080 display "Work with a ROM monitor"
1082 legal_values { "Generic" "CygMon" "GDB_stubs" }
1083 default_value { CYG_HAL_STARTUP == "RAM" ? "CygMon" : 0 }
1084 parent CYGPKG_HAL_ROM_MONITOR
1085 requires { CYG_HAL_STARTUP == "RAM" }
1087 Support can be enabled for three different varieties of ROM monitor.
1088 This support changes various eCos semantics such as the encoding
1089 of diagnostic output, or the overriding of hardware interrupt
1091 Firstly there is \"Generic\" support which prevents the HAL
1092 from overriding the hardware vectors that it does not use, to
1093 instead allow an installed ROM monitor to handle them. This is
1094 the most basic support which is likely to be common to most
1095 implementations of ROM monitor.
1096 \"CygMon\" provides support for the Cygnus ROM Monitor.
1097 And finally, \"GDB_stubs\" provides support when GDB stubs are
1098 included in the ROM monitor or boot ROM."
1104 >Or the ability to be configured as a ROM monitor:</P
1112 CLASS="PROGRAMLISTING"
1113 >cdl_option CYGSEM_HAL_ROM_MONITOR {
1114 display "Behave as a ROM monitor"
1117 parent CYGPKG_HAL_ROM_MONITOR
1118 requires { CYG_HAL_STARTUP == "ROM" }
1120 Enable this option if this program is to be used as a ROM monitor,
1121 i.e. applications will be loaded into RAM on the board, and this
1122 ROM monitor may process exceptions or interrupts generated from the
1123 application. This enables features such as utilizing a separate
1124 interrupt stack when exceptions are generated."
1130 >The latter option is accompanied by a special build rule that
1131 extends the generic ROM monitor build rule in the common HAL:</P
1139 CLASS="PROGRAMLISTING"
1140 >cdl_option CYGBLD_BUILD_GDB_STUBS {
1141 display "Build GDB stub ROM image"
1143 requires { CYG_HAL_STARTUP == "ROM" }
1144 requires CYGSEM_HAL_ROM_MONITOR
1145 requires CYGBLD_BUILD_COMMON_GDB_STUBS
1146 requires CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS
1147 requires ! CYGDBG_HAL_DEBUG_GDB_BREAK_SUPPORT
1148 requires ! CYGDBG_HAL_DEBUG_GDB_THREAD_SUPPORT
1149 requires ! CYGDBG_HAL_COMMON_INTERRUPTS_SAVE_MINIMUM_CONTEXT
1150 requires ! CYGDBG_HAL_COMMON_CONTEXT_SAVE_MINIMUM
1153 This option enables the building of the GDB stubs for the
1154 board. The common HAL controls takes care of most of the
1155 build process, but the final conversion from ELF image to
1156 binary data is handled by the platform CDL, allowing
1157 relocation of the data if necessary."
1159 make -priority 320 {
1160 <PREFIX>/bin/gdb_module.bin : <PREFIX>/bin/gdb_module.img
1161 $(OBJCOPY) -O binary $< $@
1168 >Most platforms support RedBoot, and some options are needed to
1169 configure for RedBoot.</P
1177 CLASS="PROGRAMLISTING"
1178 > cdl_component CYGPKG_REDBOOT_HAL_OPTIONS {
1179 display "Redboot HAL options"
1182 parent CYGPKG_REDBOOT
1183 active_if CYGPKG_REDBOOT
1185 This option lists the target's requirements for a valid Redboot
1188 cdl_option CYGBLD_BUILD_REDBOOT_BIN {
1189 display "Build Redboot ROM binary image"
1190 active_if CYGBLD_BUILD_REDBOOT
1193 description "This option enables the conversion of the Redboot ELF
1194 image to a binary image suitable for ROM programming."
1196 make -priority 325 {
1197 <PREFIX>/bin/redboot.bin : <PREFIX>/bin/redboot.elf
1198 $(OBJCOPY) --strip-debug $< $(@:.bin=.img)
1199 $(OBJCOPY) -O srec $< $(@:.bin=.srec)
1200 $(OBJCOPY) -O binary $< $@
1208 >The important part here is the <TT
1214 >CYGBLD_BUILD_REDBOOT_BIN</TT
1215 > option which emits
1216 makefile commands to translate the <TT
1220 generated by the link phase into both a binary file and an S-Record
1221 file. If a different format is required by a PROM programmer or ROM
1222 monitor, then different output formats would need to be generated here.</P
1230 NAME="HAL-PORTING-PLATFORM-MEMORY-LAYOUT">Platform Memory Layout</H2
1232 >The platform memory layout is defined using the Memory
1233 Configuration Window in the Configuration Tool.</P
1241 >If you do not have access to a Windows machine, you can
1248 > files to match the
1249 properties of your platform. If you want to contribute your port back
1250 to the eCos community, ask someone on the list to make proper memory
1251 map files for you.</P
1259 NAME="AEN9615">Layout Files</H3
1261 >The memory configuration details are saved in three files:</P
1265 CLASS="VARIABLELIST"
1274 >This is the Configuration Tool save-file. It is only used
1275 by the Configuration Tool.</P
1284 >This is the linker script fragment. It defines the memory
1285 and location of sections by way of macros defined in the
1286 architecture or variant linker script.</P
1295 >This file describes some of the memory region details as C
1296 macros, allowing eCos or the application adapt the memory
1297 layout of a specific configuration.</P
1302 >These three files are generated for each startup-type, since the
1303 memory details usually differ.</P
1310 NAME="AEN9635">Reserved Regions</H3
1312 >Some areas of the memory space are reserved for specific
1313 purposes, making room for exception vectors and various tables. RAM
1314 startup configurations also need to reserve some space at the bottom
1315 of the memory map for the ROM monitor.</P
1317 >These reserved areas are named with the prefix "reserved_" which is
1318 handled specially by the Configuration Tool: instead of referring to a
1319 linker macro, the start of the area is labeled and a gap left in the
1328 NAME="AEN9639">Platform Serial Device Support</H2
1330 >The first step is to set up the CDL definitions. The configuration
1331 options that need to be set are the following:</P
1335 CLASS="VARIABLELIST"
1340 >CYGNUM_HAL_VIRTUAL_VECTOR_COMM_CHANNELS</TT
1344 >The number of channels, usually 0, 1 or 2.</P
1349 >CYGNUM_HAL_VIRTUAL_VECTOR_DEBUG_CHANNEL</TT
1353 >The channel to use for GDB.</P
1358 >CYGNUM_HAL_VIRTUAL_VECTOR_DEBUG_CHANNEL_BAUD</TT
1362 >Initial baud rate for debug channel.</P
1367 >CYGNUM_HAL_VIRTUAL_VECTOR_CONSOLE_CHANNEL</TT
1371 >The channel to use for the
1377 >CYGNUM_HAL_VIRTUAL_VECTOR_CONSOLE_CHANNEL_BAUD</TT
1381 >The initial baud rate for the console
1387 >CYGNUM_HAL_VIRTUAL_VECTOR_CONSOLE_CHANNEL_DEFAULT</TT
1391 >The default console channel.</P
1399 > need to be converted to
1400 support the new serial device.
1401 If this the same as a device already supported, copy that.</P
1403 >The following functions and types need to be rewritten to support a new serial
1408 CLASS="VARIABLELIST"
1413 >struct channel_data_t;</TT
1417 > Structure containing base address, timeout and ISR vector number
1418 for each serial device supported. Extra fields my be added if
1419 necessary for the device. For example some devices have
1420 write-only control registers, so keeping a shadow of the last
1421 value written here can be useful.
1427 >xxxx_ser_channels[];</TT
1434 >, initialized with parameters of each
1435 channel. The index into this array is the channel number used
1436 in the CDL options above and is used by the virtual vector
1437 mechanism to refer to each channel.
1443 >void cyg_hal_plf_serial_init_channel(void
1448 > Initialize the serial device. The parameter is actually a pointer to a
1452 > and should be cast back to
1453 this type before use. This function should use the CDL
1454 definition for the baud rate for the channel it is initializing.
1460 >void cyg_hal_plf_serial_putc(void * __ch_data,
1465 > Send a character to the serial device. This function should
1466 poll for the device being ready to send and then write the character.
1467 Since this is intended to be a diagnostic/debug channel, it is
1468 often also a good idea to poll for end of transmission
1469 too. This ensures that as much data gets out of the system as
1476 >bool cyg_hal_plf_serial_getc_nonblock(void*
1477 __ch_data, cyg_uint8* ch)</TT
1481 > This function tests the device and if a character is
1482 available, places it in <TT
1491 >. If no character is available, then
1492 the function returns <TT
1501 >int cyg_hal_plf_serial_control(void *__ch_data,
1502 __comm_control_cmd_t __func,
1507 > This is an IOCTL-like function for controlling various aspects
1508 of the serial device. The only part in which you may need to
1509 do some work initially is in the
1512 >__COMMCTL_IRQ_ENABLE</TT
1516 >__COMMCTL_IRQ_DISABLE</TT
1518 enable/disable interrupts.
1524 >int cyg_hal_plf_serial_isr(void *__ch_data, int* __ctrlc,
1525 CYG_ADDRWORD __vector, CYG_ADDRWORD
1530 > This interrupt handler, called from the spurious interrupt
1531 vector, is specifically for dealing with
1535 > interrupts from GDB. When called
1536 this function should do the following:
1543 >Check for an incoming character. The code here is very
1547 >cyg_hal_plf_serial_getc_nonblock()</TT
1553 > Read the character and call
1556 >cyg_hal_is_break()</TT
1562 > If result is true, set <TT
1578 >CYG_ISR_HANDLED</TT
1589 >void cyg_hal_plf_serial_init()</TT
1593 > Initialize each of the serial channels.
1596 >cyg_hal_plf_serial_init_channel()</TT
1600 >CYGACC_COMM_IF_*</TT
1602 each channel. This latter set of calls are identical for all
1603 channels, so the best way to do this is to copy and edit an
1616 SUMMARY="Footer navigation table"
1627 HREF="hal-porting-coding-conventions.html"
1636 HREF="ecos-ref.html"
1645 HREF="hal-porting-variant.html"
1655 >HAL Coding Conventions</TD
1661 HREF="hal-porting-guide.html"
1669 >Variant HAL Porting</TD