[SCM] Lisaac compiler branch, master, updated. lisaac-0.12-671-g1b06bbb
ontologiae
ontologiae at gmail.com
Mon Nov 29 10:37:24 UTC 2010
The following commit has been merged in the master branch:
commit 1b06bbb210c5aedf40d55b42fe6a010a301fd728
Author: ontologiae <ontologiae at gmail.com>
Date: Mon Nov 29 11:35:59 2010 +0100
X86 filesystem
diff --git a/lib/internal/os_support/x86/file_system/directory_unix.li b/lib/internal/os_support/x86/file_system/directory_unix.li
deleted file mode 100644
index c30be62..0000000
--- a/lib/internal/os_support/x86/file_system/directory_unix.li
+++ /dev/null
@@ -1,175 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-// Lisaac OS Library //
-// //
-// LSIIT - ULP - CNRS - INRIA - FRANCE //
-// //
-// 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 3 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, see <http://www.gnu.org/licenses/>. //
-// //
-// http://isaacproject.u-strasbg.fr/ //
-///////////////////////////////////////////////////////////////////////////////
-Section Header
-
- + name :=DIRECTORY_UNIX;
-
- - copyright := "2003-2005 Jérome Boutet, 2003-2007 Benoit Sonntag";
-
- - bibliography:="http://IsaacOS.com";
-
- - author :="Benoit Sonntag (bsonntag at loria.fr)";
-
- - comment :="Directory management";
-
- - external :=
-`
-#include <dirent.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-`;
-
-Section Inherit
-
- + parent_entry_unix:Expanded ENTRY_UNIX;
-
- + parent_directory:Expanded DIRECTORY;
-
-Section Public
-
- - is_open:BOOLEAN <- ( list != NULL);
-
- //
- // Scanning
- //
-
- - open:BOOLEAN <-
- ( + p,n:NATIVE_ARRAY(CHARACTER);
- + dir,dirent:POINTER;
- + new_entry:ENTRY;
- + result:BOOLEAN;
- + i:INTEGER;
-
- (list = NULL).if {
- list := LINKED_LIST(ENTRY).create;
- } else {
- list.clear;
- };
-
- p := path.to_external;
- dir := `opendir(@p)`:POINTER;
- (dir != NULL).if {
- result := TRUE;
- {
- dirent := `readdir(@dir)`:POINTER;
- (dirent != NULL).if {
- n := `((struct dirent *)@dirent)->d_name`:NATIVE_ARRAY(CHARACTER);
- string_tmp.clear;
- i := 0;
- {n.item i = '\0'}.until_do {
- string_tmp.add_last (n.item i);
- i := i + 1;
- };
- (string_tmp !== ".".to_string).if {
- string_tmp.add_first '/';
- string_tmp.prepend path;
- reduce_path string_tmp;
- new_entry := get_entry string_tmp;
- (new_entry = NULL).if {
- "WARNING: ".print; string_tmp.print; " no readable!\n".print;
- //result := FALSE;
- } else {
- (new_entry.path.count >= path.count).if {
- list.add_last new_entry;
- };
- };
- };
- };
- }.do_while {(dirent != NULL) && {result}};
- `closedir(@dir)`;
- };
- result
- );
-
-Section DIRECTORY
-
- - physical_get_entry new_path:ABSTRACT_STRING :ENTRY <-
- ( + pe:NATIVE_ARRAY(CHARACTER);
- + result:ENTRY;
-
- pe := new_path.to_external;
- // #ifdef __MINGW_H ( voir sous winmerde )
- `#ifndef __USE_LARGEFILE64
- `;
- `{ struct stat t`;
- (`stat(@pe,&t)`:INTEGER = 0).if {
- (`S_ISDIR(t.st_mode)`:INTEGER = 0).if {
- // File.
- result := FILE_UNIX.clone;
- } else {
- // Directory.
- result := DIRECTORY_UNIX.clone;
- };
- result.set_path new_path;
- alias.put result to (result.path); // with { (e1,e2:ABSTRACT_STRING); e1 ~=e2 };
- };
- `}`;
- `#else
- `;
- `{ struct stat64 t`;
- (`stat64(@pe,&t)`:INTEGER = 0).if {
- (`S_ISDIR(t.st_mode)`:INTEGER = 0).if {
- // File.
- result := FILE_UNIX.clone;
- } else {
- // Directory.
- result := DIRECTORY_UNIX.clone;
- };
- result.set_path new_path;
- alias.put result to (result.path); //with { (e1,e2:ABSTRACT_STRING); e1 ~=e2 };
- };
- `}`;
- `#endif
- `;
- result
- );
-
- - physical_make_directory new_path:ABSTRACT_STRING :BOOLEAN <-
- ( + pa:NATIVE_ARRAY(CHARACTER);
- pa := new_path.to_external;
- `mkdir(@pa,S_IRWXU)`:(INTEGER) = 0
- );
-
- - physical_make_file new_path:ABSTRACT_STRING :BOOLEAN <-
- ( + pa:NATIVE_ARRAY(CHARACTER);
- + stream:POINTER;
- + result:BOOLEAN;
-
- pa := new_path.to_external;
- stream := `fopen((char*)@pa,"w+b")`:POINTER;
- (stream != NULL).if {
- result := `fclose((FILE*)@stream)`:INTEGER = 0;
- };
- result
- );
-
- - physical_remove p:ABSTRACT_STRING :BOOLEAN <-
- ( + pa:NATIVE_ARRAY(CHARACTER);
- pa := p.to_external;
- `remove(@pa)`:(INTEGER) = 0
- );
-
- - physical_move old_path:ABSTRACT_STRING to new_path:ABSTRACT_STRING :BOOLEAN <-
- ( + old_p,new_p:NATIVE_ARRAY(CHARACTER);
- old_p := old_path.to_external;
- new_p := new_path.to_external;
- `rename(@old_p, at new_p)`:(INTEGER) = 0
- );
diff --git a/lib/internal/os_support/x86/file_system/entry_unix.li b/lib/internal/os_support/x86/file_system/entry_unix.li
deleted file mode 100644
index 55c8a10..0000000
--- a/lib/internal/os_support/x86/file_system/entry_unix.li
+++ /dev/null
@@ -1,150 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-// Lisaac OS Library //
-// //
-// LSIIT - ULP - CNRS - INRIA - FRANCE //
-// //
-// 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 3 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, see <http://www.gnu.org/licenses/>. //
-// //
-// http://isaacproject.u-strasbg.fr/ //
-///////////////////////////////////////////////////////////////////////////////
-Section Header
-
- + name := ENTRY_UNIX;
-
- - copyright := "2003-2008 Benoit Sonntag";
-
- - bibliography:= "http://IsaacOS.com";
-
- - author := "Benoit Sonntag (bsonntag at loria.fr)";
-
- - comment := "Entry ANSI C";
-
-Section Inherit
-
- + parent_entry:Expanded ENTRY;
-
-Section Public
-
- - access:UINTEGER_16 <-
- ( + pe:NATIVE_ARRAY(CHARACTER);
- + result:UINTEGER_16;
- pe := path.to_external;
- `{ struct stat t; stat(@pe,&t)`;
- result := `t.st_mode`:UINTEGER_16 & 111_111_111b;
- `}`;
- result
- );
-
- - access_time:TIME <-
- ( + pe:NATIVE_ARRAY(CHARACTER);
- + tt:POINTER;
- + result:TIME;
- pe := path.to_external;
- `{ struct stat t; stat(@pe,&t)`;
- tt := `localtime(&(t.st_atime))`:POINTER;
- result := to_time tt;
- `}`;
- result
- );
-
- - access_date:DATE <-
- ( + pe:NATIVE_ARRAY(CHARACTER);
- + tt:POINTER;
- + result:DATE;
- pe := path.to_external;
- `{ struct stat t; stat(@pe,&t)`;
- tt := `localtime(&(t.st_atime))`:POINTER;
- result := to_date tt;
- `}`;
- result
- );
-
- - update_time:TIME <-
- ( + pe:NATIVE_ARRAY(CHARACTER);
- + tt:POINTER;
- + result:TIME;
- pe := path.to_external;
- `{ struct stat t; stat(@pe,&t)`;
- tt := `localtime(&(t.st_mtime))`:POINTER;
- result := to_time tt;
- `}`;
- result
- );
-
- - update_date:DATE <-
- ( + pe:NATIVE_ARRAY(CHARACTER);
- + tt:POINTER;
- + result:DATE;
- pe := path.to_external;
- `{ struct stat t; stat(@pe,&t)`;
- tt := `localtime(&(t.st_mtime))`:POINTER;
- result := to_date tt;
- `}`;
- result
- );
-
- - create_time:TIME <-
- ( + pe:NATIVE_ARRAY(CHARACTER);
- + tt:POINTER;
- + result:TIME;
- pe := path.to_external;
- `{ struct stat t; stat(@pe,&t)`;
- tt := `localtime(&(t.st_ctime))`:POINTER;
- result := to_time tt;
- `}`;
- result
- );
-
- - create_date:DATE <-
- ( + pe:NATIVE_ARRAY(CHARACTER);
- + tt:POINTER;
- + result:DATE;
- pe := path.to_external;
- `{ struct stat t; stat(@pe,&t)`;
- tt := `localtime(&(t.st_ctime))`:POINTER;
- result := to_date tt;
- `}`;
- result
- );
-
-Section Private
-
- //
- // Time / Date: Unix -> Lisaac
- //
-
- - to_date t:POINTER :DATE <-
- ( + result:DATE;
- + wd,md,m:UINTEGER_8;
- + y:UINTEGER_16;
-
- y := `((struct tm *)@t)->tm_year`:UINTEGER_16 + 1900;
- m := `((struct tm *)@t)->tm_mon` :UINTEGER_8 + 1;
- md := `((struct tm *)@t)->tm_mday`:UINTEGER_8;
- wd := `((struct tm *)@t)->tm_wday`:UINTEGER_8;
- (! wd.in_range 1 to 7).if { // Bug in UNIX ?
- wd := 1;
- };
- result := DATE.create (y,m,md,wd)
- );
-
- - to_time t:POINTER :TIME <-
- (
- TIME.create
- ((`((struct tm *)@t)->tm_hour`:UINTEGER_8),
- (`((struct tm *)@t)->tm_min` :UINTEGER_8),
- (`((struct tm *)@t)->tm_sec` :UINTEGER_8),
- 0)
- );
-
diff --git a/lib/internal/os_support/x86/file_system/file_system.li b/lib/internal/os_support/x86/file_system/file_system.li
index 7a41d96..8871135 100644
--- a/lib/internal/os_support/x86/file_system/file_system.li
+++ b/lib/internal/os_support/x86/file_system/file_system.li
@@ -1,50 +1,154 @@
///////////////////////////////////////////////////////////////////////////////
-// Lisaac OS Library //
-// //
-// LSIIT - ULP - CNRS - INRIA - FRANCE //
-// //
-// This program is free software: you can redistribute it and/or modify //
+// Isaac Operating System //
+// //
+// 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 3 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, see <http://www.gnu.org/licenses/>. //
-// //
-// http://isaacproject.u-strasbg.fr/ //
+// the Free Software Foundation; version 3 of the License. //
+// //
+// 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. //
+// //
+// http://www.lisaac.org //
///////////////////////////////////////////////////////////////////////////////
-Section Header
-
- + name :=FILE_SYSTEM;
-
- - copyright := "2003-2005 Jérome Boutet, 2003-2007 Benoit Sonntag";
- - comment :="File System manager for Unix.";
- - external := `#include <unistd.h>`; // For `getcwd'
-
-Section Inherit
-
- + parent_directory:DIRECTORY <-
- ( + cwd:NATIVE_ARRAY(CHARACTER);
- + result:DIRECTORY;
+Section Header
+
+ + name :=FILE_SYSTEM;
+
+ - bibliography:="http://www.lisaac.org";
- DIRECTORY.string_tmp.clear;
- cwd := DIRECTORY.string_tmp.to_external;
- `getcwd(@cwd,255)`;
- DIRECTORY.string_tmp.from_external cwd;
+ - author :=
+ "Benoit Sonntag (benoit.sonntag at lisaac.org),\
+ \ Jerome Boutet (pisteur at free.fr)";
- result ?= DIRECTORY_UNIX.physical_get_entry (DIRECTORY.string_tmp);
- DIRECTORY.alias.put result to (result.path);
- ? {result != NULL};
- parent_directory := result
+ - comment :="File System manager for ISAAC - X86.";
+
+Section Inherit
+
+ + parent_entry:Expanded ENTRY;
+
+ + parent_directory:Expanded DIRECTORY;
+
+Section Public
+
+ - is_open:BOOLEAN <- parent_directory.is_open;
+
+ - open:BOOLEAN <-
+ (
+ (is_open).if_false {
+
+ set_path "/";
+ alias.put Self to path;
+
+ physical_refresh;
+ };
+ TRUE
);
-
-
-
-
+
+Section Private
+
+ - physical_refresh <-
+ ( + ctrl:CONTROLER;
+ + drv:DRIVE;
+ + n_drv:INTEGER;
+
+ list := LINKED_LIST(ENTRY).create;
+/*
+ // Floppy Controler. JHJH: detect
+ ctrl := FLOPPY_CONTROLER.create 3F0h;
+ drv := DRIVE.create ctrl drive 00h;
+ // Init fat12
+ part := FAT12.create drv begin 0;
+ list.add_last part;
+ */
+ // Controler BIOS.
+ ctrl := BIOS_CONTROLER.create 0;
+ n_drv := 80h;
+// {
+ drv := DRIVE.create ctrl drive n_drv;
+ (drv != NULL).if {
+ // Partition.
+ "Mount IDE ".print;
+ n_drv.print;
+ '\n'.print;
+ read_partition drv begin 0;
+ };
+ n_drv := n_drv + 1;
+ // }.do_while {drv != NULL};
+ );
+
+ - buffer:FAST_ARRAY(UINTEGER_8) := FAST_ARRAY(UINTEGER_8).create_with_capacity 512;
+
+ - read_partition drv:DRIVE begin logical_sector:UINTEGER_32 <-
+ ( + mbr:MBR;
+ + new_part:PARTITION;
+ + first:UINTEGER_32;
+
+ drv.set_cursor logical_sector;
+ buffer.clear;
+ drv.read buffer size 1;
+
+ // Load mbr.
+ 1BEh.to 1EEh by 16 do { n:INTEGER;
+ mbr:=CONVERT(NATIVE_ARRAY(UINTEGER_8),MBR).on (buffer.to_native_array + n);
+
+ first := mbr.mbr_first_sector + logical_sector;
+ ((mbr.type=05h) || {mbr.type=0Fh}).if {
+ // Extended Partition.
+ "extended partition type\n".print;
+ read_partition drv begin first;
+ }.elseif {(mbr.type != 0) && {mbr.type != 0FFh}} then {
+ // Mbr Extended.
+ mbr.is_fat12.if {
+ "\t\tFAT12 detected\n".print;
+ new_part := FAT12.create drv begin first;
+ add_part new_part with "fat12";
+ }.elseif {mbr.is_fat16} then {
+ "\t\tFAT16 detected\n".print;
+ new_part := FAT16.create drv begin first;
+ add_part new_part with "fat16";
+ }.elseif {mbr.is_fat32} then {
+ "\t\tFAT32 detected.\n".print;
+ new_part := FAT32.create drv begin first;
+ add_part new_part with "fat32";
+ }.elseif {mbr.is_ext2} then {
+ "\t\tEXT2 detected.\n".print;
+ new_part := EXT2.create drv begin first;
+ add_part new_part with "ext2";
+ } else {
+ "\t\tUnknown partition detected (".print;
+ mbr.type.to_hexadecimal.print;
+ "h)\n".print;
+ };
+ };
+ };
+ );
+
+
+ - add_part new_part:PARTITION with name:ABSTRACT_STRING <-
+ (
+ new_part.make;
+ alias.put new_part to (new_part.path);
+ list.add_last new_part;
+ );
+
+Section ENTRY
+
+ - get_partition e:ENTRY :PARTITION <-
+ ( + result:PARTITION;
+
+ result ?= e;
+ (result = NULL).if {
+ string_tmp.copy (e.path);
+ string_tmp.keep_head (string_tmp.index_of '/' since 2 - 1);
+ result ?= alias.at string_tmp;
+ (result = NULL).if {
+ "GROSSE MERDE!\n".print;
+ };
+ };
+ result
+ )
+ [ +? { Result != NULL }; ];
diff --git a/lib/internal/os_support/x86/file_system/file_unix.li b/lib/internal/os_support/x86/file_system/file_unix.li
deleted file mode 100644
index afa0e95..0000000
--- a/lib/internal/os_support/x86/file_system/file_unix.li
+++ /dev/null
@@ -1,120 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-// Lisaac OS Library //
-// //
-// LSIIT - ULP - CNRS - INRIA - FRANCE //
-// //
-// 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 3 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, see <http://www.gnu.org/licenses/>. //
-// //
-// http://isaacproject.u-strasbg.fr/ //
-///////////////////////////////////////////////////////////////////////////////
-Section Header
-
- + name := FILE_UNIX;
-
- - copyright := "2003-2005 Jérome Boutet, 2003-2007 Benoit Sonntag";
-
- - comment := "File management";
-
-Section Inherit
-
- + parent_entry_unix:Expanded ENTRY_UNIX;
-
- + parent_file:Expanded FILE;
-
-Section Private
-
- + stream:POINTER; // Unix file pointer (FILE *).
-
-Section Public
-
- //
- // Physical implementation.
- //
-
- - is_open:BOOLEAN <- stream != NULL;
-
- - size:UINTEGER_32 <-
- ( + pe:NATIVE_ARRAY(CHARACTER);
- + result:UINTEGER_32;
- pe := path.to_external;
- `{ struct stat t; stat(@pe,&t)`;
- result := `t.st_size`:UINTEGER_32;
- `}`;
- result
- );
-
- - cursor:UINTEGER_32 <-
- ( + str:POINTER;
- str := stream;
- `ftell((FILE *)@str)`:UINTEGER_32
- );
-
- - set_cursor n:UINTEGER_32 <-
- [
- ...
- -? {stream != NULL};
- -? {n <= size};
- ]
- ( + str:POINTER;
- str := stream;
- `fseek((FILE*)(@str), at n,SEEK_SET)`;
- );
-
- - open:BOOLEAN <-
- [
- -? {stream = NULL};
- ]
- ( + pa:NATIVE_ARRAY(CHARACTER);
-
- pa := path.to_external;
- stream := `fopen((char*)@pa,"r+b")`:(POINTER);
- stream != NULL
- );
-
- - open_read_only:BOOLEAN <-
- ( + pa:NATIVE_ARRAY(CHARACTER);
- pa := path.to_external;
- stream := `fopen((char*)@pa,"rb")`:(POINTER);
- stream != NULL
- );
-
- - close <-
- [
- -? {stream != NULL};
- ]
- ( + str:POINTER;
-
- str := stream;
- `fclose((FILE*)(@str))`;
- stream := NULL;
- );
-
-Section FILE
-
- - physical_read buf:NATIVE_ARRAY(UINTEGER_8) size s:INTEGER :INTEGER <-
- // return size read or 0 if end of input (-1 on error => exception ?)
- ( + str:POINTER;
- str := stream;
- `fread((void *)(@buf),(size_t)(1), (size_t)(@s),(FILE*)(@str))`:(INTEGER)
- );
-
- - physical_write buf:NATIVE_ARRAY(UINTEGER_8) size s:INTEGER :INTEGER <-
- // return size read or 0 if end of input (-1 on error => exception ?)
- ( + str:POINTER;
- str := stream;
- `fwrite((void *)(@buf),(size_t)(1), (size_t)(@s),(FILE*)(@str))`:(INTEGER)
- );
-
-
-
--
Lisaac compiler
More information about the Lisaac-commits
mailing list