1184610Salfred/*-
2184610Salfred * Copyright (c) 2011, Oleksandr Tymoshenko <gonzo@FreeBSD.org>
3184610Salfred * All rights reserved.
4184610Salfred *
5184610Salfred * Redistribution and use in source and binary forms, with or without
6184610Salfred * modification, are permitted provided that the following conditions
7189585Sthompsa * are met:
8234686Shselasky * 1. Redistributions of source code must retain the above copyright
9184610Salfred *    notice unmodified, this list of conditions, and the following
10184610Salfred *    disclaimer.
11184610Salfred * 2. Redistributions in binary form must reproduce the above copyright
12184610Salfred *    notice, this list of conditions and the following disclaimer in the
13184610Salfred *    documentation and/or other materials provided with the distribution.
14184610Salfred *
15194674Sthompsa * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16184610Salfred * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17184610Salfred * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18253339Shselasky * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19184610Salfred * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20201381Sed * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21201381Sed * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22236944Shselasky * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23253339Shselasky * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24236944Shselasky * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25194674Sthompsa * SUCH DAMAGE.
26189628Sthompsa */
27189585Sthompsa
28189585Sthompsa#include <sys/cdefs.h>
29223495Shselasky__FBSDID("$FreeBSD$");
30189585Sthompsa
31194674Sthompsa#include <sys/types.h>
32194674Sthompsa#include <sys/systm.h>
33194674Sthompsa#include <sys/param.h>
34194674Sthompsa#include <sys/kernel.h>
35194674Sthompsa#include <vm/uma.h>
36194674Sthompsa
37213852Shselasky#include <machine/octeon_cop2.h>
38213852Shselasky
39213852Shselaskystatic uma_zone_t ctxzone;
40213852Shselasky
41253637Srpaulostatic void
42253637Srpauloocteon_cop2_init(void* dummy)
43253637Srpaulo{
44253637Srpaulo	printf("Create COP2 context zone\n");
45253637Srpaulo	ctxzone = uma_zcreate("COP2 context",
46253637Srpaulo	                        sizeof(struct octeon_cop2_state),
47253637Srpaulo				NULL, NULL, NULL, NULL, 8, 0);
48253637Srpaulo}
49248236Shselasky
50248236Shselaskystruct octeon_cop2_state *
51248236Shselaskyocteon_cop2_alloc_ctx()
52248236Shselasky{
53248236Shselasky	return uma_zalloc(ctxzone, M_NOWAIT);
54253339Shselasky}
55253339Shselasky
56253339Shselaskyvoid
57248236Shselaskyocteon_cop2_free_ctx(struct octeon_cop2_state *ctx)
58253339Shselasky{
59253339Shselasky	uma_zfree(ctxzone, ctx);
60253339Shselasky}
61253339Shselasky
62253339ShselaskySYSINIT(octeon_cop2, SI_SUB_CPU, SI_ORDER_FIRST, octeon_cop2_init, NULL);
63253339Shselasky