> So refactor this code into a single macro, and expand it into each vector 
> table
> slot.

 
> +  .macro  ExceptionEntry, val
> +  // Move the stackpointer so we can reach our structure with the str
> instruction.
> +  sub sp, sp, #(FP_CONTEXT_SIZE + SYS_CONTEXT_SIZE)
> +
> +  // Save all the General regs before touching x0 and x1.
> +  // This does not save r31(SP) as it is special. We do that later.
> +  ALL_GP_REGS
> +
> +  // Record the type of exception that occurred.
> +  mov       x0, #\val
> +
> +  // Jump to our general handler to deal with all the common parts and
> process the exception.
> +  ldr       x1, =ASM_PFX(CommonExceptionEntry)
> +  br        x1
> +  .ltorg
> +  .endm

The simplification to push the context save into the vector slot looks good to 
me.

Although I see why you defined a macro for saving exception context (avoiding 
duplication) I'm not sure if this is a good idea.  I'm envisioning stepping 
through the exception handling with a debugger and the resulting confusion 
because of the code hiding behind the macro.  My preference would be to 
tolerate the duplication (it's just 5 lines of assembly) in favor of 
readability / debuggability.

Thanks,
 
Eugene
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel

Reply via email to