Subversion Repositories shark

Rev

Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed


#include <kernel/func.h>

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

#include <drivers/keyb.h>

#include <sys/mount.h>

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

/* -- */

int __register_sub_init_prologue(void)
{
  return 0;
}

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,TRUE);
  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,TRUE);
  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);
    }
  }
   
  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();
  cprintf("CTRL-C pressed!\n");
  sys_end();
}