Skip to content

Commit

Permalink
add comment
Browse files Browse the repository at this point in the history
  • Loading branch information
Omar002 committed Feb 24, 2014
1 parent 9fa334f commit 6918bd0
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions context_switch.s
Original file line number Diff line number Diff line change
@@ -27,13 +27,19 @@ USART2_IRQHandler:
SVC_Handler:
/* save user state */
mrs r0, psp

/*
* this r7 is useless

This comment has been minimized.

Copy link
@jserv

jserv Feb 24, 2014

If you think r7 is useless, why don't you delete it and make it cleaner?

* hardware interrupt need r7 and activate pop r7 so SVC store it
*/
stmdb r0!, {r7}
stmdb r0!, {r4, r5, r6, r7, r8, r9, r10, r11, lr}

/* load kernel state */
pop {r4, r5, r6, r7, r8, r9, r10, r11, ip, lr}
msr psr, ip

/* jump to the next line where activate is called */
bx lr

.global activate
@@ -43,6 +49,7 @@ activate:
push {r4, r5, r6, r7, r8, r9, r10, r11, ip, lr}

/* switch to process stack pointer */
/* reference: Cortex-M3 Devices Generic User Guide Core registers */
msr psp, r0
mov r0, #3
msr control, r0

2 comments on commit 6918bd0

@Omar002
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this r7 has been stored in syscall (ex. line 8 @ syscall.s )
so this r7 is redundant.
but if I delete it, pop @ line 59 go wrong

@jserv
Copy link

@jserv jserv commented on 6918bd0 Feb 24, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since system call is invoked quite frequently, it is worthy to revise these lines. However, we only call something useless only when it has no impact to certain system designs.

Please sign in to comment.