[SCM] applications.git branch, master, updated. d3f72cec12c59082ed91648c74b503fd773f6d88
ontologiae
ontologiae at gmail.com
Wed Nov 17 11:36:59 UTC 2010
The following commit has been merged in the master branch:
commit d3f72cec12c59082ed91648c74b503fd773f6d88
Author: ontologiae <ontologiae at gmail.com>
Date: Wed Nov 17 12:35:43 2010 +0100
IsaacOS is in the GIT d
diff --git a/action-simulation/Makefile b/action-simulation/Makefile
index b18eb9f..729abcb 100644
--- a/action-simulation/Makefile
+++ b/action-simulation/Makefile
@@ -14,7 +14,7 @@ REP_SRC = ./src
REP_BIN = ./bin
#Compilateur Lisaac
-CC = lisaac -O
+CC = lisaac
#Nom executable, cible compilo
EXEC = t_client
@@ -49,10 +49,10 @@ serv:
$(CC) $(REP_SRC)/$(EXEC_S) -o $(REP_BIN)/$(EXEC_S)
warning:
- $(CC) $(REP_SRC)/$(EXEC) -o $(REP_BIN)/$(EXEC) -W
+ $(CC) $(REP_SRC)/$(EXEC) -o $(REP_BIN)/$(EXEC) -all-warning
debug:
- $(CC) $(REP_SRC)/$(EXEC) -o $(REP_BIN)/$(EXEC) -D
+ $(CC) $(REP_SRC)/$(EXEC) -o $(REP_BIN)/$(EXEC) -debug
clean :
rm -f $(REP_SRC)/*.c
diff --git a/action-simulation/src/espion_client.li b/action-simulation/src/espion_client.li
index a27774b..a15410a 100644
--- a/action-simulation/src/espion_client.li
+++ b/action-simulation/src/espion_client.li
@@ -113,7 +113,7 @@ Section Private
//Etat du programme : FALSE : actions normales, TRUE actions simulées
+ data_send:JSON_ARRAY:=JSON_ARRAY.create_with_capacity 32;
//Buffer d'événements sortant
- + data_rcv:FAST_ARRAY[JSON_VALUE];
+ + data_rcv:FAST_ARRAY(JSON_VALUE);
//Buffer d'événements entrant
//
diff --git a/action-simulation/src/espion_serveur.li b/action-simulation/src/espion_serveur.li
index f65b1f3..15537fe 100644
--- a/action-simulation/src/espion_serveur.li
+++ b/action-simulation/src/espion_serveur.li
@@ -40,8 +40,8 @@ Section Public
//Création table socket
(nbclient >= 2).if
- { tab_socket := FAST_ARRAY[SOCKET].create_with_capacity nbclient;}
- else { tab_socket := FAST_ARRAY[SOCKET].create 0};
+ { tab_socket := FAST_ARRAY(SOCKET).create_with_capacity nbclient;}
+ else { tab_socket := FAST_ARRAY(SOCKET).create 0};
//Initialisation partie serveur
//Fermer le serveur si déjà ouvert
@@ -103,7 +103,7 @@ Section ESPION_SERVEUR
//Données :
//
- + tab_socket:FAST_ARRAY[SOCKET];
+ + tab_socket:FAST_ARRAY(SOCKET);
//Liste des sockets connectés
+ sock_ecoute:SOCKET_SERVER;
//Socket d'écoute
@@ -202,7 +202,7 @@ Section Private
//Appel sur timer : gestion client + diffusion données
(
+ tmp_sock:SOCKET; //Pour gestion client
- + data:FAST_ARRAY[JSON_VALUE]; //Pour transit de données
+ + data:FAST_ARRAY(JSON_VALUE); //Pour transit de données
+ tmp_data:JSON_ARRAY; //Pour transit de données
/******************
* GESTION CLIENTS
diff --git a/action-simulation/src/ip_fct.li b/action-simulation/src/ip_fct.li
index b8fe593..1c8c2d4 100644
--- a/action-simulation/src/ip_fct.li
+++ b/action-simulation/src/ip_fct.li
@@ -32,7 +32,7 @@ Section Public
(
// Declare
+ tmp_str:STRING;
- + tmp_arr:NATIVE_ARRAY[CHARACTER];
+ + tmp_arr:NATIVE_ARRAY(CHARACTER);
+ return:UINTEGER_32;
// Init params
@@ -53,7 +53,7 @@ Section Public
(
// Declare
+ tmp_str:STRING;
- + tmp_arr:NATIVE_ARRAY[CHARACTER];
+ + tmp_arr:NATIVE_ARRAY(CHARACTER);
+ return:UINTEGER_32;
// Init params
@@ -74,7 +74,7 @@ Section Public
(
// Declare
+ tmp_str:STRING;
- + tmp_arr:NATIVE_ARRAY[CHARACTER];
+ + tmp_arr:NATIVE_ARRAY(CHARACTER);
+ return_bool:INTEGER;
+ return_addr:UINTEGER_32;
@@ -110,7 +110,7 @@ Section Public
(
// Declare
+ return_str:STRING;
- + tmp_arr:NATIVE_ARRAY[CHARACTER];
+ + tmp_arr:NATIVE_ARRAY(CHARACTER);
// Init return string
return_str := STRING.create 16;
@@ -120,7 +120,7 @@ Section Public
`;
// Get data
- tmp_arr := `inet_ntoa(in)`:(NATIVE_ARRAY[CHARACTER]);
+ tmp_arr := `inet_ntoa(in)`:(NATIVE_ARRAY(CHARACTER));
return_str.from_external_copy tmp_arr;
`}`;
@@ -141,7 +141,7 @@ Section Public
(
// Declare
+ result:UINTEGER_32;
- + name_arr:NATIVE_ARRAY[CHARACTER];
+ + name_arr:NATIVE_ARRAY(CHARACTER);
+ test:POINTER;
// Extract pointer
@@ -169,7 +169,7 @@ Section Public
(
// Declare
+ return_name:STRING;
- + tmp_arr:NATIVE_ARRAY[CHARACTER];
+ + tmp_arr:NATIVE_ARRAY(CHARACTER);
+ test:POINTER;
`{ struct hostent * host;
@@ -179,7 +179,7 @@ Section Public
(test != NULL) .if { //If data is coorect
// Get host_name
- tmp_arr := `host->h_name`:NATIVE_ARRAY[CHARACTER];
+ tmp_arr := `host->h_name`:NATIVE_ARRAY(CHARACTER);
return_name := STRING.create 0;
// Convert it to string
return_name.from_external_copy tmp_arr;
diff --git a/action-simulation/src/json_array.li b/action-simulation/src/json_array.li
index 8251cee..ef19f96 100644
--- a/action-simulation/src/json_array.li
+++ b/action-simulation/src/json_array.li
@@ -1,10 +1,10 @@
Section Header
+ name := JSON_ARRAY;
-- comment := "Prototype inheriting FAST_ARRAY[JSON_VALUE] and representing a JSON array";
+- comment := "Prototype inheriting FAST_ARRAY(JSON_VALUE) and representing a JSON array";
Section Inherit
-+ parent_array :Expanded FAST_ARRAY[JSON_VALUE] := FAST_ARRAY[JSON_VALUE];
++ parent_array :Expanded FAST_ARRAY(JSON_VALUE) := FAST_ARRAY(JSON_VALUE);
- parent_json_value :JSON_VALUE := JSON_VALUE;
Section JSON_VALUE
diff --git a/action-simulation/src/socket.li b/action-simulation/src/socket.li
index 98882e9..e5a29b2 100644
--- a/action-simulation/src/socket.li
+++ b/action-simulation/src/socket.li
@@ -35,13 +35,13 @@ Section Public
//Listens to any active incoming network interface
Section Private
- + buffer :NATIVE_ARRAY[CHARACTER];
+ + buffer :NATIVE_ARRAY(CHARACTER);
Section SOCKET
- buffer_size :INTEGER := 64;
- clone :SELF <- (
- buffer := NATIVE_ARRAY[CHARACTER].create buffer_size;
+ buffer := NATIVE_ARRAY(CHARACTER).create buffer_size;
parent_object.clone
);
@@ -207,10 +207,10 @@ Section Public
return
);
- - read_char_array :NATIVE_ARRAY[CHARACTER] <-
+ - read_char_array :NATIVE_ARRAY(CHARACTER) <-
// Reads an array of chars in the stream
// Returns TRUE (OK) or FALSE (error)
- ( + result:NATIVE_ARRAY[CHARACTER];
+ ( + result:NATIVE_ARRAY(CHARACTER);
// For storing the values of read
+ buffer_ptr:POINTER;
@@ -221,7 +221,7 @@ Section Public
// Init
capacity := 1;
// Association between the pointer (buffer) and the temporary array
- buffer := NATIVE_ARRAY[CHARACTER].create buffer_size;
+ buffer := NATIVE_ARRAY(CHARACTER).create buffer_size;
buffer_ptr := buffer.to_external;
// Readout of all the disponible data
@@ -230,7 +230,7 @@ Section Public
// Data has been read
(read_size >= 0).if
{ (result = NULL) .if
- { result := NATIVE_ARRAY[CHARACTER].create (read_size + 1); }
+ { result := NATIVE_ARRAY(CHARACTER).create (read_size + 1); }
else
{ result := result.realloc capacity with (capacity + read_size); };
// concatenation of result array and currently read data
@@ -252,7 +252,7 @@ Section Public
// Reads a string in the current stream
// Returns the read string or NULL in case a problem occured
(
- + c:NATIVE_ARRAY[CHARACTER];
+ + c:NATIVE_ARRAY(CHARACTER);
+ result:STRING;
// Reads out the char_array
@@ -278,16 +278,16 @@ Section Public
result
);
- - read_all_json :FAST_ARRAY[JSON_VALUE] <-
+ - read_all_json :FAST_ARRAY(JSON_VALUE) <-
// Reads all json values of a socket, then returns it in an array
(
+ s:STRING;
- + result :FAST_ARRAY[JSON_VALUE];
+ + result :FAST_ARRAY(JSON_VALUE);
s := read_string;
(s != NULL) .if {
+ jsv :JSON_VALUE;
- result := FAST_ARRAY[JSON_VALUE].create 0;
+ result := FAST_ARRAY(JSON_VALUE).create 0;
{
jsv := JSON_VALUE.decode s;
(jsv != NULL) .if {
diff --git a/examples/standard/gui/mpg2/recon.li b/examples/standard/gui/mpg2/recon.li
new file mode 100644
index 0000000..4fe6e27
--- /dev/null
+++ b/examples/standard/gui/mpg2/recon.li
@@ -0,0 +1,483 @@
+////////////////////////////////////////////////////////////////////////////////
+// //
+// MPEG2 Decode Video //
+// //
+// LORIA - UHP - INRIA - ST - FRANCE //
+// (c) INRIA (see `licence.txt' for more details) //
+// Benoit SONNTAG - bsonntag at loria.fr //
+// http://www.IsaacOS.com //
+// //
+////////////////////////////////////////////////////////////////////////////////
+Section Header
+
+ + name := RECON;
+
+ - bibliography := "http://IsaacOS.com";
+ - author := "Sonntag Benoit (bsonntag at loria.fr)";
+ - comment := "motion compensation routines.";
+
+Section Inherit
+
+ - parent_any_mpg2:ANY_MPG2 := ANY_MPG2;
+
+Section Private
+
+ - dmv:FAST_ARRAY2(INTEGER) := FAST_ARRAY2(INTEGER).create (2,2);
+
+Section Public
+
+ - form_predictions (bx,by,macroblock_type,motion_type:INTEGER,pmv:PMV,
+ motion_vertical_field_select:FAST_ARRAY2(BOOLEAN),dmvector:VECTOR,stwtype:INTEGER) <-
+ //
+ // motion_vertical_field_select[2][2];
+ ( + currentfield:BOOLEAN;
+ + predframe:NATIVE_ARRAY(NATIVE_ARRAY(UINTEGER_8));
+ + stwtop, stwbot:INTEGER;
+
+ stwtop := stwtype % 3; // 0:temporal, 1:(spat+temp)/2, 2:spatial
+ stwbot := stwtype / 3;
+
+ (((macroblock_type & macroblock_motion_forward) != 0) || {picture_coding_type = p_type}).if {
+ (picture_structure = frame_picture).if {
+ ((motion_type = mc_frame) || {(macroblock_type & macroblock_motion_forward) = 0}).if {
+ // frame-based prediction (broken into top and bottom halves
+ // for spatial scalability prediction purposes)
+ (stwtop < 2).if {
+ form_prediction (forward_reference_frame,FALSE,current_frame,FALSE,
+ coded_picture_width,(coded_picture_width << 1),16,8,bx,by,
+ (pmv.item (0,0,0)),(pmv.item (0,0,1)),(stwtop!=0));
+ };
+ (stwbot < 2).if {
+ form_prediction (forward_reference_frame,TRUE,current_frame,TRUE,
+ coded_picture_width,(coded_picture_width << 1),16,8,bx,by,
+ (pmv.item (0,0,0)),(pmv.item (0,0,1)),(stwbot!=0));
+ };
+ } else {
+ (motion_type = mc_field).if {
+ // field-based prediction
+ (stwtop < 2).if {
+ // top field prediction
+ form_prediction
+ (forward_reference_frame,(motion_vertical_field_select.item (0,0)),
+ current_frame,FALSE,(coded_picture_width << 1),(coded_picture_width << 1),16,8,
+ bx,(by >> 1),(pmv.item (0,0,0)),(pmv.item (0,0,1) >> 1),(stwtop!=0));
+ };
+
+ (stwbot < 2).if {
+ // bottom field prediction
+ form_prediction
+ (forward_reference_frame,(motion_vertical_field_select.item (1,0)),
+ current_frame,TRUE,(coded_picture_width << 1),(coded_picture_width << 1),16,8,
+ bx,(by >> 1),(pmv.item (1,0,0)),(pmv.item (1,0,1) >> 1),(stwbot!=0));
+ };
+ } else {
+ (motion_type = mc_dmv).if {
+ // dual prime prediction
+
+ // calculate derived motion vectors
+ MOTION.dual_prime_arithmetic (dmv,dmvector,(pmv.item (0,0,0)),(pmv.item
+ (0,0,1) >> 1));
+
+ (stwtop < 2).if {
+ // predict top field from top field
+ form_prediction (forward_reference_frame,FALSE,current_frame,FALSE,
+ (coded_picture_width << 1),(coded_picture_width << 1),16,8,bx,(by >> 1),
+ (pmv.item (0,0,0)),(pmv.item (0,0,1) >> 1),FALSE);
+
+ // predict and add to top field from bottom field
+ form_prediction (forward_reference_frame,TRUE,current_frame,FALSE,
+ (coded_picture_width << 1),(coded_picture_width << 1),16,8,bx,(by >> 1),
+ (dmv.item (0,0)),(dmv.item (0,1)),TRUE);
+ };
+
+ (stwbot < 2).if {
+ // predict bottom field from bottom field
+ form_prediction (forward_reference_frame,TRUE,current_frame,TRUE,
+ (coded_picture_width << 1),(coded_picture_width << 1),16,8,bx,(by >> 1),
+ (pmv.item (0,0,0)),(pmv.item (0,0,1) >> 1),FALSE);
+
+ // predict and add to bottom field from top field
+ form_prediction (forward_reference_frame,FALSE,current_frame,TRUE,
+ (coded_picture_width << 1),(coded_picture_width << 1),16,8,bx,(by >> 1),
+ (dmv.item (1,0)),(dmv.item (1,1)),TRUE);
+ };
+ } else {
+ // invalid motion_type
+ "invalid motion_type\n".print;
+ };
+ };
+ };
+ } else {
+ // TOP_FIELD or BOTTOM_FIELD
+
+ // field picture
+ currentfield := (picture_structure = bottom_field);
+
+ // determine which frame to use for prediction
+ ((picture_coding_type = p_type) && {second_field} &&
+ {currentfield != motion_vertical_field_select.item (0,0)}).if {
+ predframe := backward_reference_frame; // same frame
+ } else {
+ predframe := forward_reference_frame; // previous frame
+ };
+
+ ((motion_type = mc_field) || {(macroblock_type & macroblock_motion_forward) = 0}).if {
+ // field-based prediction
+ (stwtop < 2).if {
+ form_prediction (predframe,(motion_vertical_field_select.item (0,0)),current_frame,FALSE,
+ (coded_picture_width << 1),(coded_picture_width << 1),16,16,bx,by,
+ (pmv.item (0,0,0)),(pmv.item (0,0,1)),(stwtop!=0));
+ };
+ } else {
+ (motion_type = mc_16x8).if {
+ (stwtop < 2).if {
+ form_prediction (predframe,(motion_vertical_field_select.item (0,0)),current_frame,FALSE,
+ (coded_picture_width << 1),(coded_picture_width << 1),16,8,bx,by,
+ (pmv.item (0,0,0)),(pmv.item (0,0,1)),(stwtop!=0));
+
+ // determine which frame to use for lower half prediction
+ ((picture_coding_type = p_type) && {second_field} &&
+ {currentfield != motion_vertical_field_select.item (1,0)}).if {
+ predframe := backward_reference_frame; // same frame
+ } else {
+ predframe := forward_reference_frame; // previous frame
+ };
+
+ form_prediction (predframe,(motion_vertical_field_select.item (1,0)),current_frame,FALSE,
+ (coded_picture_width << 1),(coded_picture_width << 1),16,8,bx,(by + 8),
+ (pmv.item (1,0,0)),(pmv.item (1,0,1)),(stwtop!=0));
+ };
+ } else {
+ (motion_type = mc_dmv).if {
+ // dual prime prediction
+ (second_field).if {
+ predframe := backward_reference_frame; // same frame
+ } else {
+ predframe := forward_reference_frame; // previous frame
+ };
+
+ // calculate derived motion vectors
+ MOTION.dual_prime_arithmetic (dmv,dmvector,(pmv.item (0,0,0)),(pmv.item
+ (0,0,1)));
+
+ // predict from field of same parity
+ form_prediction (forward_reference_frame,currentfield,current_frame,FALSE,
+ (coded_picture_width << 1),(coded_picture_width << 1),16,16,bx,by,
+ (pmv.item (0,0,0)),(pmv.item (0,0,1)),FALSE);
+
+ // predict from field of opposite parity
+ form_prediction (predframe,(! currentfield),current_frame,FALSE,
+ (coded_picture_width << 1),(coded_picture_width << 1),16,16,bx,by,
+ (dmv.item (0,0)),(dmv.item (0,1)),TRUE);
+ } else {
+ // invalid motion_type
+ "invalid motion_type\n".print;
+ };
+ };
+ };
+ };
+ stwtop := stwbot := 1;
+ };
+
+ ((macroblock_type & macroblock_motion_backward) != 0).if {
+ (picture_structure = frame_picture).if {
+ (motion_type = mc_frame).if {
+ // frame-based prediction
+ (stwtop < 2).if {
+ form_prediction (backward_reference_frame,FALSE,current_frame,FALSE,
+ coded_picture_width,(coded_picture_width << 1),16,8,bx,by,
+ (pmv.item (0,1,0)),(pmv.item (0,1,1)),(stwtop!=0));
+ };
+
+ (stwbot < 2).if {
+ form_prediction (backward_reference_frame,TRUE,current_frame,TRUE,
+ coded_picture_width,(coded_picture_width << 1),16,8,bx,by,
+ (pmv.item (0,1,0)),(pmv.item (0,1,1)),(stwbot!=0));
+ };
+ } else { // field-based prediction
+ (stwtop < 2).if {
+ // top field prediction
+ form_prediction
+ (backward_reference_frame,(motion_vertical_field_select.item (0,1)),
+ current_frame,FALSE,(coded_picture_width << 1),(coded_picture_width << 1),16,8,
+ bx,(by >> 1),(pmv.item (0,1,0)),(pmv.item (0,1,1) >> 1),(stwtop!=0));
+ };
+
+ (stwbot < 2).if {
+ // bottom field prediction
+ form_prediction
+ (backward_reference_frame,(motion_vertical_field_select.item (1,1)),
+ current_frame,TRUE,(coded_picture_width << 1),(coded_picture_width << 1),16,8,
+ bx,(by >> 1),(pmv.item (1,1,0)),(pmv.item (1,1,1) >> 1),(stwbot!=0));
+ };
+ }
+ } else {
+ // TOP_FIELD or BOTTOM_FIELD
+ (motion_type = mc_field).if {
+ // field-based prediction
+ form_prediction
+ (backward_reference_frame,(motion_vertical_field_select.item (0,1)),
+ current_frame,FALSE,(coded_picture_width << 1),(coded_picture_width << 1),16,16,
+ bx,by,(pmv.item (0,1,0)),(pmv.item (0,1,1)),(stwtop!=0));
+ } else {
+ (motion_type = mc_16x8).if {
+ form_prediction
+ (backward_reference_frame,(motion_vertical_field_select.item (0,1)),
+ current_frame,FALSE,(coded_picture_width << 1),(coded_picture_width << 1),16,8,
+ bx,by,(pmv.item (0,1,0)),(pmv.item (0,1,1)),(stwtop!=0));
+
+ form_prediction
+ (backward_reference_frame,(motion_vertical_field_select.item (1,1)),
+ current_frame,FALSE,(coded_picture_width << 1),(coded_picture_width << 1),16,8,
+ bx,(by + 8),(pmv.item (1,1,0)),(pmv.item (1,1,1)),(stwtop!=0));
+ } else {
+ // invalid motion_type
+ "invalid motion_type\n".print;
+ };
+ };
+ };
+ };
+ );
+
+Section Private
+
+ - form_prediction
+ (src:NATIVE_ARRAY(NATIVE_ARRAY(UINTEGER_8)),sfield:BOOLEAN,dst:NATIVE_ARRAY(NATIVE_ARRAY(UINTEGER_8)),
+ dfield:BOOLEAN,plx,plx2,pw,ph,px,py,pdx,pdy:INTEGER,average_flag:BOOLEAN) <-
+ // unsigned char *src[]; prediction source buffer
+ // int sfield; prediction source field number (0 or 1)
+ // unsigned char *dst[]; prediction destination buffer
+ // int dfield; prediction destination field number (0 or 1)
+ // int lx,lx2; line strides
+ // int w,h; prediction block/sub-block width, height
+ // int x,y; pixel co-ordinates of top-left sample in current MB
+ // int dx,dy; horizontal, vertical prediction address
+ // int average_flag; add prediction error to prediction ?
+ ( + tmp_src,tmp_dst:INTEGER;
+ + lx,lx2,w,x,dx,h,y,dy:INTEGER;
+
+ lx := plx;
+ lx2 := plx2;
+ w := pw;
+ x := px;
+ dx := pdx;
+ h := ph;
+ y := py;
+ dy := pdy;
+
+ // Y
+ (sfield).if {
+ tmp_src := lx2 >> 1;
+ } else {
+ tmp_src := 0;
+ };
+
+ (dfield).if {
+ tmp_dst := lx2 >> 1;
+ } else {
+ tmp_dst := 0;
+ };
+
+ form_component_prediction ((src.item 0),tmp_src,(dst.item
+ 0),tmp_dst,lx,lx2,w,h,x,y,dx,dy,average_flag);
+
+ (chroma_format != chroma444).if {
+ lx := lx >> 1;
+ lx2 := lx2 >> 1;
+ w := w >> 1;
+ x := x >> 1;
+ dx := dx / 2;
+ };
+
+ (chroma_format = chroma420).if {
+ h := h >> 1;
+ y := y >> 1;
+ dy := dy / 2;
+ };
+
+ (sfield).if {
+ tmp_src := lx2 >> 1;
+ } else {
+ tmp_src := 0;
+ };
+ (dfield).if {
+ tmp_dst := lx2 >> 1;
+ } else {
+ tmp_dst := 0;
+ };
+
+ // Cb
+ form_component_prediction ((src.item 1),tmp_src,(dst.item 1),tmp_dst,
+ lx,lx2,w,h,x,y,dx,dy,average_flag);
+
+ // Cr
+ form_component_prediction ((src.item 2),tmp_src,(dst.item 2),tmp_dst,
+ lx,lx2,w,h,x,y,dx,dy,average_flag);
+ );
+
+
+ - form_component_prediction (src:NATIVE_ARRAY(UINTEGER_8),idx_src:INTEGER,
+ dst:NATIVE_ARRAY(UINTEGER_8),idx_dst:INTEGER,
+ lx,lx2,w,h,x,y,dx,dy:INTEGER,average_flag:BOOLEAN) <-
+ // ISO/IEC 13818-2 section 7.6.4: Forming predictions
+ // NOTE: the arithmetic below produces numerically equivalent results
+ // to 7.6.4, yet is more elegant. It differs in the following ways:
+ //
+ // 1. the vectors (dx, dy) are based on cartesian frame
+ // coordiantes along a half-pel grid (always positive numbers)
+ // In contrast, vector[r][s][t] are differential (with positive and
+ // negative values). As a result, deriving the integer vectors
+ // (int_vec[t]) from dx, dy is accomplished by a simple right shift.
+ //
+ // 2. Half pel flags (xh, yh) are equivalent to the LSB (Least
+ // Significant Bit) of the half-pel coordinates (dx,dy).
+ //
+ // NOTE: the work of combining predictions (ISO/IEC 13818-2 section 7.6.7)
+ // is distributed among several other stages. This is accomplished by
+ // folding line offsets into the source and destination (src,dst)
+ // addresses (note the call arguments to form_prediction() in Predict()),
+ // line stride variables lx and lx2, the block dimension variables (w,h),
+ // average_flag, and by the very order in which Predict() is called.
+ // This implementation design (implicitly different than the spec)
+ // was chosen for its elegance.
+ //
+ // int lx; raster line increment
+ // int average_flag; flag that signals bi-directional or Dual-Prime
+ // averaging (7.6.7.1 and 7.6.7.4). if average_flag==1,
+ // a previously formed prediction has been stored in
+ // pel_pred[]
+ ( + xint:INTEGER; // horizontal integer sample vector: analogous to int_vec[0]
+ + yint:INTEGER; // vertical integer sample vectors: analogous to int_vec[1]
+ + xh:BOOLEAN; // horizontal half sample flag: analogous to half_flag[0]
+ + yh:BOOLEAN; // vertical half sample flag: analogous to half_flag[1]
+ + v:INTEGER;
+ + s:INTEGER; // source pointer: analogous to pel_ref[][]
+ + d:INTEGER; // destination pointer: analogous to pel_pred[][]
+ + si,sil,di,wm1,hm1:INTEGER;
+ + psrc,pdst:NATIVE_ARRAY(UINTEGER_8);
+
+ // half pel scaling for integer vectors
+ xint := dx >> 1;
+ yint := dy >> 1;
+
+ // derive half pel flags
+ xh := (dx & 1).to_boolean;
+ yh := (dy & 1).to_boolean;
+
+ // compute the linear address of pel_ref[][] and pel_pred[][]
+ // based on cartesian/raster cordinates provided
+ s := idx_src + lx * (y + yint) + x + xint;
+ d := idx_dst + lx * y + x;
+
+ wm1 := w-1;
+ hm1 := h-1;
+ // BSBS:Warning!
+ psrc := src;
+ pdst := dst;
+
+ ((! xh) && {! yh}).if {
+ // no horizontal nor vertical half-pel
+ (average_flag).if {
+ hm1.downto 0 do { j:INTEGER;
+ wm1.downto 0 do { i:INTEGER;
+ di := d+i;
+ v := (1 + pdst.item di + psrc.item (s+i)) >> 1;
+ pdst.put (v.to_uinteger_8) to di;
+ };
+ s := s + lx2;
+ d := d + lx2;
+ };
+ } else {
+ hm1.downto 0 do { j:INTEGER;
+ wm1.downto 0 do { i:INTEGER;
+ pdst.put (psrc.item (s+i)) to (d+i);
+ };
+ s := s + lx2;
+ d := d + lx2;
+ };
+ };
+ } else {
+ ((! xh) && {yh}).if {
+ // no horizontal but vertical half-pel
+ (average_flag).if {
+ hm1.downto 0 do { j:INTEGER;
+ wm1.downto 0 do { i:INTEGER;
+ di := d + i;
+ si := s + i;
+ v := (((1 + psrc.item si + psrc.item (si+lx)) >> 1) + pdst.item di + 1) >> 1;
+ pdst.put (v.to_uinteger_8) to di;
+ };
+ s := s + lx2;
+ d := d + lx2;
+ };
+ } else {
+ hm1.downto 0 do { j:INTEGER;
+ wm1.downto 0 do { i:INTEGER;
+ si := s + i;
+ v := (1 + psrc.item si + psrc.item (si+lx)) >> 1;
+ pdst.put (v.to_uinteger_8) to (d+i);
+ };
+ s := s + lx2;
+ d := d + lx2;
+ };
+ };
+ } else {
+ (xh && {! yh}).if {
+ // horizontal but no vertical half-pel
+ (average_flag).if {
+ hm1.downto 0 do { j:INTEGER;
+ wm1.downto 0 do { i:INTEGER;
+ si := s + i;
+ di := d + i;
+ v := (((1 + psrc.item si + psrc.item (si+1)) >> 1) + pdst.item di + 1) >> 1;
+ pdst.put (v.to_uinteger_8) to di;
+ };
+ s := s + lx2;
+ d := d + lx2;
+ };
+ } else {
+ hm1.downto 0 do { j:INTEGER;
+ wm1.downto 0 do { i:INTEGER;
+ si := s + i;
+ v := (1 + psrc.item si + psrc.item (si+1)) >> 1;
+ pdst.put (v.to_uinteger_8) to (d+i);
+ };
+ s := s + lx2;
+ d := d + lx2;
+ };
+ };
+ } else {
+ // if (xh && yh) horizontal and vertical half-pel
+ (average_flag).if {
+ hm1.downto 0 do { j:INTEGER;
+ wm1.downto 0 do { i:INTEGER;
+ si := s + i;
+ sil := si + lx;
+ di := d + i;
+ v := (((2 + psrc.item si + psrc.item (si+1) +
+ psrc.item sil + psrc.item (sil+1)) >> 2) + pdst.item di + 1) >> 1;
+ pdst.put (v.to_uinteger_8) to di;
+ };
+ s := s + lx2;
+ d := d + lx2;
+ };
+ } else {
+ hm1.downto 0 do { j:INTEGER;
+ wm1.downto 0 do { i:INTEGER;
+ si := s + i;
+ sil := si + lx;
+ v := (2 +
+ psrc.item si + psrc.item (si+1 ) +
+ psrc.item sil + psrc.item (sil+1)
+ ) >> 2;
+ pdst.put (v.to_uinteger_8) to (d+i);
+ };
+ s := s + lx2;
+ d := d + lx2;
+ };
+ };
+ };
+ };
+ };
+
+ );
diff --git a/isaacos/Makefile b/isaacos/Makefile
new file mode 100644
index 0000000..7992c71
--- /dev/null
+++ b/isaacos/Makefile
@@ -0,0 +1,34 @@
+TARGET = x86
+
+startup.sys: startup.li
+
+ lisaac startup.li -t $(TARGET) -D
+# rm startup.sys
+ rm startup
+ mv startup.eof startup.sys
+
+
+boost: startup.li
+ lisaac startup.li -t $(TARGET) -O
+ rm startup
+ mv startup.eof startup.sys
+ tool/script/dosemu c startup.sys .
+ tool/script/dosemu e
+
+
+emul: startup.sys
+
+ tool/script/dosemu c startup.sys .
+ tool/script/dosemu e
+debug: startup.c
+ gcc -O2 -specs=/home/sonntag/svn/isaacos/trunk/isaacos/tool/gcc/x86/specs ./startup.c -o ./startup
+ /home/sonntag/svn/isaacos/trunk/isaacos/tool/elf2eof/elf2eof -p 2048 ./startup -prepend /home/sonntag/svn/isaacos/trunk/isaacos/x86/bootloader/startup.com
+ mv startup.eof startup.sys
+ tool/script/dosemu c startup.sys .
+ tool/script/dosemu e
+clean:
+
+ rm startup.sys
+ rm startup.c
+# rm startup
+ rm -rf *~
diff --git a/isaacos/file_system/ext2/directory_ext2.li b/isaacos/file_system/ext2/directory_ext2.li
new file mode 100644
index 0000000..fe7e0b6
--- /dev/null
+++ b/isaacos/file_system/ext2/directory_ext2.li
@@ -0,0 +1,102 @@
+///////////////////////////////////////////////////////////////////////////////
+// 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; 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 := DIRECTORY_EXT2;
+
+ - bibliography:= "http://www.lisaac.org";
+
+ - author := "Simon Fuhlhaber / Jerome Hilbert";
+
+ - comment := "Directory for EXT2";
+
+Section Inherit
+
+ + parent_entry_ext2:Expanded ENTRY_EXT2;
+ + parent_directory:Expanded DIRECTORY;
+
+Section Public
+
+ - is_open:BOOLEAN <- (list != NULL);
+
+ - open:BOOLEAN <-
+ ( + new_entry:ENTRY_EXT2;
+ + current_block:UINTEGER_32;
+ + inode_no:UINTEGER_32;
+ + offset:UINTEGER_32;
+ + partition:PARTITION_EXT2;
+ + name_lg,file_type:UINTEGER_8;
+ + record_lg:UINTEGER_16;
+
+ (is_open).if_false {
+ // make_inode;
+ list := LINKED_LIST(ENTRY).create;
+ partition ?= FILE_SYSTEM.get_partition Self;
+ current_block:=0;
+ offset:=partition.block_size+1;
+ {
+ (offset>partition.block_size).if{
+ offset:=0;
+ current_block:=current_block+1;
+ partition.set_block_type current_block;
+ partition.set_block (inode.get_block current_block);
+ partition.read;
+ };
+ inode_no:=((partition.buffer.item offset).to_uinteger_32)+
+ ((partition.buffer.item (offset+1)).to_uinteger_32<<8)+
+ ((partition.buffer.item (offset+2)).to_uinteger_32<<16)+
+ ((partition.buffer.item (offset+3)).to_uinteger_32<<24);
+ offset:=offset+4;
+ record_lg:=(
+ partition.buffer.item offset.to_uinteger_16 +
+ partition.buffer.item (offset+1).to_uinteger_16<<8
+ );
+ offset:=offset+2;
+ name_lg:=partition.buffer.item offset;
+ file_type:=partition.buffer.item (offset+1);
+ offset:=offset+2;
+ string_tmp.copy path;
+ string_tmp.add_last '/';
+ offset.to (offset+name_lg-1) do { i:INTEGER;
+ string_tmp.add_last (partition.buffer.item i.to_character);
+ };
+ offset:=offset+record_lg-8;
+ (( ! string_tmp.has_suffix "/." ) && { ! string_tmp.has_suffix "/.." }).if {
+ (file_type.in_range 1 to 2).if {
+ (file_type =2).if {
+ new_entry := DIRECTORY_EXT2.clone;
+ } else {
+ new_entry := STD_FILE_EXT2.clone;
+ };
+ new_entry.set_no_inode inode_no;
+ new_entry.set_path string_tmp;
+ new_entry.set_type_code file_type;
+ list.add_last new_entry;
+ alias.put new_entry to (new_entry.path);
+ };
+ };
+ }.do_until{ record_lg > 266 };
+ list.lower.to (list.upper) do{ j:INTEGER;
+ new_entry ?= item j;
+ new_entry.make_inode;
+ };
+ };
+ TRUE
+ );
+
+
+
+
diff --git a/isaacos/file_system/ext2/entry_ext2.li b/isaacos/file_system/ext2/entry_ext2.li
new file mode 100644
index 0000000..d8bfd4d
--- /dev/null
+++ b/isaacos/file_system/ext2/entry_ext2.li
@@ -0,0 +1,303 @@
+///////////////////////////////////////////////////////////////////////////////
+// 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; 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 := ENTRY_EXT2;
+
+ - bibliography:= "http://www.lisaac.org";
+
+ - author := "Benoit Sonntag (benoit.sonntag at lisaac.org), Jerome Hilbert";
+
+ - comment := "Entry ext2";
+
+Section Inherit
+
+ + parent_abstract_entry:Expanded ENTRY;
+
+Section Public//ENTRY, EXT2
+
+ + type_code:UINTEGER_8;
+
+ + inode:INODE;
+
+ + no_inode:UINTEGER_32:=0;
+
+ - make_inode <-
+ (
+ + block_group:UINTEGER_32;
+ + index,inode_block:UINTEGER_32;
+ + partition:PARTITION_EXT2;
+ + pos:UINTEGER_32;
+ + buf:FAST_ARRAY(UINTEGER_8);
+ + group_desc:GROUP_DESCRIPTOR;
+
+ partition ?= FILE_SYSTEM.get_partition Self;
+ block_group:=(no_inode-1)/partition.nb_inodes_per_group;
+ index:=(no_inode-1)%partition.nb_inodes_per_group;
+
+ pos:=GROUP_DESCRIPTOR.size*block_group;
+ partition.set_block 2;
+ partition.read;
+ buf:=FAST_ARRAY(UINTEGER_8).create_with_capacity (GROUP_DESCRIPTOR.size);
+ pos.to (pos+GROUP_DESCRIPTOR.size)do{i:INTEGER;
+ buf.add_last (partition.buffer.item i);
+ };
+ group_desc:=CONVERT(NATIVE_ARRAY(UINTEGER_8),GROUP_DESCRIPTOR).on (buf.to_native_array);
+
+ pos:=INODE.size*index;
+ inode_block:=pos/partition.block_size;
+ partition.set_block (group_desc.get_inode_table+inode_block);
+ partition.read;
+ pos:=pos%partition.block_size;
+ buf:=FAST_ARRAY(UINTEGER_8).create_with_capacity (INODE.size);
+ pos.to (pos+INODE.size-1)do{i:INTEGER;
+ buf.add_last (partition.buffer.item i);
+ };
+ inode:=CONVERT(NATIVE_ARRAY(UINTEGER_8),INODE).on (buf.to_native_array);
+ );
+
+ - create p:ABSTRACT_STRING :BOOLEAN <-
+ (
+ set_path p;
+ TRUE
+ );
+
+ - find_inode_for_size s:INTEGER <-
+ (
+ + block_group,first:UINTEGER_32;
+ + partition:PARTITION_EXT2;
+ + buf:FAST_ARRAY(UINTEGER_8);
+ + inode_buf:NATIVE_ARRAY(UINTEGER_8);
+ + inode_buf16:NATIVE_ARRAY(UINTEGER_16);
+ + inode_buf32:NATIVE_ARRAY(UINTEGER_32);
+ + group_desc:GROUP_DESCRIPTOR;
+ + pos,keep:INTEGER;
+ + bitmap,bitmap1:UINTEGER_8;
+ + found:BOOLEAN;
+
+ partition ?= FILE_SYSTEM.get_partition Self;
+ block_group := 0;
+ partition.set_block 2;
+ buf:=FAST_ARRAY(UINTEGER_8).create_with_capacity (GROUP_DESCRIPTOR.size);
+ inode_buf := NATIVE_ARRAY(UINTEGER_8).create (INODE.size);
+ inode_buf16 := CONVERT(NATIVE_ARRAY(UINTEGER_8),NATIVE_ARRAY(UINTEGER_16)).on inode_buf;
+ inode_buf32 := CONVERT(NATIVE_ARRAY(UINTEGER_8),NATIVE_ARRAY(UINTEGER_32)).on inode_buf;
+ partition.read;
+ {
+ pos:=GROUP_DESCRIPTOR.size*block_group;
+ pos.to (pos+GROUP_DESCRIPTOR.size) do { i:INTEGER;
+ buf.add_last (partition.buffer.item i);
+ };
+
+ group_desc:=CONVERT(NATIVE_ARRAY(UINTEGER_8),GROUP_DESCRIPTOR).on (buf.to_native_array);
+
+ (s < SUPERBLOCK.get_block_log_size*group_desc.get_free_blocks_count).if {
+ (group_desc.get_free_inodes_count >= 1).if {
+ partition.set_block (group_desc.get_inode_bitmap);
+ partition.read;
+ pos := 0;
+ no_inode := 0;
+ {
+ // search for contigous blocks for size s
+ first := find_contiguous_blocks group_desc size s;
+ (first != -1).if {
+ // search of first free inode in block group
+ bitmap := partition.buffer.item pos;
+ (bitmap != 0FFh).if {
+ keep := no_inode;
+ bitmap1 := bitmap;
+ {bitmap.is_odd}.while_do {
+ bitmap := bitmap >> 1;
+ no_inode := no_inode + 1;
+ };
+ (keep != no_inode-8).if {
+ found := TRUE;
+ bitmap1 := (bitmap1<<1)|1;
+ partition.buffer.put bitmap1 to pos;
+ partition.set_block (group_desc.get_inode_bitmap);
+ partition.write;
+ };
+ } else {
+ no_inode := no_inode + 8;
+ };
+ pos := pos + 1;
+ };
+ }.do_while {(bitmap = 0) && {pos < 512}};
+ };
+ };
+ block_group := block_group + 1;
+ buf.clear;
+ }.do_while {!found};
+
+ no_inode := no_inode + (block_group-1) * partition.nb_inodes_per_group + 1;
+ // inode creation
+ (is_directory).if {
+ inode_buf16.put 04000h to 0;
+ } else {
+ inode_buf16.put 08000h to 0;
+ };
+ // i_blocks
+ inode_buf32.put (s*(SUPERBLOCK.get_block_log_size/512)) to 7;
+ // blocks
+ 0.to (s.min(15)-1) do { k:INTEGER;
+ inode_buf32.put (group_desc.get_inode_table+214+first+k) to (10+k);
+ };
+ inode := CONVERT(NATIVE_ARRAY(UINTEGER_8),INODE).on inode_buf;
+ );
+
+ - find_first_block gd:GROUP_DESCRIPTOR since start:INTEGER :INTEGER <-
+ ( + partition:PARTITION_EXT2;
+ + pos,first,ind:INTEGER;
+ + bitmap:UINTEGER_8;
+
+ partition ?= FILE_SYSTEM.get_partition Self;
+ partition.set_block (gd.get_block_bitmap);
+ partition.read;
+ pos := start / 8 ;//0;
+ ind := start % 8 ;
+ {
+ bitmap := partition.buffer.item pos;
+ (pos = (start / SUPERBLOCK.get_block_log_size )).if {
+ 0.to ind do {k:INTEGER;
+ bitmap := bitmap >> 1;
+ };
+ first := start;
+ };
+ (bitmap != 0FFh).if {
+ {bitmap.is_odd}.while_do {
+ bitmap := bitmap >> 1;
+ first := first + 1;
+ };
+ } else {
+ first := first + 8;
+ };
+ pos := pos + 1;
+ }.do_while {(bitmap != 0FFh) && {pos < 512}};
+ (pos = 512).if {
+ first := -1;
+ };
+ first
+ );
+
+ - find_contiguous gd:GROUP_DESCRIPTOR first ind:INTEGER size s:INTEGER :BOOLEAN <-
+ ( + pos,idx,bc1,rest:INTEGER;
+ + bitmap:UINTEGER_8;
+ + res:BOOLEAN;
+ + partition:PARTITION_EXT2;
+
+ partition ?= FILE_SYSTEM.get_partition Self;
+ partition.set_block (gd.get_block_bitmap);
+ partition.read;
+ pos := ind / 8;
+ idx := ind % 8;
+ rest := s;
+ res := TRUE;
+ {
+ bitmap := partition.buffer.item pos;
+ (pos = (ind / 8 )).if {
+ 0.to ind do {k:INTEGER;
+ bitmap := bitmap >> 1;
+ };
+ ind.to 8 do {
+ ((!bitmap.is_odd)&&{bc1 < block_count}).while_do {
+ bitmap := bitmap >> 1;
+ bc1 := bc1 + 1;
+ };
+ };
+ } else {
+ (rest >= 8).if {
+ (bitmap = 000h).if {
+ bc1 := bc1 + 8;
+ } else {
+ res := FALSE;
+ };
+ } else {
+ 0.to rest do {k:INTEGER;
+ ((!bitmap.is_odd)&&{bc1 < block_count}).while_do {
+ bitmap := bitmap >> 1;
+ bc1 := bc1 + 1;
+ };
+ };
+ };
+ };
+ rest := s - bc1;
+ pos := pos + 1;
+ }.do_while {(rest != 0) && {res = TRUE}};
+ res
+ );
+
+ - find_contiguous_blocks gd:GROUP_DESCRIPTOR size s:INTEGER :INTEGER <-
+ ( + first,block_count:INTEGER;
+ + pos:UINTEGER_32;
+ + partition:PARTITION_EXT2;
+
+ partition ?= FILE_SYSTEM.get_partition Self;
+ partition.set_block (gd.get_block_bitmap);
+ partition.read;
+ block_count := s / SUPERBLOCK.get_block_log_size;
+ (s % SUPERBLOCK.get_block_log_size != 0).if {
+ block_count := block_count + 1;
+ };
+ {
+ first := find_first_block gd since first;
+ }.do_while {(find_contiguous gd size block_count) && {first != -1}};
+ (first != -1).if {
+ pos := first / 8;
+ 0.to ((8-(first%8)).min(block_count)) do { k:INTEGER;
+ partition.buffer.put ((partition.buffer.item pos<<1)|1) to pos ;
+ block_count := block_count - 1;
+ };
+ pos := pos + 1;
+ { block_count > 0 }.while_do {
+ 0.to 8 do { k:INTEGER;
+ partition.buffer.put ((partition.buffer.item pos<<1)|1) to pos ;
+ block_count := block_count - 1;
+ };
+ pos :=pos + 1;
+ };
+ partition.write;
+ };
+ first
+ );
+
+
+Section Public
+ //JHJH: cut into user,group, all rights
+ - access :UINTEGER_16 <- (inode.get_mode);
+
+ - access_date:DATE <- DATE.create_with_sec (inode.get_atime);
+ - access_time:TIME <- TIME.create_with_sec (inode.get_atime);
+
+ - update_date:DATE <- DATE.create_with_sec (inode.get_mtime);
+ - update_time:TIME <- TIME.create_with_sec (inode.get_mtime);
+
+ - create_time:TIME <- TIME.create_with_sec (inode.get_ctime);
+ - create_date:DATE <- DATE.create_with_sec (inode.get_ctime);
+
+ - set_no_inode inode1:UINTEGER_32 <-
+ (
+ no_inode:=inode1;
+ );
+
+ - get_no_inode :UINTEGER_32 <- no_inode;
+
+ - set_type_code type_code1:UINTEGER_8 <-
+ (
+ type_code:=type_code1;
+ );
+
+ - get_type_code :UINTEGER_8 <- type_code;
+
diff --git a/isaacos/file_system/ext2/file_system_ext2.li b/isaacos/file_system/ext2/file_system_ext2.li
new file mode 100644
index 0000000..a91060b
--- /dev/null
+++ b/isaacos/file_system/ext2/file_system_ext2.li
@@ -0,0 +1,161 @@
+///////////////////////////////////////////////////////////////////////////////
+// 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; 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_EXT2;
+
+ - bibliography:="http://www.lisaac.org";
+
+ - author := "Simon Fuhlhaber / Jerome Hilbert";
+
+ - comment :="File System manager for ISAAC - X86.";
+
+Section Inherit
+
+ - parent_directory:DIRECTORY_EXT2 :=DIRECTORY_EXT2;
+
+Section Public
+
+ - floppy:DIRECTORY <-
+ ( + part:PARTITION;
+ + ctrl:CONTROLER;
+ + drv:DRIVE;
+
+ (partition_list.first = NULL).if {
+ // Floppy Controler.
+ ctrl := FLOPPY_CONTROLER.create 3F0h;
+ drv := DRIVE.create ctrl drive 00h;
+ // Init fat12
+ part := FAT12.create drv begin 0;
+ partition_list.put part to 0;
+} else {
+ part := partition_list.first;
+};
+ part.root
+ );
+
+ - lower_part:INTEGER := 0;
+ - upper_part:INTEGER <- partition_list.upper;
+ - count_part:INTEGER <- upper_part + 1;
+
+ - item_part idx:INTEGER :DIRECTORY_EXT2 <-
+ ( + result:DIRECTORY_EXT2;
+ + part:PARTITION_EXT2;
+
+ ? {idx.in_range lower_part to upper_part};
+ (idx = 0).if {
+ // result := floppy;
+ } else {
+ part := partition_list.item idx;
+ result := part.root;
+ };
+ result
+ );
+
+
+Section FILE_SYSTEM, STD_FILE, DIRECTORY, ENTRY
+
+ + partition_list:FAST_ARRAY(PARTITION_EXT2);
+
+ //
+ // Partition Info.
+ //
+
+ - buffer:FAST_ARRAY(UINTEGER_8);
+
+ - read_partition drv:DRIVE begin logical_sector:UINTEGER_32 <-
+ ( + mbr:MBR;
+ + new_part:PARTITION_EXT2;
+ + 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.
+ read_partition drv begin first;
+}.elseif {mbr.is_ext2} then {
+ "\t\tEXT2 detected.\n".print;
+ new_part := EXT2.create drv begin first;
+ partition_list.add_last new_part;
+} else {
+ "\t\tUnknown partition detected (".print;
+ mbr.type.to_hexadecimal.print;
+ "h)\n".print;
+};
+};
+ );
+
+Section STARTUP
+
+ //
+ // Init
+ //
+
+ - make <-
+ ( + ctrl:CONTROLER;
+ + drv:DRIVE;
+
+ partition_list := FAST_ARRAY(PARTITION_EXT2).create_with_capacity 3;
+ partition_list.add_last NULL; // Floppy.
+ // Controler BIOS.
+ ctrl := BIOS_CONTROLER.create 0;
+ drv := DRIVE.create ctrl drive 81h;
+ // Partition.
+ "Mount IDE 1\n".print;
+ buffer := FAST_ARRAY(UINTEGER_8).create_with_capacity 512;
+ read_partition drv begin 0;
+ parent_directory:=item_part 1;
+ );
+
+ - supertest <-
+ (
+ + partition:PARTITION_EXT2;
+ + buf:FAST_ARRAY(UINTEGER_8);
+ + inode:INODE;
+ + group_desc:GROUP_DESCRIPTOR;
+ partition:=partition_list.item 1;
+
+ buf:=FAST_ARRAY(UINTEGER_8).create_with_capacity (GROUP_DESCRIPTOR.size);
+ partition.set_block 2;
+ partition.read;
+
+ (GROUP_DESCRIPTOR.size).to (2*GROUP_DESCRIPTOR.size)do{i:INTEGER;
+ buf.add_last (partition.buffer.item i);
+ };
+ group_desc:=CONVERT(NATIVE_ARRAY(UINTEGER_8),GROUP_DESCRIPTOR).on (buf.to_native_array);
+ group_desc.print;
+ partition.set_block 8259;
+ partition.read;
+ "5\n".print;
+ buf:=FAST_ARRAY(UINTEGER_8).create_with_capacity (INODE.size);
+ 0.to (INODE.size)do{i:INTEGER;
+ buf.add_last (partition.buffer.item i);
+ };
+ inode:=CONVERT(NATIVE_ARRAY(UINTEGER_8),INODE).on (buf.to_native_array);
+ inode.print;
+
+ );
+
diff --git a/isaacos/file_system/ext2/inode.li b/isaacos/file_system/ext2/inode.li
new file mode 100644
index 0000000..19fb550
--- /dev/null
+++ b/isaacos/file_system/ext2/inode.li
@@ -0,0 +1,169 @@
+///////////////////////////////////////////////////////////////////////////////
+// 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; 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 := INODE;
+
+ - bibliography:= "http://www.lisaac.org";
+
+ - author := "Simon Fuhlhaber / Jerome Hilbert";
+
+ - comment := "Inode for Ext2 file";
+
+
+Section Mapping
+
+ + i_mode:UINTEGER_16;
+ + i_uid:UINTEGER_16;
+ + i_size:UINTEGER_32;
+ + i_atime:UINTEGER_32;
+ + i_ctime:UINTEGER_32;
+ + i_mtime:UINTEGER_32;
+ + i_dtime:UINTEGER_32;
+ + i_gid:UINTEGER_16;
+ + i_links_count:UINTEGER_16;
+ + i_blocks:UINTEGER_32;
+ + i_flags:UINTEGER_32;
+ + i_osd1:UINTEGER_32;
+ + i_block1:UINTEGER_32;
+ + i_block2:UINTEGER_32;
+ + i_block3:UINTEGER_32;
+ + i_block4:UINTEGER_32;
+ + i_block5:UINTEGER_32;
+ + i_block6:UINTEGER_32;
+ + i_block7:UINTEGER_32;
+ + i_block8:UINTEGER_32;
+ + i_block9:UINTEGER_32;
+ + i_blocka:UINTEGER_32;
+ + i_blockb:UINTEGER_32;
+ + i_blockc:UINTEGER_32;
+ + i_blockd:UINTEGER_32;
+ + i_blocke:UINTEGER_32;
+ + i_blockf:UINTEGER_32;
+ + i_generation:UINTEGER_32;
+ + i_file_acl:UINTEGER_32;
+ + i_dir_acl:UINTEGER_32;
+ + i_faddr:UINTEGER_32;
+ + i_osd20:UINTEGER_64;
+ + i_osd21:UINTEGER_32;
+
+Section Public
+
+ - size:UINTEGER_32 := 128;
+
+ - block_size:UINTEGER_32 <- SUPERBLOCK.get_block_size;
+
+ - get_block index:UINTEGER_32 :UINTEGER_32<-
+ ( + result:UINTEGER_32;
+ + block:NATIVE_ARRAY(UINTEGER_32);
+
+ (index < 13).if {
+ block := CONVERT(INODE,NATIVE_ARRAY(UINTEGER_32)).on Self;
+ result := block.item (index + 9);
+ }.elseif {index<=(12+block_size/4)} then {
+ result := i_blockd;
+ }.elseif {index<=(12+(block_size*block_size)/4)} then {
+ result := i_blocke;
+ }.elseif {index<=(12+(block_size*block_size*block_size)/4)} then {
+ result := i_blockf;
+ };
+ result
+ );
+
+ //
+ // Getteurs de la section Mapping
+ //
+
+ - get_mode :UINTEGER_16 <- i_mode;
+ - get_uid :UINTEGER_16 <- i_uid;
+ - get_size :UINTEGER_32 <- i_size;
+ - get_atime :UINTEGER_32 <- i_atime;
+ - get_ctime :UINTEGER_32 <- i_ctime;
+ - get_mtime :UINTEGER_32 <- i_mtime;
+
+
+ //
+ // Setteur de la section Mapping
+ //
+
+ - print <-
+ (
+
+ "i_mode: ".print;
+ i_mode.print;"\n".print;
+ "i_uid: ".print;
+ i_uid.print;"\n".print;
+ "i_size: ".print;
+ i_size.print;"\n".print;
+ "i_atime: ".print;
+ i_atime.print;"\n".print;
+ "i_ctime: ".print;
+ i_ctime.print;"\n".print;
+ "i_mtime: ".print;
+ i_mtime.print;"\n".print;
+ "i_dtime: ".print;
+ i_dtime.print;"\n".print;
+ "i_gid: ".print;
+ i_gid.print;"\n".print;
+ "i_links_count: ".print;
+ i_links_count.print;"\n".print;
+ "i_blocks: ".print;
+ i_blocks.print;"\n".print;
+ "i_flags: ".print;
+ i_flags.print;"\n".print;
+ "i_osd1: ".print;
+ i_osd1.print;"\n".print;
+ KEYBOARD.wait_key;
+ "i_block1: ".print;
+ i_block1.print;"\n".print;
+ "i_block2: ".print;
+ i_block2.print;"\n".print;
+ "i_block3: ".print;
+ i_block3.print;"\n".print;
+ "i_block4: ".print;
+ i_block4.print;"\n".print;
+ "i_block5: ".print;
+ i_block5.print;"\n".print;
+ "i_block6: ".print;
+ i_block6.print;"\n".print;
+ "i_block7: ".print;
+ i_block7.print;"\n".print;
+ "i_block8: ".print;
+ i_block8.print;"\n".print;
+ "i_block9: ".print;
+ i_block9.print;"\n".print;
+ "i_blocka: ".print;
+ i_blocka.print;"\n".print;
+ "i_blockb: ".print;
+ i_blockb.print;"\n".print;
+ "i_blockc: ".print;
+ i_blockc.print;"\n".print;
+ "i_blockd: ".print;
+ i_blockd.print;"\n".print;
+ "i_blocke: ".print;
+ i_blocke.print;"\n".print;
+ "i_blockf: ".print;
+ i_blockf.print;"\n".print;
+ KEYBOARD.wait_key;
+ "i_generation: ".print;
+ i_generation.print;"\n".print;
+ "i_file_acl: ".print;
+ i_file_acl.print;"\n".print;
+ "i_dir_acl: ".print;
+ i_dir_acl.print;"\n".print;
+ "i_faddr: ".print;
+ i_faddr.print;"\n".print;
+ );
diff --git a/isaacos/file_system/ext2/partition/ext2.li b/isaacos/file_system/ext2/partition/ext2.li
new file mode 100644
index 0000000..9ef4ed4
--- /dev/null
+++ b/isaacos/file_system/ext2/partition/ext2.li
@@ -0,0 +1,58 @@
+///////////////////////////////////////////////////////////////////////////////
+// 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; 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 := EXT2;
+
+
+ - bibliography:="http://www.lisaac.org";
+ - author :="Simon Fuhlhaber / Jerome Hilbert";
+ - comment :="EXT2 Type Partition .";
+
+Section Inherit
+
+ + parent_partition:Expanded PARTITION_EXT2;
+
+Section Private
+
+ - sector:UINTEGER_32<- first_block_sector+(block-1)*step;
+
+Section Public
+
+ - make drv:DRIVE begin fsector:UINTEGER_32 <-
+ (
+ + buf:FAST_ARRAY(UINTEGER_8);
+
+ drive := drv;
+ first_block_sector := (fsector+(SUPERBLOCK.sector));
+ buffer := FAST_ARRAY(UINTEGER_8).create_with_capacity 512;
+ drive.set_cursor first_block_sector;
+ drive.read buffer size 1;
+ buf:=FAST_ARRAY(UINTEGER_8).create_with_capacity (SUPERBLOCK.size);
+ 0.to (SUPERBLOCK.size-1)do{i:INTEGER;
+ buf.add_last (buffer.item i);
+ };
+ superblock:=CONVERT(NATIVE_ARRAY(UINTEGER_8),SUPERBLOCK).on (buf.to_native_array);
+ );
+
+ - make <-
+ (
+ set_path "/ext2";
+ set_no_inode 2;
+ set_type_code 2;
+ make_inode;
+ );
+
diff --git a/isaacos/file_system/ext2/partition/group_descriptor.li b/isaacos/file_system/ext2/partition/group_descriptor.li
new file mode 100644
index 0000000..6415cf9
--- /dev/null
+++ b/isaacos/file_system/ext2/partition/group_descriptor.li
@@ -0,0 +1,75 @@
+///////////////////////////////////////////////////////////////////////////////
+// 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; 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 := GROUP_DESCRIPTOR;
+
+
+ - bibliography:= "http://www.lisaac.org";
+ - author := "Simon Fuhlhaber / Jerome Hilbert";
+ - comment := "group descriptor of ext2 partition";
+
+ - date := "2008";
+
+Section Mapping
+
+ + bg_block_bitmap:UINTEGER_32;
+ + bg_inode_bitmap:UINTEGER_32;
+ + bg_inode_table:UINTEGER_32;
+ + bg_free_blocks_count:UINTEGER_16;
+ + bg_free_inodes_count:UINTEGER_16;
+ + bg_used_dirs_count:UINTEGER_16;
+ + bg_pad:UINTEGER_16;
+ + bg_reserved0:UINTEGER_64;
+ + bg_reserved1:UINTEGER_32;
+
+Section Public
+
+ - size:UINTEGER_32 <- 32;
+
+ - get_inode_table :UINTEGER_32 <- bg_inode_table;
+
+ - get_free_blocks_count :UINTEGER_16 <- bg_free_blocks_count;
+
+ - get_free_inodes_count :UINTEGER_16 <- bg_free_inodes_count;
+
+ - get_inode_bitmap :UINTEGER_32 <- bg_inode_bitmap;
+
+ - get_block_bitmap :UINTEGER_32 <- bg_block_bitmap;
+
+
+ - print <-
+ (
+ "bg_block_bitmap: ".print;
+ bg_block_bitmap.print;"\n".print;
+ "bg_inode_bitmap: ".print;
+ bg_inode_bitmap.print;"\n".print;
+ "bg_inode_table: ".print;
+ bg_inode_table.print;"\n".print;
+ "bg_free_blocks_count: ".print;
+ bg_free_blocks_count.print;"\n".print;
+ "bg_free_inodes_count: ".print;
+ bg_free_inodes_count.print;"\n".print;
+ "bg_used_dirs_count: ".print;
+ bg_used_dirs_count.print;"\n".print;
+ "bg_pad: ".print;
+ bg_pad.print;"\n".print;
+ /*"bg_reserved0".print;
+ bg_reserved0.print;"\n".print;
+ "bg_reserved1".print;
+ bg_reserved1.print;"\n".print;*/
+ );
+
diff --git a/isaacos/file_system/ext2/partition/partition_ext2.li b/isaacos/file_system/ext2/partition/partition_ext2.li
new file mode 100644
index 0000000..927b042
--- /dev/null
+++ b/isaacos/file_system/ext2/partition/partition_ext2.li
@@ -0,0 +1,127 @@
+///////////////////////////////////////////////////////////////////////////////
+// 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; 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 := PARTITION_EXT2;
+
+
+ - bibliography:= "http://www.lisaac.org";
+ - author := "Simon Fuhlhaber / Jerome Hilbert";
+ - comment := "Partition Hard disk.";
+
+Section Inherit
+
+ + parent_directory:Expanded DIRECTORY_EXT2;
+ + parent_partition:Expanded PARTITION;
+
+Section Private
+
+ - sector:UINTEGER_32<- deferred;
+ // cluster to sector.
+
+ + superblock:SUPERBLOCK;
+
+ + block:UINTEGER_32;
+ + array_block1:UINTEGER_32;
+ + array_block2:UINTEGER_32;
+ + array_block3:UINTEGER_32;
+ + block_type:UINTEGER_32;
+ - nb_block_13:UINTEGER_32<- block_size/4;
+ - nb_block_14:UINTEGER_32<- nb_block_13*nb_block_13;
+ - nb_block_15:UINTEGER_32<- nb_block_14*nb_block_13;
+
+ + step:UINTEGER_32 <- sector_per_block;
+
+ + get_block_from idx:INTEGER :UINTEGER_32 <-
+ (
+ ((buffer.item idx).to_uinteger_32)
+ +((buffer.item (idx+1)).to_uinteger_32<<8)
+ +((buffer.item (idx+2)).to_uinteger_32<<16)
+ +((buffer.item (idx+3)).to_uinteger_32<<24)
+ );
+
+Section STD_FILE_EXT2,DIRECTORY_EXT2,ENTRY_EXT2
+
+ - set_block_type b:UINTEGER_32 <-
+ (
+ (b<=12).if
+ {
+ block_type:=0;
+ }.elseif{b<=(12+nb_block_13)} then
+ {
+ block_type:=1;
+ array_block1:=b-12;
+ }.elseif{b<=(12+nb_block_13+nb_block_14)} then
+ {
+ block_type:=2;
+ array_block1:=(b-12-nb_block_13-1)/nb_block_13;
+ array_block2:=(b-12-nb_block_13-1)%nb_block_13;
+ }.elseif{b<=(12+nb_block_13+nb_block_14+nb_block_15)} then
+ {
+ block_type:=3;
+ array_block1:=(b-12-nb_block_13-nb_block_14-1)/nb_block_14;
+ array_block2:=((b-12-nb_block_13-nb_block_14-1)%nb_block_14)/nb_block_13;
+ array_block3:=(b-12-nb_block_13-nb_block_14-1)%nb_block_13;
+ };
+ );
+ - set_block b:UINTEGER_32 <-
+ (
+ + idx:INTEGER;
+ (block_type=0).if
+ {
+ block:=b;
+ }.elseif{block_type=1} then
+ {
+ block:=b;
+ read;
+ idx:=(array_block1)*4;
+ block:=get_block_from idx;
+ }.elseif {block_type=2} then {
+ block:=b;
+ read;
+ idx:=array_block1*4;
+ block:=get_block_from idx;
+ read;
+ idx:=array_block2*4;
+ block:=get_block_from idx;
+ }.elseif {block_type=3} then {
+ block:=b;
+ read;
+ idx:=array_block1*4;
+ block:=get_block_from idx;
+ read;
+ idx:=array_block2*4;
+ block:=get_block_from idx;
+ read;
+ idx:=array_block3*4;
+ block:=get_block_from idx;
+ };
+ );
+
+
+
+Section Public
+
+ + first_block_sector:UINTEGER_32;
+
+ - block_size:UINTEGER_32<- superblock.get_block_size;
+
+
+ - sector_per_block:UINTEGER_32 <- block_size/DRIVE.sector_size;
+
+ - nb_inodes_per_group:UINTEGER_32<- superblock.get_inodes_per_group;
+
+
diff --git a/isaacos/file_system/ext2/partition/superblock.li b/isaacos/file_system/ext2/partition/superblock.li
new file mode 100644
index 0000000..47321d2
--- /dev/null
+++ b/isaacos/file_system/ext2/partition/superblock.li
@@ -0,0 +1,118 @@
+///////////////////////////////////////////////////////////////////////////////
+// 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; 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 := SUPERBLOCK;
+
+
+ - bibliography:= "http://www.lisaac.org";
+ - author := "Simon Fuhlhaber / Jerome Hilbert";
+ - comment := "superblock of ext2 partition";
+
+ - date := "2008";
+
+Section Mapping
+ + s_inodes_count:UINTEGER_32;
+ + s_blocks_count:UINTEGER_32;
+ + s_r_blocks_count:UINTEGER_32;
+ + s_free_blocks_count:UINTEGER_32;
+ + s_free_inodes_count:UINTEGER_32;
+ + s_first_data_block:UINTEGER_32;
+ + s_log_block_size:UINTEGER_32;
+ + s_log_frag_size:UINTEGER_32;
+ + s_blocks_per_group:UINTEGER_32;
+ + s_frags_per_group:UINTEGER_32;
+ + s_inodes_per_group:UINTEGER_32;
+ + s_mtime:UINTEGER_32;
+ + s_wtime:UINTEGER_32;
+ + s_mnt_count:UINTEGER_16;
+ + s_max_mnt_count:UINTEGER_16;
+ + s_magic:UINTEGER_16;
+ + s_state:UINTEGER_16;
+ + s_errors:UINTEGER_16;
+ + s_minor_rev_level:UINTEGER_16;
+ + s_lastcheck:UINTEGER_32;
+ + s_checkinterval:UINTEGER_32;
+ + s_creator_os:UINTEGER_32;
+ + s_rev_level:UINTEGER_32;
+ + s_def_resuid:UINTEGER_16;
+ + s_def_resgid:UINTEGER_16;
+ //-- EXT2_DYNAMIC_REV Specific --
+ + s_first_ino:UINTEGER_32;
+ + s_inode_size:UINTEGER_16;
+ + s_block_group_nr:UINTEGER_16;
+ + s_feature_compat:UINTEGER_32;
+ + s_feature_incompat:UINTEGER_32;
+ + s_feature_ro_compat:UINTEGER_32;
+ + s_uuid1:UINTEGER_64;
+ + s_uuid2:UINTEGER_64;
+ + s_volume_name1:UINTEGER_64;
+ + s_volume_name2:UINTEGER_64;
+ + s_last_mounted1:UINTEGER_64;
+ + s_last_mounted2:UINTEGER_64;
+ + s_last_mounted3:UINTEGER_64;
+ + s_last_mounted4:UINTEGER_64;
+ + s_last_mounted5:UINTEGER_64;
+ + s_last_mounted6:UINTEGER_64;
+ + s_last_mounted7:UINTEGER_64;
+ + s_last_mounted8:UINTEGER_64;
+ + s_algo_bitmap:UINTEGER_32;
+
+// -- Performance Hints --
+ + s_prealloc_blocks:UINTEGER_8;
+ + s_prealloc_dir_blocks:UINTEGER_8;
+ + alignment:UINTEGER_16;
+
+ Section Public
+
+ - sector:UINTEGER_32 <- 2;
+
+ - size:UINTEGER_32 <- 208;
+
+ - get_block_size:UINTEGER_32 <- 1024 << s_log_block_size;
+
+ - get_inodes_per_group:UINTEGER_32 <- s_inodes_per_group;
+
+ - get_block_log_size:UINTEGER_32<- s_log_block_size;
+
+ - print<-
+ (
+
+ "s_inodes_count ".print;
+ s_inodes_count.print;"\n".print;
+ "s_blocks_count ".print;
+ s_blocks_count.print;"\n".print;
+ "s_r_blocks_count ".print;
+ s_r_blocks_count.print;"\n".print;
+ "s_free_blocks_count ".print;
+ s_free_blocks_count.print;"\n".print;
+ "s_free_inodes_count ".print;
+ s_free_inodes_count.print;"\n".print;
+ "s_first_data_block ".print;
+ s_first_data_block.print;"\n".print;
+ "s_log_block_size ".print;
+ s_log_block_size.print;"\n".print;
+ "s_log_frag_size ".print;
+ s_log_frag_size.print;"\n".print;
+ "s_blocks_per_group ".print;
+ s_blocks_per_group.print;"\n".print;
+ "s_frags_per_group ".print;
+ s_frags_per_group.print;"\n".print;
+ "s_inodes_per_group ".print;
+ s_inodes_per_group.print;"\n".print;
+ );
+
diff --git a/isaacos/file_system/ext2/std_file_ext2.li b/isaacos/file_system/ext2/std_file_ext2.li
new file mode 100644
index 0000000..29753b3
--- /dev/null
+++ b/isaacos/file_system/ext2/std_file_ext2.li
@@ -0,0 +1,129 @@
+///////////////////////////////////////////////////////////////////////////////
+// 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; 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 := STD_FILE_EXT2;
+
+ - bibliography:= "http://www.lisaac.org";
+
+ - author := "Simon Fuhlhaber / Jerome Hilbert";
+
+ - comment := "Standard File for EXT2";
+
+Section Inherit
+
+ + parent_entry_ext2:Expanded ENTRY_EXT2;
+ + parent_file:Expanded STD_FILE;
+
+Section Public
+
+ - is_open:BOOLEAN <- (no_inode!=0);
+
+ + cursor:UINTEGER_32;
+
+ - set_cursor n:UINTEGER_32 <-
+ (
+ cursor := n;
+ );
+
+ - size:UINTEGER_32 <- (inode.get_size);
+
+ - open:BOOLEAN <-
+ (
+ // make_inode;
+ TRUE
+ );
+
+ - open_read_only:BOOLEAN <- open;
+
+ - close <-
+ (
+ cursor := 0;
+ );
+
+Section STD_FILE
+
+ - physical_read buf:NATIVE_ARRAY(UINTEGER_8) size s:INTEGER :INTEGER <-
+ (
+ + n,lower,upper,current_block,idx:UINTEGER_32;
+ + partition:PARTITION_EXT2;
+
+ partition ?= FILE_SYSTEM.get_partition Self;
+ current_block:=cursor/partition.block_size;
+ (cursor+s>size).if{
+ n:=size-cursor;
+ }else{
+ n:=s;
+ };
+ lower:=cursor%partition.block_size;
+ idx:=0;
+ {n=0}.until_do{
+ current_block:=current_block+1;
+ partition.set_block_type current_block;
+ partition.set_block (inode.get_block current_block);
+ partition.read;
+ ((lower+n)<(partition.block_size)).if{
+ upper:=lower+n-1;
+ }else{
+ upper:=partition.block_size-1;
+ };
+ lower.to upper do { i:INTEGER;
+ buf.put (partition.buffer.item i) to idx;
+ idx:=idx+1;
+ };
+ n:=n-(upper-lower+1);
+ lower:=0;
+ };
+ idx.to_integer
+ );
+
+
+ - physical_write buf:NATIVE_ARRAY(UINTEGER_8) size s:INTEGER :INTEGER <-
+ (
+ + n,lower,upper,current_block,idx:UINTEGER_32;
+ + partition:PARTITION_EXT2;
+
+ partition ?= FILE_SYSTEM.get_partition Self;
+
+ current_block:=cursor/partition.block_size;
+ (cursor+s>size).if{
+ n:=size-cursor;
+ }else{
+ n:=s;
+ };
+ lower:=cursor%partition.block_size;
+ idx:=0;
+ {n=0}.until_do{
+
+ ((lower+n)<(partition.block_size)).if{
+ upper:=lower+n-1;
+ }else{
+ upper:=partition.block_size-1;
+ };
+ lower.to upper do { i:INTEGER;
+ partition.buffer.put (buf.item idx) to i;
+ idx:=idx+1;
+ };
+ n:=n-(upper-lower+1);
+ lower:=0;
+
+ current_block:=current_block+1;
+ partition.set_block_type current_block;
+ partition.set_block (inode.get_block current_block);
+ partition.write;
+ };
+ idx.to_integer
+ );
diff --git a/isaacos/file_system/fat/directory_fat.li b/isaacos/file_system/fat/directory_fat.li
new file mode 100755
index 0000000..efc5a68
--- /dev/null
+++ b/isaacos/file_system/fat/directory_fat.li
@@ -0,0 +1,98 @@
+///////////////////////////////////////////////////////////////////////////////
+// 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; 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 := DIRECTORY_FAT;
+
+ - bibliography:= "http://www.lisaac.org";
+
+ - author := "Benoit Sonntag (benoit.sonntag at lisaac.org)";
+
+ - comment := "Directory for FAT";
+
+Section Inherit
+
+ + parent_entry_fat:Expanded ENTRY_FAT;
+ + parent_directory:Expanded DIRECTORY;
+
+Section Public
+
+ - is_open:BOOLEAN <- (list != NULL);
+
+ - open:BOOLEAN <-
+ ( + new_entry:ENTRY_FAT;
+ + nb_entry_cluster:UINTEGER_32;
+ + entry:SFN_FAT;
+ + j:UINTEGER_32;
+ + buffer_raw:NATIVE_ARRAY(UINTEGER_8);
+ + partition:PARTITION_FAT;
+ + base,cpt:INTEGER;
+ + is_again:BOOLEAN;
+
+ (is_open).if_false {
+ partition ?= FILE_SYSTEM.get_partition Self;
+ partition.set_cluster position;
+ list := LINKED_LIST(ENTRY).create;
+ nb_entry_cluster := partition.step_byte >> 5;
+ {
+ partition.read;
+ is_again := partition.next_cluster;
+ buffer_raw := partition.buffer.to_native_array;
+ j := 0;
+ {
+ entry := CONVERT(NATIVE_ARRAY(UINTEGER_8),SFN_FAT).on (buffer_raw + (j*SFN_FAT.object_size));
+ (entry.is_label).if {
+ string_tmp.copy "/";
+ entry.name_in string_tmp;
+ cpt := 1;
+ base := string_tmp.count;
+ {alias.has string_tmp}.while_do {
+ string_tmp.keep_head base;
+ cpt.append_in string_tmp;
+ cpt := cpt + 1;
+ };
+ set_path string_tmp;
+ }.elseif {entry.is_valid && {!entry.is_me} && {!entry.is_parent}} then {
+ (entry.is_directory).if{
+ new_entry := DIRECTORY_FAT.create path with entry;
+ } else {
+ new_entry := STD_FILE_FAT.create path with entry;
+ };
+ list.add_last new_entry;
+ alias.put new_entry to (new_entry.path);
+ };
+ j:=j+1;
+ }.do_while {(j < nb_entry_cluster) && {!entry.is_null}};
+ }.do_while {(!entry.is_null) && {is_again}};
+ };
+ TRUE
+ );
+
+Section DIRECTORY
+
+
+ - physical_make_directory new_path:STRING :BOOLEAN <-
+ (
+ not_yet_implemented;
+ FALSE
+ );
+
+ - physical_make_file new_path:STRING :BOOLEAN <-
+ (
+ not_yet_implemented;
+ FALSE
+ );
+
diff --git a/isaacos/file_system/fat/entry_fat.li b/isaacos/file_system/fat/entry_fat.li
new file mode 100755
index 0000000..2b78940
--- /dev/null
+++ b/isaacos/file_system/fat/entry_fat.li
@@ -0,0 +1,81 @@
+///////////////////////////////////////////////////////////////////////////////
+// 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; 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 := ENTRY_FAT;
+
+ - bibliography:= "http://www.lisaac.org";
+
+ - author :=
+ "Benoit Sonntag (benoit.sonntag at lisaac.org), \
+ \Jerome Boutet (pisteur at free.fr)";
+
+ - comment := "Entry FAT";
+
+Section Inherit
+
+ + parent_abstract_entry:Expanded ENTRY;
+
+Section ENTRY, FAT
+
+ + position:UINTEGER_32;
+
+ - create parent_path:ABSTRACT_STRING with e:SFN_FAT :SELF <-
+ ( + result:SELF;
+
+ result := clone;
+ result.make parent_path with e;
+ result
+ );
+
+ - make parent_path:ABSTRACT_STRING with e:SFN_FAT <-
+ (
+ string_tmp.copy parent_path;
+ string_tmp.add_last '/';
+ e.name_in string_tmp;
+ reduce_path string_tmp;
+ set_path string_tmp;
+ is_directory := e.is_directory;
+ /*
+ access_date := e.access_date;
+ access_time := e.access_time;
+ update_date := e.update_date;
+ update_time := e.update_time;
+ create_date := e.create_date;
+ create_time := e.create_time;
+ */
+
+ position := e.position;
+ size := e.size;
+ );
+
+Section Public//ENTRY, EXT2
+
+ - access:UINTEGER_16 := 0777o;
+
+ + is_directory:BOOLEAN;
+
+ + access_date:DATE;
+ + access_time:TIME;
+
+ + update_date:DATE;
+ + update_time:TIME;
+
+ + create_date:DATE;
+ + create_time:TIME;
+
+ + size:UINTEGER_32;
+
diff --git a/isaacos/file_system/fat/lfn_fat.li b/isaacos/file_system/fat/lfn_fat.li
new file mode 100755
index 0000000..61ef78a
--- /dev/null
+++ b/isaacos/file_system/fat/lfn_fat.li
@@ -0,0 +1,130 @@
+///////////////////////////////////////////////////////////////////////////////
+// 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; 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 := LFN_FAT;
+
+ - category := MICRO;
+
+ - bibliography:= "http://www.lisaac.org";
+
+ - author :=
+ "Benoit Sonntag (benoit.sonntag at lisaac.org), \
+ \Jerome Boutet (pisteur at free.fr)";
+
+ - comment := "";
+
+Section Inherit
+
+ - parent_lfn:LFN := LFN;
+
+Section Mapping
+
+ + stat:UINTEGER_8;
+
+ + name1_0:UINTEGER_16;
+ + name1_1:UINTEGER_16;
+ + name1_2:UINTEGER_16;
+ + name1_3:UINTEGER_16;
+ + name1_4:UINTEGER_16;
+
+ + attr:UINTEGER_8;
+
+ + reserved:UINTEGER_8;
+
+ + checksum:UINTEGER_8;
+
+ + name2_0:UINTEGER_16;
+ + name2_1:UINTEGER_16;
+ + name2_2:UINTEGER_16;
+ + name2_3:UINTEGER_16;
+ + name2_4:UINTEGER_16;
+ + name2_5:UINTEGER_16;
+
+ + cluster:UINTEGER_16;
+
+ + name3_0:UINTEGER_16;
+ + name3_1:UINTEGER_16;
+ + name3_2:UINTEGER_16;
+
+Section Public
+
+ - name1:FAST_ARRAY(CHAR_UNICODE) <-
+ ( + result:FAST_ARRAY(CHAR_UNICODE);
+ result := FAST_ARRAY(CHAR_UNICODE).create 5;
+ result.put (name1_0.to_char_unicode) to 0;
+ result.put (name1_1.to_char_unicode) to 1;
+ result.put (name1_2.to_char_unicode) to 2;
+ result.put (name1_3.to_char_unicode) to 3;
+ result.put (name1_4.to_char_unicode) to 4;
+ result
+ );
+
+ - name2:FAST_ARRAY(CHAR_UNICODE) <-
+ ( + result:FAST_ARRAY(CHAR_UNICODE);
+ result := FAST_ARRAY(CHAR_UNICODE).create 6;
+ result.put (name2_0.to_char_unicode) to 0;
+ result.put (name2_1.to_char_unicode) to 1;
+ result.put (name2_2.to_char_unicode) to 2;
+ result.put (name2_3.to_char_unicode) to 3;
+ result.put (name2_4.to_char_unicode) to 4;
+ result.put (name2_5.to_char_unicode) to 5;
+ result
+ );
+
+ - name3:FAST_ARRAY(CHAR_UNICODE) <-
+ ( + result:FAST_ARRAY(CHAR_UNICODE);
+ result := FAST_ARRAY(CHAR_UNICODE).create 3;
+ result.put (name3_0.to_char_unicode) to 0;
+ result.put (name3_1.to_char_unicode) to 1;
+ result.put (name3_2.to_char_unicode) to 2;
+ result
+ );
+
+ - print <-
+ (
+ "\nName : ".print;
+ 0.to 5 do { i:INTEGER;
+ name1.item i.print;
+ };
+ 0.to 6 do { i:INTEGER;
+ name2.item i.print;
+ };
+ 0.to 3 do { i:INTEGER;
+ name3.item i.print;
+ };
+ "\nStat : ".print;
+ stat.print;
+ print(" ");
+ ((stat & 80h) = 1).if {
+ "Erased".print;
+ };
+ ((stat & 40h) = 1).if {
+ "End Entry".print;
+ };
+ ((stat & 3Fh) = 1).if {
+ "Entry".print;
+ };
+
+ "\nChecksum : ".print;
+ checksum.print;
+
+ "\n---------------\n".print;
+
+ KEYBOARD.wait_key;
+ KEYBOARD.wait_key;
+ );
+
diff --git a/isaacos/file_system/fat/partition/boot.li b/isaacos/file_system/fat/partition/boot.li
new file mode 100755
index 0000000..b860530
--- /dev/null
+++ b/isaacos/file_system/fat/partition/boot.li
@@ -0,0 +1,271 @@
+///////////////////////////////////////////////////////////////////////////////
+// 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; 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 :=BOOT;
+
+ - bibliography:="http://www.lisaac.org";
+ - author :="Sonntag Benoit (benoit.sonntag at lisaac.org)";
+ - comment :="Boot sector.";
+
+Section Inherit
+
+ - parent_object:OBJECT := OBJECT;
+
+Section Mapping
+
+ + jump_0:UINTEGER_8;
+ + jump_1:UINTEGER_16;
+
+ // OEM
+ + oem_00:CHARACTER;
+ + oem_01:CHARACTER;
+ + oem_02:CHARACTER;
+ + oem_03:CHARACTER;
+ + oem_04:CHARACTER;
+ + oem_05:CHARACTER;
+ + oem_06:CHARACTER;
+ + oem_07:CHARACTER;
+
+ // Bios parameter block (BPB)
+ + bytes_per_sector:UINTEGER_16;
+ + get_sectors_per_cluster:UINTEGER_8; // 0Dh
+ + get_sectors_reserved:UINTEGER_16; // OEh
+ + get_nb_fat:UINTEGER_8; // 10h
+ + get_nb_root_entries:UINTEGER_16; // 11h
+ + nb_sectors:UINTEGER_16; // 13h
+ + descriptor:UINTEGER_8; // 15h
+ + get_sectors_per_fat:UINTEGER_16; // 16h
+ + sectors_per_track:UINTEGER_16;
+ + nb_head:UINTEGER_16;
+ + hidden_sectors:UINTEGER_32; // 1Ch
+ + nb_sectors_big:UINTEGER_32; // 20h
+
+ // ( Fat 32bits )
+ + get_sectors_per_fat32:UINTEGER_32; // 24h : Nbr Sector per FAT - 1
+ + flags_fat:UINTEGER_16; // 28h
+ + version_fat:UINTEGER_16; // 2Ah
+ + get_cluster_start_root:UINTEGER_32;// 2Ch
+ + fs_info_sector:UINTEGER_16; // 30h
+ + reserved_00:UINTEGER_16;
+ + reserved_01:UINTEGER_32;
+ + reserved_02:UINTEGER_32;
+ + reserved_03:UINTEGER_32;
+
+ // Drive information
+ + bios_drive:UINTEGER_8;
+ + reserved_04:UINTEGER_8;
+ + ext_boot_signature:UINTEGER_8; // 29h
+ + serial_number:UINTEGER_32;
+
+ + vol_label_00:CHARACTER;
+ + vol_label_01:CHARACTER;
+ + vol_label_02:CHARACTER;
+ + vol_label_03:CHARACTER;
+ + vol_label_04:CHARACTER;
+ + vol_label_05:CHARACTER;
+ + vol_label_06:CHARACTER;
+ + vol_label_07:CHARACTER;
+ + vol_label_08:CHARACTER;
+ + vol_label_09:CHARACTER;
+ + vol_label_10:CHARACTER;
+
+ + fs_label_00:CHARACTER;
+ + fs_label_01:CHARACTER;
+ + fs_label_02:CHARACTER;
+ + fs_label_03:CHARACTER;
+ + fs_label_04:CHARACTER;
+ + fs_label_05:CHARACTER;
+ + fs_label_06:CHARACTER;
+ + fs_label_07:CHARACTER;
+
+ // Isaac data
+
+ + sector_cluster:UINTEGER_32; // First cluster position.
+ + sector_root :UINTEGER_32; // Root position.
+ + sector_fat :UINTEGER_32; // FAT position.
+ + cluster :UINTEGER_32; // Cluster current.
+
+ + code000 :UINTEGER_64;
+ + code001 :UINTEGER_64;
+ + code002 :UINTEGER_64;
+ + code003 :UINTEGER_64;
+ + code004 :UINTEGER_64;
+ + code005 :UINTEGER_64;
+ + code006 :UINTEGER_64;
+ + code007 :UINTEGER_64;
+ + code008 :UINTEGER_64;
+ + code009 :UINTEGER_64;
+ + code010 :UINTEGER_64;
+ + code011 :UINTEGER_64;
+ + code012 :UINTEGER_64;
+ + code013 :UINTEGER_64;
+ + code014 :UINTEGER_64;
+ + code015 :UINTEGER_64;
+ + code016 :UINTEGER_64;
+ + code017 :UINTEGER_64;
+ + code018 :UINTEGER_64;
+ + code019 :UINTEGER_64;
+ + code020 :UINTEGER_64;
+ + code021 :UINTEGER_64;
+ + code022 :UINTEGER_64;
+ + code023 :UINTEGER_64;
+ + code024 :UINTEGER_64;
+ + code025 :UINTEGER_64;
+ + code026 :UINTEGER_64;
+ + code027 :UINTEGER_64;
+ + code028 :UINTEGER_64;
+ + code029 :UINTEGER_64;
+ + code030 :UINTEGER_64;
+ + code031 :UINTEGER_64;
+ + code032 :UINTEGER_64;
+ + code033 :UINTEGER_64;
+ + code034 :UINTEGER_64;
+ + code035 :UINTEGER_64;
+ + code036 :UINTEGER_64;
+ + code037 :UINTEGER_64;
+ + code038 :UINTEGER_64;
+ + code039 :UINTEGER_64;
+ + code040 :UINTEGER_64;
+ + code041 :UINTEGER_64;
+ + code042 :UINTEGER_64;
+ + code043 :UINTEGER_64;
+ + code044 :UINTEGER_64;
+ + code045 :UINTEGER_64;
+ + code046 :UINTEGER_64;
+ + code047 :UINTEGER_64;
+ + code048 :UINTEGER_64;
+ + code049 :UINTEGER_64;
+ + code050 :UINTEGER_32;
+ + code051 :UINTEGER_16;
+
+Section Public
+
+ - vol_label:STRING <-
+ ( + result:STRING;
+
+ result := STRING.create 11;
+ result.add_last vol_label_00;
+ result.add_last vol_label_01;
+ result.add_last vol_label_02;
+ result.add_last vol_label_03;
+ result.add_last vol_label_04;
+ result.add_last vol_label_05;
+ result.add_last vol_label_06;
+ result.add_last vol_label_07;
+ result.add_last vol_label_08;
+ result.add_last vol_label_09;
+ result.add_last vol_label_10;
+ result
+ );
+
+
+ - is_fat32:BOOLEAN <- (ext_boot_signature=29h);
+
+ - put_isaac_data begin_partition:UINTEGER_32 drive drv:UINTEGER_8 <-
+ // Static Compute `sector_cluster', `sector_root' and `sector_fat'.
+ (
+ bios_drive:=drv;
+ sector_fat:=begin_partition+sectors_reserved;
+
+ (is_fat32).if {
+ sector_root:=sector_fat+sectors_per_fat32 * nb_fat;
+ } else {
+ sector_root:=sector_fat+sectors_per_fat * nb_fat;
+ };
+
+ sector_cluster:=sector_root+(nb_root_entries>>4)-(sectors_per_cluster*2);
+
+ "\nBegin Part\t: ".print; begin_partition.print;
+ "\nSector FAT\t: ".print; sector_fat.print;
+ "\nSector Root\t: ".print; sector_root.print;
+ "\nSector cluster\t: ".print; sector_cluster.print;
+ '\n'.print;
+ );
+
+ - print <-
+ (
+
+ "\nOEM\t\t: ".print;
+ oem_00.print;
+ oem_01.print;
+ oem_02.print;
+ oem_03.print;
+ oem_04.print;
+ oem_05.print;
+ oem_06.print;
+ oem_07.print;
+
+ "\nBios parameter block (BPB):".print;
+ "\n Bytes per sector\t: ".print; bytes_per_sector.print;
+ "\n Sectors per cluster\t: ".print; sectors_per_cluster.print;
+ "\n Sectors reserved\t: ".print; sectors_reserved.print;
+ "\n Number FAT\t\t: ".print; nb_fat.print;
+ "\n Number root entries\t: ".print; nb_root_entries.print;
+ "\n Number sectors\t: ".print; nb_sectors.print;
+ "\n Descriptor media\t: ".print; descriptor.to_hexadecimal.print; 'h'.print;
+ "\n Sectors per FAT\t: ".print; sectors_per_fat.print;
+ "\n Sectors per track\t: ".print; sectors_per_track.print;
+ "\n Number head\t\t: ".print; nb_head.print;
+ "\n Hidden sectors\t: ".print; hidden_sectors.print;
+ "\n Number sectors big\t: ".print; nb_sectors_big.print;
+ " (".print; (nb_sectors_big>>11).print; " MB)".print;
+
+ (is_fat32).if {
+ "\nFAT 32 bits:".print;
+ "\n Sectors per FAT\t: ".print; (sectors_per_fat32+1).print;
+ "\n Flags FAT\t\t: ".print; flags_fat.to_hexadecimal.print; 'h'.print;
+ "\n Version FAT\t\t: ".print; version_fat.print;
+ "\n Cluster start root\t: ".print; cluster_start_root.print;
+
+ "\nDrive information:".print;
+ "\n Bios drive\t\t: ".print; bios_drive.to_hexadecimal.print; 'h'.print;
+ "\n Ext. boot signature\t: ".print; ext_boot_signature.to_hexadecimal.print; 'h'.print;
+ "\n Serial number\t\t: ".print; serial_number.to_hexadecimal.print; 'h'.print;
+
+ "\n Volume label\t\t: ".print;
+ vol_label_00.print;
+ vol_label_01.print;
+ vol_label_02.print;
+ vol_label_03.print;
+ vol_label_04.print;
+ vol_label_05.print;
+ vol_label_06.print;
+ vol_label_07.print;
+ vol_label_08.print;
+ vol_label_09.print;
+ vol_label_10.print;
+
+ "\n File system\t\t: ".print;
+ fs_label_00.print;
+ fs_label_01.print;
+ fs_label_02.print;
+ fs_label_03.print;
+ fs_label_04.print;
+ fs_label_05.print;
+ fs_label_06.print;
+ fs_label_07.print;
+ };
+ '\n'.print;
+ );
+
+ - sectors_per_cluster:UINTEGER_8<-get_sectors_per_cluster; // 0Dh
+ - sectors_reserved:UINTEGER_16<-get_sectors_reserved; // OEh
+ - nb_fat:UINTEGER_8<-get_nb_fat; // 10h
+ - sectors_per_fat:UINTEGER_16<- get_sectors_per_fat; // 16h
+ - nb_root_entries:UINTEGER_16<-get_nb_root_entries; // 11h
+ - sectors_per_fat32:UINTEGER_32<-get_sectors_per_fat32; // 24h : Nbr Sector per FAT - 1
+ - cluster_start_root:UINTEGER_32<-get_cluster_start_root;// 2Ch
diff --git a/isaacos/file_system/fat/partition/fat.li b/isaacos/file_system/fat/partition/fat.li
new file mode 100755
index 0000000..ce61c82
--- /dev/null
+++ b/isaacos/file_system/fat/partition/fat.li
@@ -0,0 +1,97 @@
+///////////////////////////////////////////////////////////////////////////////
+// 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; 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 := FAT;
+
+
+ - bibliography:="http://www.lisaac.org";
+ - author :="Sonntag Benoit (benoit.sonntag at lisaac.org)";
+ - comment :="FAT Type Partition .";
+
+Section Inherit
+
+ + parent_partition:Expanded PARTITION_FAT;
+
+Section Private
+
+ + fat_cache:FAST_ARRAY(UINTEGER_8);
+ + fat_cache_index:UINTEGER_32;
+
+ + fat_sector:UINTEGER_32; // Offset in sectors
+ + fat_size :UINTEGER_32; // In sectors
+ + fat_number:UINTEGER_8; // Number of FAT
+
+ + root_offset:UINTEGER_32; // Offset of the root, in sectors
+ + root_size :UINTEGER_16; // size of the root, in sectors
+
+ + block_offset:UINTEGER_32; // Offset of the first block in sectors
+
+Section FAT,FAT32,FILE_SYSTEM
+
+ + root_block :UINTEGER_32; // Number of the virtual block of the root beginning
+
+
+Section Public
+
+ //
+ // Root directory
+ //
+
+ - make <-
+ ( + time:TIME;
+ + date:DATE;
+
+ date := DATE.create (2008,07,22,1);
+ time := TIME.create (1,28,30,0);
+
+ SFN_FAT.set_name "Unknown";
+ SFN_FAT.set_attr_dir;
+ SFN_FAT.set_cluster root_block;
+ SFN_FAT.set_create_time time;
+ SFN_FAT.set_create_date date;
+ SFN_FAT.set_access_time time;
+ SFN_FAT.set_access_date date;
+ SFN_FAT.set_update_time time;
+ SFN_FAT.set_update_date date;
+ make "/" with SFN_FAT;
+ open;
+ );
+
+ //
+ // Debug & Display.
+ //
+
+ - print_fat <-
+ (
+ "\n******* FAT ******".print;
+ "\nFat_sector:".print;
+ fat_sector.print;
+ "\nFat_size:".print;
+ fat_size.print;
+ "\nFat_number:".print;
+ fat_number.print;
+ "\nRoot_offset:".print;
+ root_offset.print;
+ "\nRoot size:".print;
+ root_size.print;
+ "\nRoot_block:".print;
+ root_block.print;
+ "\nBlock_offset:".print;
+ block_offset.print;
+ "\nStep (Block size):".print;
+ step.print;
+ );
diff --git a/isaacos/file_system/fat/partition/fat12.li b/isaacos/file_system/fat/partition/fat12.li
new file mode 100755
index 0000000..732cab3
--- /dev/null
+++ b/isaacos/file_system/fat/partition/fat12.li
@@ -0,0 +1,109 @@
+///////////////////////////////////////////////////////////////////////////////
+// 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; 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 := FAT12;
+
+ - bibliography:= "http://www.lisaac.org";
+
+ - author := "Benoit Sonntag (benoit.sonntag at lisaac.org)";
+
+ - comment := "File system type: FAT 12";
+
+Section Inherit
+
+ + parent_fat:Expanded FAT;
+
+Section Private
+
+ - null_value:UINTEGER_32:= 0FF8h;
+
+ - sector:UINTEGER_32<-
+ ( + result:UINTEGER_32;
+ (cluster >= root_block).if {
+ // In the root :
+ result := root_offset + (cluster - root_block) * step;
+ } else {
+ // Classical cluster
+ result := block_offset + cluster * step;
+ };
+ result
+ );
+
+Section Public
+
+ - next_cluster:BOOLEAN <-
+ ( + idx:UINTEGER_32;
+
+ // Virtual Root cluster :
+ (cluster >= root_block).if {
+ cluster := cluster + 1;
+ } else {
+ // Real cluster :
+ idx := cluster + (cluster >> 1);
+ (cluster.is_odd).if {
+ cluster := fat_cache.item idx >> 4;
+ cluster := cluster | (fat_cache.item (idx+1).to_uinteger_32<< 4);
+ } else {
+ cluster := fat_cache.item idx;
+ cluster := cluster | ((fat_cache.item (idx+1)&0Fh).to_uinteger_32<< 8);
+ };
+ };
+ cluster != null_value
+ );
+
+ //
+ // Creation.
+ //
+
+ - make drv:DRIVE begin fsector:UINTEGER_32<-
+ ( + boot:BOOT;
+ ? {drv!=NULL};
+
+ drive := drv;
+ first_sector := fsector;
+ buffer := FAST_ARRAY(UINTEGER_8).create_with_capacity 512;
+
+ drive.set_cursor first_sector;
+ drive.read buffer size 1;
+ boot := CONVERT(NATIVE_ARRAY(UINTEGER_8),BOOT).on (buffer.to_native_array);
+
+ // Compute Size Cluster :
+ step := boot.sectors_per_cluster;
+
+ // Compute Logical Sector FAT :
+ fat_sector := first_sector + boot.sectors_reserved;
+ fat_number := boot.nb_fat;
+ fat_size := boot.sectors_per_fat;
+ // Read total FAT12 (6Ko max).
+ fat_cache := FAST_ARRAY(UINTEGER_8).create_with_capacity (fat_size << 9);
+ drive.set_cursor fat_sector;
+ drive.read fat_cache size fat_size;
+
+ // Compute Logical Sector Root :
+ root_offset := fat_sector + fat_size * fat_number;
+ root_size := boot.nb_root_entries >> 4;
+ root_block := 4096;
+
+ // Compute Sector First Cluster : (- 2 Clusters)
+ block_offset := root_offset + root_size - (step << 1);
+
+ // Buffer for one cluster.
+ buffer.set_capacity (step_byte.to_integer);
+ );
+
+
+
diff --git a/isaacos/file_system/fat/partition/fat16.li b/isaacos/file_system/fat/partition/fat16.li
new file mode 100755
index 0000000..904b53c
--- /dev/null
+++ b/isaacos/file_system/fat/partition/fat16.li
@@ -0,0 +1,104 @@
+///////////////////////////////////////////////////////////////////////////////
+// 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; 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 := FAT16;
+
+ - bibliography:= "http://www.lisaac.org";
+
+ - author := "Benoit Sonntag (benoit.sonntag at lisaac.org)";
+
+ - comment := "File system type: FAT 16";
+
+Section Inherit
+
+ + parent_fat:Expanded FAT;
+
+Section Private
+
+ - null_value:UINTEGER_32:= 0FFF8h;
+
+ - sector:UINTEGER_32<-
+ ( + result:UINTEGER_32;
+
+ (cluster >= root_block).if {
+ result := root_offset + (cluster - root_block) * step;
+ } else {
+ result := block_offset + cluster * step;
+ };
+ result
+ );
+
+Section Public
+
+ - next_cluster:BOOLEAN <-
+ ( + fat16:NATIVE_ARRAY(UINTEGER_16);
+ + sec_fat,n:UINTEGER_32;
+ // Virtual Root cluster :
+ (cluster >= root_block).if {
+ cluster := cluster + 1;
+ } else {
+ sec_fat := (fat_sector + (cluster >> 8)) & 0FFFFFFF8h;
+ n := (((fat_sector << 9) + (cluster << 1)) & 4095) >> 1;
+ (sec_fat != fat_cache_index).if {
+ drive.set_cursor sec_fat;
+ fat_cache.clear;
+ drive.read fat_cache size 8;
+ fat_cache_index := sec_fat;
+ };
+ fat16 := CONVERT(NATIVE_ARRAY(UINTEGER_8),NATIVE_ARRAY(UINTEGER_16)).on (fat_cache.to_native_array);
+ cluster := fat16.item n;
+ };
+ cluster != null_value
+ );
+
+ //
+ // Creation.
+ //
+
+ - make drv:DRIVE begin fsector:UINTEGER_32<-
+ ( + boot:BOOT;
+
+ drive := drv;
+ first_sector := fsector;
+ buffer := FAST_ARRAY(UINTEGER_8).create_with_capacity 512;
+
+ drive.set_cursor first_sector;
+ drive.read buffer size 1;
+ boot := CONVERT(NATIVE_ARRAY(UINTEGER_8),BOOT).on (buffer.to_native_array);
+
+ // Compute Size Cluster :
+ step := boot.sectors_per_cluster;
+
+ // Compute Logical Sector FAT :
+ fat_sector := first_sector + boot.sectors_reserved;
+ fat_number := boot.nb_fat;
+ fat_size := boot.sectors_per_fat;
+ fat_cache := FAST_ARRAY(UINTEGER_8).create_with_capacity 4096;
+
+ // Compute Logical Sector Root :
+ root_offset:= fat_sector + fat_size * fat_number;
+ root_size := boot.nb_root_entries >> 4;
+ root_block := 65536;
+
+ // Compute Sector First Cluster : (-2 Clusters)
+ block_offset := root_offset + root_size - (step << 1);
+
+ // Buffer for one cluster.
+ buffer.set_capacity (step_byte.to_integer);
+ );
+
diff --git a/isaacos/file_system/fat/partition/fat32.li b/isaacos/file_system/fat/partition/fat32.li
new file mode 100755
index 0000000..5ea7145
--- /dev/null
+++ b/isaacos/file_system/fat/partition/fat32.li
@@ -0,0 +1,109 @@
+///////////////////////////////////////////////////////////////////////////////
+// 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; 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 := FAT32;
+
+ - bibliography:= "http://www.lisaac.org";
+
+ - author := "Benoit Sonntag (benoit.sonntag at lisaac.org), Jerome Boutet (pisteur at free.fr)";
+
+ - comment := "File system type: FAT 32";
+
+Section Inherit
+
+ + parent_fat:Expanded FAT;
+
+Section Private
+
+ + fs_info_sector:UINTEGER_32; // A voir plus tards...
+
+ - null_value:UINTEGER_32:= 0FFFFFF8h;
+
+ - sector:UINTEGER_32<-
+ (
+ block_offset + cluster * step
+ );
+
+Section Public
+
+ - next_cluster:BOOLEAN <-
+ ( + fat32:NATIVE_ARRAY(UINTEGER_32);
+ + sec_fat,n:UINTEGER_32;
+
+ // Virtual Root cluster :
+ //(cluster >= root_block).if {
+ // cluster := cluster + 1;
+ //} else {
+ sec_fat := (fat_sector + (cluster >> 7)) & 0FFFFFFF8h;
+ n := (((fat_sector << 9) + (cluster << 2)) & 4095) >> 2;
+ (sec_fat != fat_cache_index).if {
+ drive.set_cursor sec_fat;
+ fat_cache.clear;
+ drive.read fat_cache size 8;
+ fat_cache_index := sec_fat;
+ };
+ fat32 := CONVERT(NATIVE_ARRAY(UINTEGER_8),NATIVE_ARRAY(UINTEGER_32)).on (fat_cache.to_native_array);
+ cluster := fat32.item n;
+ //};
+
+ cluster < null_value
+ );
+
+ //
+ // Creation.
+ //
+
+ - make drv:DRIVE begin fsector:UINTEGER_32<-
+ ( + boot:BOOT;
+
+ drive := drv;
+ first_sector := fsector;
+ buffer := FAST_ARRAY(UINTEGER_8).create_with_capacity 512;
+
+ drive.set_cursor first_sector;
+ drive.read buffer size 1;
+ boot := CONVERT(NATIVE_ARRAY(UINTEGER_8),BOOT).on (buffer.to_native_array);
+
+ // Compute Size Cluster :
+ step := boot.sectors_per_cluster;
+
+ // Compute Logical Sector FAT :
+ fat_sector := first_sector + boot.sectors_reserved;
+ fat_number := boot.nb_fat;
+ fat_size := boot.sectors_per_fat32;
+ fat_cache := FAST_ARRAY(UINTEGER_8).create_with_capacity 4096;
+
+ // Compute Logical Sector Root :
+ root_block := boot.cluster_start_root;
+
+ // Compute Sector First Cluster : (-2 Cluster)
+ block_offset := fat_sector + fat_size*fat_number - (step << 1);
+
+ // Buffer for one cluster.
+ buffer.set_capacity (step_byte.to_integer);
+ // Read File System Information :
+ //fs_info_sector := first_sector + BOOT.fs_info_sector;
+ //drive.set_cursor fs_info_sector;
+ //drive.read buf size 1;
+ //free_cluster :=
+ //( buf.item 488).to_uinteger_32 |
+ //((buf.item 489).to_uinteger<<8) |
+ //((buf.item 490).to_uinteger<<16) |
+ //((buf.item 491).to_uinteger<<24);
+ );
+
+
diff --git a/isaacos/file_system/fat/partition/partition_fat.li b/isaacos/file_system/fat/partition/partition_fat.li
new file mode 100755
index 0000000..272d378
--- /dev/null
+++ b/isaacos/file_system/fat/partition/partition_fat.li
@@ -0,0 +1,49 @@
+///////////////////////////////////////////////////////////////////////////////
+// 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; 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 := PARTITION_FAT;
+
+
+ - bibliography:= "http://www.lisaac.org";
+ - author := "Sonntag Benoit (benoit.sonntag at lisaac.org)";
+ - comment := "Partition Hard disk.";
+
+Section Inherit
+
+ + parent_directory:Expanded DIRECTORY_FAT;
+ + parent_partition:Expanded PARTITION;
+
+Section Private
+
+ + cluster:UINTEGER_32;
+
+Section Public
+ //
+ // Cluster manager.
+ //
+
+ - set_cluster new:UINTEGER_32<-
+ (
+ cluster := new;
+ );
+
+ - new_cluster:UINTEGER_32<- deferred;
+
+ - next_cluster:BOOLEAN <- deferred;
+
+ - new_next_cluster <- deferred;
+
diff --git a/isaacos/file_system/fat/sfn_fat.li b/isaacos/file_system/fat/sfn_fat.li
new file mode 100755
index 0000000..3be37f2
--- /dev/null
+++ b/isaacos/file_system/fat/sfn_fat.li
@@ -0,0 +1,321 @@
+///////////////////////////////////////////////////////////////////////////////
+// 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; 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 := SFN_FAT;
+
+ - bibliography:= "http://www.lisaac.org";
+
+ - author :=
+ "Benoit Sonntag (benoit.sonntag at lisaac.org), \
+ \Jerome Boutet (pisteur at free.fr)";
+
+ - comment := "Short File Name of FAT";
+
+Section Inherit
+
+ - parent_object:OBJECT := OBJECT;
+
+Section Mapping
+
+ + name0 :CHARACTER;
+ + name1 :CHARACTER;
+ + name2 :CHARACTER;
+ + name3 :CHARACTER;
+ + name4 :CHARACTER;
+ + name5 :CHARACTER;
+ + name6 :CHARACTER;
+ + name7 :CHARACTER;
+ + name8 :CHARACTER;
+ + name9 :CHARACTER;
+ + name10:CHARACTER;
+
+ + attr:UINTEGER_8;
+
+ + first_char:UINTEGER_8;
+
+ + fat_creation_time_ms:UINTEGER_8;
+
+ + fat_creation_time:UINTEGER_16;
+
+ + fat_creation_date:UINTEGER_16;
+
+ + fat_access_date:UINTEGER_16;
+
+ + high_cluster:UINTEGER_16;
+
+ + fat_update_time:UINTEGER_16;
+
+ + fat_update_date:UINTEGER_16;
+
+ + cluster:UINTEGER_16;
+
+ + map_size:UINTEGER_32;
+
+Section Public
+
+ - size:UINTEGER_32 <- map_size;
+
+ - name_in result:STRING <-
+ ( + name_raw:NATIVE_ARRAY(CHARACTER);
+ + car:CHARACTER;
+ //? {is_valid};
+
+ name_raw := CONVERT[Expanded SFN_FAT,NATIVE_ARRAY(CHARACTER)].on Self;
+ 0.to 7 do { j:INTEGER;
+ car := name_raw.item j;
+ (car > ' ').if {
+ result.add_last car;
+ };
+ };
+ result.add_last '.';
+ 8.to 10 do { j:INTEGER;
+ car := name_raw.item j;
+ (car > ' ').if {
+ result.add_last car;
+ };
+ };
+
+ (result.last = '.').if {
+ result.remove (result.count); // Remove '.' if last character (no extension)
+ };
+
+ result.to_lower; // In lower case
+ );
+
+ - set_name str:ABSTRACT_STRING <-
+ ( + name_raw:NATIVE_ARRAY(CHARACTER);
+ + car:CHARACTER;
+ + k:INTEGER;
+ ? {str.count<=12};
+
+ name_raw := CONVERT(SELF,NATIVE_ARRAY(CHARACTER)).on Self;
+ k:=str.lower;
+ 0.to 7 do { j:INTEGER;
+ (k>str.upper).if {
+ car := ' ';
+ } else {
+ car:=str.item k.to_upper;
+ ? {car.in_range '.' to 'Z'};
+ };
+ (car='.').if {
+ name_raw.put ' ' to j;
+ } else {
+ name_raw.put car to j;
+ k:=k+1;
+ };
+ };
+ (car='.').if {
+ k:=k+1;
+ };
+ 8.to 10 do { j:INTEGER;
+ (k>str.upper).if {
+ car := ' ';
+ } else {
+ car:=str.item k.to_upper;
+ ? {car.in_range '.' to 'Z'};
+ };
+ (car='.').if {
+ name_raw.put ' ' to j;
+ } else {
+ name_raw.put car to j;
+ k:=k+1;
+ };
+ };
+ );
+
+ - set_attr_dir <-
+ (
+ attr := attr | 10h;
+ );
+
+ - set_first_char f:UINTEGER_8 <-
+ (
+ first_char := f;
+ );
+
+ - create_time:TIME <-
+ (
+ time_to_isaac (fat_creation_time,fat_creation_time_ms)
+ );
+
+ - create_date:DATE <-
+ (
+ date_to_isaac fat_creation_date
+ );
+
+
+ - access_time:TIME <-
+ (
+ TIME.create (0,0,0,0)
+ );
+
+ - access_date:DATE <-
+ (
+ date_to_isaac fat_access_date
+ );
+
+ - update_time:TIME <-
+ (
+ time_to_isaac (fat_update_time,0)
+ );
+
+ - update_date:DATE <-
+ (
+ date_to_isaac fat_update_date
+ );
+
+ - set_create_time time:TIME <-
+ (
+ fat_creation_time := time_to_fat time;
+ fat_creation_time_ms := 0;
+ );
+
+ - set_create_date date:DATE <-
+ (
+ fat_creation_date := date_to_fat date;
+ );
+
+ - set_access_time time:TIME <-
+ (
+ );
+
+ - set_access_date date:DATE <-
+ (
+ fat_access_date := date_to_fat date;
+ );
+
+ - set_update_time time:TIME <-
+ (
+ fat_update_time := time_to_fat time;
+ );
+
+ - set_update_date date:DATE <-
+ (
+ fat_update_date := date_to_fat date;
+ );
+
+ - set_cluster c:UINTEGER_32<-
+ (
+ cluster := (c & 0FFFFh).to_uinteger_16;
+ high_cluster := (c >> 16).to_uinteger_16;
+ );
+
+ - set_size s:UINTEGER_32<-
+ (
+ map_size := s;
+ );
+
+ - is_directory:BOOLEAN <-
+ // TRUE if directory
+ (
+ (attr & 10h) != 0
+ );
+
+ - is_label:BOOLEAN <-
+ // Volume name
+ (
+ attr=1000b
+ );
+
+ - is_null:BOOLEAN <- (name0=0);
+
+ - is_me:BOOLEAN <- (name0 = '.') && {name1 != '.'};
+ - is_parent:BOOLEAN <- (name0 = '.') && {name1 = '.'};
+
+ - is_valid:BOOLEAN <-
+ // FALSE if it is the last entry of a directory
+ (
+ //(name0 != 00h) && {name0 != 0E5h}
+ ((attr & 1000b)=0) && {name0.in_range '.' to 'Z'}
+ );
+
+ - position:UINTEGER_32<-
+ (
+ (high_cluster.to_uinteger_32<< 16) | cluster
+ );
+
+ - owner_uid:UINTEGER_32:= 015AACh;
+ - owner_gid:UINTEGER_32:= 015AACh;
+
+ - access_permissions:UINTEGER_32<-
+ ( + result:UINTEGER_32;
+
+ ((attr & 01h) != 0).if {
+ result:= 444o;
+ } else {
+ result:= 777o;
+ };
+ result
+ );
+
+ - print <-
+ ( + tmp:STRING;
+ "\nName : ".print;
+ tmp := STRING.create 20;
+ name_in tmp;
+ tmp.print;
+ "\nAttrib : ".print;
+ attr.print;
+ "\nFirst Car : ".print;
+ first_char.print;
+ /*
+ "\nCreat Time : ".print;
+ creation_time.print;
+ "\nCreat Date : ".print;
+ creation_date.print;
+ "\nAccess Date : ".print;
+ access_date.print;
+ "\nHigh Cluster : ".print;
+ high_cluster.print;
+ "\nUpdate Time : ".print;
+ update_time.print;
+ "\nUpdate Date : ".print;
+ update_date.print;
+ */
+ "\nCluster : ".print;
+ cluster.print;
+ "\nSize : ".print;
+ size.print;
+ "\n---------------\n".print;
+ );
+
+
+Section Private
+
+ // HH MM SS MS
+ - time_to_isaac (time:UINTEGER_16,ms:UINTEGER_8) :TIME <-
+ (
+ TIME.create (((time>>11).to_uinteger_8),(((time&07E0h)>>5).to_uinteger_8),(((time&001Fh)<<1).to_uinteger_8),ms)
+ );
+
+ - time_to_fat time:TIME :UINTEGER_16 <-
+ (
+ (time.hour.to_uinteger_16 << 11)|(time.minute.to_uinteger_16 << 5)|(time.second >>1)
+ );
+
+ // AA AA MM JJ
+
+ - date_to_isaac date:UINTEGER_16 :DATE <-
+ (
+ DATE.create ((((date>>9)+1980)),(((date&01E0h)>>5).to_uinteger_8),((date&001Fh).to_uinteger_8),1)
+ );
+
+ - date_to_fat date:DATE :UINTEGER_16 <-
+ (
+ (((date.year)-1980)<<9)|((date.month.to_uinteger_16)<<5)|(date.day)
+ );
+
diff --git a/isaacos/file_system/fat/std_file_fat.li b/isaacos/file_system/fat/std_file_fat.li
new file mode 100755
index 0000000..ce3b6c2
--- /dev/null
+++ b/isaacos/file_system/fat/std_file_fat.li
@@ -0,0 +1,123 @@
+///////////////////////////////////////////////////////////////////////////////
+// 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; 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 := STD_FILE_FAT;
+
+ - bibliography:= "http://www.lisaac.org";
+
+ - author := "Benoit Sonntag (benoit.sonntag at lisaac.org)";
+
+ - comment := "File for ISAAC";
+
+Section Inherit
+
+ + parent_entry:Expanded ENTRY_FAT;
+ + parent_abstract_file:Expanded STD_FILE;
+
+Section Public
+
+ //
+ // Physical implementation.
+ //
+
+ - is_open:BOOLEAN <- TRUE;
+
+ + cursor:UINTEGER_32;
+
+ - set_cursor n:UINTEGER_32 <-
+ (
+ cursor := n;
+ );
+
+ - open:BOOLEAN <-
+ (
+ // simplicity at work :) BSJH :)
+ TRUE
+ );
+
+ - open_read_only:BOOLEAN <- open;
+
+ - close <-
+ (
+ cursor := 0;
+ );
+
+Section STD_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 ?)
+ ( + n:UINTEGER_32;
+ + size_cluster:UINTEGER_32;
+ + partition:PARTITION_FAT;
+ + lower,upper,idx,lower2:UINTEGER_32;
+
+
+ ? {s > 0};
+ ? {buf != NULL};
+ partition ?= FILE_SYSTEM.get_partition Self;
+
+ // Set position good cluster.
+ size_cluster := partition.step_byte;
+ n := cursor / size_cluster;
+ partition.set_cluster position;
+ 1.to n do { i:INTEGER;
+ partition.next_cluster;
+ };
+
+ // Read.
+ n := s;
+ lower := cursor % size_cluster;
+ {n = 0}.until_do {
+ // Read cluster.
+ partition.read;
+ partition.next_cluster;
+ lower2:=lower;
+ // Compute size for copy.
+ ((lower + n) > size_cluster).if {
+ upper := size_cluster - 1;
+ n := n - (size_cluster - lower);
+ lower := 0;
+ } else {
+ upper := lower + n - 1;
+ n := 0;
+ };
+
+ // Copy in buf.
+ lower2.to upper do { i:UINTEGER_32;
+ buf.put (partition.buffer.item i) to idx;
+ idx := idx + 1;
+ };
+ /*
+ (partition.next_cluster).if_false {
+ n := 0;
+ };
+ */
+ };
+ cursor := cursor + idx;
+ idx
+ );
+
+ - physical_write buf:NATIVE_ARRAY(UINTEGER_8) size s:INTEGER :INTEGER <-
+ // return size write or 0 if end of input (-1 on error => exception ?)
+ (
+ ? {is_open};
+ not_yet_implemented;
+ 0
+ );
+
+
+
diff --git a/isaacos/file_system/file_system.li b/isaacos/file_system/file_system.li
new file mode 100755
index 0000000..8871135
--- /dev/null
+++ b/isaacos/file_system/file_system.li
@@ -0,0 +1,154 @@
+///////////////////////////////////////////////////////////////////////////////
+// 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; 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;
+
+ - bibliography:="http://www.lisaac.org";
+
+ - author :=
+ "Benoit Sonntag (benoit.sonntag at lisaac.org),\
+ \ Jerome Boutet (pisteur at free.fr)";
+
+ - 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/isaacos/file_system/mbr.li b/isaacos/file_system/mbr.li
new file mode 100755
index 0000000..4686498
--- /dev/null
+++ b/isaacos/file_system/mbr.li
@@ -0,0 +1,389 @@
+///////////////////////////////////////////////////////////////////////////////
+// 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; 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 := MBR;
+
+ - bibliography:= "http://www.lisaac.org";
+
+ - author := "Benoit Sonntag (benoit.sonntag at lisaac.org), Jerome Boutet (pisteur at free.fr)";
+
+ - comment := "Master Boot Record";
+
+Section Inherit
+
+ - parent_object:OBJECT := OBJECT;
+
+Section Mapping
+
+ + flag_boot:UINTEGER_8;
+
+ + head_begin:UINTEGER_8;
+
+ + cylinder_sector_begin:UINTEGER_16;
+
+ + map_type:UINTEGER_8;
+
+ + head_end:UINTEGER_8;
+
+ + cylinder_sector_end:UINTEGER_16;
+
+ + map_mbr_first_sector:UINTEGER_32;
+
+ + size:UINTEGER_32;
+
+Section Private
+
+ - cylinder n:UINTEGER_16 :UINTEGER_16 <- ((n>>8) | ((n & 0C0h)<<2));
+
+ - sector n:UINTEGER_16 :UINTEGER_16 <- (n & 3Fh);
+
+Section Public
+
+ - mbr_first_sector:UINTEGER_32 <- map_mbr_first_sector;
+ - type:UINTEGER_8 <- map_type;
+
+ - is_active:BOOLEAN <- (flag_boot=80h);
+
+ - cylinder_begin:UINTEGER_16 <- cylinder cylinder_sector_begin;
+
+ - cylinder_end:UINTEGER_16 <- cylinder cylinder_sector_end;
+
+ - sector_begin:UINTEGER_16 <- sector cylinder_sector_begin;
+
+ - sector_end:UINTEGER_16 <- sector cylinder_sector_end;
+
+ - is_fat12:BOOLEAN <-
+ (
+ (type=001h) || {type=011h} ||
+ {type=08Dh} || {type=0AAh} ||
+ {type=0C1h} || {type=0D1h} ||
+ {type=0E1h}
+ );
+
+ - is_fat16:BOOLEAN <-
+ (
+ (type=004h) || {type=006h} ||
+ {type=00Eh} || {type=014h} ||
+ {type=016h} || {type=01Eh} ||
+ {type=090h} || {type=092h} ||
+ {type=09Ah} || {type=0C4h} ||
+ {type=0C6h} || {type=0CEh}
+ );
+
+ - is_fat32:BOOLEAN <-
+ (
+ (type=00Bh) || {type=00Ch} ||
+ {type=01Bh} || {type=01Ch} ||
+ {type=08Bh} || {type=08Ch} ||
+ {type=097h} || {type=098h} ||
+ {type=0CBh} || {type=0CCh}
+ );
+
+ - is_ext2:BOOLEAN <-
+ (
+ type=083h
+ );
+
+ - print <-
+ (
+ "type ".print;
+ type.to_hexadecimal.print;
+ "h : ".print;
+
+ (type)
+ .when 000h then { "Not found\n".print; }
+ .when 001h then { "FAT12 (< 10 M)\n".print; }
+ .when 002h then { "XENIX root\n".print; }
+ .when 003h then { "XENIX /usr\n".print; }
+ .when 004h then { "FAT16 (< 32 M)\n".print; }
+ .when 005h then { "Etendue\n".print; }
+ .when 006h then { "FAT16 (>32 M et <2 G)\n".print; }
+ .when 007h then { "OS/2, HPFS, NTFS, QNX 2.x\n".print; }
+ .when 008h then { "SplitDrive QNX 1.x et 2.x\n".print; }
+ .when 009h then { "AIX data, Coherent FileSystem\n".print; }
+ .when 00Ah then { "OS/2 boot manager, Coherent swap, OPUS\n".print; }
+ .when 00Bh then { "FAT32(>2 G et <2047G)\n".print; }
+ .when 00Ch then { "FAT32(>2 G et <2047G) LBA\n".print; }
+ .when 00Dh then { "non attribu�\n".print; }
+ .when 00Eh then { "FAT16 (>32 M et <2 G) LBA\n".print; }
+ .when 00Fh then { "Etendue\"x\" = Etendue + LBA\n".print; }
+ .when 010h then { "OPUS\n".print; }
+ .when 011h then { "FAT12 cach�e\n".print; }
+ .when 012h then { "Diagnostics COMPAQ\n".print; }
+ .when 013h then { "non attribu�\n".print; }
+ .when 014h then { "FAT16 (<32 M) cachee\n".print; }
+ .when 015h then { "Free type...\n".print; }
+ .when 016h then { "FAT16 (>32 M) cachee\n".print; }
+ .when 017h then { "HPFS - NTFS cachee\n".print; }
+ .when 018h then { "Windows swapfile\n".print; }
+ .when 019h then { "Willowtech Photon coS \n".print; }
+ .when 01Ah then { "Free type...\n".print; }
+ .when 01Bh then { "FAT32 cachee\n".print; }
+ .when 01Ch then { "FAT32x cachee\n".print; }
+ .when 01Dh then { "Free type...\n".print; }
+ .when 01Eh then { "FAT16x cachee\n".print; }
+ .when 01Fh then { "Free type...\n".print; }
+ .when 020h then { "Willowsoft OFS1\n".print; }
+ .when 021h then { "Oxygen File System\n".print; }
+ .when 022h then { "Oxygen Extended\n".print; }
+ .when 023h then { "reserved\n".print; }
+ .when 024h then { "NEC DOS 3.x\n".print; }
+ .when 025h then { "Free type...\n".print; }
+ .when 026h then { "reserved\n".print; }
+ .when 027h then { "Free type...\n".print; }
+ .when 028h then { "Free type...\n".print; }
+ .when 029h then { "Free type...\n".print; }
+ .when 02Ah then { "Free type...\n".print; }
+ .when 02Bh then { "Free type...\n".print; }
+ .when 02Ch then { "Free type...\n".print; }
+ .when 02Dh then { "Free type...\n".print; }
+ .when 02Eh then { "Free type...\n".print; }
+ .when 02Fh then { "Free type...\n".print; }
+ .when 030h then { "Free type...\n".print; }
+ .when 031h then { "reserved\n".print; }
+ .when 032h then { "Free type...\n".print; }
+ .when 033h then { "reserved\n".print; }
+ .when 034h then { "reserved\n".print; }
+ .when 035h then { "Journaling FS OS/2 ou eCS\n".print; }
+ .when 036h then { "reserved\n".print; }
+ .when 037h then { "Free type...\n".print; }
+ .when 038h then { "THEOS ver 3.2 2 Go\n".print; }
+ .when 039h then { "Plan 9, THEOS ver 4 spanned\n".print; }
+ .when 03Ah then { "THEOS ver 4 4Go\n".print; }
+ .when 03Bh then { "THEOS ver 4 �tendue\n".print; }
+ .when 03Ch then { "PartitionMagic recovery\n".print; }
+ .when 03Dh then { "Free type...\n".print; }
+ .when 03Eh then { "Free type...\n".print; }
+ .when 03Fh then { "Free type...\n".print; }
+ .when 040h then { "VENIX\n".print; }
+ .when 041h then { "MINIX + DRDOS Personal RISC Boot Power PC Reference Platform\n".print; }
+ .when 042h then { "Linux swap + DRDOS SFS Windows 2000\n".print; }
+ .when 043h then { "Linux native + DRDOS\n".print; }
+ .when 044h then { "Free type...\n".print; }
+ .when 045h then { "Boot US boot manager, EUMEL/Elan\n".print; }
+ .when 046h then { "EUMEL/Elan\n".print; }
+ .when 047h then { "EUMEL/Elan\n".print; }
+ .when 048h then { "EUMEL/Elan\n".print; }
+ .when 049h then { "Free type...\n".print; }
+ .when 04Ah then { "Free type...\n".print; }
+ .when 04Bh then { "Free type...\n".print; }
+ .when 04Ch then { "Free type...\n".print; }
+ .when 04Dh then { "QNX4.x\n".print; }
+ .when 04Eh then { "QNX4.x 2�me partition\n".print; }
+ .when 04Fh then { "QNX4.x 3�me partition, Oberon\n".print; }
+ .when 050h then { "OnTrack Disk Manager, Lynx RTOS, Oberon native\n".print; }
+ .when 051h then { "OnTrack Disk Manager RW Novell\n".print; }
+ .when 052h then { "Microport CP/M\n".print; }
+ .when 053h then { "Disk Manager 6.0, Aux3\n".print; }
+ .when 054h then { "Disk Manager 6.0 Dynamic Drive Overlay\n".print; }
+ .when 055h then { "EZ-Drive\n".print; }
+ .when 056h then { "Golden Bow, EZ-BIOS\n".print; }
+ .when 057h then { "DrivePro VNDI\n".print; }
+ .when 058h then { "Free type...\n".print; }
+ .when 059h then { "Free type...\n".print; }
+ .when 05Ah then { "Free type...\n".print; }
+ .when 05Bh then { "Free type...\n".print; }
+ .when 05Ch then { "Priam EDisk\n".print; }
+ .when 05Dh then { "Free type...\n".print; }
+ .when 05Eh then { "Free type...\n".print; }
+ .when 05Fh then { "Free type...\n".print; }
+ .when 060h then { "Free type...\n".print; }
+ .when 061h then { "SpeedStor\n".print; }
+ .when 062h then { "Free type...\n".print; }
+ .when 063h then { "Unix System V GNU HURD\n".print; }
+ .when 064h then { "Novell 286 PC-ARMOUR\n".print; }
+ .when 065h then { "Novell 386\n".print; }
+ .when 066h then { "Novell Netware SMS\n".print; }
+ .when 067h then { "Novell\n".print; }
+ .when 068h then { "Novell\n".print; }
+ .when 069h then { "Novell Netware NSS\n".print; }
+ .when 06Ah then { "Free type...\n".print; }
+ .when 06Bh then { "Free type... \n".print; }
+ .when 06Ch then { "Free type...\n".print; }
+ .when 06Dh then { "Free type... \n".print; }
+ .when 06Eh then { "Free type... \n".print; }
+ .when 06Fh then { "Free type...\n".print; }
+ .when 070h then { "DiskSecure Multi-Boot\n".print; }
+ .when 071h then { "reserved\n".print; }
+ .when 072h then { "reserved\n".print; }
+ .when 073h then { "reserved\n".print; }
+ .when 074h then { "Scramdisk\n".print; }
+ .when 075h then { "IBM PC/IX\n".print; }
+ .when 076h then { "reserved\n".print; }
+ .when 077h then { "VNDI\n".print; }
+ .when 078h then { "XOSL Bootloader\n".print; }
+ .when 079h then { "Free type...\n".print; }
+ .when 07Ah then { "Free type...\n".print; }
+ .when 07Bh then { "Free type...\n".print; }
+ .when 07Ch then { "Free type...\n".print; }
+ .when 07Dh then { "Free type...\n".print; }
+ .when 07Eh then { "Free type...\n".print; }
+ .when 07Fh then { "Free type...\n".print; }
+ .when 080h then { "MINIX (->1.4a)\n".print; }
+ .when 081h then { "MINIX (1.4b ->), Mitac Disk Manager\n".print; }
+ .when 082h then { "Solaris X86, LINUX swap, Prime\n".print; }
+ .when 083h then { "LINUX native (ext2fs)\n".print; }
+ .when 084h then { "OS/2 cachee, Hibernation\n".print; }
+ .when 085h then { "Linux etendue\n".print; }
+ .when 086h then { "agr�gat FAT (NT)\n".print; }
+ .when 087h then { "agr�gat NTFS (NT)\n".print; }
+ .when 088h then { "Free type...\n".print; }
+ .when 089h then { "Free type...\n".print; }
+ .when 08Ah then { "Linux Kernel\n".print; }
+ .when 08Bh then { "FAT32 miroir\n".print; }
+ .when 08Ch then { "FAT32x Miroir\n".print; }
+ .when 08Dh then { "FAT12 cachee (FreeFDISK)\n".print; }
+ .when 08Eh then { "Linux Logical Volume Manager\n".print; }
+ .when 08Fh then { "Free type...\n".print; }
+ .when 090h then { "FAT16 cachee (FreeFDISK)\n".print; }
+ .when 091h then { "Etendue cachee (FreeFDISK)\n".print; }
+ .when 092h then { "FAT16 cachee (FreeFDISK)\n".print; }
+ .when 093h then { "Amoeba, Linux native cachee\n".print; }
+ .when 094h then { "Amoeba bad block table\n".print; }
+ .when 095h then { "MIT EXOPC native\n".print; }
+ .when 096h then { "Free type...\n".print; }
+ .when 097h then { "FAT32 cachee (FreeFDISK)\n".print; }
+ .when 098h then { "FAT32x cachee (FreeFDISK)\n".print; }
+ .when 099h then { "DCE376 logical drive\n".print; }
+ .when 09Ah then { "FAT16x cachee (FreeFDISK)n".print; }
+ .when 09Bh then { "etendue X cachee (FreeFDISK)\n".print; }
+ .when 09Ch then { "Free type...\n".print; }
+ .when 09Dh then { "Free type...\n".print; }
+ .when 09Eh then { "Free type...\n".print; }
+ .when 09Fh then { "BSD/OS\n".print; }
+ .when 0A0h then { "hibernation\n".print; }
+ .when 0A1h then { "reserved\n".print; }
+ .when 0A2h then { "Free type...\n".print; }
+ .when 0A3h then { "reserved\n".print; }
+ .when 0A4h then { "reserved\n".print; }
+ .when 0A5h then { "BSD\n".print; }
+ .when 0A6h then { "OpenBSD\n".print; }
+ .when 0A7h then { "NEXTSTEP\n".print; }
+ .when 0A8h then { "Free type...\n".print; }
+ .when 0A9h then { "NetBSD\n".print; }
+ .when 0AAh then { "FAT12 1,44Mo Olivetti\n".print; }
+ .when 0ABh then { "Free type...\n".print; }
+ .when 0ACh then { "Free type...\n".print; }
+ .when 0ADh then { "Free type...\n".print; }
+ .when 0AEh then { "ShagOS filesystem\n".print; }
+ .when 0AFh then { "ShagOS swap partition\n".print; }
+ .when 0B0h then { "Free type...\n".print; }
+ .when 0B1h then { "reserved\n".print; }
+ .when 0B2h then { "Free type...\n".print; }
+ .when 0B3h then { "reserved\n".print; }
+ .when 0B4h then { "reserved\n".print; }
+ .when 0B5h then { "Free type...\n".print; }
+ .when 0B6h then { "reserved\n".print; }
+ .when 0B7h then { "BSDI BSD/386\n".print; }
+ .when 0B8h then { "BSDI BSD/386 swap\n".print; }
+ .when 0B9h then { "Free type...\n".print; }
+ .when 0BAh then { "Free type...\n".print; }
+ .when 0BBh then { "Free type...\n".print; }
+ .when 0BCh then { "Free type...\n".print; }
+ .when 0BDh then { "Free type...\n".print; }
+ .when 0BEh then { "Solaris 8 boot\n".print; }
+ .when 0BFh then { "Free type...\n".print; }
+ .when 0C0h then { "CTOS REAL/32 secure NTFT\n".print; }
+ .when 0C1h then { "FAT12 DRDOS\n".print; }
+ .when 0C2h then { "Linux swap cachee\n".print; }
+ .when 0C3h then { "Linux cachee\n".print; }
+ .when 0C4h then { "FAT16 <32M DRDOS\n".print; }
+ .when 0C5h then { "Free type...\n".print; }
+ .when 0C6h then { "FAT16 >= 32M DRDOS, FAT16 corrompue (NT)\n".print; }
+ .when 0C7h then { "NTFS corrompue (NT), Syrinx boot\n".print; }
+ .when 0C8h then { "Free type...\n".print; }
+ .when 0C9h then { "Free type...\n".print; }
+ .when 0CAh then { "Free type...\n".print; }
+ .when 0CBh then { "FAT32 DRDOS\n".print; }
+ .when 0CCh then { "FAT32x DRDOS\n".print; }
+ .when 0CDh then { "CTOS\n".print; }
+ .when 0CEh then { "FAT16x DRDOS\n".print; }
+ .when 0CFh then { "Free type...\n".print; }
+ .when 0D0h then { "REAL32\n".print; }
+ .when 0D1h then { "Multiuser DOS, secured FAT12\n".print; }
+ .when 0D2h then { "Free type...\n".print; }
+ .when 0D3h then { "Free type...\n".print; }
+ .when 0D4h then { "Multiuser\n".print; }
+ .when 0D5h then { "Multiuser\n".print; }
+ .when 0D6h then { "Multiuser\n".print; }
+ .when 0D7h then { "Free type...\n".print; }
+ .when 0D8h then { "CP/M-86\n".print; }
+ .when 0D9h then { "Free type...\n".print; }
+ .when 0DAh then { "Non-FS Dat a\n".print; }
+ .when 0DBh then { "Digital Research, CP/M, Concurrent CP/M, Concurent DOS, CTOS, KDG Telemetry,SCPU boot\n".print; }
+ .when 0DCh then { "CTOS\n".print; }
+ .when 0DDh then { "CTOS cachee\n".print; }
+ .when 0DEh then { "Free type...\n".print; }
+ .when 0DFh then { "DG/UX virtual disk manager\n".print; }
+ .when 0E0h then { "ST AVFS\n".print; }
+ .when 0E1h then { "SpeedStor FAT12\n".print; }
+ .when 0E2h then { "Free type...\n".print; }
+ .when 0E3h then { "SpeedStor\n".print; }
+ .when 0E4h then { "SpeedStor etendue\n".print; }
+ .when 0E5h then { "reserved\n".print; }
+ .when 0E6h then { "reserved\n".print; }
+ .when 0E7h then { "Free type...\n".print; }
+ .when 0E8h then { "Free type...\n".print; }
+ .when 0E9h then { "Free type...\n".print; }
+ .when 0EAh then { "Free type...\n".print; }
+ .when 0EBh then { "Be FS\n".print; }
+ .when 0ECh then { "Free type...\n".print; }
+ .when 0EDh then { "Free type...\n".print; }
+ .when 0EEh then { "EFI MBR\n".print; }
+ .when 0EFh then { "EFI\n".print; }
+ .when 0F0h then { "Linux/PA-RISC boot loader\n".print; }
+ .when 0F1h then { "SpeedStor\n".print; }
+ .when 0F2h then { "DOS 3.3+ secondary partition\n".print; }
+ .when 0F3h then { "reserved \n".print; }
+ .when 0F4h then { "SpeedStor large Prologue single-volume\n".print; }
+ .when 0F5h then { "Prologue multi-volume\n".print; }
+ .when 0F6h then { "reserved\n".print; }
+ .when 0F7h then { "Free type...\n".print; }
+ .when 0F8h then { "Free type...\n".print; }
+ .when 0F9h then { "Free type...\n".print; }
+ .when 0FAh then { "Free type...\n".print; }
+ .when 0FBh then { "VMware File System\n".print; }
+ .when 0FCh then { "VMware Swap\n".print; }
+ .when 0FDh then { "Linux raid\n".print; }
+ .when 0FEh then { "SpeedStor > 1024 cyl, IBM PS/2 IML, Windows NT Disk Administrator, Linux Logical Volume Manager\n".print; }
+ .when 0FFh then { "Xenix Bad Block Table\n".print; };
+
+ (is_active).if {
+ "Active.".print;
+ } else {
+ "Not active.".print;
+ };
+ "\n\tBegin\t Head=".print;
+ head_begin.print;
+ " Cylinder=".print;
+ cylinder_begin.print;
+ " Sector=".print;
+ sector_begin.print;
+
+ "\n\tEnd\t Head=".print;
+ head_end.print;
+ " Cylinder=".print;
+ cylinder_end.print;
+ " Sector=".print;
+ sector_end.print;
+
+ "\n\tFirst sector=".print;
+ mbr_first_sector.print;
+ "\n\tSize=".print;
+ (size>>11).print;
+ " MB.\n".print;
+ );
diff --git a/isaacos/file_system/partition.li b/isaacos/file_system/partition.li
new file mode 100755
index 0000000..2b30a89
--- /dev/null
+++ b/isaacos/file_system/partition.li
@@ -0,0 +1,89 @@
+///////////////////////////////////////////////////////////////////////////////
+// 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; 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 := PARTITION;
+
+
+ - bibliography:= "http://www.lisaac.org";
+ - author := "Sonntag Benoit (benoit.sonntag at lisaac.org)";
+ - comment := "Partition Hard disk.";
+
+Section Inherit
+
+ + parent_entry:Expanded ENTRY;
+ + parent_directory:Expanded DIRECTORY;
+
+Section Private
+
+ + step:UINTEGER_32;
+
+ - sector:UINTEGER_32<- deferred;
+ // cluster to sector.
+
+Section Public
+
+ + drive:DRIVE;
+
+ + first_sector:UINTEGER_32;
+
+ - step_byte:UINTEGER_32<- (step * drive.step);
+
+ //
+ // Read / Write.
+ //
+
+ - read <-
+ (
+ drive.set_cursor sector;
+ buffer.clear;
+ drive.read buffer size step;
+ );
+
+ - write <-
+ (
+ drive.set_cursor sector;
+ drive.write buffer size step;
+ );
+
+ + buffer:FAST_ARRAY(UINTEGER_8);
+
+ //
+ // Creation.
+ //
+
+ - create drv:DRIVE begin fsector:UINTEGER_32:SELF <-
+ ( + result:SELF;
+
+ result:=SELF.clone;
+ result.make drv begin fsector;
+ result
+ );
+
+ - make drv:DRIVE begin fsector:UINTEGER_32<-
+ (
+ deferred;
+ );
+
+ - make <- deferred; // Load root directory.
+
+ //
+ // Debug & Display.
+ //
+
+ - print <- deferred;
+
+
diff --git a/isaacos/file_system/physical/bios_controler.li b/isaacos/file_system/physical/bios_controler.li
new file mode 100755
index 0000000..f298a95
--- /dev/null
+++ b/isaacos/file_system/physical/bios_controler.li
@@ -0,0 +1,154 @@
+///////////////////////////////////////////////////////////////////////////////
+// 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; 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 := BIOS_CONTROLER;
+
+
+ - bibliography:= "http://www.lisaac.org";
+ - author := "Sonntag Benoit (benoit.sonntag at lisaac.org), Hilbert Jerome";
+ - comment := "BIOS Controler.";
+
+ - date := "2008";
+
+Section Inherit
+
+ + parent_controler:Expanded CONTROLER;
+
+Section Public
+
+ //
+ // Read Drive status.
+ //
+
+ - read_status:BOOLEAN <-
+ ( + buf_32:NATIVE_ARRAY(UINTEGER_32);
+ + buf_16:NATIVE_ARRAY(UINTEGER_16);
+ + result:BOOLEAN;
+
+ buf_16 := CONVERT(NATIVE_ARRAY(UINTEGER_8),NATIVE_ARRAY(UINTEGER_16)).on (BIOS.get_buffer);
+ buf_32 := CONVERT(NATIVE_ARRAY(UINTEGER_8),NATIVE_ARRAY(UINTEGER_32)).on (BIOS.get_buffer);
+ REGISTER.set_ah 48h;
+ REGISTER.set_dl n_drive;
+
+ REGISTER.set_ds (BIOS.segment_buffer);
+ REGISTER.set_si (BIOS.offset_buffer);
+ BIOS.clear_buffer;
+ buf_16.put 1Eh to 0;
+
+ BIOS.call_interrupt 13h;
+ (! REGISTER.carry).if {
+ nbr_cylinder := buf_32.item 1;
+ nbr_head := buf_32.item 2;
+ nbr_sector := buf_32.item 3;
+ result := TRUE;
+ };
+ result
+ );
+
+Section CONTROLER
+
+ //
+ // Read / Write.
+ //
+
+ - physical_read dest:FAST_ARRAY(UINTEGER_8) size s:INTEGER :UINTEGER_32<-
+ ( + nb_sec:UINTEGER_32;
+ + buf_32:NATIVE_ARRAY(UINTEGER_32);
+ + buf_16:NATIVE_ARRAY(UINTEGER_16);
+ + buf_8:NATIVE_ARRAY(UINTEGER_8);
+
+ ? {dest!=NULL};
+ ? { s > 0 };
+ buf_8 := BIOS.get_buffer;
+ nb_sec := s;
+
+ {
+ //version nouvelles interruptions:
+ buf_16 := CONVERT(NATIVE_ARRAY(UINTEGER_8),NATIVE_ARRAY(UINTEGER_16)).on buf_8;
+ buf_32 := CONVERT(NATIVE_ARRAY(UINTEGER_8),NATIVE_ARRAY(UINTEGER_32)).on buf_8;
+ REGISTER.set_ah 42h;
+ REGISTER.set_dl n_drive;
+ REGISTER.set_ds (BIOS.segment_buffer);
+ REGISTER.set_si (BIOS.offset_buffer);
+ BIOS.clear_buffer;
+ buf_16.put 10h to 0;
+ buf_16.put 1 to 1;
+ buf_16.put (BIOS.offset_buffer+512) to 2;
+ buf_16.put (BIOS.segment_buffer) to 3;
+ buf_32.put cursor to 2;
+ buf_32.put 0 to 3;
+ BIOS.call_interrupt 13h;
+ 0.to 511 do { j:INTEGER;
+ dest.add_last (buf_8.item (512+j));
+ };
+ cursor := cursor + 1;
+ nb_sec := nb_sec - 1;
+ }.do_until {nb_sec = 0};
+ s
+ );
+
+ - physical_write src:FAST_ARRAY(UINTEGER_8) size s:INTEGER :UINTEGER_32<-
+ ( + nb_sec:UINTEGER_32;
+ + buf_32:NATIVE_ARRAY(UINTEGER_32);
+ + buf_16:NATIVE_ARRAY(UINTEGER_16);
+ + buf_8:NATIVE_ARRAY(UINTEGER_8);
+
+ -? {src != NULL};
+ ? { s > 0 };
+
+ ? {s = 1}; // JHJH: see CACHE_SECTOR
+
+ buf_8 := BIOS.get_buffer;
+ nb_sec := s;
+// {
+ buf_16 := CONVERT(NATIVE_ARRAY(UINTEGER_8),NATIVE_ARRAY(UINTEGER_16)).on buf_8;
+ buf_32 := CONVERT(NATIVE_ARRAY(UINTEGER_8),NATIVE_ARRAY(UINTEGER_32)).on buf_8;
+ REGISTER.set_ah 43h;
+ REGISTER.set_al 0;
+ REGISTER.set_dl n_drive;
+
+ REGISTER.set_ds (BIOS.segment_buffer);
+ REGISTER.set_si (BIOS.offset_buffer);
+ buf_16.put 10h to 0;
+ buf_16.put 1 to 1;
+ buf_16.put (BIOS.offset_buffer+512) to 2;
+ buf_16.put (BIOS.segment_buffer) to 3;
+ buf_32.put cursor to 2;
+ buf_32.put 0 to 3;
+ 0.to 511 do { j:INTEGER;
+ buf_8.put (src.item j) to (512+j);
+ };
+ BIOS.call_interrupt 13h;
+
+ cursor := cursor + 1;
+// nb_sec := nb_sec - 1;
+// }.do_until {nb_sec = 0};
+ s
+ );
+
+
+ - set_head h:UINTEGER_8 track t:UINTEGER_16 sector s:UINTEGER_8 size sz:INTEGER <-
+ // Select a drive / head / track / sector
+ ( ? {sz < 256};
+ ? {nbr_head >= h};
+ ? {nbr_cylinder >= t};
+ ? {nbr_sector >= s};
+ // Nothing for BIOS
+ );
+
+
+
diff --git a/isaacos/file_system/physical/cache_sector.li b/isaacos/file_system/physical/cache_sector.li
new file mode 100644
index 0000000..9f6ebf2
--- /dev/null
+++ b/isaacos/file_system/physical/cache_sector.li
@@ -0,0 +1,76 @@
+///////////////////////////////////////////////////////////////////////////////
+// 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; 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 := CACHE_SECTOR;
+
+ - copyright := "2003-2008 Sonntag Benoit";
+
+ - author := "Sonntag Benoit (benoit.sonntag at lisaac.org)";
+ - comment := "The main prototype";
+
+Section Inherit
+
+ - parent_object:OBJECT := OBJECT;
+
+Section Public
+
+ + buffer:NATIVE_ARRAY(UINTEGER_8);
+
+ + next:CACHE_SECTOR;
+
+ - set_next c:CACHE_SECTOR <-
+ (
+ next := c;
+ );
+
+ + previous:CACHE_SECTOR;
+
+ - set_previous c:CACHE_SECTOR <-
+ (
+ previous := c;
+ );
+
+ + has_write:BOOLEAN;
+
+ - set_has_write c:BOOLEAN <-
+ (
+ has_write := c;
+ );
+
+ + cursor:UINTEGER_32;
+
+ - set_cursor c:UINTEGER_32 <-
+ (
+ cursor := c;
+ );
+ //
+ // Creation.
+ //
+
+ - create:SELF <-
+ ( + result:SELF;
+ result := clone;
+ result.make;
+ result
+ );
+
+ - make <-
+ (
+ cursor := -1;
+ buffer := NATIVE_ARRAY(UINTEGER_8).create 512;
+ );
+
diff --git a/isaacos/file_system/physical/controler.li b/isaacos/file_system/physical/controler.li
new file mode 100755
index 0000000..7e77ab0
--- /dev/null
+++ b/isaacos/file_system/physical/controler.li
@@ -0,0 +1,139 @@
+///////////////////////////////////////////////////////////////////////////////
+// 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; 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 := CONTROLER;
+
+
+ - bibliography:= "http://www.lisaac.org";
+ - author := "Sonntag Benoit (benoit.sonntag at lisaac.org)";
+ - comment := "Controler.";
+
+ - date := "2003/05";
+
+Section Inherit
+
+ - parent_object:OBJECT := OBJECT;
+
+
+Section Public
+
+ + port_base:UINTEGER_16;
+
+ //
+ // Creation.
+ //
+
+ - create port_b:UINTEGER_16 :SELF <-
+ ( + result:SELF;
+
+ result := Self.clone;
+ result.make port_b;
+ result
+ );
+
+ - make port_b:UINTEGER_16 <-
+ (
+ port_base := port_b;
+ );
+
+ //
+ // Deferred.
+ //
+
+ - n_drive:UINTEGER_8 <- deferred;
+
+ - nbr_sector:UINTEGER_32 <- deferred;
+
+ - nbr_cylinder:UINTEGER_32<- deferred;
+
+ - nbr_head:UINTEGER_32 <- deferred;
+
+ - step:UINTEGER_32 <- deferred;
+
+ - cursor:UINTEGER_32 <- deferred;
+
+ - is_removable:BOOLEAN <- deferred;
+
+// - is_read_only:BOOLEAN <- deferred;
+
+ //
+ // Services
+ //
+
+ - size:UINTEGER_32 <-
+ // Size drive (sector)
+ (
+ nbr_sector * nbr_cylinder * nbr_head
+ );
+
+ - set_cursor new_cursor:UINTEGER_32<-
+ (
+ ? { new_cursor < size};
+ cursor := new_cursor;
+ );
+
+ //
+ // Read status.
+ //
+
+ - read_status:BOOLEAN <-
+ (
+ deferred;
+ FALSE
+ );
+
+ //
+ // Read/Write
+ //
+
+Section CONTROLER
+
+ - physical_read dest:FAST_ARRAY(UINTEGER_8) size s:INTEGER :UINTEGER_32<-
+ (
+ ? {dest!=NULL};
+ deferred;
+ 0
+ );
+
+ - physical_write src:FAST_ARRAY(UINTEGER_8) size s:INTEGER :UINTEGER_32<-
+ (
+ // ( ? {! is_read_only};
+ ? {src != NULL};
+ deferred;
+ 0
+ );
+
+ - set_cursor_and_size sz:INTEGER <-
+ // Compute and physical position
+ ( + h,s:UINTEGER_8;
+ + t:UINTEGER_16;
+ + remain:UINTEGER_32;
+ + head_x_sec:UINTEGER_32;
+
+ head_x_sec := nbr_head * nbr_sector;
+ t := (cursor / head_x_sec).to_uinteger_16;
+ remain := cursor % head_x_sec;
+ h := (remain / nbr_sector).to_uinteger_8;
+ s := (remain % nbr_sector).to_uinteger_8 + 1;
+ set_head h track t sector s size sz;
+ );
+
+ - set_head h:UINTEGER_8 track t:UINTEGER_16 sector s:UINTEGER_8 size sz:INTEGER <-
+ (
+ deferred;
+ );
+
diff --git a/isaacos/file_system/physical/drive.li b/isaacos/file_system/physical/drive.li
new file mode 100755
index 0000000..f7d6b0e
--- /dev/null
+++ b/isaacos/file_system/physical/drive.li
@@ -0,0 +1,178 @@
+///////////////////////////////////////////////////////////////////////////////
+// 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; 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 := DRIVE;
+
+
+ - bibliography:= "http://www.lisaac.org";
+ - author := "Sonntag Benoit (benoit.sonntag at lisaac.org)";
+ - comment := "Drive Manager";
+
+ - date := "2003/05";
+
+Section Inherit
+
+ + parent_controler:CONTROLER := CONTROLER;
+
+Section DRIVER, FAT12, PARTITION
+
+ //
+ // Creation.
+ //
+
+ - drive_create ctrl:CONTROLER drive drv:UINTEGER_8 :SELF <-
+ ( + result:SELF;
+
+ result := SELF.clone;
+ result.make ctrl drive drv
+ );
+
+ - make ctrl:CONTROLER drive drv:UINTEGER_8 :SELF <-
+ ( + result:SELF;
+ + new:CACHE_SECTOR;
+ parent_controler := ctrl;
+ n_drive := drv;
+ (read_status).if {
+ result := Self;
+ cache := HASHED_DICTIONARY(CACHE_SECTOR,UINTEGER_32).create_with_capacity 53;
+ first := last := CACHE_SECTOR.create;
+ 1.to 53 do { j:INTEGER;
+ new := CACHE_SECTOR.create;
+ last.set_next new;
+ new.set_previous last;
+ last := new;
+ };
+ };
+ result
+ );
+
+ //
+ // Data.
+ //
+
+ + cursor:UINTEGER_32;
+
+ + n_drive:UINTEGER_8;
+
+ + nbr_sector:UINTEGER_32;
+
+ + nbr_cylinder:UINTEGER_32;
+
+ + nbr_head:UINTEGER_32;
+
+ - step:UINTEGER_32:= 512;
+
+Section Private
+
+ + cache:HASHED_DICTIONARY(CACHE_SECTOR,UINTEGER_32);
+
+ + first:CACHE_SECTOR;
+
+ + last:CACHE_SECTOR;
+
+ - dest:FAST_ARRAY(UINTEGER_8) :=FAST_ARRAY(UINTEGER_8).clone;
+
+ - flush <-
+ ( + sec:CACHE_SECTOR;
+
+ sec := first;
+ { sec != NULL }.while_do {
+ (sec.has_write).if {
+ set_cursor (sec.cursor);
+ dest.make_with_native_array (sec.buffer) size 512;
+ physical_write dest size 1;
+ };
+ sec := sec.next;
+ };
+ );
+
+ - get_cache cursor:UINTEGER_32 :CACHE_SECTOR <-
+ ( + sector:CACHE_SECTOR;
+
+ sector := cache.reference_at cursor;
+ (sector = NULL).if {
+ (last.has_write).if {
+ set_cursor (last.cursor);
+ dest.make_with_native_array (last.buffer) size 512;
+ physical_write dest size 1;
+ };
+ (last.cursor != -1).if {
+ cache.remove (last.cursor);
+ };
+ sector := last;
+ set_cursor cursor;
+ dest.make_with_native_array (sector.buffer) size 512;
+ dest.clear;
+ physical_read dest size 1;
+ sector.set_has_write FALSE;
+ sector.set_cursor cursor;
+ cache.add sector to cursor;
+ };
+ (first != sector).if {
+ (sector = last).if {
+ last := sector.previous;
+ } else {
+ sector.next.set_previous (sector.previous);
+ };
+ sector.previous.set_next (sector.next);
+ sector.set_next first;
+ first.set_previous sector;
+ sector.set_previous NULL;
+ first := sector;
+ };
+ sector
+ );
+
+
+Section Public
+
+ - create ctrl:CONTROLER drive drv:UINTEGER_8 :SELF <- drive_create ctrl drive drv;
+
+ - sector_size:UINTEGER_16 <- 512;
+
+
+ - read dest:FAST_ARRAY(UINTEGER_8) size s:INTEGER :UINTEGER_32<-
+ ( //+ sec:CACHE_SECTOR;
+ physical_read dest size s
+/* 0.to (s-1) do { j:INTEGER;
+ sec := get_cache cursor;
+ 0.to 511 do { i:INTEGER;
+ dest.add_last (sec.buffer.item i);
+ };
+ };
+ s*/
+ );
+
+ - write src:FAST_ARRAY(UINTEGER_8) size s:INTEGER :UINTEGER_32<-
+ [
+// -? {! is_read_only};
+ -? {src != NULL};
+ ]
+ ( + sec:CACHE_SECTOR;
+ + pos:INTEGER;
+
+ 0.to (s-1) do { k:INTEGER;
+ sec := get_cache cursor;
+ sec.set_has_write TRUE;
+ 0.to 511 do { i:INTEGER;
+ sec.buffer.put (src.item pos) to i;
+ pos := pos + 1;
+ };
+ cursor := cursor + 1;
+ };
+ s
+ );
diff --git a/isaacos/file_system/physical/floppy_controler.li b/isaacos/file_system/physical/floppy_controler.li
new file mode 100755
index 0000000..7172cf3
--- /dev/null
+++ b/isaacos/file_system/physical/floppy_controler.li
@@ -0,0 +1,114 @@
+///////////////////////////////////////////////////////////////////////////////
+// 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; 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 := FLOPPY_CONTROLER;
+
+ - bibliography:= "http://www.lisaac.org";
+ - author := "Boutet Jerome (pisteur at free.fr),Sonntag Benoit (benoit.sonntag at lisaac.org)";
+ - comment := "Floppy Disk Controler.";
+
+ - date := "2003/05";
+
+Section Inherit
+
+ + parent_controler:Expanded CONTROLER;
+
+Section Public
+
+ - is_removable:BOOLEAN := TRUE;
+
+ //
+ // Read Status.
+ //
+
+ - read_status <-
+ ( + boot:BOOT;
+
+ REGISTER.set_ax 0201h; // Read first sector.
+ REGISTER.set_cx 1;
+ REGISTER.set_dx n_drive;
+ REGISTER.set_es (BIOS.segment_buffer);
+ REGISTER.set_bx (BIOS.offset_buffer);
+ BIOS.call_interrupt 013h;
+
+ boot := CONVERT(NATIVE_ARRAY(UINTEGER_8),BOOT).on (BIOS.buffer);
+
+ // Read datas
+ nbr_head := boot.nb_head;
+ nbr_sector := boot.sectors_per_track;
+ nbr_cylinder := boot.nb_sectors.to_uinteger_32/ (nbr_head * nbr_sector);
+ );
+
+ //
+ // Read / Write.
+ //
+
+ - read dest:FAST_ARRAY(UINTEGER_8) size s:INTEGER :UINTEGER_32<-
+ ( + byte:UINTEGER_8;
+ ? {dest!=NULL};
+ ? {dest.valid_stream (s*step)};
+ ? { s > 0 };
+
+ 1.to s do { n:INTEGER;
+ // Read sector via Bios.
+ set_cursor_and_size 1;
+ REGISTER.set_ah 02h;
+ BIOS.call_interrupt 013h;
+ 0.to 511 do { i:UINTEGER_32;
+ byte := BIOS.buffer.item i;
+ dest.add_last byte;
+ };
+ cursor := cursor + 1;
+ };
+
+ s
+ );
+
+ - write src:FAST_ARRAY(UINTEGER_8) size s:INTEGER :UINTEGER_32<-
+ ( + idx:UINTEGER_32;
+ ? {src != NULL};
+ ? {! is_read_only};
+ ? { s > 0 };
+ ? {start + s <= (src.count)};
+ ? {src.valid_stream (s*step)};
+
+ 1.to s do { n:UINTEGER_32;
+ 0.to 511 do { i:UINTEGER_32;
+ BIOS.buffer.put (src.item idx) to i;
+ idx := idx + 1;
+ };
+ set_cursor_and_size 1;
+ REGISTER.set_ah 03h;
+ BIOS.call_interrupt 013h;
+ cursor := cursor + 1;
+ };
+
+ s
+ );
+
+Section Private
+
+ - set_head h:UINTEGER_8 track t:UINTEGER_16 sector s:UINTEGER_8 size sz:INTEGER <-
+ (
+ ? {sz = 1};
+ REGISTER.set_al sz;
+ REGISTER.set_cx (((t & 0FFh)<<8) | ((t >> 2) & 00C0h) | s);
+ REGISTER.set_dx ((h.to_uinteger_16 << 8) | n_drive);
+ REGISTER.set_es (BIOS.segment_buffer);
+ REGISTER.set_bx (BIOS.offset_buffer);
+ );
+
diff --git a/isaacos/file_system/physical/ide_controler.li b/isaacos/file_system/physical/ide_controler.li
new file mode 100755
index 0000000..3d2cef5
--- /dev/null
+++ b/isaacos/file_system/physical/ide_controler.li
@@ -0,0 +1,164 @@
+///////////////////////////////////////////////////////////////////////////////
+// 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; 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 := IDE_CONTROLER;
+
+
+ - bibliography:= "http://www.lisaac.org";
+ - author := "Sonntag Benoit (benoit.sonntag at lisaac.org)";
+ - comment := "IDE Controler.";
+
+ - date := "2003/04";
+
+Section Inherit
+
+ + parent_controler:Expanded CONTROLER;
+
+Section Public
+
+ //
+ // Read Drive status.
+ //
+
+ - read_status <-
+ (
+ wait_controler;
+ SYSTEM.putb n_drive to (port_base | 6h); // Select a drive
+ send_cmd 0ECh; // Informations on drive
+ wait_data;
+ SYSTEM.itemw port_base;
+ nbr_cylinder := SYSTEM.itemw port_base;
+ SYSTEM.itemw port_base;
+ nbr_head := SYSTEM.itemw port_base;
+ SYSTEM.itemw port_base;
+ SYSTEM.itemw port_base;
+ nbr_sector := SYSTEM.itemw port_base;
+ 0.to 248 do { j:INTEGER; // 256 - 7
+ SYSTEM.itemw port_base;
+ };
+ );
+
+ //
+ // Read / Write.
+ //
+
+ - read dest:FAST_ARRAY(UINTEGER_8) size s:INTEGER :UINTEGER_32<-
+ ( + size,nb_sec:UINTEGER_32;
+ + value:UINTEGER_16;
+ ? {dest!=NULL};
+ // ? {dest.valid_stream (step * s.to_uinteger)};
+ ? { s > 0 };
+ /*
+ "Ide_Controler : \tSector #".print;
+ cursor.to_hexadecimal.print;
+ " size #".print;
+ s.to_integer.print;
+ '\n'.print;
+ */
+ nb_sec := s;
+ {
+ size := nb_sec.min 128;
+ wait_controler;
+ set_cursor_and_size size;
+ send_cmd 20h; // read cmd (or 21h, 22h, 23h)
+ 1.to size do { i:INTEGER;
+ wait_data;
+ 0.to 255 do { j:INTEGER;
+ value := SYSTEM.itemw port_base;
+ dest.add_last ((value & 0FFh).to_uinteger_8);
+ dest.add_last ((value >> 8).to_uinteger_8);
+ };
+ };
+ cursor := cursor + size;
+ nb_sec := nb_sec - size;
+ }.do_until {nb_sec = 0};
+
+ s
+ );
+
+ - write src:FAST_ARRAY(UINTEGER_8) size s:INTEGER :UINTEGER_32<-
+ ( //+ size,nb_sec:UINTEGER_32;
+ //+ idx:UINTEGER_32;
+ ? {src != NULL};
+ ? {! is_read_only};
+ ? {s > 0};
+ /* // Pour ne pas faire de betise....
+ nb_sec := s;
+ {
+ size := nb_sec.min 128;
+ wait_controller;
+ set_cursor_and_size size;
+ send_cmd 60; // write cmd (or 202,203)
+ 1.to size do { i:INTEGER;
+ wait_data;
+ 0.to 255 do { j:INTEGER;
+ value := src.item (idx+1);
+ value := (value << 8) | src.item idx;
+ SYSTEM.putw value to port_base;
+ idx := idx + 2;
+ };
+ };
+ cursor := cursor + size;
+ nb_sec := nb_sec - size;
+ }.do_until {nb_sec = 0};
+ */
+ s
+ );
+
+Section Private
+
+ - set_head h:UINTEGER_8 track t:UINTEGER_16 sector s:UINTEGER_8 size sz:INTEGER <-
+ // Select a drive / head / track / sector
+ ( ? {sz < 256};
+ ? {nbr_head >= h};
+ ? {nbr_cylinder >= t};
+ ? {nbr_sector >= s};
+
+ SYSTEM.putb (sz.to_uinteger_8) to (port_base | 2h);
+ SYSTEM.putb s to (port_base | 3h);
+ SYSTEM.putb ((t & 0FFh).to_uinteger_8) to (port_base | 4h); // low track
+ SYSTEM.putb ((t >> 8 ).to_uinteger_8) to (port_base | 5h); // high track
+ SYSTEM.putb (n_drive | h) to (port_base | 6h); // drive/head
+ );
+
+ //
+ // Intern Sub Routine.
+ //
+
+ - wait_controler <-
+ // Wait for the IDE controler
+ (
+ {
+ (SYSTEM.itemb (port_base | 007h) != 50h) &&
+ {SYSTEM.itemb (port_base | 007h) != 51h}
+ }.while_do { };
+ );
+
+ - wait_data <-
+ // Wait for data
+ (
+ {SYSTEM.itemb (port_base | 007h) != 58h}.while_do { };
+ );
+
+ - send_cmd c:UINTEGER_8 <-
+ // Wait for the IDE controler
+ (
+ SYSTEM.putb c to (port_base | 007h);
+ );
+
+
+
diff --git a/isaacos/file_system/physical/sector.li b/isaacos/file_system/physical/sector.li
new file mode 100755
index 0000000..5b668c2
--- /dev/null
+++ b/isaacos/file_system/physical/sector.li
@@ -0,0 +1,91 @@
+///////////////////////////////////////////////////////////////////////////////
+// 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; 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 := SECTOR;
+
+ - bibliography:= "http://www.lisaac.org";
+ - author := "Sonntag Benoit (benoit.sonntag at lisaac.org)";
+ - comment := "Cache sector 4Ko";
+
+ - date := "2003/05";
+
+Section Inherit
+
+ - parent_object:OBJECT := OBJECT;
+
+Section Public
+
+ //
+ // Creation.
+ //
+
+ - create n:SECTOR :SELF <-
+ ( + result:SELF;
+
+ result := SELF.clone;
+ result.make n;
+ result
+ );
+
+ - make n:SECTOR <-
+ (
+ buffer := FAST_ARRAY(UINTEGER_8).create 4096;
+ page := 0FFFFFFFFh;
+ next := n;
+ );
+
+ //
+ // Data.
+ //
+
+ + page:UINTEGER_32;
+
+ + buffer:FAST_ARRAY(UINTEGER_8);
+
+ + is_write:BOOLEAN;
+
+ + next:SECTOR;
+
+ //
+ // Set data.
+ //
+
+ - set_page n:UINTEGER_32<-
+ (
+ page := n;
+ );
+
+ - set_write b:BOOLEAN <-
+ (
+ is_write := b;
+ );
+
+ - set_next n:SECTOR <-
+ (
+ next := n;
+ );
+
+ //
+ // Buffer facility.
+ //
+
+ - item idx:INTEGER :UINTEGER_8 <- buffer.item idx;
+
+ - put elt:UINTEGER_8 to idx:INTEGER <- buffer.put elt to idx;
+
+
+
diff --git a/isaacos/make.lip b/isaacos/make.lip
new file mode 100644
index 0000000..8b4876a
--- /dev/null
+++ b/isaacos/make.lip
@@ -0,0 +1,46 @@
+///////////////////////////////////////////////////////////////////////////////
+// Lisaac Installer //
+// //
+// 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/ //
+///////////////////////////////////////////////////////////////////////////////
+
+// Lisaac Path Directory System (by Benoit Sonntag).
+
+Section Inherit
+
+ + parent:STRING; // by default, inherite from main `make.lip'
+
+Section Private
+
+ - example_path <-
+ // Example path.
+ (
+ path "*";
+ path "../examples/standard/*";
+ );
+
+ //
+ // Execute function.
+ //
+
+ - front_end <-
+ (
+ general_front_end;
+ example_path;
+ );
+
diff --git a/isaacos/scheduler.li b/isaacos/scheduler.li
new file mode 100755
index 0000000..1e144f5
--- /dev/null
+++ b/isaacos/scheduler.li
@@ -0,0 +1,113 @@
+///////////////////////////////////////////////////////////////////////////////
+// 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; 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 := SCHEDULER;
+
+ - copyright := "2003-2008 Sonntag Benoit";
+
+ - author := "Sonntag Benoit (sonntag at icps.u-strasbg.fr)";
+ - comment := "The main prototype";
+
+Section Inherit
+
+ - parent_object:OBJECT := OBJECT;
+
+Section Private
+
+ - task_list:FAST_ARRAY(TASK);
+
+ - current_task : INTEGER;
+
+Section Interrupt
+
+ - interrupt_20h <-
+ ( + old_stack, new_stack:POINTER;
+ + old_task,new_task:TASK;
+
+ old_task := task_list.item current_task;
+ `asm("movl %%ebp,%0":"=m"(@old_stack))`;
+ old_task.set_top_stack old_stack;
+ //
+ current_task := (current_task + 1) % task_list.count;
+ //
+ new_task := task_list.item current_task;
+ (new_task.top_stack = 0).if {
+ // Wake up.
+ // Copy from frame_stack to old_stack in new_stack.
+ new_task.stack.put (CONVERT(TASK,UINTEGER_32).on new_task) to 1023;
+ new_task.stack.put (`zombie`:UINTEGER_32) to 1022;
+ new_task.stack.put 03202h to 1021; // Flags. (IOPL=3) & STI
+ new_task.stack.put (SYSTEM.descriptor_code) to 1020;
+ new_task.stack.put (`wake_up`:UINTEGER_32) to 1019;
+ //new_task.stack.put (`zombie`:UINTEGER_32) to 1019;
+ new_task.stack.put 015AAC05h to 1018;
+ new_stack := CONVERT(NATIVE_ARRAY(UINTEGER_32),POINTER).on (new_task.stack.storage+1018);
+ `asm("movl %0,%%ebp"::"m"(@new_stack))`;
+ } else {
+ new_stack := new_task.top_stack;
+ `asm("movl %0,%%ebp"::"m"(@new_stack))`;
+ };
+ // Acknowledge.
+ SYSTEM.putb 20h to 020h;
+ );
+
+Section Public
+
+ - add t:TASK <-
+ ( + stack:FAST_ARRAY(UINTEGER_32);
+
+ stack := FAST_ARRAY(UINTEGER_32).create 1024; // 4Ko.
+ t.set_stack stack;
+ task_list.add_last t;
+
+ '\n'.print;
+ SCHEDULER.task_list.count.print;
+ );
+
+ - remove t:TASK <-
+ (
+ //task_list.remove current_task;
+ //`asm("hlt")`;
+ {}.loop_infinitely;
+ );
+
+ - make <-
+ ( + stack:FAST_ARRAY(UINTEGER_32);
+ + na:NATIVE_ARRAY(UINTEGER_32);
+ + task:TASK;
+
+ task_list := FAST_ARRAY(TASK).create_with_capacity 16;
+ // Define current stack.
+ na := CONVERT(INTEGER,NATIVE_ARRAY(UINTEGER_32)).on (1.mb);
+ stack := FAST_ARRAY(UINTEGER_32).clone;
+ stack.make_with_native_array na size (1.mb);
+ // Define current stack.
+ task := TASK.clone;
+ task.set_stack stack;
+ task_list.add_last task;
+ //
+ SYSTEM.new_interrupt interrupt_20h to 20h;
+ SYSTEM.irq_on 0; // Active IRQ0
+ );
+
+Section Private
+
+ - kill th:THREAD <-
+ (
+
+ "End thread\n".print;
+ );
diff --git a/isaacos/startup.li b/isaacos/startup.li
new file mode 100755
index 0000000..c05dd62
--- /dev/null
+++ b/isaacos/startup.li
@@ -0,0 +1,184 @@
+///////////////////////////////////////////////////////////////////////////////
+// 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; 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 := STARTUP;
+
+ - bibliography:="http://www.lisaac.org";
+ - author :="Sonntag Benoit (benoit.sonntag at lisaac.org)";
+ - comment :="Startup system : First object.";
+
+ // - version :="1.0";
+ - date :="2003/04";
+
+// BUG: L'inclusion du parent dans fils (je genere un =, gcc genere un memcpy)
+ - external := `
+#include <signal.h>
+__sighandler_t signal(int signum,__sighandler_t handler) { return(handler); }
+void *memcpy(void *dest,const void *src,int n)
+{ int j;
+
+ for (j=0;j<n;j++) ((char*)dest)[j] = ((char*)src)[j];
+ return dest;
+};
+
+
+//void print_char(char c) {};
+`;
+
+Section Inherit
+
+ - parent_object:OBJECT := OBJECT;
+
+
+Section Public
+/*
+ - bitmap:ABSTRACT_BITMAP :=
+ ( + result:ABSTRACT_BITMAP;
+
+ result := BITMAP(PIXEL_24).create (90,30);
+ result.color (result.red);
+ result.print "No image" to (10,10);
+ result
+ );
+*/
+
+ - main <-
+ ( + dir:DIRECTORY;
+
+
+ SYSTEM.make;
+
+
+/* SCHEDULER.make;
+
+ th := THREAD.create (10,10) message "ISAAC" color 12;
+ THREAD2.create;
+*/
+ /*
+ th := THREAD.create (20,15) message "VIVE NOUS" color 10;
+ th := THREAD.create (30,10) message "VIVE ISAAC" color 1;
+ th := THREAD.create (40,10) message "VIVE COP" color 6;
+ th := THREAD.create (20,10) message "VIVE NEWTON" color 8Ch;
+ */
+ /*
+ th := THREAD.create (10,10) message "ISAAC" color 12;
+ */
+ // {
+ // "Life\n".print;
+ // `asm("hlt")`;
+ //KEYBOARD.wait_key;
+ //'\n'.print;
+
+ // }.loop_infinitely;
+ /*
+ THREAD.wake_up THREAD;
+ THREAD.zombie THREAD;
+ THREAD.wake_up THREAD2;
+ THREAD.zombie THREAD2;
+ */
+
+ FILE_SYSTEM.open;
+
+
+ (FILE_SYSTEM.is_open).if {
+ FILE_SYSTEM.print;
+ } else {
+ "FILE SYSTEM close\n".print;
+ };
+
+
+ dir ?= FILE_SYSTEM.get_entry "freedos/icons";
+ (dir = NULL).if{
+ "\ndirectory is NULL\n".print;
+ } else {
+ dir.open;
+ dir.print;
+ };
+
+
+/*
+ dir ?= FILE_SYSTEM.get_entry "ext2";
+
+ (dir = NULL).if{
+ "\ndirectory ext2 is NULL\n".print;
+ } else {
+ dir.open;
+ dir.print;
+ };
+ */
+ /*
+ (
+ + std,std1:STD_FILE;
+ + fa:FAST_ARRAY(CHARACTER);
+ + s:STRING;
+
+ s := STRING.create 30;
+ s.copy "YESSSS, ISAAC POWER !!!!!\n";
+ std ?= dir.get_entry "media.bmp";
+ (std = NULL).if {"pas au point\n".print;};
+ std.open;
+// std.size.print; '\n'.print;
+
+ fa := FAST_ARRAY(CHARACTER).create_with_capacity (std.size);
+ std.read fa size (std.size);
+ 0.to (std.size-1) do {j:INTEGER;
+ fa.item j .print;
+ };
+ '\n'.print;
+
+ std.write s from 0 size (s.count);
+ std.close;
+ //force l'ecriture du cache
+ std1 ?= dir.get_entry "calc.bmp";
+ (std1 = NULL).if {"pas au point\n".print;};
+ std1.open;
+ fa := FAST_ARRAY(CHARACTER).create_with_capacity (std1.size);
+ std1.read fa size (std.size);
+ //reouverture !!
+ std.open;
+ fa := FAST_ARRAY(CHARACTER).create_with_capacity (std.size);
+ std.read fa size (std.size);
+ 0.to (std.size-1) do {j:INTEGER;
+ fa.item j .print;
+ };
+ '\n'.print;
+
+ );
+ */
+
+ VIDEO.auto_make;
+ CLOCK.make;
+ /*
+ DESK.make VIDEO scale (2,1) with (
+ DESK_BOARD.create "freedos/icons/".fix_height / G_RAW.create (G_IMG.create "freedos/icons/isaac.ai")
+ );*/
+
+ //VIDEO.close;
+ die_with_code exit_success_code;
+ );
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/isaacos/startup.sys b/isaacos/startup.sys
new file mode 100644
index 0000000..d22933b
Binary files /dev/null and b/isaacos/startup.sys differ
diff --git a/isaacos/task.li b/isaacos/task.li
new file mode 100644
index 0000000..92a152f
--- /dev/null
+++ b/isaacos/task.li
@@ -0,0 +1,64 @@
+///////////////////////////////////////////////////////////////////////////////
+// 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; 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 := TASK;
+
+ - copyright := "2003-2008 Sonntag Benoit";
+
+ - author := "Sonntag Benoit (benoit.sonntag at lisaac.org)";
+ - comment := "The main prototype";
+
+Section Inherit
+
+ - parent_object:OBJECT := OBJECT;
+
+Section SCHEDULER
+
+ - set_stack s:FAST_ARRAY(UINTEGER_32) <-
+ (
+ stack := s;
+ );
+
+ - set_top_stack top:POINTER <-
+ (
+ top_stack := top;
+ );
+
+ + stack:FAST_ARRAY(UINTEGER_32);
+ + top_stack:POINTER;
+
+Section External
+
+ - wake_up obj:TASK <-
+ (
+ obj.action;
+
+ //zombie;
+ );
+
+ - zombie obj:TASK <-
+ (
+ "Zombie\n".print;
+ SCHEDULER.remove obj;
+ );
+
+Section Public
+
+ - action <-
+ (
+ deferred;
+ );
diff --git a/isaacos/thread.li b/isaacos/thread.li
new file mode 100644
index 0000000..6d677d5
--- /dev/null
+++ b/isaacos/thread.li
@@ -0,0 +1,99 @@
+///////////////////////////////////////////////////////////////////////////////
+// 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; 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 := THREAD;
+
+ - copyright := "2003-2008 Sonntag Benoit";
+
+ - author := "Sonntag Benoit (sonntag at icps.u-strasbg.fr)";
+ - comment := "The main prototype";
+
+Section Inherit
+
+ + parent_task:Expanded TASK;
+
+Section Public
+
+ + message:ABSTRACT_STRING;
+ + color:UINTEGER_8;
+ + posx:INTEGER;
+ + posy:INTEGER;
+
+ //
+ // Creation.
+ //
+
+ - create (x,y:INTEGER) message msg:ABSTRACT_STRING color col:UINTEGER_8 :SELF <-
+ ( + result:SELF;
+ result := clone;
+ result.make (x,y) message msg color col;
+ result
+ );
+
+ - make (x,y:INTEGER) message msg:ABSTRACT_STRING color col:UINTEGER_8 <-
+ (
+ message := msg;
+ color := col;
+ posx := x;
+ posy := y;
+ SCHEDULER.add Self;
+ );
+
+ - action <-
+ ( + dx,dy:INTEGER;
+
+ dx := 1;
+ dy := 1;
+ {
+ put (posx,posy) string message color 0;
+ posx := posx + dx;
+ posy := posy + dy;
+ ((posx + message.count >= 80) || {posx <= 0}).if {
+ dx := -dx;
+ };
+ ((posy >= 23) || {posy <= 0}).if {
+ dy := -dy;
+ };
+ put (posx,posy) string message color color;
+ //KEYBOARD.wait_key;
+ (SYSTEM.itemb 060h = 1h).if {
+ + str:STRING;
+ {SYSTEM.itemb 060h = 1}.while_do {};
+ str := STRING.create 50;
+ str.copy "ISAAC ";
+ SCHEDULER.task_list.count.append_in str;
+ THREAD.create (40,10) message str color ((color+1)&0Fh);
+ };
+ // `asm("hlt")`;
+ }.do_while {`(1)`:BOOLEAN(TRUE,FALSE)};
+ );
+
+Section Private
+
+ - put (x,y:INTEGER) string str:ABSTRACT_STRING color col:UINTEGER_8 <-
+ ( + ecr:NATIVE_ARRAY(UINTEGER_8);
+ + ofs:INTEGER;
+ ecr := CONVERT(INTEGER,NATIVE_ARRAY(UINTEGER_8)).on 0B8000h;
+ ofs := y*160 + 2*x;
+ (str.lower).to (str.upper) do { i:INTEGER;
+ ecr.put (str.item i.to_uinteger_8) to ofs;
+ ofs := ofs + 1;
+ ecr.put col to ofs;
+ ofs := ofs + 1;
+ };
+ );
+
diff --git a/isaacos/thread2.li b/isaacos/thread2.li
new file mode 100644
index 0000000..0c2f768
--- /dev/null
+++ b/isaacos/thread2.li
@@ -0,0 +1,49 @@
+///////////////////////////////////////////////////////////////////////////////
+// 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; 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 := THREAD2;
+
+ - copyright := "2003-2008 Sonntag Benoit ; Jérome Hilbert";
+
+ - author := "Sonntag Benoit (benoit.sonntag at lisaac.org)";
+ - comment := "The main prototype";
+
+Section Inherit
+
+ + parent_task:Expanded TASK;
+
+Section Public
+
+
+ - create:SELF <-
+ ( + result:SELF;
+ result := clone;
+ result.make;
+ result
+ );
+
+ - make <-
+ (
+ SCHEDULER.add Self;
+ );
+
+ - action <-
+ (
+ "Je suis un thread qui va mourir !!!!!!!!!!!\n".print;
+ //{}.loop_infinitely;
+ );
+
diff --git a/isaacos/tool/elf2eof/elf2eof b/isaacos/tool/elf2eof/elf2eof
new file mode 100755
index 0000000..b949c8f
Binary files /dev/null and b/isaacos/tool/elf2eof/elf2eof differ
diff --git a/isaacos/tool/elf2eof/elf_header.li b/isaacos/tool/elf2eof/elf_header.li
new file mode 100755
index 0000000..3bc4599
--- /dev/null
+++ b/isaacos/tool/elf2eof/elf_header.li
@@ -0,0 +1,169 @@
+///////////////////////////////////////////////////////////////////////////////
+// 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; 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 := ELF_HEADER;
+
+ - bibliography:= "http://www.lisaac.org";
+ - author := "Sonntag Benoit (benoit.sonntag at lisaac.org)";
+ - comment := "ELF Header Mapping";
+
+Section Inherit
+
+ - parent_object:OBJECT := OBJECT;
+
+Section Mapping
+
+ + ident_0:UINTEGER_32;
+ + class :UINTEGER_8;
+ + data :UINTEGER_8;
+ + ver :UINTEGER_8;
+ + pad_0 :UINTEGER_8;
+ + pad_1 :UINTEGER_32;
+ + pad_2 :UINTEGER_16;
+ + pad_3 :UINTEGER_8;
+ + nident :UINTEGER_8;
+
+ + type :UINTEGER_16;
+ + machine:UINTEGER_16;
+ + version:UINTEGER_32;
+
+ + entry :UINTEGER_32;
+
+ + ph_off :UINTEGER_32;
+ + sh_off :UINTEGER_32;
+
+ + flags :UINTEGER_32;
+ + size :UINTEGER_16;
+
+ + ph_entsize:UINTEGER_16;
+ + ph_num :UINTEGER_16;
+ + sh_entsize:UINTEGER_16;
+ + sh_num :UINTEGER_16;
+ + sh_strndx:UINTEGER_16;
+
+Section Public
+
+ - display <-
+ ( + ident:NATIVE_ARRAY(CHARACTER);
+
+ "ELF HEADER\n".print;
+
+ // Ident.
+ ident := NATIVE_ARRAY(CHARACTER).force_conversion self;
+ " Ident \t: ".print;
+ 0.to 3 do { j:INTEGER; ident.item j.print; };
+ class
+ .when 0 then { ", Invalid class, ".print; }
+ .when 1 then { ", 32-bit, ".print; }
+ .when 2 then { ", 64-bit, ".print; };
+ data
+ .when 0 then { "Invalid data encoding, ".print; }
+ .when 1 then { "Intel data encoding, ".print; }
+ .when 2 then { "Motorola data encoding, ".print; };
+ "Ver. ".print;
+ ver.print;
+ ", size=".print;
+ nident.print;
+ ".\n".print;
+
+ // Type.
+ " Type \t\t: ".print;
+ type
+ .when 0 then { "No file type.\n".print; }
+ .when 1 then { "Relocatable file.\n".print; }
+ .when 2 then { "Executable file.\n".print; }
+ .when 3 then { "Shared object file.\n".print; }
+ .when 4 then { "Core file.\n".print; }
+ .when 0FF00h or 0FFFFh then { "Processor-specific.\n".print; };
+
+ // Machine.
+ " Machine \t: ".print;
+ machine
+ .when 0 then { "No machine.\n".print; }
+ .when 1 then { "AT&T WE 32100.\n".print; }
+ .when 2 then { "SPARC.\n".print; }
+ .when 3 then { "Intel Architecture.\n".print; }
+ .when 4 then { "Motorola 68000.\n".print; }
+ .when 5 then { "Motorola 88000.\n".print; }
+ .when 6 then { "6 (?).\n".print; }
+ .when 7 then { "Intel 80860.\n".print; }
+ .when 8 then { "MIPS RS3000 Big-Endian.\n".print; }
+ .when 9 then { "8 (?).\n".print; }
+ .when 10 then { "MIPS RS4000 Big-Endian.\n".print; }
+ .when 11 to 16 then { "Reserved for future use.\n".print; }
+ .when 17 to 39 then { machine.print; " (?).\n".print; }
+ .when 40 then { "ARM/Thumb Architecture.\n".print; }
+ .when 41 to 0FFFFh then { machine.print; " (?).\n".print; };
+
+ // Version.
+ " Version \t: ".print;
+ (version = 0).if {
+ "Invalid version.\n".print;
+ } else {
+ "Current version.\n".print;
+ };
+
+ // Entry.
+ " Entry \t\t\t\t: ".print;
+ entry.to_hexadecimal.print;
+ "h.\n".print;
+
+ // ph_off.
+ " Program header table's file offset \t: ".print;
+ ph_off.to_hexadecimal.print;
+ "h.\n".print;
+
+ // sh_off.
+ " Section header table's file offset \t: ".print;
+ sh_off.to_hexadecimal.print;
+ "h.\n".print;
+
+ // Flags.
+ " Flags \t\t\t\t: ".print;
+ flags.to_hexadecimal.print;
+ "h.\n".print;
+ //.when
+
+ // Size.
+ " ELF header's size \t\t\t: ".print;
+ size.print;
+ " bytes.\n".print;
+
+ // Ph_entsize.
+ " Program header table size \t\t: ".print;
+ ph_entsize.print;
+ " bytes.\n".print;
+
+ // Ph_num.
+ " Number of program header table \t: ".print;
+ ph_num.print;
+ ".\n".print;
+
+ // Sh_entsize.
+ " Section header table size \t\t: ".print;
+ sh_entsize.print;
+ " bytes.\n".print;
+
+ // Sh_num.
+ " Number of section header table \t: ".print;
+ sh_num.print;
+ ".\n".print;
+
+ // Sh_strndx.
+ " String table index \t\t\t: ".print;
+ sh_strndx.to_hexadecimal.print;
+ "h.\n".print;
+ );
diff --git a/isaacos/tool/gcc/entry_isaac.c b/isaacos/tool/gcc/entry_isaac.c
new file mode 100755
index 0000000..bb9a6db
--- /dev/null
+++ b/isaacos/tool/gcc/entry_isaac.c
@@ -0,0 +1,4 @@
+void entry_isaac()
+{
+ main();
+};
diff --git a/isaacos/tool/gcc/ipaq/isaac.x b/isaacos/tool/gcc/ipaq/isaac.x
new file mode 100755
index 0000000..f280903
--- /dev/null
+++ b/isaacos/tool/gcc/ipaq/isaac.x
@@ -0,0 +1,41 @@
+/* Default linker script, for normal executables */
+OUTPUT_FORMAT("elf32-littlearm", "elf32-bigarm",
+ "elf32-littlearm")
+OUTPUT_ARCH(arm)
+ENTRY(entry_isaac)
+ SEARCH_DIR(/home/bsonntag/arm/lib);
+SECTIONS
+{
+ . = 0xA0008100;
+ .text :
+ {
+ ../tool/gcc/ipaq/entry_isaac.o
+ ../tool/gcc/ipaq/_divsi3.o
+ ../tool/gcc/ipaq/_udivsi3.o
+ ../tool/gcc/ipaq/_modsi3.o
+ ../tool/gcc/ipaq/_umodsi3.o
+ ../tool/gcc/ipaq/_dvmd_lnx.o
+ *(.text .stub .text.* .gnu.linkonce.t.*)
+ } =0
+ .rodata :
+ {
+ *(.rodata .rodata.* .gnu.linkonce.r.*)
+ }
+ .rodata1 :
+ {
+ *(.rodata1)
+ }
+ .data :
+ {
+ *(.data .data.* .gnu.linkonce.d.*)
+ SORT(CONSTRUCTORS)
+ }
+ .bss :
+ {
+ *(COMMON)
+ . = ALIGN(32 / 8);
+ }
+ . = ALIGN(32 / 8);
+ /* PROVIDE (end = .);*/
+
+}
diff --git a/isaacos/tool/gcc/ipaq/specs b/isaacos/tool/gcc/ipaq/specs
new file mode 100755
index 0000000..0aa7aa0
--- /dev/null
+++ b/isaacos/tool/gcc/ipaq/specs
@@ -0,0 +1,139 @@
+*asm:
+%{mbig-endian:-EB} %{mcpu=*:-m%*} %{march=*:-m%*} %{mapcs-*:-mapcs-%*} %{mapcs-float:-mfloat} %{msoft-float:-mno-fpu} %{mthumb-interwork:-mthumb-interwork} %(subtarget_extra_asm_spec)
+
+*asm_debug:
+
+
+*asm_final:
+
+
+*asm_options:
+%a %Y %{c:%W{o*}%{!o*:-o %w%b%O}}%{!c:-o %d%w%u%O}
+
+*invoke_as:
+%{!S:-o %{|!pipe:%g.s} |
+ as %(asm_options) %{!pipe:%g.s} %A }
+
+*cpp:
+%(cpp_cpu_arch) %(cpp_apcs_pc) %(cpp_float) %(cpp_endian) %(subtarget_cpp_spec) %(cpp_isa) %(cpp_interwork)
+
+*cpp_options:
+%(cpp_unique_options) %{std*} %{d*} %{W*} %{w} %{pedantic*} %{fshow-column} %{fno-show-column} %{fsigned-char&funsigned-char} %{fleading-underscore} %{fno-leading-underscore} %{fno-operator-names} %{ftabstop=*}
+
+*cpp_unique_options:
+%{C:%{!E:%eGNU C does not support -C without using -E}} %{nostdinc*} %{C} %{v} %{I*} %{P} %{$} %I %{MD:-MD %W{!o: %b.d}%W{o*:%.d%*}} %{MMD:-MMD %W{!o: %b.d}%W{o*:%.d%*}} %{M} %{MM} %W{MF*} %{MG} %{MP} %{MQ*} %{MT*} %{!E:%{!M:%{!MM:%{MD|MMD:%{o*:-MQ %*}}}}} %{!no-gcc:-D__GNUC__=%v1 -D__GNUC_MINOR__=%v2 -D__GNUC_PATCHLEVEL__=%v3} %{!undef:%{!ansi:%{!std=*:%p}%{std=gnu*:%p}} %P} %{trigraphs} %{Os:-D__OPTIMIZE_SIZE__} %{O*:%{!O0:-D__OPTIMIZE__}} %{fno-inline|O0|!O*:-D__NO_INLINE__} %{ffast-math:-D__FAST_MATH__} %{fshort-wchar:-U__WCHAR_TYPE__ -D__WCHAR_TYPE__=short\ unsigned\ int} %{ffreestanding:-D__STDC_HOSTED__=0} %{fno-hosted:-D__STDC_HOSTED__=0} %{!ffreestanding:%{!fno-hosted:-D__STDC_HOSTED__=1}} %{remap} %{g3:-dD} %{H} %C %{D*&U*&A*} %{i*} %Z %i %{E|M|MM:%W{o*}}
+
+*trad_capable_cpp:
+%{traditional|ftraditional|traditional-cpp:trad}cpp0
+
+*cc1:
+%{profile:-p}
+
+*cc1_options:
+%{pg:%{fomit-frame-pointer:%e-pg and -fomit-frame-pointer are incompatible}} %1 %{!Q:-quiet} -dumpbase %B %{d*} %{m*} %{a*} %{g*} %{O*} %{W*} %{w} %{pedantic*} %{std*} %{ansi} %{traditional} %{v:-version} %{pg:-p} %{p} %{f*} %{Qn:-fno-ident} %{--help:--help} %{--target-help:--target-help} %{!fsyntax-only:%{S:%W{o*}%{!o*:-o %b.s}}} %{fsyntax-only:-o %j} %{-param*}
+
+*cc1plus:
+
+
+*link_gcc_c_sequence:
+%G %L %G
+
+*endfile:
+%{!shared:crtend.o%s} %{shared:crtendS.o%s} crtn.o%s
+
+*link:
+%{h*} %{version:-v} %{b} %{Wl,*:%*} %{static:-Bstatic} %{shared:-shared} %{symbolic:-Bsymbolic} %{rdynamic:-export-dynamic} %{!dynamic-linker:-dynamic-linker /lib/ld-linux.so.2} -X %{mbig-endian:-EB} -m armelf_linux -p
+
+*lib:
+%{shared: -lc} %{!shared: %{pthread:-lpthread} %{profile:-lc_p} %{!profile: -lc}}
+
+*libgcc:
+%{msoft-float:-lfloat} %{static|static-libgcc:-lgcc -lgcc_eh}%{!static:%{!static-libgcc:%{!shared:%{!shared-libgcc:-lgcc -lgcc_eh}%{shared-libgcc:-lgcc_s%M -lgcc}}%{shared:-lgcc_s%M}}}
+
+*startfile:
+
+
+*switches_need_spaces:
+
+
+*predefines:
+-Dunix -D__gnu_linux__ -Dlinux -D__ELF__ -Asystem=unix -Asystem=posix
+
+*cross_compile:
+1
+
+*version:
+3.1.1
+
+*multilib:
+. ;
+
+*multilib_defaults:
+marm mlittle-endian mhard-float mapcs-32 mno-thumb-interwork
+
+*multilib_extra:
+
+
+*multilib_matches:
+
+
+*multilib_exclusions:
+
+
+*linker:
+collect2
+
+*link_libgcc:
+%D
+
+*md_exec_prefix:
+
+
+*md_startfile_prefix:
+
+
+*md_startfile_prefix_1:
+
+
+*cpp_cpu_arch:
+-Acpu=arm -Amachine=arm %{march=arm2:-D__ARM_ARCH_2__} %{march=arm250:-D__ARM_ARCH_2__} %{march=arm3:-D__ARM_ARCH_2__} %{march=arm6:-D__ARM_ARCH_3__} %{march=arm600:-D__ARM_ARCH_3__} %{march=arm610:-D__ARM_ARCH_3__} %{march=arm7:-D__ARM_ARCH_3__} %{march=arm700:-D__ARM_ARCH_3__} %{march=arm710:-D__ARM_ARCH_3__} %{march=arm720:-D__ARM_ARCH_3__} %{march=arm7100:-D__ARM_ARCH_3__} %{march=arm7500:-D__ARM_ARCH_3__} %{march=arm7500fe:-D__ARM_ARCH_3__} %{march=arm7m:-D__ARM_ARCH_3M__} %{march=arm7dm:-D__ARM_ARCH_3M__} %{march=arm7dmi:-D__ARM_ARCH_3M__} %{march=arm7tdmi:-D__ARM_ARCH_4T__} %{march=arm8:-D__ARM_ARCH_4__} %{march=arm810:-D__ARM_ARCH_4__} %{march=arm9:-D__ARM_ARCH_4T__} %{march=arm920:-D__ARM_ARCH_4__} %{march=arm920t:-D__ARM_ARCH_4T__} %{march=arm9tdmi:-D__ARM_ARCH_4T__} %{march=strongarm:-D__ARM_ARCH_4__} %{march=strongarm110:-D__ARM_ARCH_4__} %{march=strongarm1100:-D__ARM_ARCH_4__} %{march=xscale:-D__ARM_ARCH_5TE__} %{march=xscale:-D__XSCALE__} %{march=armv2:-D__ARM_ARCH_2__} %{march=armv2a:-D__ARM_ARCH_2__} %{march=armv3:-D__ARM_ARCH_3__} %{march=armv3m:-D__ARM_ARCH_3M__} %{march=armv4:-D__ARM_ARCH_4__} %{march=armv4t:-D__ARM_ARCH_4T__} %{march=armv5:-D__ARM_ARCH_5__} %{march=armv5t:-D__ARM_ARCH_5T__} %{march=armv5e:-D__ARM_ARCH_5E__} %{march=armv5te:-D__ARM_ARCH_5TE__} %{!march=*: %{mcpu=arm2:-D__ARM_ARCH_2__} %{mcpu=arm250:-D__ARM_ARCH_2__} %{mcpu=arm3:-D__ARM_ARCH_2__} %{mcpu=arm6:-D__ARM_ARCH_3__} %{mcpu=arm600:-D__ARM_ARCH_3__} %{mcpu=arm610:-D__ARM_ARCH_3__} %{mcpu=arm7:-D__ARM_ARCH_3__} %{mcpu=arm700:-D__ARM_ARCH_3__} %{mcpu=arm710:-D__ARM_ARCH_3__} %{mcpu=arm720:-D__ARM_ARCH_3__} %{mcpu=arm7100:-D__ARM_ARCH_3__} %{mcpu=arm7500:-D__ARM_ARCH_3__} %{mcpu=arm7500fe:-D__ARM_ARCH_3__} %{mcpu=arm7m:-D__ARM_ARCH_3M__} %{mcpu=arm7dm:-D__ARM_ARCH_3M__} %{mcpu=arm7dmi:-D__ARM_ARCH_3M__} %{mcpu=arm7tdmi:-D__ARM_ARCH_4T__} %{mcpu=arm8:-D__ARM_ARCH_4__} %{mcpu=arm810:-D__ARM_ARCH_4__} %{mcpu=arm9:-D__ARM_ARCH_4T__} %{mcpu=arm920:-D__ARM_ARCH_4__} %{mcpu=arm920t:-D__ARM_ARCH_4T__} %{mcpu=arm9tdmi:-D__ARM_ARCH_4T__} %{mcpu=strongarm:-D__ARM_ARCH_4__} %{mcpu=strongarm110:-D__ARM_ARCH_4__} %{mcpu=strongarm1100:-D__ARM_ARCH_4__} %{mcpu=xscale:-D__ARM_ARCH_5TE__} %{mcpu=xscale:-D__XSCALE__} %{!mcpu*:%(cpp_cpu_arch_default)}}
+
+*cpp_cpu_arch_default:
+-D__ARM_ARCH_5TE__ -D__XSCALE__
+
+*cpp_apcs_pc:
+%{mapcs-32:%{mapcs-26:%e-mapcs-26 and -mapcs-32 may not be used together} -D__APCS_32__} %{mapcs-26:-D__APCS_26__} %{!mapcs-32: %{!mapcs-26:%(cpp_apcs_pc_default)}}
+
+*cpp_apcs_pc_default:
+-D__APCS_32__
+
+*cpp_float:
+%{msoft-float: %{mhard-float:%e-msoft-float and -mhard_float may not be used together} -D__SOFTFP__} %{!mhard-float:%{!msoft-float:%(cpp_float_default)}}
+
+*cpp_float_default:
+
+
+*cpp_endian:
+%{mbig-endian: %{mlittle-endian: %e-mbig-endian and -mlittle-endian may not be used together} -D__ARMEB__ %{mwords-little-endian:-D__ARMWEL__} %{mthumb:-D__THUMBEB__}}%{mlittle-endian:-D__ARMEL__ %{mthumb:-D__THUMBEL__}} %{!mlittle-endian:%{!mbig-endian:%(cpp_endian_default)}}
+
+*cpp_endian_default:
+-D__ARMEL__ %{mthumb:-D__THUMBEL__}
+
+*cpp_isa:
+%{mthumb:-D__thumb__} %{!mthumb:-D__arm__}
+
+*cpp_interwork:
+ %{mthumb-interwork: %{mno-thumb-interwork: %eincompatible interworking options} -D__THUMB_INTERWORK__} %{!mthumb-interwork:%{!mno-thumb-interwork:%(cpp_interwork_default)}}
+
+*cpp_interwork_default:
+
+
+*subtarget_cpp_spec:
+%{posix:-D_POSIX_SOURCE} %{fPIC:-D__PIC__ -D__pic__} %{fpic:-D__PIC__ -D__pic__}
+
+*subtarget_extra_asm_spec:
+
+
+*link_command:
+%{!fsyntax-only:%{!c:%{!M:%{!MM:%{!E:%{!S: %(linker) %l %X %{o*} %{A} %{d} %{e*} %{m} %{N} %{n} %{r} %{s} %{t} %{u*} %{x} %{z} %{Z} %{!A:%{!nostdlib:%{!nostartfiles:%S}}} %{static:} %{L*} %(link_libgcc) %o %{!nostdlib:%{!nodefaultlibs:-nostdlib}} %{!A:%{!nostdlib:%{!nostartfiles:%E}}} %{!T*:-T../tool/gcc/ipaq/isaac.x} %{T*} }}}}}}
+
diff --git a/isaacos/tool/gcc/st2xx/asm_traphandler.S b/isaacos/tool/gcc/st2xx/asm_traphandler.S
new file mode 100755
index 0000000..ce91fdb
--- /dev/null
+++ b/isaacos/tool/gcc/st2xx/asm_traphandler.S
@@ -0,0 +1,211 @@
+/*********************************************************************
+ * File path: glue/v4-st230/traphandler.S
+ * Description: st230 specific traphandler
+ ********************************************************************/
+
+#include <macros.h>
+#include INC_ARCH(macros.h)
+#include INC_ARCH(regdef.h)
+#include INC_ARCH(cpu.h)
+#include <tcb_layout.h>
+
+ENTRY(pswset)
+ pswset r16
+ ;;
+ return lr
+ ;;
+
+ENTRY(pswclr)
+ pswclr r16
+ ;;
+ return lr
+ ;;
+
+
+ENTRY(asm_trap_handler)
+ stw user_stack[zero]= r12 // save temporary user_stack
+ ;;
+ ldw r12 = current_tcb_ptr[zero] // retrieve current TCB
+ ;;
+ ;;
+ ;;
+ ldw r12 = OFS_TCB_STACK[r12] // retrieve kernel stack of current thread
+ ;;
+ stw 4[r12]=r1 // save first r1 to use it
+ ;;
+ ldw r1 = 0xFFFFFFF0[zero] // save SAVED_PSW
+ ;;
+ ;;
+ add r12 = r12, -248
+ ;;
+ stw 260[r12] = r1
+ ;;
+ ldw r1 = 0xFFFFFFE8[zero] // save SAVED_PC
+ ;;
+ ;;
+ ;;
+ stw 256[r12] = r1
+ ;;
+ stw 248[r12]=r2 // save general registers
+ ;;
+ stw 244[r12]=r3
+ ;;
+ stw 240[r12]=r4
+ ;;
+ stw 236[r12]=r5
+ ;;
+ stw 232[r12]=r6
+ ;;
+ stw 228[r12]=r7
+ ;;
+ stw 224[r12]=r8
+ ;;
+ stw 220[r12]=r9
+ ;;
+ stw 216[r12]=r10
+ ;;
+ stw 212[r12]=r11
+ ;;
+ ldw r1 = user_stack[zero]
+ ;;
+ stw 208[r12] = r1
+ ;;
+ stw 204[r12]=r13
+ ;;
+ stw 200[r12]=r14
+ ;;
+ stw 196[r12]=r15
+ ;;
+ stw 192[r12]=r16
+ ;;
+ stw 188[r12]=r17
+ ;;
+ stw 184[r12]=r18
+ ;;
+ stw 180[r12]=r19
+ ;;
+ stw 176[r12]=r20
+ ;;
+ stw 172[r12]=r21
+ ;;
+ stw 168[r12]=r22
+ ;;
+ stw 164[r12]=r23
+ ;;
+ stw 160[r12]=r24
+ ;;
+ stw 156[r12]=r25
+ ;;
+ stw 152[r12]=r26
+ ;;
+ stw 148[r12]=r27
+ ;;
+ stw 144[r12]=r28
+ ;;
+ stw 140[r12]=r29
+ ;;
+ stw 136[r12]=r30
+ ;;
+ stw 132[r12]=r31
+ ;;
+ stw 128[r12]=r32
+ ;;
+ stw 124[r12]=r33
+ ;;
+ stw 120[r12]=r34
+ ;;
+ stw 116[r12]=r35
+ ;;
+ stw 112[r12]=r36
+ ;;
+ stw 108[r12]=r37
+ ;;
+ stw 104[r12]=r38
+ ;;
+ stw 100[r12]=r39
+ ;;
+ stw 96[r12]=r40
+ ;;
+ stw 92[r12]=r41
+ ;;
+ stw 88[r12]=r42
+ ;;
+ stw 84[r12]=r43
+ ;;
+ stw 80[r12]=r44
+ ;;
+ stw 76[r12]=r45
+ ;;
+ stw 72[r12]=r46
+ ;;
+ stw 68[r12]=r47
+ ;;
+ stw 64[r12]=r48
+ ;;
+ stw 60[r12]=r49
+ ;;
+ stw 56[r12]=r50
+ ;;
+ stw 52[r12]=r51
+ ;;
+ stw 48[r12]=r52
+ ;;
+ stw 44[r12]=r53
+ ;;
+ stw 40[r12]=r54
+ ;;
+ stw 36[r12]=r55
+ slctf r2 = br0, zero, (1<<0) // begin BRs saving
+ movl r1 = 0
+ ;;
+ stw 32[r12]=r56
+ slctf r2 = br1, zero, (1<<1)
+ or r1 = r1, r2
+ ;;
+ stw 28[r12]=r57
+ slctf r2 = br2, zero, (1<<2)
+ or r1 = r1, r2
+ ;;
+ stw 24[r12]=r58
+ slctf r2 = br3, zero, (1<<3)
+ or r1 = r1, r2
+ ;;
+ stw 20[r12]=r59
+ slctf r2 = br4, zero, (1<<4)
+ or r1 = r1, r2
+ ;;
+ stw 16[r12]=r60
+ slctf r2 = br5, zero, (1<<5)
+ or r1 = r1, r2
+ ;;
+ stw 12[r12]=r61
+ slctf r2 = br6, zero, (1<<6)
+ or r1 = r1, r2
+ ;;
+ stw 8[r12]=r62
+ slctf r2 = br7, zero, (1<<7)
+ or r1 = r1, r2
+ ;;
+ stw 4[r12]=lr
+ or r1 = r1, r2
+ ;;
+ stb 0[r12]=r1 // saving BRs
+ ;;
+ ldw r1 = current_tcb_ptr[zero]
+ ;;
+ ;;
+ ;;
+ stw OFS_TCB_STACK[r1] = r12 // save kernel_stack in TCB
+ add r12 = r12 , -16
+ ;;
+ call lr = handle_trap
+ ;;
+ rfi
+ ;;
+
+
+
+ .data
+user_stack:
+ .align 4
+ .skip 4
\ No newline at end of file
diff --git a/isaacos/tool/gcc/st2xx/entry_isaac.s b/isaacos/tool/gcc/st2xx/entry_isaac.s
new file mode 100755
index 0000000..63efc97
--- /dev/null
+++ b/isaacos/tool/gcc/st2xx/entry_isaac.s
@@ -0,0 +1,346 @@
+ .section .text
+ .global start
+start:
+ /***********************/
+ /* Stack init */
+ /***********************/
+ mov $r0.12 = 0x09FFFFF0 /* 0x09FFFFFF */ /* 32 Mo */
+ ;;
+ /***********************/
+ /* Call main */
+ /***********************/
+ call $r0.63 = main
+ ;;
+ /***********************/
+ /* PSW manager */
+ /***********************/
+ .global set_psw
+set_psw:
+ pswset $r0.16
+ ;;
+ return $r0.63
+ ;;
+ .global clr_psw
+clr_psw:
+ pswclr $r0.16
+ ;;
+ return $r0.63
+ ;;
+ /***********************/
+ /* Trap Handler */
+ /***********************/
+ .global trap_handler
+trap_handler:
+ add $r0.12 = $r0.12, - 256
+ ;;
+ stw 252[$r0.12] = $r0.1
+ ;;
+ stw 248[$r0.12] = $r0.2
+ ;;
+ stw 244[$r0.12] = $r0.3
+ ;;
+ stw 240[$r0.12] = $r0.4
+ ;;
+ stw 236[$r0.12] = $r0.5
+ ;;
+ stw 232[$r0.12] = $r0.6
+ ;;
+ stw 228[$r0.12] = $r0.7
+ ;;
+ stw 224[$r0.12] = $r0.8
+ ;;
+ stw 220[$r0.12] = $r0.9
+ ;;
+ stw 216[$r0.12] = $r0.10
+ ;;
+ stw 212[$r0.12] = $r0.11
+ ;;
+ stw 208[$r0.12] = $r0.12 /* A voir ...*/
+ ;;
+ stw 204[$r0.12] = $r0.13
+ ;;
+ stw 200[$r0.12] = $r0.14
+ ;;
+ stw 196[$r0.12] = $r0.15
+ ;;
+ stw 192[$r0.12] = $r0.16
+ ;;
+ stw 188[$r0.12] = $r0.17
+ ;;
+ stw 184[$r0.12] = $r0.18
+ ;;
+ stw 180[$r0.12] = $r0.19
+ ;;
+ stw 176[$r0.12] = $r0.20
+ ;;
+ stw 172[$r0.12] = $r0.21
+ ;;
+ stw 168[$r0.12] = $r0.22
+ ;;
+ stw 164[$r0.12] = $r0.23
+ ;;
+ stw 160[$r0.12] = $r0.24
+ ;;
+ stw 156[$r0.12] = $r0.25
+ ;;
+ stw 152[$r0.12] = $r0.26
+ ;;
+ stw 148[$r0.12] = $r0.27
+ ;;
+ stw 144[$r0.12] = $r0.28
+ ;;
+ stw 140[$r0.12] = $r0.29
+ ;;
+ stw 136[$r0.12] = $r0.30
+ ;;
+ stw 132[$r0.12] = $r0.31
+ ;;
+ stw 128[$r0.12] = $r0.32
+ ;;
+ stw 124[$r0.12] = $r0.33
+ ;;
+ stw 120[$r0.12] = $r0.34
+ ;;
+ stw 116[$r0.12] = $r0.35
+ ;;
+ stw 112[$r0.12] = $r0.36
+ ;;
+ stw 108[$r0.12] = $r0.37
+ ;;
+ stw 104[$r0.12] = $r0.38
+ ;;
+ stw 100[$r0.12] = $r0.39
+ ;;
+ stw 96[$r0.12] = $r0.40
+ ;;
+ stw 92[$r0.12] = $r0.41
+ ;;
+ stw 88[$r0.12] = $r0.42
+ ;;
+ stw 84[$r0.12] = $r0.43
+ ;;
+ stw 80[$r0.12] = $r0.44
+ ;;
+ stw 76[$r0.12] = $r0.45
+ ;;
+ stw 72[$r0.12] = $r0.46
+ ;;
+ stw 68[$r0.12] = $r0.47
+ ;;
+ stw 64[$r0.12] = $r0.48
+ ;;
+ stw 60[$r0.12] = $r0.49
+ ;;
+ stw 56[$r0.12] = $r0.50
+ ;;
+ stw 52[$r0.12] = $r0.51
+ ;;
+ stw 48[$r0.12] = $r0.52
+ ;;
+ stw 44[$r0.12] = $r0.53
+ ;;
+ stw 40[$r0.12] = $r0.54
+ ;;
+ stw 36[$r0.12] = $r0.55
+ slctf $r0.2 = $b0.0, $r0.0, (1<<0) /* begin BRs saving */
+ mov $r0.1 = $r0.0
+ ;;
+ stw 32[$r0.12] = $r0.56
+ slctf $r0.2 = $b0.1, $r0.0, (1<<1)
+ or $r0.1 = $r0.1, $r0.2
+ ;;
+ stw 28[$r0.12] = $r0.57
+ slctf $r0.2 = $b0.2, $r0.0, (1<<2)
+ or $r0.1 = $r0.1, $r0.2
+ ;;
+ stw 24[$r0.12] = $r0.58
+ slctf $r0.2 = $b0.3, $r0.0, (1<<3)
+ or $r0.1 = $r0.1, $r0.2
+ ;;
+ stw 20[$r0.12] = $r0.59
+ slctf $r0.2 = $b0.4, $r0.0, (1<<4)
+ or $r0.1 = $r0.1, $r0.2
+ ;;
+ stw 16[$r0.12] = $r0.60
+ slctf $r0.2 = $b0.5, $r0.0, (1<<5)
+ or $r0.1 = $r0.1, $r0.2
+ ;;
+ stw 12[$r0.12] = $r0.61
+ slctf $r0.2 = $b0.6, $r0.0, (1<<6)
+ or $r0.1 = $r0.1, $r0.2
+ ;;
+ stw 8[$r0.12] = $r0.62
+ slctf $r0.2 = $b0.7, $r0.0, (1<<7)
+ or $r0.1 = $r0.1, $r0.2
+ ;;
+ stw 4[$r0.12] = $r0.63
+ or $r0.1 = $r0.1, $r0.2
+ ;;
+ stb 0[$r0.12]=$r0.1 /* saving BRs */
+ ;;
+ ldw $r0.63 = lisaac_trap[$r0.0]
+ add $r0.12 = $r0.12 , -16
+ ;;
+ /*
+ * Run Interrupt Trap
+ */
+ call $r0.63 = $r0.63
+ /*
+ * Restore registers
+ */
+ ;;
+ add $r0.12 = $r0.12 , 16
+ ;;
+ ldb $r0.1 = 0[$r0.12]
+ ;;
+ andc $r0.2 = $r0.1, (1<<0)
+ ldw $r0.63 = 4[$r0.12]
+ ;;
+ cmpne $b0.0 = $r0.2, $r0.0
+ andc $r0.2 = $r0.1, (1<<1)
+ ldw $r0.62 = 8[$r0.12]
+ ;;
+ cmpne $b0.1 = $r0.2, $r0.0
+ andc $r0.2 = $r0.1, (1<<2)
+ ldw $r0.61 = 12[$r0.12]
+ ;;
+ cmpne $b0.2 = $r0.2, $r0.0
+ andc $r0.2 = $r0.1, (1<<3)
+ ldw $r0.60 = 16[$r0.12]
+ ;;
+ cmpne $b0.3 = $r0.2, $r0.0
+ andc $r0.2 = $r0.1, (1<<4)
+ ldw $r0.59 = 20[$r0.12]
+ ;;
+ cmpne $b0.4 = $r0.2, $r0.0
+ andc $r0.2 = $r0.1, (1<<5)
+ ldw $r0.58 = 24[$r0.12]
+ ;;
+ cmpne $b0.5 = $r0.2, $r0.0
+ andc $r0.2 = $r0.1, (1<<6)
+ ldw $r0.57 = 28[$r0.12]
+ ;;
+ cmpne $b0.6 = $r0.2, $r0.0
+ andc $r0.2 = $r0.1, (1<<7)
+ ldw $r0.56 = 32[$r0.12]
+ ;;
+ cmpne $b0.7 = $r0.2, $r0.0
+ ldw $r0.55 = 36[$r0.12]
+ ;;
+ ldw $r0.54 = 40[$r0.12]
+ ;;
+ ldw $r0.53 = 44[$r0.12]
+ ;;
+ ldw $r0.52 = 48[$r0.12]
+ ;;
+ ldw $r0.51 = 52[$r0.12]
+ ;;
+ ldw $r0.50 = 56[$r0.12]
+ ;;
+ ldw $r0.49 = 60[$r0.12]
+ ;;
+ ldw $r0.48 = 64[$r0.12]
+ ;;
+ ldw $r0.47 = 68[$r0.12]
+ ;;
+ ldw $r0.46 = 72[$r0.12]
+ ;;
+ ldw $r0.45 = 76[$r0.12]
+ ;;
+ ldw $r0.44 = 80[$r0.12]
+ ;;
+ ldw $r0.43 = 84[$r0.12]
+ ;;
+ ldw $r0.42 = 88[$r0.12]
+ ;;
+ ldw $r0.41 = 92[$r0.12]
+ ;;
+ ldw $r0.40 = 96[$r0.12]
+ ;;
+ ldw $r0.39 = 100[$r0.12]
+ ;;
+ ldw $r0.38 = 104[$r0.12]
+ ;;
+ ldw $r0.37 = 108[$r0.12]
+ ;;
+ ldw $r0.36 = 112[$r0.12]
+ ;;
+ ldw $r0.35 = 116[$r0.12]
+ ;;
+ ldw $r0.34 = 120[$r0.12]
+ ;;
+ ldw $r0.33 = 124[$r0.12]
+ ;;
+ ldw $r0.32 = 128[$r0.12]
+ ;;
+ ldw $r0.31 = 132[$r0.12]
+ ;;
+ ldw $r0.30 = 136[$r0.12]
+ ;;
+ ldw $r0.29 = 140[$r0.12]
+ ;;
+ ldw $r0.28 = 144[$r0.12]
+ ;;
+ ldw $r0.27 = 148[$r0.12]
+ ;;
+ ldw $r0.26 = 152[$r0.12]
+ ;;
+ ldw $r0.25 = 156[$r0.12]
+ ;;
+ ldw $r0.24 = 160[$r0.12]
+ ;;
+ ldw $r0.23 = 164[$r0.12]
+ ;;
+ ldw $r0.22 = 168[$r0.12]
+ ;;
+ ldw $r0.21 = 172[$r0.12]
+ ;;
+ ldw $r0.20 = 176[$r0.12]
+ ;;
+ ldw $r0.19 = 180[$r0.12]
+ ;;
+ ldw $r0.18 = 184[$r0.12]
+ ;;
+ ldw $r0.17 = 188[$r0.12]
+ ;;
+ ldw $r0.16 = 192[$r0.12]
+ ;;
+ ldw $r0.15 = 196[$r0.12]
+ ;;
+ ldw $r0.14 = 200[$r0.12]
+ ;;
+ ldw $r0.13 = 204[$r0.12]
+ ;;
+ ldw $r0.12 = 208[$r0.12] /* A voir... */
+ ;;
+ ldw $r0.11 = 212[$r0.12]
+ ;;
+ ldw $r0.10 = 216[$r0.12]
+ ;;
+ ldw $r0.9 = 220[$r0.12]
+ ;;
+ ldw $r0.8 = 224[$r0.12]
+ ;;
+ ldw $r0.7 = 228[$r0.12]
+ ;;
+ ldw $r0.6 = 232[$r0.12]
+ ;;
+ ldw $r0.5 = 236[$r0.12]
+ ;;
+ ldw $r0.4 = 240[$r0.12]
+ ;;
+ ldw $r0.3 = 244[$r0.12]
+ ;;
+ ldw $r0.2 = 248[$r0.12]
+ ;;
+ ldw $r0.1 = 252[$r0.12]
+ add $r0.12 = $r0.12, 256
+ ;;
+ rfi
+ ;;
+ .section .data
+ .global lisaac_trap
+lisaac_trap:
+ .long 0
+
+
diff --git a/isaacos/tool/gcc/st2xx/isaac.x b/isaacos/tool/gcc/st2xx/isaac.x
new file mode 100755
index 0000000..9baebd2
--- /dev/null
+++ b/isaacos/tool/gcc/st2xx/isaac.x
@@ -0,0 +1,41 @@
+/* Default linker script, for normal executables */
+OUTPUT_FORMAT("elf32-littlelx")
+
+ENTRY(start)
+
+SECTIONS
+{
+ .text 0x08000000 :
+ {
+ ../tool/gcc/st2xx/divuw.st220.o
+ ../tool/gcc/st2xx/moduw.st220.o
+ ../tool/gcc/st2xx/divw.st220.o
+ ../tool/gcc/st2xx/entry_isaac.o
+ *(.text .stub .text.* .gnu.linkonce.t.*)
+ }
+ .rodata :
+ {
+ *(.rodata .rodata.* .gnu.linkonce.r.*)
+ }
+ .rodata1 :
+ {
+ *(.rodata1)
+ }
+ .data :
+ {
+ *(.data .data.* .gnu.linkonce.d.*)
+ }
+ .bss :
+ {
+ *(.bss)
+ *(COMMON)
+ . = ALIGN(32 / 8);
+ __bss_stop = .;
+ }
+}
+
+
+
+
+
+
diff --git a/isaacos/tool/gcc/st2xx/tcb.S b/isaacos/tool/gcc/st2xx/tcb.S
new file mode 100755
index 0000000..199782a
--- /dev/null
+++ b/isaacos/tool/gcc/st2xx/tcb.S
@@ -0,0 +1,224 @@
+/*********************************************************************
+ * File path: glue/v4-st230/tcb.S
+ * Description: TCB specific implementations
+ ********************************************************************/
+
+#include <macros.h>
+#include INC_ARCH(regdef.h)
+#include INC_ARCH(macros.h)
+#include <tcb_layout.h>
+
+/*
+ * initial_switch_to: switch to first thread
+ * Argument 1 : New Stack
+ */
+
+
+.section .data
+ENTRY(current_tcb_ptr)
+ .align 4
+ .skip 4
+
+.section .text
+
+ENTRY(asm_initial_switch_to)
+ ldw lr = 0[r16] // prepare jumping to address specified at stack top
+ ;;
+ mov r12 = r16 // update stack_pointer with new stack
+ ;;
+ mov r16 = __idle_tcb
+ ;;
+ stw current_tcb_ptr[zero] = r16
+ ;;
+ call lr = lr
+ ;;
+ mov r16 = r12
+ ;;
+ goto asm_initial_switch_to // executing this means there is still init functions to execute, so switch again
+ add r16 = r16, 16
+ ;;
+
+ENTRY(asm_switch_to)
+
+
+ stw current_tcb_ptr[zero] = r16 // save pointer to new current tcb (global)
+ ;;
+ ldw r17 = OFS_TCB_STACK[r16] // r17 contains future kernel stack pointer
+ ;;
+ ;;
+ ;;
+ add r18 = r17,248
+ ;;
+ stw OFS_TCB_STACK[r16] = r18 // store new kernel stack pointer
+ ;;
+ ldb r1 = 0[r17]
+ ;;
+ ;;
+ ;;
+ andc r2 = r1, (1<<0)
+ ldw lr = 4[r17]
+ ;;
+ cmpne br0 = r2, zero
+ andc r2 = r1, (1<<1)
+ ldw r62 = 8[r17]
+ ;;
+ cmpne br1 = r2, zero
+ andc r2 = r1, (1<<2)
+ ldw r61 = 12[r17]
+ ;;
+ cmpne br2 = r2, zero
+ andc r2 = r1, (1<<3)
+ ldw r60 = 16[r17]
+ ;;
+ cmpne br3 = r2, zero
+ andc r2 = r1, (1<<4)
+ ldw r59 = 20[r17]
+ ;;
+ cmpne br4 = r2, zero
+ andc r2 = r1, (1<<5)
+ ldw r58 = 24[r17]
+ ;;
+ cmpne br5 = r2, zero
+ andc r2 = r1, (1<<6)
+ ldw r57 = 28[r17]
+ ;;
+ cmpne br6 = r2, zero
+ andc r2 = r1, (1<<7)
+ ldw r56 = 32[r17]
+ ;;
+ cmpne br7 = r2, zero
+ ldw r55 = 36[r17]
+ ;;
+ ldw r54 = 40[r17]
+ ;;
+ ldw r53 = 44[r17]
+ ;;
+ ldw r52 = 48[r17]
+ ;;
+ ldw r51 = 52[r17]
+ ;;
+ ldw r50 = 56[r17]
+ ;;
+ ldw r49 = 60[r17]
+ ;;
+ ldw r48 = 64[r17]
+ ;;
+ ldw r47 = 68[r17]
+ ;;
+ ldw r46 = 72[r17]
+ ;;
+ ldw r45 = 76[r17]
+ ;;
+ ldw r44 = 80[r17]
+ ;;
+ ldw r43 = 84[r17]
+ ;;
+ ldw r42 = 88[r17]
+ ;;
+ ldw r41 = 92[r17]
+ ;;
+ ldw r40 = 96[r17]
+ ;;
+ ldw r39 = 100[r17]
+ ;;
+ ldw r38 = 104[r17]
+ ;;
+ ldw r37 = 108[r17]
+ ;;
+ ldw r36 = 112[r17]
+ ;;
+ ldw r35 = 116[r17]
+ ;;
+ ldw r34 = 120[r17]
+ ;;
+ ldw r33 = 124[r17]
+ ;;
+ ldw r32 = 128[r17]
+ ;;
+ ldw r31 = 132[r17]
+ ;;
+ ldw r30 = 136[r17]
+ ;;
+ ldw r29 = 140[r17]
+ ;;
+ ldw r28 = 144[r17]
+ ;;
+ ldw r27 = 148[r17]
+ ;;
+ ldw r26 = 152[r17]
+ ;;
+ ldw r25 = 156[r17]
+ ;;
+ ldw r24 = 160[r17]
+ ;;
+ ldw r23 = 164[r17]
+ ;;
+ ldw r22 = 168[r17]
+ ;;
+ ldw r21 = 172[r17]
+ ;;
+ ldw r20 = 176[r17]
+ ;;
+ ldw r19 = 180[r17]
+ ;;
+ ldw r18 = 184[r17]
+ ;;
+ // r17 skipped
+
+ ldw r16 = 192[r17]
+ ;;
+ ldw r15 = 196[r17]
+ ;;
+ ldw r14 = 200[r17]
+ ;;
+ ldw r13 = 204[r17]
+ ;;
+ ldw r12 = 208[r17]
+ ;;
+ ldw r11 = 212[r17]
+ ;;
+ ldw r10 = 216[r17]
+ ;;
+ ldw r9 = 220[r17]
+ ;;
+ ldw r8 = 224[r17]
+ ;;
+ ldw r7 = 228[r17]
+ ;;
+ ldw r6 = 232[r17]
+ ;;
+ ldw r5 = 236[r17]
+ ;;
+ ldw r4 = 240[r17]
+ ;;
+ // r1,r2,r3 postponed because of use
+
+ ldw r1 = 256[r17] // load SAVED_PC
+ ;;
+ ldw r2 = 260[r17] // load SAVED_PSW
+ ;;
+ ldw r3 = 188[r17] // load r17
+ ;;
+ stw 0xFFFFFFE8[zero] = r1
+ ;;
+ stw 0xFFFFFFF0[zero] = r2
+ ;;
+ stw r17_temp[zero] = r3
+ ;;
+ ldw r3 = 244[r17]
+ ;;
+ ldw r2 = 248[r17]
+ ;;
+ ldw r1 = 252[r17]
+ ;;
+ ldw r17 = r17_temp[zero]
+ ;;
+ ;;
+ ;;
+ rfi
+ ;;
+
+ .data
+r17_temp:
+ .align 4
+ .skip 4
diff --git a/isaacos/tool/gcc/x86/isaac.x b/isaacos/tool/gcc/x86/isaac.x
new file mode 100755
index 0000000..3cc041d
--- /dev/null
+++ b/isaacos/tool/gcc/x86/isaac.x
@@ -0,0 +1,33 @@
+/* Default linker script, for normal executables */
+OUTPUT_FORMAT("elf32-i386")
+/* OUTPUT_ARCH(arm) */
+ENTRY(entry_isaac)
+/* SEARCH_DIR(/home/bsonntag/arm/lib);*/
+SECTIONS
+{
+ .text 0x200000 :
+ {
+ ./tool/gcc/x86/entry_isaac.o
+ *(.text .stub .text.* .gnu.linkonce.t.*)
+ }
+ .rodata :
+ {
+ *(.rodata .rodata.* .gnu.linkonce.r.*)
+ }
+ .rodata1 :
+ {
+ *(.rodata1)
+ }
+ .data :
+ {
+
+ *(.data .data.* .gnu.linkonce.d.*)
+ }
+ .bss :
+ {
+ *(.bss)
+ *(COMMON)
+ . = ALIGN(32 / 8);
+ __bss_stop = .;
+ }
+}
diff --git a/isaacos/tool/gcc/x86/specs b/isaacos/tool/gcc/x86/specs
new file mode 100755
index 0000000..c8218d9
--- /dev/null
+++ b/isaacos/tool/gcc/x86/specs
@@ -0,0 +1,137 @@
+*asm:
+%{v:-V} %{Qy:} %{!Qn:-Qy} %{n} %{T} %{Ym,*} %{Yd,*} %{Wa,*:%*} %{m32:--32} %{m64:--64}
+
+*asm_debug:
+%{gstabs*:--gstabs}%{!gstabs*:%{g*:--gdwarf2}}
+
+*asm_final:
+
+
+*asm_options:
+%a %Y %{c:%W{o*}%{!o*:-o %w%b%O}}%{!c:-o %d%w%u%O}
+
+*invoke_as:
+%{!S:-o %|.s |
+ as %(asm_options) %|.s %A }
+
+*cpp:
+%{posix:-D_POSIX_SOURCE} %{pthread:-D_REENTRANT}
+
+*cpp_options:
+%(cpp_unique_options) %1 %{m*} %{std*&ansi&trigraphs} %{W*&pedantic*} %{w} %{f*} %{g*:%{!g0:%{!fno-working-directory:-fworking-directory}}} %{O*} %{undef} %{save-temps:-fpch-preprocess}
+
+*cpp_debug_options:
+%{d*}
+
+*cpp_unique_options:
+%{C|CC:%{!E:%eGCC does not support -C or -CC without -E}} %{!Q:-quiet} %{nostdinc*} %{C} %{CC} %{v} %{I*&F*} %{P} %I %{MD:-MD %{!o:%b.d}%{o*:%.d%*}} %{MMD:-MMD %{!o:%b.d}%{o*:%.d%*}} %{M} %{MM} %{MF*} %{MG} %{MP} %{MQ*} %{MT*} %{!E:%{!M:%{!MM:%{MD|MMD:%{o*:-MQ %*}}}}} %{remap} %{g3:-dD} %{H} %C %{D*&U*&A*} %{i*} %Z %i %{fmudflap:-D_MUDFLAP -include mf-runtime.h} %{fmudflapth:-D_MUDFLAP -D_MUDFLAPTH -include mf-runtime.h} %{E|M|MM:%W{o*}}
+
+*trad_capable_cpp:
+cc1 -E %{traditional|ftraditional|traditional-cpp:-traditional-cpp}
+
+*cc1:
+%(cc1_cpu) %{profile:-p}
+
+*cc1_options:
+%{pg:%{fomit-frame-pointer:%e-pg and -fomit-frame-pointer are incompatible}} %1 %{!Q:-quiet} -dumpbase %B %{d*} %{m*} %{a*} %{c|S:%{o*:-auxbase-strip %*}%{!o*:-auxbase %b}}%{!c:%{!S:-auxbase %b}} %{g*} %{O*} %{W*&pedantic*} %{w} %{std*&ansi&trigraphs} %{v:-version} %{pg:-p} %{p} %{f*} %{undef} %{Qn:-fno-ident} %{--help:--help} %{--target-help:--target-help} %{!fsyntax-only:%{S:%W{o*}%{!o*:-o %b.s}}} %{fsyntax-only:-o %j} %{-param*} %{fmudflap|fmudflapth:-fno-builtin -fno-merge-constants} %{coverage:-fprofile-arcs -ftest-coverage}
+
+*cc1plus:
+
+
+*link_gcc_c_sequence:
+%{static:--start-group} %G %L %{static:--end-group}%{!static:%G}
+
+*link_ssp:
+%{fstack-protector:}
+
+*endfile:
+
+
+*link:
+%{m64:-m elf_x86_64} %{!m64:-m elf_i386} %{shared:-shared}
+
+*lib:
+
+
+*mfwrap:
+ %{static: %{fmudflap|fmudflapth: --wrap=malloc --wrap=free --wrap=calloc --wrap=realloc --wrap=mmap --wrap=munmap --wrap=alloca} %{fmudflapth: --wrap=pthread_create}} %{fmudflap|fmudflapth: --wrap=main}
+
+*mflib:
+%{fmudflap|fmudflapth: -export-dynamic}
+
+*link_gomp:
+
+
+*libgcc:
+
+
+*startfile:
+
+
+*switches_need_spaces:
+
+
+*cross_compile:
+0
+
+*version:
+4.2.3
+
+*multilib:
+. !m64 !m32;64:../lib64 m64 !m32;32:../lib !m64 m32;
+
+*multilib_defaults:
+m32
+
+*multilib_extra:
+
+
+*multilib_matches:
+m64 m64;m32 m32;
+
+*multilib_exclusions:
+
+
+*multilib_options:
+m64/m32
+
+*linker:
+collect2
+
+*link_libgcc:
+%D
+
+*md_exec_prefix:
+
+
+*md_startfile_prefix:
+
+
+*md_startfile_prefix_1:
+
+
+*startfile_prefix_spec:
+
+
+*sysroot_spec:
+--sysroot=%R
+
+*sysroot_suffix_spec:
+
+
+*sysroot_hdrs_suffix_spec:
+
+
+*cc1_cpu:
+%{!mtune*: %{m386:mtune=i386 %n`-m386' is deprecated. Use `-march=i386' or `-mtune=i386' instead.
+} %{m486:-mtune=i486 %n`-m486' is deprecated. Use `-march=i486' or `-mtune=i486' instead.
+} %{mpentium:-mtune=pentium %n`-mpentium' is deprecated. Use `-march=pentium' or `-mtune=pentium' instead.
+} %{mpentiumpro:-mtune=pentiumpro %n`-mpentiumpro' is deprecated. Use `-march=pentiumpro' or `-mtune=pentiumpro' instead.
+} %{mcpu=*:-mtune=%* %n`-mcpu=' is deprecated. Use `-mtune=' or '-march=' instead.
+}} %<mcpu=* %{mintel-syntax:-masm=intel %n`-mintel-syntax' is deprecated. Use `-masm=intel' instead.
+} %{mno-intel-syntax:-masm=att %n`-mno-intel-syntax' is deprecated. Use `-masm=att' instead.
+}%{march=native:%<march=native %:local_cpu_detect(arch) %{!mtune=*:%<mtune=native %:local_cpu_detect(tune)}} %{mtune=native:%<mtune=native %:local_cpu_detect(tune)}
+
+*link_command:
+%{!fsyntax-only:%{!c:%{!M:%{!MM:%{!E:%{!S: %(linker) %l %{pie:-pie} %X %{o*} %{A} %{d} %{e*} %{m} %{N} %{n} %{r} %{s} %{t} %{u*} %{x} %{z} %{Z} %{!A:%{!nostdlib:%{!nostartfiles:%S}}} %{static:} %{L*} %(mfwrap) %o %{!nostdlib:%{!nodefaultlibs:-nostdlib}} %{!T*:-T./tool/gcc/x86/isaac.x} %{fopenmp:%:include(libgomp.spec)%(link_gomp)} %(mflib) %{fprofile-arcs|fprofile-generate|coverage:-lgcov} %{!nostdlib:%{!nodefaultlibs:%(link_ssp) %(link_gcc_c_sequence)}} %{!A:%{!nostdlib:%{!nostartfiles:%E}}} %{T*} }}}}}}
+
diff --git a/isaacos/tool/script/dosemu b/isaacos/tool/script/dosemu
new file mode 100755
index 0000000..d334c03
--- /dev/null
+++ b/isaacos/tool/script/dosemu
@@ -0,0 +1,13 @@
+
+if [ "$1" = "c" ]; then
+mount /mnt/isaacsmall
+cp $2 /mnt/isaacsmall/$3
+umount /mnt/isaacsmall
+fi
+if [ "$1" = "e" ]; then
+/usr/bin/qemu -boot c -m 256 -hda ~/svn/isaacos/trunk/isaacsmall.img -hdb ~/svn/isaacos/trunk/largeext2.img -net nic,vlan=0 -net user,vlan=0 -localtime &
+fi
+if [ "$1" = "" ]; then
+echo c for copy
+echo e qemu
+fi
diff --git a/isaacos/tool/script/hdtolive b/isaacos/tool/script/hdtolive
new file mode 100755
index 0000000..a5f5aff
--- /dev/null
+++ b/isaacos/tool/script/hdtolive
@@ -0,0 +1,11 @@
+#!/bin/bash
+
+cd ..
+# cp newlive.img iso3/ISAAC.IMG
+cp isaacsmall.img iso/ISAAC.IMG
+# cp isaaclive.img.good iso3/ISAAC.IMG
+mkisofs -R -V ISAACOSLIVE -b grldr -no-emul-boot -boot-load-size 4 -o isaac.iso iso
+# mkisofs -R -b grldr -no-emul-boot -boot-load-seg 0x1000 -boot-info-table -o isaac.iso iso3
+# mkisofs -R -b ISAAC.IMG -hard-disk-boot -boot-load-seg 0x7C0 -boot-info-table -o isaac.iso iso3
+/usr/bin/qemu -boot d -m 512 -hda ~/svn/isaacos/trunk/linux-0.2.img -cdrom ~/svn/isaacos/trunk/isaac.iso -net nic,vlan=0 -net user,vlan=0 -localtime -no-kqemu &
+cd isaacos
\ No newline at end of file
diff --git a/isaacos/x86/bootloader/boot.asm b/isaacos/x86/bootloader/boot.asm
new file mode 100755
index 0000000..d22d730
--- /dev/null
+++ b/isaacos/x86/bootloader/boot.asm
@@ -0,0 +1,271 @@
+ ;; ======================
+ ;; = MULTI-BOOT ISAAC =
+ ;; = Version 3.0 =
+ ;; = 01/06 =
+ ;; = By Sonntag Benoit =
+ ;; = (Size <= 510Bytes) =
+ ;; ======================
+
+ ;; Support : Hard-Disk FAT16,FAT32
+ ;; Floppy-Disk FAT12,FAT16
+
+ ;; Compilation :
+ ;; tasm /m2 boot.asm
+ ;; tlink /t boot
+.386P
+ ;; ======================
+ ;; = MACRO =
+ ;; ======================
+b equ <byte ptr>
+w equ <word ptr>
+d equ <dword ptr>
+
+ISABOOT segment use16
+ ORG 0100h
+assume cs:ISABOOT, es:ISABOOT, ss:ISABOOT, fs:ISABOOT
+
+START: ;; ======================
+ ;; = START JUMP =
+ ;; ======================
+ jmp debcom
+
+ ;; ======================
+ ;; = GENERIC DATA =
+ ;; ======================
+NomVer db 'ISAAC V1' ; Name & Version
+
+ ;; Bios parameter block (BPB)
+Oct_Sec dw 512 ; byte / Sector
+Sec_Clu db 8 ; Sectors / Cluster
+Sec_Res dw 32 ; Nbr Sectors Reserved
+Nb_FAT db 2 ; Nbr of FAT
+E_Rac dw 0 ; Nbr Root Entries
+Sec_Vol dw 0 ; Nbr of sectors in Volume (under 32MB)
+Desc_Supp db 0F8h ; Media Descriptor Support
+Sec_FAT dw 0 ; Nbr Sectors / FAT
+Sec_Pis dw 63 ; Nbr Sectors / Track
+Nb_tet dw 128 ; Nbr Heads
+Dis_mass dd 63 ; Hidden sectors.
+Sec_Vol2 dd 004E2241h ; Nb Sectors (over 32MB)
+
+ ;; ( > 32 MB)
+Sec_FAT2 dd 00001384h ; Nbr Sectors by FAT - 1
+ dw 00h ; Flags FAT
+ dw 00h ; Version FAT
+Root_Clu dd 02h ; Start Root Directory (en Cluster)
+ db 01h, 00h, 06h, 00h ; ???
+ db 12 dup (0)
+
+ ;; Drive information
+Drive db 80h ; BIOS Drive
+ db 00h ; Reserved (Unused)
+ db 29h ; 29h (Ext. boot signature)
+ dd 'SERI' ; Volume serial number
+ db 'NO NAME ' ; 'Volume Label'
+ db 'FAT32 ' ; 'File system'
+
+ ;; ======================
+ ;; = ISAAC DATA =
+ ;; ======================
+PosClu dd 10071 ; Position of first Cluster.
+PosRac dd 10087 ; Logical Sector of root directory.
+PosFAT dd 95 ; Position of FAT.
+
+ ;; Address packet for new int 13h
+Int13_Size db 10h
+Int13_Reserved db 0
+Int13_NbrSector dw 1
+Int13_Offset dw 7C00h
+Int13_Segment dw 0
+Int13_Sector dd 0
+Int13_SectorHigh dd 0
+
+ ;; String.
+Isaac db 'STARTUP SYS'
+Msdos db 'BOOTOLD SYS'
+Invit db 'Isaac: Press [ALT]',13,10,0
+;Invit db 'Isaac Boot',13,10,0
+Error db 'Error. Press key.',13,10,0
+ ;; ======================
+ ;; = CODE =
+ ;; ======================
+debcom:
+ xor ax,ax ; Init les Regs de Segment.
+ mov ss,ax
+ mov ds,ax
+ mov es,ax
+ mov sp,7C00h-2 ; Install la pile
+;******************** Copie du Code en 0000h:0600h **************************
+ mov di,0600h ; Destination du Code.
+ mov si,7C00h ; Source (=> Ici)
+ mov cx,256 ; 256 x 2 = 512 o a copier.
+ rep movsw ; Copie le Code...
+ db 0EAh ; Jump Far sur NewCode
+ dw 500h+offset NewCode
+ dw 0000h
+NewCode:
+;******************************* Invite *************************************
+ mov si,500h+offset Invit ; aff invite
+ call Afftxt
+
+ mov bp,500h+Offset Isaac ; pointe sur STARTUP.SYS (Par Defaut)
+
+ mov cx,150 ;
+Touch1: call LecKey ;
+ jnz Touch1 ;
+Touch2: call LecKey ;
+ jz Touch2 ;
+ loop Touch1
+
+ mov bp,500h+Offset Msdos ; pointe sur BOOTOLD.SYS
+stload:
+;************************** Lecture de la Racine ***************************
+ mov ebx,[500h+PosRac] ; FAT16
+ or w [500h+E_Rac],0
+ jnz LecSuite
+ mov ebx,[500h+Root_Clu]
+ jmp CluFAT32
+LecSuite:
+;*************************** Recherche du fichier **************************
+ mov dh,[500h+Sec_Clu]
+
+SecSui: ; Begin loop in sector.
+ push dx
+ call LecSec
+ mov di,7C00h
+
+Bcl: mov si,bp ; Begin loop Entry
+ mov cx,11
+ or b es:[di],0
+ jz MessErr
+ repe cmpsb
+ jz trouv
+ add di,21
+ add di,cx
+ test di,200h
+ jz Bcl ; End loop Entry
+
+ pop dx
+ inc ebx ; Next sector.
+ dec dh
+ jnz SecSui ; End loop in sector.
+
+ or w [500h+E_Rac],0
+ jnz LecSuite ; FAT 16 : Next Sector.
+ mov ebx,[500h+Root_Clu] ; FAT 32 : Next Cluster.
+ shl ebx,2 ; x 4 : Addr. du Cluster suivant.
+ mov di,bx
+ and di,01FFh ; => Offset ds le secteur.
+ shr ebx,9
+ add ebx,[500h+PosFAT] ; Cherche le bon Secteur.
+ call LecSec
+ mov ebx,es:[di+7C00h] ; Read new/next Cluster.
+CluFAT32:
+ call AddrClu
+ jmp LecSuite
+MessErr: ; 'pop ebx' => Pas utile !
+ mov si,500h+Offset Error ; Affiche Err.
+ call Afftxt
+ReBoot: xor ax,ax ; Attend une touche
+ int 16h
+ int 19h ; Reboot
+trouv: ; 'pop ebx' => Pas utile !
+ mov bx,es:[di+14h-11]
+ shl ebx,16
+ mov bx,es:[di+1Ah-11] ; Lecture du cluster.
+ call AddrClu
+ call LecSec
+
+ db 0EAh ; Jump Far sur Le fichier ...
+ dw 7C00h
+ dw 0000h
+;******************** Lecture Clavier *************************************
+LecKey: in al,60h
+ cmp al,56 ; Press [ALT]
+ jz stload
+ mov dx,03DAh ; Wait VBL
+ in al,dx
+ test al,8
+ Ret
+;******************** Aff txt *********************************************
+Afftxt:
+ mov ah,0Eh
+ xor bx,bx
+bclaff: lodsb
+ or al,al
+ jnz aff0
+ Ret
+aff0: int 10h
+ jmp bclaff
+;********************** Lecture Sector Logique ******************************
+; EBX : Secteur Logique.
+LecSec:
+ mov [500h+Int13_Sector],ebx ; Charge le N� Sector
+ mov si,500h+offset Int13_Size ; DS:SI=Addr. du Packet (Int 13h)
+ mov dl,b [500h+Drive] ; Drive.
+ test dl,80h
+ jz floppy
+ mov ah,42h ; Read Sectors O/I
+ int 13h
+ jc MessErr
+ Ret
+floppy:
+ push bx
+
+ mov ax,bx
+ mov bl,b [500h+Sec_Pis]
+ push bx
+ shl bl,1 ; Sec_Pis * Nb_Tet
+ div bl
+ mov ch,al ; Piste = sec / (Sec_Pis * Nb_Tet)
+
+ shr ax,8
+ pop bx
+ div bl
+ mov dh,al ; Head
+
+ mov cl,ah
+ inc cl ; Sector
+
+ mov ax,0201h
+ mov bx,7C00h
+ int 13h
+ jc MessErr
+
+ pop bx
+ Ret
+
+;********************* Cluster -> Secteur Logique ***************************
+; ebx : Cluster -> EBX : Secteur Logique
+AddrClu:
+ mov [500h+Root_Clu],ebx ; Save new cluster
+ movzx eax,b [500h+Sec_Clu] ; Nbr de secteur / Cluster.
+ mul ebx
+ mov ebx,eax
+ add ebx,[500h+PosClu] ; Calcul le bon Secteur.
+ Ret
+
+;********************* Display buffer 7C00h *********************************
+
+;print_buf: ;
+; push es ;
+; pusha ;
+; mov ax,0B800h ;
+; mov es,ax ;
+; mov si,07C00h ;
+; xor di,di ;
+; mov ah,15 ;
+; mov ecx,512 ;
+;next_car: ;
+; lodsb ;
+; stosw ;
+; loop next_car ;
+; popa ;
+; pop es ;
+; Ret
+
+ISABOOT ends
+end START
+
+
+
diff --git a/isaacos/x86/bootloader/boot.li b/isaacos/x86/bootloader/boot.li
new file mode 100755
index 0000000..7e7ee8e
--- /dev/null
+++ b/isaacos/x86/bootloader/boot.li
@@ -0,0 +1,193 @@
+///////////////////////////////////////////////////////////////////////////////
+// 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; 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 :=BOOT;
+
+
+ - bibliography:="http://www.lisaac.org";
+ - author :="Sonntag Benoit (benoit.sonntag at lisaac.org)";
+ - comment :="Boot sector.";
+
+Section Inherit
+
+ - parent_object:OBJECT := OBJECT;
+
+Section Mapping
+
+ + jump_0:UINTEGER_8;
+ + jump_1:UINTEGER_16;
+
+ // OEM
+ + oem_00:CHARACTER;
+ + oem_01:CHARACTER;
+ + oem_02:CHARACTER;
+ + oem_03:CHARACTER;
+ + oem_04:CHARACTER;
+ + oem_05:CHARACTER;
+ + oem_06:CHARACTER;
+ + oem_07:CHARACTER;
+
+ // Bios parameter block (BPB)
+ + bytes_per_sector:UINTEGER_16;
+ + sectors_per_cluster:UINTEGER_8;
+ + sectors_reserved:UINTEGER_16;
+ + nb_fat:UINTEGER_8;
+ + nb_root_entries:UINTEGER_16;
+ + nb_sectors:UINTEGER_16;
+ + descriptor:UINTEGER_8;
+ + sectors_per_fat:UINTEGER_16;
+ + sectors_per_track:UINTEGER_16;
+ + nb_head:UINTEGER_16;
+ + hidden_sectors:UINTEGER_32
+ + nb_sectors_big:UINTEGER_32
+
+ // ( Fat 32bits )
+ + sectors_per_fat32:UINTEGER_32 // Nbr Secteur par FAT - 1
+ + flags_fat:UINTEGER_16;
+ + version_fat:UINTEGER_16;
+ + cluster_start_root:UINTEGER_32
+ + reserved_00:UINTEGER_32
+ + reserved_01:UINTEGER_32
+ + reserved_02:UINTEGER_32
+ + reserved_03:UINTEGER_32
+
+ // Drive information
+ + bios_drive:UINTEGER_8;
+ + reserved_04:UINTEGER_8;
+ + ext_boot_signature:UINTEGER_8; // 29h
+ + serial_number:UINTEGER_32
+
+ + vol_label_00:CHARACTER;
+ + vol_label_01:CHARACTER;
+ + vol_label_02:CHARACTER;
+ + vol_label_03:CHARACTER;
+ + vol_label_04:CHARACTER;
+ + vol_label_05:CHARACTER;
+ + vol_label_06:CHARACTER;
+ + vol_label_07:CHARACTER;
+ + vol_label_08:CHARACTER;
+ + vol_label_09:CHARACTER;
+ + vol_label_10:CHARACTER;
+
+ + fs_label_00:CHARACTER;
+ + fs_label_01:CHARACTER;
+ + fs_label_02:CHARACTER;
+ + fs_label_03:CHARACTER;
+ + fs_label_04:CHARACTER;
+ + fs_label_05:CHARACTER;
+ + fs_label_06:CHARACTER;
+ + fs_label_07:CHARACTER;
+
+ // Isaac data
+
+ + sector_cluster:UINTEGER_32 // First cluster position.
+ + sector_root :UINTEGER_32 // Root position.
+ + sector_fat :UINTEGER_32 // FAT position.
+ + cluster :UINTEGER_32 // Cluster current.
+
+Section Public
+
+ - is_fat32:BOOLEAN <- (ext_boot_signature=29h);
+
+ - put_isaac_data begin_partition:UINTEGER_32drive drv:UINTEGER_8 <-
+ // Static Compute `sector_cluster', `sector_root' and `sector_fat'.
+ (
+ bios_drive:=drv;
+ sector_fat:=begin_partition+sectors_reserved;
+
+ (is_fat32).if {
+ sector_root:=sector_fat+sectors_per_fat32 * nb_fat;
+ } else {
+ sector_root:=sector_fat+sectors_per_fat * nb_fat;
+ };
+
+ sector_cluster:=sector_root+(nb_root_entries>>4)-(sectors_per_cluster*2);
+
+ "\nBegin Part\t: ".print; begin_partition.print;
+ "\nSector FAT\t: ".print; sector_fat.print;
+ "\nSector Root\t: ".print; sector_root.print;
+ "\nSector cluster\t: ".print; sector_cluster.print;
+ '\n'.print;
+ );
+
+ - display_all <-
+ (
+
+ "\nOEM\t\t: ".print;
+ oem_00.print;
+ oem_01.print;
+ oem_02.print;
+ oem_03.print;
+ oem_04.print;
+ oem_05.print;
+ oem_06.print;
+ oem_07.print;
+
+ "\nBios parameter block (BPB):".print;
+ "\n Bytes per sector\t: ".print; bytes_per_sector.print;
+ "\n Sectors per cluster\t: ".print; sectors_per_cluster.print;
+ "\n Sectors reserved\t: ".print; sectors_reserved.print;
+ "\n Number FAT\t\t: ".print; nb_fat.print;
+ "\n Number root entries\t: ".print; nb_root_entries.print;
+ "\n Number sectors\t: ".print; nb_sectors.print;
+ "\n Descriptor media\t: ".print; descriptor.to_hexadecimal.print; 'h'.print;
+ "\n Sectors per FAT\t: ".print; sectors_per_fat.print;
+ "\n Sectors per track\t: ".print; sectors_per_track.print;
+ "\n Number head\t\t: ".print; nb_head.print;
+ "\n Hidden sectors\t: ".print; hidden_sectors.print;
+ "\n Number sectors big\t: ".print; nb_sectors_big.print;
+ " (".print; (nb_sectors_big>>11).print; " MB)".print;
+
+ (is_fat32).if {
+ "\nFAT 32 bits:".print;
+ "\n Sectors per FAT\t: ".print; (sectors_per_fat32+1).print;
+ "\n Flags FAT\t\t: ".print; flags_fat.to_hexadecimal.print; 'h'.print;
+ "\n Version FAT\t\t: ".print; version_fat.print;
+ "\n Cluster start root\t: ".print; cluster_start_root.print;
+
+ "\nDrive information:".print;
+ "\n Bios drive\t\t: ".print; bios_drive.to_hexadecimal.print; 'h'.print;
+ "\n Ext. boot signature\t: ".print; ext_boot_signature.to_hexadecimal.print; 'h'.print;
+ "\n Serial number\t\t: ".print; serial_number.to_hexadecimal.print; 'h'.print;
+
+ "\n Volume label\t\t: ".print;
+ vol_label_00.print;
+ vol_label_01.print;
+ vol_label_02.print;
+ vol_label_03.print;
+ vol_label_04.print;
+ vol_label_05.print;
+ vol_label_06.print;
+ vol_label_07.print;
+ vol_label_08.print;
+ vol_label_09.print;
+ vol_label_10.print;
+
+ "\n File system\t\t: ".print;
+ fs_label_00.print;
+ fs_label_01.print;
+ fs_label_02.print;
+ fs_label_03.print;
+ fs_label_04.print;
+ fs_label_05.print;
+ fs_label_06.print;
+ fs_label_07.print;
+ };
+ '\n'.print;
+ );
+
+
diff --git a/isaacos/x86/bootloader/install.exe b/isaacos/x86/bootloader/install.exe
new file mode 100755
index 0000000..bb00b5a
Binary files /dev/null and b/isaacos/x86/bootloader/install.exe differ
diff --git a/isaacos/x86/bootloader/install.li b/isaacos/x86/bootloader/install.li
new file mode 100755
index 0000000..9c20379
--- /dev/null
+++ b/isaacos/x86/bootloader/install.li
@@ -0,0 +1,423 @@
+///////////////////////////////////////////////////////////////////////////////
+// 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; 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 := INSTALL;
+
+ - category := MACRO;
+
+ - bibliography := "http://www.lisaac.org";
+ - author := "Sonntag Benoit (benoit.sonntag at lisaac.org)";
+ - comment := "Isaac Install for x86 architecture.";
+
+ - external := `#include <bios.h>`;
+
+Section Inherit
+
+ - parent_object:OBJECT := OBJECT;
+
+Section Private
+ //
+ // Independance File System
+ //
+
+ - open_read n:ABSTRACT_STRING :POINTER <-
+ ( + buf:NATIVE_ARRAY(CHARACTER);
+ string_tmp.copy n;
+ buf := string_tmp.to_external;
+ `fopen((char*)@buf,"rb")`:(POINTER)
+ );
+
+ - open_write n:ABSTRACT_STRING :POINTER <-
+ ( + buf:NATIVE_ARRAY(CHARACTER);
+ string_tmp.copy n;
+ buf := string_tmp.to_external;
+ `fopen((char*)@buf,"wb")`:(POINTER)
+ );
+
+ - read f:POINTER in buf:FAST_ARRAY(UINTEGER_8) size sz:INTEGER :INTEGER <-
+ ( + ptr:NATIVE_ARRAY(UINTEGER_8);
+ + result:INTEGER;
+ ptr := buf.storage;
+ result := `fread((void *)(@ptr),(size_t)(1), (size_t)(@sz),(FILE*)(@f))`:(INTEGER);
+ result
+ );
+
+ - write f:POINTER with buf:FAST_ARRAY(UINTEGER_8) size sz:INTEGER :INTEGER <-
+ ( + ptr:NATIVE_ARRAY(UINTEGER_8);
+ + result:INTEGER;
+ ptr := buf.storage;
+ result := `fwrite((void *)(@ptr),(size_t)(1), (size_t)(@sz),(FILE*)(@f))`:(INTEGER);
+ result
+ );
+
+ - close p:POINTER <- `fclose((FILE*)(@p))`;
+
+ - file_size p:POINTER :INTEGER <-
+ ( + result:INTEGER;
+ `fseek((FILE*)(@p),0,SEEK_END)`;
+ result := `ftell((FILE *)@p)`:INTEGER;
+ `fseek((FILE*)(@p),0,SEEK_SET)`;
+ result
+ );
+
+ - make_file new_path:STRING :BOOLEAN <-
+ ( + p:NATIVE_ARRAY(CHARACTER);
+ + stream:POINTER;
+ + result:BOOLEAN;
+
+ p := new_path.to_external;
+ stream := `fopen((char*)@p,"w+b")`:POINTER;
+ (result := (stream != NULL)).if {
+ close stream;
+ };
+ result
+ );
+
+ //
+ // Temp. variable.
+ //
+
+ - string_tmp:STRING := STRING.create 255;
+
+ //
+ // Isaac Install Information.
+ //
+
+ + isaac_drive:UINTEGER_8; // 0x80:Hard Disk 0x00:Floppy Disk.
+
+ + isaac_partition:INTEGER;
+
+ + isaac_head:UINTEGER_8;
+ + isaac_cylinder:UINTEGER_16;
+ + isaac_sector:UINTEGER_16;
+ + isaac_begin_partition:UINTEGER_32
+
+ //
+ // Generic manager.
+ //
+
+ - buffer :FAST_ARRAY(UINTEGER_8);
+ - buffer2:FAST_ARRAY(UINTEGER_8);
+
+ - title str:STRING_CONSTANT <-
+ (
+ "\n* ".print;
+ str.print;
+ "\n==".print;
+ 1.to (str.count) do { j:INTEGER;
+ '='.print;
+ };
+ '\n'.print;
+ );
+
+ - get_choice:BOOLEAN <-
+ ( + choice:CHARACTER;
+
+ " (Y/N) ? ".print;
+ {
+ choice:=IO.read_character.to_lower;
+ }.do_while {(choice!='n') && {choice!='y'}};
+
+ (choice='y')
+ );
+
+ - choice txt:ABSTRACT_STRING from low:CHARACTER to up:CHARACTER :CHARACTER <-
+ ( + choice:CHARACTER;
+
+ txt.print;
+ {
+ choice:=IO.read_character;
+ }.do_until {choice.in_range low to up};
+ choice
+ );
+
+ - display_sector buf:NATIVE_ARRAY(UINTEGER_8) <-
+ ( + char:CHARACTER;
+
+ "Display buffer : \n".print;
+ 0.to 511 do { n:INTEGER;
+ char:=buf.item n.to_character;
+ (char>=' ').if {
+ char.print;
+ } else {
+ '.'.print;
+ };
+ };
+ '\n'.print;
+ );
+
+ //
+ // Read / Write BIOS
+ //
+
+ - read_sector (head:UINTEGER_8,cylinder,sector:UINTEGER_16) in buf:FAST_ARRAY(UINTEGER_8) <-
+ ( + drive:UINTEGER_8;
+ + storage:NATIVE_ARRAY(UINTEGER_8);
+
+ drive := isaac_drive;
+ storage := buf.storage;
+ `biosdisk(0x02, at drive, at head, at cylinder, at sector,1, at storage)`:BOOLEAN(TRUE,FALSE).if {
+ crash_with_message "Error read bios disk 13h.\n";
+ };
+ );
+
+ - write_sector (head:UINTEGER_8,cylinder,sector:UINTEGER_16) with buf:FAST_ARRAY(UINTEGER_8) <-
+ ( + drive:UINTEGER_8;
+ + storage:NATIVE_ARRAY(UINTEGER_8);
+
+ drive := isaac_drive;
+ storage := buf.storage;
+ `biosdisk(0x03, at drive, at head, at cylinder, at sector,1, at storage)`:BOOLEAN(TRUE,FALSE).if {
+ crash_with_message "Error write bios disk 13h.\n";
+ };
+ );
+
+ //
+ // Partition Info.
+ //
+
+ + partition_list:LINKED_LIST(MBR);
+
+ - sub_read_partition sec:UINTEGER_64 <-
+ ( + part:MBR;
+ + buf:NATIVE_ARRAY(UINTEGER_8);
+
+ INT13H.read buffer sector sec;
+
+ // Load partition.
+ 1BEh.to 1EEh by 16 do { n:INTEGER;
+ buf:=buffer.storage;
+ part:=`(void *)(&@buf[@n])`:MBR;
+ ((part.type = 05h) || {part.type = 0Fh}).if {
+ // Partition Etendue.
+ //"Partition Etendu:\n".print;
+ //part.print;
+ //IO.read_character;
+ sub_read_partition (sec+part.mbr_first_sector);
+ }.elseif {(part.type != 0) && {part.type != 0FFh}} then {
+ // New Partition.
+ part.add_base (sec.to_uinteger);
+ partition_list.add_last (part.clone);
+ };
+ };
+ );
+
+ - choice_partition <-
+ ( + part:MBR;
+
+ partition_list:=LINKED_LIST(MBR).create;
+ sub_read_partition 0;
+
+ (partition_list.lower).to (partition_list.upper) do { n:INTEGER;
+ "Partition #".print;
+ n.print;
+ ": ".print;
+ partition_list.item n.print_small;
+ };
+
+ isaac_partition := choice "Isaac partition ? " from '1' to ((partition_list.upper).decimal_digit) .decimal_value;
+
+ "Isaac partition #".print;
+ isaac_partition.print;
+
+ (! get_choice).if {
+ crash_with_message "Stop install !\n";
+ };
+
+ part:=partition_list.item isaac_partition;
+ isaac_head := part.head_begin;
+ isaac_cylinder := part.cylinder_begin;
+ isaac_sector := part.sector_begin;
+ isaac_begin_partition:= part.mbr_first_sector;
+ );
+
+ //
+ // Sector BOOT Manager.
+ //
+
+ - boot_manager <-
+ ( + choice:CHARACTER;
+ + boot:BOOT;
+ + file_w,file_r:POINTER;
+ + name:ABSTRACT_STRING;
+ + sz:INTEGER;
+
+ choice := choice
+ "1. Save actual boot in 'bootold.sys'. \n\
+ \2. Install new Isaac boot. \n\
+ \3. Restore 'bootold.sys'. \n\
+ \Choice: " from '1' to '3';
+ choice
+ .when '1' then {
+ //
+ // Save old Boot.
+ //
+ (isaac_drive = 80h).if {
+ INT13H.read buffer sector isaac_begin_partition;
+ } else {
+ read_sector (isaac_head,isaac_cylinder,isaac_sector) in buffer;
+ };
+ boot := BOOT.force_conversion (buffer.storage);
+ boot.display_all;
+ // Saving old boot sector.
+ (isaac_drive=080h).if {
+ name:="C:\\bootold.sys";
+ } else {
+ name:="A:\\bootold.sys";
+ };
+ "\nThe old boot sector is saving in `bootold.sys' file.\n\
+ \WARNING : Not remove this file, please !\n".print;
+ "\nSave this boot in `".print;
+ name.print;
+ "' file".print;
+ (get_choice).if {
+ "Writting...\n".print;
+ file_w := open_write name;
+ (file_w = NULL).if {
+ string_tmp.copy "Error : Not open file `";
+ string_tmp.append name;
+ string_tmp.append "'.\n";
+ crash_with_message string_tmp;
+ };
+ sz := write file_w with buffer size 512;
+ (sz != 512).if {
+ string_tmp.copy "Error : Write `";
+ sz.append_in string_tmp;
+ string_tmp.append " bytes only !\n";
+ crash_with_message string_tmp;
+ };
+ close file_w;
+ };
+ }
+ .when '2' then {
+ //
+ // Isaac Install Boot.
+ //
+ (isaac_drive=080h).if {
+ INT13H.read buffer sector isaac_begin_partition;
+ } else {
+ read_sector (isaac_head,isaac_cylinder,isaac_sector) in buffer;
+ };
+ file_r := open_read "boot.com";
+ (file_r = NULL).if {
+ crash_with_message "Error : file `boot.com' not found.\n";
+ };
+
+ buffer2.clear;
+ {buffer2.count < 512}.while_do { buffer2.add_last 0; };
+ read file_r in buffer2 size (file_size file_r);
+ close file_r;
+
+ // Copy old_boot -> new_boot.
+ 3.to 89 do { j:INTEGER;
+ buffer2.put (buffer.item j) to j;
+ };
+ // Write Boot signature.
+ buffer2.put 055h to 510;
+ buffer2.put 0AAh to 511;
+
+ // Calcul isaac data.
+ boot:=BOOT.force_conversion (buffer2.storage);
+ boot.put_isaac_data isaac_begin_partition drive isaac_drive;
+
+ "New boot Isaac :\n".print;
+ boot.display_all;
+
+ // Write new Boot.
+ "Write new boot Isaac ".print;
+ (get_choice).if {
+ "Writting...\n".print;
+ (isaac_drive=080h).if {
+ INT13H.write buffer2 sector isaac_begin_partition;
+ } else {
+ write_sector (isaac_head,isaac_cylinder,isaac_sector) with buffer2;
+ };
+ } else {
+ crash_with_message "Stop install !\n";
+ };
+ }
+ .when '3' then {
+ //
+ // Install Old Boot.
+ //
+ file_r := open_read "bootold.sys";
+ (file_r = NULL).if {
+ string_tmp.copy "Error : file `";
+ string_tmp.append name;
+ string_tmp.append "' not found.\n";
+ crash_with_message string_tmp;
+ };
+ buffer2.clear;
+ {buffer2.count < 512}.while_do { buffer2.add_last 0; };
+ read file_r in buffer2 size 512;
+ close file_r;
+
+ // Write new Boot.
+ "Write old boot ".print;
+ (get_choice).if {
+ "Writting...\n".print;
+ (isaac_drive=080h).if {
+ INT13H.write buffer2 sector isaac_begin_partition;
+ } else {
+ write_sector (isaac_head,isaac_cylinder,isaac_sector) with buffer2;
+ };
+ } else {
+ crash_with_message "Stop install !\n";
+ };
+ };
+
+ );
+
+Section Public
+
+ - main <-
+ ( + choice:CHARACTER;
+
+ buffer :=FAST_ARRAY(UINTEGER_8).create 512;
+ buffer2:=FAST_ARRAY(UINTEGER_8).create 512;
+
+ "\t\t=====================================\n\
+ \\t\t= Isaac install for x86 (01/2006) =\n\
+ \\t\t=====================================\n\n".print;
+
+ title "Choice drive.";
+ choice := choice
+ "1. Hard Disk.\n\
+ \2. Floppy Disk.\n\
+ \Choice: " from '1' to '2';
+
+ (choice='1').if {
+ title "Partition manager.";
+ isaac_drive:=80h;
+ choice_partition;
+ } else {
+ isaac_drive:=00h;
+ isaac_head:=0;
+ isaac_cylinder:=0;
+ isaac_sector:=1;
+ isaac_begin_partition:=0;
+ };
+ title "Boot manager.";
+ boot_manager;
+
+ "Success installation !\n".print;
+ );
+
+
+
+
+
+
diff --git a/isaacos/x86/bootloader/int13h.li b/isaacos/x86/bootloader/int13h.li
new file mode 100755
index 0000000..e7779d3
--- /dev/null
+++ b/isaacos/x86/bootloader/int13h.li
@@ -0,0 +1,133 @@
+///////////////////////////////////////////////////////////////////////////////
+// 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; 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 := INT13H;
+
+
+
+ - bibliography:= "http://www.lisaac.org";
+
+ - author := "Benoit Sonntag (bsonntag at loria.fr), Jerome Boutet (boutet at loria.fr)";
+
+ - comment := "Address packet for in13h";
+
+ - external :=
+`
+#include <dos.h>
+#include <conio.h>
+#include <dpmi.h>
+`;
+
+Section Inherit
+
+ - parent_object:OBJECT := OBJECT;
+
+Section Mapping
+
+ + packet_size:USMALLINT;
+ + reserved:USMALLINT;
+
+ + nb_sector:USHORTINT;
+
+ + offset_buffer :USHORTINT;
+ + segment_buffer:USHORTINT;
+
+ + sector_lba:ULONGINT;
+
+Section Public
+
+ - read buf:FAST_ARRAY(USMALLINT) sector sec:ULONGINT :BOOLEAN <-
+ ( + buffer_adress:USHORTINT;
+ + packet_adress:USHORTINT;
+ + storage:NATIVE_ARRAY(USMALLINT);
+ + result:USHORTINT;
+
+ storage := buf.storage;
+ `{
+ int (buffer_selector1,buffer_selector2);
+ __dpmi_regs registres;`;
+
+ buffer_adress := `__dpmi_allocate_dos_memory(32,&buffer_selector1)`:USHORTINT; // Alloc DOS 512 bytes
+ packet_adress := `__dpmi_allocate_dos_memory( 1,&buffer_selector2)`:USHORTINT; // Alloc DOS 16 bytes
+
+ packet_size := 10h;
+ reserved := 0;
+ nb_sector := 1;
+ offset_buffer := 0;
+ segment_buffer := buffer_adress;
+ sector_lba := sec;
+
+ `dosmemput(@Self,16, at packet_adress*16)`;
+
+ `registres.x.ax=0x4200`;
+ `registres.x.dx=0x0080`;
+ `registres.x.ds=@packet_adress`;
+ `registres.x.si=0`;
+ `__dpmi_int(0x13,®istres)`;
+
+ result := `registres.x.ax`:USHORTINT;
+
+ `dosmemget(@buffer_adress*16,512, at storage)`;
+
+ `__dpmi_free_dos_memory(buffer_selector1)`;
+ `__dpmi_free_dos_memory(buffer_selector2)`;
+ `}`;
+ result = 0
+ );
+
+ - write buf:FAST_ARRAY(USMALLINT) sector sec:ULONGINT :BOOLEAN <-
+ ( + buffer_adress:USHORTINT;
+ + packet_adress:USHORTINT;
+ + storage:NATIVE_ARRAY(USMALLINT);
+ + result:USHORTINT;
+
+ storage := buf.storage;
+ `{
+ int (buffer_selector1,buffer_selector2);
+ __dpmi_regs registres;`;
+
+ buffer_adress := `__dpmi_allocate_dos_memory(32,&buffer_selector1)`:USHORTINT; // Alloc DOS 512 bytes
+ packet_adress := `__dpmi_allocate_dos_memory( 1,&buffer_selector2)`:USHORTINT; // Alloc DOS 16 bytes
+
+ packet_size := 10h;
+ reserved := 0;
+ nb_sector := 1;
+ offset_buffer := 0;
+ segment_buffer := buffer_adress;
+ sector_lba := sec;
+
+ `dosmemput(@storage,512, at buffer_adress*16)`;
+ `dosmemput(@Self,16, at packet_adress*16)`;
+
+ `registres.x.ax=0x4300`;
+ `registres.x.dx=0x0080`;
+ `registres.x.ds=@packet_adress`;
+ `registres.x.si=0`;
+ `__dpmi_int(0x13,®istres)`;
+
+ result := `registres.x.ax`:USHORTINT;
+
+ //`dosmemget(@buffer_adress*16,512, at storage)`;
+
+ `__dpmi_free_dos_memory(buffer_selector1)`;
+ `__dpmi_free_dos_memory(buffer_selector2)`;
+ `}`;
+ result = 0
+ );
+
+
+
diff --git a/isaacos/x86/bootloader/mbr.li b/isaacos/x86/bootloader/mbr.li
new file mode 100755
index 0000000..4d132d0
--- /dev/null
+++ b/isaacos/x86/bootloader/mbr.li
@@ -0,0 +1,404 @@
+///////////////////////////////////////////////////////////////////////////////
+// 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; 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 := MBR;
+
+
+ - bibliography:= "http://www.lisaac.org";
+
+ - author := "Benoit Sonntag (benoit.sonntag at lisaac.org), Jerome Boutet (pisteur at free.fr)";
+
+ - comment := "Master Boot Record";
+
+Section Inherit
+
+ - parent_object:OBJECT := OBJECT;
+
+Section Mapping
+
+ + flag_boot:UINTEGER_8;
+
+ + head_begin:UINTEGER_8;
+
+ + cylinder_sector_begin:UINTEGER_16;
+
+ + type:UINTEGER_8;
+
+ + head_end:UINTEGER_8;
+
+ + cylinder_sector_end:UINTEGER_16;
+
+ + mbr_first_sector:UINTEGER_32;
+
+ + size:UINTEGER_32;
+
+Section Private
+
+ - cylinder n:UINTEGER_16 :UINTEGER_16 <- ((n>>8) | ((n & 0C0h)<<2));
+
+ - sector n:UINTEGER_16 :UINTEGER_16 <- (n & 3Fh);
+
+ - print_type <-
+ (
+ (type)
+ .when 000h then { "Not found\n".print; }
+ .when 001h then { "FAT12 (< 10 M)\n".print; }
+ .when 002h then { "XENIX root\n".print; }
+ .when 003h then { "XENIX /usr\n".print; }
+ .when 004h then { "FAT16 (< 32 M)\n".print; }
+ .when 005h then { "Etendue\n".print; }
+ .when 006h then { "FAT16 (>32 M et <2 G)\n".print; }
+ .when 007h then { "OS/2, HPFS, NTFS, QNX 2.x\n".print; }
+ .when 008h then { "SplitDrive QNX 1.x et 2.x\n".print; }
+ .when 009h then { "AIX data, Coherent FileSystem\n".print; }
+ .when 00Ah then { "OS/2 boot manager, Coherent swap, OPUS\n".print; }
+ .when 00Bh then { "FAT32(>2 G et <2047G)\n".print; }
+ .when 00Ch then { "FAT32(>2 G et <2047G) LBA\n".print; }
+ .when 00Dh then { "non attribue\n".print; }
+ .when 00Eh then { "FAT16 (>32 M et <2 G) LBA\n".print; }
+ .when 00Fh then { "Etendue\"x\" = Etendue + LBA\n".print; }
+ .when 010h then { "OPUS\n".print; }
+ .when 011h then { "FAT12 cachee\n".print; }
+ .when 012h then { "Diagnostics COMPAQ\n".print; }
+ .when 013h then { "non attribue\n".print; }
+ .when 014h then { "FAT16 (<32 M) cachee\n".print; }
+ .when 015h then { "Free type...\n".print; }
+ .when 016h then { "FAT16 (>32 M) cachee\n".print; }
+ .when 017h then { "HPFS - NTFS cachee\n".print; }
+ .when 018h then { "Windows swapfile\n".print; }
+ .when 019h then { "Willowtech Photon coS \n".print; }
+ .when 01Ah then { "Free type...\n".print; }
+ .when 01Bh then { "FAT32 cachee\n".print; }
+ .when 01Ch then { "FAT32x cachee\n".print; }
+ .when 01Dh then { "Free type...\n".print; }
+ .when 01Eh then { "FAT16x cachee\n".print; }
+ .when 01Fh then { "Free type...\n".print; }
+ .when 020h then { "Willowsoft OFS1\n".print; }
+ .when 021h then { "Oxygen File System\n".print; }
+ .when 022h then { "Oxygen Extended\n".print; }
+ .when 023h then { "reserved\n".print; }
+ .when 024h then { "NEC DOS 3.x\n".print; }
+ .when 025h then { "Free type...\n".print; }
+ .when 026h then { "reserved\n".print; }
+ .when 027h then { "Free type...\n".print; }
+ .when 028h then { "Free type...\n".print; }
+ .when 029h then { "Free type...\n".print; }
+ .when 02Ah then { "Free type...\n".print; }
+ .when 02Bh then { "Free type...\n".print; }
+ .when 02Ch then { "Free type...\n".print; }
+ .when 02Dh then { "Free type...\n".print; }
+ .when 02Eh then { "Free type...\n".print; }
+ .when 02Fh then { "Free type...\n".print; }
+ .when 030h then { "Free type...\n".print; }
+ .when 031h then { "reserved\n".print; }
+ .when 032h then { "Free type...\n".print; }
+ .when 033h then { "reserved\n".print; }
+ .when 034h then { "reserved\n".print; }
+ .when 035h then { "Journaling FS OS/2 ou eCS\n".print; }
+ .when 036h then { "reserved\n".print; }
+ .when 037h then { "Free type...\n".print; }
+ .when 038h then { "THEOS ver 3.2 2 Go\n".print; }
+ .when 039h then { "Plan 9, THEOS ver 4 spanned\n".print; }
+ .when 03Ah then { "THEOS ver 4 4Go\n".print; }
+ .when 03Bh then { "THEOS ver 4 etendue\n".print; }
+ .when 03Ch then { "PartitionMagic recovery\n".print; }
+ .when 03Dh then { "Free type...\n".print; }
+ .when 03Eh then { "Free type...\n".print; }
+ .when 03Fh then { "Free type...\n".print; }
+ .when 040h then { "VENIX\n".print; }
+ .when 041h then { "MINIX + DRDOS Personal RISC Boot Power PC Reference Platform\n".print; }
+ .when 042h then { "Linux swap + DRDOS SFS Windows 2000\n".print; }
+ .when 043h then { "Linux native + DRDOS\n".print; }
+ .when 044h then { "Free type...\n".print; }
+ .when 045h then { "Boot US boot manager, EUMEL/Elan\n".print; }
+ .when 046h then { "EUMEL/Elan\n".print; }
+ .when 047h then { "EUMEL/Elan\n".print; }
+ .when 048h then { "EUMEL/Elan\n".print; }
+ .when 049h then { "Free type...\n".print; }
+ .when 04Ah then { "Free type...\n".print; }
+ .when 04Bh then { "Free type...\n".print; }
+ .when 04Ch then { "Free type...\n".print; }
+ .when 04Dh then { "QNX4.x\n".print; }
+ .when 04Eh then { "QNX4.x 2�me partition\n".print; }
+ .when 04Fh then { "QNX4.x 3�me partition, Oberon\n".print; }
+ .when 050h then { "OnTrack Disk Manager, Lynx RTOS, Oberon native\n".print; }
+ .when 051h then { "OnTrack Disk Manager RW Novell\n".print; }
+ .when 052h then { "Microport CP/M\n".print; }
+ .when 053h then { "Disk Manager 6.0, Aux3\n".print; }
+ .when 054h then { "Disk Manager 6.0 Dynamic Drive Overlay\n".print; }
+ .when 055h then { "EZ-Drive\n".print; }
+ .when 056h then { "Golden Bow, EZ-BIOS\n".print; }
+ .when 057h then { "DrivePro VNDI\n".print; }
+ .when 058h then { "Free type...\n".print; }
+ .when 059h then { "Free type...\n".print; }
+ .when 05Ah then { "Free type...\n".print; }
+ .when 05Bh then { "Free type...\n".print; }
+ .when 05Ch then { "Priam EDisk\n".print; }
+ .when 05Dh then { "Free type...\n".print; }
+ .when 05Eh then { "Free type...\n".print; }
+ .when 05Fh then { "Free type...\n".print; }
+ .when 060h then { "Free type...\n".print; }
+ .when 061h then { "SpeedStor\n".print; }
+ .when 062h then { "Free type...\n".print; }
+ .when 063h then { "Unix System V GNU HURD\n".print; }
+ .when 064h then { "Novell 286 PC-ARMOUR\n".print; }
+ .when 065h then { "Novell 386\n".print; }
+ .when 066h then { "Novell Netware SMS\n".print; }
+ .when 067h then { "Novell\n".print; }
+ .when 068h then { "Novell\n".print; }
+ .when 069h then { "Novell Netware NSS\n".print; }
+ .when 06Ah then { "Free type...\n".print; }
+ .when 06Bh then { "Free type... \n".print; }
+ .when 06Ch then { "Free type...\n".print; }
+ .when 06Dh then { "Free type... \n".print; }
+ .when 06Eh then { "Free type... \n".print; }
+ .when 06Fh then { "Free type...\n".print; }
+ .when 070h then { "DiskSecure Multi-Boot\n".print; }
+ .when 071h then { "reserved\n".print; }
+ .when 072h then { "reserved\n".print; }
+ .when 073h then { "reserved\n".print; }
+ .when 074h then { "Scramdisk\n".print; }
+ .when 075h then { "IBM PC/IX\n".print; }
+ .when 076h then { "reserved\n".print; }
+ .when 077h then { "VNDI\n".print; }
+ .when 078h then { "XOSL Bootloader\n".print; }
+ .when 079h then { "Free type...\n".print; }
+ .when 07Ah then { "Free type...\n".print; }
+ .when 07Bh then { "Free type...\n".print; }
+ .when 07Ch then { "Free type...\n".print; }
+ .when 07Dh then { "Free type...\n".print; }
+ .when 07Eh then { "Free type...\n".print; }
+ .when 07Fh then { "Free type...\n".print; }
+ .when 080h then { "MINIX (->1.4a)\n".print; }
+ .when 081h then { "MINIX (1.4b ->), Mitac Disk Manager\n".print; }
+ .when 082h then { "Solaris X86, LINUX swap, Prime\n".print; }
+ .when 083h then { "LINUX native (ext2fs)\n".print; }
+ .when 084h then { "OS/2 cachee, Hibernation\n".print; }
+ .when 085h then { "Linux etendue\n".print; }
+ .when 086h then { "agr�gat FAT (NT)\n".print; }
+ .when 087h then { "agr�gat NTFS (NT)\n".print; }
+ .when 088h then { "Free type...\n".print; }
+ .when 089h then { "Free type...\n".print; }
+ .when 08Ah then { "Linux Kernel\n".print; }
+ .when 08Bh then { "FAT32 miroir\n".print; }
+ .when 08Ch then { "FAT32x Miroir\n".print; }
+ .when 08Dh then { "FAT12 cachee (FreeFDISK)\n".print; }
+ .when 08Eh then { "Linux Logical Volume Manager\n".print; }
+ .when 08Fh then { "Free type...\n".print; }
+ .when 090h then { "FAT16 cachee (FreeFDISK)\n".print; }
+ .when 091h then { "Etendue cachee (FreeFDISK)\n".print; }
+ .when 092h then { "FAT16 cachee (FreeFDISK)\n".print; }
+ .when 093h then { "Amoeba, Linux native cachee\n".print; }
+ .when 094h then { "Amoeba bad block table\n".print; }
+ .when 095h then { "MIT EXOPC native\n".print; }
+ .when 096h then { "Free type...\n".print; }
+ .when 097h then { "FAT32 cachee (FreeFDISK)\n".print; }
+ .when 098h then { "FAT32x cachee (FreeFDISK)\n".print; }
+ .when 099h then { "DCE376 logical drive\n".print; }
+ .when 09Ah then { "FAT16x cachee (FreeFDISK)n".print; }
+ .when 09Bh then { "etendue X cachee (FreeFDISK)\n".print; }
+ .when 09Ch then { "Free type...\n".print; }
+ .when 09Dh then { "Free type...\n".print; }
+ .when 09Eh then { "Free type...\n".print; }
+ .when 09Fh then { "BSD/OS\n".print; }
+ .when 0A0h then { "hibernation\n".print; }
+ .when 0A1h then { "reserved\n".print; }
+ .when 0A2h then { "Free type...\n".print; }
+ .when 0A3h then { "reserved\n".print; }
+ .when 0A4h then { "reserved\n".print; }
+ .when 0A5h then { "BSD\n".print; }
+ .when 0A6h then { "OpenBSD\n".print; }
+ .when 0A7h then { "NEXTSTEP\n".print; }
+ .when 0A8h then { "Free type...\n".print; }
+ .when 0A9h then { "NetBSD\n".print; }
+ .when 0AAh then { "FAT12 1,44Mo Olivetti\n".print; }
+ .when 0ABh then { "Free type...\n".print; }
+ .when 0ACh then { "Free type...\n".print; }
+ .when 0ADh then { "Free type...\n".print; }
+ .when 0AEh then { "ShagOS filesystem\n".print; }
+ .when 0AFh then { "ShagOS swap partition\n".print; }
+ .when 0B0h then { "Free type...\n".print; }
+ .when 0B1h then { "reserved\n".print; }
+ .when 0B2h then { "Free type...\n".print; }
+ .when 0B3h then { "reserved\n".print; }
+ .when 0B4h then { "reserved\n".print; }
+ .when 0B5h then { "Free type...\n".print; }
+ .when 0B6h then { "reserved\n".print; }
+ .when 0B7h then { "BSDI BSD/386\n".print; }
+ .when 0B8h then { "BSDI BSD/386 swap\n".print; }
+ .when 0B9h then { "Free type...\n".print; }
+ .when 0BAh then { "Free type...\n".print; }
+ .when 0BBh then { "Free type...\n".print; }
+ .when 0BCh then { "Free type...\n".print; }
+ .when 0BDh then { "Free type...\n".print; }
+ .when 0BEh then { "Solaris 8 boot\n".print; }
+ .when 0BFh then { "Free type...\n".print; }
+ .when 0C0h then { "CTOS REAL/32 secure NTFT\n".print; }
+ .when 0C1h then { "FAT12 DRDOS\n".print; }
+ .when 0C2h then { "Linux swap cachee\n".print; }
+ .when 0C3h then { "Linux cachee\n".print; }
+ .when 0C4h then { "FAT16 <32M DRDOS\n".print; }
+ .when 0C5h then { "Free type...\n".print; }
+ .when 0C6h then { "FAT16 >= 32M DRDOS, FAT16 corrompue (NT)\n".print; }
+ .when 0C7h then { "NTFS corrompue (NT), Syrinx boot\n".print; }
+ .when 0C8h then { "Free type...\n".print; }
+ .when 0C9h then { "Free type...\n".print; }
+ .when 0CAh then { "Free type...\n".print; }
+ .when 0CBh then { "FAT32 DRDOS\n".print; }
+ .when 0CCh then { "FAT32x DRDOS\n".print; }
+ .when 0CDh then { "CTOS\n".print; }
+ .when 0CEh then { "FAT16x DRDOS\n".print; }
+ .when 0CFh then { "Free type...\n".print; }
+ .when 0D0h then { "REAL32\n".print; }
+ .when 0D1h then { "Multiuser DOS, secured FAT12\n".print; }
+ .when 0D2h then { "Free type...\n".print; }
+ .when 0D3h then { "Free type...\n".print; }
+ .when 0D4h then { "Multiuser\n".print; }
+ .when 0D5h then { "Multiuser\n".print; }
+ .when 0D6h then { "Multiuser\n".print; }
+ .when 0D7h then { "Free type...\n".print; }
+ .when 0D8h then { "CP/M-86\n".print; }
+ .when 0D9h then { "Free type...\n".print; }
+ .when 0DAh then { "Non-FS Dat a\n".print; }
+ .when 0DBh then { "Digital Research, CP/M, Concurrent CP/M, Concurent DOS, CTOS, KDG Telemetry,SCPU boot\n".print; }
+ .when 0DCh then { "CTOS\n".print; }
+ .when 0DDh then { "CTOS cachee\n".print; }
+ .when 0DEh then { "Free type...\n".print; }
+ .when 0DFh then { "DG/UX virtual disk manager\n".print; }
+ .when 0E0h then { "ST AVFS\n".print; }
+ .when 0E1h then { "SpeedStor FAT12\n".print; }
+ .when 0E2h then { "Free type...\n".print; }
+ .when 0E3h then { "SpeedStor\n".print; }
+ .when 0E4h then { "SpeedStor etendue\n".print; }
+ .when 0E5h then { "reserved\n".print; }
+ .when 0E6h then { "reserved\n".print; }
+ .when 0E7h then { "Free type...\n".print; }
+ .when 0E8h then { "Free type...\n".print; }
+ .when 0E9h then { "Free type...\n".print; }
+ .when 0EAh then { "Free type...\n".print; }
+ .when 0EBh then { "Be FS\n".print; }
+ .when 0ECh then { "Free type...\n".print; }
+ .when 0EDh then { "Free type...\n".print; }
+ .when 0EEh then { "EFI MBR\n".print; }
+ .when 0EFh then { "EFI\n".print; }
+ .when 0F0h then { "Linux/PA-RISC boot loader\n".print; }
+ .when 0F1h then { "SpeedStor\n".print; }
+ .when 0F2h then { "DOS 3.3+ secondary partition\n".print; }
+ .when 0F3h then { "reserved \n".print; }
+ .when 0F4h then { "SpeedStor large Prologue single-volume\n".print; }
+ .when 0F5h then { "Prologue multi-volume\n".print; }
+ .when 0F6h then { "reserved\n".print; }
+ .when 0F7h then { "Free type...\n".print; }
+ .when 0F8h then { "Free type...\n".print; }
+ .when 0F9h then { "Free type...\n".print; }
+ .when 0FAh then { "Free type...\n".print; }
+ .when 0FBh then { "VMware File System\n".print; }
+ .when 0FCh then { "VMware Swap\n".print; }
+ .when 0FDh then { "Linux raid\n".print; }
+ .when 0FEh then { "SpeedStor > 1024 cyl, IBM PS/2 IML, Windows NT Disk Administrator, Linux Logical Volume Manager\n".print; }
+ .when 0FFh then { "Xenix Bad Block Table\n".print; };
+ );
+
+Section Public
+
+ - add_base sec:UINTEGER_32<-
+ (
+ mbr_first_sector := mbr_first_sector + sec;
+ );
+
+ - is_active:BOOLEAN <- (flag_boot=80h);
+
+ - cylinder_begin:UINTEGER_16 <- cylinder cylinder_sector_begin;
+
+ - cylinder_end:UINTEGER_16 <- cylinder cylinder_sector_end;
+
+ - sector_begin:UINTEGER_16 <- sector cylinder_sector_begin;
+
+ - sector_end:UINTEGER_16 <- sector cylinder_sector_end;
+
+ - is_fat12:BOOLEAN <-
+ (
+ (type=001h) || {type=011h} ||
+ {type=08Dh} || {type=0AAh} ||
+ {type=0C1h} || {type=0D1h} ||
+ {type=0E1h}
+ );
+
+ - is_fat16:BOOLEAN <-
+ (
+ (type=004h) || {type=006h} ||
+ {type=00Eh} || {type=014h} ||
+ {type=016h} || {type=01Eh} ||
+ {type=090h} || {type=092h} ||
+ {type=09Ah} || {type=0C4h} ||
+ {type=0C6h} || {type=0CEh}
+ );
+
+ - is_fat32:BOOLEAN <-
+ (
+ (type=00Bh) || {type=00Ch} ||
+ {type=01Bh} || {type=01Ch} ||
+ {type=08Bh} || {type=08Ch} ||
+ {type=097h} || {type=098h} ||
+ {type=0CBh} || {type=0CCh}
+ );
+
+ - print <-
+ (
+ "type ".print;
+ type.to_hexadecimal.print;
+ "h : ".print;
+
+ print_type;
+
+ (is_active).if {
+ "Active.".print;
+ } else {
+ "Not active.".print;
+ };
+ /*
+ "\n\tBegin\t Head=".print;
+ head_begin.print;
+ " Cylinder=".print;
+ cylinder_begin.print;
+ " Sector=".print;
+ sector_begin.print;
+
+ "\n\tEnd\t Head=".print;
+ head_end.print;
+ " Cylinder=".print;
+ cylinder_end.print;
+ " Sector=".print;
+ sector_end.print;
+ */
+ "\n\tFirst sector=".print;
+ mbr_first_sector.print;
+ "\n\tSize=".print;
+ (size>>11).print;
+ " MB.\n".print;
+ );
+
+ - print_small <-
+ (
+ (size>>11).print;
+ " MB.\t Type ".print;
+ type.to_hexadecimal.print;
+ "h : ".print;
+
+ print_type;
+ );
+
diff --git a/isaacos/x86/bootloader/startup.asm b/isaacos/x86/bootloader/startup.asm
new file mode 100755
index 0000000..67cacb4
--- /dev/null
+++ b/isaacos/x86/bootloader/startup.asm
@@ -0,0 +1,1182 @@
+ ;; ======================
+ ;; = LOADER x86 - ISAAC =
+ ;; = Version 3.0 =
+ ;; = 01/06 =
+ ;; = By Sonntag Benoit =
+ ;; ======================
+
+ ;; Support : Hard-Disk FAT16,FAT32
+ ;; Floppy-Disk FAT12,FAT16
+
+ ;; Compilation :
+ ;; tasm -m2 startup.asm
+ ;; tlink /t startup
+.486P
+ ;; ======================
+ ;; = MACRO =
+ ;; ======================
+b equ <byte ptr>
+w equ <word ptr>
+d equ <dword ptr>
+o equ <offset>
+
+OS32 segment use16
+ ORG 0100h
+assume cs:OS32, es:OS32, ss:OS32
+
+START: ;; ======================
+ ;; = START JUMP =
+ ;; ======================
+ jmp debcom
+
+ ;; ======================
+ ;; = BOOT DATA =
+ ;; ======================
+DBNomVer equ 3 +600h ; Name & Version
+DWOct_Sec equ 11+600h ; Byte / Sector
+DBSec_Clu equ 13+600h ; Sector / Cluster
+DWSec_Res equ 14+600h ; Nbr Sector Reserved
+DBNb_FAT equ 16+600h ; Nbr of FAT
+DWE_Rac equ 17+600h ; Nbr Entry in root directory
+DWSec_Vol equ 19+600h ; Nbr Sector in Volume
+DBDesc_Supp equ 21+600h ; Descriptor support
+DWSec_FAT equ 22+600h ; Nbr Sector / FAT
+DWSec_Pis equ 24+600h ; Nbr Sector / Track (Piste)
+DWNb_tet equ 26+600h ; Nbr Head
+DDDis_mass equ 28+600h ; Distance of first sector in support.
+DDSec_Vol2 equ 32+600h ; Nb Sec. =>2500Mo
+
+DDSec_FAT2 equ 36+600h ; Nbr Sector / FAT - 1
+; equ 40+600h ; Flags FAT
+; equ 42+600h ; Version FAT
+DDRoot_Clu equ 44+600h ; start Root Directory
+; equ 48+600h ; ???
+; equ 52+600h ; +12
+
+ ;; Drive Information
+DBDrive equ 64+600h ; Phys. Drive
+ ; equ 65+600h ; Reserv.
+ ; equ 66+600h ; 29h
+ ; equ 67+600h ; Serial Number of Disk
+ ; equ 71+600h ; Name of Volume
+ ; equ 82+600h ; Type FAT
+
+ ;; ======================
+ ;; = DATA BOOT ISAAC =
+ ;; ======================
+DDPosClu equ 90+600h ; Position of first Cluster.
+DDPosRac equ 94+600h ; Logical Sector of root directory.
+DDPosFAT equ 98+600h ; Position of FAT.
+
+;******* Address packet for int 13h ******
+DBInt13_Size equ 102+600h
+DBInt13_Reserved equ 103+600h
+DWInt13_NbrSector equ 104+600h
+DWInt13_Offset equ 106+600h
+DWInt13_Segment equ 108+600h
+DDInt13_Sector equ 110+600h
+DDInt13_SectorHigh equ 114+600h
+
+Invit db 'dans STARTUP',13,10,0
+ ;; ======================
+ ;; = DATA STARTUP =
+ ;; ======================
+
+old_sector_FAT equ 600h
+
+ ;; ======================
+ ;; = CODE =
+ ;; ======================
+debcom:
+;***************** Test limit 512 bytes ************************
+ mov ax,FIN_LIMIT_512
+ cmp ax,512
+ jb limit_ok
+ mov ah,0Eh
+ xor bx,bx
+ mov al,'E'
+ int 10h
+ jmp $
+limit_ok:
+
+;******************* move this Code to 2800h *********************
+ mov sp,0800h
+ mov di,2800h ; Destination of Code.
+ mov si,7C00h ; Source (=> Here)
+ mov cx,256 ; 256 x 2 = 512 o copy.
+ rep movsw ; Copy Code...
+ db 0EAh ; Jump Far on NewCode
+ dw offset NewCode-100h
+ dw 280h
+NewCode:
+ xor ax,ax
+ mov fs,ax
+
+;*********** Read file 2048 bytes (modulo cluster) *******************
+ mov fs:[old_sector_FAT],d -1
+ mov bx,280h
+ mov dh,fs:[DBSec_Clu] ; Nbr sector/cluster
+ movzx cx,dh
+ shl cx,5 ; Nbr sec/clu * 32 ( 32 = 512/16 )
+LecSuite:
+ call AddrClu
+ mov es,bx
+ call LecSec
+ add bx,cx
+ call CluSuivant
+ cmp bx,300h
+ jae SuiteCode
+ jmp LecSuite
+
+;********************* Cluster -> Secteur Logique ***************************
+; -> EAX : Secteur Logique
+AddrClu:
+ push edx
+ movzx eax,b fs:[DBSec_Clu] ; Nbr de secteur / Cluster.
+ mul d fs:[DDRoot_Clu]
+ add eax,fs:[DDPosClu] ; Calcul le bon Secteur.
+ pop edx
+ Ret
+
+;********************* Cherche le cluster suivant ***************************
+CluSuivant:
+ pushad
+ push es
+
+ mov ax,100h
+ mov es,ax
+ mov dh,1 ; Nbr de sector a lire
+
+ mov ebx,fs:[DDRoot_Clu]
+ test b fs:[DBDrive],80h
+ jz CluFAT12
+ or w fs:[DWE_Rac],0
+ jnz CluFAT16
+CluFAT32:
+ shl ebx,2
+ mov eax,ebx
+ shr eax,9
+ add eax,fs:[DDPosFAT]
+ call LecSecFAT
+ and bx,1FFh
+ mov eax,es:[bx]
+ cmp eax,0FFFFFF0h
+ jae EndOfFile
+ jmp GoodClu
+
+CluFAT16:
+ shl ebx,1
+ mov eax,ebx
+ shr eax,9
+ add eax,fs:[DDPosFAT]
+ call LecSecFAT
+ and bx,1FFh
+ movzx eax,w es:[bx]
+ cmp ax,0FFF0h
+ jae EndOfFile
+ jmp GoodClu
+
+CluFAT12:
+ mov eax,ebx
+ shr eax,1
+ add eax,ebx ; cluster * 1.5
+ mov di,ax
+ shr eax,9
+ add eax,fs:[DDPosFAT]
+ inc dh ; 2 sectors a lire
+ call LecSecFAT
+ and di,1FFh
+ mov ax,es:[di]
+ test bx,1
+ jz FAT12_low
+ shr ax,4
+ jmp FAT12_suite
+FAT12_low:
+ and ax,0FFFh
+FAT12_suite:
+ cmp ax,0FF0h
+ jb GoodClu
+EndOfFile:
+ xor eax,eax
+GoodClu:
+ mov fs:[DDRoot_Clu],eax
+
+ pop es
+ popad
+ ret
+
+;******************** Aff txt *********************************************
+; DS:SI = Chaine
+;Afftxt:
+; mov ah,0Eh
+; xor bx,bx
+;bclaff: lodsb
+; or al,al
+; jnz aff0
+; Ret
+;aff0: int 10h
+; jmp bclaff
+;********************** Sector Logique -> Secteur Physique ******************
+; EAX : Secteur Logique. ES : Addr. Buf. DH : Nb de secteur.
+LecSecFAT:
+ cmp eax,fs:[old_sector_FAT]
+ jz finLec
+ mov fs:[old_sector_FAT],eax
+LecSec:
+ pushad
+
+ mov b fs:[DWInt13_NbrSector],dh
+ mov w fs:[DWInt13_Offset],0
+ mov fs:[DWInt13_Segment],es
+ mov fs:[DDInt13_Sector],eax ; Charge le N Sector
+ mov si,offset fs:[DBInt13_Size] ; DS:SI=Addr. du Packet (Int 13h)
+ mov dl,fs:[DBDrive] ; Drive.
+ test dl,80h
+ jz floppy
+ mov ah,42h ; Read Sectors O/I
+ int 13h
+ popad
+finLec:
+ Ret
+floppy:
+ mov bl,b fs:[DWSec_Pis]
+ push bx
+ shl bl,1 ; Sec_Pis * Nb_Tet
+ div bl
+ mov ch,al ; Piste = sec / (Sec_Pis * Nb_Tet)
+
+ shr ax,8
+ pop bx
+ div bl
+ xchg dh,al ; Head
+
+ mov cl,ah
+ inc cl ; Sector
+
+ mov ah,02h
+ xor bx,bx ; ES:BX = Buffer
+ int 13h
+ popad
+ Ret
+
+;print_buf:
+; push es
+; push ds
+; pusha
+;
+; push es
+; pop ds
+; xor si,si
+; mov ax,0B800h
+; mov es,ax
+; xor di,di
+;
+; mov ah,15
+; mov ecx,512
+;next_car:
+; lodsb
+; stosw
+; loop next_car
+;
+; xor ax,ax
+; int 16h
+; popa
+; pop ds
+; pop es
+; Ret
+
+;*************************** Affiche un Nbr *********************************
+; AX : Nbr
+ affax: pusha
+ push es
+ mov bx,0B800h
+ mov es,bx
+ xor di,di
+ mov cx,ax
+ mov bp,10000
+ daffnb2:mov ax,cx
+ xor dx,dx
+ div bp
+ mov cx,dx
+ add al,48
+ mov ah,10
+ stosw
+ mov ax,bp
+ mov bp,10
+ xor dx,dx
+ div bp
+ or ax,ax
+ jz qaffnb2
+ mov bp,ax
+ jmp daffnb2
+ qaffnb2:
+ xor ax,ax
+ int 16h
+
+ pop es
+ popa
+ ret
+
+FIN_LIMIT_512 equ offset $-100h
+
+;**************************************************************************
+;* LIMITE DU CODE < 512 Octets *
+;**************************************************************************
+ ;; 000000h -+-------------+ ---------
+ ;; | IDT 16 Bits |
+ ;; 000400h -+-------------+
+ ;; | Area BIOS |
+ ;; 000500h -+-------------+
+ ;; | Free | Page 1
+ ;; 000600h -+-------------+
+ ;; | Free |
+ ;; 000800h -+-------------+
+ ;; | IDT 32 Bits |
+ ;; 001000h -+-------------+ ---------
+ ;; | DATA-CODE |
+ ;; | 16 Bits | Page 2
+ ;; 001800h -+-------------+
+ ;; | STACK 16Bits|
+ ;; 002000h -+-------------+ ---------
+ ;; | GDT |
+ ;; 002800h -+-------------+ Page 3
+ ;; | STARTUP.ASM |-----------> After load. Buffer 16Bits (2Ko).
+ ;; 003000h -+-------------+ ---------
+ ;; | |
+ ;; | FREE | Page 4
+ ;; | |
+ ;; 09FC00h -+-------------+
+ ;; |Area BIOS Ext|
+ ;; 0A0000h -+-------------+ .
+ ;; | SCREEN |
+ ;; | + |
+ ;; | BIOS |
+ ;; 100000h -+-------------+
+ ;; | STACK (1Mo) |
+ ;; | 32 Bits |
+ ;; 200000h -+-------------+
+ ;; | CODE 32Bits |
+ ;; | STARTUP |
+ ;; | ----------- |
+ ;; | DATA+BSS 32 |
+ ;; | STARTUP |
+ ;; 400000h -+-------------+
+ ;; | MALLOC |
+ ;; | |
+ ;; |/\/\/\/\/\/\/|
+ ;;
+ ;; |/\/\/\/\/\/\/|
+ ;;FEC0.0000h+-------------+
+ ;; | Various BIOS|
+ ;;FFFF.FFFFh+-------------+
+
+ ;; GDT :
+ ;; 0000h -+-------------+
+ ;; | Link Free |
+ ;; 0008h -+-------------+
+ ;; | Code 16bits |
+ ;; 0010h -+-------------+
+ ;; | Data 16bits |
+ ;; 0018h -+-------------+
+ ;; | Code 32bits |
+ ;; 0020h -+-------------+
+ ;; | Data 32bits |
+ ;; 0028h -+-------------+
+ ;; |/\/\/\/\/\/\/
+
+ ;; ======================
+ ;; = DATA =
+ ;; ======================
+
+IDT dw 07FFh ; Laisse de la place pour l'ancienne table Interruption...
+ dd 0800h
+
+GDT dw 07FFh ; Une petite GDT pour commencer ... (2Ko)
+ dd 2000h ; Laisse de place pour la table des repertoire de page...
+
+ ;; ======================
+ ;; = CODE =
+ ;; ======================
+
+SuiteCode:
+
+ push bx ; Save for load KERNEL
+ push dx
+
+;************************* Preparation de la GDT ***************************
+ mov ax,80h
+ mov es,ax
+ xor eax,eax
+ mov di,ax
+ mov ecx,200h
+ rep stosd ; Vide IDT
+
+ mov ax,200h
+ mov es,ax
+ xor eax,eax
+ mov di,ax
+ mov ecx,200h
+ rep stosd ; Vide GDT
+
+ ;; Intern Linked List in GDT
+ mov ax,200h ; GDT
+ mov es,ax
+ mov cx,255
+ xor di,di
+ mov ax,1
+ListGDT: mov es:[di],ax
+ add di,8
+ inc ax
+ dec cx
+ jnz ListGDT
+ mov w es:[di],0 ; Fin de la liste.
+
+ ;***** Les descripteurs essentiel *****
+
+ ; *** CODE 16 Bits ***
+ mov eax,0
+ mov ebx,0FFFFFh ; desc 08h : CODE segment.
+ mov cx,0809Bh ; Code 16 bits (Flat mode).
+ call desc
+
+ ; *** DATA 16 Bits ***
+ mov eax,0
+ mov ebx,0FFFFFh ; desc 10h : DATA 16Bits segment.
+ mov cx,08093h ; Data Fixe (Flat mode)
+ call Desc
+
+ ; *** CODE 32 Bits ***
+ mov eax,0
+ mov ebx,0FFFFFh ; desc 18h : CODE segment.
+ mov cx,0C09Bh ; Code 32 bits.
+ call desc
+
+ ; *** DATA 32 Bits ***
+ mov eax,0
+ mov ebx,0FFFFFh ; desc 20h : DATA segment.
+ mov cx,0C093h ; Data Fixe
+ call Desc
+
+ ;; Passage en FLAT mode 32Bits :-)
+ ;; (J'encule le REAL mode pour charger le Kernel en High memory!)
+
+ call enablea20
+
+;**************************** GDTR ****************************************
+ CLI
+ lgdt fword ptr cs:[GDT-100h] ; met ds GDTR
+
+ mov eax,cr0
+ or eax,00000001h ; Passage en mode prot�g� 32 bits.
+ mov cr0,eax
+
+ mov ax,10h
+ mov es,ax
+ mov ds,ax
+ mov gs,ax
+ mov fs,ax
+
+ ;; Protecting Mode -> Real Mode
+ mov eax,cr0 ; Pass Real Mode
+ and eax,7FFFFFFEh
+ mov cr0,eax
+
+ sti
+
+;*********** Lecture du fichier KERNEL ISAAC *******************
+ pop dx
+ pop bx ; Load info Kernel...
+
+ ;; Copy modulo Cluster
+ xor ax,ax
+ mov es,ax
+ mov ds,ax
+ mov fs,ax
+ mov edi,200000h ; 2 Mo
+
+ mov esi,3000h
+ movzx ebx,bx
+ shl ebx,4
+KLoop:
+ cmp ebx,esi
+ jz ExitKcopy
+ mov eax,ds:[esi]
+ mov es:[edi],eax
+ add esi,4
+ add edi,4
+ jmp KLoop
+ExitKcopy:
+ or d fs:[DDRoot_Clu],0
+ jz Kfin
+
+ mov ax,300h
+ mov es,ax
+KLecSuite:
+ call AddrClu
+ call LecSec
+ ;; Copy Cluster > 2Mo
+ movzx ecx,dh
+ shl cx,7 ; Sec/clu * 512 / 4
+
+ xor esi,esi
+Kcopy:
+ mov eax,es:[esi]
+ mov ds:[edi],eax
+ add esi,4
+ add edi,4
+ loop Kcopy
+
+ ;; Next Cluster
+ call CluSuivant
+ or d fs:[DDRoot_Clu],0
+ jnz KLecSuite
+Kfin:
+
+;********************* Le passage commence ICI ! **************************
+ ;; Passage FLAT mode -> PROTECTING MODE
+ ;; (J'encule le FLAT mode pour le vrai protecting mode 32Bits!)
+
+ CLI
+ lidt fword ptr cs:[IDT-100h] ; met ds IDTR
+ lgdt fword ptr cs:[GDT-100h] ; met ds GDTR
+
+;**************************** Init PIC *************************************
+ mov al,11h ; ICW1 : Mode attaque / Cascade / ICW4
+ out 20h,al
+ jmp $+2
+ out 0A0h,al
+ jmp $+2
+ mov al,20h ; ICW2 : N� int Pr IRQ0
+ out 21h,al
+ jmp $+2
+ mov al,28h
+ out 0A1h,al
+ jmp $+2
+ mov al,04h ; ICW3 : Ligne IRQ Pr Esclave (2nd PIC)
+ out 21h,al
+ jmp $+2
+ mov al,02h
+ out 0A1h,al
+ jmp $+2
+ mov al,01h ; ICW4 : EOI Manuel / Intel
+ out 21h,al
+ jmp $+2
+ out 0A1h,al
+ jmp $+2
+ mov al,11111111b ; Autorise Rien pr IRQ0-7
+ out 21h,al
+ jmp $+2
+ mov al,11111111b ; Autorise Rien pr IRQ8-15
+ out 0A1h,al
+ jmp $+2
+
+ call install_bios_int
+
+ ; *** FIN ***
+
+ mov eax,1000h
+ mov cr3,eax ; Pour le repertoire de page ...
+
+ ; xor eax,eax
+ ; mov ax,BIDON_X32
+ ; or eax,10000h
+ ; mov ebx,8000h
+ ; mov cx,009Bh ; Code 16 Bits.
+ ; call desc
+ ; mov cs:[ofs_jmp-100h],dword ptr 0
+ ; mov cs:[seg_jmp-100h],ax
+
+ jmp $+2 ; Vide le Cache.
+
+ ;; ======================
+ ;; = PROTECTING MODE 32 =
+ ;; ======================
+
+;***************************** Flags **************************************
+ push d 3002h ; init le flag IOPL=3 & CLI
+ popfd
+
+;*************************** Init Mot d'etat Machine **********************
+ mov eax,cr0
+ or eax,00000001h ; Passage en mode protege 32 bits.
+ mov cr0,eax
+
+;*************************** Init les registres de segment ****************
+ mov ax,20h
+ mov es,ax
+ mov ds,ax
+ mov gs,ax
+ mov fs,ax
+ mov ss,ax
+ mov esp,200000h
+
+
+;*** LE GRAND SAUT !!! *** => Bonne chance Isaac ...
+ db 66h
+ db 0EAh ; JUMP FAR Execution du STARTUP.EOF
+ofs_jmp dd 200000h
+seg_jmp dw 18h
+
+ ;; ======================
+ ;; = SUB ROUTINE =
+ ;; ======================
+
+aff_eax:
+ pushad
+ mov edx,eax
+ xor bx,bx
+ mov cl,28
+aff_h:
+ mov eax,edx
+ shr eax,cl
+ and eax,0Fh
+ cmp al,9
+ ja hex_car
+ add al,48
+ jmp aff_car
+hex_car: add al,'A'-10
+aff_car:
+ mov ah,0Eh
+ int 10h
+ sub cl,4
+ jae aff_h
+
+ mov ah,0Eh
+ mov al,'h'
+ int 10h
+
+ call wait_key
+ call wait_key
+ popad
+ ret
+
+;******************** Aff txt *********************************************
+Afftxt:
+ mov ah,0Eh
+ xor bx,bx
+bclaff: lodsb
+ or al,al
+ jnz aff0
+ Ret
+aff0: int 10h
+ jmp bclaff
+
+;********************** Rempli un Descripteur ******************************
+;* eax:Addr de base; ebx:Taille du seg; cx:priorit� => ax: n�du desc
+Desc:
+ push ebx
+ push di
+ push es
+ push dx
+ mov di,200h
+ mov es,di
+ mov di,es:[0]
+ shl di,3
+ mov dx,es:[di]
+ mov es:[0],dx
+ mov es:[di],bx ; 0..15 de la taille
+ shr ebx,16
+ or bl,ch
+ mov es:[di+6],bl ; 16..19 de la taille
+ mov es:[di+2],ax ; 0..15 de la base
+ shr eax,16
+ mov es:[di+4],al ; 16..23 de la base
+ mov es:[di+7],ah ; 24..31 de la base
+ mov es:[di+5],cl ; priorit�
+ mov ax,di
+ pop dx
+ pop es
+ pop di
+ pop ebx
+ ret
+
+;******************************** A20 ***************************************
+enablea20:
+ pusha
+ push fs
+ push gs
+ cli
+
+ xor ax,ax ; set A20 test segments 0 and 0ffffh
+ mov fs,ax
+ dec ax
+ mov gs,ax
+
+ call a20test
+ jz a20Fin
+
+ in al,92h ; PS/2 A20
+ or al,2
+ jmp $+2
+ jmp $+2
+ jmp $+2
+ out 92h,al
+
+ call a20test
+ jz a20Fin
+
+ call a20kbwait ; AT A20 enable
+ jnz a20f0
+
+ mov al,0d1h
+ out 64h,al
+
+ call a20kbwait
+ jnz a20f0
+
+ mov al,0dfh
+ out 60h,al
+
+ call a20kbwait
+
+a20f0: ; wait A20
+ mov cx,800h
+
+a20l0:
+ call a20test
+ jz a20Fin
+
+ in al,40h ; get current tick counter
+ jmp $+2
+ jmp $+2
+ jmp $+2
+ in al,40h
+ mov ah,al
+
+a20l1: ; wait a single tick
+ in al,40h
+ jmp $+2
+ jmp $+2
+ jmp $+2
+ in al,40h
+ cmp al,ah
+ je a20l1
+
+ loop a20l0
+
+a20Fin:
+ sti
+ pop gs
+ pop fs
+ popa
+ ret
+
+;-----------------------------------------------------------------------------
+a20kbwait:
+ xor cx,cx
+waitl0:
+ jmp $+2
+ jmp $+2
+ jmp $+2
+ in al,64h ; read 8042 status
+ test al,2 ; buffer full?
+ loopnz waitl0
+ ret
+
+;-----------------------------------------------------------------------------
+a20test:
+ mov al,fs:[0]
+ mov ah,al
+ not al
+ xchg al,gs:[10h]
+ cmp ah,fs:[0]
+ mov gs:[10h],al
+ ret ; 0 : A20 OK
+
+;----------------------- INT BIOS ---------------------
+install_bios_int:
+;******************* Deplacement du Code en 1000h *********************
+ push di
+ push si
+ push cx
+ push es
+ push ds
+
+ xor ax,ax
+ mov es,ax
+ mov ax,cs
+ mov ds,ax
+ mov di,1000h ; Destination du Code.
+ mov si,offset begin_call-100h ; Source (=> Ici)
+
+ mov cx,offset end_call-100h
+ sub cx,si
+ add cx,2
+ shr cx,1
+ cmp cx,400h
+ jb limit_ok2
+ mov ah,0Eh
+ xor bx,bx
+ mov al,'e'
+ int 10h
+ jmp $
+limit_ok2:
+
+ rep movsw ; Copie le Code...
+
+ pop ds
+ pop es
+ pop cx
+ pop si
+ pop di
+ ret
+
+begin_call_int equ offset $
+begin_call:
+ pushad
+ push ds
+ push es
+
+ mov ax,10h ; Data 16 bits
+ mov ds,ax
+ mov es,ax
+ mov fs,ax
+ mov gs,ax
+
+ mov ds:[old_ss -begin_call_int+1000h],ss ; Save SS 32bits
+ mov ds:[old_esp -begin_call_int+1000h],esp ; Save ESP 32 bits
+
+ sgdt fword ptr ds:[GDT_Isa -begin_call_int+1000h]
+
+ mov ss,ax ; Install new Stack
+ mov esp,2000h-24
+
+ pop ax ; Depile Num Interrupt
+ mov ds:[num_int -begin_call_int+1000h],al ; Write Num
+
+ jmp vide_cache ; Flush cash processor (Pipeline)
+
+old_ss dw 0 ; Data Save old stack 32 bits
+old_esp dd 0
+
+GDT_Isa dw 07FFh ; save old GDT
+ dd 2000h
+
+vide_cache:
+ ;; Protecting Mode -> Real Mode
+ mov eax,cr0 ; Pass Real Mode
+ and eax,7FFFFFFEh
+ mov cr0,eax
+
+ db 0EAh ; Jump Real Mode
+ dw offset JumpRM -begin_call_int+1000h
+ dw 0
+
+JumpRM:
+ ;; lidt fword ptr cs:[IDT_Rea -begin_call_int+1000h]
+ xor ax,ax
+ mov ss,ax ; Stack Real Mode
+
+ popf
+ pop ds
+ pop es
+ popa
+
+ sti
+ ;; int 13h
+ ;; jc erro
+ ;; mov ax,0b800h
+ ;; mov ds,ax
+ ;; mov ds:[160],byte ptr 'B'
+ ;; mov ds:[161],byte ptr 12
+ ;; jmp pas_err
+ ;; erro:
+ ;; mov ax,0b800h
+ ;; mov ds,ax
+ ;; mov ds:[160],byte ptr 'E'
+ ;; mov ds:[161],byte ptr 12
+ ;; pas_err:
+ ;; jmp $
+
+ db 0CDh ; Int N #
+num_int db 0 ; num
+
+ cli
+
+ pusha
+ push es
+ push ds
+ pushf
+
+ lgdt fword ptr cs:[GDT_Isa -begin_call_int+1000h] ; restore GDT
+
+ ;; Real Mode -> Protecting Mode (WARNING : PAS de pagination!!)
+ mov eax,cr0
+ or eax,00000001h
+ mov cr0,eax
+
+ db 0EAh ; Jump Protecting Mode 16 bits
+ dw offset JumpPM -begin_call_int+1000h
+ dw 08h
+JumpPM:
+ mov ax,10h ; Data PM 16 bits
+ mov ds,ax
+
+ mov ss ,ds:[old_ss -begin_call_int+1000h]
+ mov esp,ds:[old_esp -begin_call_int+1000h]
+
+fin_int:
+ pop es
+ pop ds
+ popad
+
+ db 066h
+ Retf
+end_call:
+
+ ;; ======================
+ ;; = DEBUG SUB ROUTINE =
+ ;; ======================
+
+;*************************** Affiche un Nbr *********************************
+; EAX : Addr
+affbuf_bios:
+ pushad
+ push ds
+
+ mov esi,eax
+ xor ax,ax
+ mov ds,ax
+ mov cx,16
+affbb:
+ push cx
+
+ mov ax,si
+ call affax_bios
+ xor bx,bx
+ mov ah,0Eh
+ mov al,':'
+ int 10h
+
+ mov cx,512
+affbl:
+ mov al,ds:[esi]
+ inc esi
+ cmp al,32
+ jb passcar
+
+ xor bx,bx
+ mov ah,0Eh
+ int 10h
+passcar:
+ loop affbl
+
+ xor bx,bx
+ mov ah,0Eh
+ mov al,10
+ int 10h
+ xor bx,bx
+ mov ah,0Eh
+ mov al,13
+ int 10h
+
+ pop cx
+ loop affbb
+
+ call wait_key
+ call wait_key
+
+ pop ds
+ popad
+ ret
+
+;*************************** Affiche un Nbr *********************************
+; AX : Nbr
+ affax_bios:
+ pusha
+ mov cx,ax
+ mov bp,10000
+ xor bx,bx
+ daffnb3:mov ax,cx
+ xor dx,dx
+ div bp
+ mov cx,dx
+ add al,48
+ mov ah,0Eh
+ int 10h
+ mov ax,bp
+ mov bp,10
+ xor dx,dx
+ div bp
+ or ax,ax
+ jz qaffnb3
+ mov bp,ax
+ jmp daffnb3
+ qaffnb3:
+ call wait_key
+ popa
+ ret
+
+;******************** WaitKey ************************************************
+wait_key:
+ push ax
+ in al,60h
+ mov ah,al
+ BclTc: in al,60h
+ cmp al,ah
+ jz BclTc ; D�tect un changement d'�tat...
+ pop ax
+ ret
+
+;******************** Erreur ************************************************
+Erreur:
+ in al,60h
+ mov ah,al
+ BclTch: in al,60h
+ cmp al,ah
+ jz BclTch ; D�tect un changement d'�tat...
+
+ db 0EAh ; reboot violent
+ dw 0000
+ dw 0FFFFh
+
+;******************** Affiche une chaine ************************************
+; DS:SI= pointeur sur chaine ASCIIZ; BL= couleur;
+affline proc near
+ push ax
+ push bx
+ push dx
+ push si
+ push di
+ push es
+
+ mov dx,3D4h ; CRT
+ mov al,0Eh ; cursor location high
+ out dx,al
+ inc dx
+ in al,dx
+ dec dx
+ mov di,ax
+ shl di,8
+ mov al,0Fh ; cursor location low
+ out dx,al
+ inc dx
+ in al,dx
+ xor ah,ah
+ or di,ax ; addresse du curseur
+ shl di,1
+
+ mov ax,0B800h
+ mov es,ax
+ mov ah,bl
+affline00:
+ lodsb
+ or al,al
+ jz afflinefin
+ cmp al,10
+ jne affline01
+ push ax
+ mov ax,di
+ xor dx,dx
+ mov bx,160
+ div bx
+ sub di,dx
+ pop ax
+ jmp affline00
+affline01:
+ cmp al,13
+ jne affline02
+ add di,160
+ jmp affline00
+affline02:
+ cmp al,9
+ jne affline03
+ add di,16
+ and di,0FFF0h
+ jmp affline00
+affline03:
+ call tstecr
+ stosw
+ jmp affline00
+
+afflinefin:
+ call tstecr
+ shr di,1
+ mov dx,3D4h
+ mov ax,di
+ mov al,0Eh ; cursor location high
+ out dx,ax
+
+ mov ax,di
+ mov ah,al
+ mov al,0Fh ; cursor location low
+ out dx,ax
+
+ pop es
+ pop di
+ pop si
+ pop dx
+ pop bx
+ pop ax
+ Ret
+Tstecr:
+ cmp di,4000
+ jb affline04
+ push ax
+ push ds
+ push si
+ push cx
+ mov ax,di
+ mov bx,160
+ xor dx,dx
+ div bx ; DI / 160
+ sub ax,24 ; Lin - 25 = Lin saut
+ mov di,dx
+ add di,24*160
+ mul bx ; Lin saut * 160
+ mov si,ax
+ push es
+ pop ds
+ push di
+ xor di,di
+ mov cx,4000
+ sub cx,si
+ push si
+ rep movsb
+ pop si
+ mov cx,si
+ shr cx,1
+ mov ax,0720h
+ rep stosw
+ pop di
+
+ pop cx
+ pop si
+ pop ds
+ pop ax
+affline04:
+ Ret
+endp
+
+;*************************** Affiche un Nbr *********************************
+; AX : Nbr
+affnb: pusha
+ push es
+ mov bx,0B800h
+ mov es,bx
+ xor di,di
+ mov cx,ax
+ mov bp,10000
+ xor bx,bx
+daffnb: mov ax,cx
+ xor dx,dx
+ div bp
+ mov cx,dx
+ add al,48
+ mov ah,10
+ stosw
+ mov ax,bp
+ mov bp,10
+ xor dx,dx
+ div bp
+ or ax,ax
+ jz qaffnb
+ mov bp,ax
+ jmp daffnb
+qaffnb: pop es
+ popa
+ ret
+
+
+OS32 ends
+end START
diff --git a/isaacos/x86/bootloader/startup.com b/isaacos/x86/bootloader/startup.com
new file mode 100755
index 0000000..d2b4e97
Binary files /dev/null and b/isaacos/x86/bootloader/startup.com differ
diff --git a/isaacos/x86/bootloader/tasm.exe b/isaacos/x86/bootloader/tasm.exe
new file mode 100755
index 0000000..347ebe1
Binary files /dev/null and b/isaacos/x86/bootloader/tasm.exe differ
diff --git a/isaacos/x86/bootloader/tlink.exe b/isaacos/x86/bootloader/tlink.exe
new file mode 100755
index 0000000..33eed06
Binary files /dev/null and b/isaacos/x86/bootloader/tlink.exe differ
diff --git a/isaacos/x86/driver/clock/clock.li b/isaacos/x86/driver/clock/clock.li
new file mode 100755
index 0000000..a67ee3b
--- /dev/null
+++ b/isaacos/x86/driver/clock/clock.li
@@ -0,0 +1,101 @@
+///////////////////////////////////////////////////////////////////////////////
+// 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; 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 := CLOCK;
+
+ - bibliography:="http://www.lisaac.org";
+
+ - author := "Benoit Sonntag (bsonntag at loria.fr), Jerome Boutet (boutet at loria.fr)";
+
+ - comment :="Clock management.";
+
+ - date :="2003/04";
+
+Section Inherit
+
+ - parent_input:INPUT := INPUT;
+
+Section Private
+
+ - update <-
+ ( + s,m,h:UINTEGER_8;
+ + wd,d,mo:UINTEGER_8;
+ + y:UINTEGER_16;
+
+ SYSTEM.putb 0 to 70h;
+ s := SYSTEM.itemb 71h .to_binary;
+
+ SYSTEM.putb 2 to 70h;
+ m := SYSTEM.itemb 71h .to_binary;
+
+ SYSTEM.putb 4 to 70h;
+ h := SYSTEM.itemb 71h .to_binary;
+
+ time := TIME.create (h,m,s,0);
+
+ SYSTEM.putb 6 to 70h;
+ wd := ((SYSTEM.itemb 71h .to_binary + 4) % 7); // JBJB ??? + 1;
+
+ SYSTEM.putb 7 to 70h;
+ d := SYSTEM.itemb 71h .to_binary;
+
+ SYSTEM.putb 8 to 70h;
+ mo := SYSTEM.itemb 71h .to_binary;
+
+ SYSTEM.putb 9 to 70h;
+ y := 2000 + SYSTEM.itemb 71h .to_binary;
+
+ date := DATE.create (y,mo,d,wd);
+ );
+
+Section Interrupt
+
+ - rtc_interrupt <-
+ (
+ SYSTEM.putb 0Ch to 70h;
+ ((SYSTEM.itemb 71h & 010h)!=0).if {
+ update;
+ };
+
+ // Acknowledge.
+ SYSTEM.putb 20h to 020h;
+ SYSTEM.putb 20h to 0A0h;
+ );
+
+Section Public
+
+ - date:DATE;
+
+ - time:TIME;
+
+ - make <-
+ (
+ SYSTEM.putb 0Bh to 70h;
+ SYSTEM.putb 012h to 71h;
+
+ SYSTEM.putb 0Ah to 70h;
+ {(SYSTEM.itemb 71h & 80h)=0}.until_do {};
+
+ update;
+ SYSTEM.new_interrupt rtc_interrupt to 28h;
+ SYSTEM.irq_on 8;
+ );
+
+
+
+
+
diff --git a/isaacos/x86/driver/clock/timer.li b/isaacos/x86/driver/clock/timer.li
new file mode 100755
index 0000000..cac8788
--- /dev/null
+++ b/isaacos/x86/driver/clock/timer.li
@@ -0,0 +1,106 @@
+///////////////////////////////////////////////////////////////////////////////
+// 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; 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 := TIMER;
+
+ - bibliography:="http://www.lisaac.org";
+
+ - author := "Benoit Sonntag (bsonntag at loria.fr), Jerome Boutet (boutet at loria.fr)";
+
+ - comment :="Timer management.";
+
+ - date :="2003/04";
+
+Section Inherit
+
+ - parent_input:INPUT := INPUT;
+
+Section Private
+
+ - timer_count:UINTEGER_32;
+
+ - buffer_event:FAST_ARRAY(EVENT_TIMER);
+
+ - p_beg:UINTEGER_8; // Pointer on the buffer (beginning)
+
+ - p_end:UINTEGER_8; // Pointer on the buffer (end)
+
+Section Interrupt
+
+ - timer_interrupt <-
+ ( + tmp:UINTEGER_8;
+
+ timer_count := timer_count + 1;
+ VIDEO.pixel_hard (timer_count,0) color timer_count;
+
+ tmp:=(p_end+1)&003h;
+ buffer_event.item p_end.make timer_count;
+ (((tmp+2)&3)!=p_beg).if {
+ p_end:=tmp;
+ };
+
+ // Acknowledge.
+ SYSTEM.putb 20h to 020h;
+ );
+
+Section Public
+
+ - make <-
+ ( + new_event:EVENT_TIMER;
+
+ is_actif := TRUE;
+ //
+ // Software configuration.
+ //
+ buffer_event := FAST_ARRAY(EVENT_TIMER).create 4;
+ 0.to 3 do { j:INTEGER;
+ new_event := EVENT_TIMER.clone;
+ buffer_event.put new_event to j;
+ (j != 0).if {
+ new_event.set_prev (buffer_event.item (j-1));
+ };
+ };
+ buffer_event.first.set_prev new_event;
+
+ //
+ // Hardware configuration.
+ //
+ SYSTEM.new_interrupt timer_interrupt to 20h;
+ SYSTEM.irq_on 0;
+ );
+
+ - acknowledge <-
+ (
+ p_beg := (p_beg+1) & 03h;
+ );
+
+ - get_event <-
+ ( + p:INTEGER;
+ + evt:EVENT_TIMER;
+
+ p := p_beg;
+ { p != p_end }.while_do {
+ evt := buffer_event.item p;
+ (list_client.lower).to (list_client.upper) do { j:INTEGER;
+ list_client.item j.receive (buffer_event.item p);
+ };
+ p := (p + 1) & 03h;
+ };
+ );
+
+
+
diff --git a/isaacos/x86/driver/keyboard/keyboard.li b/isaacos/x86/driver/keyboard/keyboard.li
new file mode 100755
index 0000000..3c40070
--- /dev/null
+++ b/isaacos/x86/driver/keyboard/keyboard.li
@@ -0,0 +1,300 @@
+///////////////////////////////////////////////////////////////////////////////
+// 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; 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 := KEYBOARD;
+
+ - bibliography:="http://www.lisaac.org";
+ - author :="Boutet Jerome (pisteur at free.fr),Sonntag Benoit (benoit.sonntag at lisaac.org)";
+ - comment :="Keyboard for X86 - AZERTY";
+
+ - date :="2003/04";
+
+Section Inherit
+
+ + parent_input_keyboard:Expanded INPUT_KEYBOARD;
+
+Section Private
+
+ - e_code:BOOLEAN; // TRUE If extended mode
+
+ // Lower case.
+ - cmin:STRING_CONSTANT := "\0d\&e\"\39d\(-e_ca)=\1d\\2d\azertyuiop^$\3d\^qsdfghjklmu2^*wxcvbn,;:!^*^ ";
+ // Upper case.
+ - cmaj:STRING_CONSTANT := "\0d\1234567890o+\1d\\2d\AZERTYUIOP\"L\3d\^QSDFGHJKLM%2^UWXCVBN?./S^*^ ";
+
+ - cmm:STRING_CONSTANT := "\27d\\8d\\9d\\13d\"; // 0:Echap 1:Del 2:Tab 3:Enter
+ - caltgr:STRING_CONSTANT := "'|~#{[|`\\^@]}";
+
+ // Num keyb.
+ - keynum0:STRING_CONSTANT := "789-456+1230."; // from 70-82
+ - keynum1:STRING_CONSTANT := "BUA\0d\LMR\0d\ELZIS"; // Without NumLock
+
+ // Extended keyboard from 88 to 102
+ - ext_key:STRING_CONSTANT := "\55d\\28d\\52d\\27d\\70d\\78d\\81d\\82d\\76d\\74d\\71d\\79d\\80d\\72d\\54d\";
+ - buf_extk:STRING_CONSTANT := "\13d\BEISRLUDZAH";
+
+Section Interrupt
+
+ //
+ // Get Character (Interrupt #21)
+ //
+
+ - get_scan <-
+ ( + scancode,cu,tmp:UINTEGER_8;
+
+ scancode:=SYSTEM.itemb 60h;
+ cu:=getcode (scancode-1);
+ (cu!=0).if {
+ // Routine Pour Reboot Violant : CTRL+(ALT | ALT Gr)+Suppr
+ ((cu=='S'.to_uinteger_8) && { ((cmd&0Fh)==0Dh) || {(cmd&0Fh)==0Bh} }).if {
+ "Reboot ...\n".print;
+ BIOS.call_interrupt 19h;
+ };
+
+ tmp:=(p_end+1)&003h;
+ buffer_event.item p_end.make ((cmd.to_uinteger_16<<8)|cu);
+ (((tmp+2)&3)!=p_beg).if {
+ p_end:=tmp;
+ };
+ };
+
+ SYSTEM.putb 20h to 20h;
+ );
+
+Section Public
+
+ - send_cmd (comm,dta:UINTEGER_8) <-
+ // Send a command to keyboard
+ (
+ // Empty buffer
+ { ((SYSTEM.itemb 64h) & 2) != 0}.while_do {
+ SYSTEM.itemb 60h;
+ };
+ // Send command
+ SYSTEM.putb comm to 60h;
+ // Waiting for answer
+ { ((SYSTEM.itemb 64h) & 1) == 0}.while_do {};
+ // Read answer
+ SYSTEM.itemb 60h;
+ // Send data
+ SYSTEM.putb dta to 60h;
+ // Waiting for answer
+ { ((SYSTEM.itemb 64h) & 1) == 0}.while_do {};
+ // Read answer
+ SYSTEM.itemb 60h;
+ );
+
+ - light <-
+ (
+ send_cmd (0EDh,(((cmd & 80h)>>7)|((cmd & 40h)>>5)|((cmd & 20h)>>3)));
+ );
+
+ /* // Now in lib
+ - keyup cu:UINTEGER_8 :UINTEGER_8 <-
+ ( + result:UINTEGER_8;
+ cmd := cmd & 0F7h; // Deactivate the cmd bit
+ //bin_code.put ((bin_code.item (cu>>3)) & ~(1<<(cu&7))) to (cu>>3);
+ // Analyze: for deactivate the cmd
+ ((cu == 28) || {cu == 89}).if {
+ //CTRL 1 or CTRL2
+ cmd := cmd & (~01h);
+ }.elseif { cu == 88 } then {
+ // Alt Gr
+ cmd := cmd & (~02h);
+ }.elseif { cu == 55 } then {
+ // Alt
+ cmd := cmd & (~04h);
+ result := ascii_code;
+ ascii_code := 0;
+ }.elseif { (cu == 41) || { cu == 53} } then {
+ // Shift 1 or Shift 2
+ cmd := cmd & (~10h);
+ };
+ result
+ );
+
+ - keydown cu:UINTEGER_8 :UINTEGER_8 <-
+ ( + cu2,result:UINTEGER_8;
+
+ //bin_code.put ((bin_code.item (cu>>3)) | (~(1<<(cu&7)))) to (cu>>3); // Activate key
+ // Analyze: for activate the cmd
+ ((cu == 28) || {cu == 89}).if {
+ //CTRL 1 or CTRL2
+ cmd := cmd | 01h;
+ }.elseif { cu == 88 } then {
+ // Alt Gr
+ cmd := cmd | 02h;
+ }.elseif { cu == 55 } then {
+ // Alt
+ cmd := cmd | 04h;
+ }.elseif { (cu == 41) || { cu == 53} } then {
+ // Shift 1 or Shift 2
+ cmd := cmd | 10h;
+ ((cmd & 20h)!=0).if {
+ cmd := cmd & (~20h);
+ light;
+ };
+ }.elseif { cu == 57 } then {
+ // Cap
+ cmd := cmd ^ 20h;
+ light;
+ }.elseif { cu == 68 } then {
+ // Num Lock
+ cmd := cmd ^ 40h;
+ light;
+ }.elseif { cu == 69 } then {
+ // Scroll Lock
+ cmd := cmd ^ 80h;
+ light;
+ }.elseif { cu<=56 } then {
+ (cu == 0).if {
+ // Esc
+ cmd := cmd | 08h;
+ result := cmm.item 1.to_uinteger_8;
+ }.elseif {((cmd&2)!=0) && {cu<=12}} then {
+ cmd := cmd & (~02h);
+ result := caltgr.item cu.to_uinteger_8;
+ } else {
+ ((cmd & 30h)==0).if {
+ cu2 := cmin.item (cu+1).to_uinteger_8;
+ } else {
+ cu2 := cmaj.item (cu+1).to_uinteger_8;
+ };
+ ((cu2 & 0FCh)!=0).if {
+ result := cu2;
+ } else {
+ cmd := cmd | 08h;
+ result := cmm.item (cu2+1).to_uinteger_8;
+ };
+ };
+ }.elseif {cu <= 67} then {
+ cmd := cmd | 08h; // F1 to F10 = cmd
+ result := cu+39; // 'a' to 'j'
+ }.elseif {cu < 85} then {
+ cu2 := keynum0.item (cu-69).to_uinteger_8;
+ (cu2 < 46).if {
+ result := cu2;
+ }.elseif {(cmd & 40h)!=0} then {
+ ((cmd & 04h)==0).if {
+ result := cu2;
+ } else {
+ ascii_code := (ascii_code*10)+(cu2-48);
+ };
+ } else {
+ cmd := cmd | 08h; // cmd
+ result := cu2;
+ };
+ }.elseif {cu==85} then {
+ ((cmd & 30h)==0).if {
+ result := '<'.to_uinteger_8;
+ } else {
+ result := '>'.to_uinteger_8;
+ };
+ }.elseif {cu<=87} then {
+ cmd := cmd |08h; // 'k' to 'l'
+ result := cu+21;
+ }.elseif {cu==90} then {
+ result := '/'.to_uinteger_8;
+ } else {
+ cmd := cmd | 08h;
+ result := buf_extk.item (cu-90).to_uinteger_8;
+ };
+ result
+ );
+
+ */
+
+ - getcode cu:UINTEGER_8 :UINTEGER_8 <-
+ // Translate Scan Code -> cmd.ASCII
+ ( + j:INTEGER;
+ + result:UINTEGER_8;
+ (! e_code).if {
+ // Non extended keys
+ (cu==(0E0h-1)).if {
+ e_code := TRUE; // Extended Code
+ } else {
+ ((cu & 80h)==0).if {
+ result := keydown cu.to_uinteger_8;
+ } else {
+ result := keyup (cu & 07Fh).to_uinteger_8;
+ };
+ };
+ } else {
+ // Extended keys
+ (cu!=(0E0h-1)).if {
+ // not Pause
+ (cu !=41).if {
+ e_code := FALSE; // Deactivate extended code
+ (cu != 169).if {
+ {(ext_key.item (j+1).to_uinteger_8 != (cu & 07Fh)) && {j < 15}}.while_do {
+ j := j + 1;
+ };
+ (j < 15).if {
+ ((cu & 80h)==0).if {
+ result := keydown (88+j).to_uinteger_8;
+ } else {
+ result := keyup (88+j).to_uinteger_8;
+ };
+ };
+ };
+ };
+ };
+ };
+ result
+ );
+
+Section Public
+
+ - make <-
+ // Install keyboard.
+ (
+ parent_input_keyboard.make;
+ //
+ SYSTEM.new_interrupt get_scan to 21h;
+ SYSTEM.irq_on 1;
+ );
+
+ - get_key:UINTEGER_16 <-
+ // Use without interface running: text mode
+ ( + result:UINTEGER_16;
+ {p_beg = p_end}.while_do {};
+ result := buffer_event.item p_beg.key;
+ p_beg := (p_beg + 1) & 03h;
+ result
+ );
+
+ //
+ // Guru section.
+ //
+
+ - wait_key:UINTEGER_8 <-
+ // Hardware Wait key (for Debug system).
+ (
+ { }.do_while { (SYSTEM.itemb 60h & 80h) = 0 };
+ { }.do_while { (SYSTEM.itemb 60h & 80h) = 80h };
+ (SYSTEM.itemb 60h & 7Fh)-1
+ );
+/*
+ - acknowledge type:INPUT <-
+ (
+ ? {type = KEYBOARD};
+ p_beg := (p_beg+1) & 03h;
+ );
+*/
+
+
+
diff --git a/isaacos/x86/driver/mouse/mouse.li b/isaacos/x86/driver/mouse/mouse.li
new file mode 100755
index 0000000..7097a95
--- /dev/null
+++ b/isaacos/x86/driver/mouse/mouse.li
@@ -0,0 +1,341 @@
+///////////////////////////////////////////////////////////////////////////////
+// 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; 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 := MOUSE;
+
+ - comment := "Mouse driver - PS/2";
+ - bibliography:= "http://www.lisaac.org";
+ - author := "Benoit Sonntag (benoit.sonntag at lisaac.org), Jerome Boutet (pisteur at free.fr)";
+
+Section Inherit
+
+ + parent_input:Expanded INPUT;
+
+ + parent_window:Expanded AREA;
+
+Section Interrupt
+
+
+ - interrupt_2c <-
+ ( + stat,tmp:UINTEGER_8;
+ + dx ,dy, x_new, y_new:INTEGER;
+ + right_new,left_new:BOOLEAN;
+
+ // Read stat port.
+ stat:=SYSTEM.itemb 60h;
+ (((stat&00001000b)!=0) && {(stat&11000100b)=0}).if {
+
+ // Read dx.
+ wait_port;
+ dx:=SYSTEM.itemb 60h;
+ ((stat&00010000b)!=0).if {
+ dx := dx - 256;
+ };
+
+ // Read dy.
+ wait_port;
+ dy:=SYSTEM.itemb 60h;
+ ((stat&00100000b)!=0).if {
+ dy := dy - 256;
+ };
+
+ // Compute coord. with border test.
+ x_new := x_current + dx;
+ y_new := y_current - dy;
+ y_new := y_new.max y_minimum.min y_maximum;
+ x_new := x_new.max x_minimum.min x_maximum;
+
+ // Read Stat buttons.
+ left_new :=(stat&00000001b)!=0;
+ right_new:=(stat&00000010b)!=0;
+
+ tmp:=(p_end+1)&003h;
+ buffer_event.item p_end.make (x_new,y_new) button (left_new,right_new);
+
+ (((tmp+2)&3)!=p_beg).if {
+ p_end:=tmp;
+ };
+
+ // Update status.
+ x_current:=x_new;
+ y_current:=y_new;
+ right:=right_new;
+ left :=left_new;
+ };
+
+ flush_port;
+
+ // Acknowledge.
+ SYSTEM.putb 20h to 020h;
+ SYSTEM.putb 20h to 0A0h;
+ );
+
+Section Public
+
+ - x_minimum:INTEGER;
+ - x_maximum:INTEGER;
+
+ - y_minimum:INTEGER;
+ - y_maximum:INTEGER;
+
+ - x_current:INTEGER;
+ - y_current:INTEGER;
+
+ - right:BOOLEAN;
+ - left:BOOLEAN;
+
+Section Private
+
+ - wait_port <-
+ (
+ {}.do_while {(SYSTEM.itemb 064h & 1)=0};
+ );
+
+ - flush_port <-
+ (
+ {
+ SYSTEM.itemb 60h;
+ }.do_while {(SYSTEM.itemb 64h & 2)!=0};
+ );
+
+ - kbd_write cmd:UINTEGER_8 <-
+ (
+ flush_port;
+ SYSTEM.putb cmd to 64h;
+ );
+
+ - aux_write cmd:UINTEGER_8 error msg:ABSTRACT_STRING <-
+ // Result: FAh Ack, or FEh resend
+ (
+ kbd_write 0D4h;
+ flush_port;
+ SYSTEM.putb cmd to 60h;
+ wait_port;
+ (SYSTEM.itemb 60h != 0FAh).if {
+ "MOUSE : ".print;
+ msg.print;
+ '\n'.print;
+ };
+ );
+
+ - kbd_write_plus cmd:UINTEGER_8 <-
+ (
+ kbd_write 060h;
+ flush_port;
+ SYSTEM.putb cmd to 60h;
+ flush_port;
+ );
+
+Section Private
+
+ - buffer_event:FAST_ARRAY(EVENT_MOUSE);
+ - p_beg:UINTEGER_8; // Pointer on the buffer (beginning)
+ - p_end:UINTEGER_8; // Pointer on the buffer (end)
+
+Section Public
+
+ //
+ // Creation / Initialisation.
+ //
+
+ - make <-
+ ( + new_event:EVENT_MOUSE;
+ is_actif := TRUE;
+ //
+ // Mouse hardware configuration.
+ //
+ x_maximum := VIDEO.x_max;
+ y_maximum := VIDEO.y_max;
+
+ // Bit 0=1 : Enable IRQ01
+ // Bit 1=1 : Enable IRQ12
+ // Bit 4=0 : Not Disable Keyboard.
+ // Bit 5=0 : Not Disable Aux.
+ kbd_write_plus 047h;
+ kbd_write 0A8h; // Enable mouse interface
+
+ // Init device.
+ aux_write 0F4h error "Init device fail"; // Enable aux device
+
+ // Set Rate.
+ aux_write 0F3h error "Set rate fail!"; // Set sample rate (Result:FAh Ack, or FEh resend)
+ aux_write 100d error "Set rate fail!"; // 100 echantillons par seconde (Result:FAh Ack, or FEh resend)
+
+ // Resolution.
+ aux_write 0E8h error "Set resolution fail!"; // Set resolution
+ aux_write 003d error "Set resolution fail!"; // 8 pas par mm
+
+ // Scalling.
+ aux_write 0E7h error "Set scaling fail!"; // Set 2:1 scaling
+
+ //
+ // Software configuration.
+ //
+ buffer_event := FAST_ARRAY(EVENT_MOUSE).create 4;
+ 0.to 3 do { j:INTEGER;
+ new_event := EVENT_MOUSE.clone;
+ buffer_event.put new_event to j;
+ (j != 0).if {
+ new_event.set_prev (buffer_event.item (j-1));
+ };
+ };
+ buffer_event.first.set_prev new_event;
+
+ mask := FAST_ARRAY(UINTEGER_16).create 16;
+ make (DESK.physical_screen) from (x_current,y_current) size (16,16);
+
+ SYSTEM.new_interrupt interrupt_2c to 2Ch;
+ SYSTEM.irq_on 12; // Active IRQ12
+ );
+
+ - get_event <-
+ ( + p:INTEGER;
+ + evt:EVENT_MOUSE;
+
+ p := p_beg;
+ (p != p_end).if {
+ ((x_current != x_window) || {y_current != y_window}).if {
+ set_position (x_current,y_current);
+ };
+ { p != p_end }.while_do {
+ evt := buffer_event.item p;
+ (list_client.lower).to (list_client.upper) do { j:INTEGER;
+ list_client.item j.receive (buffer_event.item p);
+ };
+ p := (p + 1) & 03h;
+ };
+ };
+ );
+
+ - acknowledge <-
+ (
+ p_beg := (p_beg+1) & 03h;
+ );
+
+ //
+ // Display.
+ //
+
+ // BSBS: A refaire avec une bitmap en dehors contenant le dessin avec une couleur de mask!!
+ // Plus simple, plus puissant, plus rapide !
+
+ + mask:FAST_ARRAY(UINTEGER_16);
+
+ - pixel_hard (x,y:INTEGER) color col:UINTEGER_32<-
+ ( + m:UINTEGER_16;
+ ? {x<16};
+ ? {y<16};
+
+ m:=mask.item y;
+ m:=m | (1<<x);
+ mask.put m to y;
+
+ parent_window.pixel_hard (x,y) color col;
+ );
+
+ - line_h_hard (x0,y0:INTEGER) until x1:INTEGER color col:UINTEGER_32<-
+ ( + m:UINTEGER_16;
+ ? {x0<16};
+ ? {y0<16};
+ ? {x1<16};
+
+ m:=mask.item y0;
+ x0.to x1 do { xx:INTEGER;
+ m:=m | (1<<xx);
+ };
+
+ mask.put m to y0;
+ parent_window.line_h_hard (x0,y0) until x1 color col;
+ );
+
+ - slave_pixel_hard (x,y:INTEGER) color col:UINTEGER_32<-
+ ( + m:UINTEGER_16;
+
+ m:=mask.item y;
+ ((m & (1<<x))=0).if {
+ parent_window.pixel_hard (x,y) color col;
+ };
+ );
+
+ - slave_line_h_hard (x1,y:INTEGER) until x2:INTEGER color col:UINTEGER_32<-
+ ( + m:UINTEGER_16;
+
+ m:=mask.item y;
+ x1.to x2 do { xx:INTEGER;
+ ((m & (1<<xx))=0).if {
+ parent_window.pixel_hard (xx,y) color col;
+ };
+ };
+ );
+
+ - slave_line_h_hard (x1,y:INTEGER) until x2:INTEGER image line:ABSTRACT_BMP_LINE offset ofs:INTEGER <-
+ ( + m:UINTEGER_16;
+ + col:UINTEGER_32;
+ + ofs_img:INTEGER;
+ ofs_img := ofs;
+ m:=mask.item y;
+ x1.to x2 do { xx:INTEGER;
+ ((m & (1<<xx))=0).if {
+ col := line.get_color ofs_img;
+ parent_window.pixel_hard (xx,y) color col;
+ };
+ ofs_img := ofs_img + 1;
+ };
+ );
+
+ - draw (x0,y0:INTEGER) to (x1,y1:INTEGER) <-
+ (
+ clipping (x0,y0) to (x1,y1);
+
+ color white;
+ poly_move_to (1,1);
+ poly_line_to (9,9);
+ poly_line_to (6,9);
+ poly_line_to (8,14);
+ poly_line_to (5,14);
+ poly_line_to (5,9);
+ poly_line_to (1,9);
+ poly_move_to (1,1);
+ poly_trace;
+
+ color red;
+ line_v (0,0) until 10;
+ line_h (1,10) until 4;
+ line_v (4,11) until 15;
+ line_h (5,15) until 9;
+ line (9,15) to (7,10);
+ line_h (7,10) until 10;
+ line (1,0) to (10,9);
+ );
+
+ - get_object (x,y:INTEGER) :AREA <-
+ (
+ NULL
+ );
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/isaacos/x86/driver/video/mode_info.li b/isaacos/x86/driver/video/mode_info.li
new file mode 100755
index 0000000..3c49b0b
--- /dev/null
+++ b/isaacos/x86/driver/video/mode_info.li
@@ -0,0 +1,226 @@
+///////////////////////////////////////////////////////////////////////////////
+// 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; 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 := MODE_INFO;
+
+ - comment := "Mapping mode info structure";
+
+ - bibliography:= "http://www.lisaac.org";
+ - author := "Benoit Sonntag (benoit.sonntag at lisaac.org), Jerome Boutet (pisteur at free.fr)";
+
+Section Inherit
+
+ - parent_object:OBJECT := OBJECT;
+
+Section Mapping
+
+ + map_mode_attributes:UINTEGER_16;
+ + win_a_attributes:UINTEGER_8;
+ + win_b_attributes:UINTEGER_8;
+ + win_granularity:UINTEGER_16;
+ + win_size:UINTEGER_16;
+ + win_a_segment:UINTEGER_16;
+ + win_b_segment:UINTEGER_16;
+ + win_func_ptr:UINTEGER_32;
+ + map_bytes_per_scan_line:UINTEGER_16;
+ + map_x_resolution:UINTEGER_16;
+ + map_y_resolution:UINTEGER_16;
+ + x_char_size:UINTEGER_8;
+ + y_char_size:UINTEGER_8;
+ + map_number_of_planes:UINTEGER_8;
+ + map_bits_per_pixel:UINTEGER_8;
+ + number_of_banks:UINTEGER_8;
+ + map_memory_model:UINTEGER_8;
+ + bank_size:UINTEGER_8;
+ + number_of_image_pages:UINTEGER_8;
+ + reserved_page:UINTEGER_8;
+ + map_red_mask_size:UINTEGER_8;
+ + map_red_mask_pos:UINTEGER_8;
+ + map_green_mask_size:UINTEGER_8;
+ + map_green_mask_pos:UINTEGER_8;
+ + map_blue_mask_size:UINTEGER_8;
+ + map_blue_mask_pos:UINTEGER_8;
+ + reserved_mask_size:UINTEGER_8;
+ + reserved_mask_pos:UINTEGER_8;
+ + direct_color_mode_info:UINTEGER_8;
+ // VBE 2.0 extensions
+ + map_phys_base_ptr:UINTEGER_32;
+ + off_screen_mem_offset:UINTEGER_32;
+ + off_screen_mem_size:UINTEGER_16;
+ // VBE 3.0 extensions
+ + lin_bytes_per_scan_line:UINTEGER_16;
+ + bnk_number_of_pages:UINTEGER_8;
+ + lin_number_of_pages:UINTEGER_8;
+ + lin_red_mask_size:UINTEGER_8;
+ + lin_red_field_pos:UINTEGER_8;
+ + lin_green_mask_size:UINTEGER_8;
+ + lin_green_field_pos:UINTEGER_8;
+ + lin_blue_mask_size:UINTEGER_8;
+ + lin_blue_field_pos:UINTEGER_8;
+ + lin_rsvd_mask_size:UINTEGER_8;
+ + lin_rsvd_field_pos:UINTEGER_8;
+ + max_pixel_clock:UINTEGER_32;
+
+ + reserved_00:UINTEGER_64; // char[190]
+ + reserved_01:UINTEGER_64;
+ + reserved_02:UINTEGER_64;
+ + reserved_03:UINTEGER_64;
+ + reserved_04:UINTEGER_64;
+ + reserved_05:UINTEGER_64;
+ + reserved_06:UINTEGER_64;
+ + reserved_07:UINTEGER_64;
+ + reserved_08:UINTEGER_64;
+ + reserved_09:UINTEGER_64;
+ + reserved_10:UINTEGER_64;
+ + reserved_11:UINTEGER_64;
+ + reserved_12:UINTEGER_64;
+ + reserved_13:UINTEGER_64;
+ + reserved_14:UINTEGER_64;
+ + reserved_15:UINTEGER_64;
+ + reserved_16:UINTEGER_64;
+ + reserved_17:UINTEGER_64;
+ + reserved_18:UINTEGER_64;
+ + reserved_19:UINTEGER_64;
+ + reserved_20:UINTEGER_64;
+ + reserved_21:UINTEGER_64;
+ + reserved_22:UINTEGER_64;
+ + reserved_23:UINTEGER_32;
+ + reserved_24:UINTEGER_16;
+
+Section Public
+
+ - make buf:NATIVE_ARRAY(UINTEGER_8) <-
+ ( + tab:NATIVE_ARRAY(UINTEGER_8);
+ ? {object_size<=512};
+
+ tab := CONVERT(MODE_INFO,NATIVE_ARRAY(UINTEGER_8)).on Self;
+ tab.copy buf to 0 until (object_size);
+ );
+
+ - mode_attributes:UINTEGER_16 <- map_mode_attributes;
+ - number_of_planes:UINTEGER_8 <- map_number_of_planes;
+ - bits_per_pixel:UINTEGER_8 <- map_bits_per_pixel;
+ - x_resolution:UINTEGER_16 <- map_x_resolution;
+ - memory_model:UINTEGER_8 <- map_memory_model;
+ - y_resolution:UINTEGER_16 <- map_y_resolution;
+ - phys_base_ptr:UINTEGER_32 <- map_phys_base_ptr;
+ - bytes_per_scan_line:UINTEGER_16 <- map_bytes_per_scan_line;
+ - red_mask_size:UINTEGER_8 <- map_red_mask_size;
+ - red_mask_pos:UINTEGER_8 <- map_red_mask_pos;
+ - green_mask_size:UINTEGER_8 <- map_green_mask_size;
+ - green_mask_pos:UINTEGER_8 <- map_green_mask_pos;
+ - blue_mask_size:UINTEGER_8 <- map_blue_mask_size;
+ - blue_mask_pos:UINTEGER_8 <- map_blue_mask_pos;
+
+ - print <-
+ (
+ "mode attributes\t:".print;
+ map_mode_attributes.print; '\n'.print;
+ "win a attributes\t:".print;
+ win_a_attributes.print; '\n'.print;
+ "win_b_attributes\t".print;
+ win_b_attributes.print; '\n'.print;
+ "win_granularity\t".print;
+ win_granularity.print; '\n'.print;
+ "win_size\t".print;
+ win_size.print; '\n'.print;
+ "win_a_segment\t".print;
+ win_a_segment.print; '\n'.print;
+ "win_b_segment\t".print;
+ win_b_segment.print; '\n'.print;
+ "win_func_ptr\t".print;
+ win_func_ptr.print; '\n'.print;
+ "map_bytes_per_scan_line\t".print;
+ map_bytes_per_scan_line.print; '\n'.print;
+ "map_x_resolution\t".print;
+ map_x_resolution.print; '\n'.print;
+ KEYBOARD.wait_key;
+ "map_y_resolution\t".print;
+ map_y_resolution.print; '\n'.print;
+ "x_char_size\t".print;
+ x_char_size.print; '\n'.print;
+ "y_char_size\t".print;
+ y_char_size.print; '\n'.print;
+ "map_number_of_planes\t".print;
+ map_number_of_planes.print; '\n'.print;
+ "map_bits_per_pixel\t".print;
+ map_bits_per_pixel.print; '\n'.print;
+ "number_of_banks\t".print;
+ number_of_banks.print; '\n'.print;
+ "map_memory_model\t".print;
+ map_memory_model.print; '\n'.print;
+ "bank_size\t".print;
+ KEYBOARD.wait_key;
+ bank_size.print; '\n'.print;
+ "number_of_image_pages\t".print;
+ number_of_image_pages.print; '\n'.print;
+ "reserved_page\t".print;
+ reserved_page.print; '\n'.print;
+ "map_red_mask_size\t".print;
+ map_red_mask_size.print; '\n'.print;
+ "map_red_mask_pos\t".print;
+ map_red_mask_pos.print; '\n'.print;
+ "map_green_mask_size\t".print;
+ map_green_mask_size.print; '\n'.print;
+ "map_green_mask_pos\t".print;
+ map_green_mask_pos.print; '\n'.print;
+ "map_blue_mask_size\t".print;
+ map_blue_mask_size.print; '\n'.print;
+ "map_blue_mask_pos\t".print;
+ map_blue_mask_pos.print; '\n'.print;
+ KEYBOARD.wait_key;
+ "reserved_mask_size\t".print;
+ reserved_mask_size.print; '\n'.print;
+ "reserved_mask_pos\t".print;
+ reserved_mask_pos.print; '\n'.print;
+ "direct_color_mode_info\t".print;
+ direct_color_mode_info.print; '\n'.print;
+ // VBE 2.0 extensions
+ "map_phys_base_ptr\t".print;
+ map_phys_base_ptr.print; '\n'.print;
+ "off_screen_mem_offset\t".print;
+ off_screen_mem_offset.print; '\n'.print;
+ "off_screen_mem_size\t".print;
+ off_screen_mem_size.print; '\n'.print;
+ // VBE 3.0 extensions
+ "lin_bytes_per_scan_line\t".print;
+ lin_bytes_per_scan_line.print; '\n'.print;
+ "bnk_number_of_pages\t".print;
+ bnk_number_of_pages.print; '\n'.print;
+ "lin_number_of_pages\t".print;
+ lin_number_of_pages.print; '\n'.print;
+ KEYBOARD.wait_key;
+ "lin_red_mask_size\t".print;
+ lin_red_mask_size.print; '\n'.print;
+ "lin_red_field_pos\t".print;
+ lin_red_field_pos.print; '\n'.print;
+ "lin_green_mask_size\t".print;
+ lin_green_mask_size.print; '\n'.print;
+ "lin_green_field_pos\t".print;
+ lin_green_field_pos.print; '\n'.print;
+ "lin_blue_mask_size\t".print;
+ lin_blue_mask_size.print; '\n'.print;
+ "lin_blue_field_pos\t".print;
+ lin_blue_field_pos.print; '\n'.print;
+ "lin_rsvd_mask_size\t".print;
+ lin_rsvd_mask_size.print; '\n'.print;
+ "lin_rsvd_field_pos\t".print;
+ lin_rsvd_field_pos.print; '\n'.print;
+ "max_pixel_clock\t".print;
+ max_pixel_clock.print; '\n'.print;
+
+);
diff --git a/isaacos/x86/driver/video/vesa_info.li b/isaacos/x86/driver/video/vesa_info.li
new file mode 100755
index 0000000..dc594ac
--- /dev/null
+++ b/isaacos/x86/driver/video/vesa_info.li
@@ -0,0 +1,142 @@
+///////////////////////////////////////////////////////////////////////////////
+// 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; 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 := VESA_INFO;
+
+ - comment := "Mapping vesa info structure";
+
+ - bibliography:= "http://www.lisaac.org";
+ - author := "Benoit Sonntag (benoit.sonntag at lisaac.org), Jerome Boutet (pisteur at free.fr)";
+
+Section Inherit
+
+ - parent_object:OBJECT := OBJECT;
+
+Section Mapping
+
+ + vesa_signature:UINTEGER_32; // char[4]
+ + map_vesa_version:UINTEGER_16;
+ + oem_string_ptr:UINTEGER_32;
+ + capabilities:UINTEGER_32; // char [4]
+ + map_video_mode_ptr:UINTEGER_32;
+ + total_memory:UINTEGER_16; // En Bloc de 64Ko.
+ + oem_software_rev:UINTEGER_16;
+ + oem_vendor_name_ptr:UINTEGER_32;
+ + oem_product_name_ptr:UINTEGER_32;
+ + oem_product_rev_ptr:UINTEGER_32;
+
+ + reserved_00:UINTEGER_64; // char[222]
+ + reserved_01:UINTEGER_64;
+ + reserved_02:UINTEGER_64;
+ + reserved_03:UINTEGER_64;
+ + reserved_04:UINTEGER_64;
+ + reserved_05:UINTEGER_64;
+ + reserved_06:UINTEGER_64;
+ + reserved_07:UINTEGER_64;
+ + reserved_08:UINTEGER_64;
+ + reserved_09:UINTEGER_64;
+ + reserved_10:UINTEGER_64;
+ + reserved_11:UINTEGER_64;
+ + reserved_12:UINTEGER_64;
+ + reserved_13:UINTEGER_64;
+ + reserved_14:UINTEGER_64;
+ + reserved_15:UINTEGER_64;
+ + reserved_16:UINTEGER_64;
+ + reserved_17:UINTEGER_64;
+ + reserved_18:UINTEGER_64;
+ + reserved_19:UINTEGER_64;
+ + reserved_20:UINTEGER_64;
+ + reserved_21:UINTEGER_64;
+ + reserved_22:UINTEGER_64;
+ + reserved_23:UINTEGER_64;
+ + reserved_24:UINTEGER_64;
+ + reserved_25:UINTEGER_64;
+ + reserved_26:UINTEGER_64;
+ + reserved_27:UINTEGER_32;
+ + reserved_28:UINTEGER_16;
+
+ + oem_data_00:UINTEGER_64; // char[256]
+ + oem_data_01:UINTEGER_64;
+ + oem_data_02:UINTEGER_64;
+ + oem_data_03:UINTEGER_64;
+ + oem_data_04:UINTEGER_64;
+ + oem_data_05:UINTEGER_64;
+ + oem_data_06:UINTEGER_64;
+ + oem_data_07:UINTEGER_64;
+ + oem_data_08:UINTEGER_64;
+ + oem_data_09:UINTEGER_64;
+ + oem_data_10:UINTEGER_64;
+ + oem_data_11:UINTEGER_64;
+ + oem_data_12:UINTEGER_64;
+ + oem_data_13:UINTEGER_64;
+ + oem_data_14:UINTEGER_64;
+ + oem_data_15:UINTEGER_64;
+ + oem_data_16:UINTEGER_64;
+ + oem_data_17:UINTEGER_64;
+ + oem_data_18:UINTEGER_64;
+ + oem_data_19:UINTEGER_64;
+ + oem_data_20:UINTEGER_64;
+ + oem_data_21:UINTEGER_64;
+ + oem_data_22:UINTEGER_64;
+ + oem_data_23:UINTEGER_64;
+ + oem_data_24:UINTEGER_64;
+ + oem_data_25:UINTEGER_64;
+ + oem_data_26:UINTEGER_64;
+ + oem_data_27:UINTEGER_64;
+ + oem_data_28:UINTEGER_64;
+ + oem_data_29:UINTEGER_64;
+ + oem_data_30:UINTEGER_64;
+ + oem_data_31:UINTEGER_64;
+
+Section Public
+
+ - make buf:NATIVE_ARRAY(UINTEGER_8) <-
+ ( + tab:NATIVE_ARRAY(UINTEGER_8);
+ ? {object_size<=512};
+
+ tab := CONVERT(VESA_INFO,NATIVE_ARRAY(UINTEGER_8)).on Self;
+ tab.copy buf to 0 until object_size;
+ );
+
+ - vesa_version:UINTEGER_16 <- map_vesa_version;
+ - video_mode_ptr:UINTEGER_32 <- map_video_mode_ptr;
+
+
+ - print <-
+ (
+ "vesa_signature\t".print;
+ vesa_signature.print;'\n'.print; // char[4]
+ "map_vesa_version\t".print;
+ map_vesa_version.print;'\n'.print;
+ "oem_string_ptr\t".print;
+ oem_string_ptr.print;'\n'.print;
+ "capabilities\t".print;
+ capabilities.print;'\n'.print;
+ "map_video_mode_ptr\t".print;
+ map_video_mode_ptr.print;'\n'.print;
+ "total_memory\t".print;
+ total_memory.print;'\n'.print;
+ "oem_software_rev\t".print;
+ oem_software_rev.print;'\n'.print;
+ "oem_vendor_name_ptr\t".print;
+ oem_vendor_name_ptr.print;'\n'.print;
+ "oem_product_name_ptr\t".print;
+ oem_product_name_ptr.print;'\n'.print;
+ "oem_product_rev_ptr\t".print;
+ oem_product_rev_ptr.print;'\n'.print;
+
+ );
diff --git a/isaacos/x86/driver/video/video.li b/isaacos/x86/driver/video/video.li
new file mode 100755
index 0000000..ab3c6c6
--- /dev/null
+++ b/isaacos/x86/driver/video/video.li
@@ -0,0 +1,260 @@
+///////////////////////////////////////////////////////////////////////////////
+// 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; 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 := VIDEO;
+
+ - comment := "Driver video - standard VESA 2.0 Linear -";
+
+// - category := MICRO;
+
+ - bibliography:= "http://www.lisaac.org";
+ - author := "Benoit Sonntag (benoit.sonntag at lisaac.org), Jerome Boutet (pisteur at free.fr)";
+
+Section Inherit
+
+ - parent_bitmap_bug:ABSTRACT_BITMAP := ABSTRACT_BITMAP;
+ //- parent_bitmap:BITMAP := BITMAP;
+
+Section Public
+
+ - get_abstract_bitmap:ABSTRACT_BITMAP;
+
+ - get_y_line y:INTEGER :ABSTRACT_BMP_LINE <-
+ (
+ get_abstract_bitmap.get_y_line y
+ );
+
+ - is_active:BOOLEAN <- (current_mode != 0);
+
+ + horizontal_dpi:INTEGER := 72;
+ + vertical_dpi:INTEGER := 72;
+
+ + screen_width:REAL_24_8 := 12; // 12 Inch
+ + screen_height:REAL_24_8 := 8; // 8 Inch
+
+ + mode_list:FAST_ARRAY(UINTEGER_16);
+
+ + current_mode:UINTEGER_16;
+
+ - load_mode mode:UINTEGER_16 <-
+ // Get Information Vesa mode. (update MODE_INFO)
+ (
+ BIOS.clear_buffer;
+ REGISTER.set_ax 4F01h;
+ REGISTER.set_cx mode;
+ REGISTER.set_es (BIOS.segment_buffer);
+ REGISTER.set_di (BIOS.offset_buffer);
+ BIOS.call_interrupt 10h;
+ MODE_INFO.make (BIOS.buffer);
+ );
+
+ - init_mode mode:UINTEGER_16 <-
+ ( + addr,size:UINTEGER_32;
+// + new_bmp:BITMAP;
+ + is_ok:BOOLEAN;
+
+ current_mode:=mode;
+
+ // Get info mode.
+ load_mode mode;
+
+ // Allocation video Linear memory.
+ addr:=MODE_INFO.phys_base_ptr;
+
+ size:=MODE_INFO.y_resolution * MODE_INFO.bytes_per_scan_line;
+// MEMORY.allocation_reserved addr to (addr+size-1);
+
+ // Init physical video mode.
+ REGISTER.set_ax 04F02h;
+ REGISTER.set_bx (mode | 4000h); // Mode linear.
+ BIOS.call_interrupt 10h;
+ `___video_text = 0`;
+
+ // Choix de l'objet parent :
+ MODE_INFO.bits_per_pixel
+ .when 15 to 16 then {
+ ((MODE_INFO.red_mask_size = 5) &&
+ {MODE_INFO.red_mask_pos =10} &&
+ {MODE_INFO.green_mask_size= 5} &&
+ {MODE_INFO.green_mask_pos = 5} &&
+ {MODE_INFO.blue_mask_size = 5} &&
+ {MODE_INFO.blue_mask_pos = 0}).if {
+ get_abstract_bitmap:=parent_bitmap_bug := BITMAP(PIXEL_15).create ((MODE_INFO.x_resolution),(MODE_INFO.y_resolution)) at addr bytes_per_line (MODE_INFO.bytes_per_scan_line);
+ is_ok:=TRUE;
+ } else {
+ ((MODE_INFO.red_mask_size = 5) &&
+ {MODE_INFO.red_mask_pos =11} &&
+ {MODE_INFO.green_mask_size= 6} &&
+ {MODE_INFO.green_mask_pos = 5} &&
+ {MODE_INFO.blue_mask_size = 5} &&
+ {MODE_INFO.blue_mask_pos = 0}).if {
+ get_abstract_bitmap:=parent_bitmap_bug := BITMAP(PIXEL_16).create ((MODE_INFO.x_resolution),(MODE_INFO.y_resolution)) at addr bytes_per_line (MODE_INFO.bytes_per_scan_line);
+ is_ok:=TRUE;
+ };
+ };
+ }
+ .when 24 then {
+ ((MODE_INFO.red_mask_size = 8) &&
+ {MODE_INFO.red_mask_pos =16} &&
+ {MODE_INFO.green_mask_size= 8} &&
+ {MODE_INFO.green_mask_pos = 8} &&
+ {MODE_INFO.blue_mask_size = 8} &&
+ {MODE_INFO.blue_mask_pos = 0}).if {
+ get_abstract_bitmap:=parent_bitmap_bug := BITMAP(PIXEL_24).create ((MODE_INFO.x_resolution),(MODE_INFO.y_resolution)) at addr bytes_per_line (MODE_INFO.bytes_per_scan_line);
+ is_ok:=TRUE;
+ };
+ }
+ .when 32 then {
+ (
+ (MODE_INFO.red_mask_size = 8) &&
+ {MODE_INFO.red_mask_pos =16} &&
+ {MODE_INFO.green_mask_size = 8} &&
+ {MODE_INFO.green_mask_pos = 8} &&
+ {MODE_INFO.blue_mask_size = 8} &&
+ {MODE_INFO.blue_mask_pos = 0}
+ ).if {
+ get_abstract_bitmap := parent_bitmap_bug := BITMAP(PIXEL_32).create
+ ((MODE_INFO.x_resolution),(MODE_INFO.y_resolution)) at addr
+ bytes_per_line (MODE_INFO.bytes_per_scan_line);
+ is_ok:=TRUE;
+ };
+ };
+
+ // On initialise la bitmap :
+ (! is_ok).if {
+ crash_with_message "Error VESA : Mode 16bits not supported.";
+ };
+
+
+// parent_bitmap_bug := BITMAP_24.create (MODE_INFO.x_resolution),(MODE_INFO.y_resolution) at addr bytes_per_line (MODE_INFO.bytes_per_scan_line);
+
+// make (MODE_INFO.x_resolution),(MODE_INFO.y_resolution) at addr bytes_per_line (MODE_INFO.bytes_per_scan_line);
+
+ //horizontal_dpi:=MODE_INFO.x_resolution.to_real_24_8/screen_width;
+ //vertical_dpi :=MODE_INFO.y_resolution.to_real_24_8/screen_height;
+ );
+
+ - auto_make <-
+ ( + mode:NATIVE_ARRAY(UINTEGER_16);
+ + pos,j:INTEGER;
+ + mode_index:INTEGER;
+
+ BIOS.clear_buffer;
+
+ // Load information Vasa Card.
+ BIOS.buffer.put ('V'.to_uinteger_8) to 0;
+ BIOS.buffer.put ('B'.to_uinteger_8) to 1;
+ BIOS.buffer.put ('E'.to_uinteger_8) to 2;
+ BIOS.buffer.put ('2'.to_uinteger_8) to 3;
+
+ // Call Interrupt.
+ REGISTER.set_es (BIOS.segment_buffer);
+ REGISTER.set_di (BIOS.offset_buffer);
+ REGISTER.set_ax 4F00h;
+ BIOS.call_interrupt 10h;
+
+ // Get VESA Information.
+
+ VESA_INFO.make (BIOS.buffer);
+ (VESA_INFO.vesa_version < 200h).if {
+ // Version very old !
+ crash_with_message "Error VESA : Old Version.";
+ };
+ // Get VIDEO mode list.
+ mode := CONVERT(UINTEGER_32,NATIVE_ARRAY(UINTEGER_16)).on (BIOS.get_address (VESA_INFO.video_mode_ptr));
+ mode_list:=FAST_ARRAY(UINTEGER_16).create_with_capacity 256;
+
+ pos:=0;
+ {mode.item pos != 0FFFFh}.while_do {
+ mode_list.add_last (mode.item pos);
+ pos:=pos+1;
+ };
+
+ // Search good mode.
+ j:=mode_list.lower;
+ {j<=mode_list.upper}.while_do {
+ load_mode (mode_list.item j);
+ (
+ ((MODE_INFO.mode_attributes & 25)=25) &&
+ {MODE_INFO.number_of_planes=1} &&
+ {MODE_INFO.bits_per_pixel>=15} &&
+ {MODE_INFO.bits_per_pixel<=32} &&
+ {MODE_INFO.x_resolution>640} &&
+ {(MODE_INFO.memory_model=4) || {MODE_INFO.memory_model=6}}
+ ).if {
+ ('a'+j.to_character).print;
+ '-'.print;
+ MODE_INFO.x_resolution.print;
+ 'x'.print;
+ MODE_INFO.y_resolution.print;
+ 'x'.print;
+ MODE_INFO.bits_per_pixel.print;
+ '\n'.print;
+ j:=j+1;
+ } else {
+ mode_list.remove j;
+ };
+ };
+ (mode_list.is_empty).if {
+ crash_with_message "Error VESA : Mode 800x600x15bits or superior not supported.";
+ };
+
+ { + car:CHARACTER;
+ "Active mode: ".print;
+ {
+ car := KEYBOARD.getcode (KEYBOARD.wait_key).to_character;
+ car.print;
+ }.do_until {car.in_range 'a' to 'z'};
+ mode_index := car -! 'a';
+ /*
+ mode_index.print;
+ '\n'.print;
+ KEYBOARD.wait_key;
+ */
+ }.do_until {mode_index.in_range (mode_list.lower) to (mode_list.upper)};
+
+ //mode_index := 3;
+ //mode_index.print;
+
+ "\nPress key for start...\n".print;
+ KEYBOARD.wait_key;
+ //
+
+ init_mode (mode_list.item mode_index);
+
+ );
+
+ - message st:ABSTRACT_STRING <-
+ (
+ close;
+ st.print;
+ die_with_code 0;
+ );
+
+ - close <-
+ ( ? {is_active};
+
+ current_mode := 0;
+ `___video_text = 1`;
+
+ // Init physical text mode.
+ REGISTER.set_ax 03h;
+ BIOS.call_interrupt 10h;
+
+ ? {! is_active};
+ );
+
diff --git a/isaacos/x86/memory/virtual_memory.li b/isaacos/x86/memory/virtual_memory.li
new file mode 100644
index 0000000..d0892f6
--- /dev/null
+++ b/isaacos/x86/memory/virtual_memory.li
@@ -0,0 +1,135 @@
+///////////////////////////////////////////////////////////////////////////////
+// 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; 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 := VIRTUAL_MEMORY;
+
+ - copyright := "2003-2008 Sonntag Benoit";
+
+ - author := "Sonntag Benoit (benoit.sonntag at lisaac.org)";
+ - comment := "Virtual memory manager";
+
+Section Inherit
+
+ + parent_memory:Expanded MEMORY;
+
+Section MEMORY
+
+ - page:NATIVE_ARRAY(POINTER) <- CONVERT(POINTER,NATIVE_ARRAY(POINTER)).on get_adress_page;
+
+ - physical_capacity:UINTEGER_64;
+
+ - set_adress_page adr:POINTER <-
+ (
+ `asm("movl %0,%%eax\n\
+ movl %%eax,%%cr3": :"m"(@adr) :"eax")`;
+ );
+
+ - get_adress_page:POINTER <-
+ ( + result:POINTER;
+
+ `asm("movl %%cr3,%%eax\n\
+ movl %%eax,%0":"=m"(@result): :"eax")`;
+ result
+ );
+
+
+ - search_capacity <-
+ ( + addr:UINTEGER_32;
+ + idx:INTEGER;
+
+ parent_memory.search_capacity;
+ physical_capacity := capacity_max;
+ capacity_max := 4.to_uinteger_64.gb;
+ set_adress_page begin_memory;
+ // set page directory
+ {(begin_memory /* +# 100.mb */) ># (addr & 0FFC0_0000h)}.while_do {
+ page.put ((begin_memory + (idx+1)*4.kb)| 3 ) to idx;
+ idx := idx + 1;
+ addr := addr + 4.mb;
+ };
+ { idx & 1023 != 0 }.while_do {
+ page.put 0 to idx;
+ idx := idx + 1;
+ };
+ addr := 0;
+ // set page table
+ { (begin_memory /* +# 100.mb */) ># (addr & 0FFFF_F000h)}.while_do {
+ page.put (addr | 3) to idx;
+ idx := idx + 1;
+ addr := addr + 4.kb;
+ };
+ { idx & 1023 != 0 }.while_do {
+ page.put 0 to idx;
+ idx := idx + 1;
+ };
+ begin_memory := begin_memory + 4.mb;
+ set_pagination;
+ SYSTEM.new_interrupt interrupt_0eh to 0Eh;
+ "Pagination ok\n".print;
+ // print;
+ KEYBOARD.wait_key;
+ );
+
+
+
+ - print <-
+ ( + ind:INTEGER;
+ "VIRTUAL MEMORY\n".print;
+ "address page : ".print;get_adress_page.print_hex;
+ "---dir---\n".print;
+ {page.item ind != NULL }.while_do {
+ page.item ind.print_hex;'\n'.print;
+ ind := ind +1;
+ };
+ '\n'.print;
+ ind := 1024;
+ "---table---\n".print;
+ {page.item ind != NULL }.while_do {
+ page.item ind.print_hex;'\n'.print;
+ ind := ind +1;
+ };
+ '\n'.print;
+
+ );
+
+ Section Public
+ - set_pagination <-
+ // Activation of pagination.
+ (
+ `asm("movl %%cr0,%%eax \n\
+ orl $0x80000000,%%eax\n\
+ movl %%eax,%%cr0": : :"eax")`;
+ );
+
+
+Section Interrupt
+
+ - interrupt_0eh <-
+ ( + page_need:POINTER;
+
+ "Defaut de page !\n".print;
+
+ `asm("movl %%cr2,%%eax\n\
+ movl %%eax,%0":"=m"(@page_need): :"eax")`;
+
+ "fait pètè la page : ".print;
+ page_need.print_hex;
+ '\n'.print;
+
+ {
+ }.loop_infinitely;
+ );
diff --git a/isaacos/x86/system/bios.li b/isaacos/x86/system/bios.li
new file mode 100755
index 0000000..3cefd10
--- /dev/null
+++ b/isaacos/x86/system/bios.li
@@ -0,0 +1,176 @@
+///////////////////////////////////////////////////////////////////////////////
+// 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; 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 := BIOS;
+
+ - bibliography:= "http://www.lisaac.org";
+ - author := "Boutet Jerome (pisteur at free.fr),Sonntag Benoit (benoit.sonntag at lisaac.org)";
+ - comment := "Bios service (IBM PC).";
+
+Section Private
+
+ // 2Kb Stack.
+ - stack:NATIVE_ARRAY(UINTEGER_16) := CONVERT(INTEGER,NATIVE_ARRAY(UINTEGER_16)).on 1800h; //580h;
+
+ - top_stack:INTEGER := 400h; // x 2 => 800h => 2Kb.
+
+ - push val:UINTEGER_16 <-
+ (
+ ? {top_stack != 0};
+ top_stack := top_stack - 1;
+ stack.put val to top_stack;
+ );
+
+ - pop:UINTEGER_16 <-
+ ( + result:UINTEGER_16;
+ ? {top_stack != 400h};
+
+ result:=stack.item top_stack;
+ top_stack := top_stack + 1;
+
+ result
+ );
+
+ - push_all <-
+ (
+ push (REGISTER.ax);
+ push (REGISTER.cx);
+ push (REGISTER.dx);
+ push (REGISTER.bx);
+ push 0; // SP
+ push (REGISTER.bp);
+ push (REGISTER.si);
+ push (REGISTER.di);
+ );
+
+ - pop_all <-
+ (
+ REGISTER.set_di pop;
+ REGISTER.set_si pop;
+ REGISTER.set_bp pop;
+ pop; // SP
+ REGISTER.set_bx pop;
+ REGISTER.set_dx pop;
+ REGISTER.set_cx pop;
+ REGISTER.set_ax pop;
+ );
+
+Section Public
+
+ - call_interrupt num:UINTEGER_8 :BOOLEAN <-
+ ( + old_idtr:UINTEGER_32;
+ + old_irq0,old_irq1:UINTEGER_8;
+ + mem:VIRTUAL_MEMORY;
+
+ // Saving the registers in the stack 16
+ push_all;
+ push (REGISTER.es);
+ push (REGISTER.ds);
+ push (REGISTER.flags);
+ push num; // Save Int N
+
+ // Modify the idtr register (interrupt table address) :
+ old_idtr:=SYSTEM.idtr;
+ SYSTEM.interrupt_off;
+ SYSTEM.set_idtr 0 limit 3FFh;
+
+ // Configure PICs for DOS/BIOS :
+ old_irq0 := SYSTEM.itemb 21h; // Save IRQs.
+ old_irq1 := SYSTEM.itemb 0A1h;
+ SYSTEM.putb 11h to 20h; // ICW1 : Mode attaque / Cascade / ICW4
+ SYSTEM.putb 11h to 0A0h;
+ SYSTEM.putb 08h to 21h; // ICW2 : N int Pr IRQ0
+ SYSTEM.putb 70h to 0A1h;
+ SYSTEM.putb 04h to 21h; // ICW3 : Ligne IRQ Pr Esclave (2nd PIC)
+ SYSTEM.putb 02h to 0A1h;
+ SYSTEM.putb 01h to 21h; // ICW4 : EOI Manuel / Intel
+ SYSTEM.putb 01h to 0A1h;
+ SYSTEM.putb 00h to 21h; // Autorise Tout pr IRQ0-7
+ SYSTEM.putb 9Eh to 0A1h; // Autorise DD,Math,Clock pr IRQ8-15
+
+ // Call Far 08h:[1000h]
+ `
+ asm(" \n\
+ .byte 0x9A \n\
+ .long 0x1000 \n\
+ .word 0x08 \n": /* no output */ : /* no input */ : "memory");
+ `;
+
+ // Configure PICs for ISAAC :
+ SYSTEM.putb 11h to 20h; // ICW1 : Mode attaque / Cascade / ICW4
+ SYSTEM.putb 11h to 0A0h;
+ SYSTEM.putb 20h to 21h; // ICW2 : N int Pr IRQ0
+ SYSTEM.putb 28h to 0A1h;
+ SYSTEM.putb 04h to 21h; // ICW3 : Ligne IRQ Pr Esclave (2�me PIC)
+ SYSTEM.putb 02h to 0A1h;
+ SYSTEM.putb 01h to 21h; // ICW4 : EOI Manuel / Intel
+ SYSTEM.putb 01h to 0A1h;
+ SYSTEM.putb old_irq0 to 21h;
+ SYSTEM.putb old_irq1 to 0A1h;
+
+ // Restore old Idtr
+ SYSTEM.set_idtr old_idtr limit 7FFh;
+ SYSTEM.interrupt_on;
+
+ // Restore Regs in the stack 16
+ pop; // Int Num.
+ REGISTER.set_flags pop;
+ REGISTER.set_ds pop;
+ REGISTER.set_es pop;
+ pop_all;
+
+ mem ?= SYSTEM.memory;
+ (mem != NULL).if {
+ mem.set_pagination;
+ };
+
+ (REGISTER.flags & 1) = 0 // FALSE if Error (flags = 1)
+ );
+//LISAAC2
+ - clear_buffer <- launch_clear_buffer ;
+ - buffer:NATIVE_ARRAY(UINTEGER_8) <- get_buffer ;
+ - segment_buffer:UINTEGER_16 <- get_segment_buffer;
+ - offset_buffer:UINTEGER_16 <- get_offset_buffer;
+ - get_address rm_adress:UINTEGER_32 :UINTEGER_32 <- driv_get_address rm_adress;
+Section Public //DRIVER, CONTROLER
+
+ //
+ // Real Mode Memory
+ //
+
+ - buffer_size:INTEGER := 800h; // 2Ko
+
+ - get_buffer:NATIVE_ARRAY(UINTEGER_8) <- CONVERT(INTEGER,NATIVE_ARRAY(UINTEGER_8)).on 2800h;
+ // Rmq.: VIDEO (Vesa 2.0) use more of 512 bytes.
+
+ - launch_clear_buffer <-
+ (
+ buffer.clear_all (buffer_size - 1);
+ );
+
+ - get_segment_buffer:UINTEGER_16 := 0280h;
+
+ - get_offset_buffer:UINTEGER_16 := 0000h;
+
+ - driv_get_address rm_adress:UINTEGER_32 :UINTEGER_32 <-
+ // Real mode adress -> Protecting mode adress.
+ (
+ ((rm_adress & 0FFFF0000h) >> 12) + (rm_adress & 0FFFFh)
+ );
+
+
+
diff --git a/isaacos/x86/system/desc_int.li b/isaacos/x86/system/desc_int.li
new file mode 100755
index 0000000..536fa8f
--- /dev/null
+++ b/isaacos/x86/system/desc_int.li
@@ -0,0 +1,69 @@
+///////////////////////////////////////////////////////////////////////////////
+// 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; 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 := DESC_INT;
+
+ - bibliography:= "http://www.lisaac.org";
+ - author := "Boutet Jerome (pisteur at free.fr),Sonntag Benoit (benoit.sonntag at lisaac.org)";
+ - comment := "Descriptor interrupt.";
+
+Section Inherit
+
+ - parent_object:OBJECT := OBJECT;
+
+Section Mapping
+
+ + offset_0_15:UINTEGER_16;
+ + desc:UINTEGER_16;
+ + reserved:UINTEGER_8;
+ + p_dpl_0_type:UINTEGER_8;
+ + offset_16_31:UINTEGER_16;
+
+Section Public
+
+ - is_present:BOOLEAN <- (p_dpl_0_type & 10000000b)!=0;
+
+ //
+ // Consultation.
+ //
+
+ - offset:UINTEGER_32 <-
+ (
+ (offset_16_31.to_uinteger_32<< 16) |
+ (offset_0_15)
+ );
+
+ - type:UINTEGER_8 <- p_dpl_0_type & 0Fh;
+
+ //
+ // Creation.
+ //
+
+ - make offs:UINTEGER_32 <-
+ (
+ offset_0_15 := (offs & 0FFFFh).to_uinteger_16;
+ offset_16_31 := (offs >> 16).to_uinteger_16;
+ desc := SYSTEM.descriptor_code;
+ reserved := 0;
+ p_dpl_0_type := 10001110b;
+ );
+
+ - free <-
+ (
+ p_dpl_0_type:=0;
+ );
+
diff --git a/isaacos/x86/system/desc_seg.li b/isaacos/x86/system/desc_seg.li
new file mode 100755
index 0000000..1b18d1c
--- /dev/null
+++ b/isaacos/x86/system/desc_seg.li
@@ -0,0 +1,125 @@
+///////////////////////////////////////////////////////////////////////////////
+// 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; 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 := DESC_SEG;
+
+ - category := MICRO;
+
+ - bibliography:= "http://www.lisaac.org";
+ - author := "Boutet Jerome (pisteur at free.fr),Sonntag Benoit (benoit.sonntag at lisaac.org)";
+ - comment := "Descriptor segment (GDT).";
+
+Section Inherit
+
+ - parent_object:OBJECT := OBJECT;
+
+Section Mapping
+
+ + limit_0_15:UINTEGER_16;
+ + address_0_15:UINTEGER_16;
+ + address_16_23:UINTEGER_8;
+ + p_dpl_dt_type:UINTEGER_8;
+ + g_d_0_avl_limt_16_19:UINTEGER_8;
+ + address_24_31:UINTEGER_8;
+
+Section GDT
+
+ - link:UINTEGER_16 <- limit_0_15;
+
+ - set_link lnk:UINTEGER_16 <-
+ (
+ limit_0_15:=lnk;
+ );
+
+Section Private
+
+ - is_granular:BOOLEAN <- (g_d_0_avl_limt_16_19 & 10000000b)!=0;
+
+ - valid_desc d:UINTEGER_16 :BOOLEAN <-
+ (
+ (d=desc_data) || {d=desc_code} ||
+ {d=desc_data_16} || {d=desc_code_16}
+ );
+
+Section Public
+
+ //
+ // Flags.
+ //
+
+ - desc_data:UINTEGER_16 := 0100000010010011b;
+ - desc_code:UINTEGER_16 := 0100000010011011b;
+
+ - desc_data_16:UINTEGER_16 := 0000000010010011b;
+ - desc_code_16:UINTEGER_16 := 0000000010011011b;
+
+
+ - is_present:BOOLEAN <- (p_dpl_dt_type & 10000000b)!=0;
+
+ //
+ // Consultation.
+ //
+
+ - address:UINTEGER_32<-
+ (
+ (address_24_31.to_uinteger_32<< 24) |
+ (address_16_23.to_uinteger_32<< 16) |
+ (address_0_15)
+ );
+
+ - limit:UINTEGER_32<-
+ ( + result:UINTEGER_32
+
+ result:=((g_d_0_avl_limt_16_19.to_uinteger_32& 0Fh) << 16) | limit_0_15;
+ is_granular.if {
+ result:=(result << 12) | 0FFFh;
+ };
+ result
+ );
+
+ - type:UINTEGER_8 <- p_dpl_dt_type & 0Fh;
+
+ //
+ // Creation.
+ //
+
+ - create addr:UINTEGER_32limit lim:UINTEGER_32type t:UINTEGER_16 <-
+ ( ? {valid_desc t};
+
+ (lim>0FFFFFh).if {
+ // Granularity + Default + Limit.
+ g_d_0_avl_limt_16_19:=10000000b | ((lim>>28).to_uinteger_8);
+ limit_0_15:=((lim>>12) & 0FFFFh).to_uinteger_16;
+ } else {
+ // Default + Limit.
+ g_d_0_avl_limt_16_19:=(lim>>16).to_uinteger_8;
+ limit_0_15:=(lim & 0FFFFh).to_uinteger_16;
+ };
+ g_d_0_avl_limt_16_19:=g_d_0_avl_limt_16_19 | ((t>>8).to_uinteger_8);
+ address_0_15:=(addr & 0FFFFh).to_uinteger_16;
+ address_16_23:=((addr>>16) & 0FFh).to_uinteger_8;
+ address_24_31:=(addr>>24).to_uinteger_8;
+ p_dpl_dt_type:=(t & 0FFh).to_uinteger_8;
+ );
+
+ - free <-
+ (
+ p_dpl_dt_type:=0;
+ );
+
+
+
diff --git a/isaacos/x86/system/event_system.li b/isaacos/x86/system/event_system.li
new file mode 100755
index 0000000..f0ef480
--- /dev/null
+++ b/isaacos/x86/system/event_system.li
@@ -0,0 +1,51 @@
+///////////////////////////////////////////////////////////////////////////////
+// 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; 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 := EVENT_SYSTEM;
+
+ - comment := "X86 - Event System";
+ - bibliography:= "http://www.lisaac.org";
+ - author := "Benoit Sonntag (benoit.sonntag at lisaac.org)";
+
+Section Inherit
+
+ - parent_object:OBJECT := OBJECT;
+
+Section Public
+
+ - make <-
+ (
+ // Nothing.
+ );
+
+ - get_event <-
+ (
+ KEYBOARD.get_event;
+ MOUSE.get_event;
+ TIMER.get_event;
+ );
+
+
+
+
+
+
+
+
+
+
+
diff --git a/isaacos/x86/system/gdt.li b/isaacos/x86/system/gdt.li
new file mode 100755
index 0000000..6c543f2
--- /dev/null
+++ b/isaacos/x86/system/gdt.li
@@ -0,0 +1,80 @@
+///////////////////////////////////////////////////////////////////////////////
+// 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; 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 := GDT;
+
+ - category := MICRO;
+
+ - bibliography:= "http://www.lisaac.org";
+ - author := "Boutet Jerome (boutet at loria.fr),Sonntag Benoit (bsonntag at loria.fr)";
+ - comment := "Global Descriptor Table.";
+
+Section Private
+
+ - table:MAP_NATIVE_ARRAY(DESC_SEG) := MAP_NATIVE_ARRAY(DESC_SEG).force_conversion 2000h;
+
+ - new_descriptor:UINTEGER_16 <-
+ ( + free_desc:UINTEGER_16;
+
+ SYSTEM.interrupt_off;
+ free_desc:=table.item 0.link;
+
+ "Descriptor : #".print;
+ free_desc.print;
+ '\n'.print;
+
+ (free_desc=0).if {
+ // Il faut agrandir la table ou donner une erreur...
+ "Agrandir la GDT !\n".print;
+ SYSTEM.exit 1;
+ };
+ table.item 0.set_link (table.item free_desc.link);
+ SYSTEM.interrupt_on;
+
+ free_desc
+ );
+
+Section Public
+
+ - remove num:UINTEGER_16 <-
+ ( + desc:DESC_SEG;
+ + idx:UINTEGER_16;
+ ? {num.in_range 8h to 800h};
+ ? {table.item (num>>3).is_present};
+
+ idx:=num>>3;
+ desc:=table.item idx;
+ desc.free;
+
+ // Linked list.
+ desc.set_link (table.item 0.link);
+ table.item 0.set_link idx;
+ );
+
+ - add addr:UINTEGER_32limit lim:UINTEGER_32type t:UINTEGER_16 :UINTEGER_16 <-
+ ( + desc:DESC_SEG;
+ + result:UINTEGER_16;
+
+ result:=new_descriptor;
+ desc:=table.item result;
+ desc.create addr limit lim type t;
+
+ result<<3
+ );
+
+
+
diff --git a/isaacos/x86/system/register.li b/isaacos/x86/system/register.li
new file mode 100755
index 0000000..281ffde
--- /dev/null
+++ b/isaacos/x86/system/register.li
@@ -0,0 +1,174 @@
+///////////////////////////////////////////////////////////////////////////////
+// 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; 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 := REGISTER;
+
+ - bibliography:= "http://www.lisaac.org";
+ - author := "Boutet Jerome (boutet at loria.fr),Sonntag Benoit (bsonntag at loria.fr)";
+ - comment := "Registers 16 bits.";
+
+Section Public
+
+ //
+ // 16 Bits
+ //
+
+ - ax:UINTEGER_16;
+
+ - cx:UINTEGER_16;
+
+ - dx:UINTEGER_16;
+
+ - bx:UINTEGER_16;
+
+ - sp:UINTEGER_16;
+
+ - bp:UINTEGER_16;
+
+ - si:UINTEGER_16;
+
+ - di:UINTEGER_16;
+
+ - es:UINTEGER_16;
+
+ - ds:UINTEGER_16;
+
+ - flags:UINTEGER_16;
+
+ //
+ // 8 Bits
+ //
+
+ - al:UINTEGER_8 <- (ax & 0FFh).to_uinteger_8;
+
+ - ah:UINTEGER_8 <- (ax >> 8).to_uinteger_8;
+
+ - bl:UINTEGER_8 <- (bx & 0FFh).to_uinteger_8;
+
+ - bh:UINTEGER_8 <- (bx >> 8).to_uinteger_8;
+
+ - cl:UINTEGER_8 <- (cx & 0FFh).to_uinteger_8;
+
+ - ch:UINTEGER_8 <- (cx >> 8).to_uinteger_8;
+
+ - dl:UINTEGER_8 <- (dx & 0FFh).to_uinteger_8;
+
+ - dh:UINTEGER_8 <- (dx >> 8).to_uinteger_8;
+
+ - carry:BOOLEAN <- (flags & 1b) != 0;
+
+ //
+ // Modification 16 bits
+ //
+
+ - set_ax value:UINTEGER_16 <- ( ax := value; );
+
+ - set_cx value:UINTEGER_16 <- ( cx := value; );
+
+ - set_dx value:UINTEGER_16 <- ( dx := value; );
+
+ - set_bx value:UINTEGER_16 <- ( bx := value; );
+
+ - set_sp value:UINTEGER_16 <- ( sp := value; );
+
+ - set_bp value:UINTEGER_16 <- ( bp := value; );
+
+ - set_si value:UINTEGER_16 <- ( si := value; );
+
+ - set_di value:UINTEGER_16 <- ( di := value; );
+
+ - set_es value:UINTEGER_16 <- ( es := value; );
+
+ - set_ds value:UINTEGER_16 <- ( ds := value; );
+
+ - set_flags value:UINTEGER_16 <- ( flags := value; );
+
+ //
+ // Modification 8 bits
+ //
+
+ - set_al value:UINTEGER_8 <-
+ (
+ ax := (ax & 0FF00h) | value;
+ );
+
+ - set_ah value:UINTEGER_8 <-
+ (
+ ax := (ax & 0FFh) | (value.to_uinteger_16 << 8);
+ );
+
+ - set_bl value:UINTEGER_8 <-
+ (
+ bx := (bx & 0FF00h) | value;
+ );
+
+ - set_bh value:UINTEGER_8 <-
+ (
+ bx := (bx & 0FFh) | (value.to_uinteger_16 << 8);
+ );
+
+ - set_cl value:UINTEGER_8 <-
+ (
+ cx := (cx & 0FF00h) | value;
+ );
+
+ - set_ch value:UINTEGER_8 <-
+ (
+ cx := (cx & 0FFh) | (value.to_uinteger_16 << 8);
+ );
+
+ - set_dl value:UINTEGER_8 <-
+ (
+ dx := (dx & 0FF00h) | value;
+ );
+
+ - set_dh value:UINTEGER_8 <-
+ (
+ dx := (dx & 0FFh) | (value.to_uinteger_16 << 8);
+ );
+
+ - print <-
+ (
+ '\n'.print; 'a'.print; 'x'.print; ':'.print;
+ MEMORY.print_nbx ax;
+
+ ' '.print; 'b'.print; 'x'.print; ':'.print;
+ MEMORY.print_nbx bx;
+
+ ' '.print; 'c'.print; 'x'.print; ':'.print;
+ MEMORY.print_nbx cx;
+
+ ' '.print; 'd'.print; 'x'.print; ':'.print;
+ MEMORY.print_nbx dx;
+
+ ' '.print; 'b'.print; 'p'.print; ':'.print;
+ MEMORY.print_nbx bp;
+
+ ' '.print; 's'.print; 'i'.print; ':'.print;
+ MEMORY.print_nbx si;
+
+ ' '.print; 'd'.print; 'i'.print; ':'.print;
+ MEMORY.print_nbx di;
+
+ ' '.print; 'd'.print; 's'.print; ':'.print;
+ MEMORY.print_nbx ds;
+
+ ' '.print; 'e'.print; 's'.print; ':'.print;
+ MEMORY.print_nbx es;
+ );
+
+
diff --git a/isaacos/x86/system/system.li b/isaacos/x86/system/system.li
new file mode 100755
index 0000000..df84d66
--- /dev/null
+++ b/isaacos/x86/system/system.li
@@ -0,0 +1,496 @@
+///////////////////////////////////////////////////////////////////////////////
+// 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; 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 := SYSTEM;
+
+ - bibliography:= "http://www.lisaac.org";
+ - author := "Boutet Jerome (pisteur at free.fr),Sonntag Benoit (benoit.sonntag at lisaac.org)";
+ - comment := "Intel System Object (methods).";
+
+ - external := `
+unsigned char ___video_text=1;
+
+#define __BEGIN_INTERRUPT__ volatile unsigned long eax; \
+ volatile unsigned long ebx; \
+ volatile unsigned long ecx; \
+ volatile unsigned long edx; \
+ volatile unsigned long esi; \
+ volatile unsigned long edi; \
+ \
+ asm volatile (\
+ "/* BEGIN INTERRUPT */ \n\
+ movl %%eax,%0 \n\
+ movl %%ebx,%1 \n\
+ movl %%ecx,%2 \n\
+ movl %%edx,%3 \n\
+ movl %%esi,%4 \n\
+ movl %%edi,%5 \n\
+ /* BEGIN CODE */" \
+ : "=m"(eax),"=m"(ebx),"=m"(ecx),"=m"(edx),"=m"(esi),"=m"(edi) \
+ : /* no input */ \
+ : "eax","edx","ecx","ebx","esi","edi", "memory");
+
+#define __END_INTERRUPT__ asm volatile (\
+ "/* END CODE */ \n\
+ movl %0,%%eax \n\
+ movl %1,%%ebx \n\
+ movl %2,%%ecx \n\
+ movl %3,%%edx \n\
+ movl %4,%%esi \n\
+ movl %5,%%edi \n\
+ movl %%ebp,%%esp \n\
+ popl %%ebp \n\
+ iret \n\
+ /* END INTERRUPT */" \
+ : /* no output */ \
+ : "m"(eax),"m"(ebx),"m"(ecx),"m"(edx),"m"(esi),"m"(edi) \
+ : "eax","edx","ecx","ebx","esi","edi", "memory");
+int __bss_stop;
+`;
+
+Section Private
+
+ - idtr_mem:NATIVE_ARRAY(UINTEGER_16) := NATIVE_ARRAY(UINTEGER_16).create 3;
+
+Section Public
+
+ - realloc_c (beg:UINTEGER_32,nb:INTEGER) :UINTEGER_32 <- crash_with_message "SYSTEM.realloc_c";
+
+ - is_ansi:BOOLEAN := FALSE;
+
+ // Memory init
+
+ - memory:MEMORY := MEMORY;//VIRTUAL_MEMORY;
+
+ - get_begin_memory:UINTEGER_32 := `&__bss_stop`:UINTEGER_32.align_power 4096; //400000h; // 4MB
+
+ - get_memory_capacity:UINTEGER_64 <-
+ ( + all_memory:NATIVE_ARRAY_VOLATILE(INTEGER_8);
+ + byte:INTEGER_8;
+ + capacity:UINTEGER_64;
+
+ /* JBJB ... A VOIR ... www.ctyme.com/rbrowne.htm
+
+ // Call Int 15h / AH=88h
+ REGISTER.set_ah 88h;
+ BIOS.call_interrupt 15h;
+ (REGISTER.ax = 0FFC0h).if {
+ // > 64Mb
+ // Call Int 15h / AX=E801h
+ REGISTER.set_ax 0E801h;
+ BIOS.call_interrupt 15h;
+ REGISTER.print;
+ capacity := REGISTER.bx << 6;
+ };
+ capacity := (capacity + REGISTER.ax + 1024) << 10;
+
+ */
+
+ all_memory := CONVERT(UINTEGER_32,NATIVE_ARRAY_VOLATILE(INTEGER_8)).on get_begin_memory;
+
+ {
+ capacity := capacity + 200000h;
+
+ byte := all_memory.item capacity;
+ all_memory.force_put (~byte) to capacity;
+
+ all_memory.force_put 0 to (capacity + 1); // Cache invalidation for old x86 generation
+ //`print_char('0')`;
+ }.do_until {byte != ~all_memory.item capacity};
+
+ `/*BSBS MEM*/`;
+
+ capacity
+ );
+
+ // Other Features
+
+ - wait <-
+ // Wait hardware interruption.
+ (
+ `asm("wait")`;
+ );
+
+ - exit code:INTEGER <-
+ (
+ interrupt_off;
+ //"System locked: #".print;
+ //code.print;
+ {}.endless_loop;
+ );
+
+ //
+ // In / Out Hardware Port.
+ //
+
+ - itemb port:UINTEGER_16 :UINTEGER_8<-
+ // Read in port
+ ( + result:UINTEGER_8;
+
+ `{ unsigned short port;
+ volatile unsigned short val;
+
+ port=@port;
+ asm("movw %1,%%dx \n\
+ inb %%dx,%%al \n\
+ movw %%ax,%0 ": "=m"(val) : "m"(port) : "dx","ax");
+ `;
+ result:=`val`:UINTEGER_8;
+ `}`;
+
+ result
+ );
+
+ - putb value:UINTEGER_8 to port:UINTEGER_16 <-
+ // Write in port
+ (
+ `{ unsigned short port;
+ unsigned short val;
+
+ port=@port;
+ val =@value;
+ asm("movw %0,%%dx \n\
+ movw %1,%%ax \n\
+ outb %%al,%%dx ": /* no output */ : "m"(port), "m"(val) : "dx","ax");
+ }`;
+ );
+
+ - itemw port:UINTEGER_16 :UINTEGER_16<-
+ // Read in port
+ ( + result:UINTEGER_16;
+
+ `{ unsigned short port;
+ volatile unsigned short val;
+
+ port=@port;
+ asm("movw %1,%%dx \n\
+ inw %%dx,%%ax \n\
+ movw %%ax,%0 ": "=m"(val) : "m"(port) : "dx","ax")`;
+
+ result:=`val`:UINTEGER_16;
+
+ `}`;
+ result
+ );
+
+ - putw value:UINTEGER_16 to port:UINTEGER_16 <-
+ // Write in port
+ (
+ `{ unsigned short port,val;
+
+ port=@port;
+ val =@value;
+ asm("movw %0,%%dx \n\
+ movw %1,%%ax \n\
+ outw %%ax,%%dx ": /* no output */ : "m"(port), "m"(val) : "dx","ax");
+ }`;
+ );
+
+ //
+ // Interrupt manager.
+ //
+
+Section Private
+
+ - idt:NATIVE_ARRAY(Expanded DESC_INT) := CONVERT(INTEGER,NATIVE_ARRAY(Expanded DESC_INT)).on 800h;
+
+Section Public
+
+ - descriptor_code:UINTEGER_16 := 18h;
+
+ - descriptor_data:UINTEGER_16 := 20h;
+
+ - interrupt_on <- `asm("STI")`;
+
+ - interrupt_off <- `asm("CLI")`;
+
+ - new_interrupt offset:POINTER to num:UINTEGER_8 <-
+ (
+ idt.item num.make (offset.to_uinteger_32);
+ );
+
+ - idtr:UINTEGER_32 <-
+ ( + mem:UINTEGER_32;
+
+ mem:=CONVERT(NATIVE_ARRAY(UINTEGER_16),UINTEGER_32).on idtr_mem;
+ `asm volatile ("movl %0,%%eax \n\
+ .byte 0x0F \n\
+ .byte 0x01 \n\
+ .byte 0x08 \n": /* no output */ : "g" (@mem) : "eax", "memory")`;
+ (idtr_mem.item 2.to_uinteger_32<< 16) | idtr_mem.item 1
+ );
+
+ - set_idtr addr:UINTEGER_32 limit sz:UINTEGER_16 <-
+ ( + mem:UINTEGER_32;
+
+ mem:=CONVERT(NATIVE_ARRAY(UINTEGER_16),UINTEGER_32).on idtr_mem;
+ // Write addr
+ idtr_mem.put ((addr >> 16).to_uinteger_16) to 2;
+ idtr_mem.put ((addr & 0FFFFh).to_uinteger_16) to 1;
+ // Write limit
+ idtr_mem.put sz to 0;
+ `asm("movl %0,%%eax \n\
+ .byte 0x0F \n\
+ .byte 0x01 \n\
+ .byte 0x18 \n": /* no output */ : "g" (@mem) : "eax")`;
+ );
+
+ //
+ // IRQ manager.
+ //
+
+ - irq_on num:INTEGER_8 <-
+ ( + mask:UINTEGER_8;
+ ? {num<=15};
+
+ (num<8).if {
+ //mask:= ~ (1.to_uinteger_8 << num);
+ //LISAAC2 bug
+ mask:= ((~ (1<<((num)& 0Fh)))& 0FFh).to_uinteger_8;
+ putb (itemb 21h & mask) to 21h;
+ } else {
+ mask:= ((~ (1<<((num-8)& 0Fh)))& 0FFh).to_uinteger_8;
+ putb (itemb 0A1h & mask) to 0A1h;
+ };
+ );
+
+ - irq_off num:UINTEGER_8 <-
+ ( + mask:UINTEGER_8;
+ ? {num<=15};
+
+ (num<8).if {
+ mask:= 1.to_uinteger_8 << num;
+ putb (itemb 21h | mask) to 21h;
+ } else {
+ mask:= 1.to_uinteger_8 << (num-8);
+ putb (itemb 0A1h | mask) to 0A1h;
+ };
+ );
+
+ //
+ // Exceptions
+ //
+
+Section Interrupt
+
+ - exception_00 <-
+ (
+ 'E'.print;
+ '0'.print;
+ //"\nException N�00h : Division par zero !\n".print;
+ exit 1;
+ );
+
+ - exception_01 <-
+ (
+ 'E'.print;
+ '1'.print;
+ //"\nException N�01h : Trace !\n".print;
+ exit 1;
+ );
+
+ - exception_02 <-
+ (
+ 'E'.print;
+ '2'.print;
+ //"\nException N�02h : Non masquable !".print;
+ exit 1;
+ );
+
+ - exception_03 <-
+ (
+ 'E'.print;
+ '3'.print;
+ //"\nException N�03h : Point d'arr�t !".print;
+ exit 1;
+ );
+
+ - exception_04 <-
+ (
+ 'E'.print;
+ '4'.print;
+ //"\nException N�04h : D�passement de capacit� INTO !".print;
+ exit 1;
+ );
+
+ - exception_05 <-
+ (
+ 'E'.print;
+ '5'.print;
+ //"\nException N�05h : D�bordement de limites BOUND !".print;
+ exit 1;
+ );
+
+ - exception_06 <-
+ (
+ 'E'.print;
+ '6'.print;
+ //"\nException N�06h : Opcode invalide !\n".print;
+ exit 1;
+ );
+
+ - exception_07 <-
+ (
+ 'E'.print;
+ '7'.print;
+ //"\nException N�07h : Coprocesseur indisponible !".print;
+ exit 1;
+ );
+
+ - exception_08 <-
+ (
+ 'E'.print;
+ '8'.print;
+ //"\nException N�08h : Double faute !".print;
+ exit 1;
+ );
+
+ - exception_09 <-
+ (
+ 'E'.print;
+ '9'.print;
+ //"\nException N�09h : D�bordement de segment !".print;
+ exit 1;
+ );
+
+ - exception_0a <-
+ (
+ 'E'.print;
+ 'a'.print;
+ //"\nException N�0Ah : Segment de t�che invalide ! ".print;
+ exit 1;
+ );
+
+ - exception_0b <-
+ (
+ 'E'.print;
+ 'b'.print;
+ //"\nException N�0Bh : Segment absent !".print;
+ exit 1;
+ );
+
+ - exception_0c <-
+ (
+ 'E'.print;
+ 'c'.print;
+ //"\nException N�0Ch : Faute de pile !".print;
+ exit 1;
+ );
+
+ - exception_0d <-
+ (
+ 'E'.print;
+ 'd'.print;
+ //"\nException N�0Dh : Protection generale !\n".print;
+ exit 1;
+ );
+
+ - exception_0e <-
+ (
+ 'E'.print;
+ 'e'.print;
+ //"\nException N�0Eh : Faute de page !".print;
+ exit 1;
+ );
+
+ - exception_0f <-
+ (
+ 'E'.print;
+ 'f'.print;
+ //"\nException N�0Fh : R�serv� Intel !".print;
+ exit 1;
+ );
+
+ - exception_10 <-
+ (
+ 'E'.print;
+ '1'.print;
+ '0'.print;
+ //"\nException N�10h : Error coprocesseur !".print;
+ exit 1;
+ );
+
+ - exception_11 <-
+ (
+ 'E'.print;
+ '1'.print;
+ '1'.print;
+ //"\nException N�11h : V�rification d'alignement !".print;
+ exit 1;
+ );
+
+ - exception_12_1f <-
+ (
+ 'E'.print;
+ 'x'.print;
+ //"\nException N�12h-1Fh : R�serv� Intel !".print;
+ exit 1;
+ );
+
+ //
+ // Service interrupt.
+
+ - mode_text <-
+ // int. 30h.
+ (
+ VIDEO.close;
+ //"Mode text:\n".print;
+ );
+
+Section Public
+
+ //
+ // Creation.
+ //
+
+ - make <-
+ (
+ new_interrupt exception_01 to 01h;
+ new_interrupt exception_0d to 0Dh;
+
+ // Other exceptions.
+ new_interrupt exception_00 to 00h;
+ new_interrupt exception_02 to 02h;
+ new_interrupt exception_03 to 03h;
+ new_interrupt exception_04 to 04h;
+ new_interrupt exception_05 to 05h;
+ new_interrupt exception_06 to 06h;
+ new_interrupt exception_07 to 07h;
+ new_interrupt exception_08 to 08h;
+ new_interrupt exception_09 to 09h;
+ new_interrupt exception_0a to 0Ah;
+ new_interrupt exception_0b to 0Bh;
+ new_interrupt exception_0c to 0Ch;
+ new_interrupt exception_0e to 0Eh;
+ new_interrupt exception_0f to 0Fh;
+ new_interrupt exception_10 to 10h;
+ new_interrupt exception_11 to 11h;
+
+ 12h.to 1Fh do { n:UINTEGER_8;
+ new_interrupt exception_12_1f to n;
+ };
+
+ // Interrupt service.
+ new_interrupt mode_text to 30h;
+
+ // IRQ cascade on:
+ irq_on 2;
+
+ // STI
+ interrupt_on;
+ );
+
diff --git a/isaacos/x86/system/system_io.li b/isaacos/x86/system/system_io.li
new file mode 100755
index 0000000..5a1c59f
--- /dev/null
+++ b/isaacos/x86/system/system_io.li
@@ -0,0 +1,215 @@
+///////////////////////////////////////////////////////////////////////////////
+// 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; 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 := SYSTEM_IO;
+
+ - comment :="Lower level for Input / Output";
+
+ - bibliography:="http://www.www.lisaac.org";
+
+ - author :="Boutet Jerome (pisteur at free.fr), Benoit Sonntag (benoit.sonntag at lisaac.org)";
+
+ - external := `
+
+extern unsigned char ___video_text;
+
+
+int count_char=0;
+// Hardware 'print_char'.
+int print_char(char car)
+// Very low level buffered output.
+{ unsigned short tmp;
+ int i;
+ unsigned short pos_cur;
+ unsigned char *screen=(unsigned char *)0xB8000LU;
+
+ if (___video_text == 0) {
+ asm("int $0x30");
+ };
+
+ // Read cursor location.
+ asm("movw $0x0E,%%ax \n\
+ movw $0x3D4,%%dx \n\
+ outb %%al,%%dx \n\
+ incw %%dx \n\
+ inb %%dx,%%al \n\
+ movw %%ax,%0 ": "=g"(tmp) : :"ax","dx");
+ pos_cur = tmp;
+
+ asm("movw $0x0F,%%ax \n\
+ movw $0x3D4,%%dx \n\
+ outb %%al,%%dx \n\
+ incw %%dx \n\
+ inb %%dx,%%al \n\
+ movw %%ax,%0 ": "=g"(tmp) : :"ax","dx");
+ pos_cur = ((pos_cur << 8) | tmp) << 1;
+
+ // Write character.
+ switch (car) {
+ case '\b':
+ if ((pos_cur % 160) != 0) {
+ pos_cur = pos_cur - 2;
+ };
+ break;
+ case '\t':
+ pos_cur = (pos_cur + 16) & 0xFFF0;
+ break;
+ case '\n':
+ pos_cur = pos_cur + 160 - (pos_cur % 160);
+ count_char++;
+ if (count_char == 20) {
+ do {
+ asm("movw $0x60,%%dx \n\
+ inb %%dx,%%al \n\
+ movw %%ax,%0 ": "=g"(tmp) : :"ax","dx");
+ } while ((tmp & 0x80) == 0);
+ do {
+ asm("movw $0x60,%%dx \n\
+ inb %%dx,%%al \n\
+ movw %%ax,%0 ": "=g"(tmp) : :"ax","dx");
+ } while ((tmp & 0x80) == 0x80);
+ count_char = 0;
+ };
+ break;
+ case '\r':
+ pos_cur = pos_cur - (pos_cur % 160);
+ default: // other.
+ screen[pos_cur] = car;
+ screen[pos_cur+1] = 12;
+ pos_cur = pos_cur + 2;
+ };
+
+ // Scroll screen.
+ if (pos_cur>=4000) {
+ for (i=160;i<4000;i++) screen[i-160]=screen[i];
+ for (i=(4000-160);i<4000;i+=2) {
+ screen[i] = ' ';
+ screen[i + 1] = 15;
+ };
+ pos_cur = pos_cur - 160;
+ };
+
+ // Write cursor location.
+ pos_cur = pos_cur >> 1;
+
+ tmp = pos_cur;
+ asm("movw %0,%%ax \n\
+ movb $0x0E,%%al \n\
+ movw $0x3D4,%%dx \n\
+ outw %%ax,%%dx ": : "g"(tmp) : "dx","ax");
+
+ tmp = (pos_cur << 8) & 0xFF00;
+ asm("movw %0,%%ax \n\
+ movb $0x0F,%%al \n\
+ movw $0x3D4,%%dx \n\
+ outw %%ax,%%dx ": : "g"(tmp) : "dx","ax");
+};
+
+void print_nb(int n)
+{ int d;
+ char car;
+
+ d = 10000000;
+ while (d != 0) {
+ car = n / d;
+ print_char(car+'0');
+ n = n % d;
+ d = d / 10;
+ };
+};
+
+// Hardware 'exit'.
+int die_with_code(int code)
+{
+ while (1);
+};
+
+ `;
+
+Section Inherit
+
+ - parent_object:OBJECT := OBJECT;
+
+Section Public
+
+ - print_char car:CHARACTER <-
+ // Low level buffered output.
+ ( + pos_cur:UINTEGER_16;
+ + screen:NATIVE_ARRAY(INTEGER_8);
+
+ (VIDEO.is_active).if {
+ VIDEO.close;
+ };
+
+ // Screen location.
+ screen:=CONVERT(INTEGER,NATIVE_ARRAY(INTEGER_8)).on 0B8000h;
+
+ // Read cursor location.
+ SYSTEM.putb 0Eh to 3D4h;
+ pos_cur := SYSTEM.itemb 3D5h;
+ SYSTEM.putb 0Fh to 3D4h;
+ pos_cur := ((pos_cur << 8) | SYSTEM.itemb 3D5h) << 1;
+
+ // Write character.
+ car
+ .when '\b' then {
+ ((pos_cur % 160) != 0).if {
+ pos_cur := pos_cur - 2;
+ };
+ }
+ .when '\t' then {
+ pos_cur := (pos_cur + 16) & 0FFF0h;
+ }
+ .when '\n' then {
+ pos_cur := pos_cur + 160 - (pos_cur % 160);
+ }
+ .when '\r' then {
+ pos_cur := pos_cur - (pos_cur % 160);
+ }
+ .when '\14\' to (127.to_character) then {
+ // other.
+ screen.put car to pos_cur;
+ screen.put 15 to (pos_cur + 1);
+ pos_cur := pos_cur + 2;
+ };
+
+ // Scroll screen.
+ (pos_cur>=4000).if {
+ screen.move 160 to 3999 by (-160);
+ (4000-160).to 3999 by 2 do { i:INTEGER;
+ screen.put ' ' to i;
+ screen.put 15 to (i+1);
+ };
+ pos_cur := pos_cur - 160;
+ };
+
+ // Write cursor location.
+ pos_cur := pos_cur >> 1;
+ SYSTEM.putw ((pos_cur & 0FF00h) | 0Eh) to 3D4h;
+ SYSTEM.putw ((pos_cur << 8) | 0Fh) to 3D4h;
+ );
+
+ - print_error_char char:CHARACTER <-
+ // Low level buffered error output.
+ (
+ print_char char;
+ );
+
+ - get_char :CHARACTER <- ((KEYBOARD.get_key & 0FFh).to_character);
+
+ - eof:CHARACTER <- ((-1).to_character);
+
--
applications.git
More information about the Lisaac-commits
mailing list