mailing list of musl libc
 help / color / mirror / code / Atom feed
* Bare metal musl data points.
@ 2014-12-06 15:51 Richard Pennington
  0 siblings, 0 replies; only message in thread
From: Richard Pennington @ 2014-12-06 15:51 UTC (permalink / raw)
  To: musl

Hi,

A few examples of bare metal musl in action.

The simplest main(). No I/O. Just startup code and libc initialization:

dev main 367 % cat main.c
int main()
{
}
dev main 357 % size main
    text    data     bss     dec     hex filename
    5358    2080   33156   40594    9e92 main
dev main 368 % make run
Running main
enter 'control-A x' to exit QEMU
audio: Could not init `oss' audio driver

The simplest hello world example in C. Polled serial I/O:

dev hello 371 % cat main.c
#include <stdio.h>

int main()
{
     printf("hello world\n");
}
dev hello 361 % size hello
    text    data     bss     dec     hex filename
   26377    2228   34204   62809    f559 hello
dev hello 370 % make run
Running hello
enter 'control-A x' to exit QEMU
audio: Could not init `oss' audio driver
hello world

Hello world again in C++. Yikes!

dev hellocpp 373 % cat main.cpp
#include <iostream>

int main()
{
   std::cout << "hello world" << std::endl;
}
dev hellocpp 363 % size hellocpp
    text    data     bss     dec     hex filename
1327518    2568   43600 1373686  14f5f6 hellocpp

calhost.localdomain hellocpp 374 % make run
Running hellocpp
enter 'control-A x' to exit QEMU
audio: Could not init `oss' audio driver
hello world

A full ELK build with file system, virtual memory, etc.:

/* ELK running as a VM enabled OS.
  */
#include <sys/cdefs.h>
#include <stdio.h>

#include "command.h"

int main(int argc, char **argv)
{
   setprogname("elk");
   printf("%s started. Type \"help\" for a list of commands.\n", 
getprogname());
   // Enter the kernel command processor.
   do_commands(getprogname());
}
dev elk 377 % size elk
    text    data     bss     dec     hex filename
  223830    3456   54540  281826   44ce2 elk
dev elk 379 % make run
Running elk
enter 'control-A x' to exit QEMU
audio: Could not init `oss' audio driver
elk started. Type "help" for a list of commands.
elk % ps
Total pages: 7936 (32505856 bytes), Free pages: 7926 (32464896 bytes)
    PID    TID       TADR STATE        PRI NAME
      0      0 0x800452e8 RUNNING        1 kernel
      0      2 0x8004ae54 IDLE           3 [idle0]
elk % date
Thu Jan  1 00:00:31 1970
elk %
[~] main%

Fun stuff.

Rich

http://ellcc.org



^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2014-12-06 15:51 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-12-06 15:51 Bare metal musl data points Richard Pennington

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).