Native MIPS Systems

From Free Pascal wiki
Revision as of 12:02, 25 May 2011 by MarkMLl (talk | contribs) (→‎Messy Working Notes: More mess.)
Jump to navigationJump to search

The MIPS architecture is unusual in that it was designed for desktop computers, is now overwhelmingly used for embedded systems, but can still occasionally be found in desktops or small servers. The only comparable architecture is ARM, which is the platform of choice for a multitude of "bratphones", tablets etc.

Like almost all computers, MIPS-based systems will contain an internal loader, usually in Flash memory. However there are three basic categories of system:

  • Those that boot an operating system from internal Flash, such as the Linksys/Cisco WRT54G [1].
  • Those that boot an operating system from a conventional disc, connected via IDE, SCSI or USB, such as an SGI server or workstation, or a Cobalt/Sun Qube or Raq.
  • Those running as guests using an emulator such as Qemu on a general-purpose computer.

In any of these cases it is necessary to be able to install a general-purpose operating system such as Linux in order to be able to run development tools. This writer (MarkMLl) favours Debian, since he finds that using it results in a very similar system on a wide range of hardware (x86, SPARC, PPC, MIPS, ARM, zSeries).

If you intend to build Lazarus, make sure you have at least 512Mb memory (RAM + swap) available.

Interim Notes

The "unofficial" MIPS compiler at [2] was written by David Zhang (possibly [3]) and is licensed under GPL Version 2, it cites but does not include the COPYING.FPC file.

There are .zip files of both sources and a minimal executable at Sourceforge (link above). The sources are basically modified contents of fpcsrc/compiler/mips based on FPC 2.0.0, the compiler targets mipsel and is described as being operational on Qemu but not yet supporting shared libraries.

Since this is specifically a little-endian compiler it should presumably be compatible with Linux on a MIPS-based Qube or Raq, or with the Chinese "Loongson" processor of fable. It will not be compatible with SGI MIPS systems, which are big-endian.

There is a system library bundled with the compiler, but no indication of how far the compiler is capable of handling the remainder of the standard libraries.

Messy Working Notes

Anybody: please feel free to improve/delete all of this, they're basically stream-of-consciousness and are here in case I fall under the proverbial bus.

I've now got mipsel working as a Qemu guest, but have reservations about the performance; I've put test results on that page. I'd very much prefer having some real MIPS hardware, but right now that's not going to happen.

I don't know how good something like a Raq would be for compilation. They've not got much memory but take standard EDO, if we're lucky they'd work with Compaq DIMMs of which we have a lot. We missed an SGI Origin a few months ago but only spotted it a couple of hours before the eBay auction closed- went for £10 :-(

The compiler is for mipsel (i.e. not immediately usable on SGI etc.). Comparing with arm/armel I've found minimal difference in the compiler and system unit between big- and little-endian.

This comprises the binary compiler pp_mipsel32. It successfully compiles a minimal test program which appears to run.

This is both source and binary, dumped into a single directory which appears to correspond to the standard fpc_200/compiler, i.e. there's no separate compiler/mips directory. The compiler appears to be based on the SPARC port, not on the partial mainline implementation which itself appears to have been derived from ARM.

Using cksum, these files are identical in the Chinese compiler and in fpc_200/compiler, so may be removed from the former:

rabase.pas switches.pas ncal.pas tokens.pas defutil.pas msgidx.inc
ogcoff.pas nstate.pas comprsrc.pas nutils.pas cutils.pas nbas.pas
verbose.pas gendef.pas msgtxt.inc defcmp.pas aopt.pas nmem.pas
script.pas gdb.pas symutil.pas rautils.pas ncnv.pas pmodules.pas
pass_2.pas catch.pas pass_1.pas ncgset.pas symbase.pas psub.pas
impdef.pas oglx.pas aoptbase.pas symconst.pas ncgmem.pas raatt.pas
rgobj.pas regvars.pas fmodule.pas cp8859_1.pas import.pas cp437.pas
symnot.pas pbase.pas ppheap.pas aasmbase.pas pdecl.pas aoptcs.pas
charset.pas cgutils.pas pexpr.pas ncgcon.pas rasm.pas dwarf.pas
nopt.pas tgobj.pas procinfo.pas aasmtai.pas ppu.pas cg64f32.pas
pexports.pas ncgadd.pas pdecvar.pas browcol.pas nadd.pas compinnr.inc
ncgflw.pas ncgmat.pas nld.pas aggas.pas ncginl.pas ncgbas.pas
export.pas finput.pas owbase.pas symtype.pas owar.pas pdecsub.pas
cstreams.pas cp850.pas aoptda.pas ogbase.pas aoptobj.pas nflw.pas
browlog.pas symtable.pas crc.pas globtype.pas ptconst.pas widestr.pas
scandir.pas nobj.pas COPYING nset.pas node.pas ogmap.pas symsym.pas
ncon.pas link.pas cclasses.pas htypechk.pas ncgopt.pas comphook.pas
rgbase.pas nmat.pas pinline.pas ncgcnv.pas parabase.pas pdecobj.pas
cresstr.pas ogelf.pas cgbase.pas ptype.pas fppu.pas scanner.pas
parser.pas cmsgs.pas

Using cksum, these files are an exact copy of files in rtl/sparc so are a candidate to be moved to a new rtl/mips or rtl/mipsel directory:

strings.inc math.inc stringss.inc int64p.inc set.inc

Ditto for rtl/linux/mips or rtl/linux/mipsel:

syscallh.inc sighndh.inc

Using cksum, these files are duplicates of existing files elsewhere in the rtl tree so may be removed:

dati.inc dynarrh.inc sstrings.inc rtti.inc errno.inc stringsi.inc
sysinth.inc gensigset.inc genstrs.inc bunxh.inc osutil.inc dos.pp
datih.inc except.inc genset.inc systhrdh.inc osmacro.inc
bunxovlh.inc unxfunc.inc sysfile.inc sysformt.inc genmath.inc
unixtype.pp generic.inc ObjPas.pp (AKA objpas.pp) wstringh.inc
syswide.inc sysheap.inc sysuintf.inc real2str.inc heaph.inc
threadvr.inc sysdir.inc objpash.inc syspch.inc wstrings.inc
genfuncs.inc osdefs.inc int64.inc sysstrh.inc sysansih.inc fina.inc
text.inc filutilh.inc dynarr.inc aliasctp.inc astrings.inc
fexpand.inc syscall.pp variant.inc settimeo.inc typefile.inc
filerec.inc aliasptp.inc file.inc sysutils.inc genfdset.inc
sysutils.pp sysstr.inc textrec.inc syspchh.inc mathh.inc
sysutilh.inc compproc.inc dos.inc dosh.inc genstr.inc timezone.inc
baseunix.pp unxsysc.inc sysosh.inc sysconst.pp innr.inc unxsysch.inc
sysint.inc threadh.inc ctypes.inc diskh.inc heap.inc thread.inc
unxconst.inc syswideh.inc sysos.inc sysunixh.inc intfh.inc
varianth.inc unxovl.inc finah.inc objpas.inc aliases.inc unxovlh.inc
osutilsh.inc systhrd.inc ptypes.inc strings.pp variants.pp errors.pp
sysansi.inc

By name, these files are equivalents of files in rtl/sparc so may be moved to rtl/mips or rtl/mipsel:

setjumph.inc setjump.inc mipsel.inc sysutilp.inc

By name, these files are equivalents of files in rtl/linux/sparc so may be moved to rtl/linux/mips or rtl/linux/mipsel:

bsyscall.inc sighnd.inc stat.inc syscall.inc sysnr.inc

Using cksum, these files are duplicates of files in compiler/systems:

i_sunos.pas t_sunos.pas

These are test files and documentation, so don't have to be considered part of the compiler for build purposes:

bench.pas console_io.pas hello.pas magic.pp WETS.pp *TXT

That leaves these files:

aasmcpu.pas   cpupara.pas   ncpucnv.pas   psystem.pas   signal.inc
aoptcpub.pas  cpupi.pas     ncpuinln.pas  racpu.pas     strinst.inc
aoptcpud.pas  cpuswtch.pas  ncpumat.pas   raMIPS.pas    symdef.pas
aoptcpu.pas   cputarg.pas   ncpuset.pas   raMPSgas.pas  sysconst.rst
assemble.pas  fpcdefs.inc   ninl.pas      rfv32con.inc  systemh.inc
bunxovl.inc   globals.pas   opcode.inc    rfv32dwf.inc  system.inc
bunxsysc.inc  i_linux.pas   options.pas   rfv32nor.inc  System.pas
cgcpu.pas                   ossysc.inc    rfv32num.inc  systems.pas
cgobj.pas     itcpugas.pas  ostypes.inc   rfv32rni.inc  t_linux.pas
compiler.pas  ncgcal.pas    paramgr.pas   rfv32sri.inc
cpubase.pas   ncgld.pas     pp_mipsel32   rfv32sta.inc  unix.pp
cpugas.pas    ncgutil.pas   pp.pas        rfv32std.inc  version.pas
cpuinfo.pas   ncpuadd.pas   prt0.o        rfv32sup.inc
cpunode.pas   ncpucall.pas  pstatmnt.pas  rgcpu.pas

I'll continue this by trying to identify files which are trivial extensions of standard ones, e.g. compiler.pas. I could be some time.