Zephyr API Documentation 4.1.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
main.c File Reference

test static IDT APIs Ensures interrupt and exception stubs are installed correctly. More...

#include <zephyr/kernel.h>
#include <zephyr/ztest.h>
#include <zephyr/tc_util.h>
#include <zephyr/arch/x86/ia32/segmentation.h>
#include <kernel_internal.h>
#include "test_asm_inline_other.h"

Macros

#define TEST_SOFT_INT   60
 
#define TEST_SPUR_INT   61
 
#define MY_STACK_SIZE   2048
 
#define MY_PRIORITY   5
 

Functions

 K_THREAD_STACK_DEFINE (my_stack_area, 2048)
 
 NANO_CPU_INT_REGISTER (int_stub, -1, -1, 60, 0)
 
void k_sys_fatal_error_handler (unsigned int reason, const struct arch_esf *esf)
 Fatal error policy handler.
 
void isr_handler (void)
 Handler to perform various actions from within an ISR context.
 
void exc_divide_error_handler (struct arch_esf *p_esf)
 This is the handler for the divide by zero exception.
 
void test_idt_stub (void)
 Test the position of interrupt stubs in IDT.
 
void idt_spur_task (void *arg1, void *arg2, void *arg3)
 
void test_static_idt (void)
 Test entry point to static IDT.
 
 ZTEST_SUITE (static_idt, NULL, NULL, NULL, NULL, NULL)
 

Variables

static struct k_thread my_thread
 
void * int_stub
 
static volatile int exc_handler_executed
 
static volatile int int_handler_executed
 
static volatile int spur_handler_aborted_thread = 1
 

Detailed Description

test static IDT APIs Ensures interrupt and exception stubs are installed correctly.

Macro Definition Documentation

◆ MY_PRIORITY

#define MY_PRIORITY   5

◆ MY_STACK_SIZE

#define MY_STACK_SIZE   2048

◆ TEST_SOFT_INT

#define TEST_SOFT_INT   60

◆ TEST_SPUR_INT

#define TEST_SPUR_INT   61

Function Documentation

◆ exc_divide_error_handler()

void exc_divide_error_handler ( struct arch_esf * p_esf)

This is the handler for the divide by zero exception.

The source of this divide-by-zero error comes from the following line in main() ... error = error / exc_handler_executed; Where exc_handler_executed is zero. The disassembled code for it looks something like .... f7 fb idiv ecx This handler is part of a test that is only interested in detecting the error so that we know the exception connect code is working. Therefore, a very quick and dirty approach is taken for dealing with the exception; we skip the offending instruction by adding 2 to the EIP. (If nothing is done, then control goes back to the offending instruction and an infinite loop of divide-by-zero errors would be created.)

◆ idt_spur_task()

void idt_spur_task ( void * arg1,
void * arg2,
void * arg3 )

◆ isr_handler()

void isr_handler ( void )

Handler to perform various actions from within an ISR context.

This routine is the ISR handler for _trigger_isr_handler().

◆ K_THREAD_STACK_DEFINE()

K_THREAD_STACK_DEFINE ( my_stack_area ,
2048  )

◆ NANO_CPU_INT_REGISTER()

NANO_CPU_INT_REGISTER ( int_stub ,
- 1,
- 1,
60 ,
0  )

◆ ZTEST_SUITE()

ZTEST_SUITE ( static_idt ,
NULL ,
NULL ,
NULL ,
NULL ,
NULL  )

Variable Documentation

◆ exc_handler_executed

volatile int exc_handler_executed
static

◆ int_handler_executed

volatile int int_handler_executed
static

◆ int_stub

void* int_stub
extern

◆ my_thread

struct k_thread my_thread
static

◆ spur_handler_aborted_thread

volatile int spur_handler_aborted_thread = 1
static