Browse Source

crash-message

master
Stefan Naumann 4 years ago
parent
commit
95c6c38737
  1. 19
      src/cmd.c
  2. 76
      src/cmd.h
  3. 105
      src/main.c
  4. 8
      src/ui.c
  5. 2
      wireframe

19
src/cmd.c

@ -57,6 +57,20 @@ int help ( int argc, char** argv )
return 0;
}
int cmdCrash ( int argc, char** argv )
{
void* lr;
#ifdef PLATFORM
asm volatile ( "mov %0, lr\n"
: "=r" (lr) );
#else
lr = 0xdeadbeef;
#endif
int r = atoi(argv);
crash (r, lr );
}
int cmdClear ( int argc, char** argv )
{
pios_fbconsole_clear();
@ -97,10 +111,7 @@ int yil_exit ( int argc, char** argv )
exit ( retval );
return retval;
}
extern void* swrender( );
extern void display();
int run ( int argc, char** argv )
{
yil_state = RENDERER;

76
src/cmd.h

@ -1,30 +1,84 @@
/**
* \file cmd.h
* \author Stefan Naumann
* \brief contains the subprograms which can be invoked in the command-prompt
**/
#ifndef YIL_CMD
#define YIL_CMD
#include "console.h"
/**
* \brief state of the demo
**/
enum _state
{
CONSOLE,
SETTINGS,
RENDERER,
SETTINGSINGAME
CONSOLE, ///< console prompt
SETTINGS, ///< settings window opened (with console in the background)
RENDERER, ///< 3D software rendered world
SETTINGSINGAME ///< settings window opened (with the 3D image in the background)
};
/**
* \brief prints the ARGV-inputs into the prompt like any old echo-command
* \param[in] argc number of arguments for the call
* \param[in] argv the arguments itself
* \return the result-value ("return of the main-routine of the subprogram")
**/
int echoCmd ( int argc, char** argv );
/**
* \brief unused
**/
int cake ( int argc, char** argv );
/**
* \brief prints a help text, which is very helpful indeed.
* \param[in] argc number of arguments for the call
* \param[in] argv the arguments itself
* \return the result-value ("return of the main-routine of the subprogram")
**/
int help ( int argc, char** argv );
/**
* \brief print the kernel name and version number
* \param[in] argc number of arguments for the call
* \param[in] argv the arguments itself
* \return the result-value ("return of the main-routine of the subprogram")
**/
int uname ( int argc, char** argv );
/**
* \brief run the demo, i.e. start into the 3D-renderer
* \param[in] argc number of arguments for the call
* \param[in] argv the arguments itself
* \return the result-value ("return of the main-routine of the subprogram")
**/
int run ( int argc, char** argv );
/**
* \brief exit the program interely
* \param[in] argc number of arguments for the call
* \param[in] argv the arguments itself
* \return the result-value ("return of the main-routine of the subprogram")
**/
int yil_exit ( int argc, char** argv );
/**
* \brief open the settings window
* \param[in] argc number of arguments for the call
* \param[in] argv the arguments itself
* \return the result-value ("return of the main-routine of the subprogram")
**/
int setStart ( int argc, char** argv );
/**
* \brief clear the prompt from output
* \param[in] argc number of arguments for the call
* \param[in] argv the arguments itself
* \return the result-value ("return of the main-routine of the subprogram")
**/
int cmdClear ( int argc, char** argv );
/**
* \brief prints the crash-screen and hangs the program
* \param[in] argc number of arguments for the call
* \param[in] argv the arguments itself
* \return the result-value ("return of the main-routine of the subprogram")
**/
int cmdCrash ( int argc, char** argv );
#endif

105
src/main.c

@ -705,6 +705,7 @@ int main(int argc, char* argv[])
pios_fbconsole_addCommand ( "setting\0", setStart );
pios_fbconsole_addCommand ( "control\0", setStart );
pios_fbconsole_addCommand ( "clear\0", cmdClear );
pios_fbconsole_addCommand ( "crash\0", cmdCrash );
pios_window_init ( &rimg );
@ -749,21 +750,21 @@ int main(int argc, char* argv[])
hwndPiSet = pios_window ( 50, 50, 380, 220 );
pios_windowTitle ( hwndPiSet, "PiOS SettingsManager\0");
CfgIDs[0] = yil_settings_add ( hwndPiSet, "Enable Wireframe", CHECKBOX, &cfg.Wire );
CfgIDs[0] = yil_settings_add ( hwndPiSet, "Pen and Ink Mode", CHECKBOX, &cfg.Wire );
CfgIDs[1] = yil_settings_add ( hwndPiSet, "Enable Alpha Render", CHECKBOX, &cfg.AlphaRender );
CfgIDs[2] = yil_settings_add ( hwndPiSet, "Enable Textures", CHECKBOX, &cfg.Texture );
CfgIDs[3] = yil_settings_add ( hwndPiSet, "Bilinear Texture-Filter", CHECKBOX, &cfg.texture_interpol );
CfgIDs[4] = yil_settings_add ( hwndPiSet, "Enable Lighting", CHECKBOX, &cfg.Lighting );
CfgIDs[4] = yil_settings_add ( hwndPiSet, "Dark City", CHECKBOX, &cfg.Lighting );
CfgIDs[5] = yil_settings_add ( hwndPiSet, "Enable Noise", CHECKBOX, &cfg.Noise );
CfgIDs[6] = yil_settings_add ( hwndPiSet, "Enable Motion Blur", CHECKBOX, &cfg.Blur );
CfgIDs[7] = yil_settings_add ( hwndPiSet, "Motion Blur level in %", TEXTBOX, cfg.BlurLevel );
CfgIDs[8] = yil_settings_add ( hwndPiSet, "Enable Fog", CHECKBOX, &cfg.Fog );
CfgIDs[9] = yil_settings_add ( hwndPiSet, "Fog Z-Minimum", TEXTBOX, cfg.FogMin );
CfgIDs[10] = yil_settings_add ( hwndPiSet, "Fog Z-Maximum", TEXTBOX, cfg.FogMax );
CfgIDs[10] = yil_settings_add ( hwndPiSet, "Fog Z-Maximum", TEXTBOX, cfg.FogMax );
CfgIDs[11] = yil_settings_add ( hwndPiSet, "Upscale with Bilinear", CHECKBOX, &cfg.Bilinear );
CfgIDs[12] = yil_settings_add ( hwndPiSet, "Enable Depthtest", CHECKBOX, &cfg.Depthtest );
CfgIDs[13] = yil_settings_add ( hwndPiSet, "Enable Front Face Culling", CHECKBOX, &cfg.Culling );
CfgIDs[14] = yil_settings_add ( hwndPiSet, "Interpolate Colours Bilinear", CHECKBOX, &cfg.BilinearInterpol );
CfgIDs[14] = yil_settings_add ( hwndPiSet, "Pretty Colours", CHECKBOX, &cfg.BilinearInterpol );
glutDisplayFunc( displayLoop );
glutMainLoop();
@ -774,3 +775,99 @@ int main(int argc, char* argv[])
return 0;
}
enum crashFault
{
ABORT=1,
UNKNOWNIRQ=2,
DATA=3,
UNKNOWNINSTRUCTION=4,
RESET=5
};
void crash ( int fault, void* lr ) __attribute__((noreturn));
void crash ( int fault, void* lr )
{
uint8_t black[4] = { 0,0,0,0 };
uint8_t red[4] = { 0xff, 0,0,0 };
fill ( outputimg, black );
uint8_t* ptr[8] = {((uint8_t*)outputimg->payload)+(8*outputimg->width + 10) * outputimg->colorsize};
for ( int i=1; i<4; i++)
ptr[i] = ptr[i-1] + outputimg->width*outputimg->colorsize;
ptr[4] = ptr[0] + 56*outputimg->width*outputimg->colorsize;
for ( int i=5; i<8; i++)
ptr[i] = ptr[i-1] + outputimg->width*outputimg->colorsize;
for ( uint32_t x = 10; x < outputimg->width - 10; x++)
{
for ( int j=0; j<8; j++)
{
for ( int i = 0; i<outputimg->colorsize; i++)
{
ptr[j][i] = red[i];
}
ptr[j]+=outputimg->colorsize;
}
}
uint8_t* ptr2[8] = {((uint8_t*)outputimg->payload)+(8*outputimg->width + 10) * outputimg->colorsize};
for ( int i=1; i<4; i++)
ptr2[i] = ptr2[i-1] + outputimg->colorsize;
ptr2[4] = ptr[0] + (outputimg->width-4)*outputimg->colorsize;
for ( int i=5; i<8; i++)
ptr2[i] = ptr2[i-1] + outputimg->colorsize;
for (uint32_t y = 10; y < 66; y++ )
{
for ( int j=0; j<8; j++)
{
for ( int i = 0; i<outputimg->colorsize; i++)
{
ptr2[j][i] = red[i];
}
ptr2[j]+=outputimg->width*outputimg->colorsize;
}
}
char* msg;
switch ( fault )
{
case ABORT:
msg = " ABORT Exception. Please reboot. ";
break;
case UNKNOWNIRQ:
msg = " Uncaught IRQ. Can't recover. Please reboot. ";
break;
case DATA:
msg = " DATA ABORT Exception. Please reb00t. ";
break;
case UNKNOWNINSTRUCTION:
msg = " Unknown instruction. Can't recover. Ple453 r3t44b ";
break;
case RESET:
msg = " Placeholder for RESET. ";
break;
default:
msg = " Ups, your Pi ran into a problem. ";
break;
}
printText ( outputimg, 250, 20, red, msg, false );
printText ( outputimg, 324, 40, red, "Guru Meditation lr:", false );
char lrStr[11]={0};
sprintf ( lrStr, "0x%08x", (uint32_t) lr );
printText ( outputimg, 324+170, 40, red, lrStr, false );
swap (outputimg, SWAP_Y);
glDrawPixels (WIDTH*2, HEIGHT*2, GL_RGB, GL_UNSIGNED_BYTE, outdata);
glutPostRedisplay();
glFlush();
while (1);
}

8
src/ui.c

@ -323,7 +323,7 @@ int pios_window_invalidate ( int hwnd )
{
for (uint8_t k=0; k<fb->colorsize; k++)
{
*(ptr+k) = PIOS_WINDOW_FILLCOLOUR;
ptr[k] = PIOS_WINDOW_FILLCOLOUR;
}
}
ptr+=fb->colorsize;
@ -343,7 +343,7 @@ int pios_window_invalidate ( int hwnd )
{
for (uint8_t k=0; k<fb->colorsize; k++)
{
*(ptr+k) = PIOS_WINDOW_BORDERCOLOUR;
ptr[k] = PIOS_WINDOW_BORDERCOLOUR;
}
}
ptr+=fb->colorsize;
@ -363,7 +363,7 @@ int pios_window_invalidate ( int hwnd )
{
for (uint8_t k=0; k<fb->colorsize; k++)
{
*(ptr+k) = PIOS_WINDOW_BORDERCOLOUR;
ptr[k] = PIOS_WINDOW_BORDERCOLOUR;
}
ptr+= fb->colorsize;
@ -375,7 +375,7 @@ int pios_window_invalidate ( int hwnd )
{
for (uint8_t k=0; k<fb->colorsize; k++)
{
*(ptr2+k) = PIOS_WINDOW_BORDERCOLOUR;
ptr2[k] = PIOS_WINDOW_BORDERCOLOUR;
}
ptr2 -= fb->colorsize;
}

2
wireframe

@ -1,2 +1,2 @@
run
m qkkkllllllwwwwwwwwwwwwwwwwwwwww
m sssss qlllllllwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllll

Loading…
Cancel
Save