X-Git-Url: http://git.buserror.net/cgi-bin/gitweb.cgi?p=polintos%2Fscott%2Fpriv.git;a=blobdiff_plain;f=include%2Fc%2B%2B%2Forb.h;h=23f0b72571ad07e544855e6d7c26748c2ccb456e;hp=87bcd246ca713ed6f024bc948144517d6a9be8ed;hb=b5cbe98949d5b279965d607c9618d404b26d4760;hpb=b4bfc871337ca32ce83407916a87db2524729ca9 diff --git a/include/c++/orb.h b/include/c++/orb.h index 87bcd24..23f0b72 100644 --- a/include/c++/orb.h +++ b/include/c++/orb.h @@ -25,15 +25,10 @@ namespace System { ORBMM(); - void *alloc(size_t size, AllocGroup *group = NULL); - - void retain(Region region); - void release(Region region); - void super_retain(Region region); - void super_release(Region region); - AllocGroup *create_group(); - void destroy_group(AllocGroup *group); - void *add_region(Region region); + void *alloc(size_t size, int refs = 1); + void retain(void *ptr, int refs = 1); + void release(void *ptr, int refs = 1); + void add_region(Region region, bool unmap_orig, int refs = 1); }; extern ORBMM *orbmm; @@ -264,6 +259,9 @@ namespace System { uintptr_t downcast(::System::_i_Object *obj, const unsigned long *new_guid); + typedef uint64_t GUID[2]; + + // FIXME: use above typedef static inline bool guids_equal(const unsigned long *guid1, const unsigned long *guid2) { @@ -274,39 +272,99 @@ namespace System { guid1[3] == guid2[3]))); } - // Return the caller's PC. It'd be nice if GCC had a builtin for - // the current PC, so that a simple relocation could be used rather - // than a function call. OPT: put this in lowlevel-lib, so that - // architectures can provide a faster version. - - unsigned long get_pc(); - + typedef uint32_t ID; struct ParamInfoBlock { - uintptr_t buffer_size; - uintptr_t *objlist_ptr; - uintptr_t objlist_len; - uintptr_t num_segments; + uint32_t buffer_size; + uint32_t copy_size; + ID *objlist; + uint32_t objlist_len; + uint32_t num_segments; struct Segment { - void *ptr; + uint8_t *ptr; uintptr_t len; uintptr_t flags; uintptr_t reserved; + + enum { + In = 1, + Out = 2, + Inline = 4, + Copy = 8 + }; } segments[0]; }; - } + + struct Segment0 { + enum { + InvokeMethod = 0, + GetIFaces = 1, + ReturnIFaces = 2, + }; + + union { + struct { + uint8_t opcode; + }; + + unsigned long pad; + }; + }; + + struct InvokeMethod { + Segment0 seg0; + uint32_t iface; + uint32_t method; + uint8_t args[0]; + }; + + union Message { + Segment0 seg0; + InvokeMethod invoke; + }; + + namespace Priv { + // Return the caller's PC. It'd be nice if GCC had a builtin for + // the current PC, so that a simple relocation could be used rather + // than a function call. OPT: put this in lowlevel-lib, so that + // architectures can provide a faster version. + + unsigned long get_pc(); + + static inline bool in_kernel() + { +#ifdef _KERNEL + return true; +#else + return false; +#endif + } + } + }; } inline void *operator new(size_t len, ::System::RunTime::ORBMM *orbmm, - ::System::RunTime::ORBMM::AllocGroup *group = NULL) + int refs = 1) { - return orbmm->alloc(len, group); + return orbmm->alloc(len, refs); } inline void *operator new[](size_t len, ::System::RunTime::ORBMM *orbmm, - ::System::RunTime::ORBMM::AllocGroup *group = NULL) + int refs = 1) { - return orbmm->alloc(len, group); + return orbmm->alloc(len, refs); +} + +inline void operator delete(void *ptr, ::System::RunTime::ORBMM *orbmm, + int refs = 1) +{ + orbmm->release(ptr, refs); +} + +inline void operator delete[](void *ptr, ::System::RunTime::ORBMM *orbmm, + int refs = 1) +{ + orbmm->release(ptr, refs); } // This is a macro rather than an inline template function so that the @@ -316,25 +374,22 @@ inline void *operator new[](size_t len, ::System::RunTime::ORBMM *orbmm, // // To throw an IDL exception of type Foo, do this: // throw_idl(Foo, args, to, foo); -// -// FIXME: Instead, maybe a static throw method with noinline and -// builtin_return_address. #ifndef POLINTOS_NO_THROW_IDL #define throw_idl(T, args...) do { \ throw T(NULL, NULL, \ new(::System::RunTime::orbmm) \ ::System::Exceptions::NativeCodeExceptionOriginInfo \ - (::System::RunTime::get_pc()), \ - _KERNEL ? 1 : 0, ##args); \ + (::System::RunTime::Priv::get_pc()), \ + ::System::RunTime::Priv::in_kernel(), ##args); \ } while (0) #define rethrow_idl(oldex, T, args...) do { \ throw T(new(::System::RunTime::orbmm) typeof(oldex)(oldex), NULL, \ new(::System::RunTime::orbmm) \ ::System::Exceptions::NativeCodeExceptionOriginInfo \ - (::System::RunTime::get_pc()), \ - _KERNEL ? 1 : 0, ##args); \ + (::System::RunTime::Priv::get_pc()), \ + ::System::RunTime::Priv::in_kernel(), ##args); \ } while (0) #endif