__  __                        _         
 |  \/  |                      | |        
 | \  / | __ _  __ _  ___ _ __ | |_  __ _ 
 | |\/| |/ _` |/ _` |/ _ \ '_ \| __|/ _` |
 | |  | | (_| | (_| |  __/ | | | |_| (_| |
 |_|  |_|\__,_|\__, |\___|_| |_|\__|\__,_|
                __/ |                     
               |___/                      

##############################################################
# IRC
##############################################################
     
#magenta on irc.evolse.net


##############################################################
# General
##############################################################

Magenta is an implementation of Darwin/BSD on top of the Linux kernel. It is made
up of a number of kernel and userland components that work together. It is fully binary
compatible with iPhone OS 5.0 (as in, it uses the same binary format). 

So far, it includes the following libraries:
	* CoreFoundation
	* libstdc++
	* libobjc
	* libc++abi
	* libicucore
	* libncurses

	* As part of libSystem
		* libmath
		* libunwind
		* libsystem_blocks
		* libC

All libraries are compiled for vanilla Darwin, so nothing is compiled for Linux. The only
exception is libC (which resides inside the dynamic linker) as it serves as the main bridge
between the userland and the kernel. 

The final goal is probably recreating the iPhone OS 1.0 stack. I think this is a pretty feasible
goal, considering the fact that there are so many open source libs that can be used to replace
the proprietary libs used by Apple. Just as an example:
	* CoreGraphics -> Cairo
				   -> FreeType
				   -> libpng/jpg
	* Celestial -> Various open source media decoding libs.
	* UIKit -> Chamelleon

This is a very weird project. You may ask, why am I doing this? The answer is: no fucking idea :)

This project is actually far more complicated than it sounds. *Far* more complicated.


##############################################################
# Q/A
##############################################################

* Which platforms does it run on?
	* ARMv7 only. Nothing else is planned right now.
* Which SDK do I use?
	* iPhoneOS5.0 (apple-arm-darwin)
* Why is libSystem built into the linker?
	* I don't know, it just seemed more convinient.
* Is it open source?
	* Yep. Check my website. (crna.cc)
* Why not use the FreeBSD kernel instead?
	* I thought about using FreeBSD (or rather NetBSD) kernel instead of using Linux.
	  However, in this case, I prefer Linux due to  the extensive features supported by
	  the kernel and the hardware compatibility (NetBSD offers limited support for ARM
	  hardware and it doesn't support my dev board (Arm RealView) and I can't be bothered
	  to make it myself).
* Will it run iPhone OS apps?
	* No, because I'm not aiming to have compatible high level frameworks. Just think
	  about how much work is required to have a 100% compatible implementation of UIKit
	  or Celestial. HOWEVER, the CoreOS part should be 100% (or 99%) compatible. Just not
	  the higher level OS. If you're just interested in this because it will "run iOS apps"
	  please go away.
* Who are you?
	* I'm Christina, a very obscure developer obsessed with embedded hardware. I really 
	  like the ARM architecture.


##############################################################
# Notes
##############################################################

> Linking is slow. This is not a problem per se, due to the fact that linking
  is meant to be slow. The libs are not prelinked so every time, the linker has 
  to resolve everything all over again. This can be resolved with prebinding, 
  fixed load addresses, shared caches and other things like that. Right now, these
  things are not really trivial so let's leave it as is. Later on I can probably make
  some sort of a shared cache with a splitseg and stick it on a shared page.

> Core exports a lot of garbage symbols that are not really needed. Not a problem but it
  would be nice to limit the exported symbols via an exported file. Not trivial right now.

> Mach messaging is poorly implemented. I am aware of that and I will improve my crappy
  implementation later. I did not forget about it, I've just been focusing on other things.
  A large number of mach APIs and functionality still needs implementing. I will work on that
  later.

> Linking mach object files into the kernel is a silly idea. It should not be done. Never the
  less, I'm doing it as an experiement. This doesn't mean that it is a good idea or that anyone
  should ever link object files that use incompatible ABI.

> I need some sort of an IOKit-compatible kernel interface. I have a few ideas which I will
  work on in the meantime.


##############################################################
# Changelog
#	> This changelog has only been maintained for
#	  a very short amount of time so it is missing earlier
#	  things. 
##############################################################
	* 14 May
		* libmath
			* Implemented 'ceil' and 'fmod'
			* Implemented 'modf'
		* Core/Linker
			* Implemented 'atoi' and 'atol'
			* Preliminary support for signals.
			* Added more system calls.
			* OSSpinLocks are now based on low level locks.
			* ELF linker can now map files in.
			* Fixed CRT externs to point to the right locations.
		* Veronica
			* Initial version of 'veronica', a simple startup daemon.
	* 18 May
		* Core/Linker
			* Added 'stroull' and friends.
		* Core/Linker
			* libBoring stubs
	* 19 May
		* kld
			* Detect if code is ARM or Thumb(2) and set the address bit accordingly.
	* 20 May
		* Core/Linker
			* Support for TermIO ioctl calls.
			* Fixed strcpy bug.
			* The initial stack layout on initialization is now correct (Apple ABI).
			* TermIO functions are now working correctly.
			* Signal conversions.
			* 'setsigaction' is now working correctly.
			* Tidied up the structure of syscalls.
			* Made OSLog/lnk::log/OSHalt more "colourful" (see 'OSTermSetTextColor' in OSLog.c)
			* Implemented the 'clock()' function
			* Silent mode flag to shut Core up if needed.
		* Bash
			* Fixed compilation issue.
	* 23 May
		* Core/Linker
			* Can now read ELF dynamic symbols.
			* tcsetattr now works as it should do on Darwin.
			* 'getopt' support.
			* OSHalt now exits instead of entering an infinite loop.
	* 31 May
		* TestSuite
			* 'fts_tester' for testing the FTS API.
			* 'list_directories' for testing readdir.
		* FileCommands
			* 'ls' command added.
		* Kernel
			* Darwin directory listing call (getdirentries)
			* Argv/Argc passed on correctly
		* Filesystem
			* Moved libSystem's guts to /usr/lib/system/
		* Core/Linker
			* Trampolines for weird $NOCANCEL calls
			* Added code to back up the argv stuff (stack).
			* Reduced the amount of auxilary libs to the critical ones.
			* UUID library (Libc/Extensions/UUID).
			* Membership library (LibInfo).
			* Stdout now newline buffered.
			* Gdtoa library (Libc/Extensions/Gdtoa).
			* ACL library (Libc/Extensions/ACL).
			* PseudoTty library (Libc/Extensions/PseudoTty)
			* Full 'opendir' family support
			* Regex library (Libc/Extensions/Regex).
			* Arc4random.
			* 'rand' family.
			* General
				* 'fts' support (file traversing)
				* Extended attribute stubs.
				* 'stroffflags'
			* String
				* 'stpcpy' and 'strmode'
			* Time
				* 'strtftime' implemented
				* Full support for tzcode.
				* Fixed 'gettimeofday'
			* PosixSpawin
				* Added support for posix_spawn functions.
				* No __posix_spawn syscall to back them yet.
	* 1 June
		* Core/Linker
			* 'sigaction' can now take NULL arguments without crashing.
			* 'atof' added.
			* Tidied up LibSyscall's source code.
	* 3 June
		* zlib
			* Added zlib 1.2.5
		* Graphics
			* Added 'libpng'
		* Core/Linker
			* Stdout now really newline buffered (__SWR | __SLBF).
			* 'stack.s' thing.
			* Stubs for mach thread API (not really needed).
		* Kernel
			* Tidied up the source tree.
			* 'ke_array' support.
			* Ports are now defined using an abstract union 'ke_port_t'.
			* 'task' structure has new fields for its task port and a portright list.
			* IPC now initalized as part of ke_runtime.
			* Offloaded kmsg processing to 'mach_kmsg'.
			* Different named port types (ipc & task).
			* ke_runtime hooks for exit/fork/exec.
			* Task ports assigned to each task.
	* 4 June
		* Core/Linker
			* Thread ptr 0 is a synonym for main thread.
		* Kernel
			* Kmsg now requires MACH_MSG_SEND.
		* CoreFoundation
			* Fixed the 'HALT' screw up which made the compiler emit rubbish.
		* Veronica
			* Now uses a runloop source, eliminating a sched_yield() loop.