01.06.2013 Views

IPC@CHIP Documentation - SC12 @CHIP-RTOS V1.10

IPC@CHIP Documentation - SC12 @CHIP-RTOS V1.10

IPC@CHIP Documentation - SC12 @CHIP-RTOS V1.10

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

AH<br />

ES:DI<br />

Comments<br />

Must be 0x20.<br />

Address of the user error handler function (or zero to remove a previously installed handler).<br />

The user is permitted to execute an error handler function if a fatal error occurs in either an application program or the <strong>@CHIP</strong>-<br />

<strong>RTOS</strong>.<br />

Note that this mechanism will (of course) fail if the user error handler code is itself overwritten (corrupt).<br />

Only one error handler callback per system is supported. An application can remove its handler by calling this install function with a<br />

zero (NULL) value in ES:DI, which is an advisable clean-up procedure at program exit.<br />

The callback function must be of type huge _pascal with an errorcode input parameter (see the example function below). The<br />

error codes conveyed by this input parameter are as follows:<br />

1: Invalid processor opcode (usually caused by corrupted memory). The current task will be suspended.<br />

2: Fatal kernel error (usually caused by corrupted memory or a task stack overflow)<br />

3: Fatal internal TCP/IP error, current task will be suspended<br />

4: TCP/IP stack reaches memory limit<br />

5: TCP/IP memory allocation error<br />

6: Ethernet bus error (hardware decfect)<br />

7: Ethernet link error detected (cable not connected?)<br />

8: Flash write error -> Flash defect ( Note: <strong>IPC<strong>@CHIP</strong></strong> is no longer usable)<br />

9: Low Memory error -> called if a memory allocation (system or user) failed.<br />

In all cases (except errorcode 6,7 and 9) we recommend a reboot with BIOS interrupt 0xA0 0x21.<br />

Important: Do not use any message printing inside your error handler if error code is 3 or 4,<br />

because when Telnet is part of your stdio, your exit handler will hang inside the print call.<br />

// Example for Borland C: This error handler reboots the system<br />

void huge _pascal user_error_handler(int errorcode)<br />

{<br />

union REGS inregs;<br />

union REGS outregs;<br />

}<br />

Top of list<br />

Index page<br />

// e.g. resetting outputs<br />

outportb(0x600,0x00);<br />

// rebooting the <strong>IPC<strong>@CHIP</strong></strong><br />

inregs.h.ah = 0x21;<br />

int86(0xA0,&inregs,&outregs);<br />

// Installing the error handler function from program's main function<br />

inregs.h.ah=0x20;<br />

sregs.es =FP_SEG(user_error_handler);<br />

inregs.x.di=FP_OFF(user_error_handler);<br />

int86x(0xA0,&inregs,&outregs,&sregs);<br />

Interrupt 0xA0 service 0x21: Rebooting the <strong>IPC<strong>@CHIP</strong></strong><br />

Parameters<br />

AH<br />

This function works in the same way as the reboot shell command<br />

0x21<br />

Return Value<br />

Page 89 / 400

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!