Example #1
0
static void monitor_app_erase(struct dmon_comm * comm, 
							  uint32_t addr, unsigned int size)
{
	dmprintf(comm, "\r\nErasing application block ... ");
	dbgmon_soft_reset();
	if (dmon_app_erase(comm, addr, size))
		dmprintf(comm, "done.\r\n");
	else	
		dmprintf(comm, "failed!\r\n");
}
Example #2
0
static void monitor_show_help(struct dmon_comm * comm)
{
	dmprintf(comm, s_hr);
	dmprintf(comm, "ThinkOS-%d.%d.%d (%s):\r\n", 
			 this_board.sw_ver.major,
			 this_board.sw_ver.minor,
			 this_board.sw_ver.build,
			 this_board.name);
	dmprintf(comm, monitor_menu);
	dmprintf(comm, s_hr);
}
Example #3
0
static void monitor_ymodem_recv(struct dmon_comm * comm, 
								uint32_t addr, unsigned int size)
{
	dmprintf(comm, "\r\nYMODEM receive (^X to cancel) ... ");
	dbgmon_soft_reset();
	if (dmon_ymodem_flash(comm, addr, size) < 0) {
		dmprintf(comm, "\r\n#ERROR: YMODEM failed!\r\n"); 
		return;
	}	

	monitor_exec(comm, addr);
}
Example #4
0
void monitor_show_mem(struct monitor * mon)
{
	uint32_t addr = mon->memdump.addr;
	unsigned int size = mon->memdump.size;

	dmprintf(mon->comm, "Addr (0x%08x): ", addr);
	dmscanf(mon->comm, "%x", &addr);
	dmprintf(mon->comm, "Size (%d): ", size);
	dmscanf(mon->comm, "%u", &size);

	monitor_dump_mem(mon->comm, addr, size);
	mon->memdump.addr = addr;
	mon->memdump.size = size;
}
Example #5
0
/* This is also exported for teardown after background printing */
void
teardown_device_and_mem_for_thread(gx_device *dev, gp_thread_id thread_id, bool bg_print)
{
    gx_device_clist_common *thread_cdev = (gx_device_clist_common *)dev;
    gx_device_clist_reader *thread_crdev = (gx_device_clist_reader *)dev;
    gs_memory_t *thread_memory = dev->memory;

    /* First finish the thread */
    gp_thread_finish(thread_id);

    if (bg_print) {
        /* we are cleaning up a background printing thread, so we clean up similarly to */
        /* what is done  by clist_finish_page, but without re-opening the clist files.  */
        clist_teardown_render_threads(dev);	/* we may have used multiple threads */
        /* free the thread's icc_table since this was not done by clist_finish_page */
        clist_free_icc_table(thread_crdev->icc_table, thread_memory);
        thread_crdev->icc_table = NULL;
        /* NB: gdev_prn_free_memory below will free the color_usage_array */
    } else {
        /* make sure this doesn't get freed by gdev_prn_free_memory below */
        ((gx_device_clist_reader *)thread_cdev)->color_usage_array = NULL;
    }
    rc_decrement(thread_crdev->icc_cache_cl, "teardown_render_thread");
    thread_crdev->icc_cache_cl = NULL;
    /*
     * Free the BufferSpace, close the band files, optionally unlinking them.
     * We unlink the files if this call is cleaning up from bg printing.
     * Note that the BufferSpace is freed using 'ppdev->buf' so the 'data'
     * pointer doesn't need to be the one that the thread started with
     */
    /* If this thread was being used for background printing and NumRenderingThreads > 0 */
    /* the clist_setup_render_threads may have already closed these files                */
    if (thread_cdev->page_info.cfile != NULL)
        thread_cdev->page_info.io_procs->fclose(thread_cdev->page_info.bfile, thread_cdev->page_info.bfname, bg_print);
    if (thread_cdev->page_info.bfile != NULL)
        thread_cdev->page_info.io_procs->fclose(thread_cdev->page_info.cfile, thread_cdev->page_info.cfname, bg_print);
    thread_cdev->do_not_open_or_close_bandfiles = true; /* we already closed the files */

    gdev_prn_free_memory((gx_device *)thread_cdev);
    /* Free the device copy this thread used.  Note that the
       deviceN stuff if was allocated and copied earlier for the device
       will be freed with this call and the icc_struct ref count will be decremented. */
    gs_free_object(thread_memory, thread_cdev, "clist_teardown_render_threads");
#ifdef DEBUG
    dmprintf(thread_memory, "rendering thread ending memory state...\n");
    gs_memory_chunk_dump_memory(thread_memory);
    dmprintf(thread_memory, "                                    memory dump done.\n");
#endif
    gs_memory_chunk_release(thread_memory);
}
Example #6
0
void monitor_watchpoint(struct monitor * mon)
{
	unsigned int no = 0;
	uint32_t addr;

	dmprintf(mon->comm, "No (0..3): ");
	dmscanf(mon->comm, "%u", &no);
	if (no > 3)
		dmprintf(mon->comm, "Invalid!\r\n");
	addr = mon->wp[no].addr;
	dmprintf(mon->comm, "Addr (0x%08x): ", addr);
	dmscanf(mon->comm, "%x", &addr);
	mon->wp[no].addr = addr;
	dmon_watchpoint_set(addr, 4, 0);
}
Example #7
0
static void monitor_exec(struct dmon_comm * comm, unsigned int addr)
{
	if (dmon_app_exec(addr, false) < 0) {
		dmprintf(comm, "\r\n#ERROR: Invalid app!\r\n");
		return;
	}
}
Example #8
0
/* Remap a DeviceN color. */
static const gs_color_space *
gx_concrete_space_DeviceN(const gs_color_space * pcs,
                          const gs_imager_state * pis)
{
    bool is_lab = false;
#ifdef DEBUG
    /*
     * Verify that the color space and imager state info match.
     */
    if (pcs->id != pis->color_component_map.cspace_id)
        dmprintf(pis->memory, "gx_concrete_space_DeviceN: color space id mismatch");
#endif
    /*
     * Check if we are using the alternate color space.
     */
    if (pis->color_component_map.use_alt_cspace) {
        /* Need to handle PS CIE space */
        if (gs_color_space_is_PSCIE(pcs->base_space)) {
            if (pcs->base_space->icc_equivalent == NULL) {
                gs_colorspace_set_icc_equivalent(pcs->base_space,
                                                    &is_lab, pis->memory);
            }
            return (pcs->base_space->icc_equivalent);
        }
        return cs_concrete_space(pcs->base_space, pis);
    }
    /*
     * DeviceN color spaces are concrete (when not using alt. color space).
     */
    return pcs;
}
Example #9
0
/* retrieve the current pcl state and initialize pcl */
static int
pxPassthrough_init(px_state_t * pxs)
{
    int code;

    if (gs_debug_c('i'))
        dmprintf(pxs->memory, "passthrough: initializing global pcl state\n");
    global_pcs = pcl_get_gstate(pxs->pcls);

    /* default to pcl5c */
    global_pcs->personality = 0;
    /* for now we do not support intepolation in XL passthrough mode. */
    global_pcs->interpolate = false;
    /* we don't see a nice way to support the following options with
       passthrough at this time (NB) */
    global_pcs->page_set_on_command_line = false;
    global_pcs->res_set_on_command_line = false;
    global_pcs->high_level_device = false;

    {
        char buf[100];
        int ret;
        stream_cursor_read r;

        ret =
            gs_sprintf(buf,
                    "@PJL SET PAPERLENGTH = %d\n@PJL SET PAPERWIDTH = %d\n",
                    (int)(pxs->media_dims.y * 10 + .5),
                    (int)(pxs->media_dims.x * 10 + .5));
        r.ptr = (byte *) buf - 1;
        r.limit = (byte *) buf + ret - 1;
        pjl_proc_process(pxs->pjls, &r);
    }

    /* do an initial reset to set up a permanent reset.  The
       motivation here is to avoid tracking down a slew of memory
       leaks */
    global_pcs->xfm_state.paper_size = pcl_get_default_paper(global_pcs);
    pcl_do_resets(global_pcs, pcl_reset_initial);
    pcl_do_resets(global_pcs, pcl_reset_permanent);

    /* initialize pcl and install xl's page device in pcl's state */
    pcl_init_state(global_pcs, pxs->memory);
    code = gs_setdevice_no_erase(global_pcs->pgs, gs_currentdevice(pxs->pgs));
    if (code < 0)
        return code;

    /* yet another reset with the new page device */
    global_pcs->xfm_state.paper_size = pcl_get_default_paper(global_pcs);
    pcl_do_resets(global_pcs, pcl_reset_initial);
    /* set the parser state and initialize the pcl parser */
    global_pcl_parser_state.definitions = global_pcs->pcl_commands;
    global_pcl_parser_state.hpgl_parser_state = &global_gl_parser_state;
    pcl_process_init(&global_pcl_parser_state);
    /* default 600 to match XL allow PCL to override */
    global_pcs->uom_cp = 7200L / 600L;
    gs_setgray(global_pcs->pgs, 0);
    return 0;
}
Example #10
0
static void monitor_pause_all(struct dmon_comm * comm)
{
	dmprintf(comm, "\r\nPausing all threads...\r\n");
	DCC_LOG(LOG_WARNING, "__thinkos_pause_all()");
	__thinkos_pause_all();
	if (dbgmon_wait_idle() < 0) {
		DCC_LOG(LOG_WARNING, "dmon_wait_idle() failed!");
	}
}
Example #11
0
static void monitor_on_fault(struct dmon_comm * comm)
{
	struct thinkos_except * xcpt = &thinkos_except_buf;

	DCC_LOG(LOG_TRACE, "dmon_wait_idle()...");

	if (dbgmon_wait_idle() < 0) {
		DCC_LOG(LOG_WARNING, "dmon_wait_idle() failed!");
	}

	DCC_LOG(LOG_TRACE, "<<IDLE>>");

	if (dmon_comm_isconnected(comm)) {
		dmprintf(comm, s_hr);
		dmon_print_exception(comm, xcpt);
		dmprintf(comm, s_hr);
	}
}
Example #12
0
const char *
pcl_cid_enc_get_debug_name(const gs_memory_t * mem, int index)
{
    if (index < 0 || index >= countof(pcl_encnames)) {
        dmprintf(mem, "index out of range\n");
        return pcl_encnames[0];
    } else {
        return pcl_encnames[index];
    }
}
Example #13
0
static void monitor_print_fault(struct dmon_comm * comm)
{
	struct thinkos_except * xcpt = &thinkos_except_buf;

	if (xcpt->type == 0) {
		dmprintf(comm, "No fault!");
		return;
	}

	dmon_print_exception(comm, xcpt);
}
Example #14
0
const char *
pcl_cid_cspace_get_debug_name(const gs_memory_t * mem, int index)
{
    if (index == -1)
        return WHITE_CS;

    if (index < 0 || index >= countof(pcl_csnames)) {
        dmprintf(mem, "index out of range\n");
        return pcl_csnames[0];
    } else {
        return pcl_csnames[index];
    }
}
Example #15
0
int
gx_begin_transparency_group(gs_imager_state * pis, gx_device * pdev,
                                const gs_pdf14trans_params_t * pparams)
{
    gs_transparency_group_params_t tgp = {0};
    gs_rect bbox;

    if (pparams->Background_components != 0 &&
        pparams->Background_components != pdev->color_info.num_components)
        return_error(gs_error_rangecheck);
    tgp.Isolated = pparams->Isolated;
    tgp.Knockout = pparams->Knockout;
    tgp.idle = pparams->idle;
    tgp.mask_id = pparams->mask_id;

    /* Needed so that we do proper blending */
    tgp.group_color = pparams->group_color;
    tgp.group_color_numcomps = pparams->group_color_numcomps;
    tgp.iccprofile = pparams->iccprofile;
    tgp.icc_hashcode = pparams->icc_hash;

    pis->opacity.alpha = pparams->opacity.alpha;
    pis->shape.alpha = pparams->shape.alpha;
    pis->blend_mode = pparams->blend_mode;
    bbox = pparams->bbox;
#ifdef DEBUG
    if (gs_debug_c('v')) {
        static const char *const cs_names[] = {
            GS_COLOR_SPACE_TYPE_NAMES
        };
        dmlprintf6(pdev->memory, "[v](0x%lx)gx_begin_transparency_group [%g %g %g %g] Num_grp_clr_comp = %d\n",
                  (ulong)pis, bbox.p.x, bbox.p.y, bbox.q.x, bbox.q.y,
                        pparams->group_color_numcomps);
        if (tgp.ColorSpace)
            dmprintf1(pdev->memory, "     CS = %s",
                cs_names[(int)gs_color_space_get_index(tgp.ColorSpace)]);
        else
            dmputs(pdev->memory, "     (no CS)");
        dmprintf2(pdev->memory, "  Isolated = %d  Knockout = %d\n",
                 tgp.Isolated, tgp.Knockout);
        if (tgp.iccprofile)
            dmprintf(pdev->memory, "     Have ICC Profile for blending\n");
    }
#endif
    if (dev_proc(pdev, begin_transparency_group) != 0)
        return (*dev_proc(pdev, begin_transparency_group)) (pdev, &tgp, &bbox, pis,
                                                            NULL);
    else
        return 0;
}
Example #16
0
static void
pxPassthrough_setpagestate(px_state_t * pxs)
{
    /* by definition we are in "snippet mode" if pxl has dirtied
       the page */
    if (pxs->have_page) {
        if (gs_debug_c('i'))
            dmprintf(pxs->memory, "passthrough: snippet mode\n");
        /* disable an end page in pcl, also used to flag in snippet mode */
        global_pcs->end_page = pcl_end_page_noop;
        /* set the page size and orientation.  Really just sets
           the page tranformation does not feed a page (see noop
           above) */
        pcl_new_logical_page_for_passthrough(global_pcs,
                                             (int)pxs->orientation,
                                             &pxs->media_dims);

        if (gs_debug_c('i'))
            dmprintf2(pxs->memory,
                      "passthrough: snippet mode changing orientation from %d to %d\n",
                      global_pcs->xfm_state.lp_orient, (int)pxs->orientation);

    } else {                    /* not snippet mode - full page mode */
        /* pcl can feed the page and presumedely pcl commands will
           be used to set pcl's state. */
        global_pcs->end_page = pcl_end_page_top;
        /* clean the pcl page if it was marked by a previous snippet
           and set to full page mode. */
        global_pcs->page_marked = 0;
        pcl_new_logical_page_for_passthrough(global_pcs,
                                             (int)pxs->orientation,
                                             &pxs->media_dims);
        if (gs_debug_c('i'))
            dmprintf(pxs->memory, "passthrough: full page mode\n");
    }
}
Example #17
0
static int
gx_remap_concrete_DeviceN(const frac * pconc, const gs_color_space * pcs,
        gx_device_color * pdc, const gs_imager_state * pis, gx_device * dev,
                          gs_color_select_t select)
{
    int code;

#ifdef DEBUG
    /*
     * Verify that the color space and imager state info match.
     */
    if (pcs->id != pis->color_component_map.cspace_id)
        dmprintf(pis->memory, "gx_remap_concrete_DeviceN: color space id mismatch");
#endif
    if (pis->color_component_map.use_alt_cspace) {
        const gs_color_space *pacs = pcs->base_space;

        return (*pacs->type->remap_concrete_color)
                                (pconc, pacs, pdc, pis, dev, select);
    }
    else {
    /* If we are going DeviceN out to real sep device that understands these,
       and if the destination profile is DeviceN, we print the colors directly. 
       Make sure to disable the DeviceN profile color map so that is does not
       get used in gx_remap_concrete_devicen.  We probably should pass something
       through here but it is a pain due to the change in the proc. */
        cmm_dev_profile_t *dev_profile;
        bool temp_val;

        code = dev_proc(dev, get_profile)(dev, &dev_profile);
        if (dev_profile->spotnames != NULL) {
            temp_val = dev_profile->spotnames->equiv_cmyk_set;
            dev_profile->spotnames->equiv_cmyk_set = false;
            gx_remap_concrete_devicen(pconc, pdc, pis, dev, select);
            dev_profile->spotnames->equiv_cmyk_set = temp_val;
        } else {
            gx_remap_concrete_devicen(pconc, pdc, pis, dev, select);
        }
        return 0;
    }
}
Example #18
0
void
pxpcl_release(void)
{
    if (global_pcs) {
        if (gs_debug_c('i'))
            dmprintf(global_pcs->memory,
                     "passthrough: releasing global pcl state\n");
        pcl_grestore(global_pcs);
        gs_grestore_only(global_pcs->pgs);
        gs_nulldevice(global_pcs->pgs);
        pcl_do_resets(global_pcs, pcl_reset_permanent);
        global_pcs->end_page = pcl_end_page_top;        /* pcl_end_page handling */
        pxpcl_pagestatereset();
        global_pcs = NULL;
        global_this_pass_contiguous = false;
        global_pass_first = true;
        global_char_angle = 0;
        global_char_shear.x = 0;
        global_char_shear.y = 0;
        global_char_scale.x = 1.0;
        global_char_scale.y = 1.0;
        global_char_bold_value = 0.0;
    }
}
Example #19
0
void
hpgl_do_reset(pcl_state_t * pcs, pcl_reset_type_t type)
{
    /* pgframe.c (Chapter 18) */
    hpgl_args_t hpgl_args;

    if ((type & (pcl_reset_initial | pcl_reset_printer | pcl_reset_cold)) !=
        0) {
        if ((type & (pcl_reset_initial | pcl_reset_cold)) != 0) {
            gx_path_alloc_contained(&pcs->g.polygon.buffer.path,
                                    pcs->memory,
                                    "hpgl_do_reset polygon buffer");
            gs_setlimitclamp(pcs->pgs, true);
        } else
            gx_path_new(&pcs->g.polygon.buffer.path);

        /* provide default anchor point, plot size and picture frame size */
        hpgl_default_coordinate_system(pcs);

        /* we should not have a path at this point but we make sure */
        hpgl_clear_current_path(pcs);

        /* Initialize stick/arc font instances */
        hpgl_initialize_stick_fonts(pcs);

        /* intialize subpolygon started hack flag */
        pcs->g.subpolygon_started = false;

        /* indicates a line down operation has been done in polygon
           mode */
        pcs->g.have_drawn_in_path = false;
        /* execute only the implicit portion of IN */
        hpgl_IN_implicit(pcs);

        /* we select the default pen 1 here, oddly, IN does not select
           the default pen even though it sets pen widths and units of
           measure */
        pcs->g.pen.selected = 1;
    }
    /* NB check all of these */
    if ((type & pcl_reset_page_params) != 0) {
        /* provide default anchor point, plot size and picture frame
           size.  Oddly HP does not reset the scaling parameters
           when the page size is changed. */
        int scale_type = pcs->g.scaling_type;
        hpgl_scaling_params_t params = pcs->g.scaling_params;

        hpgl_default_coordinate_system(pcs);

        /* restore the scaling parameter. */
        pcs->g.scaling_type = scale_type;
        pcs->g.scaling_params = params;

        hpgl_args_setup(&hpgl_args);
        hpgl_IW(&hpgl_args, pcs);
        hpgl_args_set_int(&hpgl_args, 0);
        hpgl_PM(&hpgl_args, pcs);
        hpgl_args_set_int(&hpgl_args, 2);
        hpgl_PM(&hpgl_args, pcs);
        hpgl_args_setup(&hpgl_args);
        hpgl_IP(&hpgl_args, pcs);
    }

    if ((type & pcl_reset_picture_frame) != 0) {
        /* this shouldn't happen.  Picture frame side effects are
           handled directly by the command picture frame command. */
        dmprintf(pcs->memory, "PCL reset picture frame received\n");
    }

    if ((type & pcl_reset_overlay) != 0)
        /* ignore return */
        (void)hpgl_reset_overlay(pcs);

    if ((type & (pcl_reset_plot_size)) != 0) {
        /* this shouldn't happen.  Plot size side effects are handled
           directly by the command picture frame command. */
        dmprintf(pcs->memory, "PCL reset plot received\n");
    }

    if ((type & (pcl_reset_permanent)) != 0) {
        gx_path_free(&pcs->g.polygon.buffer.path,
                     "hpgl_do_reset polygon buffer");
        /* if we have allocated memory for a stick font free the memory */
        hpgl_free_stick_fonts(pcs);
    }
    return;
}
Example #20
0
int
pxPassthrough(px_args_t * par, px_state_t * pxs)
{
    stream_cursor_read r;
    int code = 0;
    uint used;

    /* apparently if there is no open data source we open one.  By the
       spec this should already be open, in practice it is not. */
    if (!pxs->data_source_open) {
        if (gs_debug_c('i'))
            dmprintf(pxs->memory,
                     "passthrough: data source not open upon entry\n");
        pxs->data_source_open = true;
        pxs->data_source_big_endian = true;
    }

    /* source available is part of the equation to determine if this
       operator is being called for the first time */
    if (par->source.available == 0) {
        if (par->source.phase == 0) {
            if (gs_debug_c('i'))
                dmprintf(pxs->memory,
                         "passthrough starting getting more data\n");

            if (!global_pcs)
                pxPassthrough_init(pxs);

            /* this is the first passthrough on this page */
            if (global_pass_first) {
                pxPassthrough_setpagestate(pxs);
                pxPassthrough_pcl_state_nonpage_exceptions(pxs);
                global_pass_first = false;
            } else {
                /* there was a previous passthrough check if there were
                   any intervening XL commands */
                if (global_this_pass_contiguous == false)
                    pxPassthrough_pcl_state_nonpage_exceptions(pxs);
            }
            par->source.phase = 1;
        }
        return pxNeedData;
    }

    /* set pcl data stream pointers to xl's and process this batch of data. */
    r.ptr = par->source.data - 1;
    r.limit = par->source.data + par->source.available - 1;
    code = pcl_process(&global_pcl_parser_state, global_pcs, &r);
    /* updata xl's parser position to reflect what pcl has consumed. */
    used = (r.ptr + 1 - par->source.data);
    par->source.available -= used;
    par->source.data = r.ptr + 1;

    if (code < 0) {
        dmprintf1(pxs->memory, "passthrough: error return %d\n", code);
        return code;
    }
    /* always return need data and we exit at the top when the data is
       exhausted. */
    {
        if (used > px_parser_data_left(par->parser)) {
            dmprintf(pxs->memory, "error: read past end of stream\n");
            return -1;
        } else if (used < px_parser_data_left(par->parser)) {
            return pxNeedData;
        } else {
            /* end of operator and data */
            return 0;
        }
    }
}
Example #21
0
/*
 * Check the configure image data short form structure.
 *
 * Returns 0 on success, < 0 in case of an error.
 */
static int
check_cid_hdr(pcl_state_t * pcs, pcl_cid_data_t * pcid)
{
    pcl_cid_hdr_t *pcidh = &(pcid->u.hdr);
    int i;

    if ((pcidh->cspace >= pcl_cspace_num)
        || (pcidh->encoding >= pcl_penc_num))
        return -1;

    /* apparently direct by pixel encoding mode defaults bits per
       index to 8 */
    if (pcidh->encoding == pcl_penc_direct_by_pixel)
        pcidh->bits_per_index = 8;

    /*
     * Map zero values. Zero bits per index is equivalent to one bit per index;
     * zero bits per primary is equivalent to 8 bits per primary.
     */
    if (pcidh->bits_per_index == 0)
        pcidh->bits_per_index = 1;
    for (i = 0; i < countof(pcidh->bits_per_primary); i++) {
        if (pcidh->bits_per_primary[i] == 0)
            pcidh->bits_per_primary[i] = 8;
        if (pcs->personality == pcl5e && pcidh->bits_per_primary[i] != 1)
            dmprintf(pcs->memory, "pcl5e personality with color primaries\n");
    }

    switch (pcidh->encoding) {

        case pcl_penc_indexed_by_pixel:
            if ((pcidh->bits_per_index & (pcidh->bits_per_index - 1)) != 0)
                return -1;
            /* fall through */

        case pcl_penc_indexed_by_plane:
            if (pcidh->bits_per_index > 8)
                return -1;
            break;

        case pcl_penc_direct_by_plane:
            /* must be device-specific color space */
            if ((pcidh->cspace != pcl_cspace_RGB)
                && (pcidh->cspace != pcl_cspace_CMY))
                return -1;
            if ((pcidh->bits_per_primary[0] != 1) ||
                (pcidh->bits_per_primary[1] != 1) ||
                (pcidh->bits_per_primary[2] != 1))
                return -1;
            break;

        case pcl_penc_direct_by_pixel:
            if ((pcidh->bits_per_primary[0] != 8) ||
                (pcidh->bits_per_primary[1] != 8) ||
                (pcidh->bits_per_primary[2] != 8))
                return -1;
            break;
    }

    /*
     * Strange HP-ism: for device independent color spaces, bits per primary
     * is always 8. For the direct by plane/pixel cases, this will already be
     * the case, but the indexed by pixel/plane cases may require modification.
     */
    if ((pcidh->encoding < pcl_penc_direct_by_plane) &&
        (pcidh->cspace > pcl_cspace_CMY)) {
        pcidh->bits_per_primary[0] = 8;
        pcidh->bits_per_primary[1] = 8;
        pcidh->bits_per_primary[2] = 8;
    }

    /* 
     * All long form color commands appear to be deprecated on modern
     * HP devices.  We simply truncate all long form commands to the 6
     * byte short form.
     */

    pcid->len = 6;

    /* remap the colorimetric color space to rgb */
    if (pcidh->cspace == pcl_cspace_Colorimetric)
        pcidh->cspace = pcl_cspace_RGB;

    return 0;
}
Example #22
0
static bool monitor_process_input(struct monitor * mon, int c)
{
	struct dmon_comm * comm = mon->comm;

	switch (c) {
#if (BOOT_ENABLE_GDB)
	case '+':
		dbgmon_exec(gdb_bootstrap);
		break;
#endif
#if (BOOT_ENABLE_THIRD)
	case '~':
		dbgmon_exec(third_bootstrap);
		break;
#endif
#if (MONITOR_APPTERM_ENABLE)
	case CTRL_C:
		dmprintf(comm, "^C\r\n");
		dbgmon_soft_reset();
		break;
#endif
#if (MONITOR_SELFTEST_ENABLE)
	case CTRL_E:
		dmprintf(comm, "^E\r\n");
		dbgmon_soft_reset();
		dbgmon_exec(selftest_bootstrap);
		break;
#endif
#if (MONITOR_CONFIGURE_ENABLE)
	case CTRL_K:
		dmprintf(comm, "^K\r\n");
		dbgmon_soft_reset();
		this_board.configure(comm);
		break;
#endif
#if (MONITOR_UPGRADE_ENABLE)
	case CTRL_FS:
		dbgmon_soft_reset();
		dmprintf(comm, "^\\\r\nConfirm [y]? ");
		if (dmgetc(comm) == 'y') {
			this_board.upgrade(comm);
			dmprintf(comm, "Failed !!!\r\n");
		} else {
			dmprintf(comm, "\r\n");
		}
		break;
#endif
#if (MONITOR_THREADINFO_ENABLE)
	case CTRL_N:
		mon->thread_id = __thinkos_thread_getnext(mon->thread_id);
		if (mon->thread_id == - 1)
			mon->thread_id = __thinkos_thread_getnext(mon->thread_id);
		dmprintf(comm, "Thread = %d\r\n", mon->thread_id);
		dmon_print_thread(comm, mon->thread_id);
		break;
	case CTRL_O:
		dmprintf(comm, "^O\r\n");
		dmprintf(comm, s_hr);
		dmon_print_osinfo(comm);
		break;
	case CTRL_P:
		dmprintf(comm, "^P\r\n");
		monitor_pause_all(comm);
		break;
	case CTRL_Q:
		dmprintf(comm, "^Q\r\n");
		dbgmon_exec(monitor_task);
		break;
	case CTRL_R:
		dmprintf(comm, "^R\r\n");
		monitor_resume_all(comm);
		break;
#endif
#if (MONITOR_DUMPMEM_ENABLE)
	case CTRL_S:
		dmprintf(comm, "^S\r\n");
		monitor_show_mem(mon);
		break;
#endif
#if (MONITOR_THREADINFO_ENABLE)
	case CTRL_T:
		dmon_print_thread(comm, mon->thread_id);
		break;
#endif
#if (MONITOR_STACKUSAGE_ENABLE)
	case CTRL_U:
		dmon_print_stack_usage(comm);
		break;
#endif
	case CTRL_V:
		monitor_show_help(comm);
		break;
#if (MONITOR_FAULT_ENABLE)
	case CTRL_X:
		monitor_print_fault(comm);
		break;
#endif
	case CTRL_Y:
		dmprintf(comm, "^\\\r\nConfirm [y]? ");
		if (dmgetc(comm) == 'y') {
			monitor_ymodem_recv(comm, this_board.application.start_addr, 
								this_board.application.block_size);
		} else {
			dmprintf(comm, "\r\n");
		}
		break;
#if (MONITOR_APPWIPE_ENABLE)
	case CTRL_W:
		dmprintf(comm, "^W\r\n");
		monitor_app_erase(comm, this_board.application.start_addr, 
						  this_board.application.block_size);
		break;
#endif
#if (MONITOR_APPRESTART_ENABLE)
	case CTRL_Z:
		dmprintf(comm, "^Z\r\n");
		dbgmon_soft_reset();
		monitor_exec(comm, this_board.application.start_addr);
		break;
#endif
#if (MONITOR_WATCHPOINT_ENABLE)
	case CTRL_GS:
		dmprintf(comm, "^]\r\n");
		monitor_watchpoint(mon);
		break;
#endif
	default:
		return false;
	}

	return true;
}
Example #23
0
void dmon_print_exception(struct dmon_comm * comm, 
						  struct thinkos_except * xcpt)
{
//	uint32_t psr = xcpt->ctx.xpsr;
#if THINKOS_ENABLE_MPU 
	uint32_t mmfsr;
#endif
#if THINKOS_ENABLE_BUSFAULT
	uint32_t bfsr;
#endif
#if THINKOS_ENABLE_USAGEFAULT 
	uint32_t ufsr;
#endif
	uint32_t sp;
	int ipsr;

	switch (xcpt->type) {
	case CM3_EXCEPT_HARD_FAULT:
		dmprintf(comm, " Hard Fault at ");
		break;

#if THINKOS_ENABLE_MPU 
	case CM3_EXCEPT_MEM_MANAGE:
		dmprintf(comm, " Memory Manager Fault at ");
		break;
#endif

#if THINKOS_ENABLE_BUSFAULT
	case CM3_EXCEPT_BUS_FAULT:
		dmprintf(comm, " Bus Fault at ");
		break;
#endif

#if THINKOS_ENABLE_USAGEFAULT 
	case CM3_EXCEPT_USAGE_FAULT: 
		dmprintf(comm, " Usage Fault at ");
		break;
#endif
	default:
		dmprintf(comm, " Error %d at ", xcpt->type);
	}

	ipsr = xcpt->ctx.xpsr & 0x1ff;
	if (ipsr == 0) {
		dmprintf(comm, "thread %d", xcpt->active + 1);
	} else if (ipsr > 15) {
		dmprintf(comm, "IRQ %d", ipsr - 16);
	} else {
		switch (ipsr) {
		case CM3_EXCEPT_SVC:
			dmprintf(comm, "SVCall, thread %d", xcpt->active + 1);
			break;
		case CM3_EXCEPT_DEBUG_MONITOR:
			dmprintf(comm, "Monitor");
			break;
		case CM3_EXCEPT_PENDSV:
			dmprintf(comm, "PendSV");
			break;
		case CM3_EXCEPT_SYSTICK:
			dmprintf(comm, "sysTick");
			break;
		}
	}

	dmprintf(comm, "\r\n");

	sp = (xcpt->ret == CM3_EXC_RET_THREAD_PSP) ? xcpt->psp : xcpt->msp;
	dmon_print_context(comm, &xcpt->ctx, sp);

	switch (xcpt->type) {
#if THINKOS_ENABLE_MPU 
	case CM3_EXCEPT_MEM_MANAGE:
		mmfsr = SCB_CFSR_MMFSR_GET(CM3_SCB->cfsr);
		dmprintf(comm, "mmfsr=%02x [", mmfsr);
		if (mmfsr & MMFSR_MMARVALID)
			dmprintf(comm, " MMARVALID");
		if (mmfsr & MMFSR_MLSPERR)
			dmprintf(comm, " MLSPERR");
		if (mmfsr & MMFSR_MSTKERR)
			dmprintf(comm, " MSTKERR");
		if (mmfsr & MMFSR_MUNSTKERR)
			dmprintf(comm, " MUNSTKERR");
		if (mmfsr & MMFSR_DACCVIOL)  
			dmprintf(comm, " DACCVIOL");
		if (mmfsr & MMFSR_IACCVIOL)  
			dmprintf(comm, " IACCVIOL");
		dmprintf(comm, " ]\r\n");
		if (mmfsr & MMFSR_MMARVALID) 
			dmprintf(comm, " Fault address --> %08x\r\n", 
					 (uint32_t)CM3_SCB->mmfar);
		break;
#endif

#if THINKOS_ENABLE_BUSFAULT
	case CM3_EXCEPT_BUS_FAULT:
		bfsr = SCB_CFSR_BFSR_GET(CM3_SCB->cfsr);
		dmprintf(comm, " bfsr=%02x [", bfsr);
		if (bfsr & BFSR_BFARVALID)  
			dmprintf(comm, " BFARVALID");
		if (bfsr & BFSR_LSPERR)
			dmprintf(comm, " LSPERR");
		if (bfsr & BFSR_STKERR)  
			dmprintf(comm, " STKERR");
		if (bfsr & BFSR_UNSTKERR)  
			dmprintf(comm, " UNSTKERR");
		if (bfsr & BFSR_IMPRECISERR)  
			dmprintf(comm, " IMPRECISERR");
		if (bfsr & BFSR_PRECISERR)
			dmprintf(comm, " PRECISERR");
		if (bfsr & BFSR_IBUSERR)  
			dmprintf(comm, " IBUSERR");
		dmprintf(comm, " ]\r\n");
		if (bfsr & BFSR_BFARVALID) 
			dmprintf(comm, " Fault address --> %08x\r\n", 
					 (uint32_t)CM3_SCB->bfar);
		break;
#endif

#if THINKOS_ENABLE_USAGEFAULT 
	case CM3_EXCEPT_USAGE_FAULT: 
		ufsr = SCB_CFSR_UFSR_GET(CM3_SCB->cfsr);
		dmprintf(comm, " ufsr=%04x [", ufsr);
		if (ufsr & UFSR_DIVBYZERO)  
			dmprintf(comm, " DIVBYZERO");
		if (ufsr & UFSR_UNALIGNED)  
			dmprintf(comm, " UNALIGNED");
		if (ufsr & UFSR_NOCP)  
			dmprintf(comm, " NOCP");
		if (ufsr & UFSR_INVPC)  
			dmprintf(comm, " INVPC");
		if (ufsr & UFSR_INVSTATE)  
			dmprintf(comm, " INVSTATE");
		if (ufsr & UFSR_UNDEFINSTR)  
			dmprintf(comm, " UNDEFINSTR");
		dmprintf(comm, " ]\r\n");
		break;
#endif
	}

}
Example #24
0
static int
gx_concretize_DeviceN(const gs_client_color * pc, const gs_color_space * pcs,
                      frac * pconc, const gs_imager_state * pis, gx_device *dev)
{
    int code, tcode = 0;
    gs_client_color cc;
    gs_color_space *pacs = (gs_color_space*) (pcs->base_space);
    gs_device_n_map *map = pcs->params.device_n.map;
    bool is_lab;
    int k;
    int num_des_comps = dev->color_info.num_components;
    gsicc_namedcolor_t *named_color;
    const gs_separation_name *names = pcs->params.device_n.names;
    int num_src_comps = pcs->params.device_n.num_components;

#ifdef DEBUG
    /*
     * Verify that the color space and imager state info match.
     */
    if (pcs->id != pis->color_component_map.cspace_id)
        dmprintf(dev->memory, "gx_concretize_DeviceN: color space id mismatch");
#endif

    /*
     * Check if we need to map into the alternate color space.
     * We must preserve tcode for implementing a semi-hack in the interpreter.
     */

    if (pis->color_component_map.use_alt_cspace) {
        /* First see if we have a named color object that we can use to try
           to map from the spot color into device values.  */
        if (pis->icc_manager->device_named != NULL) {
            /* There is a table present.  If we have the colorant name
               then get the device values */
            gx_color_value device_values[GX_DEVICE_COLOR_MAX_COMPONENTS];
            byte *pname;
            uint name_size;
            gsicc_rendering_param_t rendering_params;

            /* Define the rendering intents. */
            rendering_params.black_point_comp = pis->blackptcomp;
            rendering_params.graphics_type_tag = dev->graphics_type_tag;
            rendering_params.override_icc = false;
            rendering_params.preserve_black = gsBKPRESNOTSPECIFIED;
            rendering_params.rendering_intent = pis->renderingintent;
            rendering_params.cmm = gsCMM_DEFAULT;

            /* Allocate and initialize name structure */
            named_color = 
                (gsicc_namedcolor_t*) gs_alloc_bytes(dev->memory,
                    num_src_comps * sizeof(gsicc_namedcolor_t),
                    "gx_remap_concrete_DeviceN");

            for (k = 0; k < num_src_comps; k++) {
                pcs->params.device_n.get_colorname_string(dev->memory, names[k], 
                                                          &pname, &name_size);
                named_color[k].colorant_name = (char*) pname;
                named_color[k].name_size = name_size;
            }
            code = gsicc_transform_named_color(pc->paint.values, named_color,
                                               num_src_comps, device_values, 
                                               pis, dev, NULL, 
                                               &rendering_params);
            gs_free_object(dev->memory, named_color, 
                           "gx_remap_concrete_DeviceN");
            if (code == 0) {
                for (k = 0; k < num_des_comps; k++){
                    pconc[k] = float2frac(((float) device_values[k])/65535.0);
                }
                return(0);
            }
        }
        /* Check the 1-element cache first. */
        if (map->cache_valid) {
            int i;

            for (i = pcs->params.device_n.num_components; --i >= 0;) {
                if (map->tint[i] != pc->paint.values[i])
                    break;
            }
            if (i < 0) {
                int num_out = gs_color_space_num_components(pacs);

                for (i = 0; i < num_out; ++i)
                    pconc[i] = map->conc[i];
                return 0;
            }
        }
        tcode = (*pcs->params.device_n.map->tint_transform)
             (pc->paint.values, &cc.paint.values[0],
             pis, pcs->params.device_n.map->tint_transform_data);
        (*pacs->type->restrict_color)(&cc, pacs);
        if (tcode < 0)
            return tcode;
        /* First check if this was PS based. */
        if (gs_color_space_is_PSCIE(pacs)) {
            /* We may have to rescale data to 0 to 1 range */
            rescale_cie_colors(pacs, &cc);
            /* If we have not yet created the profile do that now */
            if (pacs->icc_equivalent == NULL) {
                gs_colorspace_set_icc_equivalent(pacs, &(is_lab), pis->memory);
            }
            /* Use the ICC equivalent color space */
            pacs = pacs->icc_equivalent;
        }
        if (pacs->cmm_icc_profile_data->data_cs == gsCIELAB ||
            pacs->cmm_icc_profile_data->islab) {
            /* Get the data in a form that is concrete for the CMM */
            cc.paint.values[0] /= 100.0;
            cc.paint.values[1] = (cc.paint.values[1]+128)/255.0;
            cc.paint.values[2] = (cc.paint.values[2]+128)/255.0;
        }
        code = cs_concretize_color(&cc, pacs, pconc, pis, dev);
    }
    else {
        int i;

        for (i = num_src_comps; --i >= 0;)
            pconc[i] = gx_unit_frac(pc->paint.values[i]);
        return 0;
    }
    return (code < 0 || tcode == 0 ? code : tcode);
}
Example #25
0
static int
gx_concretize_DeviceN(const gs_client_color * pc, const gs_color_space * pcs,
                      frac * pconc, const gs_imager_state * pis, gx_device *dev)
{
    int code, tcode = 0;
    gs_client_color cc;
    gs_color_space *pacs = (gs_color_space*) (pcs->base_space);
    gs_device_n_map *map = pcs->params.device_n.map;
    bool is_lab;
    int num_src_comps = pcs->params.device_n.num_components;

#ifdef DEBUG
    /*
     * Verify that the color space and imager state info match.
     */
    if (pcs->id != pis->color_component_map.cspace_id)
        dmprintf(dev->memory, "gx_concretize_DeviceN: color space id mismatch");
#endif

    /*
     * Check if we need to map into the alternate color space.
     * We must preserve tcode for implementing a semi-hack in the interpreter.
     */

    if (pis->color_component_map.use_alt_cspace) {
        /* Check the 1-element cache first. */
        if (map->cache_valid) {
            int i;

            for (i = pcs->params.device_n.num_components; --i >= 0;) {
                if (map->tint[i] != pc->paint.values[i])
                    break;
            }
            if (i < 0) {
                int num_out = gs_color_space_num_components(pacs);

                for (i = 0; i < num_out; ++i)
                    pconc[i] = map->conc[i];
                return 0;
            }
        }
        tcode = (*pcs->params.device_n.map->tint_transform)
             (pc->paint.values, &cc.paint.values[0],
             pis, pcs->params.device_n.map->tint_transform_data);
        (*pacs->type->restrict_color)(&cc, pacs);
        if (tcode < 0)
            return tcode;
        /* First check if this was PS based. */
        if (gs_color_space_is_PSCIE(pacs)) {
            /* We may have to rescale data to 0 to 1 range */
            rescale_cie_colors(pacs, &cc);
            /* If we have not yet created the profile do that now */
            if (pacs->icc_equivalent == NULL) {
                gs_colorspace_set_icc_equivalent(pacs, &(is_lab), pis->memory);
            }
            /* Use the ICC equivalent color space */
            pacs = pacs->icc_equivalent;
        }
        if (pacs->cmm_icc_profile_data->data_cs == gsCIELAB ||
            pacs->cmm_icc_profile_data->islab) {
            /* Get the data in a form that is concrete for the CMM */
            cc.paint.values[0] /= 100.0;
            cc.paint.values[1] = (cc.paint.values[1]+128)/255.0;
            cc.paint.values[2] = (cc.paint.values[2]+128)/255.0;
        }
        code = cs_concretize_color(&cc, pacs, pconc, pis, dev);
    }
    else {
        int i;

        for (i = num_src_comps; --i >= 0;)
            pconc[i] = gx_unit_frac(pc->paint.values[i]);
        return 0;
    }
    return (code < 0 || tcode == 0 ? code : tcode);
}
Example #26
0
void dmon_print_thread(struct dmon_comm * comm, unsigned int thread_id)
{
	struct thinkos_rt * rt = &thinkos_rt;
	int32_t timeout;
	uint32_t cyccnt;
	int sched_val;
	int sched_pri;
	int type;
	int tmw;
	int wq;
#if !THINKOS_ENABLE_THREAD_STAT
	int i;
#endif

	if ((thread_id >= THINKOS_THREADS_MAX) || (rt->ctx[thread_id] == NULL)) {
		return;
	}

#if THINKOS_ENABLE_THREAD_STAT
	wq = rt->th_stat[thread_id] >> 1;
	tmw = rt->th_stat[thread_id] & 1;
#else
	for (i = 0; i < THINKOS_WQ_LST_END; ++i) {
		if (rt->wq_lst[i] & (1 << thread_id))
			break;
	}
	if (i == THINKOS_WQ_LST_END)
		return ; /* not found */
	wq = i;
#if THINKOS_ENABLE_CLOCK
	tmw = rt->wq_clock & (1 << thread_id) ? 1 : 0;
#else
	tmw = 0;
#endif
#endif /* THINKOS_ENABLE_THREAD_STAT */

#if THINKOS_ENABLE_TIMESHARE
	sched_val = rt->sched_val[thread_id];
	sched_pri = rt->sched_pri[thread_id]; 
#else
	sched_val = 0;
	sched_pri = 0;
#endif

#if THINKOS_ENABLE_CLOCK
	timeout = (int32_t)(rt->clock[thread_id] - rt->ticks); 
#else
	timeout = -1;
#endif

#if THINKOS_ENABLE_PROFILING
	cyccnt = rt->cyccnt[thread_id];
#else
	cyccnt = 0;
#endif

	type = thinkos_obj_type_get(wq);

	/* Internal thread ids start form 0 whereas user
	   thread numbers start form one ... */
	dmprintf(comm, " - No: %d", thread_id + 1); 
#if THINKOS_ENABLE_THREAD_INFO
	if (rt->th_inf[thread_id])
		dmprintf(comm, ", '%s'", rt->th_inf[thread_id]->tag); 
	else
#endif
		dmprintf(comm, ", '...'"); 

	if (THINKOS_OBJ_READY == type) {
		dmprintf(comm, " %s.\r\n", thinkos_type_name_lut[type]); 
	} else {
		dmprintf(comm, " %swait on %s(%3d)\r\n", 
				 tmw ? "time" : "", thinkos_type_name_lut[type], wq); 
	}

	dmprintf(comm, " - sched: val=%3d pri=%3d - ", 
			 sched_val, sched_pri); 
	dmprintf(comm, " timeout=%8d ms", timeout); 
	dmprintf(comm, " - cycles=%u\r\n", cyccnt); 

	dmon_print_context(comm, rt->ctx[thread_id], (uint32_t)rt->ctx[thread_id]);

	dmprintf(comm, "\r\n");
}
Example #27
0
/* <source> <dict> /JPXDecode <file> */
static int
z_jpx_decode(i_ctx_t * i_ctx_p)
{
    os_ptr op = osp;
    ref *sop = NULL;
    ref *csname = NULL;
    stream_jpxd_state state;

    /* it's our responsibility to call set_defaults() */
    state.memory = imemory->non_gc_memory;
    if (s_jpxd_template.set_defaults)
      (*s_jpxd_template.set_defaults)((stream_state *)&state);
    if (r_has_type(op, t_dictionary)) {
        check_dict_read(*op);
        if ( dict_find_string(op, "Alpha", &sop) > 0) {
            check_type(*sop, t_boolean);
            if (sop->value.boolval)
                state.alpha = true;
        }
        if ( dict_find_string(op, "ColorSpace", &sop) > 0) {
            /* parse the value */
            if (r_is_array(sop)) {
                /* assume it's the first array element */
                csname =  sop->value.refs;
            } else if (r_has_type(sop,t_name)) {
                /* use the name directly */
                csname = sop;
            } else {
                dmprintf(imemory, "warning: JPX ColorSpace value is an unhandled type!\n");
            }
            if (csname != NULL) {
                ref sref;
                /* get a reference to the name's string value */
                name_string_ref(imemory, csname, &sref);
                /* request raw index values if the colorspace is /Indexed */
                if (!ISTRCMP(&sref, "Indexed"))
                    state.colorspace = gs_jpx_cs_indexed;
                /* tell the filter what output we want for other spaces */
                else if (!ISTRCMP(&sref, "DeviceGray"))
                    state.colorspace = gs_jpx_cs_gray;
                else if (!ISTRCMP(&sref, "DeviceRGB"))
                    state.colorspace = gs_jpx_cs_rgb;
                else if (!ISTRCMP(&sref, "DeviceCMYK"))
                    state.colorspace = gs_jpx_cs_cmyk;
                else if (!ISTRCMP(&sref, "ICCBased")) {
                    /* The second array element should be the profile's
                       stream dict */
                    ref *csdict = sop->value.refs + 1;
                    ref *nref;
                    ref altname;
                    if (r_is_array(sop) && (r_size(sop) > 1) &&
                      r_has_type(csdict, t_dictionary)) {
                        check_dict_read(*csdict);
                        /* try to look up the alternate space */
                        if (dict_find_string(csdict, "Alternate", &nref) > 0) {
                          name_string_ref(imemory, csname, &altname);
                          if (!ISTRCMP(&altname, "DeviceGray"))
                            state.colorspace = gs_jpx_cs_gray;
                          else if (!ISTRCMP(&altname, "DeviceRGB"))
                            state.colorspace = gs_jpx_cs_rgb;
                          else if (!ISTRCMP(&altname, "DeviceCMYK"))
                            state.colorspace = gs_jpx_cs_cmyk;
                        }
                        /* else guess based on the number of components */
                        if (state.colorspace == gs_jpx_cs_unset &&
                                dict_find_string(csdict, "N", &nref) > 0) {
                          if_debug1m('w', imemory, "[w] JPX image has an external %"PRIpsint
                                     " channel colorspace\n", nref->value.intval);
                          switch (nref->value.intval) {
                            case 1: state.colorspace = gs_jpx_cs_gray;
                                break;
                            case 3: state.colorspace = gs_jpx_cs_rgb;
                                break;
                            case 4: state.colorspace = gs_jpx_cs_cmyk;
                                break;
                          }
                        }
                    }
                }
            } else {
                if_debug0m('w', imemory, "[w] Couldn't read JPX ColorSpace key!\n");
            }
        }
    }

    /* we pass npop=0, since we've no arguments left to consume */
    /* we pass 0 instead of the usual rspace(sop) which will allocate storage
       for filter state from the same memory pool as the stream it's coding.
       this causes no trouble because we maintain no pointers */
    return filter_read(i_ctx_p, 0, &s_jpxd_template,
                       (stream_state *) & state, 0);
}
Example #28
0
static void monitor_resume_all(struct dmon_comm * comm)
{
	dmprintf(comm, "\r\nResuming all threads...\r\n");
	__thinkos_resume_all();
	dmprintf(comm, "Restarting...\r\n");
}