static int ram_console_lastk_show(struct ram_console_buffer *buffer, struct seq_file *m, void *v)
{
	unsigned int wdt_status;
	if (ram_console_check_header(buffer) && buffer->sz_buffer != 0) {
		pr_err("ram_console: buffer %p, size %x(%x)\n", buffer, buffer->sz_buffer, ram_console_buffer->sz_buffer);
		if (buffer)
			seq_write(m, buffer, ram_console_buffer->sz_buffer);
		else
			seq_printf(m, "NO VALID DATA.\n");
		return 0;
	}
	if (buffer->off_pl == 0 || buffer->off_pl + ALIGN(buffer->sz_pl, 64) != buffer->off_lpl) {
		/* workaround for compatiblity to old preloader & lk (OTA) */
		wdt_status = *((unsigned char*)buffer + 12);
	} else
		wdt_status = LAST_RRPL_BUF_VAL(buffer, wdt_status);
	
	seq_printf(m, "ram console header, hw_status: %u, fiq step %u.\n",
		   wdt_status, LAST_RRR_BUF_VAL(buffer, fiq_step));

	if (buffer->off_console != 0 && buffer->off_linux + ALIGN(sizeof(struct last_reboot_reason), 64) == buffer->off_console
	    && buffer->sz_console == buffer->sz_buffer - buffer->off_console && buffer->log_size <= buffer->sz_console &&
	    buffer->log_start <= buffer->sz_console) {
		seq_write(m, (void*)buffer + buffer->off_console + buffer->log_start, buffer->log_size - buffer->log_start);
		seq_write(m, (void*)buffer + buffer->off_console, buffer->log_start);
	} else {
		seq_printf(m, "header may be corrupted, dump the raw buffer for reference only\n");
		seq_write(m, buffer, ram_console_buffer->sz_buffer);
	}
	return 0;
}
static int tpm2_binary_bios_measurements_show(struct seq_file *m, void *v)
{
	struct tpm_chip *chip = m->private;
	struct tpm_bios_log *log = &chip->log;
	struct tcg_pcr_event *event_header = log->bios_event_log;
	struct tcg_pcr_event2 *event = v;
	void *temp_ptr;
	size_t size;

	if (v == SEQ_START_TOKEN) {
		size = sizeof(struct tcg_pcr_event) -
			sizeof(event_header->event) + event_header->event_size;

		temp_ptr = event_header;

		if (size > 0)
			seq_write(m, temp_ptr, size);
	} else {
		size = calc_tpm2_event_size(event, event_header);
		temp_ptr = event;
		if (size > 0)
			seq_write(m, temp_ptr, size);
	}

	return 0;
}
Esempio n. 3
0
static int ram_console_lastk_show(struct ram_console_buffer *buffer, struct seq_file *m, void *v)
{
	unsigned int wdt_status;
	if (ram_console_check_header(buffer) && buffer->sz_buffer != 0) {
		pr_err("ram_console: buffer %p, size %x(%x)\n", buffer, buffer->sz_buffer, ram_console_buffer->sz_buffer);
		if (buffer)
			seq_write(m, buffer, ram_console_buffer->sz_buffer);
		else
			seq_printf(m, "NO VALID DATA.\n");
		return 0;
	}
	if (buffer->off_pl == 0 || buffer->off_pl + ALIGN(buffer->sz_pl, 64) != buffer->off_lpl) {
        pr_err("ram_console OTA: sig(0x%p):0x%x, off_lpl(0x%p):0x%x, off_pl(0x%p):0x%x, sz_pl(0x%p):0x%x, off_lk(0x%p):0x%x, off_llk(0x%p):0x%x,sz_lk(0x%p):0x%x\n", 
            &(buffer->sig), buffer->sig, 
            &(buffer->off_lpl), buffer->off_lpl, 
            &(buffer->off_pl), buffer->off_pl, 
            &(buffer->sz_pl), buffer->sz_pl, 
            &(buffer->off_lk), buffer->off_lk, 
            &(buffer->off_llk), buffer->off_llk,
            &(buffer->sz_lk), buffer->sz_lk);
		/* workaround for compatiblity to old preloader & lk (OTA) */
		wdt_status = *((unsigned char*)buffer + 12);
	} else {
        pr_err("ram_console NON-OTA: sig(0x%p):0x%x, off_lpl(0x%p):0x%x, off_pl(0x%p):0x%x, sz_pl(0x%p):0x%x, off_lk(0x%p):0x%x, off_llk(0x%p):0x%x,sz_lk(0x%p):0x%x\n", 
            &(buffer->sig), buffer->sig, 
            &(buffer->off_lpl), buffer->off_lpl, 
            &(buffer->off_pl), buffer->off_pl, 
            &(buffer->sz_pl), buffer->sz_pl, 
            &(buffer->off_lk), buffer->off_lk, 
            &(buffer->off_llk), buffer->off_llk,
            &(buffer->sz_lk), buffer->sz_lk);
		wdt_status = LAST_RRPL_BUF_VAL(buffer, wdt_status);
    }
	
	seq_printf(m, "ram console header, hw_status: %u, fiq step %u.\n",
		   wdt_status, LAST_RRR_BUF_VAL(buffer, fiq_step));

#ifdef CONFIG_PSTORE_CONSOLE
	pr_err("ram_console: pstore show start\n");
	pstore_console_show(PSTORE_TYPE_CONSOLE, m, v);
	pr_err("ram_console: pstore show end\n");
#else
	if (buffer->off_console != 0 && buffer->off_linux + ALIGN(sizeof(struct last_reboot_reason), 64) == buffer->off_console
	    && buffer->sz_console == buffer->sz_buffer - buffer->off_console && buffer->log_size <= buffer->sz_console &&
	    buffer->log_start <= buffer->sz_console) {
		seq_write(m, (void*)buffer + buffer->off_console + buffer->log_start, buffer->log_size - buffer->log_start);
		seq_write(m, (void*)buffer + buffer->off_console, buffer->log_start);
	} else {
		seq_printf(m, "header may be corrupted, dump the raw buffer for reference only\n");
		seq_write(m, buffer, ram_console_buffer->sz_buffer);
	}
#endif
	return 0;
}
Esempio n. 4
0
/*
 * Supply data on a read from /proc/device-tree/node/property.
 */
static int property_proc_show(struct seq_file *m, void *v)
{
	struct property *pp = m->private;

	seq_write(m, pp->value, pp->length);
	return 0;
}
Esempio n. 5
0
void write_vga_register(register_set_t target, uint8_t index, uint8_t value)
{
	switch(target)
	{
	case GRAPHIC_CTRL:
		gctrl_write(index, value);
		break;
	case SEQUENCER:
		seq_write(index, value);
		break;
	case ATTRIBUTE_CTRL:
		attr_write(index, value);
		break;
	case CRT_CTRL:
		crtc_write(index, value);
		break;
	case EXTERNAL_REGISTERS:
		switch(index)
		{
		case MISC_OUTPUT_REGISTER:
			misc_output_write(value);
			break;
		case FEATURE_CONTROL_REGISTER:
			feature_control_write(value);
			break;
		}
		break;
	default:
		break;
	}
}
Esempio n. 6
0
static void seq_flush_thread(void)
{

  seq_list_t *ptr, *tmp;

  ptr = seq_retrieve();

  if(ptr!=NULL) {

      if(verbose & TC_SYNC) {
          tc_log_msg(__FILE__, "syncinfo write (%d)", ptr->id);
      }

      seq_write(ptr);

      // release valid pointer to pool
      ptr->status = BUFFER_EMPTY;

      tmp=ptr->prev;
      seq_remove(tmp);

      pthread_mutex_lock(&seq_ctr_lock);
      --seq_ctr;
      pthread_mutex_unlock(&seq_ctr_lock);

  } else
     tc_log_error(__FILE__, "called but no work to do - this shouldn't happen");

  return;
}
Esempio n. 7
0
static int lastlog_m_show(struct seq_file *s, void *v)
{
	const char priority_chars[] = {'?', '?', 'V', 'D', 'I','W','E', 'F', 'S'};
	struct logger_entry *entry = v;
	struct logger_entry tmp;
	char* tagaddr;
	char *msgaddr;
	struct rtc_time rtctime;
	int priority;

	memcpy (&tmp, entry, sizeof(tmp));

	rtctime = rtc_ktime_to_tm(ktime_set (tmp.sec, tmp.nsec));
	priority = entry->msg[0];
	tagaddr = &(entry->msg[1]);
	msgaddr = tagaddr + strlen(tagaddr) + 1;

	seq_printf (s, "%02d-%02d %02d:%02d:%02d.%03d %c/%-8s(%5d:%d): ",
						rtctime.tm_mon + 1, rtctime.tm_mday, rtctime.tm_hour,
						rtctime.tm_min, rtctime.tm_sec + 1,
						tmp.nsec / 1000000, priority_chars[priority],
						tagaddr, tmp.pid, tmp.tid);
	if (entry->msg[tmp.len-1] == '\0') {
		seq_printf (s, "%s", msgaddr);
	} else {
		seq_write (s, msgaddr, tmp.len - (msgaddr - entry->msg));
	}

	if (s->buf[s->count-1] != '\n')
		seq_putc(s, '\n');

	return 0;
}
/** Show callback for the @c mem_profile debugfs file.
 *
 * This function is called to get the contents of the @c mem_profile debugfs
 * file. This is a report of current memory usage and distribution in userspace.
 *
 * @param sfile The debugfs entry
 * @param data Data associated with the entry
 *
 * @return 0 if successfully prints data in debugfs entry file
 *         -1 if it encountered an error
 */
static int kbasep_mem_profile_seq_show(struct seq_file *sfile, void *data)
{
	struct kbase_context *kctx = sfile->private;

	KBASE_DEBUG_ASSERT(kctx != NULL);

	/* MALI_SEC_INTEGRATION */
	{
	struct kbase_device *kbdev = kctx->kbdev;

	atomic_inc(&kctx->mem_profile_showing_state);
	if(kbdev->vendor_callbacks->mem_profile_check_kctx)
		if (!kbdev->vendor_callbacks->mem_profile_check_kctx(kctx)) {
			atomic_dec(&kctx->mem_profile_showing_state);
			return 0;
		}
	}

	/* MALI_SEC_INTEGRATION */
	if (kctx->destroying_context) {
		atomic_dec(&kctx->mem_profile_showing_state);
		return 0;
	}

	spin_lock(&kctx->mem_profile_lock);
	/* MALI_SEC_INTEGRATION */
	if (kctx->mem_profile_data) {
		seq_write(sfile, kctx->mem_profile_data, kctx->mem_profile_size);
		seq_putc(sfile, '\n');
	}
	spin_unlock(&kctx->mem_profile_lock);
	atomic_dec(&kctx->mem_profile_showing_state);

	return 0;
}
Esempio n. 9
0
void pstore_console_show(enum pstore_type_id type_id, struct seq_file *m, void *v)
{
	struct pstore_info *psi = psinfo;
	char			*buf = NULL;
	ssize_t			size;
	u64			id;
	int			count;
	enum pstore_type_id	type;
	struct timespec		time;

	if (!psi)
		return;
	mutex_lock(&psi->read_mutex);
	if (psi->open && psi->open(psi))
		goto out;

	while ((size = psi->read(&id, &type, &count, &time, &buf, psi)) > 0) {
		pr_err("ram_console: id %lld, type %d, count %d, size %zx\n", id, type, count, size);
		if (type == type_id)
			seq_write(m, buf, size);
		kfree(buf);
		buf = NULL;
	}

	if (psi->close)
		psi->close(psi);
out:
	mutex_unlock(&psi->read_mutex);
}
Esempio n. 10
0
File: cpu.c Progetto: avagin/linux
static void print_isa(struct seq_file *f, const char *orig_isa)
{
	static const char *ext = "mafdcsu";
	const char *isa = orig_isa;
	const char *e;

	/*
	 * Linux doesn't support rv32e or rv128i, and we only support booting
	 * kernels on harts with the same ISA that the kernel is compiled for.
	 */
#if defined(CONFIG_32BIT)
	if (strncmp(isa, "rv32i", 5) != 0)
		return;
#elif defined(CONFIG_64BIT)
	if (strncmp(isa, "rv64i", 5) != 0)
		return;
#endif

	/* Print the base ISA, as we already know it's legal. */
	seq_puts(f, "isa\t\t: ");
	seq_write(f, isa, 5);
	isa += 5;

	/*
	 * Check the rest of the ISA string for valid extensions, printing those
	 * we find.  RISC-V ISA strings define an order, so we only print the
	 * extension bits when they're in order. Hide the supervisor (S)
	 * extension from userspace as it's not accessible from there.
	 */
	for (e = ext; *e != '\0'; ++e) {
		if (isa[0] == e[0]) {
			if (isa[0] != 's')
				seq_write(f, isa, 1);

			isa++;
		}
	}
	seq_puts(f, "\n");

	/*
	 * If we were given an unsupported ISA in the device tree then print
	 * a bit of info describing what went wrong.
	 */
	if (isa[0] != '\0')
		pr_info("unsupported ISA \"%s\" in device tree\n", orig_isa);
}
Esempio n. 11
0
int main()
{
    struct list *data = NULL;
    seq_read(&data);
    seq_write(data);
    __VERIFIER_plot(NULL);

    // NOTE: you may mix seq_insert/seq_sort as you like, we'll take care of it
    seq_sort(&data);
    seq_write(data);
    __VERIFIER_plot(NULL);

    seq_destroy(data);
    __VERIFIER_plot(NULL);

    return 0;
}
Esempio n. 12
0
/*
 * Send a pitchbend message. The bend parameter is centered on
 * zero, negative values mean a lower pitch.
 *  Arguments:
 *    ctxp      - Application context
 *    ep        - Event template
 *    bend      - Bend value, centered on zero.
 */
void 
SeqContext::seq_midi_pitchbend(snd_seq_event_t *ep, int devchan, int bend)
{
	ep->type = SND_SEQ_EVENT_PITCHBEND;

	ep->data.control.channel = devchan & 0xf;
	ep->data.control.value = bend;
	seq_write(ep);
}
Esempio n. 13
0
static int tima_proc_secure_show(struct seq_file *m, void *v)
{
	/* Pass on the whole debug buffer to the user-space. User-space
	 * will interpret it as it chooses to.
	 */
	seq_write(m, (const char *)tima_secure_log_addr, DEBUG_LOG_SIZE);

	return 0;
}
Esempio n. 14
0
/*
 * Send a program change event.
 *  Arguments:
 *    ctxp      - Application context
 *    ep        - Event template
 *    program   - Program to set
 */
void 
SeqContext::seq_midi_program(snd_seq_event_t *ep, int devchan, int program)
{
	ep->type = SND_SEQ_EVENT_PGMCHANGE;

	ep->data.control.channel = devchan & 0xf;
	ep->data.control.value = program;
	seq_write(ep);
}
Esempio n. 15
0
/*
 * Send a channel pressure event.
 *  Arguments:
 *    ctxp      - Application context
 *    ep        - Event template
 *    pressure  - Pressure value
 */
void 
SeqContext::seq_midi_chanpress(snd_seq_event_t *ep, int devchan, int pressure)
{
	ep->type = SND_SEQ_EVENT_CHANPRESS;

	ep->data.control.channel = devchan & 0xf;
	ep->data.control.value = pressure;
	seq_write(ep);
}
static int perflog_show(struct seq_file *s, void *buffer)
{
    perflog_Buffer  *psBuffer = (perflog_Buffer*)buffer;

    //write relevant part of buffer to output
    seq_write(s, psBuffer->pui64Buffer, psBuffer->stIter * sizeof(IMG_UINT64));

    return 0;
}
Esempio n. 17
0
/*
 * Send an echo event back to the source client at the specified
 * time.
 * 
 *  Arguments:
 *    ctxp      - Application context
 *    time      - Time of event
 */
void 
SeqContext::seq_midi_echo(unsigned long time)
{
	snd_seq_event_t ev;

	seq_midi_event_init(&ev, time, 0);
	/* Loop back */
	ev.dest = source;
	seq_write(&ev);
}
Esempio n. 18
0
LVAL xlc_seq_write(void)
{
    seq_type arg1 = getseq(xlgaseq());
    FILE * arg2 = getfile(xlgastream());
    int arg3 = getboolean(xlgetarg());

    xllastarg();
    seq_write(arg1, arg2, arg3);
    return NIL;
}
Esempio n. 19
0
size_t _write_wrapped(SeqFile *sf, const char *str, size_t str_len)
{
  size_t num_bytes_printed = 0;

  if(sf->curr_line_length == sf->line_wrap)
  {
    sf->curr_line_length = 0;
    num_bytes_printed += seq_puts(sf, "\n");
    sf->line_number++;
  }
  
  if(sf->curr_line_length + str_len <= sf->line_wrap)
  {
    // Doesn't go over a single line
    sf->curr_line_length += str_len;
    num_bytes_printed += seq_puts(sf, str);
    return num_bytes_printed;
  }

  size_t bytes_to_print = sf->line_wrap - sf->curr_line_length;

  num_bytes_printed += seq_write(sf, str, bytes_to_print);
  num_bytes_printed += seq_puts(sf, "\n");
  sf->line_number++;

  size_t offset;

  for(offset = bytes_to_print; offset < str_len; offset += sf->line_wrap)
  {
    bytes_to_print = MIN(str_len - offset, sf->line_wrap);
    num_bytes_printed += (size_t)seq_write(sf, str + offset, bytes_to_print);

    if(bytes_to_print < sf->line_wrap)
    {
      num_bytes_printed += seq_puts(sf, "\n");
      sf->line_number++;
    }
  }

  sf->curr_line_length = bytes_to_print;

  return num_bytes_printed;
}
Esempio n. 20
0
/*
 * Send the event to the specified client and port.
 * 
 *  Arguments:
 *    ctxp      - Client context
 *    ev        - Event to send
 *    client    - Client to send the event to
 *    port      - Port to send the event to
 */
int SeqContext::seq_sendto(snd_seq_event_t *ev, int client, int port)
{
	ev->source = source;
	ev->queue = queue;
	ev->dest.client = client;
	ev->dest.port = port;
	seq_write(ev);

	return 0;
}
Esempio n. 21
0
/*
 * Send a tempo event. The tempo parameter is in microseconds
 * per beat.
 *  Arguments:
 *    ctxp      - Application context
 *    ep        - Event template
 *    tempo     - New tempo in usec per beat
 */
void 
SeqContext::seq_midi_tempo(snd_seq_event_t *ep, int tempo)
{
	ep->type = SND_SEQ_EVENT_TEMPO;

	ep->data.queue.queue = queue;
	ep->data.queue.param.value = tempo;
	ep->dest.client = SND_SEQ_CLIENT_SYSTEM;
	ep->dest.port = SND_SEQ_PORT_SYSTEM_TIMER;
	seq_write(ep);
}
Esempio n. 22
0
/*
 * Send a key pressure event.
 *  Arguments:
 *    ctxp      - Application context
 *    ep        - Event template
 *    note      - Note to be altered
 *    value     - Pressure value
 */
void 
SeqContext::seq_midi_keypress(snd_seq_event_t *ep, int devchan, int note, 
        int value)
{
	ep->type = SND_SEQ_EVENT_KEYPRESS;

	ep->data.control.channel = devchan & 0xf;
	ep->data.control.param = note;
	ep->data.control.value = value;
	seq_write(ep);
}
Esempio n. 23
0
/*
 * Send a control event.
 *  Arguments:
 *    ctxp      - Application context
 *    ep        - Event template
 *    control   - Controller to change
 *    value     - Value to set it to
 */
void 
SeqContext::seq_midi_control(snd_seq_event_t *ep, int devchan, int control, 
        int value)
{
	ep->type = SND_SEQ_EVENT_CONTROLLER;

	ep->data.control.channel = devchan & 0xf;
	ep->data.control.param = control;
	ep->data.control.value = value;
	seq_write(ep);
}
static void debug_read_build_id(struct seq_file *s)
{
	unsigned size;
	void *data;

	data = smem_get_entry(SMEM_HW_SW_BUILD_ID, &size, 0,
							SMEM_ANY_HOST_FLAG);
	if (!data)
		return;

	seq_write(s, data, size);
}
/** Show callback for the @c mem_profile debugfs file.
 *
 * This function is called to get the contents of the @c mem_profile debugfs
 * file. This is a report of current memory usage and distribution in userspace.
 *
 * @param sfile The debugfs entry
 * @param data Data associated with the entry
 *
 * @return 0 if successfully prints data in debugfs entry file
 *         -1 if it encountered an error
 */
static int kbasep_mem_profile_seq_show(struct seq_file *sfile, void *data)
{
	struct kbase_context *kctx = sfile->private;

	KBASE_DEBUG_ASSERT(kctx != NULL);

	spin_lock(&kctx->mem_profile_lock);
	seq_write(sfile, kctx->mem_profile_data, kctx->mem_profile_size);
	seq_putc(sfile, '\n');
	spin_unlock(&kctx->mem_profile_lock);

	return 0;
}
Esempio n. 26
0
static void vga_load_regs(const mux_reg_t *reg, unsigned short vendor, unsigned short device)
{
	int c, r, i;

	while (reg->fn != FN_END) {
		switch (reg->fn) {
		case FN_ATT:
			attrib_write(reg->reg, reg->val);
			break;

		case FN_GRPH:
			grph_write(reg->reg, reg->val);
			break;

		case FN_CRTC:
			crtc_write(reg->reg, reg->val);
			break;

		case FN_SEQ:
			seq_write(reg->reg, reg->val);
			break;

		case FN_DLUT:
			io_base[0x3c8] = 0;
			for (i = 0; i < sizeof(DAC); i++)
				io_base[0x3c9] = DAC[i];
			break;

		case FN_MISC:
			io_base[0x3c2] = reg->val;
			break;

		case FN_CMAP:
			for (c = 0; c < 256; c++)
				for (r = 0; r < 32; r++)
					if (r < 8)
						charmap[(c << 5) + r] = cmap_80[c][r];
					else
						charmap[(c << 5) + r] = 0;
			break;

		case FN_CARD:
			for (i = 0; cards[i].vendor; i++)
				if (cards[i].vendor == vendor &&
				    cards[i].device == device)
					vga_load_regs(cards[i].mux, 0, 0);
			break;
		}
		reg++;
	}
}
Esempio n. 27
0
static int imem1_read_proc(struct seq_file *filq, void *v)
{
	int len = 0;
	unsigned int start_addr, end_addr, max_order, max_size;
	struct imem_list *imem;

	unsigned int *tmp = (unsigned int *)(filq->buf + len);

	start_addr = jz_imem1_base;
	end_addr = start_addr + (1 << IMEM1_MAX_ORDER) * PAGE_SIZE;

	if (!imem1_list_head)
		max_size = end_addr - start_addr;
	else {
		max_size = 0;
		imem = imem1_list_head;
		while (imem) {
			if (max_size < (imem->phys_start - start_addr))
				max_size = imem->phys_start - start_addr;

			start_addr = imem->phys_end + 1;
			imem = imem->next;
		}

		if (max_size < (end_addr - start_addr))
			max_size = end_addr - start_addr;
	}

	if (max_size > 0) {
		max_order = get_order(max_size);
		if (((1 << max_order) * PAGE_SIZE) > max_size)
		    max_order--;
	}
	else {
		max_order = 0xffffffff;	/* No any free buffer */
	}

	*tmp++ = allocated_phys_addr1;	/* address allocated by 'echo n > /proc/jz/imem' */
	*tmp = max_order;		/* max order of current free buffers */

	len += 2 * sizeof(unsigned int);

	seq_write(filq, &allocated_phys_addr1, len);

	if(filq->count < filq->size)
		return 0;
	else
		return 1;
}
static void seq_print_vma_name(struct seq_file *m, struct vm_area_struct *vma)
{
	const char __user *name = vma_get_anon_name(vma);
	struct mm_struct *mm = vma->vm_mm;

	unsigned long page_start_vaddr;
	unsigned long page_offset;
	unsigned long num_pages;
	unsigned long max_len = NAME_MAX;
	int i;

	page_start_vaddr = (unsigned long)name & PAGE_MASK;
	page_offset = (unsigned long)name - page_start_vaddr;
	num_pages = DIV_ROUND_UP(page_offset + max_len, PAGE_SIZE);

	seq_puts(m, "[anon:");

	for (i = 0; i < num_pages; i++) {
		int len;
		int write_len;
		const char *kaddr;
		long pages_pinned;
		struct page *page;

		pages_pinned = get_user_pages(current, mm, page_start_vaddr,
				1, 0, 0, &page, NULL);
		if (pages_pinned < 1) {
			seq_puts(m, "<fault>]");
			return;
		}

		kaddr = (const char *)kmap(page);
		len = min(max_len, PAGE_SIZE - page_offset);
		write_len = strnlen(kaddr + page_offset, len);
		seq_write(m, kaddr + page_offset, write_len);
		kunmap(page);
		put_page(page);

		/* if strnlen hit a null terminator then we're done */
		if (write_len != len)
			break;

		max_len -= len;
		page_offset = 0;
		page_start_vaddr += PAGE_SIZE;
	}

	seq_putc(m, ']');
}
Esempio n. 29
0
/*
 * Send a note off event.
 *  Arguments:
 *    ctxp      - Client context
 *    ep        - Event template
 *    note      - Pitch of note
 *    vel       - Velocity of note
 *    length    - Length of note
 */
void 
SeqContext::seq_midi_note_off(snd_seq_event_t *ep, int devchan, int note, int vel, 
        int length)
{
	ep->type = SND_SEQ_EVENT_NOTEOFF;

	ep->data.note.channel = devchan & 0xf;
	ep->data.note.note = note;
	ep->data.note.velocity = vel;
	ep->data.note.duration = length;

	if( verbose ) 
		fprintf(stderr, "midi note off: note=%d velocity=%d length=%d", note, vel, length );

	seq_write(ep);
}
static int knox_kap_read(struct seq_file *m, void *v)
{
	unsigned long tz_ret = 0;
	unsigned char ret_buffer[KAP_RET_SIZE];
	unsigned volatile int ret_val;

	tz_ret = kap_status_scm_call();

	if (tz_ret == 0)
		printk(KERN_ERR "Failure : KAP Read STATUS %lx val = %lx\n", (unsigned long int)__pa(&tz_ret), tz_ret);
	else
		printk(KERN_ERR "Success : KAP Read STATUS %lx val = %lx\n", (unsigned long int)__pa(&tz_ret), tz_ret);

	if (tz_ret == (KAP_MAGIC | 3)) {
		ret_val = 0x03;	//RKP and/or DMVerity says device is tampered
	} else if (tz_ret == (KAP_MAGIC | 2)) {
		ret_val = 0x2;	//The device is tampered through trusted boot
	} else if (tz_ret == (KAP_MAGIC | 1)) {
		/* KAP is ON*/
		/* Check if there is any pending On/Off action */
		if (kap_off_reboot == 1){
			ret_val = 0x10;	//KAP is ON and will turn OFF upon next reboot
		} else {
			ret_val = 0x11;	//KAP is ON and and no change so far
		}
	} else if (tz_ret == (KAP_MAGIC)) {
		/* KAP is OFF*/
		/* Check if there is any pending On/Off action */
		if (kap_on_reboot == 1){
			ret_val = 0x01;	//KAP is OFF but will turn on upon next reboot
		} else {
			ret_val = 0;	//KAP is OFF and no change so far
		}
	} else {
		ret_val = 0x04;	//The magic string is not there. KAP mode not implemented
	}

	printk(KERN_ERR "knox_kap_read ret_val = %0x\n", ret_val);
	memset(ret_buffer,0,KAP_RET_SIZE);
	snprintf(ret_buffer, sizeof(ret_buffer), "%02x\n", ret_val);
	seq_write(m, ret_buffer, sizeof(ret_buffer));

	return 0;
}