Freebsd and Netbsd on APM86290 System on Chip
Total Page:16
File Type:pdf, Size:1020Kb
FreeBSD and NetBSD on APM86290 System on Chip Zbigniew Bodek Semihalf [email protected] Abstract Single chip computers conquered not only the world of mobile devices, but are extensively be- This paper covers recent development ing used in the modern telecommunication sys- work on porting FreeBSD/powerpc and tems as they provide high performance data NetBSD/evbppc to the new APM86290 processing and a large number of capabilities system-on-chip from AppliedMicro. The combined with the low energy consumption and APM86290 is a dual core device compliant reasonable price. PowerPC is a superscalar, with the Book-E definition of the PowerPC RISC-like computer architecture, originally in- architecture, presenting a number of periph- troduced by Apple-IBM-Motorola (AIM) al- erals integrated in a single chip and labour liance. Initially designed for personal comput- efficiency improved by implementation of a ers, it became popular for embedded systems, message passing architecture. servers, super-computers, and gaming. The article focuses on presenting the dif- Fast evolving telecommunication industry ferences and similarities between FreeBSD and demands from the modern chips more and more NetBSD systems in the context of porting them packet processing power, along with the so- to an embedded architecture. The material phisticated capabilities concerning packet clas- briefly describes the influence of the innova- sification, security extensions, and acceleration tive inter-circuit communication architecture, subsystems designed to offload CPUs from the and data flow in the APM86290 chip on de- compute-intensive data servicing. vice drivers development. In particular the pa- per talks about the new architecture’s impact Every processor, even the most sophisti- on the FreeBSD’s and NetBSD’s drivers infras- cated one, is just an empty vessel without an tructure in example of the networking driver. operating system to have control over its func- tionality and behavior. There are a number of Finally, the overall focus of this paper is embedded operating systems available on the to compare FreeBSD’s and NetBSD’s portabil- market. Open source stands as winner among ity on the APM86290 example, to discuss prob- them thanks to its rapid development and relia- lems that may occur, and to compare diagnos- bility. FreeBSD and NetBSD are the two most tic, debugging and development tools that both popular representatives of the Unix-like oper- systems provide. ating systems, providing both: trustworthiness and a friendly BSD licence for computer system 1 Introduction manufacturers. During the past years, embedded sys- System selection is often a difficult chal- tems market has become a significant part of lenge for a developer as there is a vast variety the widely understood computer science area. and availability of operating systems. In the decision, one must take into account the exist- enables a multiple instruction and data address ing support for the target platform or time to breakpoints, data value compare, and single- achieve such support, portability of the soft- step, branch, trap and other debug events. Fi- ware that is going to be used by the client, and nally the PPC465 core implements the full, 32- system’s support for the chip’s extra features. bit fixed-point subset of the Book-E Enhanced PowerPC Architecture. This work describes the process of de- veloping an embedded operating system for a Furthermore, the on-chip processors are new platform - APM86290 from AppliedMicro assisted by a rich set of configurable hardware - in the frame of FreeBSD and NetBSD. The accelerators focused on the packet classifica- challenges of bringing-up drivers for peripherals tion, scheduling, packet/data manipulation and present on a chip and the special care taken over security. the new message passing architecture of net- These include: work controller introduced in the APM86290 are briefly described. Implementation details • Dedicated Ethernet Offload Engine are presented along with challenges and diffi- culties which were encountered during the de- • Queue Manager / Traffic Manager velopment. • Classification Engine Finally, the goal of this paper is to com- pare both systems concerning their portability, 2.1 Ethernet Offload Engine and hence to reveal their time to market capa- Ethernet Offload Engine integrated to the bilities. Differences between bringing-up of ma- APM86290 is capable of doing inline IPSec with jor subsystems are presented for both, FreeBSD greater than 2 Gbps line rate throughput, and and NetBSD operating systems. also provides inline TCP/IP and UDP check- sums calculation. It was designed to meet the 2 Hardware needs of low power all-IP networks. The APM86290 is the first chip from 2.2 Queue Manager / Traffic Manager AppliedMicro that incorporates two high per- formance PowerPC 465 processors in a single Queue Manager / Traffic Manager package. Each of them provides functional el- (QMTM) is an important element of the ements required by the most of modern em- APM86290’s design as it allows the most bedded systems. These functions include mem- efficient moving of data and packets between ory management, floating point unit (FPU), a the processors and integrated peripherals 32KB data and 32KB instruction cache. by using a message passing architecture. Communication interface offloads software The PPC465 processor connects to a from the routing of packets and transaction Level 2 cache through a high-performance Pro- synchronization. It can be therefore used cessor Local Bus 5 (PLB5), which supports to reduce communication overhead between hardware coherency. In addition, the L2 com- software and hardware. plex uses the MESI protocol to maintain mem- ory coherency for pages marked as such. Each 2.3 Classification Engine core has at its disposal a fully associative, 64 entry Translation Look-aside Buffer (TLB). De- Programmable Classification Engine sup- bug facilities that PPC465 provides constitute ports i.a. IPv4, IPv6 and AppleTalk packet an important feature from the software devel- classification, with greater than 2 Gbps line oper’s point of view. Hence, the PPC465 core rate throughput, offloading software from that is equipped with IEEE 1149.1 JTAG port that task. 2 3 Porting was a great start point as the ways of handling the core (which was the older brother of the The process of porting the operating sys- PPC465) were very instructive. In spite of all tem is divided into several stages, in which the the advantages, the forthcoming rebase to the development process is moving from the fulfill- current version was inevitable. ing prerequisites that include the cross-build toolchain and booting environment, through Regarding NetBSD, the baseline for the low-level system bootstrap and up to MMU work was the existing in the NetBSD 5.99 port support, peripheral devices support, execution for the MPC85XX - the PowerQUICC commu- of the userland applications and last but not nication processor from Freescale. Obviously least - stability and performance improvements. there was much more work to be done there because despite similarities, Book-E compati- All of the mentioned stages were elabo- bility, etc. the cores and hence the low-level rated during the work on the APM86290. Most areas of the system, were completely different. of them are presented in this paper, however, more important issues were discussed further at the expense of those less interesting in the 3.2 Cross-building environment context of the whole process. The first step to achieve was to set- Following phases were carefully depicted: up a cross-building environment. Suitable toolchain is an essential part of the develop- • Baseline code selection ment as it is required to generate proper ma- chine code for a target system. Both NetBSD • Cross-build toolchain preparation and FreeBSD sources provide the completely sufficient toolchains and scripts for building • System bootstrap kernel and root file system. The crosscompiling • Early kernel initialization in locore.S environment is required when building code for a target platform of different architecture than • Platform initialization the build host. Host’s operating system is no less important. FreeBSD can be built on the • Low-level memory management support FreeBSD hosts only, but NetBSD is suitable for • Device drivers along with support for building also on a different operating systems chip’s special features like Linux or other BSD thanks to the build.sh script which is attached to the source code. • Testing and debugging This basically consists of: 3.1 Baseline • ppc4xx crosscompiler Development versions of the FreeBSD 9.0 and NetBSD 5.99 have been chosen as a base • assembler for the upcoming ports. The first major de- cision was to choose an existing support for a • linker particular platform on which the development • other utilities will be based. It was reasonable to bounce from as similar platform as possible in order to mini- mize the effort of creating low-level parts of the Fortunately, FreeBSD 9.0 and system from scratch. Considering FreeBSD, the NetBSD 5.99 were equipped with the tools unofficial port for PPC460EX SoC developed mentioned above so that we could move by Semihalf has been chosen as a reference. Al- forward without any additional adjustments to though this port was based on FreeBSD 8.1 it that matter. 3 3.3 System bootstrap action involves creating initial mapping for the kernel text and data, only and therefore it cuts After power-up, the BootROM is off the processor from any of the mappings cre- launched by the processor so it can find and ated by the bootloader and the bootloader itself load the code to the RAM that is to be exe- (it won’t be "visible" in virtual space anymore). cuted. The role of this code, called firmware or first stage bootloader, is to perform early, Low-level initialization for the Book-E ar- low-level initialization of the DDR controller, chitecture compliant processor includes also an clocks, and power domains.