Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This commit tackles the following issues: * Update bootloader * Remove hlt when idle and fix bug in ThreadCreate() * Issue #418: Update README.md
- Loading branch information
1 parent
e0bbb6c
commit 5718bf7
Showing
17 changed files
with
340 additions
and
8,232 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
// | ||
// Exception Handling | ||
// | ||
// Copyright (c) 2003-2020 Matias Vara <matiasevara@gmail.com> | ||
// All Rights Reserved | ||
// | ||
// 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/>. | ||
// | ||
|
||
program ExceptionHandling; | ||
|
||
{$IFDEF FPC} | ||
{$mode delphi} | ||
{$ENDIF} | ||
|
||
{%RunCommand qemu-system-x86_64 -m 256 -smp 2 -drive format=raw,file=ExceptionHandling.img} | ||
{%RunFlags BUILD-} | ||
|
||
uses | ||
SysUtils, | ||
Kernel, | ||
Process, | ||
Memory, | ||
Debug, | ||
Arch, | ||
Filesystem, | ||
Console; | ||
|
||
var | ||
tmp: TThreadID = 0; | ||
|
||
{$ASMMODE intel} | ||
|
||
// Procedure that tests Division by zero exception handler | ||
procedure DoDivZero; | ||
var | ||
Q, R: Longint; | ||
begin | ||
try | ||
Q := 5; | ||
R := 0; | ||
R := Q div R; | ||
except | ||
on E: Exception do | ||
begin | ||
WriteConsoleF('Exception Message: %s\n',[PtrUInt(@E.Message)]); | ||
end; | ||
end; | ||
end; | ||
|
||
// Procedure that tests Page Fault exception handler | ||
procedure DoPageFault; | ||
var | ||
p: ^longint; | ||
begin | ||
// this page is not present | ||
try | ||
p := pointer($ffffffffffffffff); | ||
p^ := $1234; | ||
except | ||
on E: Exception do | ||
begin | ||
WriteConsoleF('Exception Message: %s\n',[PtrUInt(@E.Message)]); | ||
end; | ||
end; | ||
end; | ||
|
||
// Procedure that tests Protection Fault exception handler | ||
procedure DoProtectionFault; | ||
begin | ||
try | ||
asm | ||
mov ax, $20 | ||
mov ds, ax | ||
end; | ||
except | ||
on E: Exception do | ||
begin | ||
WriteConsoleF('Exception Message: %s\n',[PtrUInt(@E.Message)]); | ||
end; | ||
end; | ||
end; | ||
|
||
// Procedure that tests Illegal instruction exception handler | ||
procedure DoIllegalInstruction; | ||
begin | ||
try | ||
asm | ||
db $ff, $ff | ||
end; | ||
except | ||
on E: Exception do | ||
begin | ||
WriteConsoleF('Exception Message: %s\n',[PtrUInt(@E.Message)]); | ||
end; | ||
end; | ||
end; | ||
|
||
function Exception_Core2(Param: Pointer):PtrInt; | ||
begin | ||
//DoDivZero; | ||
// no registra la interruption y el raise exception termina llamando a unhandle | ||
DoPageFault; | ||
//DoProtectionFault; | ||
//DoIllegalInstruction; | ||
Result := 0; | ||
end; | ||
|
||
begin | ||
//tmp:= BeginThread(nil, 4096, Exception_Core2, nil, 1, tmp); | ||
DoDivZero; | ||
//try | ||
// Raise EDivException.Create ('Division by Zero would occur'); | ||
//except | ||
// WriteConsoleF('Exception!\n',[]); | ||
//end; | ||
//DoPageFault; | ||
//DoProtectionFault; | ||
//DoIllegalInstruction; | ||
end. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# Exception Handling Example | ||
|
||
In this example, we show how the handling of exceptions. The mechanism is the same that used in freepascal or delphi. You need to just wrap up your statements with the **try..except** keywords. Toro handles exceptions in the same way other kernel does. It invokes the user's code if an exception happens. In Linux, to compile and exceute the application on QEMU, go to the **ExceptionHandling** directory and execute: | ||
|
||
`../CloudIt.sh ExceptionHandling "" "-display gtk"` | ||
|
||
If you want to test without graphical interface execute: | ||
|
||
`../CloudIt.sh ExceptionHandling` | ||
|
||
If you want to redirect the screen through VNC execute: | ||
|
||
`../CloudIt.sh ExceptionHandling "" "-vnc :0"` | ||
|
||
You can connect the vnc client to **localhost:5900** | ||
|
||
If you want to enable some debug symbols in the unit **Process** and check what Toro is doing execute: | ||
|
||
`../CloudIt.sh ExceptionHandling "-dEnableDebug -dDebugProcess"` | ||
|
||
You will see how toro initializes the unit by calling the scheduler. | ||
|
||
## Windows Users | ||
|
||
Windows' users should open **ExceptionHandling.lpi** and launch the compilation and execution of the application directly from the IDE by doing first **Compile** and then **Run**. |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Oops, something went wrong.