Blame |
Last modification |
View Log
| RSS feed
/*
* Project: HARTIK (HA-rd R-eal TI-me K-ernel)
*
* Coordinators: Giorgio Buttazzo <giorgio@sssup.it>
* Gerardo Lamastra <gerardo@sssup.it>
*
* Authors : Massimiliano Giorgi <massy@hartik.sssup.it>
* (see authors.txt for full list of hartik's authors)
*
* ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy)
*
* http://www.sssup.it
* http://retis.sssup.it
* http://hartik.sssup.it
*/
/*
* Copyright (C) 2000 Massimiliano Giorgi
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
/*
* CVS : $Id: hello.c,v 1.1.1.1 2004-05-24 18:03:44 giacomo Exp $
*
* File: $File$
* Revision: $Revision: 1.1.1.1 $
* Last update: $Date: 2004-05-24 18:03:44 $
*/
/*
* Example of tracer initialization.
*/
#include <ll/i386/cons.h>
#include <kernel/func.h>
#include <tracer.h>
#include <fs/bdevinit.h>
#include <fs/fsinit.h>
#include <fs/bdev.h>
#include <drivers/keyb.h>
#include <trace.h>
#include <queues.h>
#include <sys/mount.h>
#include <stddef.h>
/*
this example use initfs.c to initialize the system; this file define
the following two function.
__kernel_register_levels__(), must initialize all kernel modules,
it has this structure:
{
__register_sub_init_prologue();
... modules initialization....
__register_sub_init();
}
__init__(void *arg) is called when the first task is created
and must call the main():
{
... drivers initialization ....
__bdev_sub_init();
__fs_sub_init();
call_main()
}
*/
/*
* This function is called before all other modules initialization because
* all modules that need the tracer must follow tracer initialization.
*/
int __register_sub_init_prologue
(void)
{
/* the first functions to call... parameters can be passed */
TRC_init_phase1
(NULL
);
/* all the tracer queues must be registrated (in this case only */
/* a dummy queue is initialized) */
trc_register_dummy_queue
();
/* the queues must be created (only one in this example) */
trc_create_queue
(TRC_DUMMY_QUEUE
,NULL
);
/* events can be dispatch to a queue (nothing in this case) */
return 0;
}
/*
* This function is called after all other modules initialization
* functions... notjing to do.
*/
int __register_sub_init
(void)
{
return 0;
}
__dev_t root_device
;
__dev_t temp_device
;
/*
* Now the system is running... we have to initialize the block device
* drivers
*/
int __bdev_sub_init
(void)
{
BDEV_PARMS bdev
=BASE_BDEV
;
/* This to initialize the block device drivers... a NULL can be passed */
/* to the bdev_init() functions */
bdev_def_showinfo
(bdev
,FALSE
);
bdev_init
(&bdev
);
/* The following phase ca be made in several way: we must decide the */
/* device that we want mount as root... we use the bdev_find_byname() */
/* functions to find a specific device */
root_device
=bdev_find_byname
("ide/hda1");
if (root_device
<0) {
cprintf
("can't find root device to mount on /!!!\n");
sys_end
();
return -1;
}
/* Well, we want a device to mount into /TEMP */
temp_device
=bdev_find_byname
("ide/hdb3");
if (temp_device
<0) {
cprintf
("can't find a filesystem to mount on /TEMP!!!\n");
sys_end
();
return -1;
}
return 0;
}
/*
* This is the real filesystem initialization!
*/
int __fs_sub_init
(void)
{
FILESYSTEM_PARMS fs
=BASE_FILESYSTEM
;
extern int libc_initialize
(void);
int res
;
struct mount_opts opts
;
/* We set the root device and call the filesystem_init() function */
filesystem_def_rootdevice
(fs
,root_device
);
filesystem_def_fs
(fs
,FS_MSDOS
);
filesystem_def_showinfo
(fs
,FALSE
);
filesystem_init
(&fs
);
/* We must initialize the libC if we use it */
libc_initialize
();
/* We have choose to mount the second partiotion into the /TEMP */
/* directory with read/write privilegies (this step is not required) */
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
);
}
}
/* NOW we call the tracer initialization phase 2!!! */
/* It must FOLLOW the filesystem initialization... (this function */
/* can be called after the call to filesystem_init() functions but */
/* we do it here because we want be able to write into the /TEMP */
/* directory! */
TRC_init_phase2
();
return 0;
}
void ctrlc_exit
(KEY_EVT
*k
)
{
sys_end
();
}
int main
(int argc
,char *argv
[])
{
cprintf
("\nHello, world!\n");
return 0;
}