<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>change log for examples-v2 (2011-03-11)</title>
</head>
<body text='#000000' bgcolor='#ffffff'>
<a name='cs1'></a>
<table border='0' cellspacing='0' cellpadding='5' width='100%' bgcolor='#eeeeee'>
<tr><td colspan='3' bgcolor='#dddddd'>
 <font color='#bb2222'><strong>joel</strong></font>
</td></tr>
<tr><td colspan='3' bgcolor='#dddddd'><pre>2011-03-11 Joel Sherrill <joel.sherrill@oarcorp.com>

        * fat_ramdisk/.cvsignore, fat_ramdisk/Makefile, fat_ramdisk/README,
        fat_ramdisk/init.c, fat_ramdisk/rootfs/shell-init: New files.
</pre></td></tr>
<tr><td width='1%'><a href="http://www.rtems.com/cgi-bin/viewcvs.cgi//examples-v2/file_io/ChangeLog.diff?r1=text&tr1=1.5&r2=text&tr2=1.6&diff_format=h">M</a></td><td width='1%'>1.6</td><td width='100%'>file_io/ChangeLog</td></tr>
<tr><td width='1%'><a href="http://www.rtems.com/cgi-bin/viewcvs.cgi//examples-v2/file_io/fat_ramdisk/.cvsignore?rev=1.1&content-type=text/vnd.viewcvs-markup">A</a></td><td width='1%'><font color="#000088">1.1</font></td><td width='100%'><font color="#000088">file_io/fat_ramdisk/.cvsignore</font></td></tr>
<tr><td width='1%'><a href="http://www.rtems.com/cgi-bin/viewcvs.cgi//examples-v2/file_io/fat_ramdisk/Makefile?rev=1.1&content-type=text/vnd.viewcvs-markup">A</a></td><td width='1%'><font color="#000088">1.1</font></td><td width='100%'><font color="#000088">file_io/fat_ramdisk/Makefile</font></td></tr>
<tr><td width='1%'><a href="http://www.rtems.com/cgi-bin/viewcvs.cgi//examples-v2/file_io/fat_ramdisk/README?rev=1.1&content-type=text/vnd.viewcvs-markup">A</a></td><td width='1%'><font color="#000088">1.1</font></td><td width='100%'><font color="#000088">file_io/fat_ramdisk/README</font></td></tr>
<tr><td width='1%'><a href="http://www.rtems.com/cgi-bin/viewcvs.cgi//examples-v2/file_io/fat_ramdisk/init.c?rev=1.1&content-type=text/vnd.viewcvs-markup">A</a></td><td width='1%'><font color="#000088">1.1</font></td><td width='100%'><font color="#000088">file_io/fat_ramdisk/init.c</font></td></tr>
<tr><td width='1%'><a href="http://www.rtems.com/cgi-bin/viewcvs.cgi//examples-v2/file_io/fat_ramdisk/rootfs/shell-init?rev=1.1&content-type=text/vnd.viewcvs-markup">A</a></td><td width='1%'><font color="#000088">1.1</font></td><td width='100%'><font color="#000088">file_io/fat_ramdisk/rootfs/shell-init</font></td></tr>
</table>
<pre>
<font color='#006600'>diff -u examples-v2/file_io/ChangeLog:1.5 examples-v2/file_io/ChangeLog:1.6
--- examples-v2/file_io/ChangeLog:1.5   Fri Mar 11 11:35:58 2011
+++ examples-v2/file_io/ChangeLog       Fri Mar 11 12:37:57 2011
</font><font color='#997700'>@@ -1,5 +1,10 @@
</font> 2011-03-11        Joel Sherrill <joel.sherrill@oarcorp.com>
 
<font color='#000088'>+   * fat_ramdisk/.cvsignore, fat_ramdisk/Makefile, fat_ramdisk/README,
+       fat_ramdisk/init.c, fat_ramdisk/rootfs/shell-init: New files.
+
+2011-03-11     Joel Sherrill <joel.sherrill@oarcorp.com>
+
</font>   * Makefile: Add new example of untar to load initial contents of IMFS.
        * crc/.cvsignore, crc/LICENSE, crc/Makefile, crc/README, crc/crc.h,
        crc/crc_32.c, crc/init.c, crc/sniptype.h, crc/rootfs/image.img: New

<font color='#006600'>diff -u /dev/null examples-v2/file_io/fat_ramdisk/.cvsignore:1.1
--- /dev/null   Fri Mar 11 13:10:04 2011
+++ examples-v2/file_io/fat_ramdisk/.cvsignore  Fri Mar 11 12:37:57 2011
</font><font color='#997700'>@@ -0,0 +1,4 @@
</font><font color='#000088'>+o-optimize
+FilesystemImage
+FilesystemImage.c
+FilesystemImage.h
</font>
<font color='#006600'>diff -u /dev/null examples-v2/file_io/fat_ramdisk/Makefile:1.1
--- /dev/null   Fri Mar 11 13:10:04 2011
+++ examples-v2/file_io/fat_ramdisk/Makefile    Fri Mar 11 12:37:57 2011
</font><font color='#997700'>@@ -0,0 +1,41 @@
</font><font color='#000088'>+#
+#  $Id$
+#
+
+#
+#  RTEMS_MAKEFILE_PATH is typically set in an environment variable
+#
+
+PGM=${ARCH}/fat_ramdisk.exe
+
+# optional managers required
+MANAGERS=all
+
+# C source names
+CSRCS = init.c FilesystemImage.c
+COBJS = $(CSRCS:%.c=${ARCH}/%.o)
+
+CLEAN_ADDITIONS += stamp-fs-image
+CLEAN_ADDITIONS += FilesystemImage FilesystemImage.c FilesystemImage.h
+
+include $(RTEMS_MAKEFILE_PATH)/Makefile.inc
+include $(RTEMS_CUSTOM)
+include $(PROJECT_ROOT)/make/leaf.cfg
+
+OBJS= $(COBJS) $(CXXOBJS) $(ASOBJS)
+
+all:    ${ARCH} $(OBJS) $(PGM)
+
+$(ARCH)/init.o: init.c stamp-fs-image
+
+FilesystemImage: $(ARCH) rootfs/shell-init
+       cd rootfs ; \
+           tar cf ../FilesystemImage --exclude CVS --exclude .cvsignore .
+
+stamp-fs-image: $(ARCH) FilesystemImage
+       $(PROJECT_ROOT)/bin/rtems-bin2c FilesystemImage FilesystemImage
+       ls -l Filesystem*
+       touch stamp-fs-image
+
+$(PGM): $(OBJS)
+       $(make-exe)
</font>
<font color='#006600'>diff -u /dev/null examples-v2/file_io/fat_ramdisk/README:1.1
--- /dev/null   Fri Mar 11 13:10:04 2011
+++ examples-v2/file_io/fat_ramdisk/README      Fri Mar 11 12:37:57 2011
</font><font color='#997700'>@@ -0,0 +1,9 @@
</font><font color='#000088'>+#
+#  $Id$
+#
+
+This is a simple example which illustrates how to use the
+In-Memory File System (IMFS) in conjunction with "untar" to
+load the initial contents.
+
+Thanks to Gedare Bloom for the code this is based upon.
</font>
<font color='#006600'>diff -u /dev/null examples-v2/file_io/fat_ramdisk/init.c:1.1
--- /dev/null   Fri Mar 11 13:10:04 2011
+++ examples-v2/file_io/fat_ramdisk/init.c      Fri Mar 11 12:37:57 2011
</font><font color='#997700'>@@ -0,0 +1,163 @@
</font><font color='#000088'>+/*
+ *  COPYRIGHT (c) 1989-2011.
+ *  On-Line Applications Research Corporation (OAR).
+ *
+ *  The license and distribution terms for this file may be
+ *  found in the file LICENSE in this distribution or at
+ *  http://www.rtems.com/license/LICENSE.
+ *
+ *  $Id$
+ */
+
+
+#include <bsp.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <rtems/ramdisk.h>
+#include <rtems/error.h>
+#include <rtems/untar.h>
+#include <rtems/shell.h>
+
+#include "FilesystemImage.h"
+
+
+/**
+ * The RAM Disk configuration.
+ */
+rtems_ramdisk_config rtems_ramdisk_configuration[] =
+{
+  {
+    block_size: 256,
+    block_num:  1024,
+    location:   NULL
+  }
+};
+
+/**
+ * The number of RAM Disk configurations.
+ */
+size_t rtems_ramdisk_configuration_size = 1;
+
+/**
+ * Create the RAM Disk Driver entry.
+ */
+rtems_driver_address_table rtems_ramdisk_io_ops = {
+  initialization_entry: ramdisk_initialize,
+  open_entry:           rtems_blkdev_generic_open,
+  close_entry:          rtems_blkdev_generic_close,
+  read_entry:           rtems_blkdev_generic_read,
+  write_entry:          rtems_blkdev_generic_write,
+  control_entry:        rtems_blkdev_generic_ioctl
+};
+
+#define RTEMS_DRIVER_AUTO_MAJOR (0)
+
+int setup_ramdisk (const char* mntpath)
+{
+  rtems_device_major_number major;
+  rtems_status_code         sc;
+<span style="background-color: #FF0000">  </span>
+  /*
+   * Register the RAM Disk driver.
+   */
+  printf ("Register RAM Disk Driver: ");
+  sc = rtems_io_register_driver (RTEMS_DRIVER_AUTO_MAJOR,
+                                 &rtems_ramdisk_io_ops,
+                                 &major);
+  if (sc != RTEMS_SUCCESSFUL) {
+    printf ("error: ramdisk driver not initialised: %s\n",
+            rtems_status_text (sc));
+    return 1;
+  }
+
+  printf ("successful\n");
+  return 0;
+}
+
+/**
+ * Run the /shell-init script.
+ */
+void shell_init_script(void)
+{
+  rtems_status_code sc;
+  printf("Running /shell-init....\n\n");
+  sc = rtems_shell_script("fstst", 60 * 1024, 160, "/shell-init", "stdout",
+                           0, 1, 1);
+  if (sc != RTEMS_SUCCESSFUL)
+    printf("error: running shell script: %s (%d)\n",
+             rtems_status_text (sc), sc);
+}
+
+/**
+ * Start the RTEMS Shell.
+ */
+void shell_start ()
+{
+  rtems_status_code sc;
+  printf ("Starting shell....\n\n");
+  sc = rtems_shell_init ("fstst", 60 * 1024, 150, "/dev/console", 0, 1, NULL);
+  if (sc != RTEMS_SUCCESSFUL)
+    printf ("error: starting shell: %s (%d)\n", rtems_status_text (sc), sc);
+}
+
+
+
+rtems_task Init(
+  rtems_task_argument ignored
+)
+{
+  int ret;
+
+  puts( "\n\n*** ramdisk/fat example ***" );
+
+  printf("Unpacking tar filesystem\nThis may take awhile...\n");
+  if(Untar_FromMemory(FilesystemImage, FilesystemImage_size) != 0) {
+    printf("Can't unpack tar filesystem\n");
+    exit(1);
+  }
+
+  ret = setup_ramdisk ("/mnt/ramdisk");
+  if (ret)
+    exit (ret);
+
+  shell_init_script();
+  shell_start();
+
+  printf( "*** end of demonstration ***\n" );
+  exit( 0 );
+}
+
+
+/* configuration */
+
+#define CONFIGURE_SHELL_COMMANDS_INIT
+#define CONFIGURE_SHELL_COMMANDS_ALL
+#define CONFIGURE_SHELL_MOUNT_MSDOS
+
+#include <rtems/shellconfig.h>
+
+/* drivers */
+#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
+#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
+
+/* filesystem */
+#define CONFIGURE_USE_IMFS_AS_BASE_FILESYSTEM
+#define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS   40
+#define CONFIGURE_IMFS_MEMFILE_BYTES_PER_BLOCK    512
+#define CONFIGURE_MAXIMUM_DRIVERS                  10
+
+#define CONFIGURE_APPLICATION_NEEDS_LIBBLOCK
+#define CONFIGURE_SWAPOUT_TASK_PRIORITY            10
+
+#define CONFIGURE_MAXIMUM_TASKS                    rtems_resource_unlimited (10)
+#define CONFIGURE_MAXIMUM_SEMAPHORES               rtems_resource_unlimited (10)
+#define CONFIGURE_MAXIMUM_MESSAGE_QUEUES           rtems_resource_unlimited (5)
+#define CONFIGURE_MAXIMUM_PARTITIONS               rtems_resource_unlimited (2)
+#define CONFIGURE_UNIFIED_WORK_AREAS
+#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
+
+#define CONFIGURE_INIT
+#include <rtems/confdefs.h>
+/* end of file */
</font>
<font color='#006600'>diff -u /dev/null examples-v2/file_io/fat_ramdisk/rootfs/shell-init:1.1
--- /dev/null   Fri Mar 11 13:10:04 2011
+++ examples-v2/file_io/fat_ramdisk/rootfs/shell-init   Fri Mar 11 12:37:57 2011
</font><font color='#997700'>@@ -0,0 +1,3 @@
</font><font color='#000088'>+mkdos /dev/ramdisk0
+mkdir /rd
+mount -t msdos /dev/ramdisk0 /rd
</font></pre>
<p> </p>

<p>--<br />
<small>Generated by <a href="http://www.codewiz.org/projects/index.html#loginfo">Deluxe Loginfo</a> 2.122 by Bernardo Innocenti <bernie@develer.com></small></p>
</body>
</html>