Subversion Repositories shark

Rev

Blame | Last modification | View Log | RSS feed


#include <kernel/func.h>
#include <kernel/trace.h>

#include <fs/bdevinit.h>
#include <fs/fsinit.h>
#include <fs/bdev.h>

#include <drivers/keyb.h>

#include <trace/trace.h>
#include <trace/queues.h>

#include <sys/mount.h>

#include <fcntl.h>
#include <unistd.h>
#include <errno.h>

int __register_sub_init(void)
{
  return 0;
}

/* -- */

__dev_t root_device;
__dev_t temp_device;

int choose_root_callback(__dev_t dev,__uint8_t fs)
{
  if (fs==FS_MSDOS) return dev;
  return -1;
}

int choose_temp_callback(__dev_t dev,__uint8_t fs)
{
  static int flag=0;
  if (fs==FS_MSDOS) {
    if (flag) return dev;
    flag=1;
  }
  return -1;
}

/* -- */

extern int bdev_scan_devices(int(*callback)(__dev_t,__uint8_t));

int __bdev_sub_init(void)
{
  BDEV_PARMS bdev=BASE_BDEV;
 
  bdev_def_showinfo(bdev,FALSE);
  bdev_init(&bdev);

  root_device=bdev_scan_devices(choose_root_callback);
  if (root_device<0) {
    cprintf("can't find root device to mount on /!!!\n");
    sys_end();
    return -1;
  }

  temp_device=bdev_scan_devices(choose_temp_callback);
  if (temp_device<0) {
    cprintf("can't find a filesystem to mount on /TEMP!!!\n");
  }
 
  return 0;
}

/* -- */

extern int libc_initialize(void);

int __fs_sub_init(void)
{
  FILESYSTEM_PARMS fs=BASE_FILESYSTEM;
  struct mount_opts opts;
  int res;
 
  filesystem_def_rootdevice(fs,root_device);
  filesystem_def_fs(fs,FS_MSDOS);
  filesystem_def_showinfo(fs,FALSE);


  //filesystem_init_prologue();  
  filesystem_init(&fs);
 
  libc_initialize();

  if (temp_device>=0) {
    memset(&opts,0,sizeof(struct mount_opts));
    opts.flags=MOUNT_FLAG_RW;
    res=mount(temp_device,FS_MSDOS,"/TEMP",&opts);
    if (res!=0) {
      cprintf("can't mount XXX on /TEMP (errno: %i)\n",errno);
    }
  }
   
  TRC_init_phase2();
 
  return 0;
}

/* -- */

void ctrlc_exit(KEY_EVT *k)
{
  extern void dump_sem_table(void);
  extern void dump_nop_table(void);
  //dump_sem_table();
  //dump_nop_table();
  //sys_status(SCHED_STATUS);
  sys_end();
}

/* -- */

void showmessage(char *s)
{
  cputs(s);
  cprintf("Press [x] to begin...");
  while (keyb_getchar()!='x');
  cprintf("\n");
}

void waitend(void)
{
  int c;
  cprintf("Press [x] to exit...");
  while ((c=keyb_getchar())!='x');
  cprintf("\n");
}