Exemplo n.º 1
0
int		main(int ac, char **av)
{
	t_nm		nm;
	int			i;
	int			return_value;
	t_symtable	*list;
	static char	default_name[] = "a.out";

	return_value = EXIT_SUCCESS;
	nm_init(&nm, av);
	nm.list = &list;
	if (ac < 2)
	{
		nm.file = default_name;
		return (handle_file(&nm));
	}
	nm.file = av[1];
	if ((i = nm_flag_handler(av, &(nm.flag))) < 0)
		return (return_value);
	nm.flag = ((ac - i - 2) > 0) ? nm.flag | FLAG_PRINT : nm.flag;
	while (++i < ac)
	{
		nm.file = av[i];
		return_value |= handle_file(&nm);
	}
	return (return_value);
}
Exemplo n.º 2
0
void DH_Agree_Key_Gen(unsigned char *Y, int len, unsigned char *xx, int len1, unsigned char *kb)
{
	DH_NUMBERS n, x, g;
	DH_NUMBERS o;

	bytesToNumbers( &n, default_DH, 32);
	bytesToNumbers( &g, Y , len);
	bytesToNumbers( &x, xx,   len1);
	nm_init( &n, NUM0P );
	nm_exp(  &g, &x, &o );
	nm_toBytes(&o, kb);
}
Exemplo n.º 3
0
void DH_Public_Key_Gen(unsigned char *in_buf, int len, unsigned char *out_buf)
{
	DH_NUMBERS n, x, g;
	DH_NUMBERS o;

	bytesToNumbers( &n, default_DH, 32);
	bytesToNumbers( &x, in_buf, len);
	bytesToNumbers( &g, default_DH + 64 , 32);
	nm_init( &n, NUM0P );
	nm_exp(  &g, &x, &o );
	nm_toBytes(&o, out_buf);
}
Exemplo n.º 4
0
Arquivo: neo.c Projeto: bluhm/sys
int
neo_activate(struct device *self, int act)
{
	struct neo_softc *sc = (struct neo_softc *)self;

	switch (act) {
	case DVACT_SUSPEND:
		break;
	case DVACT_RESUME:
		nm_init(sc);
		break;
	}
	return 0;
}
Exemplo n.º 5
0
int
neo_activate(struct device *self, int act)
{
	struct neo_softc *sc = (struct neo_softc *)self;

	switch (act) {
	case DVACT_SUSPEND:
		break;
	case DVACT_RESUME:
		nm_init(sc);
		(sc->codec_if->vtbl->restore_ports)(sc->codec_if);
		break;
	}
	return 0;
}
Exemplo n.º 6
0
static int
nm_pci_attach(device_t dev)
{
	struct sc_info *sc;
	struct ac97_info *codec = 0;
	char 		status[SND_STATUSLEN];

	sc = malloc(sizeof(*sc), M_DEVBUF, M_WAITOK | M_ZERO);
	sc->dev = dev;
	sc->type = pci_get_devid(dev);

	pci_enable_busmaster(dev);

	sc->bufid = PCIR_BAR(0);
	sc->buf = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &sc->bufid,
					 RF_ACTIVE);
	sc->regid = PCIR_BAR(1);
	sc->reg = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &sc->regid,
					 RF_ACTIVE);

	if (!sc->buf || !sc->reg) {
		device_printf(dev, "unable to map register space\n");
		goto bad;
	}

	if (nm_init(sc) == -1) {
		device_printf(dev, "unable to initialize the card\n");
		goto bad;
	}

	codec = AC97_CREATE(dev, sc, nm_ac97);
	if (codec == NULL) goto bad;
	if (mixer_init(dev, ac97_getmixerclass(), codec) == -1) goto bad;

	sc->irqid = 0;
	sc->irq = bus_alloc_resource_any(dev, SYS_RES_IRQ, &sc->irqid,
					 RF_ACTIVE | RF_SHAREABLE);
	if (!sc->irq || snd_setup_intr(dev, sc->irq, 0, nm_intr, sc, &sc->ih)) {
		device_printf(dev, "unable to map interrupt\n");
		goto bad;
	}

	snprintf(status, SND_STATUSLEN, "at memory 0x%lx, 0x%lx irq %ld %s",
		 rman_get_start(sc->buf), rman_get_start(sc->reg),
		 rman_get_start(sc->irq),PCM_KLDSTRING(snd_neomagic));

	if (pcm_register(dev, sc, 1, 1)) goto bad;
	pcm_addchan(dev, PCMDIR_REC, &nmchan_class, sc);
	pcm_addchan(dev, PCMDIR_PLAY, &nmchan_class, sc);
	pcm_setstatus(dev, status);

	return 0;

bad:
	if (codec) ac97_destroy(codec);
	if (sc->buf) bus_release_resource(dev, SYS_RES_MEMORY, sc->bufid, sc->buf);
	if (sc->reg) bus_release_resource(dev, SYS_RES_MEMORY, sc->regid, sc->reg);
	if (sc->ih) bus_teardown_intr(dev, sc->irq, sc->ih);
	if (sc->irq) bus_release_resource(dev, SYS_RES_IRQ, sc->irqid, sc->irq);
	free(sc, M_DEVBUF);
	return ENXIO;
}
Exemplo n.º 7
0
static int
nm_pci_attach(device_t dev)
{
	snddev_info    *d;
	u_int32_t	data;
	struct sc_info *sc;
	struct ac97_info *codec;
	char 		status[SND_STATUSLEN];

	d = device_get_softc(dev);
	if ((sc = malloc(sizeof(*sc), M_DEVBUF, M_NOWAIT)) == NULL) {
		device_printf(dev, "cannot allocate softc\n");
		return ENXIO;
	}

	bzero(sc, sizeof(*sc));
	sc->dev = dev;
	sc->type = pci_get_devid(dev);

	data = pci_read_config(dev, PCIR_COMMAND, 2);
	data |= (PCIM_CMD_PORTEN|PCIM_CMD_MEMEN|PCIM_CMD_BUSMASTEREN);
	pci_write_config(dev, PCIR_COMMAND, data, 2);
	data = pci_read_config(dev, PCIR_COMMAND, 2);

	sc->bufid = PCIR_MAPS;
	sc->buf = bus_alloc_resource(dev, SYS_RES_MEMORY, &sc->bufid,
				     0, ~0, 1, RF_ACTIVE);
	sc->regid = PCIR_MAPS + 4;
	sc->reg = bus_alloc_resource(dev, SYS_RES_MEMORY, &sc->regid,
				     0, ~0, 1, RF_ACTIVE);

	if (!sc->buf || !sc->reg) {
		device_printf(dev, "unable to map register space\n");
		goto bad;
	}

	if (nm_init(sc) == -1) {
		device_printf(dev, "unable to initialize the card\n");
		goto bad;
	}

	codec = ac97_create(dev, sc, nm_rdcd, nm_wrcd);
	if (codec == NULL) goto bad;
	mixer_init(d, &ac97_mixer, codec);

	sc->irqid = 0;
	sc->irq = bus_alloc_resource(dev, SYS_RES_IRQ, &sc->irqid,
				 0, ~0, 1, RF_ACTIVE | RF_SHAREABLE);
	if (!sc->irq ||
	    bus_setup_intr(dev, sc->irq, INTR_TYPE_TTY, nm_intr, sc, &sc->ih)) {
		device_printf(dev, "unable to map interrupt\n");
		goto bad;
	}

	snprintf(status, SND_STATUSLEN, "at memory 0x%lx, 0x%lx irq %ld",
		 rman_get_start(sc->buf), rman_get_start(sc->reg),
		 rman_get_start(sc->irq));

	if (pcm_register(dev, sc, 1, 1)) goto bad;
	pcm_addchan(dev, PCMDIR_REC, &nm_chantemplate, sc);
	pcm_addchan(dev, PCMDIR_PLAY, &nm_chantemplate, sc);
	pcm_setstatus(dev, status);

	return 0;

bad:
	if (sc->buf) bus_release_resource(dev, SYS_RES_MEMORY, sc->bufid, sc->buf);
	if (sc->reg) bus_release_resource(dev, SYS_RES_MEMORY, sc->regid, sc->reg);
	if (sc->ih) bus_teardown_intr(dev, sc->irq, sc->ih);
	if (sc->irq) bus_release_resource(dev, SYS_RES_IRQ, sc->irqid, sc->irq);
	free(sc, M_DEVBUF);
	return ENXIO;
}
Exemplo n.º 8
0
Arquivo: neo.c Projeto: bluhm/sys
void
neo_attach(struct device *parent, struct device *self, void *aux)
{
	struct neo_softc *sc = (struct neo_softc *)self;
	struct pci_attach_args *pa = (struct pci_attach_args *)aux;
	pci_chipset_tag_t pc = pa->pa_pc;
	char const *intrstr;
	pci_intr_handle_t ih;
	int error;

	sc->type = pa->pa_id;

	/* Map I/O register */
	if (pci_mapreg_map(pa, PCI_MAPS, PCI_MAPREG_TYPE_MEM, 0,
			   &sc->bufiot, &sc->bufioh, NULL, NULL, 0)) {
		printf("\n%s: can't map i/o space\n", sc->dev.dv_xname);
		return;
	}


	if (pci_mapreg_map(pa, PCI_MAPS + 4, PCI_MAPREG_TYPE_MEM, 0,
			   &sc->regiot, &sc->regioh, NULL, NULL, 0)) {
		printf("\n%s: can't map i/o space\n", sc->dev.dv_xname);
		return;
	}

	/* Map and establish the interrupt. */
	if (pci_intr_map(pa, &ih)) {
		printf("\n%s: couldn't map interrupt\n", sc->dev.dv_xname);
		return;
	}
	intrstr = pci_intr_string(pc, ih);
	sc->ih = pci_intr_establish(pc, ih, IPL_AUDIO | IPL_MPSAFE,
	    neo_intr, sc, sc->dev.dv_xname);

	if (sc->ih == NULL) {
		printf("\n%s: couldn't establish interrupt",
		       sc->dev.dv_xname);
		if (intrstr != NULL)
			printf(" at %s", intrstr);
		printf("\n");
		return;
	}
	printf(": %s\n", intrstr);

	if ((error = nm_init(sc)) != 0)
		return;

	sc->host_if.arg = sc;

	sc->host_if.attach = neo_attach_codec;
	sc->host_if.read   = neo_read_codec;
	sc->host_if.write  = neo_write_codec;
	sc->host_if.reset  = neo_reset_codec;
	sc->host_if.flags  = neo_flags_codec;

	if ((error = ac97_attach(&sc->host_if)) != 0)
		return;

	audio_attach_mi(&neo_hw_if, sc, &sc->dev);

	return;
}