/** * Set up frame buffer. * * @param width Frame buffer width(less than 4096) * @param height Frame buffer height(less than 4096) * @param bit_depth less than 32 bits * @return Pointer to frame buffer info. Return 0 if failed. */ FrameBufferInfo *init_framebuffer(int width, int height, int bit_depth) { if (width > 4096) goto ERROR; if (height > 4096) goto ERROR; if (bit_depth > 32) goto ERROR; int response; FrameBufferInfo *frameBuffer = &frameBufferInfo; frameBuffer->p_width = width; frameBuffer->p_height = height; frameBuffer->v_width = width; frameBuffer->v_height = height; frameBuffer->gpu_pitch = 0; frameBuffer->bit_depth = bit_depth; frameBuffer->x = 0; frameBuffer->y = 0; frameBuffer->gpu_pointer = 0; frameBuffer->gpu_size = 0; int frameBufferAddr = (int)frameBuffer; frameBufferAddr += 0x40000000; // Write frame buffer to channel 1 mailbox_write(frameBufferAddr, 1); response = mailbox_read(1); if (response != 0) return 0; return frameBuffer; ERROR: return 0; }
char *framebuffer_init(int x, int y, int depth) { struct frame_buffer_info_type fb_info __attribute__ ((aligned(16)));; int result; fb_info.phys_x=x; fb_info.phys_y=y; fb_info.virt_x=x; fb_info.virt_y=y; fb_info.pitch=0; fb_info.depth=depth; fb_info.x=0; fb_info.y=0; fb_info.pointer=0; fb_info.size=0; if (debug) { printk("fb: Writing message @%x to mailbox %x\r\n", &fb_info,MAILBOX_BASE); printk("fb: asking for "); dump_framebuffer_info(&fb_info); } result=mailbox_write( (unsigned int)(&fb_info)+0x40000000 , MAILBOX_FRAMEBUFFER); if (result<0) { printk("Mailbox write failed\r\n"); return NULL; } result=mailbox_read(MAILBOX_FRAMEBUFFER); if (debug) { printk("fb: we got "); dump_framebuffer_info(&fb_info); } if (result==-1) { printk("Mailbox read failed\r\n"); return NULL; } current_fb.pointer=(int)(fb_info.pointer); current_fb.phys_x=fb_info.phys_x; current_fb.phys_y=fb_info.phys_y; current_fb.pitch=fb_info.pitch; current_fb.depth=fb_info.depth; framebuffer_initialized=1; return (char *)(fb_info.pointer); }
void framebuf_init() { framebuf_info.width = 1024; framebuf_info.height = 768; framebuf_info.vwidth = 1024; framebuf_info.vheight = 768; framebuf_info.pitch = 0; framebuf_info.depth = 24; framebuf_info.xoffset = 0; framebuf_info.yoffset = 0; framebuf_info.ptr = 0; framebuf_info.size = 0; mailbox_write(1, ((uint32)&framebuf_info) + 0x40000000); mailbox_read(1); };
void* sort8k_entry3( void *data ) { sortarg_t * my_arg; void *ptr; my_arg = (sortarg_t *)data; //unsigned int tid = (unsigned int)hthread_self(); //unsigned int thread_number = ( unsigned int ) data; while ( 1 ) { // get pointer to next chunk of data ptr = (void*)mailbox_read( &my_arg->mb_start ); // sort it bubblesort3( ( unsigned int * ) ptr, N ); // return mailbox_write( &my_arg->mb_done, (void*)23 ); // return any value } return NULL; }
int initialize_framebuffer(uint32_t physical_w, uint32_t physical_h, uint32_t virtual_w, uint32_t virtual_h) { print_debug("Initializing framebuffer"); __screenbuffer->physical_width = physical_w; __screenbuffer->physical_height = physical_h; __screenbuffer->virtual_width = virtual_w; __screenbuffer->virtual_height = virtual_h; __screenbuffer->bit_depth = 32; __screenbuffer->gpu_pointer = 0; uint32_t read = 0; while (__screenbuffer->gpu_pointer == 0) { if (mailbox_write(MAILBOX_FRAMEBUFFER, (uint32_t)(__screenbuffer) + 0x40000000) == -1) { return -1; } read = mailbox_read(MAILBOX_FRAMEBUFFER); } return read; }
void fb_init(unsigned width, unsigned height, unsigned depth, unsigned db) { // add code to handle double buffering fb.width = width; fb.virtual_width = width; fb.height = height; fb.virtual_height = height; fb.depth = depth * 8; // convert number of bytes to number of bits fb.x_offset = 0; fb.y_offset = 0; // set values returned by the GPU to 0; see mailbox manual fb.pitch = 0; fb.framebuffer = 0; fb.size = 0; mailbox_write(MAILBOX_FRAMEBUFFER, (unsigned)&fb + GPU_NOCACHE); (void) mailbox_read(MAILBOX_FRAMEBUFFER); }
static void IpcTask (void * pvParameters) { unsigned int msg, *local_vq_buf; int ret; struct virtqueue_buf virtq_buf; portTickType LastWake; trace_append("%s: starting task\n", __func__); /* Workaround * * We can't enable interrupts in U-Boot. Let's wait until Linux is booted * on CPU. Linux remoteproc framework sends a ping to IPU via mailbox when * its initialization is completed. This ping is a good indicator for IPU * that Linux and its remoteproc/rpmsg subsystems are up an running. */ while (1) { msg = mailbox_read(); if (msg == HOST_ECHO_REQUEST) { trace_append("%s: received echo request [0x%x] from CPU\n", __func__, msg); break; } trace_append("%s: host-to-m3 mailbox [0x%x]\n", __func__, msg); LastWake = xTaskGetTickCount(); vTaskDelayUntil(&LastWake, 5000); } virtqueue_init(); nvic_enable_irq(MAILBOX_IRQ); enable_mailbox_irq(); trace_append("%s: start main loop\n", __func__); for (;;) { xQueueReceive(MboxQueue, &msg, portMAX_DELAY); switch(msg) { case RP_MBOX_ECHO_REQUEST : mailbox_send(M3_TO_HOST_MBX, RP_MBOX_ECHO_REPLY); break; case HOST_TO_M3_VRING : ret = virtqueue_get_avail_buf(&virtqueue_list[msg], &virtq_buf); /* make a local copy of the buffer */ local_vq_buf = pvPortMalloc(RP_MSG_BUF_SIZE); memcpy(local_vq_buf, virtq_buf.buf_ptr, RP_MSG_BUF_SIZE); virtqueue_add_used_buf(&virtqueue_list[msg], virtq_buf.head); /* dispatch to the service queue */ rpmsg_dispatch_msg(local_vq_buf); break; case M3_TO_HOST_VRING : xSemaphoreGive(InitDoneSemaphore); break; default: trace_append("%s: unknown message\n", __func__); break; } } vTaskDelete(NULL); }
static void mail_func_read(t_connection * c, const char * str) { t_account * user; t_mailbox * mailbox; const char *p; char tmp[256]; int i; if (c==NULL) { eventlog(eventlog_level_error,__FUNCTION__,"got NULL connection"); return; } if (str==NULL) { eventlog(eventlog_level_error,__FUNCTION__,"got NULL command string"); return; } for(i=0;str[i]==' ';i++); p=str+i; if ((user=conn_get_account(c))==NULL) { eventlog(eventlog_level_error,__FUNCTION__,"got NULL account"); return; } mailbox=mailbox_open(user, mbox_mode_read); if (*p=='\0') { /* user wants to see the mail summary */ struct maillist_struct *maill, *mp; unsigned int idx; if (!mailbox_count(mailbox)) { message_send_text(c,message_type_info,c,"You have no mail."); mailbox_close(mailbox); return; } if ((maill=mailbox_get_list(mailbox))==NULL) { eventlog(eventlog_level_error,__FUNCTION__,"got NULL maillist"); mailbox_close(mailbox); return; } sprintf(tmp,"You have %d messages. Your mail qouta is set to %d.",mailbox_count(mailbox),get_mail_quota(user)); message_send_text(c,message_type_info,c,tmp); message_send_text(c,message_type_info,c,"ID Sender Date"); message_send_text(c,message_type_info,c,"-------------------------------------"); for(mp=maill,idx=1;mp!=NULL;mp=mp->next,idx++) { sprintf(tmp,"%02u %-14s %s",idx,mp->sender,ctime(&mp->timestamp)); clean_str(tmp); /* ctime() appends an newline that we get cleaned */ message_send_text(c,message_type_info,c,tmp); } message_send_text(c,message_type_info,c,"Use /mail read <ID> to read the content of any message"); mailbox_unget_list(maill); } else { /* user wants to read a message */ int idx; t_mail * mail; for(i=0;p[i]>='0' && p[i]<='9' && p[i]!='\0';i++); if (p[i]!='\0' && p[i]!=' ') { message_send_text(c,message_type_error,c,"Invalid index. Please use /mail read <index> where <index> is a number."); mailbox_close(mailbox); return; } idx=atoi(p); if (idx<1 || idx>mailbox_count(mailbox)) { message_send_text(c,message_type_error,c,"That index is out of range."); mailbox_close(mailbox); return; } if ((mail=mailbox_read(mailbox,idx))==NULL) { message_send_text(c,message_type_error,c,"There was an error completing your request."); mailbox_close(mailbox); return; } sprintf(tmp,"Message #%d from %s on %s:",idx,mail->sender,clean_str(ctime(&mail->timestamp))); message_send_text(c,message_type_info,c,tmp); message_send_text(c,message_type_info,c,mail->message); mailbox_unread(mail); } mailbox_close(mailbox); }