From: Scott Wood Date: Fri, 22 Apr 2011 03:37:54 +0000 (-0500) Subject: Random stuff. X-Git-Url: http://git.buserror.net/cgi-bin/gitweb.cgi?p=polintos%2Fscott%2Fpriv.git;a=commitdiff_plain;h=139f54779f6395a1828261423cd8013ca940ff36 Random stuff. Random stuff lying around uncommitted from when I last worked on this a couple years ago. It's not in a good state, but the commit before it probably wasn't either. Signed-off-by: Scott Wood --- diff --git a/doc/abi/x86 b/doc/abi/x86 index 7a11bd1..a095a79 100644 --- a/doc/abi/x86 +++ b/doc/abi/x86 @@ -13,15 +13,16 @@ Out-of-Process Method Invocation: function will search for an exception handling function that covers the calling address. If none is found, it will assume that it is a language without exception - handling, an5Ad return the exception to the caller in eax. + handling, and return the exception to the caller in eax. edx: length of exception segment, if any ecx: may be clobbered Callee: - eax: pointer to PIB - edx: pointer to caller information struct, or NULL if not - requested - esp: NULL. + eax: object ID + edx: segment zero size + ecx: total size + ebx: method ID + esp, ebp, esi, edi: NULL. Jump to 0x7fff0080 to return. @@ -31,9 +32,9 @@ Out-of-Process Method Invocation: ebx, ecx, esi, edi, ebp, esp: may be clobbered Other system calls: - eax, edx, ecx: syscall arguments. + eax, edx, ecx: syscall arguments. - Call 0x7fff0000 + 0x80 * syscallnum + Call 0x7fff0000 + 0x80 * syscallnum - eax: return value - edx, ecx: may be clobbered + eax: return value + edx, ecx: may be clobbered diff --git a/doc/orb/parameter-info-block b/doc/orb/parameter-info-block index c4f1768..7c9b3d8 100644 --- a/doc/orb/parameter-info-block +++ b/doc/orb/parameter-info-block @@ -24,9 +24,7 @@ Parameter Info Block (PIB) This is like buffer_size, but for Copy segments. objlist_ptr pointer Pointer to the object list - newobj_ptr pointer Pointer to the new object list. objlist_len 32-bit Length of the object list, in IDs - newobj_len 32-bit Length of the new object list, in entries. The object list is a special segment that contains object IDs rather than arbitrary data. Each object ID will be translated @@ -38,8 +36,7 @@ Parameter Info Block (PIB) Objects which live in this address space have the high bit clear; remote objects have the high bit set. When sending an object reference that has not been exposed to the kernel - before, its interface hash (SHA-1 of interface GUIDs) should - exist in the newobj list. + before, the new_object() syscall must first be called. num_segments 32-bit Number of data segments diff --git a/idlcomp/BUGS b/idlcomp/BUGS index fc1be9d..8a8090c 100644 --- a/idlcomp/BUGS +++ b/idlcomp/BUGS @@ -2,3 +2,5 @@ IDLC does not check whether the contents of a bitfield or enum fit within the specified size. IDLC does not check for loops in the inheritance chain. + +oldptr not underscored diff --git a/idlcomp/idlc.h b/idlcomp/idlc.h index 414d14a..56dfefe 100644 --- a/idlcomp/idlc.h +++ b/idlcomp/idlc.h @@ -30,6 +30,7 @@ #include #include #include +#include #include "compileddef.h" @@ -824,9 +825,9 @@ protected: CompiledDefHeader hdr; // sym is the symbol from which to get the path/name, and - // dir is true if it should be "name/.self" rather than + // is_dir is true if it should be "name/.self" rather than // "name". - void output_self(const char *dir, Symbol *sym, bool dir); + void output_self(const char *dir, Symbol *sym, bool is_dir); public: Def(const char *self, int self_len, CompiledDefHeader::Type type) : diff --git a/idlcomp/idlparse.y b/idlcomp/idlparse.y index a6f30e9..23bd8fd 100644 --- a/idlcomp/idlparse.y +++ b/idlcomp/idlparse.y @@ -421,15 +421,14 @@ param: } ; -more_params: - /* empty */ -| ',' param_list +param_list_nonempty: + param +| param_list_nonempty ',' param ; param_list: /* empty */ -| param more_params -; +| param_list_nonempty method: ident '(' { diff --git a/idlcomp/input.cc b/idlcomp/input.cc index 1ef953d..80a5f87 100644 --- a/idlcomp/input.cc +++ b/idlcomp/input.cc @@ -271,7 +271,7 @@ StrList::StrList(const String *input, char delimeter) const char *cur = input->c_str(); do { - char *next = strchr(cur, delimeter); + const char *next = strchr(cur, delimeter); String *s = new String(); s->token = TOK_IDENT; diff --git a/idlcomp/main.cc b/idlcomp/main.cc index a02453c..00c2151 100644 --- a/idlcomp/main.cc +++ b/idlcomp/main.cc @@ -349,7 +349,7 @@ static void longopt(const char *s, const char *arg) } else if (!strcmp(s, "show-targets")) { printf("Supported target architectures:\n"); for (int i = 1; i <= max_target; i++) - printf(" %s\n", targets[i].name); + printf(" %s\n", targets[i].name); printf("\n"); exit(0); } else if (!strcmp(s, "server")) { @@ -361,7 +361,7 @@ static void longopt(const char *s, const char *arg) } static int global_argc; -static const char **global_argv; +static char **global_argv; static int got_dashdash; static void process_args(void) @@ -372,7 +372,7 @@ static void process_args(void) for (i = 1; i < global_argc; i++) { if (global_argv[i][0] == '-' && global_argv[i][1] && !got_dashdash) { - const char *opt = global_argv[i]; + char *opt = global_argv[i]; if (opt[1] == '-') { if (!opt[2]) { @@ -719,7 +719,7 @@ void language_output() autorelease_pool.clean(); } -int run_idlc(int argc, const char **argv) +int run_idlc(int argc, char **argv) { global_argc = argc; global_argv = argv; @@ -783,7 +783,7 @@ int run_idlc(int argc, const char **argv) return 0; } -int main(int argc, const char **argv) +int main(int argc, char **argv) { int ret = run_idlc(argc, argv); autorelease_pool.clean(); diff --git a/include/c/std/string.h b/include/c/std/string.h index 6c2f4c9..e50633c 100644 --- a/include/c/std/string.h +++ b/include/c/std/string.h @@ -18,7 +18,7 @@ extern "C" { char *strcat(char *dest, const char *src); char *strncat(char *dest, const char *src, size_t len); int strcmp(const char *s1, const char *s2); - int strncmp(const char *s1, const char *s2, int n); + int strncmp(const char *s1, const char *s2, size_t n); #ifdef __cplusplus char *strchr(char *s, int c); diff --git a/kernel/arch/x86/descriptors.cc b/kernel/arch/x86/descriptors.cc index 35e11f9..172e4e4 100644 --- a/kernel/arch/x86/descriptors.cc +++ b/kernel/arch/x86/descriptors.cc @@ -183,7 +183,7 @@ static void set_int_gate(int num, void *addrptr, bool ints_off = false, extern int x86_diverr, x86_debug, x86_breakpoint; extern int x86_gpf, x86_page_fault, x86_invalid_insn; -extern int x86_int98_entry, x86_int99_entry; +extern int x86_int98_entry, x86_int99_entry, x86_int9a_entry, x86_int9b_entry; extern void *x86_irqs[256]; namespace Arch { @@ -203,6 +203,8 @@ namespace Priv { set_int_gate(14, &x86_page_fault, true); set_int_gate(0x98, &x86_int98_entry, false, true); set_int_gate(0x99, &x86_int99_entry, false, true); + set_int_gate(0x9a, &x86_int9a_entry, false, true); + set_int_gate(0x9b, &x86_int9b_entry, false, true); for (int i = 0x20; i < 0x30; i++) set_int_gate(i, x86_irqs[i], true); diff --git a/kernel/arch/x86/entry.S b/kernel/arch/x86/entry.S index 8d4ede4..8308fb7 100644 --- a/kernel/arch/x86/entry.S +++ b/kernel/arch/x86/entry.S @@ -321,6 +321,38 @@ x86_int99_entry: movl $ROSHARED_PTR(x86_shared_int98_ret), (%esp) iret + .global x86_int9a_entry +x86_int9a_entry: + pushl %edx + pushl %eax + enterkernel %edx + + pushl %esp + call x86_new_object + addl $4, %esp + + exitkernel + popl %eax + xorl %ecx, %ecx + xorl %edx, %edx + iret + + .global x86_int9b_entry +x86_int9b_entry: + pushl %edx + pushl %eax + enterkernel %edx + + pushl %esp + call x86_get_iface_hash + addl $4, %esp + + exitkernel + popl %eax + xorl %ecx, %ecx + xorl %edx, %edx + iret + .global x86_irq x86_irq: pushvolatilesnoeax @@ -430,6 +462,16 @@ x86_shared_int99: int $0x99 ret + . = roshared + 0x100 +x86_shared_int9a: + int $0x9a + ret + + . = roshared + 0x180 +x86_shared_int9b: + int $0x9b + ret + .global test_user_ptr test_user_ptr: .long ROSHARED_PTR(test_user) diff --git a/kernel/arch/x86/misc.cc b/kernel/arch/x86/misc.cc index 3e0091a..a458a56 100644 --- a/kernel/arch/x86/misc.cc +++ b/kernel/arch/x86/misc.cc @@ -253,11 +253,13 @@ namespace Priv { union { System::RunTime::ParamInfoBlock *pib; uintptr_t exptr; + uintptr_t arg0; }; union { uintptr_t caller; size_t exlen; + uintptr_t arg1; }; ulong eip, cs, eflags, user_esp, user_ss; @@ -298,3 +300,15 @@ extern "C" void x86_return_from_method(Arch::Priv::OrbRegs *regs) assert(regs->cs & 3); regs->user_esp = ORB::return_from_method(regs->exptr, regs->exlen); } + +extern "C" void x86_new_object(Arch::Priv::OrbRegs *regs) +{ + assert(regs->cs & 3); + regs->arg0 = 0; +} + +extern "C" void x86_get_iface_hash(Arch::Priv::OrbRegs *regs) +{ + assert(regs->cs & 3); + regs->arg0 = 0; +} diff --git a/kernel/include/kern/orb.h b/kernel/include/kern/orb.h index f965434..22664ec 100644 --- a/kernel/include/kern/orb.h +++ b/kernel/include/kern/orb.h @@ -49,17 +49,9 @@ namespace ORB { CallFrame frames[0]; }; + static const ID invalid_id = 0xffffffff; struct ObjectHdr { ID id; - - union { - struct { - u32 Valid:1; - u32 Pointer:1; - }; - - u32 flags; - }; }; struct Object : public ObjectHdr { @@ -70,19 +62,15 @@ namespace ORB { Object *object; }; - union ObjTableEntry { - ObjectHdr hdr; - Object obj; - ObjectPtr ptr; - }; - - typedef Util::RadixTree IDTable; + typedef Util::RadixTree LocalIDTable; + typedef Util::RadixTree RemoteIDTable; typedef Util::RBPtr IDRMap; typedef Util::BitmapTree IDAlloc; class IDSpace { Lock::SpinLock lock; // For add/del only; not needed for lookup - IDTable table; // Forward mapping of local IDs to object ptrs + LocalIDTable locals; // Objects that live in this address space + RemoteIDTable remotes; // Objects that live in other address spaces IDRMap rmap; // Reverse mapping of remote object pointers to local IDs IDAlloc alloc; // Bitmap for allocating IDs diff --git a/kernel/orb/invoke.cc b/kernel/orb/invoke.cc index ced7ad8..abfe237 100644 --- a/kernel/orb/invoke.cc +++ b/kernel/orb/invoke.cc @@ -57,7 +57,7 @@ namespace ORB { { // FIXME: refcounting ObjTableEntry *ote = table.lookup(id); - if (!ote || !ote->hdr.Valid) + if (!ote || ote->hdr.id == invalid_id) return NULL; if (ote->hdr.Pointer) diff --git a/lib/c/freestanding/string.c b/lib/c/freestanding/string.c index 45eb246..77c13ef 100644 --- a/lib/c/freestanding/string.c +++ b/lib/c/freestanding/string.c @@ -153,9 +153,9 @@ int strcmp(const char *s1, const char *s2) return (unsigned char)*s2 - (unsigned char)*s1; } -int strncmp(const char *s1, const char *s2, int n) +int strncmp(const char *s1, const char *s2, size_t n) { - int i = 0; + size_t i = 0; while (i < n && s1[i] && s2[i] && s1[i] == s2[i]) i++;