Can you put a picture of your design to well understand the context please.
Else, the variable context here is just to save values during ISR. For example in the count_binary example, you have the following :
1 /* A variable to hold the value of the button pio edge capture register. */
2 volatile int edge_capture;
3 static void init_button_pio()
4 {
5 /* Recast the edge_capture pointer to match the alt_irq_register() function
6 * prototype. */
7 void* edge_capture_ptr = (void*) &edge_capture;
8 /* Enable all 4 button interrupts. */
9 IOWR_ALTERA_AVALON_PIO_IRQ_MASK(BUTTON_PIO_BASE, 0xf);
10 /* Reset the edge capture register. */
11 IOWR_ALTERA_AVALON_PIO_EDGE_CAP(BUTTON_PIO_BASE, 0x0);
12 /* Register the interrupt handler. */
13 alt_irq_register( BUTTON_PIO_IRQ, edge_capture_ptr,
14 handle_button_interrupts );
15 }
16 static void handle_button_interrupts(void* context, alt_u32 id)
17 {
18 /* Cast context to edge_capture's type. It is important that this be
19 * declared volatile to avoid unwanted compiler optimization.
20 */
21 volatile int* edge_capture_ptr = (volatile int*) context;
22 /* Store the value in the Button's edge capture register in *context. */
23 *edge_capture_ptr = IORD_ALTERA_AVALON_PIO_EDGE_CAP(BUTTON_PIO_BASE);
24 /* Reset the Button's edge capture register. */
25 IOWR_ALTERA_AVALON_PIO_EDGE_CAP(BUTTON_PIO_BASE, 0);
26 IORD_ALTERA_AVALON_PIO_EDGE_CAP(BUTTON_PIO_BASE); //An extra read call to clear of delay through the bridge
27
28 }
In the ISR, you get the value of the edge capture register to know which button has been pushed, and store it at the address pointed by edge_capture_ptr. This variable point to the same address as context (line 21). And context has the same address as edge_capture variable (line 13 and 7).