diff -ruN /tmp/sos-code-article7.5/bootstrap/multiboot.h ../sos-code-article7.5/bootstrap/multiboot.h
--- /tmp/sos-code-article7.5/bootstrap/multiboot.h	2005-04-27 20:17:12.000000000 +0200
+++ ../sos-code-article7.5/bootstrap/multiboot.h	2005-06-06 20:47:18.000000000 +0200
@@ -47,10 +47,12 @@
 
 #include <sos/types.h>
 
+
 /* The address of the stack of the bootstrap thread */
 extern sos_vaddr_t bootstrap_stack_bottom;
 extern sos_size_t bootstrap_stack_size;
 
+
 /* Types.  */
 
 /* The Multiboot header.  */
diff -ruN /tmp/sos-code-article7.5/drivers/zero.c ../sos-code-article7.5/drivers/zero.c
--- /tmp/sos-code-article7.5/drivers/zero.c	2005-04-27 20:17:13.000000000 +0200
+++ ../sos-code-article7.5/drivers/zero.c	2005-06-06 20:47:20.000000000 +0200
@@ -109,7 +109,7 @@
   zero_resource
     = (struct zero_mapped_resource*)
     sos_umem_vmm_get_mapped_resource_of_vr(vr)->custom_data;
-  
+
   /* Decrement ref coutner */
   SOS_ASSERT_FATAL(zero_resource->ref_cnt > 0);
   zero_resource->ref_cnt --;
@@ -121,9 +121,8 @@
       struct zero_mapped_page *zmp;
       list_collapse(zero_resource->list_mapped_pages, zmp)
 	{
-	  /* No need to free the underlying physical pages, since they
-	     should have been unmapped just before this unref is
-	     called */
+	  /* Unreference the underlying physical page */
+	  sos_physmem_unref_physpage(zmp->ppage_paddr);
 	  sos_kfree((sos_vaddr_t)zmp);
 	}
 
@@ -169,6 +168,7 @@
 				  SOS_PAGE_ALIGN_INF(uaddr),
 				  TRUE,
 				  vr_prot);
+
 	  return retval;
 	}
     }
@@ -182,7 +182,7 @@
       ppage_paddr = sos_physmem_ref_physpage_new(FALSE);
       if (! ppage_paddr)
 	return -SOS_ENOMEM;
-      
+
       retval = sos_paging_map(ppage_paddr,
 			      SOS_PAGE_ALIGN_INF(uaddr),
 			      TRUE,
@@ -286,6 +286,7 @@
   zmp->ppage_paddr = ppage_paddr;
 
   list_add_head(mr->list_mapped_pages, zmp);
+  sos_physmem_ref_physpage_at(ppage_paddr);
   return SOS_OK;
 }
 
diff -ruN /tmp/sos-code-article7.5/extra/bootsect.S ../sos-code-article7.5/extra/bootsect.S
--- /tmp/sos-code-article7.5/extra/bootsect.S	2005-04-27 20:17:13.000000000 +0200
+++ ../sos-code-article7.5/extra/bootsect.S	2005-06-06 20:47:22.000000000 +0200
@@ -1,10 +1,11 @@
 
 /*
- * @(#) $Id: bootsect.S,v 1.8 2004/11/20 16:00:11 d2 Exp $
+ * @(#) $Id: bootsect.S,v 1.11 2005/04/28 21:55:35 d2 Exp $
  * Description : Bootsecteur en syntaxe AT&T
  * Auteurs : Thomas Petazzoni & Fabrice Gautier & Emmanuel Marty
  *	     Jerome Petazzoni & Bernard Cassagne & coffeeman
- *	     David Decotigny
+ *	     David Decotigny (SOS integration for kernel size detection)
+ *           Christopher Goyet (RAM size determination through BIOS int 15H)
  * Bug reports to kos-misc@enix.org
  */
 
@@ -37,8 +38,8 @@
   *   valide
   * - Le bootsect verifie que le processeur est du type 386+
   * - Il charge le noyau depuis la disquette en memoire a partir de
-  *   0x1000 (LOAD_ADRESS). Le noyau peut au max tenir sur
-  *   SECTORS_TO_LOAD secteurs
+  *   0x1000 (LOAD_ADRESS). La place dispo est donc 0x9f000 - 0x1000 , soit
+  *   0x9E000, soit encore 1264 secteurs de 512 octets
   * - Il passe en pmode flat (apres ouverture a20)
   * - Il recopie le noyau (situe en LOAD_ADRESS) vers son adresse
   *   finale (FINAL_ADDRESS = 2Mo). La recopie se fait sur tout l'espace
@@ -67,8 +68,6 @@
 	/* Pour que gas genere du 16bits, afin que ca marche en realm */
 	.code16
 
-#define SECTORS_TO_LOAD 128 /* 64 ko */ /* MAX=1264 */
-
 /*
  * Parametres de la disquette. Comme c'est chiant de faire une
  * procedure de detection auto, et que ca prend de la place, on fait
@@ -88,7 +87,8 @@
 					  copier le bootsecteur */
 #define LOAD_ADRESS 0x01000  	       /* 1er chargement du systeme */
 #define LOAD_SEG (LOAD_ADRESS>>4)      /* Segment du 1er chargement du */
-#define MAX_KERN_LEN COPY_ADRESS-LOAD_ADRESS /* Taille noyau maxi */
+#define MAX_KERN_LEN (COPY_ADRESS-LOAD_ADRESS) /* Taille noyau maxi */
+#define MAX_KERN_SECTS ((MAX_KERN_LEN + 511) / 512) /* Nbre de secteurs maxi */
 
 /* IMPORTANT : Cette valeur DOIT etre identique a l'adresse presente
 	       dans sos.lds ! */
@@ -150,7 +150,21 @@
 	/* Efface l'ecran */
 	movb $0x0, %ah
 	movb $0x3, %al
-	int 	$0x10
+	int  $0x10
+
+	/* Verifie que le noyau n'est pas trop gros a charger */
+	cmpw $MAX_KERN_SECTS, (load_size)
+	jb sizeOk
+	movw $toobig, %si
+	call message
+	call halt
+
+sizeOk:	
+	/* Recupere la taille de la RAM */
+	mov $0xE801, %ax
+	int $0x15
+	movw %ax, (memsize1)
+	movw %bx, (memsize2)
 
 	/* Affiche les messages d'attente */
 	movw $loadkern, %si
@@ -313,6 +327,19 @@
 	movl %eax, %ss
 	movl $(stack + BOOT_STACK_SIZE), %ebp
 	movl %ebp, %esp
+
+/* passe les arguments a sos */                                       
+	xor %eax, %eax
+	xor %ebx, %ebx
+	movw (COPY_ADRESS+(memsize2)), %ax /*eax = num de block de 64KB apres 16MB*/
+	movw (COPY_ADRESS+(memsize1)), %bx /*ebx = num de block de 1KB entre 1MB et 16MB*/
+	movl $0x40, %ecx /*ecx=64 */
+	mul %ecx
+	add %ebx, %eax
+	pushl %eax  /* valeur de addr */
+	pushl $0x42244224 /* valeur de magic pour indiquer qu'on a pousse
+	                     la taille de la RAM sur la pile */
+	pushl $0 /* normalement call fait un push eip, mais la on a un jmp*/
 	
 	/* Saut vers le noyau. La GDT est en place (flat mode), les
  	 * selecteurs aussi, a20 est ouverte, et les interruptions sont
@@ -373,14 +400,19 @@
 
      /* quelques messages */
 
-loadkern:  .string      "-= S O S =- : The Simple Operating System \r\n"
-check:     .string      "Checking for a 386+ processor... "
+loadkern:  .string      "This is SOS\r\n"
+toobig:	   .string	"Image too big\r\n"
+check:     .string      "Checking 386+ processor... "
 found386:  .string      " [OK]\r\n"
 need386:   .string      " [FAILED]\r\n"
 diskerror: .string	"Disk Error\r\n"
 loading:   .string	"Loading... "
 haltmsg:   .string	"System Halted\r\n"
 
+     /* Variables pour stocker la taille de la RAM (int 0x15) */
+memsize1:  .long        0
+memsize2:  .long        0
+
 /*** Les code/données du boot secteur se terminent ICI. le marqueur de
  * fin (aa55) est ajouté automatiquement par le script ld
  * sos_bsect.lds ***/
diff -ruN /tmp/sos-code-article7.5/extra/Makefile ../sos-code-article7.5/extra/Makefile
--- /tmp/sos-code-article7.5/extra/Makefile	2005-04-27 20:17:13.000000000 +0200
+++ ../sos-code-article7.5/extra/Makefile	2005-06-06 20:47:21.000000000 +0200
@@ -1,4 +1,6 @@
 OBJCOPY=objcopy
+LIBGCC := $(shell $(CC) -print-libgcc-file-name) # To benefit from FP/64bits artihm.
+EXTRA := $(shell [ -f ../userland/userprogs.kimg ] && echo ../userland/userprogs.kimg)
 
 all: sos_qemu.img
 
@@ -31,7 +33,8 @@
 # above) because they share some symbol definitions
 sos_bsect.elf: bootsect.o compile_kernel
 	$(LD) --warn-common -T ./sos_bsect.lds -o $@ \
-		bootsect.o $(wildcard ../hwcore/*.o ../drivers/*.o ../sos/*.o)
+		bootsect.o $(wildcard ../hwcore/*.o ../drivers/*.o ../sos/*.o)\
+		$(EXTRA) $(LIBGCC)
 
 compile_kernel:
 	$(MAKE) -C ..
diff -ruN /tmp/sos-code-article7.5/extra/README ../sos-code-article7.5/extra/README
--- /tmp/sos-code-article7.5/extra/README	2005-04-27 20:17:13.000000000 +0200
+++ ../sos-code-article7.5/extra/README	2005-06-06 20:47:22.000000000 +0200
@@ -65,8 +65,15 @@
  - for cross-architecture compilation: see above
  - cd to this extra/ directory
  - run 'make'
- - the floppy image is: sos_bsect.img
- NOTE : SOS will not boot correctly this way after article 2 !
+ - the floppy image is: sos_bsect.img for use with bochs or on a real
+   floppy disk
+   to use the image under qemu: use sos_qemu.img
+
+ NOTE : From article 2 onward, be warned that using this bootsect
+        might lead to system crashes. This would be because the
+        solution we use to retrieve the RAM size might not work
+        properly on some systems (BIOS buggy or more than 1G RAM). THE
+        best way to boot SOS is always to use Grub.
 
 
 --
diff -ruN /tmp/sos-code-article7.5/extra/sos_bsect.lds ../sos-code-article7.5/extra/sos_bsect.lds
--- /tmp/sos-code-article7.5/extra/sos_bsect.lds	2005-04-27 20:17:14.000000000 +0200
+++ ../sos-code-article7.5/extra/sos_bsect.lds	2005-06-06 20:47:24.000000000 +0200
@@ -37,9 +37,12 @@
       /* The load_size symbol contains the size of the area (in
        * sectors, aka 512 Bytes) that the boot sector should copy from
        * the disk. The bss section is not included since it uses 0
-       * bytes on disk */
+       * bytes on disk. This variable is short (16b) because it is used
+       * by the bootsector in real mode, and this is enough because
+       * our boot sector cannot transfer more than 1264 sectors (see
+       * bootsector sources) */
       load_size = .;
-      LONG((__e_load - __b_load + 511) >> 9);
+      SHORT((__e_load - __b_load + 511) >> 9);
       /* ---> This is equivalent to ceil( (__e_load - __b_load) / 512 ) */
 
       /* At offsets 511 and 512, we set the boot sector signature (AA55h) */
diff -ruN /tmp/sos-code-article7.5/hwcore/i8254.h ../sos-code-article7.5/hwcore/i8254.h
--- /tmp/sos-code-article7.5/hwcore/i8254.h	2005-04-27 20:17:15.000000000 +0200
+++ ../sos-code-article7.5/hwcore/i8254.h	2005-06-06 20:47:28.000000000 +0200
@@ -15,8 +15,8 @@
    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
    USA. 
 */
-#ifndef _SOS_i8259_H_
-#define _SOS_i8259_H_
+#ifndef _SOS_i8254_H_
+#define _SOS_i8254_H_
 
 #include <sos/errno.h>
 
@@ -32,4 +32,4 @@
 /** Change timer interrupt (IRQ 0) frequency */
 sos_ret_t sos_i8254_set_frequency(unsigned int freq);
 
-#endif /* _SOS_i8259_H_ */
+#endif /* _SOS_i8254_H_ */
diff -ruN /tmp/sos-code-article7.5/hwcore/ioports.h ../sos-code-article7.5/hwcore/ioports.h
--- /tmp/sos-code-article7.5/hwcore/ioports.h	2005-04-27 20:17:15.000000000 +0200
+++ ../sos-code-article7.5/hwcore/ioports.h	2005-06-06 20:47:29.000000000 +0200
@@ -43,4 +43,23 @@
   _v;                                                           \
 })
 
+// write value (word) on port
+#define outw(value, port)					\
+  __asm__ volatile (	       					\
+	"outw %w0,%w1"						\
+	::"a" (value),"Nd" (port)				\
+	)							\
+
+// read one word from port
+#define inw(port)						\
+({								\
+  unsigned int _v;						\
+  __asm__ volatile (						\
+	"inw %w1,%w0"						\
+	:"=a" (_v)						\
+	:"Nd" (port)						\
+	);							\
+  _v;								\
+})
+
 #endif /* _SOS_IOPORTS_H_ */
diff -ruN /tmp/sos-code-article7.5/hwcore/mm_context.c ../sos-code-article7.5/hwcore/mm_context.c
--- /tmp/sos-code-article7.5/hwcore/mm_context.c	2005-04-27 20:17:15.000000000 +0200
+++ ../sos-code-article7.5/hwcore/mm_context.c	2005-06-06 20:47:32.000000000 +0200
@@ -152,6 +152,7 @@
   mmctxt->paddr_PD = sos_paging_get_paddr(mmctxt->vaddr_PD);
   if (mmctxt->paddr_PD == 0)
     {
+      sos_kmem_cache_free((sos_vaddr_t) mmctxt->vaddr_PD);
       sos_kmem_cache_free((sos_vaddr_t) mmctxt);
       return NULL;
     }
@@ -160,6 +161,7 @@
   if (SOS_OK != sos_paging_copy_kernel_space(mmctxt->vaddr_PD,
 					     current_mm_context->vaddr_PD))
     {
+      sos_kmem_cache_free((sos_vaddr_t) mmctxt->vaddr_PD);
       sos_kmem_cache_free((sos_vaddr_t) mmctxt);
       return NULL;
     }
diff -ruN /tmp/sos-code-article7.5/hwcore/swintr.h ../sos-code-article7.5/hwcore/swintr.h
--- /tmp/sos-code-article7.5/hwcore/swintr.h	2005-04-27 20:17:16.000000000 +0200
+++ ../sos-code-article7.5/hwcore/swintr.h	2005-06-06 20:47:33.000000000 +0200
@@ -31,7 +31,6 @@
  */
 #define SOS_SWINTR_SOS_SYSCALL  0x42
 
-
 #if defined(KERNEL_SOS) && !defined(ASM_SOURCE)
 
 #include <hwcore/cpu_context.h>
diff -ruN /tmp/sos-code-article7.5/INSTALL ../sos-code-article7.5/INSTALL
--- /tmp/sos-code-article7.5/INSTALL	2005-04-27 20:17:12.000000000 +0200
+++ ../sos-code-article7.5/INSTALL	2005-06-06 20:47:17.000000000 +0200
@@ -64,9 +64,9 @@
       copy the file 'fd.img' to a floppy, and boot from it
 
  2nd method
-   => see extra/README to compile with the boot sector we provide (up to
-      article 2 only), copy the file 'extra/sos_bsect.img' to a floppy,
-      and boot from it
+   => see extra/README to compile with the boot sector we provide,
+      copy the file 'extra/sos_bsect.img' to a floppy, and boot from
+      it
 
 
 Inside a PC emulator (x86 and non-x86 hosts)
@@ -78,6 +78,7 @@
 installed: 'apt-get install libsdl1.2-dev' on debian
 testing/unstable).
 
+
  1/ Grub is installed on the host (x86 hosts only)
  - - - - - - - - - - - - - - - - - - - - - - - - -
 
@@ -90,6 +91,7 @@
    qemu: run 'qemu -fda fd.img'
      If grub hangs while loading the kernel, please go to method 2/
 
+
  2/ Grub is not installed (all hosts)
  - - - - - - - - - - - - - - - - - -
 
@@ -100,8 +102,9 @@
 
    qemu: run 'qemu -fda fd.img'
 
- 3/ Bonus: boot with the bootsector we provide (all hosts, up to art. 2 ONLY !)
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+
+ 3/ Bonus: boot with the bootsector we provide (all hosts)
+ - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
   
   See extra/README to generate a floppy image with the boot sector we
   provide, and:
@@ -110,14 +113,16 @@
 
    qemu: run 'qemu -fda extra/sos_qemu.img'
 
-  NOTE: After article 2, this way of booting is not supported: please
-  use the method 2/ above.
+  NOTE: This technique assumes that INT 15H is supported by the
+  machine's BIOS. This should be OK for the vast majority of targets
+  (bochs, qemu, recent machines), but we do not guarantee it. In case
+  of doubt, please use Grub.
 
 
 NOTE : recommended versions of the tools
 ----------------------------------------
- - OS           : Linux 2.6.11.7-d2-1 i686
- - gcc          : gcc (GCC) 3.3.5 (Debian 1:3.3.5-8)
+ - OS           : Linux 2.6.11.7 i686
+ - gcc          : gcc (GCC) 3.3.5 (Debian 1:3.3.5-12)
  - GNU binutils : GNU ld version 2.15
  - GNU make     : GNU Make 3.80
 
diff -ruN /tmp/sos-code-article7.5/Makefile ../sos-code-article7.5/Makefile
--- /tmp/sos-code-article7.5/Makefile	2005-04-27 20:17:12.000000000 +0200
+++ ../sos-code-article7.5/Makefile	2005-06-06 20:47:16.000000000 +0200
@@ -17,15 +17,17 @@
 
 CC=gcc
 LD=ld
+CP=cp
+STRIP=strip
 CFLAGS  = -Wall -nostdinc -ffreestanding -DKERNEL_SOS
-LIBGCC := $(shell $(CC) -print-libgcc-file-name) # To benefit from FP/64bits artihm.
+LIBGCC  = $(shell $(CC) -print-libgcc-file-name) # To benefit from FP/64bits artihm.
 LDFLAGS = --warn-common -nostdlib
 OBJECTS = bootstrap/multiboot.o					\
           hwcore/idt.o hwcore/gdt.o				\
 	  hwcore/swintr.o hwcore/swintr_wrappers.o		\
 	  hwcore/exception.o hwcore/exception_wrappers.o	\
 	  hwcore/irq.o hwcore/irq_wrappers.o hwcore/i8259.o	\
-	  hwcore/paging.o					\
+	  hwcore/paging.o 					\
 	  hwcore/i8254.o drivers/x86_videomem.o drivers/bochs.o	\
 	  hwcore/cpu_context.o hwcore/cpu_context_switch.o	\
 	  hwcore/mm_context.o					\
@@ -41,15 +43,20 @@
           userland/userprogs.kimg
 
 KERNEL_OBJ   = sos.elf
+KERNEL_LOAD  = sos.gz
 MULTIBOOT_IMAGE = fd.img
 PWD := $(shell pwd)
 
 # Main target
 all: $(MULTIBOOT_IMAGE)
 
-$(MULTIBOOT_IMAGE): $(KERNEL_OBJ)
+$(MULTIBOOT_IMAGE): $(KERNEL_LOAD)
 	./support/build_image.sh $@ $<
 
+$(KERNEL_LOAD): $(KERNEL_OBJ)
+	$(CP) $< $<.strip && $(STRIP) -sx $<.strip
+	gzip < $<.strip > $@
+
 $(KERNEL_OBJ): $(OBJECTS) ./support/sos.lds
 	$(LD) $(LDFLAGS) -T ./support/sos.lds -o $@ $(OBJECTS) $(LIBGCC)
 	-nm -C $@ | cut -d ' ' -f 1,3 > sos.map
@@ -74,8 +81,8 @@
 
 # Clean directory
 clean:
-	$(RM) *.img *.o mtoolsrc *~ menu.txt *.img *.elf *.bin *.map
-	$(RM) *.log *.out bochs*
+	$(RM) *.img *.o mtoolsrc *~ menu.txt *.img *.elf *.bin *.strip *.map
+	$(RM) *.log *.out bochs* sos.gz
 	$(RM) bootstrap/*.o bootstrap/*~
 	$(RM) drivers/*.o drivers/*~
 	$(RM) hwcore/*.o hwcore/*~
diff -ruN /tmp/sos-code-article7.5/README ../sos-code-article7.5/README
--- /tmp/sos-code-article7.5/README	2005-04-27 20:17:12.000000000 +0200
+++ ../sos-code-article7.5/README	2005-06-06 20:47:18.000000000 +0200
@@ -33,8 +33,7 @@
    i586-gnu) is available. Can be tested on real i486/pentium
    hardware, or on any host that can run an i486/pentium PC emulator
    (bochs or qemu)
- - kernel loaded by grub, or by a sample bootsector (up to article 2
-   ONLY)
+ - kernel loaded by grub or by a sample bootsector
  - clear separation of physical memory and virtual memory concepts,
    even inside the kernel: no identity-mapping of the physical memory
    inside the kernel (allows to move virtual mappings of kernel pages
@@ -54,7 +53,7 @@
    'all' and 'clean'
  - bootstrap/ directory: code to load the kernel. Both the stuff
    needed for a multiboot-compliant loader (eg grub) AND a bootsector
-   are provided. The bootsector may only be used up to article 2.
+   are provided.
  - sos/ directory: the entry routine for the kernel (main.c), various
    systemwide header files, a set of common useful C routines
    ("nano-klibc"), and kernel subsystems (kernel memory management,
diff -ruN /tmp/sos-code-article7.5/sos/errno.h ../sos-code-article7.5/sos/errno.h
--- /tmp/sos-code-article7.5/sos/errno.h	2005-04-27 20:17:16.000000000 +0200
+++ ../sos-code-article7.5/sos/errno.h	2005-06-06 20:47:34.000000000 +0200
@@ -25,16 +25,16 @@
  */
 
 /* Positive values of the error codes */
-#define SOS_OK     0   /* No error */
-#define SOS_EINVAL 1   /* Invalid argument */
-#define SOS_ENOSUP 2   /* Operation not supported */
-#define SOS_ENOMEM 3   /* No available memory */
-#define SOS_EBUSY  4   /* Object or device still in use */
-#define SOS_EINTR  5   /* Wait/Sleep has been interrupted */
-#define SOS_EPERM  6   /* Mutex/files ownership error */
-#define SOS_EFAULT 7   /* Unresolved virtual memory fault */
-#define SOS_ENOENT 8   /* No such file or directory */
-#define SOS_EFATAL 255 /* Internal fatal error */
+#define SOS_OK            0   /* No error */
+#define SOS_EINVAL        1   /* Invalid argument */
+#define SOS_ENOSUP        2   /* Operation not supported */
+#define SOS_ENOMEM        3   /* No available memory */
+#define SOS_EBUSY         4   /* Object or device still in use */
+#define SOS_EINTR         5   /* Wait/Sleep has been interrupted */
+#define SOS_EPERM         6   /* Mutex/files ownership error */
+#define SOS_EFAULT        7   /* Unresolved virtual memory fault */
+#define SOS_ENOENT        8   /* No such file or directory */
+#define SOS_EFATAL      255 /* Internal fatal error */
 
 /* A negative value means that an error occured.  For
  *  example -SOS_EINVAL means that the error was "invalid
diff -ruN /tmp/sos-code-article7.5/sos/main.c ../sos-code-article7.5/sos/main.c
--- /tmp/sos-code-article7.5/sos/main.c	2005-04-27 20:17:17.000000000 +0200
+++ ../sos-code-article7.5/sos/main.c	2005-06-06 20:47:35.000000000 +0200
@@ -16,6 +16,8 @@
    USA. 
 */
 
+#include <sos/errno.h>
+
 /* Include definitions of the multiboot standard */
 #include <bootstrap/multiboot.h>
 #include <hwcore/idt.h>
@@ -64,7 +66,6 @@
     }
 }
 
-
 /* Clock IRQ handler */
 static void clk_it(int intid)
 {
@@ -290,7 +291,7 @@
       sos_process_unref(proc_init);
       return -SOS_ENOENT;
     }
-     
+
   /* Allocate the user stack */
   ustack = (SOS_PAGING_TOP_USER_ADDRESS - SOS_DEFAULT_USER_STACK_SIZE) + 1;
   retval = sos_dev_zero_map(as_init, &ustack, SOS_DEFAULT_USER_STACK_SIZE,
@@ -298,7 +299,6 @@
 			    /* PRIVATE */ 0);
   if (SOS_OK != retval)
     {
-      sos_bochs_printf("ici 2\n");
       sos_process_unref(proc_init);
       return -SOS_ENOMEM;
     }
@@ -312,7 +312,6 @@
 				   SOS_SCHED_PRIO_TS_LOWEST);
   if (! new_thr)
     {
-      sos_bochs_printf("ici 3\n");
       sos_process_unref(proc_init);
       return -SOS_ENOMEM;
     }
@@ -325,17 +324,14 @@
 /* ======================================================================
  * The C entry point of our operating system
  */
-void sos_main(unsigned long magic, unsigned long addr)
+void sos_main(unsigned long magic, unsigned long arg)
 {
   unsigned i;
   sos_paddr_t sos_kernel_core_base_paddr, sos_kernel_core_top_paddr;
   struct sos_time tick_resolution;
 
-  /* Grub sends us a structure, called multiboot_info_t with a lot of
-     precious informations about the system, see the multiboot
-     documentation for more information. */
-  multiboot_info_t *mbi;
-  mbi = (multiboot_info_t *) addr;
+  /* Size of RAM above 1MB. Might be undefined ! */
+  unsigned long int upper_mem = 0;
 
   /* Setup bochs and console, and clear the console */
   sos_bochs_setup();
@@ -345,15 +341,37 @@
 
   /* Greetings from SOS */
   if (magic == MULTIBOOT_BOOTLOADER_MAGIC)
-    /* Loaded with Grub */
-    sos_x86_videomem_printf(1, 0,
-			    SOS_X86_VIDEO_FG_YELLOW | SOS_X86_VIDEO_BG_BLUE,
-			    "Welcome From GRUB to %s%c RAM is %dMB (upper mem = 0x%x kB)",
-			    "SOS article 7.5", ',',
-			    (unsigned)(mbi->mem_upper >> 10) + 1,
-			    (unsigned)mbi->mem_upper);
+    {
+      /* Grub sends us a structure, called multiboot_info_t with a lot of
+	 precious informations about the system, see the multiboot
+	 documentation for more information. */
+      multiboot_info_t *mbi = (multiboot_info_t *) arg;
+
+      /* Multiboot says: "The value returned for upper memory is
+	 maximally the address of the first upper memory hole minus 1
+	 megabyte.". It also adds: "It is not guaranteed to be this
+	 value." aka "YMMV" ;) */
+      upper_mem = mbi->mem_upper;
+      sos_x86_videomem_printf(1, 0,
+			      SOS_X86_VIDEO_FG_YELLOW | SOS_X86_VIDEO_BG_BLUE,
+			      "Welcome From GRUB to %s%c RAM is %dMB (upper mem = 0x%x kB)",
+			      "SOS article 7.5", ',',
+			      (unsigned)(upper_mem >> 10) + 1,
+			      (unsigned)upper_mem);
+    }
+  else if (magic == 0x42244224)
+    {
+      /* Loaded with SOS bootsect */
+      upper_mem = arg;
+      sos_x86_videomem_printf(1, 0,
+			      SOS_X86_VIDEO_FG_YELLOW | SOS_X86_VIDEO_BG_BLUE,
+			      "Welcome to %s%c RAM is %dMB (upper mem = 0x%x kB)",
+			      "SOS article 7.5", ',',
+			      (unsigned)(upper_mem >> 10) + 1,
+			      (unsigned)upper_mem);
+    }
   else
-    /* Not loaded with grub */
+    /* Not loaded with grub, not from an enhanced bootsect */
     sos_x86_videomem_printf(1, 0,
 			    SOS_X86_VIDEO_FG_YELLOW | SOS_X86_VIDEO_BG_BLUE,
 			    "Welcome to SOS article 7.5");
@@ -376,14 +394,14 @@
   tick_resolution = (struct sos_time) { .sec=0, .nanosec=10000000UL };
   sos_time_subsysem_setup(& tick_resolution);
 
-  /* We need a multiboot-compliant boot loader to get the size of the RAM */
-  if (magic != MULTIBOOT_BOOTLOADER_MAGIC)
+  /* We need to know the RAM size */
+  if (upper_mem == 0)
     {
       sos_x86_videomem_putstring(20, 0,
 				 SOS_X86_VIDEO_FG_LTRED
 				   | SOS_X86_VIDEO_BG_BLUE
 				   | SOS_X86_VIDEO_FG_BLINKING,
-				 "I'm not loaded with Grub !");
+				 "I don't know RAM size ! Load me with Grub...");
       /* STOP ! */
       for (;;)
 	continue;
@@ -401,12 +419,10 @@
    * Setup physical memory management
    */
 
-  /* Multiboot says: "The value returned for upper memory is maximally
-     the address of the first upper memory hole minus 1 megabyte.". It
-     also adds: "It is not guaranteed to be this value." aka "YMMV" ;) */
-  sos_physmem_subsystem_setup((mbi->mem_upper<<10) + (1<<20),
-			      & sos_kernel_core_base_paddr,
-			      & sos_kernel_core_top_paddr);
+  SOS_ASSERT_FATAL(SOS_OK
+		   == sos_physmem_subsystem_setup((upper_mem<<10) + (1<<20),
+						  &sos_kernel_core_base_paddr,
+						  &sos_kernel_core_top_paddr));
   
   /*
    * Switch to paged-memory mode
@@ -492,10 +508,10 @@
      interrupt call the scheduler */
   asm volatile ("sti\n");
 
+
   /* Start the 'init' process, which in turns launches the other
      programs */
   start_init();
-
   /*
    * We can safely exit from this function now, for there is already
    * an idle Kernel thread ready to make the CPU busy working...
diff -ruN /tmp/sos-code-article7.5/sos/process.c ../sos-code-article7.5/sos/process.c
--- /tmp/sos-code-article7.5/sos/process.c	2005-04-27 20:17:18.000000000 +0200
+++ ../sos-code-article7.5/sos/process.c	2005-06-06 20:47:40.000000000 +0200
@@ -26,8 +26,7 @@
 
 #include "process.h"
 
-
-#define SOS_PROCESS_MAX_NAMELEN 32
+#define SOS_PROCESS_MAX_NAMELEN       32
 
 
 /**
diff -ruN /tmp/sos-code-article7.5/sos/process.h ../sos-code-article7.5/sos/process.h
--- /tmp/sos-code-article7.5/sos/process.h	2005-04-27 20:17:18.000000000 +0200
+++ ../sos-code-article7.5/sos/process.h	2005-06-06 20:47:40.000000000 +0200
@@ -37,7 +37,6 @@
 
 #include <sos/errno.h>
 
-
 /**
  * The definition of an SOS process is opaque. @see process.c
  */
diff -ruN /tmp/sos-code-article7.5/sos/sched.c ../sos-code-article7.5/sos/sched.c
--- /tmp/sos-code-article7.5/sos/sched.c	2005-04-27 20:17:17.000000000 +0200
+++ ../sos-code-article7.5/sos/sched.c	2005-06-06 20:47:38.000000000 +0200
@@ -131,7 +131,7 @@
     return SOS_OK;
 
   /* Reset the CPU time used in the quantuum */
-  memset(& thr->running.user_time_spent_in_slice, 0x0, sizeof(struct sos_time));
+  memset(& thr->user_time_spent_in_slice, 0x0, sizeof(struct sos_time));
 
   if (SOS_SCHED_PRIO_IS_RT(sos_thread_get_priority(thr)))
     {
@@ -185,7 +185,7 @@
   /* Current (user) thread expired its time quantuum ?  A kernel
      thread never expires because sos_sched_do_timer_tick() below
      won't update its user_time_spent_in_slice */
-  if (sos_time_cmp(& thr->running.user_time_spent_in_slice,
+  if (sos_time_cmp(& thr->user_time_spent_in_slice,
 		   & time_slice[prio]) >= 0)
       return TRUE;
 
@@ -203,7 +203,7 @@
   if (thread_expired_its_quantuum(current_thread))
     {
       /* Reset the CPU time used in the quantuum */
-      memset(& current_thread->running.user_time_spent_in_slice,
+      memset(& current_thread->user_time_spent_in_slice,
 	     0x0, sizeof(struct sos_time));
 
       do_yield = TRUE;
@@ -290,7 +290,7 @@
 		   & tick_duration);
 
       /* Update time spent is current timeslice ONLY for a user thread */
-      sos_time_inc(& interrupted_thread->running.user_time_spent_in_slice,
+      sos_time_inc(& interrupted_thread->user_time_spent_in_slice,
 		   & tick_duration);
     }
   else
diff -ruN /tmp/sos-code-article7.5/sos/syscall.c ../sos-code-article7.5/sos/syscall.c
--- /tmp/sos-code-article7.5/sos/syscall.c	2005-04-27 20:17:18.000000000 +0200
+++ ../sos-code-article7.5/sos/syscall.c	2005-06-06 20:47:40.000000000 +0200
@@ -417,6 +417,7 @@
 	    retval = -SOS_ENOMEM;
 	    break;	    
 	  }
+
       }
       break;
 
diff -ruN /tmp/sos-code-article7.5/sos/thread.h ../sos-code-article7.5/sos/thread.h
--- /tmp/sos-code-article7.5/sos/thread.h	2005-04-27 20:17:17.000000000 +0200
+++ ../sos-code-article7.5/sos/thread.h	2005-06-06 20:47:37.000000000 +0200
@@ -136,13 +136,10 @@
       struct sos_sched_queue *rdy_queue;
       struct sos_thread     *rdy_prev, *rdy_next;
     } ready;
-
-    struct
-    {
-      struct sos_time user_time_spent_in_slice;
-    } running;
   }; /* Anonymous union (gcc extenion) */
 
+  struct sos_time user_time_spent_in_slice;
+
 
   /**
    * When a thread in kernel mode is accessing the user space, it may
diff -ruN /tmp/sos-code-article7.5/sos/types.h ../sos-code-article7.5/sos/types.h
--- /tmp/sos-code-article7.5/sos/types.h	2005-04-27 20:17:17.000000000 +0200
+++ ../sos-code-article7.5/sos/types.h	2005-06-06 20:47:36.000000000 +0200
@@ -46,6 +46,8 @@
 
 /** Generic count of objects */
 typedef unsigned int           sos_count_t;
+/** Generic count of objects (LARGE) */
+typedef unsigned long long int sos_lcount_t;
 
 /* Low-level sizes */
 typedef unsigned long long int sos_ui64_t; /**< 32b unsigned */
diff -ruN /tmp/sos-code-article7.5/userland/init.c ../sos-code-article7.5/userland/init.c
--- /tmp/sos-code-article7.5/userland/init.c	2005-04-27 20:17:19.000000000 +0200
+++ ../sos-code-article7.5/userland/init.c	2005-06-06 20:47:44.000000000 +0200
@@ -27,7 +27,6 @@
 
 int main()
 {
-
   /* launch the tests */
   if (fork() == 0)
     exec("myprog7");
diff -ruN /tmp/sos-code-article7.5/userland/Makefile ../sos-code-article7.5/userland/Makefile
--- /tmp/sos-code-article7.5/userland/Makefile	2005-04-27 20:17:19.000000000 +0200
+++ ../sos-code-article7.5/userland/Makefile	2005-06-06 20:47:43.000000000 +0200
@@ -17,9 +17,11 @@
 
 CC=gcc
 AR=ar
+CP=cp
+STRIP=strip
 OBJCOPY=objcopy
 CFLAGS  = -Wall -nostdinc -ffreestanding -I. -I..
-LIBGCC := $(shell $(CC) -print-libgcc-file-name) # To benefit from FP/64bits artihm.
+LIBGCC  = $(shell $(CC) -print-libgcc-file-name) # To benefit from FP/64bits artihm.
 LDFLAGS = -Wl,--warn-common -nostdlib -Wl,-Tldscript.lds
 
 # Main target
@@ -58,7 +60,8 @@
 	   echo "  = { \"$$f\", &_begin_userprog$$i, &_end_userprog$$i };"  \
                 >> .userprog$$i.c ;                                         \
 	   $(CC) $(CFLAGS) -c .userprog$$i.c -o .userprog$$i.o ;            \
-           $(OBJCOPY) --add-section .userprog$$i=$$f .userprog$$i.o         \
+	   $(CP) $$f $$f.strip && $(STRIP) -sx $$f.strip ;                  \
+           $(OBJCOPY) --add-section .userprog$$i=$$f.strip .userprog$$i.o   \
                 .userprog$$i.kimg ;                                         \
            echo "  . = ALIGN(4096);" >> .userprogs.lds ;                    \
            echo "  _begin_userprog$$i = .;" >> .userprogs.lds ;             \
@@ -87,5 +90,5 @@
 
 # Clean directory
 clean:
-	$(RM) *.o *.a *~ $(PROGS) *.kimg
+	$(RM) *.o *.a *~ $(PROGS) *.kimg *.strip
 	$(RM) .userprog*
diff -ruN /tmp/sos-code-article7.5/userland/myprog12.c ../sos-code-article7.5/userland/myprog12.c
--- /tmp/sos-code-article7.5/userland/myprog12.c	2005-04-27 20:17:20.000000000 +0200
+++ ../sos-code-article7.5/userland/myprog12.c	2005-06-06 20:47:44.000000000 +0200
@@ -24,7 +24,7 @@
 
 
 /**
- * @file myprog10.c
+ * @file myprog12.c
  *
  * /dev/mem & /dev/kmem tests
  */
diff -ruN /tmp/sos-code-article7.5/userland/myprog9.c ../sos-code-article7.5/userland/myprog9.c
--- /tmp/sos-code-article7.5/userland/myprog9.c	2005-04-27 20:17:20.000000000 +0200
+++ ../sos-code-article7.5/userland/myprog9.c	2005-06-06 20:47:44.000000000 +0200
@@ -22,7 +22,7 @@
 #include <debug.h>
 
 /**
- * @file myprog7.c
+ * @file myprog9.c
  *
  * mmap/munmap tests
  *
