Subversion Repositories HelenOS

Compare Revisions

Ignore whitespace Rev 3349 → Rev 3386

/branches/network/uspace/app/init/init.c
34,30 → 34,88
* @file
*/
 
#include <stdio.h>
#include <unistd.h>
#include <vfs/vfs.h>
#include <bool.h>
#include <errno.h>
#include <fcntl.h>
#include <task.h>
#include <malloc.h>
#include "init.h"
#include "version.h"
#include <stdio.h>
 
static void test_console(void)
static void console_wait(void)
{
int c;
while (get_cons_phone() < 0)
usleep(50000); // FIXME
}
 
while ((c = getchar()) != EOF)
putchar(c);
static bool mount_fs(const char *fstype)
{
int rc = -1;
while (rc < 0) {
rc = mount(fstype, "/", "initrd");
 
switch (rc) {
case EOK:
printf(NAME ": Root filesystem mounted\n");
break;
case EBUSY:
printf(NAME ": Root filesystem already mounted\n");
break;
case ELIMIT:
printf(NAME ": Unable to mount root filesystem\n");
return false;
case ENOENT:
printf(NAME ": Unknown filesystem type (%s)\n", fstype);
return false;
default:
sleep(5); // FIXME
}
}
return true;
}
 
static void spawn(char *fname)
{
char *argv[2];
 
printf(NAME ": Spawning %s\n", fname);
 
argv[0] = fname;
argv[1] = NULL;
 
if (task_spawn(fname, argv) != 0) {
/* Success */
sleep(1);
}
}
 
int main(int argc, char *argv[])
{
info_print();
sleep(5); // FIXME
if (!mount_fs("tmpfs") && !mount_fs("fat")) {
printf(NAME ": Exiting\n");
return -1;
}
// FIXME: spawn("/sbin/pci");
spawn("/sbin/fb");
spawn("/sbin/kbd");
spawn("/sbin/console");
console_wait();
version_print();
 
printf("This is init\n");
test_console();
 
printf("\nBye.\n");
 
spawn("/sbin/bdsh");
return 0;
}
 
/** @}
*/
 
/branches/network/uspace/app/init/Makefile
61,7 → 61,7
 
.PHONY: all clean depend disasm
 
all: $(OUTPUT) disasm
all: $(OUTPUT) $(OUTPUT).disasm
 
-include Makefile.depend
 
74,9 → 74,11
$(OUTPUT): $(OBJECTS) $(LIBS)
$(LD) -T $(LIBC_PREFIX)/arch/$(ARCH)/_link.ld $(OBJECTS) $(LIBS) $(LFLAGS) -o $@ -Map $(OUTPUT).map
 
disasm:
$(OBJDUMP) -d $(OUTPUT) >$(OUTPUT).disasm
disasm: $(OUTPUT).disasm
 
$(OUTPUT).disasm: $(OUTPUT)
$(OBJDUMP) -d $< >$@
 
%.o: %.S
$(CC) $(DEFS) $(AFLAGS) $(CFLAGS) -D__ASM__ -c $< -o $@
 
/branches/network/uspace/app/init/version.c
35,6 → 35,7
 
#include <unistd.h>
#include <stdio.h>
#include "init.h"
#include "version.h"
 
char *release = RELEASE;
51,6 → 52,11
char *timestamp = "";
#endif
 
void info_print(void)
{
printf(NAME ": HelenOS init\n");
}
 
/** Print version information. */
void version_print(void)
{
/branches/network/uspace/app/init/init.h
36,7 → 36,7
#ifndef __INIT_H__
#define __INIT_H__
 
#include "version.h"
#define NAME "init"
 
#endif
 
/branches/network/uspace/app/init/version.h
36,6 → 36,7
#ifndef __VERSION_H__
#define __VERSION_H__
 
extern void info_print(void);
extern void version_print(void);
 
#endif