diff -uNr a/weightless/MANIFEST b/weightless/MANIFEST --- a/weightless/MANIFEST ce98038600fdf660c887ad515089f873fee1e8aa5dfbbd9ffab8f1c0b7d97da9b3acb65c1634acf3878d9ad1dc0ca9d8b395a051e5841d869877c74071457579 +++ b/weightless/MANIFEST 333496df6480f8a695b7fdbd370a7c098cc06cc9067294cdbaf74faa007e532d648fea1247c86c953847d2bbc7b0b9187c9f50578145fd524fd46a483155fd96 @@ -1 +1,2 @@ 828710 weightless_genesis "Genesis." + 850294 weightless_time_dpmi_api "System time and DPMI API (interrupt vector)." diff -uNr a/weightless/adainclude/weightless-dpmi-dpmi_api.adb b/weightless/adainclude/weightless-dpmi-dpmi_api.adb --- a/weightless/adainclude/weightless-dpmi-dpmi_api.adb false +++ b/weightless/adainclude/weightless-dpmi-dpmi_api.adb 1b390e460273db4e7a17f9b57dbe22b532ae74a1abe173e6e26892b404f877dba6eaf8279cfa66f5649f999b3eafd676374a782a9f3612ba1bc260938aff4d15 @@ -0,0 +1,57 @@ +with System.Machine_Code; use System.Machine_Code; +with Weightless.DPMI; use Weightless.DPMI; +with Weightless.DPMI.System_Calls; use Weightless.DPMI.System_Calls; + +package body Weightless.DPMI.DPMI_API is + + function Get_Protected_Mode_Interrupt_Vector + (Interrupt_Number : in Interrupt_Number_Type; + Selector : out Selector_Type; + Exception_Handler_Address : out System.Address) return DPMI_Error is + ErrorP : Unsigned_8; + Output : Unsigned_16; + begin + Asm("int $0x31" & ASCII.LF & ASCII.HT & + "setc %0", + Inputs => (Unsigned_16'Asm_Input("a", + SYSCALL_GET_PROTECTED_MODE_INTERRUPT_VECTOR), + Interrupt_Number_Type'Asm_Input("b", Interrupt_Number)), + Outputs => (Unsigned_8'Asm_Output("=q", ErrorP), + Unsigned_16'Asm_Output("=a", Output), + Selector_Type'Asm_Output("=c", Selector), + System.Address'Asm_Output("=d", + Exception_Handler_Address)), + Volatile => True); + if ErrorP = 0 then + return DPMI_NO_ERR; + else + return DPMI_Error'Enum_Val(Output); + end if; + end Get_Protected_Mode_Interrupt_Vector; + + function Set_Protected_Mode_Interrupt_Vector + (Interrupt_Number : in Interrupt_Number_Type; + Selector : in Selector_Type; + Exception_Handler_Address : in System.Address) return DPMI_Error is + ErrorP : Unsigned_8; + Output : Unsigned_16; + begin + Asm("int $0x31" & ASCII.LF & ASCII.HT & + "setc %0", + Inputs => (Unsigned_16'Asm_Input("a", + SYSCALL_SET_PROTECTED_MODE_INTERRUPT_VECTOR), + Interrupt_Number_Type'Asm_Input("b", Interrupt_Number), + Selector_Type'Asm_Input("c", Selector), + System.Address'Asm_Input("d", + Exception_Handler_Address)), + Outputs => (Unsigned_8'Asm_Output("=q", ErrorP), + Unsigned_16'Asm_Output("=a", Output)), + Volatile => True); + if ErrorP = 0 then + return DPMI_NO_ERR; + else + return DPMI_Error'Enum_Val(Output); + end if; + end Set_Protected_Mode_Interrupt_Vector; + +end Weightless.DPMI.DPMI_API; diff -uNr a/weightless/adainclude/weightless-dpmi-dpmi_api.ads b/weightless/adainclude/weightless-dpmi-dpmi_api.ads --- a/weightless/adainclude/weightless-dpmi-dpmi_api.ads false +++ b/weightless/adainclude/weightless-dpmi-dpmi_api.ads b2b370e894d5d91abcb357cf730e50af9f89418be49946e61d74030e247eb3a0194ff921bf28e8fca890759ab56c6fc1d08be636d124f5c20ece143406d95505 @@ -0,0 +1,21 @@ +with System; + +package Weightless.DPMI.DPMI_API is + + subtype Interrupt_Number_Type is Unsigned_8; + subtype Selector_Type is Unsigned_16; + + function Get_Protected_Mode_Interrupt_Vector + (Interrupt_Number : in Interrupt_Number_Type; + Selector : out Selector_Type; + Exception_Handler_Address : out System.Address) return DPMI_Error; + + function Set_Protected_Mode_Interrupt_Vector + (Interrupt_Number : in Interrupt_Number_Type; + Selector : in Selector_Type; + Exception_Handler_Address : in System.Address) return DPMI_Error; + +private + pragma Inline_Always(Get_Protected_Mode_Interrupt_Vector); + pragma Inline_Always(Set_Protected_Mode_Interrupt_Vector); +end Weightless.DPMI.DPMI_API; diff -uNr a/weightless/adainclude/weightless-dpmi-system_time.adb b/weightless/adainclude/weightless-dpmi-system_time.adb --- a/weightless/adainclude/weightless-dpmi-system_time.adb false +++ b/weightless/adainclude/weightless-dpmi-system_time.adb 50fe92706e56720064af44681cc24d1a08f4f60db334cb66e7946fabb9fce9a091033291e435203b3dc93c7654b2ac5f621856e13da54279068fc68ed03c57d0 @@ -0,0 +1,44 @@ +with System.Machine_Code; use System.Machine_Code; +with Weightless.DPMI.System_Calls; use Weightless.DPMI.System_Calls; + +package body Weightless.DPMI.System_Time is + + procedure Get_System_Date(Current_Year : out Year; + Current_Month : out Month; + Current_Day : out Day; + Current_Day_of_Week : out Day_of_Week) is + Out_Year : Unsigned_16; + Out_Month_Day : Unsigned_16; + Out_Day_of_Week : Unsigned_8; + begin + Asm("int $0x21", + Inputs => (Unsigned_16'Asm_Input("a", SYSCALL_GET_DATE)), + Outputs => (Unsigned_16'Asm_Output("=c", Out_Year), + Unsigned_16'Asm_Output("=d", Out_Month_Day), + Unsigned_8'Asm_Output("=a", Out_Day_of_Week)), + Volatile => true); + Current_Year := Year(Out_year); + Current_Month := Month(Shift_Right(Out_Month_Day, 8)); + Current_Day := Day(Out_Month_Day and 16#ff#); + Current_Day_of_Week := Day_of_Week'Enum_Val(Out_Day_of_Week); + end Get_System_Date; + + procedure Get_System_Time(Current_Hour : out Hour; + Current_Minutes : out Minutes; + Current_Seconds : out Seconds; + Current_Centiseconds : out Centiseconds) is + Out_Hour_Minutes : Unsigned_16; + Out_Centiseconds : Unsigned_16; + begin + Asm("int $0x21", + Inputs => (Unsigned_16'Asm_Input("a", SYSCALL_GET_TIME)), + Outputs => (Unsigned_16'Asm_Output("=c", Out_Hour_Minutes), + Unsigned_16'Asm_Output("=d", Out_Centiseconds)), + Volatile => True); + Current_Hour := Hour(Shift_Right(Out_Hour_Minutes, 8)); + Current_Minutes := Minutes(Out_Hour_Minutes and 16#ff#); + Current_Seconds := Seconds(Shift_Right(Out_Centiseconds, 8)); + Current_Centiseconds := Centiseconds(Out_Centiseconds and 16#ff#); + end Get_System_Time; + +end Weightless.DPMI.System_Time; diff -uNr a/weightless/adainclude/weightless-dpmi-system_time.ads b/weightless/adainclude/weightless-dpmi-system_time.ads --- a/weightless/adainclude/weightless-dpmi-system_time.ads false +++ b/weightless/adainclude/weightless-dpmi-system_time.ads 7b0a080e92912f1bea62dc7d3513d96e1ddf407615839294a3c38ca5a6a21de616c68fa3f850da9f4a2301dfa06092b7484e0e217c6ca80258d065c5c821c690 @@ -0,0 +1,33 @@ +package Weightless.DPMI.System_Time is + + subtype Year is Integer range 1980 .. 2099; + subtype Month is Integer range 1 .. 12; + subtype Day is Integer range 1 .. 31; + subtype Hour is Integer range 0 .. 23; + subtype Minutes is Integer range 0 .. 59; + subtype Seconds is Integer range 0 .. 59; + subtype Centiseconds is Integer range 0 .. 99; + + type Day_of_Week is + (Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday); + + for Day_of_Week use + (Sunday => 0, + Monday => 1, + Tuesday => 2, + Wednesday => 3, + Thursday => 4, + Friday => 5, + Saturday => 6); + + procedure Get_System_Date(Current_Year : out Year; + Current_Month : out Month; + Current_Day : out Day; + Current_Day_of_Week : out Day_of_Week); + + procedure Get_System_Time(Current_Hour : out Hour; + Current_Minutes : out Minutes; + Current_Seconds : out Seconds; + Current_Centiseconds : out Centiseconds); + +end Weightless.DPMI.System_Time;