Subversion Repositories shark

Rev

Rev 1655 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1655 giacomo 1
 
2
#include <kernel/func.h>
3
 
4
#include <fs/bdevinit.h>
5
#include <fs/fsinit.h>
6
#include <fs/bdev.h>
7
 
8
#include <drivers/keyb.h>
9
 
10
#include <sys/mount.h>
11
 
12
#include <fcntl.h>
13
#include <unistd.h>
14
#include <errno.h>
15
 
16
/* -- */
17
 
18
int __register_sub_init_prologue(void)
19
{
20
  return 0;
21
}
22
 
23
int __register_sub_init(void)
24
{
25
  return 0;
26
}
27
 
28
/* -- */
29
 
30
__dev_t root_device;
31
__dev_t temp_device;
32
 
33
int choose_root_callback(__dev_t dev,__uint8_t fs)
34
{
35
  if (fs==FS_MSDOS) return dev;
36
  return -1;
37
}
38
 
39
int choose_temp_callback(__dev_t dev,__uint8_t fs)
40
{
41
  static int flag=0;
42
  if (fs==FS_MSDOS) {
43
    if (flag) return dev;
44
    flag=1;
45
  }
46
  return -1;
47
}
48
 
49
/* -- */
50
 
51
//extern int bdev_scan_devices(int(*callback)(__dev_t,__uint8_t));
52
 
53
int __bdev_sub_init(void)
54
{
55
  BDEV_PARMS bdev=BASE_BDEV;
56
 
57
  bdev_def_showinfo(bdev,TRUE);
58
  bdev_init(&bdev);
59
 
60
  root_device=bdev_scan_devices(choose_root_callback);
61
  if (root_device<0) {
62
    cprintf("can't find root device to mount on /!!!\n");
63
    sys_end();
64
    return -1;
65
  }
66
 
67
  temp_device=bdev_scan_devices(choose_temp_callback);
68
  if (temp_device<0) {
69
    cprintf("can't find a filesystem to mount on /TEMP!!!\n");
70
  }
71
 
72
  return 0;
73
}
74
 
75
/* -- */
76
 
77
extern int libc_initialize(void);
78
 
79
int __fs_sub_init(void)
80
{
81
  FILESYSTEM_PARMS fs=BASE_FILESYSTEM;
82
  struct mount_opts opts;
83
  int res;
84
 
85
  filesystem_def_rootdevice(fs,root_device);
86
  filesystem_def_fs(fs,FS_MSDOS);
87
  filesystem_def_showinfo(fs,TRUE);
88
  filesystem_init(&fs);
89
 
90
  libc_initialize();
91
 
92
  if (temp_device>=0) {
93
    memset(&opts,0,sizeof(struct mount_opts));
94
    opts.flags=MOUNT_FLAG_RW;
95
    res=mount(temp_device,FS_MSDOS,"/TEMP",&opts);
96
    if (res!=0) {
97
      cprintf("can't mount XXX on /TEMP (errno: %i)\n",errno);
98
    }
99
  }
100
 
101
  return 0;
102
}
103
 
104
/* -- */
105
 
106
 
107
/* -- */
108
 
109
void ctrlc_exit(KEY_EVT *k)
110
{
111
  extern void dump_sem_table(void);
112
  extern void dump_nop_table(void);
113
  //dump_sem_table();
114
  //dump_nop_table();
115
  cprintf("CTRL-C pressed!\n");
116
  sys_end();
117
}