[SCM] Lisaac compiler branch, master, updated. lisaac-0.12-667-g273b55c
ontologiae
ontologiae at gmail.com
Fri Nov 26 00:10:48 UTC 2010
The following commit has been merged in the master branch:
commit 5d51f546d10c36b45ab265b2b0b93b30dce579e1
Author: ontologiae <ontologiae at gmail.com>
Date: Fri Nov 26 01:07:45 2010 +0100
lib for x86, IsaacOS
diff --git a/lib/internal/os_support/unix/file_system/directory_unix.li b/lib/internal/os_support/x86/file_system/directory_unix.li
similarity index 100%
copy from lib/internal/os_support/unix/file_system/directory_unix.li
copy to lib/internal/os_support/x86/file_system/directory_unix.li
diff --git a/lib/internal/os_support/unix/file_system/entry_unix.li b/lib/internal/os_support/x86/file_system/entry_unix.li
similarity index 100%
copy from lib/internal/os_support/unix/file_system/entry_unix.li
copy to lib/internal/os_support/x86/file_system/entry_unix.li
diff --git a/lib/internal/os_support/unix/file_system/file_system.li b/lib/internal/os_support/x86/file_system/file_system.li
similarity index 100%
copy from lib/internal/os_support/unix/file_system/file_system.li
copy to lib/internal/os_support/x86/file_system/file_system.li
diff --git a/lib/internal/os_support/unix/file_system/file_unix.li b/lib/internal/os_support/x86/file_system/file_unix.li
similarity index 100%
copy from lib/internal/os_support/unix/file_system/file_unix.li
copy to lib/internal/os_support/x86/file_system/file_unix.li
diff --git a/lib/internal/os_support/x86/system/clock.li b/lib/internal/os_support/x86/system/clock.li
new file mode 100644
index 0000000..a67ee3b
--- /dev/null
+++ b/lib/internal/os_support/x86/system/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/lib/internal/os_support/unix/system/environment.li b/lib/internal/os_support/x86/system/environment.li
similarity index 100%
copy from lib/internal/os_support/unix/system/environment.li
copy to lib/internal/os_support/x86/system/environment.li
diff --git a/lib/internal/os_support/unix/system/float_processor.li b/lib/internal/os_support/x86/system/float_processor.li
similarity index 100%
copy from lib/internal/os_support/unix/system/float_processor.li
copy to lib/internal/os_support/x86/system/float_processor.li
diff --git a/lib/internal/os_support/unix/system/processor.li b/lib/internal/os_support/x86/system/processor.li
similarity index 100%
copy from lib/internal/os_support/unix/system/processor.li
copy to lib/internal/os_support/x86/system/processor.li
diff --git a/lib/internal/os_support/x86/system/system.li b/lib/internal/os_support/x86/system/system.li
new file mode 100755
index 0000000..6780ec8
--- /dev/null
+++ b/lib/internal/os_support/x86/system/system.li
@@ -0,0 +1,519 @@
+///////////////////////////////////////////////////////////////////////////////
+// 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;
+
+ // Ancienne ligne
+ //- get_begin_memory:UINTEGER_32 := `&__bss_stop`:UINTEGER_32.align_power 4096; //400000h; // 4MB
+
+ // Nouvelle ligne pour que ça compile
+ - get_begin_memory:POINTER := CONVERT(UINTEGER_32,POINTER).on (`&__bss_stop`:UINTEGER_32.align_power 4096); //400000h; // 4MB
+
+ - get_memory_capacity:UINTEGER_CPU <-
+ ( + all_memory:NATIVE_ARRAY_VOLATILE(INTEGER_8);
+ + byte:INTEGER_8;
+ + capacity:UINTEGER_CPU;
+
+ /* 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;
+
+ */
+/* // Pose trop de problème à la compil
+
+ // BUG COMPIL !!! Line #74 Column #27 in PUT_TO (.../src/external/put_to.li). Call On NULL
+ all_memory := CONVERT(POINTER,NATIVE_ARRAY_VOLATILE(INTEGER_8)).on get_begin_memory;
+ // all_memory := CONVERT(NATIVE_ARRAY_VOLATILE(INTEGER_8),POINTER).on all_memory;
+
+ {
+ capacity := capacity + 200000h;
+
+ byte := all_memory.item (capacity.to_uinteger_64.to_uinteger_32);
+ all_memory.force_put (~byte) to (capacity.to_uinteger_64.to_uinteger_32);
+
+ all_memory.force_put 0 to ((capacity.to_uinteger_64.to_uinteger_32) + 1); // Cache invalidation for old x86 generation
+ //`print_char('0')`;
+ }.do_until {byte != ~all_memory.item (capacity.to_uinteger_64.to_uinteger_32)};
+ */
+ `/*BSBS MEM*/`;
+
+ //capacity
+ 8388608 // 8Mb
+ );
+
+ // 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;
+
+ /* // Ce code fait planter le compilateur !!!!!
+ 12h.to 1Fh do { n:UINTEGER_8;
+ new_interrupt exception_12_1f to n;
+ };*/
+ new_interrupt exception_12_1f to 12h;
+ new_interrupt exception_12_1f to 13h;
+ new_interrupt exception_12_1f to 14h;
+ new_interrupt exception_12_1f to 15h;
+ new_interrupt exception_12_1f to 16h;
+ new_interrupt exception_12_1f to 1Ah;
+ new_interrupt exception_12_1f to 1Bh;
+ new_interrupt exception_12_1f to 1Ch;
+ new_interrupt exception_12_1f to 1Dh;
+ new_interrupt exception_12_1f to 1Eh;
+ new_interrupt exception_12_1f to 1Fh;
+
+
+
+
+ // Interrupt service.
+ new_interrupt mode_text to 30h;
+
+ // IRQ cascade on:
+ irq_on 2;
+
+ // STI
+ interrupt_on;
+ );
+
diff --git a/lib/internal/os_support/x86/system/system_io.li b/lib/internal/os_support/x86/system/system_io.li
new file mode 100644
index 0000000..2611c82
--- /dev/null
+++ b/lib/internal/os_support/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_integer_8) 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_integer_8) 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);
+
diff --git a/lib/internal/os_support/x86/system/timer.li b/lib/internal/os_support/x86/system/timer.li
new file mode 100755
index 0000000..cac8788
--- /dev/null
+++ b/lib/internal/os_support/x86/system/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/lib/internal/os_support/unix/video/event_system.li b/lib/internal/os_support/x86/video/event_system.li
similarity index 100%
copy from lib/internal/os_support/unix/video/event_system.li
copy to lib/internal/os_support/x86/video/event_system.li
diff --git a/lib/internal/os_support/unix/video/keyboard.li b/lib/internal/os_support/x86/video/keyboard.li
similarity index 100%
copy from lib/internal/os_support/unix/video/keyboard.li
copy to lib/internal/os_support/x86/video/keyboard.li
diff --git a/lib/internal/os_support/x86/video/mode_info.li b/lib/internal/os_support/x86/video/mode_info.li
new file mode 100755
index 0000000..3c49b0b
--- /dev/null
+++ b/lib/internal/os_support/x86/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/lib/internal/os_support/unix/video/mouse.li b/lib/internal/os_support/x86/video/mouse.li
similarity index 100%
copy from lib/internal/os_support/unix/video/mouse.li
copy to lib/internal/os_support/x86/video/mouse.li
diff --git a/lib/internal/os_support/x86/video/timer.li b/lib/internal/os_support/x86/video/timer.li
new file mode 100644
index 0000000..cac8788
--- /dev/null
+++ b/lib/internal/os_support/x86/video/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/lib/internal/os_support/x86/video/vesa_info.li b/lib/internal/os_support/x86/video/vesa_info.li
new file mode 100755
index 0000000..dc594ac
--- /dev/null
+++ b/lib/internal/os_support/x86/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/lib/internal/os_support/x86/video/video.li b/lib/internal/os_support/x86/video/video.li
new file mode 100644
index 0000000..ab3c6c6
--- /dev/null
+++ b/lib/internal/os_support/x86/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};
+ );
+
--
Lisaac compiler
More information about the Lisaac-commits
mailing list