Mr Thomas, one more question please... [Initializing Partition Table (?)]

Thomas Doerfler Thomas.Doerfler at imd-systems.de
Tue Jul 27 09:49:17 UTC 2004


Hello,

yes, I think the IDE and ATA driver should 
initialize on your system. So in the "fileio" menu, 
you should call "fileio_part_table_initialize" (menu 
letter 'p') and then "fileio_fsmount" (menu letter 
'f'). Then your first harddisk partition with FAT 
filesystem should be mounted to /mnt/hda.

What messages do you get, when you call 
"fileio_mount"? What kind of harddisk do you use and 
how is it partitioned?

wkr,
Thomas.


> Hello Mr Thomas and thank you for your help,
> 
> I have the following instruction in my rtems program
> and I realize that the RTEMS_BSP_HAS_IDE_DRIVER is
> defined!
> 
> rtems_driver_address_table Device_drivers[] =
> {
>  	CONSOLE_DRIVER_TABLE_ENTRY
>  	,CLOCK_DRIVER_TABLE_ENTRY
> #ifdef RTEMS_BSP_HAS_IDE_DRIVER
>  	,IDE_CONTROLLER_DRIVER_TABLE_ENTRY
>  	/* important: ATA driver must be after ide drivers
>  */
> 	,ATA_DRIVER_TABLE_ENTRY 
> #endif
> };
> 
> But I cant see the hda anyway... :-(
> That instruction is enough to load and initialize the
> hardisk driver?
> 
> So, please, could you give a quick look at the
> scaletton of my program... I cant solve this problem
> alone... Did you saw anything suspicious? Do I have to
> include any special parameter when I configure and
> build the rtems to access hard drive? 
> 
> 
> Thank you Mr Thomas...
> 
> Joe
> 
> 
> PS: My program is in one file only called hello.c and
> i want to use POSIX api as much as possible...
> ==================================================================
> 
> #define CONFIGURE_INIT
> 
> #include <bsp.h> /* for device driver prototypes */
> #include <libchip/ata.h> /* for ata driver prototype
> */
> #include <libchip/ide_ctrl.h> /* for general ide
> driver prototype */
> 
> #define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
> #define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
> #define CONFIGURE_USE_IMFS_AS_BASE_FILESYSTEM
> #define CONFIGURE_HAS_OWN_DEVICE_DRIVER_TABLE
> 
> #ifdef CONFIGURE_INIT
> rtems_driver_address_table Device_drivers[] =
> 	{
> 	CONSOLE_DRIVER_TABLE_ENTRY
> 	,CLOCK_DRIVER_TABLE_ENTRY
> #ifdef RTEMS_BSP_HAS_IDE_DRIVER
> 	,IDE_CONTROLLER_DRIVER_TABLE_ENTRY
> 	/* important: ATA driver must be after ide drivers */
> 	,ATA_DRIVER_TABLE_ENTRY
> #endif
> 	};
> 
> #include <rtems/bdbuf.h>
> rtems_bdbuf_config rtems_bdbuf_configuration[] = {
>   {512,128,NULL}
> };
> int rtems_bdbuf_configuration_size =(
> sizeof(rtems_bdbuf_configuration)
> 				     /sizeof(rtems_bdbuf_configuration[0]));
> #endif
> 
> #include <unistd.h>
> #include <rtems/error.h>
> #include <dosfs.h>
> #include <ctype.h>
> #include <rtems/ide_part_table.h>
> #include <rtems/libcsupport.h>
> #include "fsmount.h"
> 
> #include <rtems.h>
> #include <stdlib.h>
> #include <stdio.h>
> #include <string.h>
> #include <errno.h>
> #include <semaphore.h>
> #include <pthread.h>
> #include <fcntl.h>
> #include <time.h>
> #include <rtems/posix/timer.h>
> 
> #define print_time(_s1, _tb, _s2) \
>   do { \
>     printf( "%s%02d:%02d:%02d   %02d/%02d/%04d%s", \
>        _s1, (_tb)->hour, (_tb)->minute, (_tb)->second,
> \
>        (_tb)->month, (_tb)->day, (_tb)->year, _s2 ); \
>     fflush(stdout); \
>   } while ( 0 )
> 
> /*
>  *  Macro to print an task name that is composed of
> ASCII characters.
>  *
>  */
> 
> #define put_name( _name, _crlf ) \
>   do { \
>     rtems_unsigned32 c0, c1, c2, c3; \
>     \
>     c0 = ((_name) >> 24) & 0xff; \
>     c1 = ((_name) >> 16) & 0xff; \
>     c2 = ((_name) >> 8) & 0xff; \
>     c3 = (_name) & 0xff; \
>     putchar( (char)c0 ); \
>     if ( c1 ) putchar( (char)c1 ); \
>     if ( c2 ) putchar( (char)c2 ); \
>     if ( c3 ) putchar( (char)c3 ); \
>     if ( (_crlf) ) \
>       putchar( '\n' ); \
>   } while (0)
> 
> /*
>  *  static inline routine to make obtaining ticks per
> second easier.
>  */
> 
> static inline rtems_unsigned32 get_ticks_per_second(
> void )
> {
>   rtems_interval ticks_per_second;
>   (void) rtems_clock_get(
> RTEMS_CLOCK_GET_TICKS_PER_SECOND, &ticks_per_second );
>  return ticks_per_second;
> }
> 
> 
> /*
>  *  This allows us to view the "Test_task"
> instantiations as a set
>  *  of numbered tasks by eliminating the number of
> application
>  *  tasks created.
>  *
>  *  In reality, this is too complex for the purposes
> of this
>  *  example.  It would have been easier to pass a task
> argument. :)
>  *  But it shows how rtems_id's can sometimes be used.
>  */
> 
> #define task_number( tid ) \
>   ( rtems_get_index( tid ) - \
>     
> rtems_configuration_get_rtems_api_configuration()->number_of_initialization_tasks
> )
> 
> /* end of include file */
> 
> 
> /*
>  * Table of FAT file systems that will be mounted
>  * with the "fsmount" function.
>  * See cpukit/libmisc/fsmount for definition of fields
>  */
> fstab_t fs_table[] = {
>   {
>     "/dev/hda1","/mnt/hda",
>     &msdos_ops, RTEMS_FILESYSTEM_READ_WRITE,
>     FSMOUNT_MNT_OK | FSMOUNT_MNTPNT_CRTERR |
> FSMOUNT_MNT_FAILED,
>     0
>   }/*,
>   {
>     "/dev/hda2","/mnt/hda",
>     &msdos_ops, RTEMS_FILESYSTEM_READ_WRITE,
>     FSMOUNT_MNT_OK | FSMOUNT_MNTPNT_CRTERR |
> FSMOUNT_MNT_FAILED,
>     0
>   },
>   {
>     "/dev/hda3","/mnt/hda",
>     &msdos_ops, RTEMS_FILESYSTEM_READ_WRITE,
>     FSMOUNT_MNT_OK | FSMOUNT_MNTPNT_CRTERR |
> FSMOUNT_MNT_FAILED,
>     0
>   },
>   {
>     "/dev/hda4","/mnt/hda",
>     &msdos_ops, RTEMS_FILESYSTEM_READ_WRITE,
>     FSMOUNT_MNT_OK | FSMOUNT_MNTPNT_CRTERR |
> FSMOUNT_MNT_FAILED,
>     0
>   }*/
> };
> 
> #ifndef MIN
> #define MIN(a,b) (((a) > (b)) ? (b) : (a))
> #endif
> 
> #define USE_SHELL
> 
> #ifdef USE_SHELL
> #include <rtems/shell.h>
> 
> void fileio_start_shell(void)
> {
>   ...
> }
> 
> #endif /* USE_SHELL */
> 
> void fileio_print_free_heap(void)
> {
>   ...
> }
> 
> 
> void fileio_part_table_initialize(void)
> {
>   rtems_status_code rc;
>   fileio_print_free_heap();
> 
>   rc = rtems_ide_part_table_initialize("/dev/hda");
>   printf("\n rtems_ide_part_table_initialize(/dev/hda)
> with result=%d and errno=%d
> (%s)\n",rc,errno,strerror(errno));
> 
>   fileio_print_free_heap();
> }
> 
> void fileio_fsmount(void)
> {
>   rtems_status_code rc;
> 
>   printf(" =========================\n");
>   printf(" Process fsmount table\n");
>   printf(" =========================\n");
>   fileio_print_free_heap();
>   /*
>    * call function
>    */
>   rc = rtems_fsmount( fs_table,
> 		      sizeof(fs_table)/sizeof(fs_table[0]),
> 		      NULL);
> 
>   printf("*** RESULT=%d, errno =
> %d(%s)\n",rc,errno,strerror(errno));
> 
>   fileio_print_free_heap();
> }
> 
> void fileio_list_file(void)
> {
>   ...
> }
> 
> /*
>  * convert a size string (like 34K or 12M) to actual
> byte count
>  */
> boolean fileio_str2size(const char *str,unsigned32
> *res_ptr)
> {
>   ...
> }
> 
> void fileio_write_file(void)
> {
>   ...
> }
> 
> void fileio_read_file(void)
> {
>   ...
> }
> 
> void fileio_menu (void)
> {
>   char inbuf[10];
> 
>   /*
>    * Wait for characters from console terminal
>    */
>   for (;;)
>   {
>     printf(" =========================\n");
>     printf(" RTEMS FILE I/O Test Menu \n");
>     printf(" =========================\n");
>     printf("   p -> part_table_initialize\n");
>     printf("   f -> mount all disks in fs_table\n");
>     printf("   l -> list  file\n");
>     printf("   r -> read  file\n");
>     printf("   w -> write file\n");
> #ifdef USE_SHELL
>     printf("   s -> start shell\n");
> #endif
>     printf("   Enter your selection ==>");
> 
>     inbuf[0] = '\0';
> 
>     fgets(inbuf,sizeof(inbuf),stdin);
>     switch (inbuf[0])
>     {
>     case 'l':
>       fileio_list_file ();
>       break;
>     case 'r':
>       fileio_read_file ();
>       break;
>     case 'w':
>       fileio_write_file ();
>       break;
>     case 'p':
>       fileio_part_table_initialize ();
>       break;
>     case 'f':
>       fileio_fsmount ();
>       break;
> #ifdef USE_SHELL
>     case 's':
>       fileio_start_shell ();
>       break;
> #endif
>     default:
>       printf("Selection `%c` not
> implemented\n",inbuf[0]);
>       break;
>     }
>   }
>   exit (0);
> }
> 
> int menu_tid;
> 
> void POSIX_Init(void* args)
> {
> 	puts( "\n\n*** FILE I/O SAMPLE AND TEST ***" );
> 	fileio_menu();
> }
> 
> 
> #define CONFIGURE_POSIX_INIT_THREAD_TABLE
> #define CONFIGURE_MAXIMUM_POSIX_THREADS	10
> #define CONFIGURE_MAXIMUM_POSIX_MUTEXES	5
> #define CONFIGURE_MAXIMUM_POSIX_CONDITION_VARIABLES	5
> #define CONFIGURE_MAXIMUM_POSIX_KEYS	5
> #define CONFIGURE_MAXIMUM_POSIX_TIMERS	5
> #define CONFIGURE_MAXIMUM_POSIX_QUEUED_SIGNALS	2000
> #define CONFIGURE_MAXIMUM_POSIX_MESSAGE_QUEUES	5
> #define CONFIGURE_MAXIMUM_POSIX_SEMAPHORES	10
> #define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 10
> 
> #include <confdefs.h>
> 
> 
> 
> ===========================================================================================
> 
> 
> --- Thomas Doerfler <Thomas.Doerfler at imd-systems.de>
> wrote:
> 
> > Hello Joe,
> > 
> > it seems you do not have a IDE driver or it is not
> > initialized.
> > 
> > I have also written a sample/test application called
> > "fileio" 
> > (in c/src/tests/samples/fileio). If you look at the
> > "system.h" 
> > file, you will see, that there is a special device
> > driver table:
> > 
> > rtems_driver_address_table Device_drivers[] =
> > 	{
> > 	CONSOLE_DRIVER_TABLE_ENTRY
> > 	,CLOCK_DRIVER_TABLE_ENTRY
> > #ifdef RTEMS_BSP_HAS_IDE_DRIVER
> > 	,IDE_CONTROLLER_DRIVER_TABLE_ENTRY
> > 	/* important: ATA driver must be after ide drivers
> > */
> > 	,ATA_DRIVER_TABLE_ENTRY 
> > #endif
> > 	};
> > 
> > If the last two entries are missing, hard disk
> > access is not 
> > available.
> > 
> > wkr,
> > Thomas.
> > 
> > > Hi all,
> > > 
> > > I am trying to access my hard disk and floppy
> > using
> > > rtems. I am using the fsmount source code of
> > > Thomas.Doerfler at imd-systems.de.
> > > 
> > > First thing I am trying is to initialize partition
> > > table.
> > > (should be partition table initialization executed
> > > after mount operation??? I am trying it before!)  
> > > 
> > > I am using rtems 4.6 in a linux mandrake box in a
> > i386
> > > BSP686!
> > > 
> > > The source code I have is the following:
> > > 
> > > main(...)
> > > {
> > >    rc =
> > rtems_ide_part_table_initialize("/dev/hda");
> > > }
> > > 
> > > I can see it failling in the for cicle of the
> > > rtems_ide_part_table_initialize() function in the
> > > ide_part_table.c file. It fails when it try to get
> > the
> > > partition table! The source of the failure is in
> > the
> > > stat() function which doesnt find the hda!
> > > 
> > > If I list all existing directories in the /dev I
> > see
> > > this hierarchie:
> > > 
> > > /
> > > ---dev
> > > ------console
> > > ------ide
> > > 
> > > 
> > > Where is the hda???
> > > Should I try to initialize partition table for
> > > /dev/hda or should I initialize partition table
> > for
> > > /dev/ide ? 
> > > Why hda doesnt exists?
> > > 
> > > If I try to initialize partition table for
> > /dev/ide it
> > > works well but it raises an exception 13 at the
> > end
> > > and freezes...
> > > 
> > > What I am doing wrong?
> > > Any help?
> > > 
> > > Is there any readme or tutorial or how-to
> > explaining
> > > How to mount msdos file system in RTEMS?
> > > 
> > > Many thanks,
> > > 
> > > Joe
> > > (rtems beginner)
> > > 
> > > 
> > > 
> > > 
> > > 
> > > 	
> > > 		
> > > __________________________________
> > > Do you Yahoo!?
> > > New and Improved Yahoo! Mail - 100MB free storage!
> > > http://promotions.yahoo.com/new_mail 
> > --------------------------------------------
> > IMD Ingenieurbuero fuer Microcomputertechnik
> > Thomas Doerfler           Herbststrasse 8
> > D-82178 Puchheim          Germany
> > email:    Thomas.Doerfler at imd-systems.de
> > PGP public key available at: http://www.imd-
> > systems.de/pgp_keys.htm
> > 
> > 
> 
> 
> 
> 		
> __________________________________
> Do you Yahoo!?
> Yahoo! Mail - 50x more storage than other providers!
> http://promotions.yahoo.com/new_mail

--------------------------------------------
IMD Ingenieurbuero fuer Microcomputertechnik
Thomas Doerfler           Herbststrasse 8
D-82178 Puchheim          Germany
email:    Thomas.Doerfler at imd-systems.de
PGP public key available at: http://www.imd-
systems.de/pgp_keys.htm




More information about the users mailing list