port.ms 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590
  1. .TL
  2. Inferno Ports: Hosted and Native
  3. .AU
  4. Vita Nuova
  5. 27 April 2005
  6. Revised 22 January 2007
  7. .PP
  8. Inferno is a portable environment, encompassing operating system,
  9. languages, virtual machine and the tools required to build it.
  10. This section briefly summarises the state of the ports and compilers
  11. included in this release.
  12. Directory names are relative to the root of the Inferno release tree,
  13. unless otherwise specified by the context.
  14. .PP
  15. All components are built using the program
  16. .CW mk ,
  17. based on `make'-like recipes found in the
  18. .CW mkfile
  19. in each source directory throughout the Inferno tree.
  20. .CW Mk
  21. is described by the manual page
  22. .I mk (10.1)
  23. in Volume 1; a more tutorial discussion, including
  24. a summary of differences with Unix
  25. .I make ,
  26. can be found in
  27. .I "Maintaining Files on Plan 9 with Mk"
  28. by Hume and Flandrena,
  29. reprinted in this volume.
  30. The source for
  31. .CW mk
  32. itself is included in
  33. .CW utils/mk .
  34. It is included ready-made in the full and source-only distributions, to make life easier.
  35. It must be compiled manually only on the initial port to a new host environment;
  36. instructions for that are given below.
  37. .PP
  38. .NH 1
  39. The C compilers
  40. .PP
  41. An unusual property of the compiler suites used to compile native
  42. Inferno is that there is no difference in configuration or content
  43. between a `compiler' (compiling on the same system and processor type as the target)
  44. and a `cross compiler' (compiling on a host that differs from the target),
  45. even when the host operating systems are quite different.
  46. Indeed, in their ancestral home, Plan 9, it is the default action to compile
  47. instances of all compilers for all possible target architectures,
  48. as a matter of course.
  49. .PP
  50. The main difference between this suite and the original Plan 9 suite is
  51. that all Plan 9 C extensions have been eliminated from the compiler's own source,
  52. allowing it to be compiled on environments that accurately support
  53. ANSI C and a few necessary Posix functions.
  54. .PP
  55. The source for the compilers is found in subdirectories of
  56. .CW utils .
  57. The compilers are named as follows:
  58. .RS
  59. .IP \f50c\fP 8
  60. MIPS compiler for 64-bit little-endian R4000 MIPS (or `\f5spim\fP')
  61. .IP \f51c\fP
  62. 68000 compiler, usable with the Motorola Dragonball
  63. .IP \f52c\fP
  64. 680x0 compiler for x >= 2
  65. .IP \f55c\fP
  66. ARM compiler
  67. .IP \f56c\fP
  68. AMD64
  69. .IP \f58c\fP
  70. Intel x86 compiler, for x>2
  71. .IP \f5kc\fP
  72. Sun SPARC compiler
  73. .IP \f5qc\fP
  74. PowerPC compiler
  75. .IP \f5vc\fP
  76. MIPS R[234]000 in 32-bit big-endian mode
  77. .RE
  78. .LP
  79. The compilers share components, compiled into a library from
  80. source in the directory
  81. .CW utils/cc .
  82. The corresponding assemblers and linkers are found in similarly
  83. named directories:
  84. .CW 2a
  85. and
  86. .CW 2l
  87. are the assembler and linker for use with
  88. .CW 2c
  89. for instance.
  90. Note that this suite is unusual in that the compilers and assemblers produce
  91. a binary assembly language that is finally converted to machine code
  92. by the linker.
  93. The assembler is used only to write machine-language assist for the operating
  94. system, or a run-time routines using instructions not accessible from C,
  95. and is not used by the compiler.
  96. See the paper ``Plan 9 C compilers'' by Ken Thompson,
  97. reprinted in this volume.
  98. .PP
  99. With the exception of the 68000 compiler, all the compilers have been
  100. used extensively to compile Inferno, and most have been used
  101. to compile Plan 9 and all its applications; and we have found them solid.
  102. The 68000 compiler was used to attempt a port of Inferno to the Motorola
  103. Dragonball (in the Palm Pilot).
  104. It is included here in case someone wishes to have another go.
  105. We have no experience with it.
  106. .PP
  107. The ARM compiler
  108. .CW 5c
  109. supports the ARM (Strongarm, PXA) architecture;
  110. the related compiler
  111. .CW tc
  112. generates ARM's Thumb instructions instead.
  113. The output of both can be linked together by the ARM loader
  114. .CW 5l
  115. to achieve ARM-Thumb interworking.
  116. .CW 5c
  117. has been used to generate code for the StrongARM SA110 and SA1100
  118. processors (the primary
  119. targets for native Inferno for many years).
  120. The code generated was greatly improved by Richard Miller.
  121. The floating-point support is adequate for C programs: the compiler
  122. generates ARM floating-point instructions, as implemented on the ARM7500 but
  123. not on the Strongarm, where they must be emulated.
  124. .PP
  125. The PowerPC compiler supports the 32-bit PowerPC architecture only;
  126. it does not support either the 64-bit extensions or the POWER compatibility instructions.
  127. It has been used for production operating system work on the 405EP, 603, 70x, 821, 823, and 860.
  128. On the embedded processors such as 405 and 8xx floating-point instructions must be emulated.
  129. Instruction scheduling is not implemented; otherwise the code generated
  130. is similar to that for the other load-store architectures.
  131. The compiler makes little or no use of unusual PowerPC features such as the
  132. counter register, several condition code registers, and multiply-accumulate
  133. instructions, but they are sometimes
  134. used by assembly language routines in the libraries.
  135. The compiler does replace explicit comparisons by condition-setting instructions.
  136. Its run-time conventions are more efficient than those of the PowerPC ABI.
  137. .NH 1
  138. Applications
  139. .PP
  140. Dis object files are portable across all variants of Inferno, hosted and native.
  141. There need be only one copy of the Dis files to serve many different
  142. versions of Inferno; they need not be rebuilt for each platform
  143. and can be shared by different types of host.
  144. Limbo insulates the programmer from all details of
  145. the particular processor, including byte-ordering,
  146. and consequently the applications themselves are portable.
  147. .PP
  148. The source for the applications is found in subdirectories of
  149. .CW appl :
  150. .CW appl/cmd
  151. holds the source for most command line applications (that use no graphics);
  152. .CW appl/wm
  153. contains the source for most applications that run under
  154. .I wm (1);
  155. .CW appl/svc
  156. contains the source for various system services and file servers;
  157. .CW appl/mux ,
  158. the source for the interactive television demo
  159. .I mux (1);
  160. .CW appl/charon ,
  161. the source for the Charon web browser; and
  162. .CW appl/acme
  163. the source for Acme written in Limbo.
  164. .PP
  165. The
  166. .CW mkfile
  167. in each directory can currently only be used by an instance of
  168. .CW mk
  169. running
  170. .I outside
  171. the Inferno environment, under the host operating system.
  172. This complicates its use with
  173. .I acme (1),
  174. normally requiring the use of the
  175. .I os (1)
  176. command.
  177. In a few cases, there is a
  178. .CW mashfile
  179. that can be used by
  180. .I mash-make (1)
  181. to build a Limbo application from within Inferno (native or hosted).
  182. A consistent approach to building applications both inside and outside
  183. Inferno is being developed.
  184. In any case, the resulting Dis files are portable once produced.
  185. .NH 1
  186. Hosted Inferno (emu)
  187. .PP
  188. There are currently four main variants of hosted Inferno: Plan 9, Unix (and clones), MacOS X and Windows.
  189. The source is held in directory
  190. .CW emu ,
  191. with a subdirectory for each hosted platform:
  192. .CW FreeBSD ,
  193. .CW Irix ,
  194. .CW Linux ,
  195. .CW MacOSX ,
  196. .CW NetBSD ,
  197. .CW Nt
  198. (for all Windows platforms, including the Internet Explorer plug-in),
  199. .CW Plan9 ,
  200. .CW Solaris ,
  201. and so on.
  202. Each platform directory has a
  203. .CW mkfile
  204. and one or more configuration files of the form described by
  205. .I config (6).
  206. An executable for a particular host type is built on that host type,
  207. using the host's own command interpreter, not under Inferno.
  208. Move to the
  209. .CW emu
  210. subdirectory appropriate to that host,
  211. ensure the command interpreter's path variable includes
  212. the directory containing the Inferno
  213. .CW bin
  214. directory for that host
  215. (eg,
  216. .CW /home/inferno/Solaris/sparc/bin ),
  217. and run
  218. .CW mk .
  219. .PP
  220. Like the native kernels
  221. .CW emu
  222. relies on several auxiliary libraries (the source of which
  223. it often shares with the native kernels).
  224. Emu itself is built by the
  225. .CW mkfile
  226. in the
  227. .CW emu
  228. subdirectory containing the platform-specific source for the host platform.
  229. Each library has its own
  230. .CW mkfile ;
  231. the various components are made in the right order by the
  232. .CW mkfile
  233. at the root of the Inferno tree.
  234. The
  235. .CW mkfile
  236. for each platform will also invoke
  237. .CW mk
  238. recursively to make the appropriate libraries
  239. for a given configuration.
  240. .PP
  241. The Unix emu variant generally is covered by `POSIX' (with common extensions)
  242. but each Unix port has one file that differs considerably for each port,
  243. namely \f5emu/\fP\fIplatform\fP\f5/os.c\fP, the differences
  244. corresponding to the different ways under Unix of implementing kernel-scheduled
  245. threads efficiently.
  246. .PP
  247. There are working emu versions
  248. for
  249. FreeBSD/386,
  250. Irix/mips,
  251. Linux/386,
  252. NetBSD/386,
  253. MacOSX/386,
  254. MacOSX/power,
  255. Plan 9,
  256. Solaris/sparc,
  257. and Windows (NT, 2000 and Explorer plug-in).
  258. Each platform typically uses mechanisms specific to the host operating
  259. system to implement Inferno's internal thread/process structure.
  260. POSIX threads have often been found to be insufficient (poorly implemented)
  261. on some platforms, and if so are avoided.
  262. See
  263. .CW kproc
  264. in
  265. .CW emu/*/os.c .
  266. .PP
  267. Source is included for ports to HP/UX (S800 architecture),
  268. Solaris/386, and Unixware, in case someone wishes to take them up now,
  269. but we have not determined their fitness.
  270. .PP
  271. The Plan 9 hosted implementation is unusual in that it supports
  272. several processor types:
  273. .CW 386 ,
  274. .CW mips ,
  275. .CW power
  276. (Power PC)
  277. and
  278. .CW sparc .
  279. Furthermore, all versions of
  280. .CW emu
  281. can be built on any processor type, in the usual way for Plan 9.
  282. .PP
  283. Otherwise, as distributed,
  284. .CW emu
  285. for a platform can only be built when running on that platform.
  286. .PP
  287. One unusual variant makes the whole of Inferno a plug-in for Microsoft's
  288. Internet Explorer, giving the same environment for Inferno applications
  289. running in an HTML page as is provided by hosted or native Inferno.
  290. That is, there is not a distinct `applet' environment with special programming interfaces.
  291. The source for the various plug-in components is found in
  292. .CW /tools/plugin
  293. and
  294. .CW /usr/internet
  295. within the Inferno tree; they use the version of
  296. .I emu
  297. defined by the configuration file
  298. .CW /emu/Nt/ie .
  299. .PP
  300. All the libraries and executables can be built in a tree containing only the source code.
  301. To do that for a supported variant of hosted Inferno, on Unix or Plan 9, do the following
  302. in the root of the Inferno tree:
  303. .nr Ci 0 +1
  304. .de Xx
  305. .IP \\n+(Ci
  306. ..
  307. .Xx
  308. Edit
  309. .CW mkconfig
  310. to reflect your host environment,
  311. specifically ROOT (which must be an absolute path name), SYSHOST and OBJTYPE.
  312. The comments in the file should help you choose.
  313. .Xx
  314. Run
  315. .CW makemk.sh
  316. to rebuild the
  317. .CW mk
  318. command, which is used to build everything else.
  319. .Xx
  320. Set
  321. .CW PATH
  322. (or
  323. .CW path
  324. on Plan 9)
  325. to include the
  326. .CW bin
  327. directory for the platform, which will now contain the
  328. .CW mk
  329. binary just built.
  330. On Unix, export
  331. .CW PATH .
  332. .Xx
  333. Then
  334. .CW "mk nuke"
  335. to remove any extraneous object files.
  336. .Xx
  337. Finally,
  338. .CW "mk install"
  339. to create and install the libraries,
  340. .CW limbo
  341. compiler,
  342. .CW emu
  343. for hosted Inferno, and auxiliary commands.
  344. The rules do that in an order that ensures that the commands or libraries
  345. needed by a later stage are built and installed first.
  346. (Note that a plain
  347. .CW mk
  348. will not suffice, because it does not put the results in the search path.)
  349. .LP
  350. Doing something similar on Windows or Plan 9 currently requires the executable for
  351. .CW mk
  352. to be available in the search path,
  353. since there is no equivalent of
  354. .CW makemk.sh .
  355. Otherwise the procedure is the same.
  356. On Plan 9, of course, the host system's normal version of
  357. .CW mk
  358. should be adequate.
  359. .NH 1
  360. Native Inferno
  361. .PP
  362. As with the different versions of emu, once the native kernel is running, all applications
  363. work straight away;
  364. the same applications are used in native and emulated mode, subject to
  365. suitable devices being available.
  366. Because the portable compiler suite is used to compile native kernels,
  367. and those compilers are automatically cross-compilers, all native Inferno
  368. implementations can be built on any host platform.
  369. Furthermore, the build procedures and resulting object files are the same.
  370. .PP
  371. Early ports in 1996 were made by Bell Labs to an internal device based on
  372. the AMD 29000, an early ARM-based `network computer', and Intel-based PCs.
  373. Between 1997 and 1999, Lucent concentrated mainly on the Strongarm platform
  374. (SA1100), for various Digital/Intel development boards,
  375. and especially several `web phones', including the Sword Webphone Reference Design.
  376. It also undertook ports to other devices for experiment, or under contract.
  377. .PP
  378. Vita Nuova Limited also ported the system, both for its own purposes
  379. and under contract to Lucent.
  380. Targets included a small 386-based Internet device,
  381. a set top Internet box using the PowerPC 603e,
  382. a digital television set top box with a Strongarm SA110 and a Teralogic TL750 graphics chip,
  383. the USR/3Com Edgeserver (in a chassis containing various types of line card),
  384. various boards based on the PowerPC 823/821/860,
  385. many different configurations of IBM PC,
  386. and a Ziatech Pentium-based VME crate.
  387. .PP
  388. Distribution of most previous and existing ports is restricted by
  389. the terms on which they were undertaken,
  390. or because they were ports of older Inferno releases and not kept up to date.
  391. We have included the following as examples in this distribution.
  392. .SH
  393. The StrongARM kernel
  394. .PP
  395. The source for the StrongARM kernels is split across several directories.
  396. The directory
  397. .CW os/sa1110
  398. contains all code that is generally architecture-specific but platform-independent.
  399. Other directories contain platform-specific code:
  400. .CW os/cerf1110
  401. for the Intrinsyc Cerfcube1110,
  402. and
  403. .CW os/ipaq1110
  404. for the Compaq (as it then was) IPAQ H3650.
  405. Earlier Webphone ports are tied to hardware that is not generally obtainable
  406. and the ports to those
  407. platforms included some software (notably modem software)
  408. that cannot generally be distributed.
  409. .PP
  410. There is also a preliminary port to the ARM-based Intel XScale.
  411. The code common to PXA implementations is in
  412. .CW os/pxa .
  413. The initial platform was the Intrinsyc Cerfboard 250; its code is in
  414. .CW os/cerf250 .
  415. A port to the Gumstix (see
  416. .CW www.gumstix.com )
  417. is in progress.
  418. .PP
  419. The platform's own bootstrap is used in all cases.
  420. On the IPAQ, the Linux bootloader from Compaq (HP) Research must
  421. be loaded onto the device first, following instructions given at
  422. .CW www.handhelds.org .
  423. See the
  424. .CW README
  425. file in each
  426. .CW os
  427. source directory for details.
  428. .PP
  429. Other ARM-based processors to which Inferno has been ported include
  430. the ARM-7 evaluator kit (see
  431. .CW os/ks32 ),
  432. although its memory is tight,
  433. and the TI925 including the TI OMAP.
  434. The latter two ports were to proprietary TI925 implementations, and have not
  435. been included, but there is a body of code common to all such platforms that
  436. could be made available if that were useful.
  437. .SH
  438. The PowerPC kernel
  439. .PP
  440. The directory
  441. .CW os/fads
  442. contains the port of Inferno to the MPC8xx FADS development board.
  443. It has been used with the MPC821, MPC823 and MPC860 processors.
  444. It uses code common to MPC8xx processors, found in
  445. .CW os/mpc .
  446. The interface to the CPM is provided by
  447. .CW cpm.c .
  448. There are drivers for the real time clock,
  449. flash devices (including a Flash Translation Layer driver),
  450. and communications controllers in Ethernet,
  451. UART, and IrDA mode
  452. (see
  453. .CW etherscc.c
  454. and
  455. .CW devuart.c ).
  456. The IrDA has been used for 9P transport between a FADS board
  457. and an IBM Thinkpad 560.
  458. The file
  459. .CW screen.c
  460. drives an 8-bit per pixel LCD (TFT) display panel.
  461. A sample interface to the on-chip video device of the MPC823 (only)
  462. as wired on the FADS board using auxiliary chips can be found in
  463. .CW devvid.c .
  464. The York Electronics Centre developed a touch panel for us,
  465. connected using SPI;
  466. the driver is
  467. .CW devtouch.c ,
  468. and could be adapted for similar devices.
  469. .PP
  470. The bootstrap program for the FADS board is in
  471. .CW os/boot/mpc ,
  472. loosely derived from an older version of
  473. .CW os/boot/pc .
  474. It is initially converted to S records that are loaded into flash by MPC8BUG
  475. from a PC, and thereafter the images of the boot and kernel images can
  476. be updated using the flash devices provided by the system itself,
  477. and the utility programs
  478. .CW qconfig.b
  479. and
  480. .CW qflash.b
  481. in
  482. .CW appl/cmd/mpc .
  483. .PP
  484. Another port is to the Brightstar Engineering ip-Engine containing an MPC823
  485. and an Altera FPGA.
  486. See
  487. .CW os/ipengine .
  488. It uses common code from
  489. .CW os/mpc .
  490. The device driver that loads the FPGA is in
  491. .CW devfpga.c ;
  492. see
  493. .I fpga (3)
  494. for the interface and
  495. .I fpgaload (8)
  496. for a command to do it.
  497. See the
  498. .CW README
  499. file for information on loading the kernel into the flash.
  500. .PP
  501. The most recent PowerPC port is to the IBM 405EP, and more specifically
  502. to the Intrinsyc Cerfcube 405EP.
  503. The source for that port is in
  504. .CW os/cerf405 ;
  505. lacking another 405EP platform for reference, the source code has not yet
  506. been split into that common to all 405EP implementations and that specific
  507. to the Cerfcube, although that would be easy to do.
  508. .SH
  509. The x86 kernel
  510. .PP
  511. The
  512. .CW os/pc
  513. directory contains the components for ports to 386, 486 and Pentium class machines.
  514. The main difficulty is device support: in particular
  515. only a limited set of Ethernet and graphics cards is supported.
  516. We have used mainly the 3Com and Intel 82557 drivers.
  517. A `generic' PC port is included that has a graphics driver that
  518. should run on systems that provide a VESA BIOS mode.
  519. .PP
  520. We have a (slow) floating-point emulator for the 386 found in
  521. .CW os/pc/fpi387.c ;
  522. code to invoke it in trap can be provided on request.
  523. .PP
  524. The source for the PC bootstrap program
  525. .CW 9load
  526. is in
  527. .CW os/boot/pc .
  528. It is simply a copy of the current Plan 9 PC bootstrap program, with slight modifications
  529. to allow it to be compiled on many host systems.
  530. .SH
  531. The Javastation 1 kernel
  532. .PP
  533. The directory
  534. .CW os/js
  535. has the first port
  536. to the Sun Javastation 1.
  537. It was done by Tad Hunt and Eric Van Hensbergen
  538. in a matter of days to demonstrate Inferno at Java One in 1997.
  539. It boots over the net using TFTP.
  540. Javastations being a bit thin on the ground now,
  541. it is unlikely to be directly usable unless you can find one second hand
  542. (you might find a Javastation 2 coffee pot, but that is slightly different again).
  543. That is a pity, because the machine was quite usable running Inferno and
  544. Limbo applications, often surprising those used to the Java-based
  545. offering on the same platform.
  546. It is included as an example of a micro-SPARC port.
  547. Beware that
  548. .CW screen.c
  549. has not yet been converted for Fourth Edition graphics
  550. (partly because we no longer have a suitable device for testing).
  551. .NH 1
  552. Supporting tools
  553. .PP
  554. The
  555. .CW utils
  556. directory also contains ANSI C versions of other components of the
  557. Plan 9 development suite,
  558. such as
  559. .CW nm ,
  560. .CW ksize ,
  561. .CW ar ,
  562. and of course
  563. the
  564. .CW acid
  565. debugger.
  566. Most rely on
  567. .CW libmach ,
  568. a suite of functions forming a
  569. library to handle the various object and executable files in one place.
  570. .PP
  571. Some other utilities give a portable
  572. way to express some of the kernel build scripts:
  573. .CW sed ,
  574. .CW test ,
  575. .CW rm ,
  576. and
  577. .CW mkdir .
  578. On Plan 9,
  579. .CW mk
  580. and kernel build scripts use Plan 9's own shell,
  581. .I rc .
  582. On Unix systems, they use
  583. .I sh .
  584. On Windows, a version of Plan 9's
  585. .I rc
  586. has been ported to reduce the number of variants
  587. to two, and keep the system self-contained; its source is in
  588. .CW utils/rcsh
  589. and installs as
  590. .CW rcsh.exe .