Exemple #1
0
guint
serializeio_count_xdeltachecksum (guint16 high, guint16 low) {
  guint size = sizeof (SerialXdeltaChecksum);
  ALIGN_8 (size);
  ALIGN_8 (size);
  ALIGN_8 (size);
  return size;
}
Exemple #2
0
guint
serializeio_count_version0instruction (guint32 offset, guint32 length) {
  guint size = sizeof (SerialVersion0Instruction);
  ALIGN_8 (size);
  ALIGN_8 (size);
  ALIGN_8 (size);
  return size;
}
Exemple #3
0
guint
serializeio_count_xdeltainstruction (guint32 index, guint32 offset, guint32 length) {
  guint size = sizeof (SerialXdeltaInstruction);
  ALIGN_8 (size);
  ALIGN_8 (size);
  ALIGN_8 (size);
  ALIGN_8 (size);
  return size;
}
Exemple #4
0
guint
serializeio_count_rsyncindexelt (const guint8 md5[16], SerialXdeltaChecksum const* cksum) {
  guint size = sizeof (SerialRsyncIndexElt);
  ALIGN_8 (size);
  ALIGN_8 (size);
  size += serializeio_count_xdeltachecksum_obj (cksum) - sizeof (SerialXdeltaChecksum);
  ALIGN_8 (size);
  return size;
}
Exemple #5
0
guint
serializeio_count_version0sourceinfo (const guint8 md5[16], const guint8 real_md5[16], guint32 length) {
  guint size = sizeof (SerialVersion0SourceInfo);
  ALIGN_8 (size);
  ALIGN_8 (size);
  ALIGN_8 (size);
  ALIGN_8 (size);
  return size;
}
Exemple #6
0
guint
serializeio_count_xdeltaindex (guint32 file_len, const guint8 file_md5[16], guint32 index_len, SerialXdeltaChecksum const* index) {
  guint size = sizeof (SerialXdeltaIndex);
  ALIGN_8 (size);
  ALIGN_8 (size);
  ALIGN_8 (size);
  {
    gint i;
    for (i = 0; i < index_len; i += 1)
      {
        size += serializeio_count_xdeltachecksum_obj (& (index[i]));
      }
  }
  ALIGN_8 (size);
  return size;
}
Exemple #7
0
Fichier : hw_vm.c Projet : 5kg/gdb
static int
hw_vm_ioctl(device *me,
	    cpu *processor,
	    unsigned_word cia,
	    device_ioctl_request request,
	    va_list ap)
{
  /* While the caller is notified that the heap has grown by the
     requested amount, the heap is actually extended out to a page
     boundary. */
  hw_vm_device *vm = (hw_vm_device*)device_data(me);
  switch (request) {
  case device_ioctl_break:
    {
      unsigned_word requested_break = va_arg(ap, unsigned_word);
      unsigned_word new_break = ALIGN_8(requested_break);
      unsigned_word old_break = vm->heap_bound;
      signed_word delta = new_break - old_break;
      if (delta > 0)
	vm->heap_bound = ALIGN_PAGE(new_break);
      break;
    }
  default:
    device_error(me, "Unsupported ioctl request");
    break;
  }
  return 0;
    
}
Exemple #8
0
guint
serializeio_count_rsyncindex (guint32 seg_len, guint32 file_len, const guint8 file_md5[16], guint32 index_len, SerialRsyncIndexElt const* index) {
  guint size = sizeof (SerialRsyncIndex);
  ALIGN_8 (size);
  ALIGN_8 (size);
  ALIGN_8 (size);
  ALIGN_8 (size);
  {
    gint i;
    for (i = 0; i < index_len; i += 1)
      {
        size += serializeio_count_rsyncindexelt_obj (& (index[i]));
      }
  }
  ALIGN_8 (size);
  return size;
}
Exemple #9
0
int decompress_startswith_xz(const void *src, uint64_t src_size,
                             void **buffer, size_t *buffer_size,
                             const void *prefix, size_t prefix_len,
                             uint8_t extra) {

#ifdef HAVE_XZ
        _cleanup_(lzma_end) lzma_stream s = LZMA_STREAM_INIT;
        lzma_ret ret;

        /* Checks whether the decompressed blob starts with the
         * mentioned prefix. The byte extra needs to follow the
         * prefix */

        assert(src);
        assert(src_size > 0);
        assert(buffer);
        assert(buffer_size);
        assert(prefix);
        assert(*buffer_size == 0 || *buffer);

        ret = lzma_stream_decoder(&s, UINT64_MAX, 0);
        if (ret != LZMA_OK)
                return -EBADMSG;

        if (!(greedy_realloc(buffer, buffer_size, ALIGN_8(prefix_len + 1), 1)))
                return -ENOMEM;

        s.next_in = src;
        s.avail_in = src_size;

        s.next_out = *buffer;
        s.avail_out = *buffer_size;

        for (;;) {
                ret = lzma_code(&s, LZMA_FINISH);

                if (ret != LZMA_STREAM_END && ret != LZMA_OK)
                        return -EBADMSG;

                if (*buffer_size - s.avail_out >= prefix_len + 1)
                        return memcmp(*buffer, prefix, prefix_len) == 0 &&
                                ((const uint8_t*) *buffer)[prefix_len] == extra;

                if (ret == LZMA_STREAM_END)
                        return 0;

                s.avail_out += *buffer_size;

                if (!(greedy_realloc(buffer, buffer_size, *buffer_size * 2, 1)))
                        return -ENOMEM;

                s.next_out = *buffer + *buffer_size - s.avail_out;
        }

#else
        return -EPROTONOSUPPORT;
#endif
}
Exemple #10
0
guint
serializeio_count_version0control (gboolean normalized, guint32 data_len, SerialVersion0SourceInfo const* to_info, guint32 source_info_len, SerialVersion0SourceInfo* const* source_info, guint32 inst_len, SerialVersion0Instruction const* inst) {
  guint size = sizeof (SerialVersion0Control);
  ALIGN_8 (size);
  ALIGN_8 (size);
  ALIGN_8 (size);
  size += serializeio_count_version0sourceinfo_obj (to_info) - sizeof (SerialVersion0SourceInfo);
  ALIGN_8 (size);
  {
    gint i;
    for (i = 0; i < source_info_len; i += 1)
      {
        size += serializeio_count_version0sourceinfo_obj ((source_info[i])) + sizeof (void*);
      }
  }
  ALIGN_8 (size);
  {
    gint i;
    for (i = 0; i < inst_len; i += 1)
      {
        size += serializeio_count_version0instruction_obj (& (inst[i]));
      }
  }
  ALIGN_8 (size);
  return size;
}
Exemple #11
0
guint
serializeio_count_xdeltacontrol (const guint8 to_md5[16], guint32 to_len, gboolean has_data, guint32 source_info_len, SerialXdeltaSourceInfo* const* source_info, guint32 inst_len, SerialXdeltaInstruction const* inst) {
  guint size = sizeof (SerialXdeltaControl);
  ALIGN_8 (size);
  ALIGN_8 (size);
  ALIGN_8 (size);
  ALIGN_8 (size);
  {
    gint i;
    for (i = 0; i < source_info_len; i += 1)
      {
        size += serializeio_count_xdeltasourceinfo_obj ((source_info[i])) + sizeof (void*);
      }
  }
  ALIGN_8 (size);
  {
    gint i;
    for (i = 0; i < inst_len; i += 1)
      {
        size += serializeio_count_xdeltainstruction_obj (& (inst[i]));
      }
  }
  ALIGN_8 (size);
  return size;
}
Exemple #12
0
static void
write_stack_arguments(device *me,
		      char **arg,
		      unsigned_word start_block,
		      unsigned_word end_block,
		      unsigned_word start_arg,
		      unsigned_word end_arg)
{
  DTRACE(stack,
	("write_stack_arguments(device=%s, arg=0x%lx, start_block=0x%lx, end_block=0x%lx, start_arg=0x%lx, end_arg=0x%lx)\n",
	 device_name(me), (long)arg, (long)start_block, (long)end_block, (long)start_arg, (long)end_arg));
  if (arg == NULL)
    device_error(me, "Attempt to write a null array onto the stack\n");
  /* only copy in arguments, memory is already zero */
  for (; *arg != NULL; arg++) {
    int len = strlen(*arg)+1;
    unsigned_word target_start_block;
    DTRACE(stack,
	  ("write_stack_arguments() write %s=%s at %s=0x%lx %s=0x%lx %s=0x%lx\n",
	   "**arg", *arg, "start_block", (long)start_block,
	   "len", (long)len, "start_arg", (long)start_arg));
    if (psim_write_memory(device_system(me), 0, *arg,
			  start_block, len,
			  0/*violate_readonly*/) != len)
      device_error(me, "Write of **arg (%s) at 0x%lx of stack failed\n",
		   *arg, (unsigned long)start_block);
    target_start_block = H2T_word(start_block);
    if (psim_write_memory(device_system(me), 0, &target_start_block,
			  start_arg, sizeof(target_start_block),
			  0) != sizeof(target_start_block))
      device_error(me, "Write of *arg onto stack failed\n");
    start_block += ALIGN_8(len);
    start_arg += sizeof(start_block);
  }
  start_arg += sizeof(start_block); /*the null at the end*/
  if (start_block != end_block
      || ALIGN_8(start_arg) != end_arg)
    device_error(me, "Probable corrpution of stack arguments\n");
  DTRACE(stack, ("write_stack_arguments() = void\n"));
}
Exemple #13
0
static void
create_ppc_elf_stack_frame(device *me,
			   unsigned_word bottom_of_stack,
			   char **argv,
			   char **envp)
{
  /* fixme - this is over aligned */

  /* information block */
  const unsigned sizeof_envp_block = sizeof_argument_strings(envp);
  const unsigned_word start_envp_block = bottom_of_stack - sizeof_envp_block;
  const unsigned sizeof_argv_block = sizeof_argument_strings(argv);
  const unsigned_word start_argv_block = start_envp_block - sizeof_argv_block;

  /* auxiliary vector - contains only one entry */
  const unsigned sizeof_aux_entry = 2*sizeof(unsigned_word); /* magic */
  const unsigned_word start_aux = start_argv_block - ALIGN_8(sizeof_aux_entry);

  /* environment points (including null sentinal) */
  const unsigned sizeof_envp = sizeof_arguments(envp);
  const unsigned_word start_envp = start_aux - sizeof_envp;

  /* argument pointers (including null sentinal) */
  const int argc = number_of_arguments(argv);
  const unsigned sizeof_argv = sizeof_arguments(argv);
  const unsigned_word start_argv = start_envp - sizeof_argv;

  /* link register save address - alligned to a 16byte boundary */
  const unsigned_word top_of_stack = ((start_argv
				       - 2 * sizeof(unsigned_word))
				      & ~0xf);

  /* install arguments on stack */
  write_stack_arguments(me, envp,
			start_envp_block, bottom_of_stack,
			start_envp, start_aux);
  write_stack_arguments(me, argv,
			start_argv_block, start_envp_block,
			start_argv, start_envp);

  /* set up the registers */
  psim_write_register(device_system(me), -1,
		      &top_of_stack, "sp", cooked_transfer);
  psim_write_register(device_system(me), -1,
		      &argc, "r3", cooked_transfer);
  psim_write_register(device_system(me), -1,
		      &start_argv, "r4", cooked_transfer);
  psim_write_register(device_system(me), -1,
		      &start_envp, "r5", cooked_transfer);
  psim_write_register(device_system(me), -1,
		      &start_aux, "r6", cooked_transfer);
}
Exemple #14
0
static int
sizeof_argument_strings(char **arg)
{
  int sizeof_strings = 0;

  /* robust */
  if (arg == NULL)
    return 0;

  /* add up all the string sizes (padding as we go) */
  for (; *arg != NULL; arg++) {
    int len = strlen(*arg) + 1;
    sizeof_strings += ALIGN_8(len);
  }

  return sizeof_strings;
}
Exemple #15
0
guint
serializeio_count_xdeltasourceinfo (const gchar* name, const guint8 md5[16], guint32 len, gboolean isdata, gboolean sequential) {
  guint size = sizeof (SerialXdeltaSourceInfo);
  ALIGN_8 (size);
  size += strlen (name) + 1;
  ALIGN_8 (size);
  ALIGN_8 (size);
  ALIGN_8 (size);
  ALIGN_8 (size);
  ALIGN_8 (size);
  return size;
}
Exemple #16
0
int decompress_startswith_lz4(const void *src, uint64_t src_size,
                              void **buffer, size_t *buffer_size,
                              const void *prefix, size_t prefix_len,
                              uint8_t extra) {
#ifdef HAVE_LZ4
        /* Checks whether the decompressed blob starts with the
         * mentioned prefix. The byte extra needs to follow the
         * prefix */

        int r;

        assert(src);
        assert(src_size > 0);
        assert(buffer);
        assert(buffer_size);
        assert(prefix);
        assert(*buffer_size == 0 || *buffer);

        if (src_size <= 8)
                return -EBADMSG;

        if (!(greedy_realloc(buffer, buffer_size, ALIGN_8(prefix_len + 1), 1)))
                return -ENOMEM;

        r = LZ4_decompress_safe_partial(src + 8, *buffer, src_size - 8,
                                        prefix_len + 1, *buffer_size);

        if (r < 0)
                return -EBADMSG;
        if ((unsigned) r >= prefix_len + 1)
                return memcmp(*buffer, prefix, prefix_len) == 0 &&
                        ((const uint8_t*) *buffer)[prefix_len] == extra;
        else
                return 0;

#else
        return -EPROTONOSUPPORT;
#endif
}
Exemple #17
0
static int
sizeof_arguments(char **arg)
{
  return ALIGN_8((number_of_arguments(arg) + 1) * sizeof(unsigned_word));
}