xpcom/reflect/xptcall/src/md/unix/xptcstubs_netbsd_m68k.cpp

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/xpcom/reflect/xptcall/src/md/unix/xptcstubs_netbsd_m68k.cpp	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,115 @@
     1.4 +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
     1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.8 +
     1.9 +/* Implement shared vtbl methods. */
    1.10 +
    1.11 +#include "xptcprivate.h"
    1.12 +
    1.13 +#if !defined(__NetBSD__) || !defined(__m68k__)
    1.14 +#error This code is for NetBSD/m68k only
    1.15 +#endif
    1.16 +
    1.17 +extern "C" {
    1.18 +    static nsresult ATTRIBUTE_USED
    1.19 +    PrepareAndDispatch(nsXPTCStubBase* self, uint32_t methodIndex, uint32_t* args)
    1.20 +    {
    1.21 +#define PARAM_BUFFER_COUNT     16
    1.22 +
    1.23 +        nsXPTCMiniVariant paramBuffer[PARAM_BUFFER_COUNT];
    1.24 +        nsXPTCMiniVariant* dispatchParams = nullptr;
    1.25 +        nsIInterfaceInfo* iface_info = nullptr;
    1.26 +        const nsXPTMethodInfo* info;
    1.27 +        uint8_t paramCount;
    1.28 +        uint8_t i;
    1.29 +        nsresult result = NS_ERROR_FAILURE;
    1.30 +
    1.31 +        NS_ASSERTION(self,"no self");
    1.32 +
    1.33 +        self->GetInterfaceInfo(&iface_info);
    1.34 +        NS_ASSERTION(iface_info,"no interface info");
    1.35 +
    1.36 +        iface_info->GetMethodInfo(uint16_t(methodIndex), &info);
    1.37 +        NS_ASSERTION(info,"no interface info");
    1.38 +
    1.39 +        paramCount = info->GetParamCount();
    1.40 +
    1.41 +        // setup variant array pointer
    1.42 +        if(paramCount > PARAM_BUFFER_COUNT)
    1.43 +            dispatchParams = new nsXPTCMiniVariant[paramCount];
    1.44 +        else
    1.45 +            dispatchParams = paramBuffer;
    1.46 +        NS_ASSERTION(dispatchParams,"no place for params");
    1.47 +
    1.48 +        uint32_t* ap = args;
    1.49 +        for(i = 0; i < paramCount; i++, ap++)
    1.50 +        {
    1.51 +            const nsXPTParamInfo& param = info->GetParam(i);
    1.52 +            const nsXPTType& type = param.GetType();
    1.53 +            nsXPTCMiniVariant* dp = &dispatchParams[i];
    1.54 +
    1.55 +            if(param.IsOut() || !type.IsArithmetic())
    1.56 +            {
    1.57 +                dp->val.p = (void*) *ap;
    1.58 +                continue;
    1.59 +            }
    1.60 +
    1.61 +            switch(type)
    1.62 +            {
    1.63 +            // the 8 and 16 bit types will have been promoted to 32 bits before
    1.64 +            // being pushed onto the stack. Since the 68k is big endian, we
    1.65 +            // need to skip over the leading high order bytes.
    1.66 +            case nsXPTType::T_I8     : dp->val.i8  = *(((int8_t*) ap) + 3);  break;
    1.67 +            case nsXPTType::T_I16    : dp->val.i16 = *(((int16_t*) ap) + 1); break;
    1.68 +            case nsXPTType::T_I32    : dp->val.i32 = *((int32_t*) ap);       break;
    1.69 +            case nsXPTType::T_I64    : dp->val.i64 = *((int64_t*) ap); ap++; break;
    1.70 +            case nsXPTType::T_U8     : dp->val.u8  = *(((uint8_t*) ap) + 3); break;
    1.71 +            case nsXPTType::T_U16    : dp->val.u16 = *(((uint16_t*)ap) + 1); break;
    1.72 +            case nsXPTType::T_U32    : dp->val.u32 = *((uint32_t*)ap);       break;
    1.73 +            case nsXPTType::T_U64    : dp->val.u64 = *((uint64_t*)ap); ap++; break;
    1.74 +            case nsXPTType::T_FLOAT  : dp->val.f   = *((float*)   ap);       break;
    1.75 +            case nsXPTType::T_DOUBLE : dp->val.d   = *((double*)  ap); ap++; break;
    1.76 +            case nsXPTType::T_BOOL   : dp->val.b   = *(((char*)   ap) + 3);  break;
    1.77 +            case nsXPTType::T_CHAR   : dp->val.c   = *(((char*)   ap) + 3);  break;
    1.78 +            // wchar_t is an int (32 bits) on NetBSD
    1.79 +            case nsXPTType::T_WCHAR  : dp->val.wc  = *((wchar_t*) ap);       break;
    1.80 +            default:
    1.81 +                NS_ERROR("bad type");
    1.82 +                break;
    1.83 +            }
    1.84 +        }
    1.85 +
    1.86 +        result = self->CallMethod((uint16_t)methodIndex, info, dispatchParams);
    1.87 +
    1.88 +        NS_RELEASE(iface_info);
    1.89 +
    1.90 +        if(dispatchParams != paramBuffer)
    1.91 +            delete [] dispatchParams;
    1.92 +
    1.93 +        return result;
    1.94 +    }
    1.95 +}
    1.96 +
    1.97 +#define STUB_ENTRY(n)							\
    1.98 +__asm__(								\
    1.99 +    ".global	_Stub"#n"__14nsXPTCStubBase\n\t"			\
   1.100 +"_Stub"#n"__14nsXPTCStubBase:\n\t"					\
   1.101 +    "link  a6,#0			\n\t"				\
   1.102 +    "lea   a6@(12), a0			\n\t"	/* pointer to args */	\
   1.103 +    "movl  a0, sp@-			\n\t"				\
   1.104 +    "movl  #"#n", sp@-			\n\t"	/* method index */	\
   1.105 +    "movl  a6@(8), sp@-			\n\t"	/* this */		\
   1.106 +    "jbsr  _PrepareAndDispatch		\n\t"				\
   1.107 +    "unlk  a6				\n\t"				\
   1.108 +    "rts				\n\t"				\
   1.109 +);
   1.110 +
   1.111 +#define SENTINEL_ENTRY(n) \
   1.112 +nsresult nsXPTCStubBase::Sentinel##n() \
   1.113 +{ \
   1.114 +    NS_ERROR("nsXPTCStubBase::Sentinel called"); \
   1.115 +    return NS_ERROR_NOT_IMPLEMENTED; \
   1.116 +}
   1.117 +
   1.118 +#include "xptcstubsdef.inc"

mercurial