URL
https://opencores.org/ocsvn/openrisc/openrisc/trunk
Subversion Repositories openrisc
[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [libgcc/] [config/] [rl78/] [trampoline.S] - Rev 734
Compare with Previous | Blame | View Log
/* libgcc routines for RL78Copyright (C) 2011Free Software Foundation, Inc.Contributed by Red Hat.This file is part of GCC.GCC is free software; you can redistribute it and/or modify itunder the terms of the GNU General Public License as publishedby the Free Software Foundation; either version 3, or (at youroption) any later version.GCC is distributed in the hope that it will be useful, but WITHOUTANY WARRANTY; without even the implied warranty of MERCHANTABILITYor FITNESS FOR A PARTICULAR PURPOSE. See the GNU General PublicLicense for more details.Under Section 7 of GPL version 3, you are granted additionalpermissions described in the GCC Runtime Library Exception, version3.1, as published by the Free Software Foundation.You should have received a copy of the GNU General Public License anda copy of the GCC Runtime Library Exception along with this program;see the files COPYING3 and COPYING.RUNTIME respectively. If not, see<http://www.gnu.org/licenses/>. *//* RL78 Trampoline supportSince the RL78's RAM is not in the first 64k, we cannot "just" use afunction pointer to point to a trampoline on the stack. So, wecreate N fixed trampolines that read from an array, and allocatethem as needed.*/r8 = 0xffef0r10 = 0xffef2r14 = 0xffef6.data.p2align 1trampoline_array:.macro stub n.texttrampoline_\n:.type trampoline_\n, @functionmovw ax, !trampoline_chain_\nmovw r14, axmovw ax, !trampoline_addr_\nbr ax.size trampoline_\n, .-trampoline_\n.datatrampoline_frame_\n:.short 0trampoline_stub_\n:.short trampoline_\ntrampoline_chain_\n:.short 0trampoline_addr_\n:.short 0#define TO_FRAME 0#define TO_STUB 2#define TO_CHAIN 4#define TO_ADDR 6#define TO_SIZE 8.endmstub 0stub 1stub 2stub 3stub 4stub 5trampoline_array_end:/* Given the function pointer in R8 and the static chainpointer in R10, allocate a trampoline and return its address inR8. */.text.global ___trampoline_init.type ___trampoline_init, @function___trampoline_init:movw hl, #trampoline_array1:movw ax, [hl + TO_ADDR]cmpw ax, #0bz $2fmovw ax, hladdw ax, #TO_SIZEmovw hl, axcmpw ax, #trampoline_array_endbnz $1bbrk ; no more slots?2: movw ax, r8movw [hl + TO_ADDR], axmovw ax, r10movw [hl + TO_CHAIN], axmovw ax, spmovw [hl + TO_FRAME], axmovw ax, [hl + TO_STUB]movw r8, axret.size ___trampoline_init, . - ___trampoline_init.global ___trampoline_uninit.type ___trampoline_uninit, @function___trampoline_uninit:movw hl, #trampoline_arraymovw ax, spmovw bc, ax1:movw ax, [hl + TO_FRAME]cmpw ax, bcbc $2fclrw axmovw [hl + TO_ADDR], ax2:movw ax, hladdw ax, #TO_SIZEmovw hl, axcmpw ax, #trampoline_array_endbnz $1bret.size ___trampoline_uninit, . - ___trampoline_uninit
